From: Stefan Ring Date: Wed, 17 Sep 2008 11:39:41 +0000 (+0200) Subject: Merged trunk and subtype. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=219e4a46e3d127d3c0883ee2e8635b4fe3c94d60;hp=95476ea581bfcd559a7384003da8e7616f1593c1;p=cacao.git Merged trunk and subtype. --HG-- branch : subtype-trunk rename : src/vm/builtin.c => src/vm/jit/builtin.cpp rename : src/vm/jit/emit-common.c => src/vm/jit/emit-common.cpp rename : src/vm/jit/emit-common.h => src/vm/jit/emit-common.hpp rename : src/vmcore/linker.c => src/vm/linker.c rename : src/vmcore/linker.h => src/vm/linker.h --- diff --git a/.hgignore b/.hgignore index b46a9a618..f1aa443c5 100644 --- a/.hgignore +++ b/.hgignore @@ -56,9 +56,9 @@ tests/*.class tests/regression/*.class tests/regression/assertion/*.class tests/regression/assertion/packagetest/*.class +tests/regression/base/*.class tests/regression/bugzilla/*.class tests/regression/jasmin/*.class -tests/regression/junit/*.class tests/regression/native/*.class tests/regression/native/*.h tests/regression/native/*.so diff --git a/.hgtags b/.hgtags index 734924606..cb0d3f7d5 100644 --- a/.hgtags +++ b/.hgtags @@ -12,3 +12,6 @@ f0bbc765d01fd58f0c42e25de02f059c2f9a9598 cacao-0.95 31f9c3186dded73dab4ed3f519c1cc28940c98dd cacao-0.96 ae597ed07b16e08575c39f88b93004049f663b2b new_instruction_format_branch_point d19da1d8ff91d76df914b1d2455d6faaec4fbcdf unified_variables_branch_point +ce7b6a16a176be6285837629912e8be7fa955086 cacao-0.97 +430cdebdf7d1fb22e8c78fbfadae72b9ee6bc9dd cacao-0.98 +633b9803f4f4067a40edb0d1172516e1e9d3c5b5 cacao-0.99 diff --git a/ChangeLog b/ChangeLog index c26a79c57..048694e0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,834 +1,544 @@ -2007-06-06 09:24 twisti - - * configure.ac (AC_INIT): Changed version to 0.98. - -2007-06-05 23:46 twisti - - * src/native/vm/gnu/java_lang_VMString.c - (native/vm/java_lang_String.h): Added. - (intern): Call _Jv_java_lang_String_intern. - - * src/native/vm/java_lang_String.c: New file. - * src/native/vm/java_lang_String.h: Likewise. - - * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added - java_lang_String.[ch]. - -2007-06-05 22:11 twisti - - * src/native/native.c (native_init): Check nativevm_init return value. - - * src/native/vm/nativevm.c (nativevm_init): Changed signature. - * src/native/vm/nativevm.h (nativevm_init): Likewise. - -2007-06-05 20:58 twisti - - * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): Removed - sun_misc_Unsafe.c. - - * src/native/vm/Makefile.am [ENABLE_JAVASE] (SUN_MISC_UNSAFE_SOURCES): - Added. - (libnativevm_la_SOURCES): Added SUN_MISC_UNSAFE_SOURCES. - - * src/native/vm/gnu/sun_misc_Unsafe.c: Removed. - * src/native/vm/sun_misc_Unsafe.c: Added. - -2007-06-05 12:53 twisti - - * src/vm/jit/codegen-common.c [__ARM__] (md-abi.h): Removed. - (codegen_reg_of_var) [__ARM__]: Removed split-code. - -2007-06-05 10:19 twisti - - * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 8]: Use - reguse instead of i. - -2007-06-05 10:14 twisti - - * src/vm/jit/mips/md-abi.c (md_param_alloc_native) - [SIZEOF_VOID_P == 8]: Fixed compilation. - -2007-06-05 10:06 twisti - - * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 4]: Use - internally a different calling convention. It's the same as on n64 - with register skipping and, but with long alignment (as on ARM). - (md_param_alloc_native) [SIZEOF_VOID_P == 4]: Use the o32 ABI. - - * src/vm/jit/mips/codegen.c (codegen_emit) [SIZEOF_VOID_P == 4]: - Changes for new internal calling conventions. - (codegen_emit_stub_native) [SIZEOF_VOID_P == 4]: Likewise. - - * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [SIZEOF_VOID_P == 4]: - Adjusted reserved stack-space to 4*4. - -2007-06-05 09:00 twisti - - * src/vm/jit/mips/codegen.c (codegen_emit): Use FLTMOVE and DBLMOVE to - save some moves. - -2007-06-05 07:56 twisti - - * src/vm/jit/mips/codegen.c (codegen_emit): Small code-layout change. - -2007-06-05 07:44 twisti - - * src/vm/vm.c: Set Id keyword. - -2007-06-05 07:42 twisti - - * src/vm/vm.c (vmcore/statistics.h): Added. - -2007-06-05 07:40 twisti - - * src/vmcore/statistics.c (count_calls_java_to_native): Added. - (count_calls_native_to_java): Likewise. - (count_native_function_calls): Removed. - (nativeinvokation): Likewise. - (print_stats): Print new variables. - - * src/vmcore/statistics.h (count_calls_java_to_native): Added. - (count_calls_native_to_java): Likewise. - (nativeinvokation): Removed. - - * src/vm/jit/codegen-common.c (codegen_start_native_call) - [ENABLE_STATISTICS]: Increase count_calls_java_to_native. - - * src/vm/vm.c (vm_call_method_vmarg) [ENABLE_STATISTICS]: Increase - count_calls_native_to_java. - (vm_call_method_int_vmarg): Likewise. - (vm_call_method_long_vmarg): Likewise. - (vm_call_method_float_vmarg): Likewise. - (vm_call_method_double_vmarg): Likewise. - -2007-06-04 13:12 twisti - - * src/vm/signal.c (unistd.h): Removed. - (sys/mman.h): Likewise. - (signal_init): Moved mmap of page 0x0 and the hardware-exceptions - check into exceptions_init. - - * src/vm/exceptions.c (unistd.h): Added. - (sys/mman.h): Likewise. - (exceptions_init): See above. - -2007-06-04 12:59 twisti - - * src/vm/signal.c (signal_init): Use if-vm_abort instead of assert. - * src/vm/exceptions.h: Changed hardware-exception comment accordingly. - -2007-06-03 18:42 twisti - - * src/threads/threads-common.c (threads_thread_start_internal): - Changed order of initialization stuff, so we can leave the join-mutex - very early. - (threads_thread_start): Likewise. - - * src/threads/native/threads.c (threads_mutex_join_lock): New - function. - (threads_mutex_join_unlock): Likewise. - (threads_attach_current_thread): Changed order of initialization - stuff, so we can leave the join-mutex very early. - (threads_detach_thread): Send the signal inside the join-mutex. - (threads_join_all_threads): Use join-mutex functions. - - * src/threads/threads-common.h (threads_mutex_join_lock): Added. - (threads_mutex_join_unlock): Likewise. - -2007-06-03 18:24 pm - - * configure.ac: Fix broken regex.h test. - -2007-06-02 17:47 pm - - * contrib/vmlog/vmlogfilter.c: Added a tool that filters a vmlog log - file the same way as -XXfi and -XXfx do. - - * contrib/vmlog/vmlog.c, - contrib/vmlog/vmlog.h (vmlog_thread_log_append): Made not-static. - - * contrib/vmlog/Makefile.am, - configure.ac: Conditional building of vmlogfilter if ENABLE_VMLOG is - set and regex.h present. - -2007-06-01 19:34 ajordan - - * src/vm/signal.c: Added ifdefs to fix compiling with disabled - threads. - -2007-06-01 00:45 ajordan - - * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed the - way - float arguments are preserved over codegen_start_native_call. - * src/vm/jit/sparc64/md-abi.c (codegen_start_native_call): Likewise. - - * src/vm/jit/sparc64/machine-instr.h (compare_and_swap): Changed - inline - assembly, so it survives gcc optimization. - - * src/vm/jit/sparc64/asmpart.S (asm_patcher_wrapper): Saving and - restoring - float return register. - * src/vm/jit/sparc64/md-asm.h: Likewise. - -2007-06-01 00:29 twisti - - * m4/ac_pthreads_implementation.m4: Reverted rev7996. - * m4/threads.m4: Likewise. - - * src/threads/threads-common.c [__LINUX__] - (threads_pthreads_implementation_nptl): Added. - (threads_preinit) [__LINUX__]: Check which thread-implementation we - are using. - - * src/threads/threads-common.h [__LINUX__] - (threads_pthreads_implementation_nptl): Added. - - * src/vm/signal.c (signal_init) [__LINUX__]: Check for - threads_pthreads_implementation_nptl. - - * src/vm/vm.c (vm_create) [__LINUX__]: Likewise. - -2007-05-31 23:26 twisti - - * src/vm/jit/mips/irix/md-os.c (vm/jit/mips/codegen.h): Added. - (md_signal_handler_sigsegv): Updated to new exception-handling. - (thread_restartcriticalsection): Renamed to - md_critical_section_restart. - -2007-05-31 23:05 twisti - - * m4/ac_pthreads_implementation.m4: New file. - - * m4/threads.m4 (AC_CHECK_ENABLE_THREADS): Call - AC_CHECK_PTHREADS_IMPLEMENTATION for posix and linux. - - * configure.ac (AC_CHECK_HEADERS): Added stdlib.h. - (AC_CHECK_FUNCS): Added confstr, strstr. - - * src/vm/signal.c (signal_init) [!PTHREADS_IS_LINUXTHREADS]: Only - block the signals if we are not on LinuxThreads. - (signal_thread): Set state accordingly. - - * src/vm/vm.c (vm_create) [!PTHREADS_IS_LINUXTHREADS]: Only start - signal-thread if we are not on LinuxThreads. - -2007-05-31 22:45 twisti - - * src/vm/signal.c: Reverted rev7978. - -2007-05-31 16:10 twisti - - * src/vm/vm.c (vm_create): Added comment. - -2007-05-30 22:32 twisti - - * src/vm/jit/powerpc64/emit.c (emit_branch): Removed debug output. - -2007-05-30 22:01 twisti - - * NEWS: Added some 0.98 release notes. - -2007-05-30 21:59 twisti - - * ChangeLog: Updated. - * ChangeLog-2006: New file. - -2007-05-30 21:05 twisti - - * src/vm/jit/powerpc/darwin/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-30 21:04 twisti - - * src/vm/jit/powerpc/asmpart.S [ENABLE_REPLACEMENT] (L_replace_me) - (L_replace_build_execution_state, L_replace_free_safestack): Only if - replacement is enabled, otherwise we get a linker error. - -2007-05-30 20:53 twisti - - * src/vm/jit/powerpc/darwin/md-abi.c, - src/vm/jit/powerpc/darwin/md-abi.h: Removed Contact, Authors, Changes - from header. - -2007-05-30 20:51 twisti - - * src/vm/signal.c (signal_thread) [!__DARWIN__]: Don't do the - GC_signum stuff on Darwin (should also be done on Solaris, but let's - wait how the exact-GC is doing). - -2007-05-30 20:45 twisti - - * src/vm/builtin.c (math.h): Removed because we don't need it as we - include fdlibm.h and it does not work on some OSs, like Darwin. - -2007-05-30 20:40 twisti - - * src/mm/boehm-gc/pthread_stop_world.c (GC_signum1, GC_signum2): No it - did not work, reverted rev7981. - -2007-05-30 20:30 twisti - - * src/threads/native/threads.c (threads_impl_preinit): Initialize - mutex_threads_list. - (threads_impl_table_init): Removed. - (threads_impl_table_init, threads_list_unlock): Fixed debug message. - - * src/threads/threads-common.h (threads_impl_table_init): Removed. - -2007-05-30 20:04 twisti - - * src/vm/resolve.c (resolve_subtype_check): Don't free the memory - before it's used. - -2007-05-30 20:01 twisti - - * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Fixed - typo. - - * src/vm/jit/powerpc64/emit.c [!NDEBUG] (emit_verbosecall_enter) - (emit_verbosecall_exit): Only compile conditionally. - -2007-05-30 19:43 twisti - - * src/mm/boehm-gc/pthread_stop_world.c (cacao_suspendhandler): - Commented. - (GC_suspend_handler): Commented cacao_suspendhandler call. - (GC_signum1, GC_signum2): Define for all configurations (hope that - works). - - * src/threads/native/threads.c: Commented all critical-sections code, - as it does not work anyway and it does not compile everywhere. - -2007-05-30 16:01 twisti - - * src/vm/jit/powerpc64/md.c (md_get_method_patch_address): Use - vm_abort and fixed warning. - (md_codegen_get_pv_from_pc): Likewise. - -2007-05-30 15:52 twisti - - * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed --disable-debug - build. - -2007-05-30 14:09 twisti - - * src/vm/signal.c (mm/boehm-gc/include/gc.h): Added. - (GC_suspend_handler): Defined. - (GC_restart_handler): Likewise. - (signal_thread): Add the Boehm-GC signals to the mask and call the - appropriate Boehm-function. This is a workaround for the - Boehm-LinuxThreads bug. - -2007-05-29 12:34 twisti - - * src/vm/signal.c (signal_init): Changed signature. - * src/vm/signallocal.h (signal_init): Likewise. - - * src/vm/vm.c (vm_create): Call signal_init right after gc_init and - check return value. - -2007-05-29 12:22 twisti - - * src/vm/access.c (string.h): Added. - (mm/memory.h): Likewise. - (vmcore/field.h): Likewise. - (vmcore/method.h): Likewise. - (access_check_member): Removed. - (access_check_field): New function. - (access_check_method): Likewise. - - * src/vm/access.h (vmcore/field.h): Added. - (vmcore/method.h): Likewise. - (access_check_member): Removed. - (access_check_field): New function. - (access_check_method): Likewise. - - * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): Call - access_check_method instead of access_check_member. - - * src/native/vm/gnu/java_lang_reflect_Constructor.c (constructNative): - Likewise. - - * src/native/vm/gnu/java_lang_reflect_Field.c - (cacao_get_field_address): Call access_check_field instead of - access_check_member. - -2007-05-29 11:44 pm - - * src/vm/jit/show.c (vm/vm.h) add missing include, - (_no_threads_filterverbosecallctr) fix type: u2 instead of u4 - -2007-05-29 11:30 twisti - - * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed warnings, some - indent. - -2007-05-29 09:03 twisti - - * src/vm/exceptions.c (exceptions_throw_illegalaccessexception): - Changed signature. - * src/vm/exceptions.h: Likewise. - - * src/vm/resolve.c (resolve_class_from_name): Make utf8-string out of - exception message. - (resolve_subtype_check): Likewise. - (resolve_field_verifier_checks): Likewise. - (resolve_method_verifier_checks): Likewise. - -2007-05-28 00:05 ajordan - - * src/vm/jit/sparc64/codegen.h: Removed asserts for stores with sethi. - - * src/vm/jit/sparc64/codegen.c: Added code to fill with nops when a - patcher is right at the - end of a basic block. - - * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method_end): Returning 0 - when an exception occurs. - - * src/vm/jit/sparc64/md.c (md_get_method_patch_address): Improved - handling of mptr loads when - a sethi is involved. - -2007-05-26 15:26 pm - - * contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to - determine endianess. - -2007-05-25 15:23 twisti - - * src/threads/threads-common.c (threads_thread_start_internal) - [WITH_CLASSPATH_CLDC1_1]: Set name to NULL, but this needs a fix. - (threads_thread_print_info) [ENABLE_JAVAME_CLDC1_1]: Set name to - utf_null. - -2007-05-25 15:05 twisti - - * src/vm/jit/optimizing/ifconv.c (vm/vm.h): Added. - (ifconv_static): Fixed warning, use vm_abort. - * src/vm/jit/powerpc/md.c (md_get_method_patch_address): Fixed - warning, use vm_abort. - -2007-05-25 15:03 twisti - - * src/vm/string.c (javastring_new_from_utf_buffer): Made static. - * src/vm/stringlocal.h (javastring_new_from_utf_buffer): Removed. - -2007-05-25 12:41 pm - - * src/vm/jit/show.h (show_filters_init, show_filters_apply, - show_filters_test_verbosecall_enter, - show_filters_test_verbosecall_exit): Added. - * src/vm/jit/show.c: Likewise. - * src/vm/jit/jit.c (jit_compile_intern): Honour filters. - * src/vm/jit/codegen-common.c (codegen_add_patch_ref, - codegen_generate_stub_native): Honour PATCHER_LONGBRANCHES_NOPS if - defined, honour filters. - * src/vm/builtin.c (builtin_trace_exception, - builtin_verbosecall_enter, builtin_verbosecall_exit): Honour filters. - * src/vm/signal.c (signal_init): Register SIGILL handler on s390. - * src/vm/vm.c: Handle -XXfi, -XXfe, -XXfm commandline options. - * src/vm/signallocal.h (md_signal_handler_sigill): Forward declare on - s390. - * src/threads/none/threads.h (_no_threads_filterverbosecallctr, - FILTERVERBOSECALLCTR): Added. - * src/threads/native/threads.h (struct threadobject): Added - filterverbosecallctr. - * src/threads/native/threads.c (threads_impl_thread_new): Initialize - filterverbosecallctr. - * src/threads/critical.c (critical_comparator): On s390, clear bit 32 - of pointer when comparing. - * src/vmcore/options.h (opt_filter_verbosecall_include, - opt_filter_verbosecall_exclude, opt_filter_show_method): Added. - * src/vmcore/options.c: Likewise. - * src/vmcore/method.h (struct methodinfo): Added filtermatches. - * configure.ac: If no NDEBUG and regex.h header is present, define - ENABLE_DEBUG_FILTER. - * src/vm/jit/s390/emit.c, - src/vm/jit/s390/md.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/tests/dacapo.status, - src/vm/jit/s390/patcher.c: Changed a lot. - -2007-05-24 13:25 michi - - * src/vmcore/linker.c (link_class_intern) [__ARM_EABI__]: Fixed field - alignment bug. Double and Long fields are 8-byte aligned with EABI. - -2007-05-24 10:23 twisti - - * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Fixed - warning. - -2007-05-24 10:21 twisti - - * src/threads/threads-common.c (mm/memory.h): Added. - (toolbox/list.h): Likewise. - (threads_table): Removed. - (list_threads, list_threads_free): Added. - (threads_preinit): Initialize lists. - (threads_table_init): Removed. - (threads_table_add): Likewise. - (threads_table_remove): Likewise. - (threads_table_get): Likewise. - (threads_table_get_threads): Likewise. - (threads_table_get_non_daemons): Likewise. - (threads_table_first): Likewise. - (threads_table_next): Likewise. - (threads_table_dump): Likewise. - (threads_list_first): New function. - (threads_list_next): Likewise. - (threads_list_get_non_daemons): Likewise. - (threads_thread_new): Likewise. - (threads_thread_free): Likewise. - (threads_thread_print_info): Added state-assert, print thread index. - (threads_thread_state_runnable): New function. - (threads_thread_state_waiting): Likewise. - (threads_thread_state_timed_waiting): Likewise. - (threads_thread_state_terminated): Likewise. - (threads_dump): Use threads-list functions. - - * src/threads/threads-common.h: Likewise. - (threads_table_entry_t): Removed. - (threads_table_t): Likewise. - - * src/threads/native/threads.c (mutex_threads_table): Renamed to - mutex_threads_list. - (threads_cast_sendsignals): Use threads-list functions. - (threads_table_lock): Renamed to threads_list_lock. - (threads_table_unlock): Renamed to threads_list_unlock. - (threads_startup_thread): Use threads-state functions. - (threads_detach_thread): Likewise. - (threads_wait_with_timeout): Likewise. - (threads_join_all_threads): Use threads-list functions. - - * src/threads/native/threads.h (threadobject): Added linkage. - -2007-05-23 23:56 ajordan - - * src/vm/jit/sparc64/Makefile.am: Added missing emit.h. - -2007-05-23 22:54 ajordan - - * src/vm/jit/sparc64/Makefile.am: - md-asm.h was not properly added to noinst_HEADERS. - -2007-05-23 22:04 twisti - - * configure.ac (AM_INIT_AUTOMAKE): Added dist-bzip2. - -2007-05-23 19:37 twisti - - * src/threads/threads-common.h (THREAD_STATE_NEW) - (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING) - (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Start states - with 1, so we can catch unset states. - -2007-05-23 19:11 twisti - - * src/vm/jit/powerpc64/linux/md-os.c (md_critical_section_restart): - Fixed typo. - -2007-05-23 18:28 twisti - - * src/vm/jit/mips/Makefile.am (DIST_SUBDIRS): Added uclinux. - -2007-05-23 18:08 twisti - - * src/vmcore/statistics.c (statistics_print_memory_usage): Smaller - output changes. - -2007-05-23 18:05 twisti - - * src/vm/jit/arm/linux/md-os.c, - src/vm/jit/alpha/linux/md-os.c, - src/vm/jit/i386/linux/md-os.c, - src/vm/jit/powerpc/linux/md-os.c, - src/vm/jit/powerpc64/linux/md-os.c, - src/vm/jit/x86_64/linux/md-os.c (md_critical_section_restart): Removed - debug output. - -2007-05-23 17:58 twisti - - * src/threads/native/lock.c: Set Id keyword. - * src/threads/native/lock.h: Likewise. - -2007-05-23 17:56 twisti - - * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass): - Return NULL in error case. - -2007-05-23 17:53 twisti - - * src/vm/jit/optimizing/profile.c: Set Id keyword. - -2007-05-23 17:51 twisti - - * src/vm/jit/optimizing/profile.c (profile_thread): Replaced table- - with list-functions. - * src/vm/vm.c (vm_create): Use vm_abort for profile_start_thread. - -2007-05-23 17:46 twisti - - * src/vm/jit/jit.c (jit_compile_intern): Fixed typo. - -2007-05-23 16:00 twisti - - * src/vm/exceptions.c (exceptions_new_hardware_exception): Fixed - warning. - -2007-05-23 15:57 twisti - - * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Fixed warning. - * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): +2008-06-14 Christian Thalinger + + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99. (OPT_CFLAGS): Set + to -O2. + [ea12d8e7f38d] [tip] + + * NEWS: + * NEWS: Added latest 0.99 news. + [3d976222eac4] + + * src/vm/properties.c: + * src/vm/properties.c (properties_set): Changed java.vm.vendor to + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine + CACAO. + [801e8faac4a0] + + * .hgignore, configure.ac, tests/regression/Makefile.am, + tests/regression/base/All.java, tests/regression/base/Makefile.am, + tests/regression/base/TestExceptionInStaticClassInitializer.java, + tests/regression/base/TestPatcher.java, + tests/regression/junit/All.java, tests/regression/junit/Makefile.am, + tests/regression/junit/TestExceptionInStaticClassInitializer.java, + tests/regression/junit/TestPatcher.java: + * .hgignore: Removed tests/regression/junit/*.class, added + tests/regression/base/*.class. + * configure.ac (AC_CONFIG_FILES): Removed + tests/regression/junit/Makefile, added + tests/regression/base/Makefile. + * tests/regression/Makefile.am (SUBDIRS): Removed junit, added base. + * tests/regression/junit/All.java, tests/regression/junit/Makefile.am, + tests/regression/junit/TestExceptionInStaticClassInitializer.java, + tests/regression/junit/TestPatcher.java: Moved from here... + * tests/regression/base/All.java, tests/regression/base/Makefile.am, + tests/regression/base/TestExceptionInStaticClassInitializer.java, + tests/regression/base/TestPatcher.java: ...to here. + [c08a0a544e42] + +2008-06-13 Christian Thalinger + + * configure.ac: + * configure.ac: Bumped _XOPEN_SOURCE version to 600. + [fcabb9585a21] + + * src/vm/builtin.c, tests/regression/bugzilla/All.java, + tests/regression/bugzilla/PR80.java: + Fixes PR80. + * src/vm/builtin.c (builtin_arraycopy): Fixed range checks, cast to + unsigned values. + * tests/regression/bugzilla/All.java (suite): Added PR80. + * tests/regression/bugzilla/PR80.java: New file. + [75bfed30df25] + + * autogen.sh: + * autogen.sh (CACAO_ACLOCAL): Added aclocal-1.10. (CACAO_AUTOMAKE): + Added automake-1.10. + [f1f4b00872fb] + +2008-06-12 Christian Thalinger + + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99rc7. + (AM_INIT_AUTOMAKE): Added tar-ustar for long filename support + (thanks to Mark Wielaard). (OPT_CFLAGS): Only use -g to be portable. + [b35960d5977e] + + * src/vm/vm.c: + * src/vm/vm.c (vm_run): Fixed compiler warning. + [62e3843fdbfa] + + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c: Ported to UNIX03 + (__DARWIN_UNIX03). + [f8847b43a1aa] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (threads_startup_thread) + [__DARWIN__]: Don't register the thread to Boehm-GC, it's not + implemented yet. + [dfff3126e8cb] + + * configure.ac, src/vm/global.h: + * configure.ac (INTRP_CFLAGS, ARCH_CFLAGS): Use -std=c99 instead of + -ansi and bumped _POSIX_C_SOURCE to version 200112L. + (AC_CHECK_HEADERS): Added stdbool.h and stdint.h. + * src/vm/global.h (boolm true, false): Removed. + [f2cd982f6ab5] + + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_store): Removed inline keyword. + [6c549a21d7ec] + + * src/toolbox/set.c, src/toolbox/set.h: + * src/toolbox/set.c (config.h): Added. (vm/global.h): Likewise. + * src/toolbox/set.h (config.h): Likewise. + [7b5a9fbd4309] + + * * Merged with tip. + [e195cdba0d70] + + * configure.ac, m4/dl.m4, m4/ltdl.m4, src/cacao/cacao.c, + src/native/native.c, src/native/native.h, + src/native/vm/gnuclasspath/java_lang_VMRuntime.c, + src/vmcore/system.h: + * configure.ac (AC_CHECK_ENABLE_LTDL): Removed. + (AC_CHECK_ENABLE_DL): Added. + * m4/ltdl.m4: Removed. + * m4/dl.m4: New file. + + * src/cacao/cacao.c [ENABLE_LIBJVM] (ltdl.h): Removed. + (vmcore/system.h): Added. (LIBJVM_NAME): New define. (main): Use + system_dl* functions. + + * src/native/native.c: Replaced ltdl stuff with sytem_dl* stuff. + * src/native/native.h (NATIVE_LIBRARY_PREFIX): New define. + (NATIVE_LIBRARY_SUFFIX): Likewise. + + * src/native/vm/gnuclasspath/java_lang_VMRuntime.c (mapLibraryName): + Use NATIVE_LIBRARY_* defines. + + * src/vmcore/system.h [HAVE_DLFCN_H] (dlfcn.h): Added. + (system_dlclose): New function. (system_dlerror): Likewise. + (system_dlopen): Likewise. (system_dlsym): Likewise. + [9ce78261b91c] + + * src/native/include/Makefile.am: + * src/native/include/Makefile.am (VM_ZIP) [ENABLE_ZLIB]: Added if. + [aba8982958ea] + + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c: Fixed indent. + [377f38200eb2] + + * src/native/jni.c, src/threads/posix/thread-posix.c, + src/threads/posix/thread-posix.h, src/threads/thread.c, + src/threads/thread.h, src/vm/vm.c: + Fixes PR77. + * src/native/jni.c (jni_attach_current_thread): Call + thread_attach_current_external_thread instead of + threads_attach_current_thread. (_Jv_JNI_AttachCurrentThread): + Renamed to jni_AttachCurrentThread. (_Jv_JNI_DetachCurrentThread): + Renamed to jni_DetachCurrentThread, call + thread_detach_current_external_thread instead of + threads_detach_thread. (_Jv_JNI_AttachCurrentThreadAsDaemon): + Renamed to jni_AttachCurrentThreadAsDaemon. + + * src/threads/posix/thread-posix.c (threads_startup_thread) + [ENABLE_GC_BOEHM]: Call GC_register_my_thread. Call + thread_detach_current_thread instead of threads_detach_thread. + (threads_detach_thread): Removed. (thread_detach_current_thread): + New function. + * src/threads/posix/thread-posix.h (threads_detach_thread): Removed. + + * src/threads/thread.c [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): + Added. (threads_attach_current_thread): Renamed to + thread_attach_current_thread. + (thread_attach_current_external_thread): New function. + (thread_detach_current_external_thread): Likewise. + * src/threads/thread.h (threads_attach_current_thread): Removed. + (thread_attach_current_thread): Added. + (thread_attach_current_external_thread): Likewise. + (thread_detach_current_thread): Likewise. + (thread_detach_current_external_thread): Likewise. + + * src/vm/vm.c (vm_run): Call thread_detach_current_thread instead of + threads_detach_thread. (vm_destroy): Call + thread_attach_current_thread instead of + threads_attach_current_thread. + [9aa5016cca58] + +2008-06-12 Stefan Ring + + * .hgtags: + Oops. Corrected cacao-0.97 tag. + [1bcb1eb6f00b] + + * .hgtags: + Added tag cacao-0.98 for changeset 430cdebdf7d1 + [93eb8ccd253b] + + * .hgtags: + Added tag cacao-0.97 for changeset 430cdebdf7d1 + [32222043ce3e] + +2008-06-09 Stefan Ring + + * src/cacaoh/dummy.c, src/vm/builtin.c, src/vm/builtin.h, src/vm/jit + /emit-common.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/emit.h, src/vmcore/class.c, src/vmcore/linker.c, + src/vmcore/linker.h: + * src/vm/builtin.c: Added fast_subtype_check. + (builtin_fast_canstore, builtin_fast_canstore_onedim, + builtin_fast_canstore_onedim_class): Using fast subtype check. Don't + need to lock linker_classrenumber_lock anymore. + * src/vm/builtin.h: Added fast_subtype_check. + + * src/vm/jit/emit-common.h: Added more branch labels. + + * src/vm/jit/x86_64/codegen.c (gen_method): New subtype checking + code. + * src/vm/jit/x86_64/codegen.h: Added some new mnemonics. + * src/vm/jit/x86_64/emit.c: New mnemonics. (emit_classcast_check): New + branch modes. + * src/vm/jit/x86_64/emit.h: New mnemonics. + * src/vmcore/class.c (class_isanysubclass): Using fast_subtype_check. + + * src/vmcore/linker.c: Removed linker_classrenumber_lock. + (build_display): Implemented. (link_class_intern, link_array, + linker_compute_subclasses): Minor changes. + + * src/vmcore/linker.h: Removed linker_compute_subclasses. Added + subtype-related fields to _vftbl. + + * src/cacaoh/dummy.c: Added fast_subtype_check (link dependency). + [f4d2cd262a58] + +2008-06-11 Stefan Ring + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h: + Fixes PR72. + * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Return value + expansion in native stubs (for gcc 4.3). + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Likewise. + + * src/vm/jit/i386/codegen.h: Added more value extension operations. + * src/vm/jit/i386/emit.c: Likewise. + * src/vm/jit/i386/emit.h: Likewise. + * src/vm/jit/x86_64/codegen.h: Likewise. + * src/vm/jit/x86_64/emit.c: Likewise. + * src/vm/jit/x86_64/emit.h: Likewise. + [f4e23a5fb467] + +2008-06-11 Christian Thalinger + + * src/vm/jit/arm/emit.c: + Fixes PR63. + * src/vm/jit/arm/emit.c (emit_verbosecall_enter) [ENABLE_SOFTFLOAT]: + Save and restore floating point types correctly. + [cc3688ed7116] + + * src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h: + * src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h: Fixed comment + type. + [d5092d317d71] + + * tests/havoc.class: + * tests/havoc.class: Removed binary file. + [0ec52c695779] + +2008-06-09 Christian Thalinger + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_GetEnv): Renamed to jni_GetEnv. + [5e61d64d83a9] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_PushLocalFrame): Renamed to + jni_PushLocalFrame, added trace output. (_Jv_JNI_PopLocalFrame): + Renamed to jni_PopLocalFrame. (_Jv_JNI_DeleteLocalRef): Renamed to + jni_DeleteLocalRef. (_Jv_JNI_NewLocalRef): Renamed to + jni_NewLocalRef. (_Jv_JNI_EnsureLocalCapacity): Renamed to + jni_EnsureLocalCapacity. + [b8487bde49f1] + + * src/threads/thread.c: + * src/threads/thread.c (threads_preinit): Check if main thread index + is 1. + [e747bbe9a38e] + + * src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java: + * src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java: + Updated to current GNU Classpath CVS version. + [d6187703cf55] + +2008-06-08 Christian Thalinger + + * * Merged with 7d4cc49cbd31. + [b5d519382b16] + + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99rc6. This reflects + the update to Boehm-GC 7.1. + [a7955e22203b] + + * configure.ac, src/mm/boehm-gc/configure.in, src/mm/boehm- + gc/doc/Makefile.am, src/mm/boehm-gc/gcc_support.c, src/mm/boehm- + gc/include/Makefile.am, src/mm/boehm-gc/include/gc_alloc.h, src/mm + /boehm-gc/include/gc_inl.h, src/mm/boehm- + gc/include/gc_local_alloc.h, src/mm/boehm- + gc/include/private/solaris_threads.h, src/mm/boehm-gc/ltconfig, + src/mm/boehm-gc/pc_excludes, src/mm/boehm- + gc/powerpc_darwin_mach_dep.s, src/mm/boehm-gc/solaris_pthreads.c, + src/mm/boehm-gc/solaris_threads.c, src/mm/boehm- + gc/tests/trace_test.c, src/mm/boehm-gc/version.h: + * Merged with 31f9198caefc. + [fee37d480fb4] + +2008-06-05 Christian Thalinger + + * src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h: + Missed a file again, grrrrrrrrr. + + * src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/mips.h: Patched. + [31f9198caefc] + + * src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/s390.h: + S390 patch applied from Thiemo Seufer. This is also already applied + to bdwgc CVS. + + * src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/s390.h: Patched. + [b5631b6d091a] + + * src/mm/boehm-gc/include/private/gcconfig.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am, src/mm + /boehm-gc/mach_dep.c: + MIPS patches applied from Thiemo Seufer. These are also already + applied to bdwgc CVS. + + * src/mm/boehm-gc/include/private/gcconfig.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am, src/mm + /boehm-gc/mach_dep.c: Patched. + [1386a607d249] + + * src/mm/boehm-gc/Makefile.am: + * src/mm/boehm-gc/Makefile.am (AM_CPPFLAGS): Use libatomic_ops + instead of libatomic_ops-1.2, because only the former is linked into + the build directory. Maybe this should go upstream? + [8157901df4bf] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c: Added a comment why we include + Boehm's gc.h. + [1382eba18ad3] + + * configure.ac, src/mm/boehm-gc/configure.in, src/mm/boehm- + gc/doc/Makefile.am, src/mm/boehm-gc/gcc_support.c, src/mm/boehm- + gc/include/Makefile.am, src/mm/boehm-gc/include/gc_alloc.h, src/mm + /boehm-gc/include/gc_inl.h, src/mm/boehm- + gc/include/gc_local_alloc.h, src/mm/boehm- + gc/include/private/solaris_threads.h, src/mm/boehm-gc/ltconfig, + src/mm/boehm-gc/pc_excludes, src/mm/boehm- + gc/powerpc_darwin_mach_dep.s, src/mm/boehm-gc/solaris_pthreads.c, + src/mm/boehm-gc/solaris_threads.c, src/mm/boehm- + gc/tests/trace_test.c, src/mm/boehm-gc/version.h, src/threads/posix + /thread-posix.c: + * Merged gc7-branch to default. + [71c85ba866cf] + +2008-06-08 Peter Molnar + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.h, + src/vm/jit/optimizing/bytecode_escape.c, + src/vm/jit/optimizing/escape.c, src/vm/jit/optimizing/escape.h: + * src/vm/jit/i386/codegen.c (codegen_emit): Commented out escape + checks. + * src/vm/jit/i386/emit.h: Fixed typo. + * src/vm/jit/optimizing/bytecode_escape.c, + src/vm/jit/optimizing/escape.c, src/vm/jit/optimizing/escape.h: + Added copyright header. + [7d4cc49cbd31] + +2008-06-06 Peter Molnar + + * src/vm/jit/optimizing/escape.h: + * src/vm/jit/optimizing/escape.h: Added forgotten file. + [c8ec78cfd2db] + + * configure.ac, src/vm/global.h, src/vm/jit/asmpart.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h, + src/vm/jit/optimizing/escape.c: + * configure.ac: [ENABLE_SSA] define ENABLE_ESCAPE_CHECK. + * src/vm/global.h [ENABLE_ESCAPE_CHECK] add additional fields to + java_object_t for escape analysis verification. + * src/vm/jit/asmpart.h, src/vm/jit/i386/asmpart.S + [ENABLE_ESCAPE_CHECK] (asm_escape_check): new symbol. + * src/vm/jit/i386/codegen.c [ENABLE_ESCAPE_CHECK] (codegen_emit): + First stetps of annotating all objects with escape information and + checking that information upon every access to an object. + * src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h (emit_escape_check): + New symbol. + * src/vm/jit/optimizing/escape.c (escape_analysis_escape_check): New + symbol. + [348a7d510d11] + +2008-06-05 Christian Thalinger + + * .hgignore, src/mm/boehm-gc/NT_X64_THREADS_MAKEFILE, src/mm/boehm- + gc/include/extra/gc.h, src/mm/boehm-gc/include/extra/gc_cpp.h, + src/mm/boehm-gc/include/gc_version.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/armcc/arm_v6.h, src/mm + /boehm-gc/tests/huge_test.c, src/mm/boehm-gc/tests/smash_test.c, + src/mm/boehm-gc/version.h: + Files missed in the Boehm-GC 7.1 import (sorry). + + * .hgignore: Added src/mm/boehm-gc/.dirstamp. + * src/mm/boehm-gc/NT_X64_THREADS_MAKEFILE: Added. + * src/mm/boehm-gc/include/extra/gc.h, src/mm/boehm- + gc/include/extra/gc_cpp.h, src/mm/boehm-gc/include/gc_version.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/armcc/arm_v6.h, src/mm + /boehm-gc/tests/huge_test.c, src/mm/boehm-gc/tests/smash_test.c: Likewise. - -2007-05-23 15:43 twisti - - * configure.ac (OPT_CFLAGS): Changed to -O2. - -2007-05-23 15:25 twisti - - * src/vm/jit/powerpc64/codegen.c (codegen_emit): ICMD_INSTANCEOF: - Removed unused supervftbl. - - * src/vm/jit/emit-common.h [__POWERPC64__] (emit_bnan): Enabled. - -2007-05-23 14:15 tbfg - - * src/vm/jit/powerpc64/emit.c (MCODECHECK): Increase values to fix - canary corruption. - * src/vm/jit/powerpc64/codegen.c (MCODECHECK): Increase values to fix - canary corruption. - -2007-05-23 13:09 twisti - - * src/vmcore/linker.c (linker_compute_subclasses): We don't ship the - critical-section stuff with this release, since it's broken on some - architectures because of boehm. - -2007-05-23 12:40 twisti - - * src/vm/exceptions.c (threads/lock-common.h): Added. - [ENABLE_THREADS] (threads/native/threads.h): Removed. - [!ENABLE_THREADS] (threads/none/threads.h): Likewise. - (threads/threads-common.h): Added. - (new_exception_message): Removed. - (exceptions_throw_classcircularityerror): Use - exceptions_throw_utf_utf. - (exceptions_throw_classformaterror): Likewise. - (classnotfoundexception_to_noclassdeffounderror): Fixed warning. - (exceptions_throw_incompatibleclasschangeerror): Use - exceptions_throw_utf_utf. - (exceptions_throw_internalerror): Likewise. - (exceptions_throw_unsupportedclassversionerror): Likewise. - (exceptions_throw_verifyerror): Likewise. - (exceptions_throw_verifyerror_for_stack): Likewise. - (exceptions_new_arithmeticexception): Likewise. - (exceptions_new_classcastexception): Use exceptions_new_class_utf. - (exceptions_print_exception): Fixed warnings. - - * src/vmcore/utf8.c (utf_division_by_zero): Added. - (utf8_init): Likewise. - - * src/vmcore/utf8.h (utf_division_by_zero): Likewise. - -2007-05-23 11:59 twisti - - * src/vm/exceptions.c (new_exception_int): Removed. - * src/vm/exceptions.h (new_exception_int): Likewise. - - * src/native/native.c (native_new_and_init_int): Likewise. - * src/native/native.h (native_new_and_init_int): Likewise. - -2007-05-23 09:40 tbfg - - * src/vm/jit/m68k/codegen.c (codegen_emit): Remove NOP after each - ICMD. - Add NOP generation at end of basci block when patcher is longer than - instruction to be patched. - - * src/vm/jit/m68k/patcher.c (patcher_get_putfield): Implemented. - - * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Correct value. - - * src/vm/jit/codegen-common.c (codegen_increase): Enable NOP after - patcher generation at end of basic block. - -2007-05-23 09:37 tbfg - - * src/vm/jit/abi.h (abi_registers_address_name): Added. - (abi_registers_address_argument): Likewise. - (abi_registers_address_saved): Likewise. - (abi_registers_address_temporary): Likewise. - -2007-05-22 11:18 twisti - - * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Replaced - assert with vm_abort. - -2007-05-22 10:07 michi - - * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed - obsolete SPLIT-stuff. - -2007-05-22 07:21 michi - - * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Removed obsolete - SPLIT-stuff. - -2007-05-22 07:00 michi - - * src/vm/jit/arm/md-abi.c (md_param_alloc): Align stack arguments as - well. - * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Use EABI internally. - -2007-05-21 14:42 twisti - - * src/vm/jit/arm/md-abi.c (md_param_alloc): Use EABI internally. - (ALIGN_2): Removed. - - * src/vm/jit/arm/codegen.c (codegen_emit): Removed SPLIT-stuff. - * src/vm/jit/arm/emit.c (emit_store): Likewise. - -2007-05-21 14:40 twisti - - * src/vm/global.h (ALIGN_2): Added. - -2007-05-21 11:45 michi - - * src/vm/jit/arm/codegen.h (M_EORLE): Added. - - * src/vm/jit/arm/codegen.c (codegen_emit): Fixed superindex overflow - for ICMD_INSTANCEOF and ICMD_CHECKCAST. - - * src/vm/jit/arm/patcher.c (patcher_checkcast_instanceof_interface): - Adapted patcher to above changes. - -2007-05-21 08:48 twisti - - * src/native/include/Makefile.am (CLEANFILES): Simply clean an *.h - files. - -2007-05-21 08:27 twisti - - * src/native/jni.c (_Jv_jni_CallLongMethodA): New function. - (_Jv_jni_CallFloatMethodA): Likewise. - (_Jv_jni_CallDoubleMethodA): Likewise. - (_Jv_JNI_CallStaticBooleanMethodA): Implemented. - (_Jv_JNI_CallStaticByteMethodA): Likewise. - (_Jv_JNI_CallStaticCharMethodA): Likewise. - (_Jv_JNI_CallStaticShortMethodA): Likewise. - (_Jv_JNI_CallStaticIntMethodA): Likewise. - (_Jv_JNI_CallStaticLongMethodA): Likewise. - (_Jv_JNI_CallStaticFloatMethodA): Likewise. - (_Jv_JNI_CallStaticDoubleMethodA): Likewise. - -2007-05-18 15:05 twisti - - * src/native/vm/cldc1.1/java_lang_Object.c (getClass): Fixed - signature. - -2007-05-18 14:24 twisti - - * src/vmcore/statistics.c (count_nstub_len): Renamed to - size_stub_native. - (statistics_print_memory_usage): Likewise. - - * src/vmcore/statistics.h: Likewise. - - * src/vm/jit/codegen-common.c (codegen_generate_stub_native): - Likewise, moved statistics-calculation after codegen_finish(), so - actually something is counted. - -2007-05-18 14:22 twisti - - * src/toolbox/list.c (list_create): Use LOCK_INIT_OBJECT_LOCK-macro. - -2007-05-18 14:17 twisti - - * src/threads/threads-common.c (threads_thread_get_state): Fixed - compiler warning. - (threads_thread_is_alive): Likewise. - -2007-05-18 13:45 twisti - - * src/native/vm/cldc1.1/java_lang_String.c (methods): Removed - quick-hack. - - * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace): - Fixed signature. - -2007-05-18 13:12 twisti - - * src/native/native.c (native_tree_native_methods_comparator): Compare - classname, name and descriptor. - (native_method_register): Set all structure members. - (native_method_find): Changed argument-type to methodinfo. - (native_resolve_function): Likewise. - - * src/native/native.h (native_methods_node_t): Added classname and - descriptor, renamed method to function. - - * src/native/vm/gnu/java_lang_VMClass.c: Updated wrong signatures. - * src/native/vm/gnu/java_lang_VMObject.c: Likewise. - * src/native/vm/gnu/java_lang_VMThread.c: Likewise. - * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. - -2007-05-16 09:01 twisti - - * src/native/native.c (native_library_open): New function. - (native_hashtable_library_add): Renamed to native_library_add. - (native_hashtable_library_find): Renamed to native_library_find. - * src/native/native.h: Likewise. - - * src/native/vm/java_lang_Runtime.c (loadLibrary): Use - native_library_open. - -2007-05-16 08:02 twisti - - * src/native/native.c: Removed all native-includes. - (dummynativetable): Removed. - (mainhandle): Likewise. - (native_init): Don't dlopen libjvm, initialize the native-methods - tree. - (native_tree_native_methods_comparator): New function. - (native_method_symbol): Likewise. - (native_method_find): Likewise. - (native_resolve_function): Use native-methods tree for internal native - methods. - - * src/native/native.h (native/jni.h): Added. - (NATIVE_METHODS_COUNT): Defined. - (native_methods_node_t): New structure. - (native_method_register): Added. - - * src/native/vm/nativevm.c: New file. - * src/native/vm/nativevm.h: Likewise. - - * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added - nativevm.[ch]. - - * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, - src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, - src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, - src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, - src/native/vm/cldc1.1/java_lang_Class.c, - src/native/vm/cldc1.1/java_lang_Double.c, - src/native/vm/cldc1.1/java_lang_Float.c, - src/native/vm/cldc1.1/java_lang_Math.c, - src/native/vm/cldc1.1/java_lang_Object.c, - src/native/vm/cldc1.1/java_lang_Runtime.c, - src/native/vm/cldc1.1/java_lang_String.c, - src/native/vm/cldc1.1/java_lang_System.c, - src/native/vm/cldc1.1/java_lang_Thread.c, - src/native/vm/cldc1.1/java_lang_Throwable.c, + * src/mm/boehm-gc/version.h: Removed. + [0340b2f6a236] + + * src/mm/boehm-gc/configure.ac, src/mm/boehm- + gc/libatomic_ops-1.2/configure.ac: + * src/mm/boehm-gc/configure.ac: Made autogen.sh warning free. + * src/mm/boehm-gc/libatomic_ops-1.2/configure.ac: Likewise. + [7256403a4a32] + + * src/mm/boehm-gc/ChangeLog, src/mm/boehm-gc/Makefile.am, src/mm + /boehm-gc/Makefile.direct, src/mm/boehm-gc/Makefile.dj, src/mm + /boehm-gc/NT_X64_STATIC_THREADS_MAKEFILE, src/mm/boehm- + gc/add_gc_prefix.c, src/mm/boehm-gc/allchblk.c, src/mm/boehm- + gc/alloc.c, src/mm/boehm-gc/backgraph.c, src/mm/boehm- + gc/configure.ac, src/mm/boehm-gc/darwin_stop_world.c, src/mm/boehm- + gc/dbg_mlc.c, src/mm/boehm-gc/doc/README, src/mm/boehm- + gc/doc/README.macros, src/mm/boehm-gc/doc/README.win32, src/mm + /boehm-gc/doc/README.win64, src/mm/boehm-gc/doc/gcinterface.html, + src/mm/boehm-gc/doc/scale.html, src/mm/boehm-gc/dyn_load.c, src/mm + /boehm-gc/finalize.c, src/mm/boehm-gc/gc_cpp.cc, src/mm/boehm- + gc/gcname.c, src/mm/boehm-gc/headers.c, src/mm/boehm- + gc/include/gc.h, src/mm/boehm-gc/include/gc_cpp.h, src/mm/boehm- + gc/include/gc_inline.h, src/mm/boehm-gc/include/gc_tiny_fl.h, src/mm + /boehm-gc/include/include.am, src/mm/boehm- + gc/include/private/gc_locks.h, src/mm/boehm- + gc/include/private/gc_pmark.h, src/mm/boehm- + gc/include/private/gc_priv.h, src/mm/boehm- + gc/include/private/gcconfig.h, src/mm/boehm- + gc/include/private/thread_local_alloc.h, src/mm/boehm- + gc/libatomic_ops-1.2/ChangeLog, src/mm/boehm- + gc/libatomic_ops-1.2/doc/README.txt, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/generalize.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/powerpc.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86_64.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/standard_ao_double_t.h, + src/mm/boehm-gc/mach_dep.c, src/mm/boehm-gc/malloc.c, src/mm/boehm- + gc/mark.c, src/mm/boehm-gc/mark_rts.c, src/mm/boehm-gc/misc.c, + src/mm/boehm-gc/msvc_dbg.c, src/mm/boehm-gc/obj_map.c, src/mm/boehm- + gc/os_dep.c, src/mm/boehm-gc/pthread_stop_world.c, src/mm/boehm- + gc/pthread_support.c, src/mm/boehm-gc/reclaim.c, src/mm/boehm- + gc/tests/test.c, src/mm/boehm-gc/tests/tests.am, src/mm/boehm- + gc/thread_local_alloc.c, src/mm/boehm-gc/typd_mlc.c, src/mm/boehm- + gc/win32_threads.c: + * Imported Boehm-GC 7.1. + [a09ac5792898] + + * .hgignore: + * .hgignore: Added src/mm/boehm-gc/atomic_ops.c, src/mm/boehm- + gc/atomic_ops_sysdeps.S, src/mm/boehm-gc/bdw-gc.pc, src/mm/boehm- + gc/libatomic_ops, src/mm/boehm-gc/cord/.dirstamp. + [c0c33aa59df7] + + * configure.ac, src/mm/boehm-gc/Makefile.am, src/mm/boehm- + gc/cord/cord.am: + * configure.ac (ac_configure_args): Removed --disable-shared, add + --disable-static. + * src/mm/boehm-gc/Makefile.am (lib_LTLIBRARIES): Renamed to + noinst_LTLIBRARIES. + * src/mm/boehm-gc/cord/cord.am: Likewise. + [ded63b659817] + +2008-06-01 Peter Molnar + + * configure.ac, src/vm/global.h, src/vm/jit/cfg.c, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/optimizing/Makefile.am, + src/vm/jit/optimizing/bytecode_escape.c, + src/vm/jit/optimizing/escape.c, src/vm/jit/optimizing/ssa3.c, + src/vmcore/method.h: + * configure.ac: Define ENABLE_ESCAPE if ENABLE_SSA is defined. + * src/vm/global.h (ACC_METHOD_EA): new symbol. + * src/vm/jit/cfg.c (cfg_add_root): correctly initialize method member + of basicblock. + * src/vm/jit/jit.c (basicblock) [ENABLE_SSA]: new members phis and + phicount. + * src/vm/jit/jit.h (jit_compile_intern): Transform exception handlers + only if -lsra is given. + * src/vm/jit/optimizing/Makefile.am: Adpated. + * src/vm/jit/optimizing/bytecode_escape.c: New file. Implementation of + escape analysis on bytecode. + * src/vm/jit/optimizing/escape.c: Changed a lot. + * src/vm/jit/optimizing/ssa3.c: Changed a lot. + * src/vmcore/method.h (methodinfo) [ENABLE_ESCAPE]: New member + paramescape. + [76f979c4a7dc] + +2008-05-19 Christian Thalinger + + * m4/classpath.m4, src/classes/gnu/gnu/classpath/VMStackWalker.java, + src/classes/gnu/gnu/classpath/VMSystemProperties.java, + src/classes/gnu/gnu/java/lang/CPStringBuilder.java, + src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java, + src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/classes/gnu/java/lang/VMClassLoader.java, + src/classes/gnu/java/lang/VMString.java, + src/classes/gnu/java/lang/VMThread.java, + src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java, + src/classes/gnu/java/lang/reflect/Modifier.java, + src/classes/gnu/java/lang/reflect/VMConstructor.java, + src/classes/gnu/java/lang/reflect/VMField.java, + src/classes/gnu/java/lang/reflect/VMMethod.java, + src/classes/gnu/java/security/VMAccessController.java, + src/classes/gnu/sun/misc/Unsafe.java, + src/classes/gnu/sun/reflect/ConstantPool.java, + src/classes/gnu/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas + ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy. + java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE + xceptionProxy.java, + src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas + ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c, + src/native/vm/gnu/VMjdwp.h, src/native/vm/gnu/gnu_classpath_VMStackWalker.c, src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, - src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, + src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, src/native/vm/g + nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, @@ -841,5018 +551,4811 @@ src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/gnu/java_lang_management_VMManagementFactory.c, - src/native/vm/gnu/java_lang_reflect_Constructor.c, - src/native/vm/gnu/java_lang_reflect_Field.c, - src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMConstructor.c, + src/native/vm/gnu/java_lang_reflect_VMField.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c, src/native/vm/gnu/java_lang_reflect_VMProxy.c, src/native/vm/gnu/java_security_VMAccessController.c, - src/native/vm/gnu/sun_misc_Unsafe.c: Added methods table and init - function to register the native methods. - -2007-05-15 10:32 tbfg - - * src/vm/jit/powerpc64/patcher.c - (patcher_resolve_classref_to_classinfo): Patch back original code. - - (patcher_resolve_classref_to_vftbl): Likewise. - (patcher_resolve_classref_to_flags): Likewise. - - * src/vm/jit/powerpc64/asmpart.S (DARWIN): Removed all darwin - ifdefed code for readability. Needs to be ported carefully anyways. - - (asm_vm_call_method): When handling arguments treat address type as - long. - -2007-05-15 09:55 christian - - * src/vm/jit/codegen-common.c: (codegen_emit_phi_moves): Added. - (Former - codegen_insert_phi_moves from codegen.c) - - * src/vm/jit/codegen-common.h: Function prototype for - codegen_emit_phi_moves - added. - - * src/vm/jit/optimizing/lsra.c: Adapted to new instruction format and - unified + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/openjdk/jvm.c, src/native/vm/sun/Makefile.am, + src/native/vm/sun/hpi.c, src/native/vm/sun/hpi.h, + src/native/vm/sun/jvm.c: + * Merged with tip. + [b3b00c455d2b] + +2008-05-08 Christian Thalinger + + * src/vm/jit/m68k/linux/md-os.h, tests/regression/HelloWorld.java, + tests/regression/codepatching/Makefile.am, + tests/regression/codepatching/aastoreconstClass.java, + tests/regression/codepatching/checkcastC.java, + tests/regression/codepatching/checkcastI.java, + tests/regression/codepatching/getfieldD.java, + tests/regression/codepatching/getfieldF.java, + tests/regression/codepatching/getfieldI.java, + tests/regression/codepatching/getfieldJ.java, + tests/regression/codepatching/getfieldL.java, + tests/regression/codepatching/getstaticD.java, + tests/regression/codepatching/getstaticF.java, + tests/regression/codepatching/getstaticI.java, + tests/regression/codepatching/getstaticJ.java, + tests/regression/codepatching/getstaticL.java, + tests/regression/codepatching/instanceofC.java, + tests/regression/codepatching/instanceofI.java, + tests/regression/codepatching/invokespecial.java, + tests/regression/codepatching/invokestatic.java, + tests/regression/codepatching/multianewarray.java, + tests/regression/codepatching/newarray.java, + tests/regression/codepatching/putfieldD.java, + tests/regression/codepatching/putfieldF.java, + tests/regression/codepatching/putfieldI.java, + tests/regression/codepatching/putfieldJ.java, + tests/regression/codepatching/putfieldL.java, + tests/regression/codepatching/putfieldconstC.java, + tests/regression/codepatching/putfieldconstD.java, + tests/regression/codepatching/putfieldconstF.java, + tests/regression/codepatching/putfieldconstI.java, + tests/regression/codepatching/putfieldconstJ.java, + tests/regression/codepatching/putfieldconstL.java, + tests/regression/codepatching/putstaticD.java, + tests/regression/codepatching/putstaticF.java, + tests/regression/codepatching/putstaticI.java, + tests/regression/codepatching/putstaticJ.java, + tests/regression/codepatching/putstaticL.java, + tests/regression/codepatching/putstaticconstC.java, + tests/regression/codepatching/putstaticconstD.java, + tests/regression/codepatching/putstaticconstF.java, + tests/regression/codepatching/putstaticconstI.java, + tests/regression/codepatching/putstaticconstJ.java, + tests/regression/codepatching/putstaticconstL.java, + tests/regression/codepatching/test.java, + tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j, + tests/regression/jasmin/test_verify_fail_jsr_recursion.j, + tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j: + * Merged with tip. + [b0f1bca06030] + +2008-04-26 Christian Thalinger + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetEnclosingMethodInfo): Use + class_get_enclosingmethod_raw instead of class_get_enclosingmethod. + [14d10bd7f425] + +2008-05-15 Stefan Ring + + * src/classes/gnuclasspath/java/lang/.VMClassLoader.java.swp: + * src/classes/gnuclasspath/java/lang/.VMClassLoader.java.swp: + Removed. How did this get in? + [7c99307ac907] + +2008-05-14 Peter Molnar + + * m4/classpath.m4, src/classes/gnu/gnu/classpath/VMStackWalker.java, + src/classes/gnu/gnu/classpath/VMSystemProperties.java, + src/classes/gnu/gnu/java/lang/CPStringBuilder.java, + src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java, + src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/classes/gnu/java/lang/VMClassLoader.java, + src/classes/gnu/java/lang/VMString.java, + src/classes/gnu/java/lang/VMThread.java, + src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java, + src/classes/gnu/java/lang/reflect/Modifier.java, + src/classes/gnu/java/lang/reflect/VMConstructor.java, + src/classes/gnu/java/lang/reflect/VMField.java, + src/classes/gnu/java/lang/reflect/VMMethod.java, + src/classes/gnu/java/security/VMAccessController.java, + src/classes/gnu/sun/misc/Unsafe.java, + src/classes/gnu/sun/reflect/ConstantPool.java, + src/classes/gnu/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas + ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy. + java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE + xceptionProxy.java, + src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas + ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/classes/gnuclasspath/java/lang/.VMClassLoader.java.swp, + src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c, + src/native/vm/gnu/VMjdwp.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, + src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, src/native/vm/g + nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_VMConstructor.c, + src/native/vm/gnu/java_lang_reflect_VMField.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/sun/Makefile.am, src/native/vm/sun/hpi.c, + src/native/vm/sun/hpi.h, src/native/vm/sun/jvm.c, src/vm/jit/jit.c: + Merging 8179. + [e1df59a7c5b8] + + * src/vm/jit/cfg.c, src/vm/jit/optimizing/ssa3.c: + * src/vm/jit/cfg.c: Changed all occurences of class to clazz. + * src/vm/jit/optimizing/ssa3.c: Removed accidentally forgotten diff + marker resulting from previous merge. + [3497103d748b] + + * src/vm/jit/allocator/simplereg.c, src/vm/jit/cfg.c, + src/vm/jit/i386/codegen.c, src/vm/jit/icmdtable.inc, + src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa3.c, src/vm/jit/show.c: + * src/vm/jit/allocator/simplereg.c (simplereg_allocate_temporaries): + Support for ICMD_GETEXCEPTION. + * src/vm/jit/cfg.c (cfg_eliminate_edges_to_unreachable, + cfg_calculate_reachability, cfg_remove_predecessors, + cfg_eliminate_edges_to_unreachable): new functions. + * src/vm/jit/i386/codegen.c [ENABLE_SSA] (codegen_emit): Don't copy + itmp1 into invar 1 in exh blocks. + * src/vm/jit/icmdtable.inc (ICMD_GETEXCEPTION, ICMD_PHI): new opcodes. + * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_SSA]: Normalizing + exception handlers before SSA transformation. + * src/vm/jit/jit.h (var_is_inout): Correctly handling TYPE_RET variables. - - * src/vm/jit/optimizing/lsra.h: Likewise. - - * src/vm/jit/optimizing/ssa.c: Likewise. - - * src/vm/jit/optimizing/ssa.h: Likewise. - - * src/vm/jit/optimizing/graph.c: Likewise. - - * src/vm/jit/optimizing/graph.h: Likewise. - - * src/vm/jit/optimizing/dominators.c: Likewise. - - * src/vm/jit/optimizing/lifetimes.c: Likewise and changed lifetime - anaylsis to - a worklist algorithmus. - - * src/vm/jit/optimizing/lifetimes.h: Likewise. - - * src/vm/jit/i386/codegen.c: (codegen_insert_phi_moves): Moved to - src/vm/jit/codegen-common.c codegen_emit_phi_moves - (codegen_emit): Necessary Adaptions for SSA. - - * src/toolbox/worklist.c: (wl_reset): Added. - - * src/toolbox/worklist.h: Function Prototype for wl_reset added. - - * src/vm/jit/stack.c: Removed old SSA specific code. - -2007-05-15 09:25 tbfg - - * builtin.c (builtin_ldiv): Needed when DISABLE_GC. - -2007-05-14 17:25 twisti - - * src/native/native.c (native_class_getdeclaredannotations): Removed. - -2007-05-14 14:11 twisti - - * src/toolbox/list.c (list_add_first): Call list_add_first_unsynced. - (list_add_first_unsynced): New function. - * src/toolbox/list.h (list_add_first_unsynced): Added. - -2007-05-14 13:29 twisti - - * src/threads/threads-common.c (threads_create_thread): Renamed to - threads_thread_new. - (threads_thread_free): New function. - (threads_preinit): Renamed threads_create_thread to - threads_thread_new. - (threads_thread_start_internal): Likewise. - (threads_thread_start): Likewise. - - * src/threads/threads-common.h (threads_create_thread): Renamed to - threads_thread_new. - (threads_thread_free): Added. - (threads_init_threadobject): Renamed to threads_impl_thread_new. - (threads_impl_thread_free): Added. - - * src/threads/native/threads.c (toolbox/avl.h): Removed. - (threadattr): Likewise. - (threads_init_threadobject): Renamed to threads_impl_thread_new. - (threads_impl_thread_free): New function. - (threads_init): Use local pthread_attr_t. - (threads_impl_thread_start): Use pthread_attr_setdetachstate (fixes - memory leak), check more return values of pthread-calls. - (threads_attach_current_thread): Renamed threads_create_thread to - threads_thread_new. - (threads_detach_thread): Removed lock-record pools comment, call - threads_thread_free. - -2007-05-14 11:15 tbfg - - * src/vm/jit/dseg.h (dseg_adddata): Removed warning due to typo. - - * src/vm/jit/m68k/arch.h (SUPPORT_LONG) Defined. - (SUPPORT_LONG_ADD): Defined. - (SUPPORT_CONST_LOGICAL): Defined. - - * src/vm/jit/m68k/codegen.c (ICMD_LADD): Implemented. - (ICMD_LADDCONST): Implemented. - (ICMD_LSUB): Implemented. - (ICMD_LSUBCONST): Implemented. - (ICMD_LNEG): Implemented. - - * src/vm/jit/m68k/codegen.h (M_ISUBX): Added. - (M_INEGX): Added. - -2007-05-11 22:33 twisti - - * configure.ac (AC_CHECK_HEADERS): Added time.h. - (AC_CHECK_FUNCS): Added localtime, localtime_r, time. - - * src/vmcore/statistics.c [HAVE_TIME_H] (time.h): Added. - (statistics_print_date): New function. - * src/vmcore/statistics.h (statistics_print_date): Added. - - * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: Call - statistics_print_date. - -2007-05-11 21:18 twisti - - * src/vmcore/statistics.c (statistics_print_memory_usage): Use - log_println instead of printf. - -2007-05-11 20:35 twisti - - * src/vm/jit/arm/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - - * src/vm/jit/arm/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-11 19:31 twisti - - * src/threads/threads-common.c (threads_create_thread): Removed - lock_init_execution_env. - - * src/threads/lock-common.h (lock_init_execution_env): Removed. - (lock_record_free_pools): Likewise. - - * src/threads/native/threads.h (threadobject): Removed ee. - - * src/threads/native/lock.c (vm/finalizer.h): Added. - [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): Likewise. - (lock_global_pool): Removed. - (lock_global_pool_lock): Likewise. - (lock_init): Don't initialize lock_global_pool_lock. - (lock_record_init): Removed. - (lock_init_execution_env): Likewise. - (lock_record_alloc_new_pool): Likewise. - (lock_record_alloc_pool): Likewise. - (lock_record_free_pools): Likewise. - (lock_record_alloc): Likewise. - (lock_record_recycle): Likewise. - (lock_hashtable_get_lock_record): Renamed to lock_hashtable_get. - (lock_record_new): New function. - (lock_record_free): Likewise. - (lock_hashtable_remove): Likewise. - [ENABLE_GC_BOEHM] (lock_record_finalizer): Likewise. - - * src/threads/native/lock.h (lock_execution_env_t): Removed. - (lock_record_pool_header_t): Likewise. - (lock_record_pool_t): Likewise. - (lock_record_t): Renamed obj to object, removed nextfree. - [ENABLE_JVMTI] (lock_global_pool_lock, lock_global_pool): Removed. - - * src/vmcore/statistics.c (size_lock_record_pool): Renamed to - size_lock_record. - (statistics_print_memory_usage): Likewise. - * src/vmcore/statistics.h: Likewise. - -2007-05-11 18:58 tbfg - - * src/vm/jit/m68k/linux/md-abi.h (ADR_SAV_CNT): Increased by one - (%fp). - (ADR_RES_CNT): Decreased by one (%fp). - - * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Declared %fp a - REG_SAV. - - * src/vm/jit/m68k/arch.h (SUPPORT_DIVISION): Defined. - - - * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Additional - logic to restore %fp when unwinding the stack. - -2007-05-11 18:23 twisti - - * src/threads/native/threads.h (threadobject): Removed next and prev. - -2007-05-11 17:15 tbfg - - * src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize - allocation in not synchronized methods which call a builtin returning - a double. Merged with ENABLE_THREADS case. - Added code to copy interface registers. - - * src/vm/jit/m68k/asmpart.S (asm_handle_exception): - Save temporary registers, dunno if really needed, but its a - slow path anyways. - -2007-05-10 14:34 tbfg - - * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Make SOFTFLOAT - clean. - (emit_verbosecall_exit): Likewise. - - * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Mark comment about - gcc abi wiredness. - - * src/vm/jit/m68k/codegen.h (M_D2F): Fixed. - (M_F2D): Fixed. - -2007-05-10 14:04 twisti - - * src/vmcore/options.c (opt_verbosethreads): Added. - * src/vmcore/options.h (opt_verbosethreads): Likewise. - - * src/vm/vm.c (XXusage): Added -verbose:threads. - (vm_create): Likewise. - - * src/threads/threads-common.c (threads_create_thread): Renamed - variable thread to t. - (threads_thread_print_info): New function. - (threads_dump): Use threads_thread_print_info. - - * src/threads/threads-common.h (threads_thread_print_info): Added. - - * src/threads/native/threads.c (threads_init) [!NDEBUG]: Added - -verbose:threads debug-output. - (threads_startup_thread): Likewise. - (threads_attach_current_thread): Likewise. - (threads_detach_thread): Likewise. - -2007-05-10 13:27 twisti - - * src/threads/threads-common.c (threads_thread_start_internal): Set - thread-flags. - (threads_thread_start): Likewise. - - * src/threads/native/threads.c (threads_startup_thread): Don't set - thread-flags. - -2007-05-10 12:50 tbfg - - * src/vm/jit/powerpc64/patcher.c (patcher_checkcast_interface): - Fixed not flushing all bytes written. - -2007-05-09 16:37 tbfg - - * src/vm/jit/powerpc64/codegen.c (ICMD_CHECKCAST): Use - branch_label_* instead of harcoded jump offsets. - - (ICMD_INSTANCEOF): Likewise. - -2007-05-09 16:05 twisti - - * src/lib/Makefile.am (VM_JAVA_FILES): Renamed vm/reference/ to gnu/. - - * src/lib/vm: Removed. - * src/lib/gnu: Added. - * src/lib/gnu/java: Likewise. - * src/lib/gnu/gnu: Likewise. - -2007-05-09 08:52 tbfg - - * src/vm/jit/m68k/linux/md-abi.h (LA_SIZE_IN_POINTERS): Defined 0. - (PA_SIZE_IN_POINTERS): Removed. - (PA_SIZE): Removed. - (LA_LR_OFFSET): Removed. - (LA_SIZE_ALIGNED): Removed. - - * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Removed - linking instructions, save only used registers. - - (emit_verbosecall_exit): Likewise. - - * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Depends on - configure option ENABLE_SOFTFLOAT. - - * src/vm/jit/m68k/codegen.c (codegen_emit): Use M_FSTORE/M_FLOAT - to save/restore float registers without converting any values. - Fixed offset of IsSync. - - (codegen_emit_stub_native): Move floating point return values - into floating point registers. - - * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Save/restore - floating point registers. - - (asm_call_jit_compiler): Save/restore volatile floating point - registers. - - (asm_patcher_wrapper): Likewise. - - (asm_handle_exception): Use fmovemd instructions to restore - floatng point registers without converting. - - * src/vm/jit/m68k/codegen.h (M_FSTORE): Added. - (M_FLOAT): Added. - -2007-05-09 08:36 tbfg - - * src/vm/jit/powerpc64/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - - * src/vm/jit/powerpc64/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - -2007-05-08 13:03 twisti - - * src/configure.ac (AC_CHECK_HEADERS): Added string.h. - (AC_CHECK_FUNCS): Added strdup. - - * src/src/vmcore/options.c [HAVE_STRING_H] (string.h): Added #ifdef. - (options_get) HAVE_STRDUP]: Added. - -2007-05-07 21:34 twisti - - * src/vm/jit/alpha/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - - * src/vm/jit/alpha/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-07 21:29 twisti - - * src/threads/native/threads.c (mainthreadobj): Removed. - * src/threads/native/threads.h (mainthreadobj): Likewise. - - * src/vm/jit/optimizing/profile.c (threads/native/threads.h): - Likewise. - (profile_thread): Rewritten thread iteration. - -2007-05-07 15:07 ajordan - - * src/vm/jit/sparc64/codegen.c (codegen_emit): Adapted to critical - section renames. - * src/vm/jit/sparc64/linux/md-os.c: Likewise. - -2007-05-07 14:26 tbfg - - * src/vm/jit/m68k/codegen.c (ICMD_FNEG): Implemented. - (ICMD_DNEG): Implemented. - - * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): - Store volatile floatregisters. - (asm_patcher_wrapper): Likewise. - (asm_handle_exception): Restore float registers. - - * src/vm/jit/m68k/codegen.h (M_FNEG): Added. - (M_DNEG): Added. - -2007-05-07 14:23 tbfg - - * tests/exception_restore_registers.java: New test, tests if - variables get restored in case of exceptions. - - * tests/exception_restore_registers.output: New file, expected - output. - - * tests/Makefile.am: Added exception_restore_registers target. - -2007-05-07 14:16 twisti - - * configure.ac (AC_CONFIG_FILES): Added - src/vm/jit/mips/uclinux/Makefile. - - * src/vm/jit/mips/uclinux: New directory. - * src/vm/jit/mips/uclinux/md-os.c: New file. - * src/vm/jit/mips/uclinux/Makefile.am: Likewise. - -2007-05-07 14:13 twisti - - * src/vm/jit/mips/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - - * src/vm/jit/mips/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-07 13:45 twisti - - * configure.ac (AC_CHECK_HEADERS): Added sys/mman.h, sys/resource.h. - (AC_CHECK_FUNCS): Added getrusage, mprotect. - - * src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include - conditionally. - [HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise. - (getcputime) [!HAVE_GETRUSAGE]: Return 0. - -2007-05-07 13:31 twisti - - * src/native/vm/java_lang_Thread.h (threads/native/threads.h): - Removed. - -2007-05-07 13:02 tbfg - - * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Enabled. - (SUPPORT_FLOAT_CMP): Enabled. - (SUPPORT_DOUBLE): Enabled. - (SUPPORT_DOUBLE_CMP): Enabled. - - * src/vm/jit/m68k/codegen.c (ICMD_FCMPL): Implemented. - (ICMD_DCMPL): Likewise. - (ICMD_FCMPG): Likewise. - (ICMD_DCMPG): Likewise. - (ICMD_FMUL): Likewise. - (ICMD_DMUL): Likewise. - (ICMD_FDIV): Likewise. - (ICMD_DDIV): Likewise. - (ICMD_FADD): Likewise. - (ICMD_DADD): Likewise. - (ICMD_FSUB): Likewise. - (ICMD_DSUB): Likewise. - (ICMD_F2D): Likewise. - (ICMD_D2F): Likewise. - (ICMD_BUILTIN): Handle float return values. - (codegen_emit_stub_native): Handle float values. - - * src/vm/jit/m68k/codegen.h (M_FCMP): Added. - (M_BFEQ): Added. - (M_BFLT): Added. - (M_BFGT): Added. - (M_BFUN): Added. - (M_FADD): Added. - (M_DADD): Added. - (M_FSUB): Added. - (M_DSUB): Added. - (M_FMUL): Added. - (M_DMUL): Added. - (M_FDIV): Added. - (M_DDIV): Added. - (M_D2F): Added. - (M_F2D): Added. - -2007-05-07 11:37 twisti - - * src/threads/threads-common.c (threads_dump): Typo. - -2007-05-07 11:35 twisti - - * src/threads/threads-common.c (threads_table_get): Made static and - removed table lock. - (threads_dump): Lock threads table. - - * src/threads/threads-common.h (threads_table_get): Removed. - - * src/threads/native/threads.c (threads_cast_stopworld): Lock threads - table. - (threads_cast_startworld): Likewise. - -2007-05-07 01:44 ajordan - - * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed fp - arg passing. - * src/vm/jit/sparc64/md-abi.h: Likewise. - - * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Likewise, but - the other way around. - * src/vm/jit/sparc64/md-asm.h: Likewise. - -2007-05-06 22:20 tbfg - - * src/vm/jit/m68k/codegen.c (codegen_emit): Allocate 2 additional - words in stackframe for long to double conversion. - - * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Copy exception - object into correct register. - - * src/vm/jit/m68k/codegen.h (M_FLD): Implemented. - (M_DLD): Likewise. - (M_FST): Likewise. - (M_DST): Likewise. - (M_FLTMOVE): Likewise. - (M_INT2FLTMOVE): Likewise. - (M_DBLMOVE): Likewise. - (FCONST): Likewise. - -2007-05-06 13:32 ajordan - - * src/vm/jit/sparc64/codegen.c: Implemented threads support. - * src/vm/jit/sparc64/machine-instr.h: Likewise. - * src/vm/jit/sparc64/linux/md-os.c: Likewise. - -2007-05-05 13:48 tbfg - - * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Add thread - support. - (emit_exception_check_areg): Removed dead code. - - * src/vm/jit/m68k/codegen.c (codegen_emit): Add thread support. - - * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Likewise. - -2007-05-05 13:46 tbfg - - * linker.c (linker_compute_subclasses): - threads_cast_[start|stop]world only available when using GC. - -2007-05-05 08:08 pm - - * contrib/vmlog/Makefile.am (AM_CPPFLAGS): Add include directories - for vmlog. - * src/vm/Makefile.am: Likewise. - -2007-05-04 10:13 tbfg - - * linker.c (linker_compute_subclasses): Only call - threads_cast_[start|stop]world when ENABLE_THREADS. - -2007-05-03 23:31 tbfg - - * src/vm/jit/m68k/md.c (md_stacktrace_get_returnaddress): Removed - braindead address check and fixed the real bug. - - * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Added float - argument handling. - (asm_call_jit_compiler): Fixed stack offset bug. - -2007-05-03 22:32 twisti - - * src/vm/jit/x86_64/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - - * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-03 21:29 twisti - - * src/vm/jit/i386/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - - * src/vm/jit/i386/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-03 21:17 twisti - - * src/threads/critical.c (critical_compare): Renamed to - critical_comparator. - (critical_find): Removed. - (critical_register_critical_section): Renamed to - critical_section_register. - (critical_find_restart_point): Call avl_find. - (critical_register_asm_critical_sections): Call - critical_section_register. - - * src/threads/critical.h (critical_section_node_t): Renamed members. - (thread_restartcriticalsection): Renamed to - md_critical_section_restart. - - * src/threads/native/threads.c (threads_cast_darwinstop): Call - md_critical_section_restart. - (threads_sigsuspend_handler): Likewise. - - * src/vmcore/linker.c (linker_compute_subclasses): Call - threads_cast_{start,stop}world, removed LOCK_MONITOR_{ENTER,EXIT}. - - * src/cacaoh/dummy.c (threads_cast_stopworld): Added. - (threads_cast_startworld): Likewise. - - * src/vm/jit/codegen-common.c (codegen_setup): Setup listcritical. - (codegen_reset): Likewise. - (codegen_critical_section_new): New function. - (codegen_critical_section_start): Likewise. - (codegen_critical_section_end): Likwise. - (codegen_critical_section_finish): Likewise. - (codegen_finish): Call codegen_critical_section_finish. - (codegen_threadcritrestart): Removed. - (codegen_threadcritstart): Likewise. - (codegen_threadcritstop): Likewise. - - * src/vm/jit/codegen-common.h (codegen_critical_section_t): Renamed to - critical_section_ref_t. - (codegendata): Added listcritical, removed threadcrit, - threadcritcurrent and threadcritcount. - (CODEGEN_CRITICAL_SECTION_NEW, CODEGEN_CRITICAL_SECTION_START) - (CODEGEN_CRITICAL_SECTION_END): Defined. - - * src/vm/jit/powerpc/codegen.c (codegen_emit): Use - CODEGEN_CRITICAL_SECTION_* macros. - - * src/vm/jit/powerpc/linux/md-os.c (thread_restartcriticalsection): - Renamed to md_critical_section_restart. - -2007-05-03 20:58 twisti - - * src/mm/boehm-gc/include/gc.h (GC_HAVE_BUILTIN_BACKTRACE): Commented, - we don't need it and uClibc doesn't have it. - -2007-05-03 14:53 twisti - - * src/toolbox/avl.c (toolbox/logging.h): Added. - (vm/global.h): Likewise. - (vm/vm.h): Likewise. - (avl_insert_intern): Use vm_abort instead of assert. - (avl_insert): Removed debug code. - (avl_dump): Use logging functions. - -2007-05-03 13:49 twisti - - * src/vm/jit/codegen-common.c (codegen_start_native_call) - [ENABLE_JAVASE]: This has to be ENABLE_JNI. - (codegen_finish_native_call): Likewise. - -2007-05-03 12:30 twisti - - * src/toolbox/avl.c (avl_insert_intern): Changed order of - comparator-arguments. - (avl_find): Likewise. - - * src/toolbox/avl.h (avl_comparator): Renamed arguments, to reflect - the change. - - * src/vm/jit/codegen-common.c (methodtree_comparator): Likewise. - -2007-05-03 08:29 twisti - - * src/toolbox/avl.h (avl_tree): Renamed to avl_tree_t. - (avl_node): Renamed to avl_node_t. - - * src/toolbox/avl.c: Likewise. - * src/threads/critical.c: Likewise. - * src/vm/jit/codegen-common.c: Likewise. - -2007-05-03 08:16 twisti - - * contrib/check_dangerous_printf.pl: Removed this file in favor of - pscan. - -2007-05-03 00:33 tbfg - - * src/vm/jit/m68k/codegen.c (ICMD_CALOAD): Fixed. - - * src/vm/jit/m68k/patcher.c (*): Removed patching back of - old opcodes from patcher_wrapper, moved into each patcher. - (patcher_patch_back): Added. - -2007-05-02 22:28 tbfg - - * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Fixed. - (ICMD_IREM): Fixed. - (ICMD_LASTORE): Use M_LST. - (ICMD_DASTORE): Use M_LST. - (ICMD_LALOAD): Use M_LLD. - (ICMD_DALOAD): Use M_LLD. - -2007-05-02 20:46 twisti - - * src/native/vm/cldc1.1/java_lang_Float.c (native/native.h): Removed. - (native/include/java_lang_Float.h): Added. - -2007-05-02 20:44 twisti - - * src/native/vm/cldc1.1/java_lang_Double.c - (native/include/java_lang_Double.h): Added. - (longBitsToDouble): Fixed return type. - -2007-05-02 20:40 twisti - - * src/threads/threads-common.c (threads_table_get_threads): New + * src/vm/jit/optimizing/ssa.c: adapted. + * src/vm/jit/optimizing/ssa3.c: Changed a lot. + * src/vm/jit/show.c (show_icmd): Support for ICMD_GETEXCEPTION. + [3224e4058498] + +2008-05-14 Christian Thalinger + + * src/classes/Makefile.am, + src/classes/gnu/gnu/classpath/VMStackWalker.java, + src/classes/gnu/gnu/classpath/VMSystemProperties.java, + src/classes/gnu/gnu/java/lang/CPStringBuilder.java, + src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java, + src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/classes/gnu/java/lang/VMClassLoader.java, + src/classes/gnu/java/lang/VMString.java, + src/classes/gnu/java/lang/VMThread.java, + src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java, + src/classes/gnu/java/lang/reflect/Modifier.java, + src/classes/gnu/java/lang/reflect/VMConstructor.java, + src/classes/gnu/java/lang/reflect/VMField.java, + src/classes/gnu/java/lang/reflect/VMMethod.java, + src/classes/gnu/java/security/VMAccessController.java, + src/classes/gnu/sun/misc/Unsafe.java, + src/classes/gnu/sun/reflect/ConstantPool.java, + src/classes/gnu/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas + ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy. + java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE + xceptionProxy.java, + src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas + ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/classes/gnuclasspath/gnu/classpath/VMStackWalker.java, + src/classes/gnuclasspath/gnu/classpath/VMSystemProperties.java, + src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java, + src/classes/gnuclasspath/gnu/java/lang/VMCPStringBuilder.java, src/c + lasses/gnuclasspath/gnu/java/lang/management/VMMemoryMXBeanImpl.java + , src/classes/gnuclasspath/gnu/java/lang/management/VMRuntimeMXBeanI + mpl.java, src/classes/gnuclasspath/java/lang/VMClassLoader.java, + src/classes/gnuclasspath/java/lang/VMString.java, + src/classes/gnuclasspath/java/lang/VMThread.java, + src/classes/gnuclasspath/java/lang/reflect/Constructor.java, + src/classes/gnuclasspath/java/lang/reflect/Field.java, + src/classes/gnuclasspath/java/lang/reflect/Method.java, + src/classes/gnuclasspath/java/lang/reflect/Modifier.java, + src/classes/gnuclasspath/java/lang/reflect/VMConstructor.java, + src/classes/gnuclasspath/java/lang/reflect/VMField.java, + src/classes/gnuclasspath/java/lang/reflect/VMMethod.java, + src/classes/gnuclasspath/java/security/VMAccessController.java, + src/classes/gnuclasspath/sun/misc/Unsafe.java, + src/classes/gnuclasspath/sun/reflect/ConstantPool.java, src/classes/ + gnuclasspath/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java, + src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismat + chExceptionProxy.java, src/classes/gnuclasspath/sun/reflect/annotati + on/EnumConstantNotPresentExceptionProxy.java, + src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java, + src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExcept + ionProxy.java: + * src/classes/gnu: Renamed to src/classes/gnuclasspath. + [caa690b0970d] + + * src/classes/Makefile.am: + * src/classes/Makefile.am (BOOTCLASSPATH): Removed, this is set + during configure. + [b46e2a411a24] + + * configure.ac, src/native/vm/Makefile.am, + src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c, + src/native/vm/gnu/VMjdwp.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, + src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, src/native/vm/g + nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_VMConstructor.c, + src/native/vm/gnu/java_lang_reflect_VMField.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/gnuclasspath/Makefile.am, + src/native/vm/gnuclasspath/VMjdwp.c, + src/native/vm/gnuclasspath/VMjdwp.h, + src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c, + src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c, + src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c, + src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c, + src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c, src/na + tive/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanIm + pl.c, src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMX + BeanImpl.c, src/native/vm/gnuclasspath/gnu_java_lang_management_VMRu + ntimeMXBeanImpl.c, src/native/vm/gnuclasspath/gnu_java_lang_manageme + nt_VMThreadMXBeanImpl.c, + src/native/vm/gnuclasspath/java_lang_VMClass.c, + src/native/vm/gnuclasspath/java_lang_VMClassLoader.c, + src/native/vm/gnuclasspath/java_lang_VMObject.c, + src/native/vm/gnuclasspath/java_lang_VMRuntime.c, + src/native/vm/gnuclasspath/java_lang_VMString.c, + src/native/vm/gnuclasspath/java_lang_VMSystem.c, + src/native/vm/gnuclasspath/java_lang_VMThread.c, + src/native/vm/gnuclasspath/java_lang_VMThrowable.c, src/native/vm/gn + uclasspath/java_lang_management_VMManagementFactory.c, + src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c, + src/native/vm/gnuclasspath/java_lang_reflect_VMField.c, + src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c, + src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c, + src/native/vm/gnuclasspath/java_security_VMAccessController.c, + src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c, + src/native/vm/nativevm.c, src/native/vm/openjdk/Makefile.am, + src/native/vm/openjdk/hpi.c, src/native/vm/openjdk/hpi.h, + src/native/vm/openjdk/jvm.c, src/native/vm/sun/Makefile.am, + src/native/vm/sun/hpi.c, src/native/vm/sun/hpi.h, + src/native/vm/sun/jvm.c: + * src/native/vm/gnu: Renamed to src/native/vm/gnuclasspath. + * src/native/vm/sun: Renamed to src/native/vm/openjdk. + [1c0d84d8f0dc] + + * m4/classpath.m4, m4/java-runtime-library.m4: + * m4/classpath.m4: Moved from here... + * m4/java-runtime-library.m4: ...to here. + [0c5b61d3cdea] + + * contrib/setenvinstalled.in, contrib/setenvsource.in: + * contrib/setenvinstalled.in: Missed in renaming. + * contrib/setenvsource.in: Likewise. + [69c19a930578] + + * configure.ac, contrib/setenvinstalled.in, contrib/setenvsource.in, + m4/classpath.m4, m4/hpi.m4, src/cacao/Makefile.am, + src/cacaoh/cacaoh.c, src/classes/Makefile.am, + src/native/include/Makefile.am, src/native/jni.c, + src/native/native.c, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/reflect.c, src/native/vm/reflect.h, + src/native/vm/sun_misc_Unsafe.c, src/threads/posix/thread-posix.c, + src/threads/thread.c, src/vm/access.c, src/vm/assertion.c, + src/vm/initialize.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c, + src/vm/jit/stacktrace.c, src/vm/properties.c, src/vm/signal.c, + src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/utf8.c, + src/vmcore/utf8.h: + * m4/classpath.m4: Renamed --with-classpath* options to + --with-java-runtime-library* and the defines respectively. + + * configure.ac, contrib/setenvinstalled.in, contrib/setenvsource.in, + m4/hpi.m4, src/cacao/Makefile.am, src/cacaoh/cacaoh.c, + src/classes/Makefile.am, src/native/include/Makefile.am, + src/native/jni.c, src/native/native.c, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/reflect.c, src/native/vm/reflect.h, + src/native/vm/sun_misc_Unsafe.c, src/threads/posix/thread-posix.c, + src/threads/thread.c, src/vm/access.c, src/vm/assertion.c, + src/vm/initialize.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c, + src/vm/jit/stacktrace.c, src/vm/properties.c, src/vm/signal.c, + src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/utf8.c, + src/vmcore/utf8.h: Likewise. + [ec4ce9fdb0b0] + +2008-05-13 Christian Thalinger + + * src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (mainstring): Removed. (mainclass): Made static. + (vm_create): Moved main-class argument handling from here... + (vm_run): ...to here. (vm_compile_method): Pass class name to the function. - - * src/threads/threads-common.h (threads_table_get_threads): Added. - - * src/threads/native/threads.c (threads_cast_sendsignals): Rewritten. - (threads_cast_stopworld): Likewise. - -2007-05-02 20:36 tbfg - - * java_lang_Double.c (Java_java_lang_Double_doubleToLongBits): Added - missing JNIEnv* argument to signature. - -2007-05-02 19:57 twisti - - * src/vmcore/class.c (class_load_attributes): Disable annotation - loading for the release. - -2007-05-02 16:21 twisti - - * src/threads/threads-common.c (threads_preinit): Create and - initialize the main-thread. - (threads_table_init): Changed signature, insert main-thread and - maintain a used list too. - (threads_table_add): Use locking and maintain used list. - (threads_table_remove): Likewise. - (threads_table_get): New function. - (threads_table_get_non_daemons): Likewise. - (threads_table_first): Likewise. - (threads_table_next): Likewise. - [!NDEBUG] (threads_table_dump): Use log_* functions. - (threads_dump): Use threads-table and functions. - - * src/threads/threads-common.h (threads_table_entry_t): Made a struct - and renamed nextfree to next. - (threads_table_get): Added - (threads_table_get_non_daemons): Likewise. - (threads_table_first): Likewise. - (threads_table_next): Likewise. - [!NDEBUG] (threads_table_dump): Likewise. - (threads_impl_table_init): Likewise. - (threads_table_lock): Likewise. - (threads_table_unlock): Likewise. - (threads_set_current_threadobject): Likewise. - - * src/threads/native/threads.c (threadlistlock): Removed. - (threads_impl_preinit): Removed main-thread initialization code. - (threads_impl_table_init): New function. - (threads_table_lock): New function. - (threads_table_unlock): Likewise. - (threads_init): Get main-thread from threads-table and removed - thread-list code. - (threads_attach_current_thread): Likewise. - (threads_detach_thread): Removed thread-list code. - (threads_find_non_daemon_thread): Removed. - (threads_join_all_threads): Use threads_table_get_non_daemons. - -2007-05-02 09:57 twisti - - * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Added - uClibc support. - (md_signal_handler_sigtrap): Likewise. - (md_signal_handler_sigusr2): Likewise. - (thread_restartcriticalsection): Likewise. - -2007-05-01 21:40 pm - - * src/vm/jit/s390/md.c (md_dump_context): Added. Fatal signals now - print the context and a stacktrace. - * src/vm/jit/s390/emit.h (emit_restore_pv): Added. Fixes bug where - REG_PV recalculation uses dseg value to recalculate REG_PV. - * src/vm/jit/s390/emit.c: Likewise. - * src/vm/jit/s390/codegen.h (N_RI, N_RI2): Test immediate operand for - correct signedness. - * src/vm/jit/s390/codegen.c (codegen_emit): Use emit_restore_pv for - REG_PV recalculation/ - * src/vm/jit/s390/disass.c (disass_pseudo_instr): Fix formating. - * src/vm/jit/s390/tests/dacapo.status: Added. - -2007-05-01 17:35 ajordan - - * src/vm/jit/sparc64/codegen.h: Removed unused var_to_reg_int define. - - * src/vm/jit/sparc64/codegen.c: Fixed JIT float argument passing via - stack. - - * src/vm/jit/sparc64/asmpart.S (asm_vm_call): Fixed integer argument - passing via stack args. - -2007-05-01 16:14 pm - - * src/vm/jit/s390/codegen.h (gen_bound_check, - gen_nullptr_check_intern, gen_bound_check, N_LONG_0): Remove because - obsolete. - -2007-05-01 16:05 pm - - * src/vm/jit/s390/codegen.c (codegen_emit): Use new emit_label and - emit_label_* functions. - * src/vm/jit/s390/disass.c (disass_pseudo_instr): Nicer formatting - for ill pseudo instruction. - -2007-05-01 15:46 pm - - * src/vm/jit/emit-common.h (BRANCH_LABEL_6): Added. - -2007-05-01 13:00 tbfg - - * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): Support - EXCEPTION_HARDWARE_ARITHMETIC. - - * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Use corret opcode for - word forms. - - * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Implemented. - (ICMD_IREMPOW2): Implemented. - (ICMD_ISHLCONST): Fixed. - (ICMD_ISHRCONST): Fixed. - (ICMD_IUSHRCONST): Fixed. - (ICMD_SALOAD): Signextension fix. - (ICMD_LALOAD): Implemented. - (ICMD_LASTORE): Fixed. - (ICMD_IASTORE): Fixed. - (ICMD_MULITANEWARRAY): Fixed. - - * src/vm/jit/m68k/codegen.h (M_IADDX): Added. - (M_IXOR): Fixed. - (M_BCS): Fixed. - -2007-04-30 12:44 tbfg - - * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Restore registers - correctly. - -2007-04-30 11:58 twisti - - * src/vm/jit/inline/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - -2007-04-30 10:53 tbfg - - * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed. - (emit_arithmetic_check): Implemented. - - * src/vm/jit/m68k/md.c (md_get_method_patch_address): Changed invoking - register. - (md_stacktrace_get_returnaddress): Fix for linking words on stack. - - * src/vm/jit/m68k/codegen.c (IUSHRCONST): Fix. - (ICMD_IOR): Implemented. - (ICMD_IORCONST): Likewise. - (ICMD_IXOR): Likewise. - (ICMD_IXORCONST): Likewise. - (ICMD_INVOKEVIRTUAL): Changed invoking register. - (ICMD_INVOKEINTERFACE): Likewise. - - * src/vm/jit/m68k/patcher.c (patcher_invokevirtual): Changed - invoking register. - - * src/vm/jit/m68k/asmpart.S (asm_vm_call_method_exception_handler): - Proper stack restauration. - (L_asm_call_jit_compiler_exception): Implemented. - (asm_patcher_wrapper): Fixses. - (L_asm_patcher_wrapper_exception): Implemented. - - * src/vm/jit/m68k/codegen.h (M_IXOR): Added. - (M_IOR_IMM): Added. - (M_IXOR_IMM): Added. - - * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): - Comment and further m68k stuff. - -2007-04-29 22:46 pm - - * src/vm/jit/s390/emit.c, - src/vm/jit/s390/md-abi.h, - src/vm/jit/s390/md.c, - src/vm/jit/s390/emit.h, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/machine-instr.h, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/arch.h, - src/vm/jit/s390/md-asm.h, - src/vm/jit/s390/disass.c, - src/vm/jit/s390/patcher.c, - src/vm/jit/s390/asmpart.S, - src/vm/jit/s390/md-abi.c: Adapted S390 port to changes from - branches/twisti (hardware exceptions, emit_branch, abi_registers_*), - jctest works again. Cleaned up almost all dead x86_64 code. - -2007-04-28 12:59 ajordan - - * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Fixed stack - alignement in first save. - -2007-04-27 08:43 tbfg - - * src/vm/jit/m68k/emit.c (emit_arrayindexoutofbounds_check): Fixed. - * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): AIOOB - fixed. - Editor boiler plate added. - - * src/vm/jit/m68k/linux/md-os.h: Editor boiler plate. - - * src/vm/jit/m68k/linux/md-abi.c: Likewise. - - * src/vm/jit/m68k/md.c: Likewise. - - * src/vm/jit/m68k/machine-instr.h: Likewise. - - * src/vm/jit/m68k/patcher.c: Editor boiler plate. - (patcher_invokeinterface): Implemented. - (patcher_get_putfield): Implemented. - (patcher_resolve_class): Implemented. - (patcher_get_putstatic): Implemented. - - * src/vm/jit/m68k/codegen.c: Editor boiler plate. - (ICMD_GETSTATIC): Added patcher. - (ICMD_AASTORE): Fixed. - - * src/vm/jit/m68k/asmpart.S: Editor boiler plate. - (asm_vm_call_method_exception_handler): Fixed used register. - Return values in %d0 and %a0 as gcc sometimes expects pointers - in %a0. - -2007-04-27 01:37 ajordan - - * src/vm/jit/sparc64/emit.c: Keeping stack 16-byte aligned when - calling C/native functions from the stack. (Solaris requires this) - * src/vm/jit/sparc64/codegen.c: Likewise. - * src/vm/jit/sparc64/codegen.h: Likewise. - - * src/vm/jit/sparc64/md-abi.c: Removed zero sized abi_register_* - arrays. (not allowed in ISO C) - - * src/vm/jit/sparc64/solaris/md-os.c: Preliminary hardware exception - handling. (untested) - -2007-04-26 13:43 twisti - - * src/vm/jit/inline/inline.h (config.h): Added. - (inline_inline): Likewise. - - * src/vm/jit/jit.c (threads/threads-common.h): Added. - [ENABLE_INLINING] (vm/jit/inline/inline.h): Likewise. - [ENABLE_THREADS] (threads/native/threads.h): Removed. - -2007-04-26 13:32 twisti - - * src/vm/vm.c [ENABLE_THREADS] (threads/native/threads.h): Removed. - (threads/threads-common.h): Added. - -2007-04-26 13:07 twisti - - * src/native/vm/java_lang_Thread.c: Set Id keyword. - -2007-04-26 13:06 twisti - - * src/native/vm/java_lang_Thread.c (start): Renamed - threads_start_javathread to threads_thread_start. - -2007-04-26 12:48 twisti - - * src/threads/threads-common.c (threads_thread_create_internal): - Renamed to threads_thread_start_internal and start the thread. - (threads_start_javathread): Renamed to threads_thread_start. - * src/threads/threads-common.h: Likewise. - - * src/threads/native/threads.c (threads_start_thread): Renamed to - threads_impl_thread_start. - - * src/mm/memory.c (thread_memory): Removed. - (memory_start_thread): Call threads_thread_start_internal. - - * src/vm/finalizer.c (thread_finalizer): Removed. - (finalizer_start_thread): Call threads_thread_start_internal. - - * src/vm/signal.c (thread_signal): Removed. - (signal_start_thread): Call threads_thread_start_internal. - - * src/vm/jit/optimizing/profile.c (thread_profile): Removed. - (profile_start_thread): Call threads_thread_start_internal. - - * src/vm/jit/optimizing/recompile.c (thread_recompile): Removed. - (recompile_start_thread): Call threads_thread_start_internal. - -2007-04-26 11:14 twisti - - * src/threads/threads-common.c (threads/critical.h): Added. - (threads/native/threads.h): Removed. - (threads_table): Added. - (threads_preinit): New function. - (threads_table_init): Moved from implementation file. - (threads_table_add): Likewise. - (threads_table_remove): Likewise. - (threads_table_dump): Likewise. - - * src/threads/threads-common.h (threads_table_entry_t) - (threads_table_t): Added. - (threads_preinit): Likewise. - (threads_table_add): Likewise. - (threads_table_remove): Likewise. - (threads_impl_preinit): Likewise. - (threads_init_threadobject): Likewise. - - * src/threads/native/threads.c (threads_table): Removed. - (threads_preinit): Renamed to threads_impl_preinit. - (threads_table_init): Removed. - (threads_table_add): Likewise. - (threads_table_remove): Likewise. - (threads_table_dump): Likewise. - - * src/threads/native/threads.h (threads_table_entry_t) - (threads_table_t): Removed. - (threads_preinit): Likewise. - -2007-04-25 21:47 stefan - - * src/vm/jit/i386/darwin/md-os.c: added threads/threads-common.h, - removed vm/jit/i386/md-abi.h - -2007-04-25 21:23 stefan - - * src/vm/jit/i386/darwin/md-os.c: attempt at porting the exception - changes - (see r7596 & r7648). - -2007-04-25 21:03 twisti - - * src/threads/lock-common.h (threads/threads-common.h): Removed that - header again and added a comment about not including thread headers. - - * src/threads/threads-common.c (threads_start_javathread): Reverted. - * src/threads/threads-common.h (threads_start_javathread): Likewise. - -2007-04-25 20:56 twisti - - * src/threads/threads-common.c (threads_dump) [!SIZEOF_VOID_P == 8]: - Fixed warning. - -2007-04-25 20:31 twisti - - * src/threads/threads-common.c (threads_start_javathread): Changed - signature. - - * src/threads/lock-common.h (threads/threads-common.h): Added. - [ENABLE_THREADS]: Only define functions when threads are enabled. - - * src/threads/threads-common.h (native/include/java_lang_Thread.h): - Removed. - [ENABLE_THREADS]: Only define functions when threads are enabled. - (threads_start_javathread): Changed signature. - -2007-04-25 20:07 twisti - - * src/vm/jit/mips/codegen.c: Changed lock includes. - * src/vm/jit/mips/emit.c: Likewise. - -2007-04-25 20:03 twisti - - * src/vm/jit/arm/codegen.c: Changed lock include. - * src/vm/jit/arm/emit.c: Likewise. - -2007-04-25 20:02 twisti - - * src/vm/jit/arm/emit.c (emit_load): Use switch-case instead of - if-else contruct. - (emit_store): Likewise. - (emit_copy): Likewise. - -2007-04-25 19:56 twisti - - * src/vm/jit/alpha/emit.c: Set Id keyword. - -2007-04-25 19:55 twisti - - * src/vm/jit/alpha/codegen.c: Changed lock include. - * src/vm/jit/alpha/emit.c: Likewise. - -2007-04-25 19:54 twisti - - * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Use - md->params to save and restore argument registers. - -2007-04-25 19:47 twisti - - * src/vm/jit/i386/codegen.c: Changed lock include. - * src/vm/jit/i386/emit.c: Likewise. - -2007-04-25 19:42 twisti - - * src/vm/jit/powerpc64/codegen.c: Changed lock includes. - * src/vm/jit/powerpc64/emit.c: Likewise. - -2007-04-25 19:38 twisti - - * src/vm/jit/powerpc/emit.c: Set Id keyword. - -2007-04-25 19:37 twisti - - * src/vm/jit/powerpc/codegen.c: Fixed lock include. - * src/vm/jit/powerpc/emit.c: Likewise. - -2007-04-25 19:36 twisti - - * src/vm/jit/powerpc/linux/md-abi.c (abi_registers_float_temporary): - Fixed number of registers. - -2007-04-25 19:20 twisti - - * src/threads/lock-common.h: New file. - - * src/threads/native/lock.h: Removed function prototypes. - * src/threads/none/lock.h (LOCK_INIT_OBJECT_LOCK): Added. - - * src/mm/memory.c, - src/native/jni.c, - src/native/native.c, - src/native/vm/java_lang_Object.c, - src/native/vm/java_lang_Thread.c, - src/threads/Makefile.am, - src/threads/native/threads.c, - src/threads/threads-common.c, - src/toolbox/avl.c, - src/toolbox/hashtable.c, - src/toolbox/list.c, - src/vm/builtin.c, - src/vm/finalizer.c, - src/vm/initialize.c, - src/vm/jit/inline/inline.c, - src/vm/jit/jit.c, - src/vm/jit/optimizing/recompile.c, - src/vm/jit/parse.c, - src/vm/jit/patcher.h, - src/vm/jit/show.c, - src/vm/jit/x86_64/codegen.c, - src/vm/jit/x86_64/emit.c, - src/vm/string.c, - src/vmcore/class.c, - src/vmcore/classcache.c, - src/vmcore/linker.c, - src/vmcore/loader.c, - src/vmcore/suck.c, - src/vmcore/utf8.c: Updated headers. - -2007-04-25 18:51 twisti - - * src/mm/memory.h: Updated copyright header. - -2007-04-25 18:33 twisti - - * src/threads/threads-common.c (threads_create_thread): Renamed to - threads_thread_create_internal and a new function. - (threads_start_javathread): Use threads_create_thread. - - * src/threads/threads-common.h (threads_create_thread): Changed - signature. - (threads_thread_create_internal): Added. - - * src/threads/native/threads.c (threads_set_current_threadobject): - Made non-static. - (threads_init_threadobject): Likewise, use threads_create_thread. - (threads_init): Cleanup. - (threads_startup_thread): Likewise. - (threads_attach_current_thread): Use threads_create_thread. - - * src/vm/jit/optimizing/profile.c (profile_start_thread): Replaced - threads_create_thread with threads_thread_create_internal. - * src/vm/jit/optimizing/recompile.c (recompile_start_thread): - Likewise. - * src/vm/signal.c (signal_start_thread): Likewise. - * src/vm/finalizer.c (finalizer_start_thread): Likewise. - * src/mm/memory.c (memory_start_thread): Likewise. - -2007-04-25 16:39 stefan - - * src/vmcore/linker.c (linker_init): added missing - lock_init_object_lock. - -2007-04-25 15:14 twisti - - * src/threads/native/threads.c (threads_preinit): We always need - variable t. - -2007-04-25 15:12 twisti - - * src/native/native.c (native/include/java_lang_Object.h): Include - always. - [ENABLE_JAVAME_CLDC1_1] - (native/include/com_sun_cldc_io_ResourceInputStream.h) - (native/include/com_sun_cldc_io_j2me_socket_Protocol.h): Added. - -2007-04-25 14:24 twisti - - * contrib: Ignore TAGS. - * contrib/vmlog: Likewise. - -2007-04-25 11:54 twisti - - * src/threads/native/threads.c (threads_init): Use variable t instead - of mainthreadobj->object, makes code simpler. - -2007-04-25 11:47 twisti - - * src/threads/threads-common.c (threads_create_thread) - [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE. - (threads_start_javathread) [ENABLE_GC_BOEHM]: Likewise. - - * src/threads/native/threads.c (threads_preinit) [ENABLE_GC_BOEHM]: - Likewise. - (threads_init): Removed resizing-of-threadobject code, we don't need - it anymore. - (threads_attach_current_thread) [ENABLE_GC_BOEHM]: Use - GCNEW_UNCOLLECTABLE. - (threads_detach_thread) [ENABLE_GC_BOEHM]: Use GCFREE. - -2007-04-24 14:29 twisti - - * src/threads/threads-common.c: Set Id keyword. - * src/threads/threads-common.h: Likewise. - -2007-04-24 14:23 twisti - - * src/threads/threads-common.c (threads_dump): Also print integer - thread id, so it's easier to compare with the ones from gdb. - -2007-04-24 10:20 tbfg - - * threads.m4: Fixed a typo - -2007-04-23 23:51 twisti - - * contrib/.cvsignore, - doc/.cvsignore, - doc/handbook/.cvsignore, - man/.cvsignore, - src/.cvsignore, - src/cacao/.cvsignore, - src/cacaoh/.cvsignore, - src/fdlibm/.cvsignore, - src/lib/.cvsignore, - src/mm/.cvsignore, - src/mm/boehm-gc/.cvsignore, - src/mm/boehm-gc/doc/.cvsignore, - src/mm/boehm-gc/include/.cvsignore, - src/mm/cacao-gc/.cvsignore, - src/native/.cvsignore, - src/native/include/.cvsignore, - src/native/jvmti/.cvsignore, - src/native/tools/.cvsignore, - src/native/vm/.cvsignore, - src/native/vm/cldc1.1/.cvsignore, - src/native/vm/gnu/.cvsignore, - src/scripts/.cvsignore, - src/threads/.cvsignore, - src/threads/none/.cvsignore, - src/threads/posix/.cvsignore, - src/toolbox/.cvsignore, - src/vm/.cvsignore, - src/vm/jit/.cvsignore, - src/vm/jit/allocator/.cvsignore, - src/vm/jit/alpha/.cvsignore, - src/vm/jit/alpha/freebsd/.cvsignore, - src/vm/jit/alpha/linux/.cvsignore, - src/vm/jit/arm/.cvsignore, - src/vm/jit/arm/linux/.cvsignore, - src/vm/jit/i386/.cvsignore, - src/vm/jit/i386/cygwin/.cvsignore, - src/vm/jit/i386/darwin/.cvsignore, - src/vm/jit/i386/freebsd/.cvsignore, - src/vm/jit/i386/linux/.cvsignore, - src/vm/jit/inline/.cvsignore, - src/vm/jit/intrp/.cvsignore, - src/vm/jit/loop/.cvsignore, - src/vm/jit/m68k/.cvsignore, - src/vm/jit/m68k/linux/.cvsignore, - src/vm/jit/mips/.cvsignore, - src/vm/jit/mips/irix/.cvsignore, - src/vm/jit/mips/linux/.cvsignore, - src/vm/jit/optimizing/.cvsignore, - src/vm/jit/parisc/.cvsignore, - src/vm/jit/parisc/linux/.cvsignore, - src/vm/jit/powerpc/.cvsignore, - src/vm/jit/powerpc/darwin/.cvsignore, - src/vm/jit/powerpc/linux/.cvsignore, - src/vm/jit/powerpc/netbsd/.cvsignore, - src/vm/jit/powerpc64/.cvsignore, - src/vm/jit/powerpc64/linux/.cvsignore, - src/vm/jit/s390/.cvsignore, - src/vm/jit/schedule/.cvsignore, - src/vm/jit/sparc64/.cvsignore, - src/vm/jit/sparc64/linux/.cvsignore, - src/vm/jit/sparc64/solaris/.cvsignore, - src/vm/jit/tools/.cvsignore, - src/vm/jit/verify/.cvsignore, - src/vm/jit/x86_64/.cvsignore, - src/vm/jit/x86_64/freebsd/.cvsignore, - src/vm/jit/x86_64/linux/.cvsignore, - src/vmcore/.cvsignore, - tests/.cvsignore, - tests/regression/.cvsignore, - tests/regression/codepatching/.cvsignore, - tests/regression/jasmin/.cvsignore, - tests/regression/native/.cvsignore, - tests/stack/.cvsignore: Removed. - -2007-04-23 23:39 twisti - - * .cvsignore: Removed. - -2007-04-23 23:03 twisti - - * configure.ac: Removed --enable-threads checks and call instead - AC_CHECK_ENABLE_THREADS. - * m4/threads.m4: New file. - -2007-04-23 20:04 twisti - - * configure.ac: Removed all classpath related checks and made - functions for them. - * m4/classpath.m4: New file. - -2007-04-23 20:03 twisti - - * src/vm/builtin.h (md-abi.h): Added. - -2007-04-23 14:29 twisti - - * src/vm/signal.c (signal_thread): Don't check for an error on - sigwait (revisit this patch with the exact-GC). - -2007-04-22 20:02 tbfg - - * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigsegv): - Implemented. - (md_signal_handler_sigill): More exceptions handled. Some fixes. - - * src/vm/jit/m68k/linux/md-os.h - (M68K_EXCEPTION_HARDWARE_NULLPOINTER): Used instead of - EXCEPTION_HARDWARE_NULLPOINTER, because a trap with value #0 will - not be taken. - - * src/vm/jit/m68k/emit.c (emit_load_[low|high]): Fixed assertion. - (emit_arrayindexoutofbounds_check): Implemented. - (emit_nullpointer_check): Implemented. - (emit_exception_check_ireg): Renamed emit_exception_check. - (emit_exception_check_areg): Disabled code. - (emit_exception_check): Implemented. - - * src/vm/jit/m68k/codegen.c (ICMD_LALOAD): Implemented. - (ICMD_FALOAD): Implemented. - (ICMD_DALOAD): Implemented. - (ICMD_LASTORE): Implemented. - (ICMD_FASTORE): Implemented. - (ICMD_DASTORE): Implemented. - (ICMD_BUILTIN): Exception check enabled. - (ICMD_MULTIANEWARRAY): Implemented. - (codegen_emit_stub_native): Exception check implemented. - - * src/vm/jit/m68k/asmpart.S (asm_handle_nat_exception): Symbol - exported and implemented. - - * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): More - m68k fixes. - -2007-04-22 15:55 ajordan - - * src/vm/jit/sparc64/arch.h: Properly activated all FP features - SPARC64 supports in hardware. - - * src/vm/jit/sparc64/asmpart.S: Added functions to read/write the FP - state register. - * src/vm/jit/sparc64/md.c: Added prototypes here. - - * src/vm/jit/sparc64/codegen.h: Added 'branch on FP condition codes' - macros. - - * src/vm/jit/sparc64/emit.c (emit_verbosecall_enter): Fixed FP - argument passing. - - * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed FP conversion - functions to (a) use unique slots in the data segment (doh!), - (b) catch the case where NaN is converted to an integer value. (JVMS - and SPARC do not inherently agree here). - -2007-04-21 18:56 edwin - - * tests/regression/resolving/Makefile.am: Added "-classpath ." to - javac - options so the tests work with ecj out-of-the-box. - -2007-04-21 16:42 edwin - - * configure.ac: Generate vmlog Makefiles. - * contrib/Makefile.am: Added vmlog to SUBDIRS. - * contrib/vmlog/Makefile.am, contrib/vmlog/t/Makefile.am: New files. - -2007-04-21 16:26 edwin - - * contrib/vmlog/Makefile: Renamed to maintain.mk. - -2007-04-21 12:48 edwin - - * contrib/vmlog/vmlog_cacao.patch: Removed. It is no longer needed. - * contrib/vmlog/README: Updated for CACAO's --enable-vmlog. - -2007-04-21 12:37 edwin - - * configure.ac (--enable-vmlog): New configure option. - - * src/vm/jit/Makefile.am, src/vm/Makefile.am, - src/threads/native/Makefile.am (AM_CPPFLAGS): Added -I for vmlog - includes. - -2007-04-21 10:55 edwin - - * src/vm/jit/replace.c, src/vm/jit/intrp/asmpart.c, - src/vm/jit/codegen-common.c, src/vm/builtin.c, src/vm/exceptions.c, - src/vm/vm.c, src/threads/native/lock.c (ENABLE_VMLOG): Applied the - vmlog patch and wrapped all inserted code with - #if defined(ENABLE_VMLOG). - -2007-04-20 13:51 twisti - - * src/toolbox/list.h (list_t): Added size. - - * src/toolbox/list.c (list_create): Initialize size. - (list_create_dump): Likewise. - (list_add_first): Increase size. - (list_add_last_unsynced): Likewise. - (list_add_before): Likewise. - (list_remove_unsynced): Decrease size. - -2007-04-20 13:28 twisti - - * src/toolbox/list.h (listnode): Renamed to listnode_t. - (list): Renamed to list_t. - - * src/toolbox/list.c, - src/vm/jit/codegen-common.c, - src/vm/jit/codegen-common.h, - src/vm/jit/emit-common.c, - src/vm/jit/optimizing/profile.c, - src/vm/jit/optimizing/recompile.c, - src/vm/jit/optimizing/recompile.h, - src/vm/properties.c, - src/vmcore/class.c, - src/vmcore/class.h, - src/vmcore/suck.c, - src/vmcore/suck.h: Likewise. - -2007-04-20 13:09 twisti - - * src/vm/vm.c: Changed header order to prevent a warning. - -2007-04-20 13:06 twisti - - * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (loadLibrary): Fixed - string-internal warnings. - * src/native/vm/cldc1.1/java_lang_System.c (getProperty0): Likewise. - -2007-04-20 12:53 twisti - - * src/vm/vm.c (version): Print libjvm.so path. - -2007-04-20 12:48 twisti - - * src/vm/vm.c (vm_create): Print unknown -verbose option. - -2007-04-20 12:40 twisti - - * src/vm/jit/codegen-common.c (codegen_finish_native_call): #ifdef lrt - and plrt. Don't set lrt, we don't need it. - -2007-04-20 11:21 twisti - - * src/threads/threads-common.h (native/jni.h): Added. - -2007-04-19 21:31 twisti - - * src/vm/signal.c (signal_thread): Check return value of sig* - functions. - -2007-04-19 19:59 twisti - - * tests/regression/resolving/Makefile.am (check): Added missing - JAVAFLAGS. - -2007-04-19 19:58 twisti - - * configure.ac (AC_INIT): Changed version to 0.98rc. - -2007-04-19 19:44 twisti - - * src/vm/exceptions.h: Added a comment about the hardware-exception - assert in signal_init. - -2007-04-19 19:43 twisti - - * src/vm/signal.c (assert.h): Added. - (vm/exceptions.h): Likewise. - [ENABLE_STATISTICS] (vmcore/statistics.h): Likewise. - (signal_init): Added hardware-exception assert. - -2007-04-19 19:41 twisti - - * src/cacaoh/dummy.c (exceptions_print_current_exception): Added - abort. - (exceptions_throw_outofmemoryerror): Removed. - (exceptions_throw_illegalaccessexception): Likewise. - -2007-04-19 19:39 twisti - - * src/vm/jit/powerpc/darwin/md-abi.h (REG_FA0, REG_FA1): Added. - (REG_A0_A1_PACKED, REG_A2_A3_PACKED): Likewise. - - * src/vm/jit/powerpc/darwin/md-os.c [ENABLE_THREADS] - (threads/native/threads.h): Added. - (md_signal_handler_sigsegv): Changed for hardware-exceptions. - (md_signal_handler_sigtrap): New function. - - * src/vm/jit/powerpc/darwin/md-abi.c (vm/descriptor.h): Changed to - vmcore/descriptor.h. - (regs): Renamed to abi_registers_integer_name. - (abi_registers_integer_argument): Added. - (abi_registers_integer_saved): Likewise. - (abi_registers_integer_temporary): Likewise. - (abi_registers_float_argument): Likewise. - (abi_registers_float_saved): Likewise. - (abi_registers_float_temporary): Likewise. - (md_param_alloc): Use new register arrays. - (md_param_alloc_native): New function. - -2007-04-19 15:01 tbfg - - * src/vm/jit/m68k/linux/md-abi.c (abi_registers_integer_saved): Fixed. - (abi_registers_float_saved): Fixed. - - * src/vm/jit/m68k/emit.c (emit_classcast_check): Fixed. - - * src/vm/jit/m68k/codegen.c (codegen_emit): Temporary hacked - a field for saved adr registers until real patch will be done. - (ICMD_INSTANCEOF): Fixed. - (ICMD_CHECKCAST): Fixed. - (codegen_emit_stub_compiler): Removed useless code. - - * src/vm/jit/m68k/asmpart.S (L_asm_handle_exception_not_catched): - Implemented. - - * src/vm/jit/m68k/codegen.h (M_BLS): Added. - -2007-04-19 12:19 michi - - * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Use long branch - construct - for exception handling here. This fixes a crash in the following - jasmin - regression testcase: jasmin/test_verify_fail_areturn_wrong_reftype. - -2007-04-19 09:19 twisti - - * src/threads/threads-common.c (threads_start_javathread) - [ENABLE_JAVASE]: Check for daemon thread and set the flag. - -2007-04-19 09:18 twisti - - * src/threads/native/threads.c (threads_start_javathread): Removed. - (threads_detach_thread): Added some comments. - - * src/threads/native/threads.h (threads_start_javathread): Removed. - - * src/threads/threads-common.c (assert.h): Added. - [ENABLE_STATISTICS] (vmcore/options.h, vmcore/statistics.h): Added. - (threads_start_javathread): Added. - - * src/threads/threads-common.h (vm/global.h): Added. - (native/include/java_lang_Thread.h): Likewise. - (threads_start_javathread): Likewise. - -2007-04-18 21:04 ajordan - - * src/vm/jit/sparc64/emit.c: Migrated to - abi_registers_{integer,float}_argument. - * src/vm/jit/sparc64/codegen.c: Likewise. - * src/vm/jit/sparc64/md-abi.c: Likewise. - -2007-04-18 15:31 michi - - * src/vm/jit/powerpc64/linux/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - -2007-04-18 14:49 tbfg - - * src/vm/jit/powerpc64/codegen.c (sign_ext): Removed from - ICMD_INEG, ICMD_IDIV, ICMD_IREM, ICMD_IMUL, ICMD_IAND and ICMD_IOR - to save the if runtime costs. - - (ICMD_IUSHR): Needs sign extension for 0 bit shift case. - -2007-04-18 14:11 twisti - - * src/threads/native/threads.c (mutex_join, cond_join): Added. - (threads_init_threadobject): Don't initalize join-mutex and cond. - (threads_preinit): Initialize mutex_join and cond_join. - (threads_startup_thread): Added vm_abort. - (threads_detach_thread): Don't reset thread id and use global mutex - and condition. - (threads_find_non_daemon_thread): Lock thread list. - (threads_join_all_threads): Use global mutex and condition. - - * src/threads/native/threads.h (threadobject): Removed joinmutex and - joincond. - -2007-04-18 09:59 twisti - - * src/native/vm/java_lang_ClassLoader.c [ENABLE_STATISTICS] - (vmcore/statistics.h): Added. - -2007-04-17 23:18 twisti - - * src/vm/jit/emit-common.h (emit_copy): Changed signature. - - * src/vm/jit/alpha/codegen.c, - src/vm/jit/alpha/emit.c, - src/vm/jit/arm/codegen.c, - src/vm/jit/arm/emit.c, - src/vm/jit/i386/codegen.c, - src/vm/jit/i386/emit.c, - src/vm/jit/m68k/codegen.c, - src/vm/jit/m68k/emit.c, - src/vm/jit/mips/codegen.c, - src/vm/jit/mips/emit.c, - src/vm/jit/powerpc/codegen.c, - src/vm/jit/powerpc/emit.c, - src/vm/jit/powerpc64/codegen.c, - src/vm/jit/powerpc64/emit.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/emit.c, - src/vm/jit/sparc64/codegen.c, - src/vm/jit/sparc64/emit.c, - src/vm/jit/x86_64/codegen.c, - src/vm/jit/x86_64/emit.c: Likewise. - -2007-04-17 22:55 twisti - - * src/vm/jit/m68k/emit.c: boilerplate added. - -2007-04-17 22:50 twisti - - * src/vm/jit/m68k/codegen.c: Boilerplate added. - -2007-04-17 22:06 twisti - - * src/vm/jit/alpha/codegen.c (codegen_emit): Fixed bug in - float-argument passing. - -2007-04-17 21:37 twisti - - * tests/regression/resolving/Makefile.am (check): Use LD_LIBRARY_PATH - for JAVA. - -2007-04-17 21:30 edwin - - * src/vm/jit/stack.c (stack_init_javalocals): Use "type" as variable - for the type. - (stack_analyse): Likewise. - -2007-04-17 21:25 edwin - - * src/vm/jit/stack.c (stack_analyse): Do not abuse poor "i" for types, - use a separate variable for that. - -2007-04-17 21:11 edwin - - * src/vm/jit/stack.c (stack_reanalyse_block, stack_analyse): Renamed - variable "j" to a more obvious "varindex". - -2007-04-17 21:01 edwin - - * src/vm/jit/verify/typecheck.c: More variable renaming for clarity. - -2007-04-17 20:59 twisti - - * src/vm/builtintable.inc (builtintable_function) [ENABLE_JIT]: We - need the entries only for JIT. - -2007-04-17 20:54 twisti - - * tests/regression/jasmin/Makefile.am (check): Set LD_LIBRARY_PATH. - -2007-04-17 20:53 edwin - - * src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c, - src/vm/jit/verify/typeinfo.c, src/vm/jit/inline/inline.c, - src/vm/jit/allocator/simplereg.c: Clarification: Renamed variables - that are indices into jd->var to "varindex". Renamed variables that - are bytecode variable indices to "javaindex". - -2007-04-17 20:37 edwin - - * src/vm/jit/stack.c, src/vm/jit/show.c, src/vm/jit/inline/inline.c, - src/vm/jit/replace.c, src/vm/jit/jit.h: Fix and use the new macros - for calculating javalocals values representing returnAddresses. - -2007-04-17 20:30 edwin - - * src/vm/jit/jit.h (basicblock): Document the javalocal array. - (JAVALOCAL_FROM_RETADDR): New macro. - (RETADDR_FROM_JAVALOCAL): Likewise. - -2007-04-17 20:25 twisti - - * src/threads/native/threads.c (threads_init): Fixed string-internal - warnings. - (threads_attach_current_thread): Likewise. - -2007-04-17 20:17 twisti - - * src/threads/threads-common.c (threads_print_stacktrace): Renamed to - threads_thread_print_stacktrace. - (threads_print_stacktrace): New function. - (threads_dump): Use threads_thread_print_stacktrace. - - * src/threads/threads-common.h: Likewise. - - * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Use new - threads_print_stacktrace. - -2007-04-17 20:06 edwin - - * src/vm/jit/jit.h (jitdata): Cleaned up comments for local_map. - -2007-04-17 19:57 edwin - - * src/vm/jit/stack.c (stack_javalocals_store): Added an assert. - -2007-04-17 19:24 edwin - - * src/vm/jit/stack.c (stack_analyse): The javalocals array can have - negative values != UNUSED (these values < UNUSED represent - returnAddresses of local subroutines). Thus >= 0 must be used to - check for normal indices. - -2007-04-17 18:47 edwin - - * src/vm/jit/parse.c (parse): Small cleanup of local variable - renaming. - (No code changes.) - -2007-04-17 11:15 twisti - - * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Use simpler - code to save and restore argument registers. - -2007-04-16 22:56 twisti - - * src/vm/jit/x86_64/codegen.c (codegen_emit): Made argument passing - cleaner. - -2007-04-16 22:24 twisti - - * src/vm/jit/codegen-common.c (codegen_setup): Removed maxstack stuff. - * src/vm/jit/codegen-common.h (codegendata): Likewise. - - * src/vm/jit/inline/inline.c: Fixed includes. - (inline_jit_compile): Removed maxstack stuff. - (inline_transform): Removed basicblockindex. - -2007-04-16 21:09 twisti - - * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added m68k. - * src/mm/cacao-gc/Makefile.am (libgc_la_SOURCES): Removed heap.c. - -2007-04-16 21:07 twisti - - * src/vm/jit/powerpc64/linux/md-abi.c: Argument register changes - ported (rev7713). - * src/vm/jit/powerpc64/emit.c: Likewise. - * src/vm/jit/powerpc64/codegen.c: Likewise. - -2007-04-16 15:57 twisti - - * src/native/jni.c (_Jv_JNI_DefineClass): Fixed string-internal - warnings. - (_Jv_JNI_NewStringUTF): Likewise. - (_Jv_JNI_GetStringUTFChars): Likewise. - -2007-04-16 15:53 twisti - - * src/native/vm/java_lang_Class.c (forName): Fixed string-internal - warnings. - (getDeclaredFields): Likewise. - (getDeclaredMethods): Likewise. - (getEnclosingMethod): Likewise. - (getClassSignature): Likewise. - -2007-04-16 15:49 twisti - - * src/native/vm/java_lang_ClassLoader.c (defineClass): Fixed - string-internal warnings. - - * src/native/vm/java_lang_Runtime.c (loadLibrary): Likewise. - - * src/native/vm/gnu/java_lang_reflect_Field.c (getSignature): - Likewise. - - * src/native/vm/gnu/java_lang_reflect_Constructor.c (getSignature): - Likewise. - - * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Likewise. - -2007-04-16 15:29 twisti - - * src/native/vm/gnu/java_lang_reflect_Method.c (getSignature): Fixed - string-internal warnings. - -2007-04-16 15:26 twisti - - * src/native/vm/gnu/java_lang_VMRuntime.c (mapLibraryName): Fixed - string-internal warnings. - -2007-04-16 15:23 twisti - - * src/native/vm/gnu/java_lang_VMClassLoader.c (loadClass): Fixed - string-internal warnings. - (nativeGetResources): Likewise. - (findLoadedClass): Likewise. - -2007-04-16 14:29 twisti - - * src/vmcore/utf8.c (utf_get_number_of_u2s): Return 0 instead of NULL. - -2007-04-16 14:28 twisti - - * src/threads/threads-common.c (native/include/java_lang_String.h): - Added. - (threads_create_thread): Fixed string-internal warnings. - (threads_dump): Likewise. - -2007-04-16 14:11 twisti - - * src/vm/builtin.c (builtin_print_argument): Removed java_lang_String - until we know what we do with strings internally (more patches to - come). - -2007-04-15 21:49 twisti - - * src/vm/jit/reg.c (reg_setup): Removed arg{int,flt}regs stuff. - * src/vm/jit/reg.h (registerdata): Removed arg{int,flt}regs. - - * src/vm/jit/stack.c (stack_analyse): regoff now contains the register - number instead of an offset. - - * src/vm/jit/allocator/simplereg.c: Use - abi_registers_{integer,float}_argument instead of arg{int,flt}regs. - - * src/vm/jit/alpha/codegen.c, - src/vm/jit/alpha/emit.c, - src/vm/jit/alpha/md-abi.c, - src/vm/jit/arm/codegen.c, - src/vm/jit/arm/emit.c, - src/vm/jit/arm/md-abi.c, - src/vm/jit/arm/md-abi.h, - src/vm/jit/i386/codegen.c, - src/vm/jit/i386/md-abi.c, - src/vm/jit/mips/codegen.c, - src/vm/jit/mips/emit.c, - src/vm/jit/mips/md-abi.c, - src/vm/jit/powerpc/codegen.c, - src/vm/jit/powerpc/emit.c, - src/vm/jit/powerpc/linux/md-abi.c, - src/vm/jit/powerpc/linux/md-abi.h, - src/vm/jit/x86_64/codegen.c, - src/vm/jit/x86_64/emit.c, - src/vm/jit/x86_64/md-abi.c: A lot of changes like the ones above. - -2007-04-15 21:13 twisti - - * src/vm/jit/mips/emit.c (emit_load): Bugfix: Added missing float - instruction. - (emit_store): Likewise. - -2007-04-15 12:17 michi - - * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Fixed. - -2007-04-15 12:15 michi - - * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Added. - (abi_registers_integer_saved): Likewise. - (abi_registers_integer_temporary): Likewise. - -2007-04-15 11:55 michi - - * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Fixed - calculation of stackframesize. - -2007-04-15 11:37 twisti - - * tests/regression/resolving/Makefile.am: Added GNU header and fixed - srcdir != builddir. - * tests/regression/resolving/classes1/Makefile.am: Likewise. - * tests/regression/resolving/classes2/Makefile.am: Likewise. - * tests/regression/resolving/classes3/Makefile.am: Likewise. - -2007-04-13 11:48 twisti - - * src/vm/jit/mips/codegen.c (codegen_emit): ICMD_LDIV, ICMD_LREM: Use - REG_Ax_Ax_PACKED defines. - -2007-04-13 10:42 twisti - - * src/vm/jit/mips/md-abi.c (md_param_alloc): Code beautified. - -2007-04-13 10:12 twisti - - * src/cacao/cacao.c (main): Save the error message of the first - lt_dlopenext and print it too when the second fails (thanks Dalibor). - Although there's still a problem, when the first fails for some reason - and the second picks up and old installed one silently. - -2007-04-12 19:49 twisti - - * src/vm/jit/stack.c (stack_analyse): Removed USEBUILTINTABLE, always - check for automatic-builtins (compile this is not affected). - - * src/vm/jit/alpha/arch.h, - src/vm/jit/arm/arch.h, - src/vm/jit/i386/arch.h, - src/vm/jit/m68k/arch.h, - src/vm/jit/mips/arch.h, - src/vm/jit/powerpc/arch.h, - src/vm/jit/powerpc64/arch.h, - src/vm/jit/s390/arch.h, - src/vm/jit/sparc64/arch.h, - src/vm/jit/x86_64/arch.h (USEBUILTINTABLE): Removed. - -2007-04-12 15:35 tbfg - - * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed dead code. - - * src/vm/jit/powerpc64/codegen.c (ICMD_ISUB): Fixed evil bug. - (ICMD_LSHR): Fixed a bug. - (createnativestub): Use emit_patcher_stub. - - * src/vm/jit/powerpc64/patcher.c (patcher_resolve_native): Fixed. - -2007-04-12 14:47 twisti - - * src/vm/jit/codegen-common.c (codegen_createnativestub): Renamed to - codegen_generate_stub_native and call codegen_finish. - - * src/vm/jit/codegen-common.h (codegen_createnativestub): Removed. - (codegen_generate_stub_native): Added. - * src/vm/jit_interface.h: Likewise. - * src/cacaoh/dummy.c: Likewise. - - * src/vmcore/loader.c (load_newly_created_array): Renamed - codegen_createnativestub to codegen_generate_stub_native and changed - signature. - * src/vm/jit/jit.c (jit_compile_intern): Likewise. - - * src/vm/jit/arm/codegen.c, - src/vm/jit/powerpc/codegen.c, - src/vm/jit/sparc64/codegen.c, - src/vm/jit/alpha/codegen.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/mips/codegen.c, - src/vm/jit/m68k/codegen.c, - src/vm/jit/powerpc64/codegen.c, - src/vm/jit/i386/codegen.c, - src/vm/jit/x86_64/codegen.c (createnativestub): Renamed to - codegen_emit_stub_native and changed signature, don't call - codegen_finish. - -2007-04-12 12:45 twisti - - * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): New - function. - - * src/vm/jit/codegen-common.h (createcompilerstub): Removed. - (codegen_generate_stub_compiler): Added. - * src/vm/jit_interface.h: Likewise. - * src/cacaoh/dummy.c: Likewise. - - * src/vmcore/linker.c (link_class_intern): Replaced createcompilerstub - with codegen_generate_stub_compiler. - - * src/vm/jit/alpha/codegen.c, - src/vm/jit/arm/codegen.c, - src/vm/jit/i386/codegen.c, - src/vm/jit/m68k/codegen.c, - src/vm/jit/mips/codegen.c, - src/vm/jit/powerpc/codegen.c, - src/vm/jit/powerpc64/codegen.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/sparc64/codegen.c, - src/vm/jit/x86_64/codegen.c (COMPILERSTUB_DATASIZE) - (COMPILERSTUB_SIZE): Removed. - (createcompilerstub): Renamed to codegen_emit_stub_compiler and - changed signature. - - * src/vm/jit/alpha/codegen.h, - src/vm/jit/arm/codegen.h, - src/vm/jit/i386/codegen.h, - src/vm/jit/m68k/codegen.h, - src/vm/jit/mips/codegen.h, - src/vm/jit/powerpc/codegen.h, - src/vm/jit/powerpc64/codegen.h, - src/vm/jit/s390/codegen.h, - src/vm/jit/sparc64/codegen.h, - src/vm/jit/x86_64/codegen.h (COMPILERSTUB_CODESIZE): Added. - -2007-04-12 11:56 twisti - - * src/vm/jit/arm/linux/md-os.c (mm/memory.h): Removed. - [ENABLE_THREADS] (threads/native/threads.h): Added. - -2007-04-11 16:39 tbfg - - * src/vm/jit/powerpc64/arch.h (SUPPORT_LONG_SHIFT): Enabled. - - * src/vm/jit/powerpc64/codegen.c (ICMD_LSHLCONST): Implemented. - (ICMD_LSHRCONST): Likewise. - (ICMD_LUSHRCONST): Likewise. - (ICMD_LSHL): Likewise. - (ICMD_LSHR): Likewise. - (ICMD_LUSHR): Likewise. - (ICMD_IUSHR): Fixed. - (ICMD_IUSHRCONST): Fixed. - - * src/vm/jit/powerpc64/codegen.h (M_SRL): Use 64bit opcode. - (M_SRA): Likewise. - (M_SRA_IMM): Likewise. - (M_SRL_IMM): Likewise. - (M_SSL_IMM): Likewise. - (M_SSL): Likewise. - (M_CLR_HIGH): Added. - -2007-04-11 08:21 twisti - - * src/toolbox/logging.c (log_finish): Also print a \n in the log-file. - -2007-04-11 08:11 twisti - - * src/vm/jit/codegen-common.c (codegen_generate): Added re-generating - debug message. - -2007-04-10 21:37 twisti - - * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): We only - need to check the cause for pre glibc-2.5. - -2007-04-10 21:24 twisti - - * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_IF_Lxx - instructions for 64-bit. - -2007-04-10 12:22 twisti - - * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Set val - accordingly. - -2007-04-10 05:02 pm - - * src/vm/jit/s390/emit.c, - src/vm/jit/s390/md-abi.h, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/arch.h, - src/vm/jit/s390/asmpart.S, - src/vm/jit/s390/tests/tests.java.pp: Changed very much. - -2007-04-09 21:17 twisti - - * src/vm/jit/alpha/emit.c (emit_copy): Check src-type, not dst-type. - -2007-04-09 17:23 twisti - - * src/vm/jit/alpha/asmpart.S: Use % instead of @ for progbits as ARM's - assembler uses @ as comment character. - * src/vm/jit/arm/asmpart.S: Likewise. - * src/vm/jit/i386/asmpart.S: Likewise. - * src/vm/jit/mips/asmpart.S: Likewise. - * src/vm/jit/powerpc/asmpart.S: Likewise. - * src/vm/jit/powerpc64/asmpart.S: Likewise. - * src/vm/jit/s390/asmpart.S: Likewise. - * src/vm/jit/sparc64/asmpart.S: Likewise. - * src/vm/jit/x86_64/asmpart.S: Likewise. - -2007-04-09 11:51 twisti - - * src/vm/jit/mips/codegen.h (BRANCH_NOPS): Added long-branches case. - - * src/vm/jit/mips/emit.c (emit_load): Use switch-case instead of - if-else contruct. - (emit_store): Likewise. - (emit_copy): Likewise. - (emit_branch): Implemented conditional long-branches. - -2007-04-08 21:14 twisti - - * src/native/vm/cldc1.1/java_lang_Object.c (notifyAll): Implemented. - * src/native/vm/cldc1.1/java_lang_String.c (lastIndexOf__I): Likewise. - -2007-04-05 14:23 michi - - * src/vm/global.h (compiler_lock, compiler_unlock): Removed. - * src/cacaoh/dummy.c (compiler_lock, compiler_unlock): Removed. - * src/threads/native/threads.c (compiler_lock, compiler_unlock): - Removed. - - * src/vmcore/linker.h (linker_classrenumber_lock): Added. - * src/vmcore/linker.c (linker_classrenumber_lock): Added. - (linker_compute_subclasses): Uses above lock object instead of - compiler_lock. - - * src/vm/jit/intrp/asmpart.c (intrp_asm_getclassvalues_atomic): - Likewise. - -2007-04-05 13:22 michi - - * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Inserted - ifdef to fix - compiler error with disabled threads. - -2007-04-05 12:06 twisti - - * src/vm/exceptions.c (exceptions_throw_nosuchmethoderror) - [!ENABLE_JAVASE]: Throw an error. - -2007-04-05 11:57 twisti - - * src/threads/threads-common.c (threads_get_state): Renamed to - threads_thread_get_state. - (threads_thread_is_alive): New function. - - * src/threads/threads-common.h: Likewise. - - * src/native/vm/java_lang_Thread.c (isAlive): New function. - (getState): Renamed threads_get_state to threads_thread_get_state. - - * src/native/vm/java_lang_Thread.h (isAlive): Added. - - * src/native/vm/cldc1.1/java_lang_Thread.c (isAlive): New function. - -2007-04-05 11:39 twisti - - * src/native/vm/java_lang_Thread.c [ENABLE_THREADS] - (threads/native/threads.h): Removed. - (threads/threads-common.h): Added. - (vm/stringlocal.h): Likewise. - (vm/vm.h): Removed. - (getState): Implemented. - - * src/threads/threads-common.c (vm/vm.h): Added. - (threads_get_state): New function. - (threads_dump): Print thread state. - - * src/threads/threads-common.h (THREAD_STATE_NEW) - (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING) - (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Defined. - (threads_get_state): Added. - - * src/threads/native/threads.c (threads_init): Set thread-state. - (threads_startup_thread): Likewise. - (threads_attach_current_thread): Likewise. - (threads_detach_thread): Likewise. - (threads_wait_with_timeout): Likewise. - - * src/threads/native/threads.h (threadobject): Added state field. - - * src/native/native.c (dummynativetable) [ENABLE_JAVASE]: Added - Java_java_lang_VMThread_getState. - -2007-04-05 00:14 twisti - - * src/threads/threads-common.c (threads_print_stacktrace): Removed - !ENABLE_THREADS code, since this file is only compiled with - ENABLE_THREADS. - -2007-04-04 22:29 twisti - - * src/vm/jit/verify/typecheck-stackbased.c: Use block directly instead - of insindex. - * src/vm/jit/verify/typecheck-stackbased-gen.inc: Newly generated. - -2007-04-04 22:14 twisti - - * src/vm/jit/parse.c (BYTECODEINDEX_TO_BASICBLOCK): Added. - (parsedata_t): Removed instructionstart, added bytecodestart, - basicblockstart, bytecodemap, instructionmap. - (parse_setup): Allocate new arrays. - (parse_bytecodeindex_to_basicblock): New function. - (parse_mark_exception_boundaries): Pass parsedata_t. - (parse_resolve_exception_table): Likewise. - (parse): Completely rewritten so we are able to have basic block - boundaries on IR instruction level. We now also resolve basic block - pointers in this pass. - - * src/vm/jit/parse.h (MARK_BASICBLOCK): Pass parsedata_t. - (BLOCK_OF): Removed. - - * src/vm/jit/jit.h (jitdata): Removed basicblockindex. - - * src/vm/jit/show.c (SHOW_TARGET): Print block instead of insindex. - (show_icmd): Likewise. - - * src/vm/jit/stack.c (BRANCH_TARGET): Directly use block. - (stack_analyse): Likewise. - * src/vm/jit/verify/icmds.c: Likewise. - * src/vm/jit/verify/typecheck-stackbased.c: Likewise. - -2007-04-04 14:16 twisti - - * src/native/vm/gnu/sun_misc_Unsafe.c: Header changes. - - * src/native/native.c [ENABLE_JAVASE] - (native/include/sun_misc_Unsafe.h): Added. - [ENABLE_JAVASE] (dummynativetable): Added - Java_sun_misc_Unsafe_objectFieldOffset and - Java_sun_misc_Unsafe_compareAndSwapInt. - -2007-04-03 22:29 twisti - - * src/vm/jit/alpha/asmpart.S: Replaced __GNU__ with __linux__ for - exec-stacks. - * src/vm/jit/arm/asmpart.S: Likewise. - * src/vm/jit/i386/asmpart.S: Likewise. - * src/vm/jit/mips/asmpart.S: Likewise. - * src/vm/jit/powerpc/asmpart.S: Likewise. - * src/vm/jit/powerpc64/asmpart.S: Likewise. - * src/vm/jit/s390/asmpart.S: Likewise. - * src/vm/jit/sparc64/asmpart.S: Likewise. - * src/vm/jit/x86_64/asmpart.S: Likewise. - -2007-04-03 21:30 twisti - - * src/vm/jit/i386/linux/md-os.c (threads/threads-common.h): Added. - -2007-04-03 18:02 twisti - - * src/vm/jit/mips/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Defined. - -2007-04-03 16:06 twisti - - * src/threads/threads-common.c (threads_print_stacktrace): Pass - stackframeinfo to stacktrace_create. - - * src/vm/jit/codegen-common.c (threads/native/threads.h): Removed. - (threads/threads-common.h): Added. - (codegen_get_pv_from_pc): Replaced stacktrace_dump_trace with - threads_print_stacktrace. - - * src/vm/jit/stacktrace.h (stacktrace_print_trace_from_buffer): Added. - -2007-04-03 15:51 twisti - - * src/vm/jit/stacktrace.c (stacktrace_create): Changed signature. - - (stacktrace_fillInStackTrace): Pass stackframeinfo to - stacktrace_create. - (stacktrace_getClassContext): Likewise. - (stacktrace_getCurrentClass): Likewise. - (stacktrace_getStack): Likewise. - (stacktrace_dump_trace): Removed. - - * src/vm/jit/stacktrace.h (threads/native/threads.h) - (threads/none/threads.h): Removed. - (stacktrace_create): Added. - (stacktrace_dump_trace): Removed. - - * src/threads/native/threads.c (threads_dump): Removed. - * src/threads/native/threads.h (threads_dump): Likewise. - - * src/threads/threads-common.c (vm/jit/stacktrace.h): Added. - (threads_dump): Added. - (threads_print_stacktrace): Likewise. - - * src/threads/threads-common.h (threads_dump): Added. - (threads_print_stacktrace): Likewise. - -2007-04-03 15:29 twisti - - * src/vm/jit/replace.c (threads/threads-common.h): Added. - - * src/vm/jit/replace.h: Moved empty defines to the top of the file to - see what's happening when !defined(ENABLE_REPLACEMENT). - -2007-04-03 15:22 twisti - - * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigfpe): Use - exceptions_new_hardware_exception. - * src/vm/exceptions.c (exceptions_fillinstacktrace) - [ENABLE_JAVAME_CLDC1_1]: fillInStackTrace has another signature in - CLDC-1.1. - -2007-04-03 14:34 twisti - - * src/vm/jit/arm/emit.c (emit_exception_stubs): Removed. - - * src/vm/jit/arm/md.c (md_codegen_patch_branch): Likewise. - (md_stacktrace_get_returnaddress): Removed debug code. - -2007-04-03 14:23 twisti - - * src/threads/native/threads.h (STACKFRAMEINFO): Return stackframeinfo - instead of a pointer to it. - * src/threads/none/threads.h (STACKFRAMEINFO): Likewise. - - * src/vm/jit/codegen-common.c (codegen_finish_native_call): - STACKFRAMEINFO changes. - - * src/vm/jit/replace.c (replace_recover_source_state): Likewise. - - * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo): - Likewise. - (stacktrace_create_extern_stackframeinfo): Likewise. - (stacktrace_create_native_stackframeinfo): Likewise. - (stacktrace_remove_stackframeinfo): Likewise. - -2007-04-03 14:00 twisti - - * src/vm/jit/stacktrace.c (stacktrace_create_inline_stackframeinfo): - Removed. - (stacktrace_inline_arithmeticexception): Likewise. - (stacktrace_inline_arrayindexoutofboundsexception): Likewise. - (stacktrace_inline_arraystoreexception): Likewise. - (stacktrace_inline_classcastexception): Likewise. - (stacktrace_inline_nullpointerexception): Likewise. - (stacktrace_inline_fillInStackTrace): Likewise. - (stacktrace_hardware_arithmeticexception): Likewise. - (stacktrace_hardware_nullpointerexception): Likewise. - - * src/vm/jit/stacktrace.h: Likewise. - -2007-04-03 13:48 twisti - - * configure.ac: Added armv4 architecture. - -2007-04-03 13:47 twisti - - * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use - exceptions_new_hardware_exception. - [ENABLE_THREADS] (md_signal_handler_sigusr2): New function. - -2007-04-03 13:14 twisti - - * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigfpe): Use - exceptions_new_hardware_exception. - -2007-04-03 12:10 twisti - - * src/vm/jit/jit.h: Includes alpha-sorted. - -2007-04-03 11:56 twisti - - * src/vm/jit/replace.c (native/include/java_lang_String.h): Removed. - (java_value_print): Don't cast to java_lang_String. - -2007-04-03 11:46 twisti - - * src/vm/jit/allocator/simplereg.c (simplereg_make_statistics): Fixed - compiler warning. - -2007-04-03 11:37 twisti - - * src/vm/jit/x86_64/emit.c (emit_replacement_stubs): Removed unused - variable disp. - -2007-04-03 11:35 twisti - - * src/vmcore/statistics.c (statistics_print_memory_usage): Prevent - compiler warning on 64-bit machines. - -2007-04-02 23:13 michi - - * src/vm/jit/replace.c: Added include to fix crash on x86_64. - -2007-04-02 21:24 twisti - - * src/vm/jit/alpha/linux/md-os.c [ENABLE_THREADS] - (threads/native/threads.h): Added. - [ENABLE_THREADS] (md_signal_handler_sigusr2): Added #ifdef. - -2007-04-02 20:58 twisti - - * src/vm/jit/alpha/md-abi.c (abi_registers_integer_argument): Added. - (abi_registers_integer_saved): Likewise. - (abi_registers_integer_temporary): Likewise. - -2007-04-02 20:04 michi - - * src/vm/jit/stacktrace.c (stacktrace_create): Returns NULL if there - is no - stacktrace available for the given thread. Fixed comments. - -2007-04-02 19:56 twisti - - * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_argument): Added. - (abi_registers_integer_saved): Likewise. - (abi_registers_integer_temporary): Likewise. - -2007-04-02 19:45 twisti - - * src/vm/jit/parse.c (parse): JAVA_GOTO_W must be converted to a - ICMD_GOTO. - -2007-04-02 18:56 twisti - - * src/vm/jit/jit.h (INS_FLAG_BASICBLOCK): Defined. - (INS_FLAG_ID_SHIFT): Changed to 5. - (INSTRUCTION_STARTS_BASICBLOCK): Added. - - * src/vm/jit/parse.c (parse): Changed basic block determination. Now - basic blocks can start at IR instruction level. This is required for - slow-fast path builtins. - -2007-04-02 16:09 twisti - - * src/vm/jit/stack.c (stack_reach_next_block): Reformatted comments. - (stack_analyse): Likewise. - -2007-04-02 13:45 twisti - - * src/vm/jit/stack.c (stack_mark_reached): Added assert on b. - (stack_mark_reached_from_outvars): Likewise. - (stack_reach_next_block): Use NULL instead of !. - (stack_analyse): Indent. - -2007-04-01 22:53 ajordan - - * src/vm/jit/sparc64/codegen.c: Implemented float argument passing - for builtin calls. - * src/vm/jit/sparc64/codegen.h: Likewise. - -2007-04-01 16:18 stefan - - * src/vm/jit/powerpc/darwin/md-asm.h, - src/vm/jit/i386/darwin/md-asm.h: added missing symbol - asm_vm_call_method_end. - -2007-04-01 10:50 edwin - - * contrib/vmlog: Committed vmlog 0.0.5. - * THIRDPARTY: Added copyright notice for vmlog. - -2007-03-30 11:41 twisti - - * src/vm/jit/parse.c (parse_realloc_instructions): Renamed ipc to - icount. - (parse): Renamed ipc to icount, set method variables at the very end - and use local variables before. - - * src/vm/jit/parse.h (INSTRUCTIONS_CHECK): Renamed ipc to icount. - (PINC): Likewise. - (OP_PREPARE_FLAGS): Likewise. - -2007-03-29 23:22 twisti - - * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Fixed - address check (thanks Michi). - -2007-03-29 23:01 ajordan - - * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed ICMD_IREMPOW2. - Added ICMD_L2F and ICMD_L2D. - Fixed constant creation in IF_L* compares. - -2007-03-29 21:56 michi - - * src/mm/nogc.c: Fixed merging conflict which was commited to that - file. - -2007-03-29 21:37 ajordan - - * src/vm/jit/sparc64/md.c (md_get_pv_from_pc): Implemented sethi - hanlding. - - * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed window/stack - handling in case of exception. - * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Likewise. - -2007-03-29 11:04 twisti - - * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Check - for addr == NULL in NPE case. - -2007-03-29 06:52 pm - - * src/vm/jit/s390/md-abi.h, - src/vm/jit/s390/emit.c, - src/vm/jit/s390/emit.h, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/arch.h: Changed a lot. - -2007-03-28 22:59 twisti - - * src/vm/exceptions.h (exceptionptr): Removed. - (_no_threads_exceptionptr): Likewise. - -2007-03-28 22:32 twisti - - * svnmerge uninit. - -2007-03-28 22:25 michi - - * AUTHORS: Added myself to the list of authors (finally). - -2007-03-28 21:05 twisti - - * Merged in twisti-branch. - -2007-03-28 20:50 twisti - - Initialized merge tracking via "svnmerge" with revisions "1-6085" - from - file:///ahome/cacao/svn/cacao/branches/twisti - -2007-03-28 20:28 twisti - - Initialized merge tracking via "svnmerge" with revisions "1-6086" - from - svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/branches/twisti - -2007-03-28 20:22 twisti - - Initialized merge tracking via "svnmerge" with revisions "1-7592" - from - svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/branches/twisti - -2007-03-28 13:29 twisti - - * src/vm/exceptions.c (throw_exception_exit_intern): Removed. - (throw_exception): Likewise. - (throw_exception_exit): Likewise. - (throw_main_exception): Likewise. - (throw_main_exception_exit): Likewise. - (throw_cacao_exception_exit): Likewise. - (exceptions_print_stacktrace): New function. - * src/vm/exceptions.h: Likewise. - - * src/vm/vm.c (vm_create): Use vm_abort or exceptions_print_stacktrace - instead of throw_main_exception_exit. - (vm_run): Likewise. - (vm_exit): Likewise. - (vm_get_mainclass_from_jar): Likewise. - - * src/threads/native/threads.c (threads_init): Use return instead of - throw_exception_exit. - (threads_startup_thread): Use vm_abort. - -2007-03-26 07:23 pm - - * src/vm/jit/s390/emit.c, - src/vm/jit/s390/md-abi.h, - src/vm/jit/s390/md.c, - src/vm/jit/s390/emit.h, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/tests/tests.java.pp, - src/vm/jit/s390/patcher.c, - src/vm/jit/s390/md-abi.c: Chaned a lot. - -2007-03-25 20:30 twisti - - Reverted patch 7268. - - * src/vm/jit/code.c: Reverted. - * src/vm/jit/code.h: Likewise. - * src/vm/jit/jit.c: Likewise. - * src/vm/jit/jit.h: Likewise. - * src/vmcore/loader.c: Likewise. - * src/vmcore/method.h: Likewise. - -2007-03-25 18:55 twisti - - * src/native/native.c (native_get_parametertypes): Removed. - (native_get_exceptiontypes): Likewise. - * src/native/native.h: Likewise. - - * src/vmcore/method.c (vm/builtin.h): Added. - (vm/resolve.h): Likewise. - (method_get_parametertypearray): New function. - (method_get_exceptionarray): Likewise. - * src/vmcore/method.h (method_get_parametertypearray): Added. - (method_get_exceptionarray): Likewise. - - * src/cacaoh/dummy.c (builtin_anewarray): Added. - (resolve_class_from_typedesc): Likewise. - - * src/native/vm/gnu/java_lang_reflect_Method.c (getParameterTypes): - Use method function. - (getExceptionTypes): Likewise. - * src/native/vm/gnu/java_lang_reflect_Constructor.c - (getParameterTypes): Likewise. - (getExceptionTypes): Likewise. - -2007-03-23 21:33 twisti - - * src/vm/builtin.c (builtin_isanysubclass): Removed. - (builtin_instanceof): Replaced builtin_isanysubclass with - class_isanysubclass. - (builtin_descriptorscompatible): Likewise. - - * src/vm/builtin.h (builtin_isanysubclass): Removed. - - * src/vm/access.c (access_is_accessible_member): Replaced - builtin_isanysubclass with class_isanysubclass. - * src/native/vm/java_lang_Class.c (isAssignableFrom): Likewise. - - * src/vm/jit/asmpart.h (castinfo): Removed. - - * src/vmcore/class.c (vm/jit/asmpart.h): Added. - (class_isanysubclass): New function. - - * src/vmcore/class.h (castinfo): Added. - (class_isanysubclass): Likewise. - - * src/cacaoh/dummy.c (asm_getclassvalues_atomic): New function. - (intrp_asm_getclassvalues_atomic): Likewise. - -2007-03-23 20:38 twisti - - * src/vm/builtin.c (builtin_isanysubclass_vftbl): Removed. - (builtin_descriptorscompatible): Use builtin_isanysubclass instead of - builtin_isanysubclass_vftbl. - -2007-03-23 19:10 twisti - - * src/vm/global.h (ACC_CLASS_PRIMITIVE): Defined. - - * src/vm/builtin.c (builtin_isanysubclass): Check for primitive - classes. - - * src/vmcore/linker.c (link_primitivetype_table): Set primitive flag. - -2007-03-23 18:51 twisti - - * src/vmcore/classcache.c (classcache_add_constraint) - [CLASSCACHE_VERBOSE]: Started to use log-functions. - (classcache_debug_dump): Likewise. - -2007-03-23 11:56 twisti - - * src/vm/jit/powerpc/emit.c (emit_load): Use switch-case instead of - if-else contruct. - (emit_store): Likewise. - (emit_copy): Likewise. - -2007-03-22 13:55 michi - - * src/vm/jit/arm/codegen.c (codegen) [!ENABLE_SOFTFLOAT]: Fixed - position of - soft null pointer checks in PUTFIELD and GETFIELD. - -2007-03-21 14:26 twisti - - * src/vmcore/statistics.c (size_lock_record_pool): Added. - (statistics_print_memory_usage): Print new variable. - - * src/vmcore/statistics.h (size_lock_record_pool): Added. - - * src/threads/native/lock.c (lock_record_alloc_new_pool): Added - statistics. - -2007-03-21 13:27 twisti - - * src/vmcore/statistics.c (size_threadobject, size_lock_hashtable) - (size_lock_waiter): Added. - (statistics_print_memory_usage): Print new variables. - - * src/vmcore/statistics.h (size_threadobject, size_lock_hashtable) - (size_lock_waiter): Added. - - * src/threads/native/lock.c (vmcore/options.h): Added. - [ENABLE_STATISTICS] (vmcore/statistics.h): Added. - (lock_hashtable_init): Added statistics. - (lock_hashtable_grow): Likewise. - (lock_record_add_waiter): Likewise. - (lock_record_remove_waiter): Likewise. - - * src/threads/native/threads.c [ENABLE_STATISTICS] - (vmcore/statistics.h): Added. - (threads_preinit): Added statistics. - (threads_init): Likewise. - (threads_start_javathread): Likewise. - (threads_attach_current_thread): Likewise. - (threads_detach_thread): Likewise. - -2007-03-21 13:19 twisti - - * src/vmcore/zip.c (zip_get): Don't assign in if-statement, this makes - debugging a bit easier. - -2007-03-21 13:18 twisti - - * src/vmcore/linker.c (link_primitivetype_table): Set super class - explicitly to NULL. - (linker_compute_subclasses): Indent. - -2007-03-20 00:25 ajordan - - * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): using this for - native param allocation. No need for my own version of this anymore. - * src/vm/jit/sparc64/codegen.c: Likewise. - -2007-03-17 13:12 twisti - - * src/vm/builtin.h (builtin_isanysubclass_vftbl): Removed, made - static. - -2007-03-17 13:11 twisti - - * src/vm/builtin.c (builtin_isanysubclass): Code cleanup. - (builtin_isanysubclass_vftbl): Likewise. - -2007-03-17 13:10 twisti - - * src/native/vm/gnu/java_lang_reflect_Method.c (vm/resolve.h): Added. - -2007-03-17 12:57 twisti - - * src/vm/builtin.c (builtin_isanysubclass): Cleanup and comments. - -2007-03-16 23:00 pm - - * src/vm/exceptions.c (exceptions_handle_exception): 31 bit address - comparison for S390. These address comparison macros need to be moved - to some header. - * src/vm/jit/s390/emit.c, - src/vm/jit/s390/md.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/arch.h, - src/vm/jit/s390/patcher.c, - src/vm/jit/s390/md-abi.c, - src/vm/jit/s390/tests/tests.java.pp, - src/vm/jit/s390/tests/Makefile: Changed a lot. - -2007-03-15 09:28 twisti - - * src/native/jni.c (_Jv_jni_invokeNative): Release memory in exception - case. - -2007-03-15 08:23 pm - - * src/vm/jit/s390/tests/tests.java.pp: added INT2CHAR test testing - negative values. - -2007-03-15 07:07 pm - - * src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h: Changed a lot. - * src/vm/jit/s390/tests, - src/vm/jit/s390/tests/tests.java.pp, - src/vm/jit/s390/tests/Makefile: Added opcode tests in java. - -2007-03-14 21:54 twisti - - * src/vmcore/statistics.c (size_string): Added. - (statistics_print_memory_usage): Likewise. - * src/vmcore/statistics.h (size_string): Likewise. - - * src/vm/string.c (vmcore/statistics.h): Added. - (literalstring_u2): Added statistics. - -2007-03-14 21:18 twisti - - * src/vm/jit/alpha/emit.c (emit_load): Use switch-case instead of - if-else contruct. - (emit_store): Likewise. - (emit_copy): Likewise. - -2007-03-14 21:16 twisti - - * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Added temporarily. - -2007-03-14 17:31 michi - - * src/vm/jit/arm/codegen.c (codegen): All the long compares have a - different - implementation now. - -2007-03-14 16:44 michi - - * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Fixed bug with - inmemory - arguments, which caused some crashes with verbose-calls. - -2007-03-14 12:00 michi - - * src/mm/nogc.c: Fixed includes and exceptions. - -2007-03-13 20:31 twisti - - * src/vm/jit/i386/emit.c (emit_load): Use switch-case instead of - if-else contruct. - (emit_store): Likewise. - (emit_copy): Likewise. - * src/vm/jit/i386/codegen.c (codegen): Fixed compiler warning. - -2007-03-13 16:32 michi - - * src/vm/jit/arm/codegen.c (codegen): Long branches are implemented - differently now. - - * src/vm/jit/arm/codegen.h (M_COMPARE): Easier macros without - overjumps. - (M_MOVEQ_IMM, M_MOVGT_IMM, M_ADDHI_IMM, M_SUBLO_IMM, M_CMPEQ_IMM): - New macro. - -2007-03-13 13:19 michi - - * src/vm/jit/arm/linux/Makefile.am: Fixed include path to care about - builddir. - -2007-03-12 13:34 twisti - - * src/vm/jit/codegen.c (codegen): Change the operand direction of some - macros. Started to implement long-compares differently. - - * src/vm/jit/codegen.h (M_AND, M_ORR, M_EOR, M_AND_IMM, M_MOVEQ) - (M_MOVVS_IMM, M_MOVNE_IMM, M_MOVLT_IMM, M_MOVLS_IMM): Changed operand - direction. - (M_ORR_S, M_CMPEQ, M_CMPLE): New macro. - -2007-03-12 13:17 twisti - - * src/vm/jit/arm/md.c (vm/jit/codegen-common.h): Added. - -2007-03-12 10:11 twisti - - * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c - (vm/vm.h): Added. - (open): Call vm_abort. - - * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c - (unistd.h): Added. - (readByte): New function. - (writeBuf): Likewise. - (available0): Likewise. - (close0): Likewise. - -2007-03-09 21:26 twisti - - * tests/regression/resolving (svn:ignore): Added. - * tests/regression/resolving/classes1: Likewise. - * tests/regression/resolving/classes2: Likewise. - * tests/regression/resolving/classes3: Likewise. - -2007-03-08 02:59 michi - - * src/threads/native/threads.c (threads_init) [!ENABLE_GC_CACAO]: - Fixed bug for - lost java.lang.Thread object of mainthread with BoehmGC. - - * src/native/vm/java_lang_Thread.c: Fixed includes to prevend - compiler warnings. - -2007-03-07 14:05 twisti - - * src/vm/jit/mips/md.c (vm/jit/codegen-common.h): Temporarily added. - -2007-03-07 13:12 twisti - - * src/vm/jit/x86_64/emit.c (emit_call_reg): Call emit_rex with size 0. - -2007-03-07 12:37 twisti - - * src/vm/jit/x86_64/asmpart.S (asm_compare_and_swap): New function. - (asm_memory_barrier): Likewise. - -2007-03-07 11:47 michi - - * src/threads/native/threads.h (threadobject): This structure is no - longer an - instance of java.lang.Thread, but contains a reference to it. - - * src/threads/native/threads.c (threads_start_javathread): Added. - - * src/threads/threads-common.c: Adapted to above changes. - * src/threads/native/threads.c: See above. - * src/native/vm/java_lang_Thread.c: See above. - -2007-03-07 00:32 ajordan - - * src/vm/jit/sparc64/md-abi.h: increased number of JIT float argument - registers to 5. - * src/vm/jit/sparc64/md-asm.h: likewise. - * src/vm/jit/sparc64/md-abi.c: likewise. - - * src/vm/jit/sparc64/asmpart.S: added floating point argument - handling in asm_vm_call. - -2007-03-06 18:55 ajordan - - * src/vm/jit/sparc64/emit.c: emit_{load,store,copy} changed to - switch/case for handling different types. - - * src/vm/jit/sparc64/codegen.h: fixed f2d and d2f conversion. - - * src/vm/jit/sparc64/md-abi.c: removed md_native_reg_setup(), not - needed any longer. - - * src/vm/jit/sparc64/codegen.c: implemented ICMD_MULTIANEWARRAY. - fixed FRETURN, DRETURN. - repaired native float arg passing. - -2007-03-06 17:01 twisti - - * src/vm/signal.c (arch.h): Added. - * src/vm/vm.c (vm_create): Reenabled signal-thread. This only works on - NPTL-threads and NOT with linuxthreads! - - * src/vm/signal.c (signal_init): Reenabled blocking for SIGINT and - SIGQUIT. - -2007-03-06 11:12 twisti - - * src/vmcore/statistics.c (vm/jit/code.h): Added for codeinfo. - (vmcore/class.h): Added. - (vmcore/field.h): Likewise. - (vmcore/method.h): Likewise. - - * src/vm/jit/optimizing/recompile.c (vm/jit/code.h): Likewise. - (vm/jit/jit.h): Likewise. - - * src/vm/jit/x86_64/md.c (vm/jit/codegen-common.h): Likewise. - * src/vm/jit/x86_64/md-abi.c (vm/jit/jit.h): Likewise. - -2007-03-06 00:27 edwin - - * src/vm/jit_interface.h: Added Id keyword. - -2007-03-06 00:26 edwin - - * src/vmcore/resolve.c: Moved back to src/vm/resolve.c. - * src/vmcore/resolve.h: Moved back to src/vm/resolve.h. - * src/vm/jit/code.h (codeinfo): Moved typedef to method.h. - (code_get_methodinfo_for_pv): Added prototype. - * src/vmcore/method.h (codeinfo): Moved typedef here. - - * src/vm/jit_interface.h: New file. - - * src/vm/Makefile.am: Added resolve.[ch] and jit_interface.h. - * src/vmcore/Makefile.am: Removed resolve.[ch]. - - * src/vmcore/class.c: Include "arch.h", but don't include "resolve.h". - - * src/vmcore/method.c (method_vftbl_lookup): - Use code_get_methodinfo_for_pv. - - * src/vmcore/linker.c (resolve_classref_or_classinfo_eager): Added - copy of prototype to avoid bootstrapping issues. - - * src/cacaoh/dummy.c (code_get_methodinfo_for_pv): New dummy. - (resolve_classref_or_classinfo_eager): Simple implementation that does - not use resolve.c code. - (typeinfo_init_class): Removed dummy. - (typeinfo_init_classinfo): Likewise. - (typeinfo_is_assignable_to_class): Likewise. - (typeinfo_print): Likewise. - - * many other files: Changed #include "vmcore/resolve.h" to - "vm/resolve.h". - -2007-03-06 00:02 edwin - - * src/vmcore/linker.c (link_class_intern): - Use resolve_classref_or_classinfo_eager. - -2007-03-05 23:56 edwin - - * src/cacaoh/headers.c: Don't include asmpart.h. - -2007-03-05 23:50 edwin - - * src/native/native.c (native_get_exceptiontypes): - Use resolve_classref_or_classinfo_eager. - -2007-03-05 17:44 edwin - - * src/native/vm/java_lang_Class.c (_Jv_java_lang_Class_getSuperclass), - (_Jv_java_lang_Class_getDeclaringClass) - (_Jv_java_lang_Class_getDeclaredClasses): - Use resolve_classref_or_classinfo_eager. - -2007-03-05 17:34 edwin - - * src/vm/builtin.h (builtintable_replace_function): Don't use - instruction * to avoid bootstrapping problems. - * src/vm/builtin.c (builtintable_replace_function): Likewise. - -2007-03-05 17:32 edwin - - * src/vm/jit/code.c (code_get_methodinfo_from_pv): New function. - -2007-03-05 16:53 edwin - - * src/vmcore/resolve.h, src/vmcore/resolve.c - (resolve_classref_or_classinfo_eager): New function. - -2007-03-05 08:38 pm - - * src/vm/jit/s390/md-abi.h, - src/vm/jit/s390/emit.c, - src/vm/jit/s390/emit.h, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/patcher.c: Changed a lot. - -2007-03-04 20:10 edwin - - * src/vm/jit/replace.c: Handle countdown traps. Request optimization - of hot methods and their callers. - - * src/vm/jit/jit.c (jit_compile): Set JITDATA_FLAG_COUNTDOWN for - inlining. - (jit_recompile): Set JITDATA_FLAG_INLINE for inlining. - -2007-03-04 19:13 edwin - - * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c, - src/vmcore/linker.c: Replayed lost parts of commit 7228. - - * src/vm/jit/intrp/intrp.h: Added missing #include to make it compile. - - * src/vm/jit/inline/inline.c: Fixed names of vmcore/ #include files. - -2007-03-04 18:07 twisti - - * src/vm/jit/x86_64/emit.c (emit_load): Use switch-case instead of - if-else contruct. - (emit_store): Likewise. - (emit_copy): Likewise. - -2007-03-04 14:46 edwin - - * src/vm/jit/i386/codegen.c (codegen): Emit code for countdown traps. - - * src/vm/jit/i386/emit.c (emit_replacement_stubs): Add jump reference - for countdown traps. - -2007-03-04 14:22 edwin - - * src/vmcore/method.h (methodinfo): Added hitcountdown field. (Only - if ENABLE_REPLACEMENT). - - * src/vmcore/loader.c (loader_load_method): Initialize hitcountdown - field. - -2007-03-04 14:02 edwin - - * src/vm/jit/inline/inline.c: Committed breadth-first inlining code. - -2007-03-04 12:32 edwin - - * tests/regression/resolving/test_return_subtype_ok.java: New test. - - * tests/regression/resolving/Makefile.am: Added new test. - -2007-03-04 12:28 edwin - - * tests/regression/resolving/test_return_subtype_violated.java: - New test. - - * tests/regression/resolving/Makefile.am: Added new test. - -2007-03-02 23:28 pm - - * src/vm/jit/s390/emit.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/md-asm.h, - src/vm/jit/s390/patcher.c, - src/vm/jit/s390/asmpart.S: Changed a lot in S390 codegen. - -2007-03-02 19:45 edwin - - * src/vmcore/classcache.c: Print debug messages to stdout. - -2007-03-02 19:44 edwin - - * configure.ac: Added Makefiles of resolving test suite. - -2007-03-02 19:42 edwin - - * tests/regression/resolving: Added resolving test suite. These tests - check lazy loading, classloader handling, loading & subtype - constraints. - -2007-03-01 13:49 edwin - - * src/vmcore/resolve.h, src/vmcore/resolve.c - (resolve_class_eager_no_access_check): New function. - - * src/vm/jit/powerpc/patcher.c: Use - resolve_class_eager_no_access_check. - * src/vm/jit/arm/patcher.c: Likewise. - * src/vm/jit/sparc64/patcher.c: Likewise. - * src/vm/jit/alpha/patcher.c: Likewise. - * src/vm/jit/s390/patcher.c: Likewise. - * src/vm/jit/mips/patcher.c: Likewise. - * src/vm/jit/powerpc64/patcher.c: Likewise. - * src/vm/jit/i386/patcher.c: Likewise. - * src/vm/jit/x86_64/patcher.c: Likewise. - -2007-03-01 12:39 twisti - - * src/native/vm/Makefile.am [ENABLE_JAVASE] (CLASSLOADER_SOURCES): - Added. - (libnativevm_la_SOURCES): Use CLASSLOADER_SOURCES. - - * src/native/vm/java_lang_ClassLoader.c (native/jni.h): Added. - -2007-03-01 12:32 edwin - - * src/vmcore/resolve.c (resolve_classref_or_classinfo): Always use - refmethod->class as the referring class, if it is available. - -2007-02-28 23:57 twisti - - * src/vmcore/classcache.c (toolbox/logging.h): Added. - (classcache_merge_class_entries): Replace log_text with log_println. - (classcache_store): Likewise. - (classcache_store_defined): Likewise. + * src/vm/vm.h (mainstring): Removed. (mainclass): Likewise. + [0dc5ef768134] + + * src/threads/none/thread-none.h: + * src/threads/none/thread-none.h (THREADINFO): Removed. + [a68de3a1d5c6] + + * src/threads/none/thread-none.h, src/threads/posix/thread-posix.h: + * src/threads/none/thread-none.h (THREADSPECIFIC): Removed because + it's not used anymore. + * src/threads/posix/thread-posix.h: Likewise. + [5925f8258a23] + +2008-05-11 Stefan Ring + + * src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/x86_64/asmpart.S (asm_get_cycle_count): Repaired + --enable-cycles-stats. + [a63c117e1ebd] + + * src/mm/boehm-gc/pthread_stop_world.c, src/threads/posix/thread- + posix.c: + Merged cleanup -> gc7-branch + [d12524409a9c] + + * configure.ac, src/lib/Makefile.am, + src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/lib/gnu/gnu/classpath/VMStackWalker.java, + src/lib/gnu/gnu/classpath/VMSystemProperties.java, + src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/gnu/java/lang/VMClassLoader.java, + src/lib/gnu/java/lang/VMString.java, + src/lib/gnu/java/lang/VMThread.java, + src/lib/gnu/java/lang/VMThrowable.java, + src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/java/security/VMAccessController.java, + src/lib/gnu/sun/misc/Unsafe.java, + src/lib/gnu/sun/reflect/ConstantPool.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/ + sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr + c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx + y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/ + lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h, + src/threads/native/Makefile.am, src/threads/native/generic- + primitives.h, src/threads/native/lock.c, src/threads/native/lock.h, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/none/threads.h, src/threads/posix/thread-posix.c, + src/threads/threads-common.c, src/threads/threads-common.h, + src/vm/jit/m68k/linux/md-os.h, tests/A2.java, tests/AA.java, + tests/AA1.java, tests/AA2.java, tests/BB.java, tests/C.java, + tests/C2.java, tests/C3.java, tests/CC.java, tests/D.java, + tests/DD.java, tests/EE.java, tests/GG.java, tests/HI2.java, + tests/II.java, tests/IIAA.java, tests/IIBB.java, tests/IICC.java, + tests/IIexample.java, tests/n.java, + tests/regression/HelloWorld.java, + tests/regression/clinitexception.2output, + tests/regression/clinitexception.java, + tests/regression/codepatching/Makefile.am, + tests/regression/codepatching/aastoreconstClass.java, + tests/regression/codepatching/checkcastC.java, + tests/regression/codepatching/checkcastI.java, + tests/regression/codepatching/getfieldD.java, + tests/regression/codepatching/getfieldF.java, + tests/regression/codepatching/getfieldI.java, + tests/regression/codepatching/getfieldJ.java, + tests/regression/codepatching/getfieldL.java, + tests/regression/codepatching/getstaticD.java, + tests/regression/codepatching/getstaticF.java, + tests/regression/codepatching/getstaticI.java, + tests/regression/codepatching/getstaticJ.java, + tests/regression/codepatching/getstaticL.java, + tests/regression/codepatching/instanceofC.java, + tests/regression/codepatching/instanceofI.java, + tests/regression/codepatching/invokespecial.java, + tests/regression/codepatching/invokestatic.java, + tests/regression/codepatching/multianewarray.java, + tests/regression/codepatching/newarray.java, + tests/regression/codepatching/putfieldD.java, + tests/regression/codepatching/putfieldF.java, + tests/regression/codepatching/putfieldI.java, + tests/regression/codepatching/putfieldJ.java, + tests/regression/codepatching/putfieldL.java, + tests/regression/codepatching/putfieldconstC.java, + tests/regression/codepatching/putfieldconstD.java, + tests/regression/codepatching/putfieldconstF.java, + tests/regression/codepatching/putfieldconstI.java, + tests/regression/codepatching/putfieldconstJ.java, + tests/regression/codepatching/putfieldconstL.java, + tests/regression/codepatching/putstaticD.java, + tests/regression/codepatching/putstaticF.java, + tests/regression/codepatching/putstaticI.java, + tests/regression/codepatching/putstaticJ.java, + tests/regression/codepatching/putstaticL.java, + tests/regression/codepatching/putstaticconstC.java, + tests/regression/codepatching/putstaticconstD.java, + tests/regression/codepatching/putstaticconstF.java, + tests/regression/codepatching/putstaticconstI.java, + tests/regression/codepatching/putstaticconstJ.java, + tests/regression/codepatching/putstaticconstL.java, + tests/regression/codepatching/test.java, + tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j, + tests/regression/jasmin/test_verify_fail_jsr_recursion.j, + tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j, + tests/scribble.java: + Clean merge -> gc7-branch + [98fcc574613e] + + * src/mm/boehm-gc/pthread_stop_world.c, src/threads/posix/thread- + posix.c, src/threads/posix/thread-posix.h: + * src/mm/boehm-gc/pthread_stop_world.c: Cleaned up some old Boehm- + based stop-the-world code. + * src/threads/posix/thread-posix.c: Likewise. + * src/threads/posix/thread-posix.h: Likewise. + [f1539535de4a] + +2008-05-10 Peter Molnar + + * src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen_emit): For ICMD_LALOAD, + ICMD_LASTORE, ICMD_DALOAD, fixed offset of first array element. This + fixes the failing dacapo antlr benchmark. + [6d6dc5996014] + +2008-05-09 Stefan Ring + + * src/threads/posix/lock.c: + * src/threads/posix/lock.c: Replaced UTF-8 characters with ASCII. + [d3272044b8ba] + +2008-05-08 Christian Thalinger + + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99rc5. + [487fdcb54770] + + * src/vm/jit/s390/md.c: + * src/vm/jit/s390/md.c (md_executionstate_read): New function (stub + only). (md_executionstate_write): Likewise. + [1f78ff4da6c6] + +2008-05-07 Christian Thalinger + + * m4/cacaoh.m4, src/Makefile.am: + * m4/cacaoh.m4 (AC_CHECK_WITH_CACAOH): Don't set ENABLE_CACAOH. + * src/Makefile.am [ENABLE_CACAOH] (CACAOH_DIR): Removed. (SUBDIRS): + Always build cacaoh because it's required e.g. when running make + check on the target. + [94ddb4bbdab5] + +2008-05-06 Christian Thalinger + + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99rc4. + [7eb41343fb41] + + * src/vmcore/system.h: + * src/vmcore/system.h (system_scandir) [__IRIX__]: On IRIX the + signature is a bit different. This prevents a lot of compiler + warnings. + [07aeecc03c14] + + * src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (md_executionstate_read): New + function. (md_executionstate_write): Likewise. + [a0a153d01b3b] + + * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/md-asm.h: + * src/vm/jit/mips/asmpart.S: Replaced ldc1/sdc1 with l.d/s.d macros. + * src/vm/jit/mips/md-asm.h: Likewise. + [683df1b2eac0] + + * src/vm/jit/alpha/md-asm.h: + * src/vm/jit/alpha/md-asm.h (SAVE_RETURN_REGISTERS): Removed, it's + not used anymore. (RESTORE_RETURN_REGISTERS): Likewise. + [e4ed14b8cf28] + + * src/mm/boehm.c, src/mm/gc-common.h: + * src/mm/boehm.c: Use stdint-types. + * src/mm/gc-common.h: Likewise. + [ddc2fa158b02] + + * tests/regression/jasmin/Makefile.am: + * tests/regression/jasmin/Makefile.am (build): Added cup.jar to + classpath. + [da35822eaaf4] + + * tests/regression/bugzilla/PR65.java: + * tests/regression/bugzilla/PR65.java (test): Fixed compiler + warning. + [7f91d6142bfa] -2007-02-28 23:39 twisti +2008-05-05 Stefan Ring - * src/cacaoh/dummy.c (typeinfo_print): Added. + * src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/stacktrace.c: + Merged with tip. + [630215c2fbf8] -2007-02-28 23:27 edwin + * src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/stacktrace.c: + * src/vm/jit/i386/darwin/md-asm.h: Repaired --enable-cycles-stats. + * src/vm/jit/stacktrace.c: Likewise. + [36b6519d4b72] - * src/vm/jit/verify/typecheck.c (handle_basic_block): Move the - printing - of the block to a point where jd->var is already valid. +2008-05-03 Stefan Ring -2007-02-28 23:20 edwin + * src/cacaoh/dummy.c, src/threads/critical.h, src/vm/jit/i386/cygwin + /md-asm.h, src/vm/jit/i386/darwin/md-asm.h, + src/vm/jit/intrp/asmpart.c: + * src/cacaoh/dummy.c: Removed asm_criticalsections and + asm_getclassvalues_atomic. They have not been used anywhere in a + long time. + * src/threads/critical.h: Likewise. + * src/vm/jit/i386/cygwin/md-asm.h: Likewise. + * src/vm/jit/i386/darwin/md-asm.h: Likewise. + * src/vm/jit/intrp/asmpart.c: Likewise. + [dc465902bf87] + + * tests/regression/bugzilla/All.java, + tests/regression/bugzilla/PR65.java: + * tests/regression/bugzilla/All.java: Added test case for PR65. + [c1ec27d0f8f0] + +2008-05-02 Stefan Ring + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_descriptorscompatible): Experimental fix + for bugzilla bug #65. + [4436cc114a77] + +2008-04-30 Stefan Ring + + * tests/threads/threadInterrupt.java, + tests/threads/waitAndInterrupt.java: + * tests/threads/threadInterrupt.java: Added brief comment explaining + the purpose of this test. + * tests/threads/waitAndInterrupt.java: Likewise. + [9ca0035d4d04] + + * tests/weakref.java: + * tests/weakref.java: New test for weak references. + [6647d194cff1] + + * src/vm/jit/i386/machine-instr.h, src/vmcore/linker.c, + tests/threads/threadInterrupt.java, + tests/threads/waitAndInterrupt.java: + Backed out changeset ecf451e74e7e + [d0882f1633d5] + + * src/vm/jit/i386/machine-instr.h, src/vmcore/linker.c, + tests/threads/threadInterrupt.java, + tests/threads/waitAndInterrupt.java: + * tests/threads/threadInterrupt.java: Added brief comment explaining + the purpose of this test. + * tests/threads/waitAndInterrupt.java: Likewise. + [ecf451e74e7e] + +2008-04-29 Christian Thalinger + + * tests/regression/jasmin/Makefile.am, + tests/regression/jasmin/runtest, + tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j, + tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j-no, + tests/regression/jasmin/test_verify_fail_jsr_recursion.j, + tests/regression/jasmin/test_verify_fail_jsr_recursion.j-no, + tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j, + tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j- + no: + * tests/regression/jasmin/Makefile.am (JAVA): Prefix + LD_LIBRARY_PATH. (JASMIN_TESTS): Removed. (EXTRA_DIST): Removed + JASMIN_TESTS, added $(srcdir)/*.j. (build): Target added. (run): + Likewise. + * tests/regression/jasmin/runtest: Removed compilation of the tests. - * src/vm/jit/stack.c (stack_analyse): Minor STACK_VERBOSE - improvements. + * tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j: + Moved from here... + * tests/regression/jasmin/test_verify_fail_jsr_multiple_returns.j-no: + ... to here. -2007-02-28 22:50 edwin + * tests/regression/jasmin/test_verify_fail_jsr_recursion.j: + Likewise. + * tests/regression/jasmin/test_verify_fail_jsr_recursion.j-no: + Likewise. * - tests/regression/jasmin/test_verify_ok_local_as_retaddr_and_reference.j: - New test. - * tests/regression/jasmin/Makefile.am: Added new test. - -2007-02-28 22:31 twisti - - * src/vm/vm.c (vm_create): Changed initialization order. Call - properties_postinit later, since it puts a pointer to - _Jv_bootclasspath into the properties list. - -2007-02-28 22:30 edwin - - * src/vm/jit/stack.c (stack_analyse): Fix: reset TYPE_VOID to - TYPE_ADR at the end of stack_analyse. + tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j: + Likewise. + * tests/regression/jasmin/test_verify_fail_jsr_recursion_terminates.j- + no: Likewise. + [845282affca0] + + * tests/regression/HelloWorld.java, tests/regression/Makefile.am: + * tests/regression/Makefile.am (JAVACCMD): Added -source 1.5 -target + 1.5 -nowarn. (SOURCE_FILES): Removed HelloWorld.java. + (SIMPLE_JAVA_TESTS): Removed. (run): Target added. + * tests/regression/HelloWorld.java: Removed. + [e91af259734b] + + * tests/regression/assertion/Makefile.am: + * tests/regression/assertion/Makefile.am (JAVACCMD): Added -source + 1.5 + -target 1.5. (run): Target added. + [4c49e26a4bd4] + + * tests/regression/bugzilla/Makefile.am: + * tests/regression/bugzilla/Makefile.am (run): Target added. + [d4377a3eef9c] + + * tests/regression/junit/Makefile.am: + * tests/regression/junit/Makefile.am (JAVACCMD): Added -source 1.5 + -target 1.5 -nowarn (TODO: move this into a variable). (run): Target + added. + [46571e5bbf57] -2007-02-28 22:00 twisti +2008-04-28 Christian Thalinger - * src/vm/access.h (access_check_caller): Renamed to - access_check_member. + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99rc3. + [c197b02ff123] -2007-02-28 20:07 twisti + * .hgignore: + * .hgignore: Added m4/libtool.m4, m4/ltoptions.m4, m4/ltsugar.m4, + m4/ltversion.m4, m4/lt~obsolete.m4. + [ebbb6e7a1914] - * src/vm/access.c (access_check_caller): Renamed to - access_check_member. Don't call access_is_accessible_class, this is - wrong. - - * src/native/vm/gnu/java_lang_reflect_Constructor.c (constructNative): - Use access_check_member. - - * src/native/vm/gnu/java_lang_reflect_Field.c (CHECKFIELDACCESS): - Removed. - (cacao_get_field_address): Use access_check_member. - - * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): + * configure.ac, m4/jre-layout.m4, src/cacao/cacao.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/vm/properties.c, src/vm/vm.c, src/vmcore/system.h: + * m4/jre-layout.m4 (AC_CHECK_WITH_JRE_LAYOUT): Renamed to + AC_CHECK_ENABLE_JRE_LAYOUT. + * configure.ac: Likewise. + + * src/cacao/cacao.c: Renamed WITH_JRE_LAYOUT to ENABLE_JRE_LAYOUT. + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: Likewise. + * src/vm/properties.c: Likewise. + * src/vm/vm.c: Likewise. + * src/vmcore/system.h: Likewise. + [59ee69e0f277] + + * .hgignore, configure.ac, doc/Makefile.am, doc/doxygen/Doxyfile, + doc/doxygen/Makefile.am: + * .hgignore: Added doc/doxygen/html, doc/doxygen/latex. + * configure.ac (AC_CONFIG_FILES): Added doc/doxygen/Makefile. + * doc/Makefile.am (SUBDIRS): Added doxygen. + * doc/doxygen/Doxyfile: New file. + * doc/doxygen/Makefile.am: Likewise. + [809dfcaf02f9] + + * src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/linux/md-os.c (md_executionstate_read): New + function (but not implemted yet). (md_executionstate_write): Likewise. + [0ad564b6fc63] + + * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.h, + src/vm/jit/mips/linux/md-os.c, src/vm/vm.c: + * Merged in new trap code (twisti-branch). + [8a2df154e6e2] + + * src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/md-trap.h, src/vm/jit/sparc64/solaris/md-os.c: + * src/vm/jit/sparc64/Makefile.am (libarch_la_SOURCES): Added md- + trap.h. + * src/vm/jit/sparc64/codegen.c: Use new trap stuff. + * src/vm/jit/sparc64/emit.c: Likewise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + * src/vm/jit/sparc64/md-trap.h: New file. + * src/vm/jit/sparc64/solaris/md-os.c: Use new trap stuff. + [55d40b03e4f4] + + * src/vm/jit/powerpc64/md.c: + * src/vm/jit/powerpc64/md.c (md_patch_replacement_point): Use new + trap stuff. + [6b82b87fc058] + + * src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-os.h: + * src/vm/jit/m68k/linux/md-os.h: Removed. + * src/vm/jit/m68k/linux/Makefile.am (libmd_la_SOURCES): Removed md- + os.h. + [64717fad182b] + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_handler): Fixed compiler + warnings. + [6e1285e13d18] + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_handler) + [ENABLE_DISASSEMBLER]: Use disassembler to print machine code. + [f7850a0245ba] + + * src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/md-trap.h: + * src/vm/jit/m68k/Makefile.am (libarch_la_SOURCES): Added md-trap.h. + * src/vm/jit/m68k/codegen.c: Use new trap stuff. + * src/vm/jit/m68k/emit.c: Likewise. + * src/vm/jit/m68k/linux/md-os.c: Likewise. + * src/vm/jit/m68k/md-trap.h: New file. + [de0973a17a25] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [__I386__]: Enable tracing native methods. + (codegen_finish_native_call): Likewise. + [784b956d8ecd] -2007-02-28 13:25 twisti - - * src/native/vm/java_lang_ClassLoader.c (vm/stringlocal.h): Added. - -2007-02-28 13:23 twisti - - * src/native/vm/java_lang_ClassLoader.c (defineClass): Added - loader-variable for convenience. + * * Merged with tip. + [22e6633864b8] -2007-02-28 07:22 pm + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call): Added + __M68K__ to trace native methods. (codegen_finish_native_call): + Likewise. + [ee12606c51c1] - * src/vm/jit/s390/codegen.c (codegen): Added ICMD_AASTORE. - * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Added exception - handler. - * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Likewise. + * src/vm/jit/m68k/codegen.c: + * src/vm/jit/m68k/codegen.c (codegen_emit_stub_native): Removed old, + deprecated stuff (patcher and call trace). + [17c9c2559e52] -2007-02-27 21:13 twisti + * src/vm/jit/trace.c: + * src/vm/jit/trace.c (trace_java_call_enter): Don't trace builtins, + it does not work (because of the ABI). (trace_java_call_exit): + Likewise. + [928814cce084] + + * src/vmcore/method.h: + * src/vmcore/method.h (method_is_builtin): New function. + [137038362c4b] + + * src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Added + patch from http://bugs.debian.org/cgi- + bin/bugreport.cgi?bug=441122#35. + [4b1912970eac] + + * src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/md-trap.h: + * src/vm/jit/powerpc/Makefile.am (libarch_la_SOURCES): Added md- + trap.h. + * src/vm/jit/powerpc/codegen.c: Use new trap stuff. + * src/vm/jit/powerpc/emit.c: Likewise. + * src/vm/jit/powerpc/linux/md-os.c: Likewise. + * src/vm/jit/powerpc/md-trap.h: New file. + [f2da4ab3dcba] + + * src/vm/jit/s390/Makefile.am, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-trap.h, + src/vm/jit/s390/md.c: + * src/vm/jit/s390/Makefile.am (libarch_la_SOURCES): Added md-trap.h. + * src/vm/jit/s390/codegen.c: Use new trap stuff. + * src/vm/jit/s390/emit.c: Likewise. + * src/vm/jit/s390/md-trap.h: New file. + * src/vm/jit/s390/md.c: Use new trap stuff. + [e7b71db899d5] + + * src/vm/jit/mips/Makefile.am, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md-trap.h: + * src/vm/jit/mips/Makefile.am (libarch_la_SOURCES): Added md-trap.h. + * src/vm/jit/mips/codegen.c: Use new trap stuff. + * src/vm/jit/mips/emit.c: Likewise. + * src/vm/jit/mips/linux/md-os.c: Likewise. + * src/vm/jit/mips/md-trap.h: New file. + [64f0215ce5fe] + + * src/vm/jit/arm/Makefile.am, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/md-trap.h: + * src/vm/jit/arm/Makefile.am (libarch_la_SOURCES): Added md-trap.h. + * src/vm/jit/arm/emit.c: Use new trap stuff. + * src/vm/jit/arm/linux/md-os.c: Likewise. + * src/vm/jit/arm/md-trap.h: New file. + [f7e39c89f923] + + * src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md-trap.h: + * src/vm/jit/powerpc64/Makefile.am (libarch_la_SOURCES): Added md- + trap.h. + * src/vm/jit/powerpc64/codegen.c: Use new trap stuff. + * src/vm/jit/powerpc64/emit.c: Likewise. + * src/vm/jit/powerpc64/linux/md-os.c: Likewise. + * src/vm/jit/powerpc64/md-trap.h: New file. + [a9eafa03d678] + + * src/vm/jit/alpha/Makefile.am, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md-trap.h, src/vm/jit/alpha/md.c: + * src/vm/jit/alpha/Makefile.am (libarch_la_SOURCES): Added md- + trap.h. + * src/vm/jit/alpha/codegen.c: Use new trap stuff. + * src/vm/jit/alpha/emit.c: Likewise. + * src/vm/jit/alpha/linux/md-os.c: Likewise. + * src/vm/jit/alpha/md-trap.h: New file. + * src/vm/jit/alpha/md.c: Use new trap stuff. + [f97606f11648] + +2008-04-27 Christian Thalinger + + * configure.ac: + * configure.ac (AC_INIT): Bumped version to 0.99rc2. + [e0c01948bb61] + + * * Merged with ea434f5851f4. + [72249b4c9b1d] + + * .hgignore, configure.ac, tests/regression/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/codepatching/aastoreconstClass.java, + tests/regression/codepatching/checkcastC.java, + tests/regression/codepatching/checkcastI.java, + tests/regression/codepatching/getfieldD.java, + tests/regression/codepatching/getfieldF.java, + tests/regression/codepatching/getfieldI.java, + tests/regression/codepatching/getfieldJ.java, + tests/regression/codepatching/getfieldL.java, + tests/regression/codepatching/getstaticD.java, + tests/regression/codepatching/getstaticF.java, + tests/regression/codepatching/getstaticI.java, + tests/regression/codepatching/getstaticJ.java, + tests/regression/codepatching/getstaticL.java, + tests/regression/codepatching/instanceofC.java, + tests/regression/codepatching/instanceofI.java, + tests/regression/codepatching/invokespecial.java, + tests/regression/codepatching/invokestatic.java, + tests/regression/codepatching/multianewarray.java, + tests/regression/codepatching/newarray.java, + tests/regression/codepatching/putfieldD.java, + tests/regression/codepatching/putfieldF.java, + tests/regression/codepatching/putfieldI.java, + tests/regression/codepatching/putfieldJ.java, + tests/regression/codepatching/putfieldL.java, + tests/regression/codepatching/putfieldconstC.java, + tests/regression/codepatching/putfieldconstD.java, + tests/regression/codepatching/putfieldconstF.java, + tests/regression/codepatching/putfieldconstI.java, + tests/regression/codepatching/putfieldconstJ.java, + tests/regression/codepatching/putfieldconstL.java, + tests/regression/codepatching/putstaticD.java, + tests/regression/codepatching/putstaticF.java, + tests/regression/codepatching/putstaticI.java, + tests/regression/codepatching/putstaticJ.java, + tests/regression/codepatching/putstaticL.java, + tests/regression/codepatching/putstaticconstC.java, + tests/regression/codepatching/putstaticconstD.java, + tests/regression/codepatching/putstaticconstF.java, + tests/regression/codepatching/putstaticconstI.java, + tests/regression/codepatching/putstaticconstJ.java, + tests/regression/codepatching/putstaticconstL.java, + tests/regression/codepatching/test.java, + tests/regression/junit/All.java, tests/regression/junit/Makefile.am, + tests/regression/junit/TestPatcher.java: + * .hgignore: Removed tests/regression/codepatching/*.class. + * configure.ac (AC_CONFIG_FILES): Removed + tests/regression/codepatching/Makefile. + * tests/regression/Makefile.am (SUBDIRS): Removed codepatching. + * tests/regression/junit/All.java (suite): Added TestPatcher. + * tests/regression/junit/Makefile.am (EXTRA_DIST): Added $(srcdir) to + actually find the files. + * tests/regression/junit/TestPatcher.java: New file. + + * tests/regression/codepatching/Makefile.am, + tests/regression/codepatching/aastoreconstClass.java, + tests/regression/codepatching/checkcastC.java, + tests/regression/codepatching/checkcastI.java, + tests/regression/codepatching/getfieldD.java, + tests/regression/codepatching/getfieldF.java, + tests/regression/codepatching/getfieldI.java, + tests/regression/codepatching/getfieldJ.java, + tests/regression/codepatching/getfieldL.java, + tests/regression/codepatching/getstaticD.java, + tests/regression/codepatching/getstaticF.java, + tests/regression/codepatching/getstaticI.java, + tests/regression/codepatching/getstaticJ.java, + tests/regression/codepatching/getstaticL.java, + tests/regression/codepatching/instanceofC.java, + tests/regression/codepatching/instanceofI.java, + tests/regression/codepatching/invokespecial.java, + tests/regression/codepatching/invokestatic.java, + tests/regression/codepatching/multianewarray.java, + tests/regression/codepatching/newarray.java, + tests/regression/codepatching/putfieldD.java, + tests/regression/codepatching/putfieldF.java, + tests/regression/codepatching/putfieldI.java, + tests/regression/codepatching/putfieldJ.java, + tests/regression/codepatching/putfieldL.java, + tests/regression/codepatching/putfieldconstC.java, + tests/regression/codepatching/putfieldconstD.java, + tests/regression/codepatching/putfieldconstF.java, + tests/regression/codepatching/putfieldconstI.java, + tests/regression/codepatching/putfieldconstJ.java, + tests/regression/codepatching/putfieldconstL.java, + tests/regression/codepatching/putstaticD.java, + tests/regression/codepatching/putstaticF.java, + tests/regression/codepatching/putstaticI.java, + tests/regression/codepatching/putstaticJ.java, + tests/regression/codepatching/putstaticL.java, + tests/regression/codepatching/putstaticconstC.java, + tests/regression/codepatching/putstaticconstD.java, + tests/regression/codepatching/putstaticconstF.java, + tests/regression/codepatching/putstaticconstI.java, + tests/regression/codepatching/putstaticconstJ.java, + tests/regression/codepatching/putstaticconstL.java, + tests/regression/codepatching/test.java: Removed. + [c7fbe6cfa0d0] + + * tests/Makefile.am, tests/regression/bugzilla/Makefile.am: + * tests/Makefile.am (EXTRA_DIST): Added $(srcdir) to actually find + the files. + * tests/regression/bugzilla/Makefile.am: Likewise. + [574e4f244959] + +2008-04-27 Stefan Ring + + * src/threads/posix/lock.c: + * src/threads/posix/lock.c (lock_record_notify): Skip the check for + interrupted. It was data-race ridden anyway. + [ea434f5851f4] + +2008-04-26 Christian Thalinger + + * * Merged with f9adc5b4d7f0. + [9e1c37400fc1] + + * .hgignore, configure.ac, tests/regression/Makefile.am, + tests/regression/clinitexception.2output, + tests/regression/clinitexception.java, + tests/regression/junit/All.java, tests/regression/junit/Makefile.am, + tests/regression/junit/TestExceptionInStaticClassInitializer.java: + * .hgignore: Added tests/regression/junit/*.class. - * src/vm/jit/sparc64/solaris: Set ignore-properties. + * configure.ac (AC_CONFIG_FILES): Added + tests/regression/junit/Makefile. -2007-02-27 02:07 ajordan + * tests/regression/Makefile.am (SUBDIRS): Added junit. + (SOURCE_FILES): Removed clinitexceptions.java. (EXTRA_DIST): Removed + clinitexceptions.2output. (OUTPUT_JAVA_TESTS): Removed + clinitexception. - * configure.ac: added solaris specific stuff: arch defines, libintl - dependency and solaris subdir makefile. - - * src/vm/jit/stacktrace.h: declared SPARC specific functions. - - * src/vm/jit/sparc64/emit.c: fixed call to builtin_verbosecall_exit. - - * src/vm/jit/sparc64/solaris/md-os.c: signal handling disabled, can't - test right now. + * tests/regression/junit/All.java: Likewise. + * tests/regression/junit/Makefile.am: Likewise + * tests/regression/junit/TestExceptionInStaticClassInitializer.java: + Likewise. -2007-02-26 22:11 twisti + * tests/regression/clinitexception.2output: Removed. + * tests/regression/clinitexception.java: Likewise. + [4201a6a37d6e] - * src/native/vm/java_lang_ClassLoader.c: New file. - * src/native/vm/java_lang_ClassLoader.h: Likewise. - - * src/native/vm/gnu/java_lang_VMClassLoader.c - (native/vm/java_lang_ClassLoader.h): Added. - (defineClass): Removed code and call - _Jv_java_lang_ClassLoader_defineClass. - - * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added - java_lang_ClassLoader.[ch]. - - * src/native/jni.c [ENABLE_JAVASE] - (native/vm/java_lang_ClassLoader.h): Added. - (_Jv_JNI_DefineClass): Removed env and NULL arguments. + * tests/regression/bugzilla/Makefile.am: + * tests/regression/bugzilla/Makefile.am (build): Changed -cp to + -classpath so GCJ works too. (check): Likewise. + [5a22603f6b24] -2007-02-25 22:34 pm + * src/native/vm/gnu/java_lang_reflect_VMMethod.c: + * src/native/vm/gnu/java_lang_reflect_VMMethod.c (getDefaultValue): + Pass the correct method object to the Java method. + [e2470ff85c70] - * src/vm/jit/s390/codegen.c (codegen): Fixed ICMD_IF_ACMPNE - * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Handling NULL - return value of jit_asm_compile. + * src/vm/vm.c: + * src/vm/vm.c (vm_get_mainclass_from_jar): Print error when Main- + Class attribute not found. + [d446954c2415] -2007-02-25 22:02 pm + * m4/jre-layout.m4: + * m4/jre-layout.m4 (AC_CHECK_WITH_JRE_LAYOUT): Fixed typo, used + enableval instead of withval. + [f9adc5b4d7f0] - * src/vm/jit/s390/asmpart.S (asm_getclassvalues_atomic, - asm_criticalsections): Added. +2008-04-24 Stefan Ring -2007-02-25 21:31 pm + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c: Added md-trap.h (same as + 42dc5863f378). + [1c792ca003e4] - * src/vm/jit/codegen-common.c (methodtree_comparator): Fixed S390 - related comment. - * src/vm/jit/s390/codegen.h: Fixed M_JSR macro, did not store RA. - * src/vm/jit/s390/md-asm.h: Added (LOAD|STORE)_TEMPORARY_REGISTERS - and (LOAD|STORE)_ARGUMENT_REGISTERS macros. - * src/vm/jit/s390/asmpart.S: Implemented asm_handle_exception and - asm_vm_call_method_exception_handler. - * src/vm/jit/s390/md-abi.c (abi_registers_integer_temporary): did not - contain %r0, added. +2008-04-24 Christian Thalinger -2007-02-24 14:47 twisti + * src/vm/jit/i386/Makefile.am, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/i386/md-trap.h: + * src/vm/jit/i386/Makefile.am (libarch_la_SOURCES): Added md-trap.h. + * src/vm/jit/i386/codegen.c: Use new trap stuff. + * src/vm/jit/i386/emit.c: Likewise. + * src/vm/jit/i386/linux/md-os.c: Likewise. + * src/vm/jit/i386/md-trap.h: New file. + [42dc5863f378] + + * src/vm/jit/x86_64/Makefile.am: + * src/vm/jit/x86_64/Makefile.am (libarch_la_SOURCES): Added md- + trap.h. + [0db016f6b071] + + * src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c: + * src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c: Use stdint-types. + * src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c: Likewise. + [208f94c92da1] - * src/vmcore/zip.c (errno.h): Added. - (vm/vm.h): Likewise. - (zip_get): Replaced asserts with vm_abort. + * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c: + * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c: + Use stdint-types. + [555b5c4eefa9] -2007-02-23 22:57 michi + * src/cacaoh/dummy.c, src/mm/boehm.c, src/mm/gc-common.h: + * src/cacaoh/dummy.c (heap_alloc_uncollectable): Use stdint-types. + * src/mm/boehm.c: Likewise. + * src/mm/gc-common.h: Likewise. + [33887ab24ca7] - * src/vm/jit/replace.c: Renamed regs to abi_registers_integer_name. + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/Makefile.am, + src/vm/jit/trap.c, src/vm/jit/trap.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/md-trap.h, src/vm/signal.c, src/vm/signallocal.h, + src/vm/vm.c: + * src/vm/jit/trap.c: New file. + * src/vm/jit/trap.h: Likewise. -2007-02-21 23:26 twisti + * src/vm/jit/Makefile.am [ENABLE_JIT] (TRAP_SOURCES): Added. + (libjit_la_SOURCES): Added TRAP_SOURCES. - * src/vm/global.h (ACC_CLASS_SOFT_REFERENCE, ACC_CLASS_WEAK_REFERENCE) - (ACC_CLASS_PHANTOM_REFERENCE): Added. - - * src/vmcore/class.c (class_create_classinfo) [ENABLE_JAVASE]: Check - if the class is a reference class and flag it. - - * src/vmcore/loader.c (load_class_from_classbuffer): OR the flags - loaded. - - * src/vmcore/utf8.c (utf_java_lang_ref_SoftReference) - (utf_java_lang_ref_WeakReference, utf_java_lang_ref_PhantomReference): - Added. - (utf8_init): Initialize added variables. - * src/vmcore/utf8.h: Likewise. + * src/vm/exceptions.c (exceptions_init): Removed. + * src/vm/exceptions.h (EXCEPTION_HARDWARE_*): Removed. -2007-02-21 23:23 twisti + * src/vm/signal.c (signal_handle): Removed. + * src/vm/signallocal.h: Likewise. - * src/vm/exceptions.c (exceptions_throw_noclassdeffounderror): Abort - when VM is initializing. + * src/vm/vm.c (vm_create): Removed exceptions_init call, added + trap_init call. -2007-02-21 23:12 pm + * src/vm/jit/x86_64/codegen.c: Use new trap stuff. + * src/vm/jit/x86_64/emit.c: Likewise. + * src/vm/jit/x86_64/linux/md-os.c: Likewise. + * src/vm/jit/x86_64/md-trap.h: New file. + [e1964528a1af] + + * src/cacaoh/dummy.c, src/mm/memory.c, src/mm/memory.h, + src/vm/builtin.c, src/vm/builtin.h: + * src/cacaoh/dummy.c: Use stdint-types. + * src/mm/memory.c, src/mm/memory.h, src/vm/builtin.c, + src/vm/builtin.h: Likewise. + [3cf50ae219ef] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetHostName): Use TRACEJVMCALLSENTER + and TRACEJVMCALLSEXIT. + [999c2d2889c5] + + * src/vm/jit/arm/codegen.h: + * src/vm/jit/arm/codegen.h (SPLIT_LOAD): Removed. + [9affd9c7a536] + +2008-04-23 Christian Thalinger + + * src/vm/jit/abi.h, src/vm/jit/allocator/liveness.c, + src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/lsra.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/md-abi.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386 + /md-abi.c, src/vm/jit/jit.h, src/vm/jit/loop/analyze.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/mips/md-abi.c, + src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c, + src/vm/jit/parse.c, src/vm/jit/powerpc/darwin/md-abi.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/netbsd/md- + abi.c, src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/md- + abi.c, src/vm/jit/sparc64/md-abi.c, src/vm/jit/stack.c, + src/vm/jit/stack.h, src/vm/jit/x86_64/md-abi.c: + * src/vm/jit/jit.h (stackptr): Removed. (stackelement): Moved from + here... + * src/vm/jit/stack.h (stackelement_t): ...to here. + + * src/vm/jit/abi.h, src/vm/jit/allocator/liveness.c, + src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/lsra.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/md-abi.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386 + /md-abi.c, src/vm/jit/loop/analyze.c, src/vm/jit/m68k/linux/md- + abi.c, src/vm/jit/mips/md-abi.c, src/vm/jit/optimizing/lifetimes.h, + src/vm/jit/optimizing/lsra.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/powerpc/netbsd/md-abi.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/md-abi.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/stack.c, src/vm/jit/x86_64 + /md-abi.c: Replaced stackptr with stackelement_t*. + [ab0f521edd32] + +2008-04-23 Stefan Ring + + * src/native/vm/gnu/java_lang_VMRuntime.c, + src/vm/jit/executionstate.c: + * src/native/vm/gnu/java_lang_VMRuntime.c: Compiler warning + squashing. + * src/vm/jit/executionstate.c (executionstate_println): Likewise. + [d26a4fc535cd] + +2008-04-23 Christian Thalinger + + * autogen.sh: + * autogen.sh: Fixed error output. + [a00932f0646f] + + * autogen.sh: + * autogen.sh: Support libtool-2.x. + [3555026385e5] + + * src/vmcore/system.h: + * src/vmcore/system.h (system_scandir) [__LINUX__]: The signature is + different on various OSs. + [f0e9ab27db0c] + +2008-04-22 Christian Thalinger + + * src/vm/jit/verify/typecheck.c: + * src/vm/jit/verify/typecheck.c (typecheck): Fixed compiler warning. + [f402b152d1f4] + + * src/cacaoh/dummy.c, src/native/jni.c, src/native/vm/Makefile.am, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/native/vm/java_lang_Class.c: Removed. + * src/native/vm/java_lang_Class.h: Likewise. + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed + java_lang_Class.[ch]. - * src/vm/jit/s390/codegen.c (codegen): allocate register save area - required by C abi for builtin calls - * src/vm/jit/s390/codegen.c (createnativestub): fix errornous code - generated for return, fix datasp argument to - codegen_finish_native_call + * src/cacaoh/dummy.c (builtin_instanceof): New function. + (reflect_constructor_new, reflect_field_new, reflect_method_new): + Likewise. -2007-02-21 22:17 twisti + * src/native/jni.c (_Jv_JNI_IsAssignableFrom): Use new class + functions. (_Jv_JNI_IsInstanceOf): Likewise. - * m4/jni.m4: Added ENABLE_JNI AM_CONDITIONAL. - - * src/vm/vm.c (vm_createjvm): Replaced some ENABLE_JAVASE with - ENABLE_JNI. - (vm_create): Likewise. - - * src/native/Makefile.am: Likewise. - - * src/native/jni.c (jni_init) [ENABLE_JAVASE]: ifdef'ed Java SE stuff. - (_Jv_JNI_DefineClass) [!ENABLE_JAVASE]: Abort. - (_Jv_JNI_FindClass): Likewise. - (_Jv_JNI_FromReflectedMethod): Likewise. - (_Jv_JNI_FromReflectedField): Likewise. - (_Jv_JNI_NewDirectByteBuffer): Likewise. - (_Jv_JNI_GetDirectBufferAddress): Likewise. - (_Jv_JNI_GetDirectBufferCapacity): Likewise. - (_Jv_JNI_IsAssignableFrom): Call _Jv_java_lang_Class_isAssignableFrom. - (_Jv_JNI_IsInstanceOf): Call _Jv_java_lang_Class_isInstance. - (_Jv_JNI_EnsureLocalCapacity): Removed debug output. + * src/native/vm/cldc1.1/java_lang_Class.c (forName): Implemented + directly. (isInstance): Use new class functions. (isAssignableFrom): + Likewise. (getName): Likewise. -2007-02-21 20:24 twisti + * src/native/vm/gnu/java_lang_VMClass.c (isInstance): Likewise. + (isAssignableFrom): Likewise. (getName): Likewise. + (getDeclaredClasses): Likewise. (getDeclaredFields): Likewise. + (getDeclaredMethods): Likewise. (getDeclaredConstructors): Likewise. + (forName): Implemented directly. (getDeclaredAnnotations): Likewise. + (getEnclosingConstructor): Use new class functions. + (getEnclosingMethod): Likewise. + * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Likewise. - * src/vm/jit/Makefile.am [!WITH_BINUTILS_DISASSEMBLER] - (DISASS_SOURCES): Removed. - - * src/vm/jit/disass-common.c: Removed WITH_BINUTILS_DISASSEMBLER - ifdefs, since it's compiled conditionally. + * src/native/vm/reflect.h (_REFLECT_H): Added. -2007-02-21 18:20 twisti + * src/native/vm/sun/jvm.c (JVM_GetStackTraceElement): Use new class + functions. (JVM_GetClassName): Likewise. + (JVM_GetClassDeclaredFields): Likewise. + (JVM_GetClassDeclaredMethods): Likewise. + (JVM_GetClassDeclaredConstructors): Likewise. (JVM_LoadLibrary): Use + TRACEJVMCALLSENTER and TRACEJVMCALLSEXIT. (JVM_FindLibraryEntry): + Likewise. - * src/vm/jit/x86_64/md-abi.c (regs): Renamed to - abi_registers_integer_name. - (md_param_alloc): Made code more clear. - (md_param_alloc_native): New function. + * src/vmcore/class.c (class_is_assignable_from): New function. + (class_is_instance): Likewise. (class_get_declaredconstructors): + Likewise. (class_get_declaredfields): Likewise. + (class_get_declaredmethods): Likewise. + (class_get_enclosingconstructor): Likewise. + (class_get_enclosingmethod): Renamed to + class_get_enclosingmethod_raw. class_get_enclosingmethod): Likewise. + * src/vmcore/class.h (class_get_classname): New function. + [dfe0c5810056] + + * src/vm/jit/code.h: + * src/vm/jit/code.h (codeinfo): Moved stackframesize outside of + ENABLE_REPLACEMENT. + [5c10cc5e0dce] + + * * Merged twisti branch. + [989bfa895cd1] + + * NEWS: + Dummy commit to remove twisti branch. + * NEWS: Useless. + [8bc236b29952] + + * NEWS: + Dummy commit to create twisti branch. + * NEWS: Useless. + [c153a9d8f8ce] + + * * Merged with tip. + [30024dee3c14] + + * src/vm/jit/Makefile.am, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/replace.c, + src/vm/jit/x86_64/linux/md-os.c: + * Merged executionstate branch. + [becec2dbe184] + + * src/native/vm/sun/jvm.c: + Reverted 40d6392fb38f. + * src/native/vm/sun/jvm.c (JVM_FindLibraryEntry): Using HPI function + crashes. + [8c0ddfb79909] + + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c (md_replace_executionstate_read): + Renamed to md_executionstate_read. + (md_replace_executionstate_write): Renamed to + md_executionstate_write. + [9bb627fa59f1] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_FindLibraryEntry): Use HPI. + [40d6392fb38f] + + * src/vm/jit/powerpc/linux/md-os.c: + * src/vm/jit/powerpc/linux/md-os.c (md_executionstate_write): Fixed + comment typo. + [3c102f278b7a] + + * src/vm/jit/powerpc/linux/md-os.c: + * src/vm/jit/powerpc/linux/md-os.c (md_replace_executionstate_read): + Renamed to md_executionstate_read. + (md_replace_executionstate_write): Renamed to + md_executionstate_write. + [6f19ebc51c4c] + + * * Merged with tip. + [d492fa9b3e05] + +2008-04-20 Christian Thalinger + + * src/native/jni.c: + * src/native/jni.c (jni_GetPrimitiveArrayCritical): Implemented + correcly. (jni_ReleasePrimitiveArrayCritical): Likewise. + [9c681dc4dcc4] + +2008-04-21 Christian Thalinger + + * src/native/jni.h: + * src/native/jni.h (_Jv_jni_invokeNative): Removed. + [50357bec0c1a] + +2008-04-17 Christian Thalinger + + * src/vm/jit/linenumbertable.c: + * src/vm/jit/linenumbertable.c (linenumbertable_create): Changed the + direction of the list. (linenumbertable_list_entry_add): Likewise. + (linenumbertable_list_entry_add_inline_start): Likewise. + (linenumbertable_list_entry_add_inline_end): Likewise. + [2536b88d4f77] + + * src/vm/jit/emit-common.c: + * src/vm/jit/emit-common.c (emit_label_bccz): Code restructured. + (emit_label): Likewise. + [770ec75a0101] + + * src/vm/jit/codegen-common.c, src/vm/jit/patcher-common.c, src/vm/jit + /patcher-common.h: + * src/vm/jit/patcher-common.c (patcher_resolve): New function. + * src/vm/jit/patcher-common.h (patcher_resolve): Export. + * src/vm/jit/codegen-common.c (codegen_finish): Use patcher_resolve. + [4cc078f655ff] + +2008-04-16 Christian Thalinger + + * src/vm/jit/reg.h, src/vm/jit/verify/typecheck-builtins.inc, + src/vm/jit/verify/typecheck-common.h, src/vm/jit/verify/typecheck- + fields.inc, src/vm/jit/verify/typecheck-invoke.inc, + src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/verify/typeinfo.h, src/vm/resolve.c, src/vm/resolve.h: + * src/vm/jit/verify/typeinfo.h (typeinfo): Renamed to typeinfo_t. + (typeinfo_mergedlist): Renamed to typeinfo_mergedlist_t. + (typedescriptor): Renamed to typedescriptor_t. + + * src/vm/jit/reg.h, src/vm/jit/verify/typecheck-builtins.inc, + src/vm/jit/verify/typecheck-common.h, src/vm/jit/verify/typecheck- + fields.inc, src/vm/jit/verify/typecheck-invoke.inc, + src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/resolve.c, src/vm/resolve.h: Likewise. + [2b2ea4de2f79] + + * src/vmcore/descriptor.c, src/vmcore/references.h: + * src/vmcore/references.h (parseddesc): Renamed to parseddesc_t. + + * src/vmcore/descriptor.c: Likewise. + [8bf03b52775b] + + * src/native/jni.c, src/native/llni.h, src/vm/builtin.c, + src/vm/exceptions.c, src/vm/jit/replace.c, src/vm/jit/trace.c, + src/vm/jit/verify/typeinfo.c, src/vmcore/class.c, + src/vmcore/linker.c, src/vmcore/linker.h: + * src/vmcore/linker.h (_vftbl): Renamed class to clazz. + + * src/native/jni.c, src/native/llni.h, src/vm/builtin.c, + src/vm/exceptions.c, src/vm/jit/replace.c, src/vm/jit/trace.c, + src/vm/jit/verify/typeinfo.c, src/vmcore/class.c, + src/vmcore/linker.c: Likewise. + [b28587b87dba] + + * src/native/jni.c, src/native/native.c, src/native/native.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/native/vm/sun_misc_Unsafe.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/classcache.c, src/vmcore/classcache.h, + src/vmcore/loader.c, src/vmcore/loader.h: + * src/vmcore/loader.h (classloader): Renamed to classloader_t. + + * src/native/jni.c, src/native/native.c, src/native/native.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/native/vm/sun_misc_Unsafe.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/classcache.c, src/vmcore/classcache.h, + src/vmcore/loader.c: Likewise. + [76cd2f513c2e] + + * src/vmcore/annotation.c, src/vmcore/class.c, src/vmcore/field.c, + src/vmcore/loader.c, src/vmcore/loader.h, src/vmcore/method.c, + src/vmcore/stackmap.c, src/vmcore/suck.c, src/vmcore/zip.c: + * src/vmcore/loader.h (classbuffer): Renamed class to clazz. + + * src/vmcore/annotation.c, src/vmcore/class.c, src/vmcore/field.c, + src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/stackmap.c, + src/vmcore/suck.c, src/vmcore/zip.c: Likewise. + [1386fb01ffaf] + +2008-04-15 Christian Thalinger + + * src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/patcher.c (patcher_invokeinterface): Forgot to + rename class to clazz. + [c8a40a22ee20] + + * src/native/vm/reflect.c, src/vm/access.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c, + src/vm/jit/intrp/patcher.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/python.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/patcher.c, src/vm/resolve.c, + src/vmcore/annotation.c, src/vmcore/field.c, src/vmcore/field.h, + src/vmcore/references.h: + * src/vmcore/field.h (fieldinfo): Renamed class to clazz. + + * src/native/vm/reflect.c, src/vm/access.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c, + src/vm/jit/intrp/patcher.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/python.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/patcher.c, src/vm/resolve.c, + src/vmcore/annotation.c, src/vmcore/field.c, + src/vmcore/references.h: Likewise. + [5a14bfe129aa] + + * src/cacaoh/headers.c, src/native/native.c, + src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/toolbox/logging.c, src/vm/access.c, + src/vm/exceptions.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/patcher.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c, + src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, + src/vm/jit/optimizing/dominators.c, + src/vm/jit/optimizing/lifetimes.c, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa3.c, + src/vm/jit/optimizing/ssa_rename.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/python.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/trace.c, + src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-common.c, + src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck- + invoke.inc, src/vm/jit/verify/typecheck-stackbased-gen.inc, + src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify + /typecheck-typeinferer-gen.inc, src/vm/jit/verify/typecheck- + variablesbased-gen.inc, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/patcher.c, src/vm/resolve.c, + src/vmcore/annotation.c, src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/references.h: + * src/vmcore/method.h (methodinfo): Renamed class to clazz. + + * src/cacaoh/headers.c, src/native/native.c, + src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/toolbox/logging.c, src/vm/access.c, + src/vm/exceptions.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/patcher.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/disass.c, + src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, + src/vm/jit/optimizing/dominators.c, + src/vm/jit/optimizing/lifetimes.c, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa3.c, + src/vm/jit/optimizing/ssa_rename.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/python.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/trace.c, + src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-common.c, + src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck- + invoke.inc, src/vm/jit/verify/typecheck-stackbased-gen.inc, + src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify + /typecheck-typeinferer-gen.inc, src/vm/jit/verify/typecheck- + variablesbased-gen.inc, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/patcher.c, src/vm/resolve.c, + src/vmcore/annotation.c, src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/references.h: Likewise. + [d3299bba3c70] + +2008-04-14 Stefan Ring + + * src/threads/posix/thread-posix.c, src/threads/thread.c, + src/threads/thread.h: + Merging darwin compile fixes -> trunk. + [9d2e729a6841] + + * src/threads/posix/thread-posix.c: + Merging fixes. + [d852f098fe45] + + * src/native/vm/gnu/java_lang_VMThread.c, src/threads/thread.c, + src/threads/thread.h: + * src/native/vm/gnu/java_lang_VMThread.c + (Java_java_lang_VMThread_getState): Renamed thread_get_state because + of a name conflict with mach headers. + * src/threads/thread.c (thread_print_info, threads_thread_is_alive): + Likewise. + * src/threads/thread.h: Likewise. + [dfe2ed3a1417] + + * src/threads/posix/thread-posix.c: + Merging fixes. + [61a938a77b77] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (threads_startup_thread): Compile + fix. + [be94e07a636c] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (sem_*): Fixed compile errors. + [bbaa09c52c9b] + +2008-04-14 Christian Thalinger + + * src/threads/thread.c: + * src/threads/thread.c (thread_set_state_runnable): Moved + DEBUGTHREADS into if, so the output is correct. + (thread_set_state_waiting): Likewise. + (thread_set_state_timed_waiting): Likewise. + [43d16d77d6e5] + + * src/threads/posix/thread-posix.c, src/threads/thread.c, + src/threads/thread.h, src/vm/signal.c: + * src/threads/thread.c (threads_thread_state_runnable): Renamed to + thread_set_state_runnable. (threads_thread_state_waiting): Renamed + to thread_set_state_waiting. (threads_thread_state_timed_waiting): + Renamed to thread_set_state_timed_waiting. + (thread_set_state_terminated): Renamed to + thread_set_state_terminated. + * src/threads/thread.h: Likewise. + * src/threads/posix/thread-posix.c: Use new function names. + * src/vm/signal.c: Likewise. + [9e11431508ae] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (threads_sleep): Clear + interrupted flag in exception case. + [39438e55e9d0] + + * src/native/vm/gnu/java_lang_VMThread.c, src/threads/thread.c, + src/threads/thread.h: + * src/threads/thread.h (thread_get_state): New function. + (threads_thread_get_state): Removed. + * src/threads/thread.c (thread_print_info): Use thread_get_state. + (threads_thread_is_alive): Likewise. (threads_thread_get_state): + Removed. + * src/native/vm/gnu/java_lang_VMThread.c (getState): Implemented + directly. + [d6879d90499a] + + * src/threads/posix/thread-posix.c, src/threads/posix/thread-posix.h: + * src/threads/posix/thread-posix.c (threads_sleep): Throw correct + exceptions, use stdint.h types + * src/threads/posix/thread-posix.h (threads_sleep): Use stdint.h + types. + [2a41965d0840] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (threads_detach_thread): Reset + threadgroup when thread has terminated. + [d10959c776b1] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_IsInterrupted): Handle + clear_interrupted. + [865bf6ced98b] + + * src/threads/thread.c: + * src/threads/thread.c (threads_attach_current_thread) + [ENABLE_JAVASE]: Set group to NULL, as it might contain any value. + [770449e5df5e] + + * src/threads/thread.c: + * src/threads/thread.c (threads_attach_current_thread): Set the + thread data-structure in the TSD. + [c4f96b0c4d7d] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (threads_startup_thread): Renamed + variable thread to t. + [fe21e42f3871] + + * src/native/jni.c: + * src/native/jni.c (JNI_NEW_ARRAY): Fixed typo for short array. + [ba3de48b4c29] + +2008-04-13 Christian Thalinger + + * src/vm/access.c, src/vm/access.h: + * src/vm/access.c [ENABLE_JAVASE] (access_check_field): Added + #ifdef. [ENABLE_JAVASE] (access_check_method): Likewise. + * src/vm/access.h: Likewise. + [0d747a4b03c4] + + * src/native/vm/sun/hpi.c: + * src/native/vm/sun/hpi.c (hpi_initialize): Fixed compiler warning. + (hpi_initialize_socket_library): Likewise. + [04c6c41e37cb] + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_print_entry): Print newline + for builtins. + [3864e0d2176b] + +2008-04-11 Christian Thalinger + + * * Commited with tip. + [f86b8b643b79] + + * src/threads/posix/thread-posix.c: + * src/threads/posix/thread-posix.c (threads_sleep): Removed + threads_check_if_interrupted_and_reset usage and use new functions. + [afc6c05d1704] + + * src/native/vm/gnu/java_lang_reflect_VMField.c: + * src/native/vm/gnu/java_lang_reflect_VMField.c + (native/include/java_lang_reflect_Field.h): Added include. + [655d7c04e703] + + * src/native/vm/gnu/java_lang_VMThread.c, src/threads/posix/thread- + posix.c, src/threads/posix/thread-posix.h, src/threads/thread.h: + * src/threads/thread.h (thread_set_interrupted): New function. + * src/threads/posix/thread-posix.c + (threads_check_if_interrupted_and_reset): Removed. + * src/threads/posix/thread-posix.h: Likewise. + * src/native/vm/gnu/java_lang_VMThread.c (interrupted): Use new + function. + [e33009dc3e7c] + + * src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c, + src/threads/posix/thread-posix.c, src/threads/posix/thread-posix.h, + src/threads/thread.h: + * src/threads/thread.h (thread_is_interrupted): New function. + * src/threads/posix/thread-posix.c + (threads_thread_has_been_interrupted): Removed. + * src/threads/posix/thread-posix.h: Likewise. + * src/native/vm/gnu/java_lang_VMThread.c (isInterrupted): Use new + function. + * src/native/vm/sun/jvm.c (JVM_IsInterrupted): Likewise. + [f7128be365f8] + + * src/threads/none/thread-none.h, src/threads/posix/thread-posix.h, + src/threads/thread.h: + * src/threads/none/thread-none.h: Fixed define name. + * src/threads/posix/thread-posix.h: Likewise. + * src/threads/thread.h: Likewise. + [d3a4c83bd558] + +2008-04-10 Christian Thalinger + + * src/vm/jit/arm/asmpart.S: + * src/vm/jit/arm/asmpart.S (asm_cacheflush) [__ARM_EABI__]: Use + syscall number 0. + [ec144df42ca1] + + * src/Makefile.am, src/cacao/Makefile.am, src/threads/Makefile.am, + src/threads/none/Makefile.am, src/threads/none/thread-none.c, + src/threads/none/thread-none.h, src/threads/posix/Makefile.am, + src/threads/thread.c, src/threads/thread.h, src/vm/jit/methodtree.c, + src/vm/jit/s390/md.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h: + src/vm/jit/stacktrace.c (stacktrace_print_entry): New function. + (stacktrace_print_current): Likewise. [ENABLE_THREADS] + (stacktrace_print_of_thread): Likewise. [!ENABLE_THREADS] + (_no_threads_stackframeinfo): Removed. + * src/vm/jit/stacktrace.h: Likewise. -2007-02-21 18:19 twisti + * src/Makefile.am [ENABLE_THREADS] (THREADS_DIR): Removed. + (SUBDIRS): Added threads. - * src/vm/jit/abi-asm.h: Cosmetic changes. + * src/cacao/Makefile.am [ENABLE_THREADS] (THREAD_LIB): Removed. + (libjvm_la_LIBADD): Removed $(THREAD_LIB), added + $(top_builddir)/src/threads/libthreads.la. + * src/threads/Makefile.am [!ENABLE_THREADS]: Recurse into none/. + * src/threads/none/Makefile.am (EXTRA_DIST): Removed. (AM_CPPFLAGS): + Added. (LIBS): Likewise. (noinst_LTLIBRARIES): Likewise. + (libthreadsnone_la_SOURCES): Likewise. + + * src/threads/none/thread-none.c: New file. + * src/threads/none/thread-none.h (_no_threads_stackframeinfo): Export. + + * src/threads/posix/Makefile.am (noinst_LTLIBRARIES): Renamed + library from libposix to libthreadsposix. (libposix_la_SOURCES): + Renamed to libthreadsposix_la_SOURCES. + + * src/threads/thread.c (threads_dump): Use + stacktrace_print_of_thread. (threads_thread_print_stacktrace): + Removed. (threads_print_stacktrace): Likewise. + * src/threads/thread.h (threads_thread_print_stacktrace): Likewise. + (threads_print_stacktrace): Likewise. -2007-02-20 01:23 twisti + * src/vm/jit/methodtree.c (methodtree_find): Use + stacktrace_print_current. + * src/vm/jit/s390/md.c (md_dump_context): Likewise. + [3457d7de230f] + + * src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Use + vm_abort instead of assert. + [98fd037a7854] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_print_stacktrace) [!NDEBUG]: + #ifdef'ed class_print. + [6b3787897afb] + + * src/threads/thread.h: + * src/threads/thread.h (thread_current_is_attached): Check if t is + NULL and return false in this case. + [79e7e22055fa] + +2008-04-07 Christian Thalinger + + * src/classes/Makefile.am, + src/classes/gnu/gnu/java/lang/CPStringBuilder.java, + src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java, + src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java, + src/classes/gnu/java/lang/reflect/Modifier.java, + src/classes/gnu/java/lang/reflect/VMConstructor.java, + src/classes/gnu/java/lang/reflect/VMField.java, + src/classes/gnu/java/lang/reflect/VMMethod.java, + src/native/include/Makefile.am, src/native/jni.c, + src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMConstructor.c, + src/native/vm/gnu/java_lang_reflect_VMField.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/reflect.c, src/native/vm/sun_misc_Unsafe.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/classes/Makefile.am (VM_JAVA_FILES_GNU): Added new VM + interface files. + * src/native/include/Makefile.am (JAVASE_HEADER_FILES): Likewise. + + * src/classes/gnu/gnu/java/lang/CPStringBuilder.java, + src/classes/gnu/gnu/java/lang/VMCPStringBuilder.java, + src/classes/gnu/java/lang/reflect/Modifier.java: New file. + + * src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java: Updated. + + * src/classes/gnu/java/lang/reflect/VMConstructor.java, + src/classes/gnu/java/lang/reflect/VMField.java, + src/classes/gnu/java/lang/reflect/VMMethod.java: New file. + + * src/native/jni.c (FromReflectedMethod): Adapted to new VM + interface. (FromReflectedField): Likewise. + + * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): + Removed java_lang_reflect_Constructor.c, java_lang_reflect_Field.c, + java_lang_reflect_Method.c, added gnu_java_lang_VMCPStringBuilder.c, + java_lang_reflect_VMConstructor.c, java_lang_reflect_VMField.c, + java_lang_reflect_VMMethod.c. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c: Removed. - * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (vm/exceptions.h): - Added. - (vm/stringlocal.h): Likewise. - (loadLibrary): Throw error in case. + * src/native/vm/gnu/gnu_java_lang_VMCPStringBuilder.c, + src/native/vm/gnu/java_lang_reflect_VMConstructor.c, + src/native/vm/gnu/java_lang_reflect_VMField.c, + src/native/vm/gnu/java_lang_reflect_VMMethod.c: New file. -2007-02-20 00:42 twisti + * src/native/vm/nativevm.c (nativevm_preinit): Added + _Jv_gnu_java_lang_VMCPStringBuilder_init. + * src/native/vm/nativevm.h: Likewise. - * src/native/vm/java_lang_Runtime.c (loadLibrary): Different signature - for _Jv_java_lang_Runtime_loadLibrary depending on ENABLE_JNI. - * src/native/vm/java_lang_Runtime.h: Likewise. - * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: Likewise. - * src/native/vm/gnu/java_lang_VMRuntime.c: Likewise. - -2007-02-20 00:38 twisti - - * configure.ac (AC_CHECK_ENABLE_JAVA): Added. - (AC_CHECK_ENABLE_JIT): Likewise. - (AC_CHECK_ENABLE_JNI): Likewise. - - * m4/jni.m4: New file. - * m4/java.m4: Likewise. - * m4/jit.m4: Likewise. - -2007-02-19 23:47 twisti - - * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: New file. - - * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES): - Added com_sun_cldchi_jvm_JVM.c. - - * src/native/vm/java_lang_Runtime.c [!WITH_STATIC_CLASSPATH] (ltdl.h): - Added. - (native/jni.h): Likewise. - (native/native.h): Likewise. - (native/include/java_lang_String.h): Likewise. - (toolbox/logging.h): Likewise. - (vm/exceptions.h): Likewise. - (vm/stringlocal.h): Likewise. - (vmcore/options.h): Likewise. - (loadLibrary): New function. - - * src/native/vm/java_lang_Runtime.h (native/jni.h): Added. - (native/include/java_lang_String.h): Likewise. - - * src/native/vm/gnu/java_lang_VMRuntime.c [!WITH_STATIC_CLASSPATH] - (ltdl.h): Removed. - (native/native.h): Likewise. - (toolbox/logging.h): Likewise. - (vmcore/options.h): Likewise. - (nativeLoad): Call _Jv_java_lang_Runtime_loadLibrary. - - * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES): Added - com_sun_cldchi_jvm_JVM.h. - -2007-02-18 20:16 pm - - * src/vm/jit/s390/patcher.c (patcher_wrapper): Formatting changes. - * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Did not remove - stack frame created by patcher stubs. - -2007-02-16 17:56 twisti - - * src/vmcore/statistics.c (mm/gc-common.h): Added. - (statistics_print_gc_memory_usage): New function. - * src/vmcore/statistics.h (statistics_print_gc_memory_usage): + * src/native/vm/reflect.c (reflect_constructor_new): Adapted to new + VM interface. (reflect_field_new): Likewise. (reflect_method_new): Likewise. - - * src/cacaoh/dummy.c (gc_get_heap_size): New stub. - (gc_get_free_bytes): Likewise. - (gc_get_total_bytes): Likewise. - (gc_get_max_heap_size): Likewise. - - * src/mm/memory.c (memory_thread): Call - statistics_print_gc_memory_usage. - -2007-02-16 07:17 pm - - * src/vm/jit/s390/md.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/patcher.c, - src/vm/jit/s390/asmpart.S, - src/vm/jit/s390/md-abi.c: Changed a lot. Mostly adapted to changes in - the tree. - -2007-02-15 19:48 twisti - - * src/cacaoh/dummy.c (intrp_asm_abstractmethoderror): New stub. - (print_dynamic_super_statistics): Likewise. - - * src/vm/jit/intrp/engine.c (mm/memory.h): Added. - * src/vm/jit/intrp/dynamic-super.c [!ENABLE_THREADS] - (threads/none/lock.h): Likewise. - -2007-02-15 19:42 twisti - - * src/Makefile.am [ENABLE_THREADS] (THREADS_DIR): Added. - (SUBDIRS): Added THREADS_DIR. - - * src/threads/Makefile.am (SUBDIRS): Set always to native. - - * src/threads/threads-common.c (threads/none/threads.h): Removed. - [ENABLE_THREADS] (threads_create_thread): Removed ifdef. - (threads_get_current_tid) [ENABLE_THREADS]: Removed. - -2007-02-15 11:43 pm - - * src/threads/threads-common.c (threads_get_current_tid): Return 0 if - compiled with --enable-threads=none - -2007-02-14 11:35 twisti - - * src/vm/jit/intrp/peephole.c: Updated to current codebase. - * src/vm/jit/intrp/intrp.h: Likewise. - * src/vm/jit/intrp/codegen.c: Likewise. - * src/vm/jit/intrp/engine.c: Likewise. - * src/vm/jit/intrp/asmpart.c: Likewise. - * src/vm/jit/intrp/dynamic-super.c: Likewise. - * src/vm/jit/intrp/patcher.c: Likewise. - * src/vm/jit/intrp/java.vmg: Likewise. -2007-02-13 23:14 twisti + * src/native/vm/sun_misc_Unsafe.c (objectFieldOffset): Likewise. + (staticFieldBase): Likewise. - * src/vm/jit/arm/codegen.c (createnativestub) [!__ARM_EABI__]: - #ifdef'ed split-stuff. - * src/vm/jit/arm/md-abi.c (md_param_alloc_native) [!__ARM_EABI__]: - Added GNU EABI stuff. + * src/vmcore/class.c [WITH_CLASSPATH_GNU] + (class_java_lang_reflect_VMConstructor) + (class_java_lang_reflect_VMField, class_java_lang_reflect_VMMethod): + New global variable. + * src/vmcore/class.h: Likewise. + * src/vmcore/linker.c (linker_init): Added new classes. + * src/vmcore/loader.c (loader_init): Likewise. -2007-02-13 22:11 ajordan + * src/vmcore/utf8.c [WITH_CLASSPATH_GNU] + (utf_java_lang_reflect_VMConstructor, utf_java_lang_reflect_VMField) + (utf_java_lang_reflect_VMMethod): New global variable. + * src/vmcore/utf8.h: Likewise. + [1dba59001474] - * configure.ac: Added support for compiling on Solaris. - - * src/vm/jit/sparc64/*: Added os subdir, changes for compiling on - Solaris. + * src/native/jni.c, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h, src/native/vm/reflect.c, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c: + * src/native/vm/java_lang_reflect_Constructor.c: Removed. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. + * src/native/vm/java_lang_reflect_Method.c: Likewise. + * src/native/vm/java_lang_reflect_Method.h: Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Likewise. + + * src/native/vm/Makefile.am (JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES): + Removed. (JAVA_LANG_REFLECT_METHOD_SOURCES): Likewise. + (libnativevm_la_SOURCES): Removed + JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES and + JAVA_LANG_REFLECT_METHOD_SOURCES. + + * src/native/vm/reflect.c (reflect_invoke): New function. + (reflect_constructor_newinstance): Likewise. + (reflect_method_invoke): Likewise. + * src/native/vm/reflect.h (reflect_constructor_newinstance): Export. + (reflect_method_invoke): Likewise. -2007-02-13 21:32 twisti + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Use reflect_constructor_newinstance. + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): Use + reflect_method_invoke. + * src/native/vm/sun/jvm.c (JVM_InvokeMethod): Use + reflect_method_invoke. (JVM_NewInstanceFromConstructor): Use + reflect_constructor_newinstance. + [a3189e2fbd34] + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h: + * src/native/vm/gnu/java_lang_reflect_Constructor.c (getSignature): + Implemented directly. + * src/native/vm/java_lang_reflect_Constructor.c (getSignature): + Removed. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. + [d1ea50387ceb] - * src/vm/jit/mips/md-abi.c (regs): Renamed to - abi_registers_integer_name. - (md_param_alloc_native): New function. - * src/vm/jit/mips/disass.c (disassinstr): Replaced regs with - abi_registers_integer_name. + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h: + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (getExceptionTypes): Implemented directly. + * src/native/vm/java_lang_reflect_Constructor.c (getExceptionTypes): + Removed. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. + [2bfcb5cbdd18] -2007-02-13 21:30 twisti + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h: + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (getParameterTypes): Implemented directly. + * src/native/vm/java_lang_reflect_Constructor.c (getParameterTypes): + Removed. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. + [5b6da046d461] - * src/vm/jit/mips/emit.c (emit_verbosecall_exit): Fixed argument - passing, but I think there's still something left to fix. - * src/vm/jit/mips/md-abi.h (REG_A2_A3_PACKED): Added. + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h: + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (getModifiersInternal): Implemented directly. + * src/native/vm/java_lang_reflect_Constructor.c (getModifiers): + Removed. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. + [f1da619c1b0b] + +2008-04-03 Christian Thalinger + + * src/threads/posix/Makefile.am, src/threads/posix/threadlist-posix.c, + src/threads/threadlist.c: + * src/threads/posix/threadlist-posix.c: Removed. + * src/threads/posix/Makefile.am (libposix_la_SOURCES): Removed + threadlist-posix.c. + * src/threads/threadlist.c (threads/mutex.h): Added. + (threadlist_mutex): New global variable. (threadlist_init): + Initialize mutex. (threadlist_lock, threadlist_unlock): New + functions. + [d8f389d4b3f7] + +2008-04-02 Christian Thalinger + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_new_class_utf): Check for c == + NULL when VM is initializing. + [3ac1ce7dadb2] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (TRACEJVMCALLSENTER, TRACEJVMCALLSEXIT): + New macro. (JVM_GetClassLoader): Trace return value. + [c4ceb9518a19] + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_get): Correctly skip + Throwable.init() functions. (stacktrace_stackframeinfo_fill): + Changed debugging messge. + [18f868142155] + + * src/threads/thread.c, src/threads/thread.h: + * src/threads/thread.c (threads_thread_print_info): Renamed to + thread_print_info, removed assert on THREAD_STATE_NEW but print as + much info as possible. (threads_dump): Use new functio name. + * src/threads/thread.h: Likewise. + [d6c927d2e029] + + * * Merged with tip. + [da113f4ae466] + + * src/vm/string.c: + * src/vm/string.c (javastring_safe_new_from_utf8): Don't assert on + text is NULL, but return NULL. Checked with jconsole. + [af3aa1b2e676] + + * src/mm/Makefile.am: + * src/mm/Makefile.am: Changed copyright. + [906626e18451] + +2008-04-02 Michael Starzinger + + * src/cacao/cacao.c, src/native/jvmti/cacaodbg.c, + src/native/jvmti/cacaodbg.h, src/native/jvmti/jvmti.c, + src/threads/Makefile.am, src/threads/mutex.h, + src/threads/posix/Makefile.am, src/threads/posix/generic- + primitives.h, src/threads/posix/lock.c, src/threads/posix/lock.h, + src/threads/posix/mutex-posix.h, src/threads/posix/thread-posix.c, + src/threads/posix/thread-posix.h, src/threads/posix/threadlist- + posix.c, src/vm/vm.c: + * src/threads/Makefile.am: Added mutex.h. + * src/threads/posix/Makefile.am: Added mutex-posix.h. + + * src/threads/mutex.h: Added new file. + * src/threads/posix/mutex-posix.h: Likewise. (mutex_init): Implemented + inline wrapper function. (mutex_lock): Likewise. (mutex_unlock): + Likewise. (mutex_destroy): Likewise. + + * src/cacao/cacao.c, src/native/jvmti/cacaodbg.c, + src/native/jvmti/cacaodbg.h, src/native/jvmti/jvmti.c, + src/threads/posix/generic-primitives.h, src/threads/posix/lock.c, + src/threads/posix/lock.h, src/threads/posix/thread-posix.c, + src/threads/posix/thread-posix.h, src/threads/posix/threadlist- + posix.c, src/vm/vm.c: Included mutex.h and used wrapper functions + throughout the whole file. + [30bdc35a0486] + +2008-04-01 Christian Thalinger + + * src/threads/none/thread-none.h, src/threads/none/threads.h, + src/threads/thread.h: + * src/threads/none/threads.h: Renamed from here... + * src/threads/none/thread-none.h: ...to here. + * src/threads/thread.h: Fixed include. + [cce680c919ac] + + * src/native/jni.c, src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c, + src/threads/none/threads.h, src/threads/posix/thread-posix.c, + src/threads/thread.c, src/threads/thread.h, src/vm/exceptions.c: + * src/native/jni.c (_Jv_JNI_FindClass): Renamed to jni_FindClass, + call resolve_handle_pending_exception in exception case. + (_Jv_JNI_ExceptionDescribe): Renamed to jni_ExceptionDescribe, use + exceptions_print_stacktrace. (_Jv_JNI_ExceptionClear): Renamed to + jni_ExceptionClear. + + * src/threads/thread.h (threads_thread_get_object): Renamed to + thread_get_object. (threads_thread_set_object): Renamed to + thread_set_object. (threads_get_current_object): Renamed to + thread_get_current_object. (thread_is_attached): Use new function + names. (thread_fprint_name): Export. + + * src/threads/none/threads.h (threads_get_current_object): Renamed + to thread_get_current_object. + + * src/native/vm/cldc1.1/java_lang_Thread.c (currentThread): Use new + function names. + * src/native/vm/gnu/java_lang_VMThread.c (currentThread): Likewise. + * src/native/vm/sun/jvm.c (JVM_CurrentThread): Likewise. + * src/threads/posix/thread-posix.c (threads_startup_thread): Likewise. + (threads_detach_thread): Likewise. + * src/threads/thread.c (thread_create_object): Likewise. + (thread_free): Likewise. (threads_thread_start): Likewise. + (thread_fprint_name): New function. (threads_thread_print_info): Use + thread_fprint_name. + + * src/vm/exceptions.c (exceptions_print_stacktrace): Implemented + (mostly) as in HotSpot. + [10f85b96a2de] + + * src/vm/string.c, src/vm/stringlocal.h: + * src/vm/string.c (javastring_print): Renamed to javastring_fprint + and added a stream argument. + * src/vm/stringlocal.h: Likewise. + [abde7ae98d1d] + + * src/vm/vm.c: + * src/vm/vm.c (vm_run) [ENABLE_THREADS]: #ifdef'ed threading stuff. + [9d9bdfdef420] + + * configure.ac: + * configure.ac (AC_CHECK_HEADERS): Added stdio.h. + [68c3572dec69] + + * src/threads/thread.c, src/threads/thread.h, + src/threads/threadlist.c: + * src/threads/thread.c (thread_create_object): New function. + (thread_method_init): Made static. (threadgroup_system, + threadgroup_main): Changed type to java_handle_t. + (thread_create_initial_threadgroup): Chnaged type of + threadgroup_system and threadgroup_main. + (thread_create_initial_thread): Use thread_create_object. + (threads_thread_start_internal): Likewise. + (threads_attach_current_thread): Likewise. + (threads_thread_print_info): Use thread_is_daemon. + * src/threads/thread.h (thread_method_init): Removed. + (thread_is_daemon): New function. + * src/threads/threadlist.c (threadlist_get_non_daemons): Use + thread_is_daemon. + [ea1ec101d6fe] + + * src/threads/posix/thread-posix.c, src/threads/thread.c, + src/threads/thread.h: + * src/threads/thread.c (threads_thread_new): Renamed to thread_new + and made static. (threads_thread_free): Renamed to thread_free. + (threads_thread_start_internal): Use new function names. + (threads_thread_start): Likewise. (threads_attach_current_thread): + Likewise. + * src/threads/thread.h (threads_thread_new): Removed. + (threads_thread_free): Renamed to thread_free. + + * src/threads/posix/thread-posix.c (threads_detach_thread): Use new + function names. + [e5e0b246a78b] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao- + gc/rootset.c, src/mm/cacao-gc/rootset.h, src/mm/codememory.c, + src/mm/dumpmemory.c, src/mm/memory.c, src/native/jni.c, + src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h, + src/native/jvmti/jvmti.c, src/native/llni.c, src/native/llni.h, + src/native/localref.c, src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c, + src/threads/Makefile.am, src/threads/posix/Makefile.am, + src/threads/posix/lock.c, src/threads/posix/thread-posix.c, + src/threads/posix/thread-posix.h, src/threads/posix/threads.c, + src/threads/posix/threads.h, src/threads/thread.c, + src/threads/thread.h, src/threads/threadlist.c, + src/threads/threadlist.h, src/threads/threads-common.c, src/threads + /threads-common.h, src/toolbox/logging.c, src/vm/builtin.c, + src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/engine.c, src/vm/jit/jit.c, + src/vm/jit/methodtree.c, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/replace.c, + src/vm/jit/s390/md.c, src/vm/jit/show.c, src/vm/jit/stacktrace.c, + src/vm/jit/trace.c, src/vm/jit/x86_64/freebsd/md-os.c, + src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c, src/vm/vm.c: + * src/threads/posix/threads.c: Renamed from here... + * src/threads/posix/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h: Likewise. + + * src/threads/posix/thread-posix.c: ...to here. + * src/threads/posix/thread-posix.h, src/threads/thread.c, + src/threads/thread.h: Likewise. + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao- + gc/rootset.c, src/mm/cacao-gc/rootset.h, src/mm/codememory.c, + src/mm/dumpmemory.c, src/mm/memory.c, src/native/jni.c, + src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h, + src/native/jvmti/jvmti.c, src/native/llni.c, src/native/llni.h, + src/native/localref.c, src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c, + src/threads/Makefile.am, src/threads/posix/lock.c, + src/threads/posix/Makefile.am, src/threads/threadlist.c, + src/threads/threadlist.h, src/toolbox/logging.c, src/vm/builtin.c, + src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/engine.c, src/vm/jit/jit.c, + src/vm/jit/methodtree.c, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/replace.c, + src/vm/jit/s390/md.c, src/vm/jit/show.c, src/vm/jit/stacktrace.c, + src/vm/jit/trace.c, src/vm/jit/x86_64/freebsd/md-os.c, + src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c, src/vm/vm.c: + Changed filename occurrences. + [38d26f1a1c95] + +2008-03-31 Christian Thalinger + + * src/native/jni.c, src/threads/posix/threads.c, src/threads/threads- + common.c, src/threads/threads-common.h, src/vm/global.h, + src/vm/vm.c: + Fixes PR59. + * src/native/jni.c (_Jv_JNI_Get##name##Field): Added TRACEJNICALLS. + (_Jv_JNI_Set##name##Field): Likewise. + (_Jv_JNI_CallStaticObjectMethod): Likewise. + (_Jv_JNI_CallStaticObjectMethodV): Likewise. + (_Jv_JNI_CallStaticObjectMethodA): Likewise. + (_Jv_JNI_CallStaticVoidMethod): Likewise. + (_Jv_JNI_CallStaticVoidMethodV): Likewise. + (_Jv_JNI_CallStaticVoidMethodA): Likewise. (_Jv_JNI_GetArrayLength): + Likewise. (_Jv_JNI_Get##name##ArrayElements): Likewise. + (_Jv_JNI_Get##name##ArrayRegion): Likewise. + (jni_attach_current_thread): Check correctly if current thread is + already attached. (_Jv_JNI_DetachCurrentThread): Check if current + thread is already detached. + * src/threads/posix/threads.c (threads_detach_thread): Likewise. + + * src/threads/threads-common.c (threads_init) [WITH_CLASSPATH_SUN]: + Resolve correct thread init method. (thread_create_object): New + function, but not yet implemented. (thread_create_initial_thread): + Lot of changes. + + * src/threads/threads-common.h (thread_is_attached): New function. + (thread_current_is_attached): Likewise. + + * src/vm/global.h (STR): New macro, stolen from OpenJDK. + + * src/vm/vm.c (vm_run): Detach the main thread before calling + vm_destroy. (vm_destroy): Attach the main thread again as + DestroyJavaVM thread. + [5b1738cbdeac] + + * src/native/jni.c, src/native/jvmti/cacaodbg.c, + src/threads/posix/threads.c, src/threads/posix/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/posix/threads.c (threads_set_current_threadobject): + Moved from here... (threads_get_current_threadobject): Likewise. + * src/threads/posix/threads.h (thread_get_current): ...to here. + (thread_set_current): Likewise. + * src/threads/threads-common.h (threads_set_current_threadobject): + Removed. -2007-02-13 15:15 twisti + * src/native/jni.c (jni_attach_current_thread): Use new function + name. (_Jv_JNI_DetachCurrentThread): Likewise. (_Jv_JNI_GetEnv): + Likewise. + * src/native/jvmti/cacaodbg.c (jvmti_get_current_thread): Likewise. + * src/threads/threads-common.c (threads_preinit): Likewise. + [6bdc40cea36e] + + * configure.ac, m4/classpath.m4, m4/hpi.m4, src/native/vm/nativevm.c, + src/native/vm/sun/Makefile.am, src/native/vm/sun/hpi.c, + src/native/vm/sun/hpi.h, src/native/vm/sun/jvm.c, + src/vmcore/options.c, src/vmcore/options.h: + * configure.ac (AC_CHECK_WITH_HPI_MD_H): Added. + (AC_CHECK_WITH_HPI_H): Likewise. + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed default + for OpenJDK. (AC_CHECK_WITH_CLASSPATH_LIBDIR): Likewise. + (AC_CHECK_WITH_JNI_MD_H): Likewise. (AC_CHECK_WITH_JNI_H): Likewise. + + * m4/hpi.m4: New file. + * src/native/vm/nativevm.c (nativevm_preinit): Call hpi_initialize. + * src/native/vm/sun/Makefile.am (libnativevmcore_la_SOURCES): Added + hpi.[ch]. + * src/native/vm/sun/hpi.c: New file. + * src/native/vm/sun/hpi.h: Likewise. + + * src/native/vm/sun/jvm.c (JVM_GetLastErrorString): Use HPI + function. (JVM_NativePath): Likewise. (JVM_Open): Likewise. + (JVM_Close): Likewise. (JVM_Read): Likewise. (JVM_Write): Likewise. + (JVM_Available): Likewise. (JVM_Lseek): Likewise. (JVM_SetLength): + Likewise. (JVM_Sync): Likewise. (JVM_InitializeSocketLibrary): Call + hpi_initialize_socket_library. + + * src/vmcore/options.c (opt_TraceHPI): Added global variable. + (options_xx): Handle new option. + * src/vmcore/options.h: Likewise. + [fceac7c38a1b] + + * src/native/vm/nativevm.c: + * src/native/vm/nativevm.c (nativevm_preinit) [WITH_CLASSPATH_SUN]: + Check for native_library_open error. + [fc69ca6c9fbe] + +2008-03-29 Edwin Steiner + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): Clean up: removed an obsolete + assignment to copy->varkind. (It is set in SET_TEMPVAR anyway.) + [da706966db7d] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): Use the javaindex instead of + the CACAO varindex for checking conflicts with local variables. + While there is no real conflict between CACAO variables of different + types, the register allocator makes the implicit assumption that + variables corresponding to the same javaindex may be coalesced. As + long as this assumption is made, we must consider variables with the + same javaindex as conflicting (and also check against that in the + verifier). This fixes [Bug 49] VerifyError with obfuscated classes. + [08444c22b833] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): Clean up the ICMD_IINC case so + it uses the javaindex variable. (No functional change.) + [18e1045d35f2] + + * src/vm/jit/jit.h, src/vm/jit/parse.c, src/vm/jit/verify/typecheck- + common.h, src/vm/jit/verify/typecheck.c: + * src/vm/jit/jit.h (jitdata): Added reverselocalmap. + + * src/vm/jit/parse.c (parse): Fill the reverselocalmap. + + * src/vm/jit/verify/typecheck-common.h (verifier_state): Removed the + reverselocalmap. + + * src/vm/jit/verify/typecheck.c (typecheck_invalidate_locals): Use + jd->reverselocalmap. (typecheck): Likewise. + [8a9d9cd39976] + + * tests/regression/jasmin/Makefile.am, + tests/regression/jasmin/test_load_store_conflict_different_types.j: + * + tests/regression/jasmin/test_load_store_conflict_different_types.j: + New test exposing the bug in conflict checking for local variables + ([Bug 49] VerifyError with obfuscated classes). - * src/threads/native/lock.c (vm/vm.h): Added. - (lock_record_add_waiter): New function. - (lock_record_remove_waiter): Free the waiter data structure. - (lock_record_wait): Use lock_record_add_waiter. - * src/threads/native/lock.h: Cosmetic changes. + * tests/regression/jasmin/Makefile.am: Added new test. + [e5dbef3898c1] -2007-02-13 14:15 twisti + * contrib/vmlog/vmlog_cacao.h: + * contrib/vmlog/vmlog_cacao.h: Removed #include of a header that + does not exist anymore. + [5b8c6c097400] - * src/cacaoh/dummy.c (mem_alloc): Arghhhh, fixed arguments. +2008-03-27 Christian Thalinger -2007-02-13 14:13 twisti + * src/threads/posix/threads.c, src/threads/posix/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/posix/threads.c (threads_attach_current_thread): + Removed. + * src/threads/posix/threads.h: Likewise. + * src/threads/threads-common.c (threads_attach_current_thread): Added. + * src/threads/threads-common.h: Likewise. + [e1fa9148b033] + + * src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/sun/jvm.c, src/vm/global.h, src/vm/initialize.c, + src/vm/initialize.h, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/native/vm/nativevm.c (nativevm_preinit): Changed signature, + use system_* functions. (nativevm_init): Changed signature. + * src/native/vm/nativevm.h: Likewise. - * src/cacaoh/dummy.c (mem_alloc): Use calloc instead of malloc. + * src/native/vm/sun/jvm.c (JVM_InitProperties): Added + sun.nio.MaxDirectMemorySize handling. -2007-02-13 13:23 twisti + * src/vm/global.h (PRINTF_FORMAT_INT64_T): Added define for int64_t + formater. - * src/threads/threads-common.c (threads_get_current_tid): Check if - thread is NULL and return 0. + * src/vm/initialize.c (initialize_init): New function. + * src/vm/initialize.h: Likewise. -2007-02-13 13:04 twisti + * src/vm/vm.c (vm_create): Added initialize_init. - * src/threads/threads-common.c (threads_get_current_tid): New + * src/vmcore/options.c (opt_MaxDirectMemorySize): New global + variable. (options_xx): Use system_* functions. + * src/vmcore/options.h: Likewise. + [bd1fba089d84] + + * configure.ac, src/vmcore/system.h: + * configure.ac (AC_CHECK_FUNCS): Added strcat, strcpy. + * src/vmcore/system.h (system_atoi): New function. (system_strcat): + Likewise. (system_strcpy): Likewise. + [3bc1e510dba5] + +2008-03-26 Christian Thalinger + + * src/vmcore/loader.c, tests/regression/bugzilla/PR58.java: + * src/vmcore/loader.c (load_class_from_classbuffer_intern): Also + call resolve_handle_pending_exception for super interfaces. + * tests/regression/bugzilla/PR58.java (test): Renamed to + testSuperClass. (testSuperInterface): New method. + [a9203003de40] + + * src/cacaoh/dummy.c, src/native/vm/sun/jvm.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/resolve.c, src/vm/resolve.h, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h, + tests/regression/bugzilla/All.java, + tests/regression/bugzilla/PR58.java: + * src/cacaoh/dummy.c (resolve_handle_pending_exception): New function. - * src/threads/threads-common.h (threads_get_current_tid): Added. - - * src/toolbox/logging.c (log_start): Use threads_get_current_tid. - - * src/cacaoh/dummy.c (threads_get_current_threadobject): Removed. - (threads_get_current_tid): Added. - -2007-02-13 12:23 ajordan - - * src/vm/jit/Makefile.am: Reverted duplicate changes. - - * src/vm/signal.c: Reverted one duplicate header include. - -2007-02-13 02:36 ajordan - - * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo): - SPARC specific retrieval of the PV. - (stacktrace_create): SPARC specific stack walking. - - * src/vm/jit/Makefile.am: Not compiling verifier source when disabled. - - * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Included - __SPARC_64__ in ifdef to add patcher NOPs from here. - - * src/vm/signal.c: Added include statements and/or ifdefs to fix - compiling without threads. - * src/vm/exceptions.c: Likewise. - * src/vm/finalizer.c: Likewise. - * src/native/jni.c: Likewise. - * src/threads/none/threads.h: Likewise. - * src/threads/threads-common.c: Likewise. - * src/threads/critical.c: Likewise. - -2007-02-13 02:12 ajordan - - * src/vm/jit/sparc64/md-abi.h: set TRACE_ARGS_NUM to 6. - * src/vm/jit/sparc64/emit.c: using the 6 available integer argument - regs for call tracing. - - * src/vm/jit/sparc64/md-abi.c: added abi register names. - Added md_param_alloc_native(), but still using the existing - workaround. -2007-02-13 00:51 twisti + * src/native/vm/sun/jvm.c (JVM_FindClassFromClassLoader): Added + assert on throwError. (JVM_DoPrivileged): Throw + PrivilegedActionException only if the exception is an instance of + java.lang.Exception but not of java.lang.RuntimeException. - * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: #ifdef'ed - statistics_print_memory_usage call. + * src/vm/exceptions.c (exceptions_new_class_utf): New function. + (exceptions_throw_class_utf): Likewise. + (exceptions_throw_classnotfoundexception): Use + exceptions_throw_class_utf. + (exceptions_classnotfoundexception_to_noclassdeffounderror): + Removed. + * src/vm/exceptions.h: Likewise. -2007-02-13 00:40 twisti + * src/vm/resolve.c (resolve_handle_pending_exception): New function. + (resolve_class_from_name): Don't convert exception. + * src/vm/resolve.h (resolve_handle_pending_exception): Added. + + * src/vmcore/class.c (class_java_lang_Exception): New global + variable. (class_java_lang_ClassNotFoundException): Likewise. + (class_java_lang_RuntimeException): Likewise. + * src/vmcore/class.h: Likewise. + + * src/vmcore/linker.c (linker_init): Link new global classes. + * src/vmcore/loader.c (loader_init): Load new global classes. + + * src/vmcore/utf8.c (utf_java_lang_RuntimeException): New global + variable. (utf8_init): Initialize new global variable. + * src/vmcore/utf8.h (utf_java_lang_RuntimeException): Export. + + * tests/regression/bugzilla/All.java: Added PR58. + * tests/regression/bugzilla/PR58.java: New file. + [4067fe3a3bee] + + * tests/A2.java, tests/AA.java, tests/AA1.java, tests/AA2.java, + tests/BB.java, tests/C.java, tests/C2.java, tests/C3.java, + tests/CC.java, tests/D.java, tests/DD.java, tests/EE.java, + tests/GG.java, tests/HI2.java, tests/II.java, tests/IIAA.java, + tests/IIBB.java, tests/IICC.java, tests/IIexample.java, + tests/Makefile.am, tests/n.java, tests/scribble.java: + * tests/Makefile.am: Cleanup, removed checkall, added build target. + * tests/A2.java: Removed. + * tests/AA.java, tests/AA1.java, tests/AA2.java, tests/BB.java, + tests/C.java, tests/C2.java, tests/C3.java, tests/CC.java, + tests/D.java, tests/DD.java, tests/EE.java, tests/GG.java, + tests/HI2.java, tests/II.java, tests/IIAA.java, tests/IIBB.java, + tests/IICC.java, tests/IIexample.java, tests/n.java, + tests/scribble.java: Likewise. + [91251aac4dec] + + * tests/regression/bugzilla/All.java, + tests/regression/bugzilla/PR57.java: + * tests/regression/bugzilla/All.java: Added PR57. + * tests/regression/bugzilla/PR57.java: New file. + [8a65518935cf] + + * tests/regression/bugzilla/Makefile.am: + * tests/regression/bugzilla/Makefile.am (JAVA): Added + LD_LIBRARY_PATH so we can really overrite JAVA. (build): Added + $(srcdir) to find .java files. (check): Removed LD_LIBRARY_PATH. + [dbf4b68b6d25] + +2008-03-25 Christian Thalinger + + * src/threads/native/Makefile.am, src/threads/native/generic- + primitives.h, src/threads/native/lock.c, src/threads/native/lock.h, + src/threads/native/threadlist-posix.c, src/threads/native/threads.c, + src/threads/native/threads.h: + * src/threads/native/Makefile.am: Removed. + * src/threads/native/generic-primitives.h, src/threads/native/lock.c, + src/threads/native/lock.h, src/threads/native/threadlist-posix.c, + src/threads/native/threads.c, src/threads/native/threads.h: + Likewise. + [0337947f848f] + + * configure.ac, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/rootset.h, + src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h, + src/native/jvmti/jvmti.c, src/native/llni.h, + src/threads/Makefile.am, src/threads/lock-common.h, + src/threads/posix/Makefile.am, src/threads/posix/generic- + primitives.h, src/threads/posix/lock.c, src/threads/posix/lock.h, + src/threads/posix/threadlist-posix.c, src/threads/posix/threads.c, + src/threads/posix/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/builtintable.inc, + src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/intrp/asmpart.c, src/vm/jit/intrp/dynamic-super.c, + src/vm/jit/intrp/engine.c, src/vm/jit/powerpc/darwin/md-os.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md- + os.c, src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/show.c, src/vm/jit/stacktrace.c, + src/vm/jit/x86_64/freebsd/md-os.c, src/vm/jit/x86_64/linux/md-os.c: + * configure.ac (AC_CONFIG_FILES): Moved src/threads/native/Makefile + to src/threads/posix/Makefile. + + * src/threads/posix/Makefile.am, src/threads/posix/generic- + primitives.h, src/threads/posix/lock.c, src/threads/posix/lock.h, + src/threads/posix/threadlist-posix.c, src/threads/posix/threads.c, + src/threads/posix/threads.h: Moved from src/threads/native/. + + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/rootset.h, + src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h, + src/native/jvmti/jvmti.c, src/native/llni.h, + src/threads/Makefile.am, src/threads/lock-common.h, src/threads + /threads-common.c, src/threads/threads-common.h, + src/vm/builtintable.inc, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/dynamic-super.c, src/vm/jit/intrp/engine.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, src/vm/jit/show.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/freebsd/md-os.c, + src/vm/jit/x86_64/linux/md-os.c: Fixed header includes. + [e852f2d0d4c4] + + * src/cacaoh/Makefile.am: + * src/cacaoh/Makefile.am: Changed copyright. + [5974a060a410] + +2008-03-25 Peter Molnar + + * src/vm/jit/optimizing/ssa.h: + Dummy push for testing. + [484dcf446038] + + * src/vm/jit/optimizing/ssa.h: + Dummy push for testing. + [177737032317] + + * src/vm/jit/optimizing/ssa.h: + Dummy push for testing. + [119782e1ae60] + + * src/vm/jit/optimizing/ssa.h: + Dummy push for testing. + [0a173b247580] + +2008-03-25 Christian Thalinger + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/mm/cacao- + gc/rootset.c, src/threads/native/lock.c, src/threads/threadlist.c, + src/toolbox/list.c, src/toolbox/list.h, src/vm/assertion.c, + src/vm/jit/codegen-common.c, src/vm/jit/emit-common.c, + src/vm/jit/linenumbertable.c, src/vm/jit/optimizing/recompile.c, + src/vm/jit/patcher-common.c, src/vm/jit/s390/codegen.c, + src/vm/properties.c: + * src/toolbox/list.c (list_add_first_unsynced): Removed. + (list_add_last_unsynced): Likewise. (list_remove_unsynced): + Likewise. (list_first_unsynced): Likewise. (list_last_unsynced): + Likewise. (list_next_unsynced): Likewise. (list_prev_unsynced): + Likewise. + * src/toolbox/list.h: Likewise. + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/mm/cacao- + gc/rootset.c, src/threads/native/lock.c, src/threads/threadlist.c, + src/vm/assertion.c, src/vm/jit/codegen-common.c, src/vm/jit/emit- + common.c, src/vm/jit/linenumbertable.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/patcher-common.c, + src/vm/jit/s390/codegen.c, src/vm/properties.c: Use normal list + functions instead of the unsynced ones. + [0795aaaa726c] + +2008-03-22 Peter Molnar + + * src/vm/jit/cfg.c: + * src/vm/jit/cfg.c (cfg_build): Fixed off by one in predecessorcount + for exception handler blocks. See #53. + [2065c6bdf8b7] + +2008-03-21 Christian Thalinger + + * .hgignore, configure.ac, src/vm/array.c, + tests/regression/Makefile.am, tests/regression/bugzilla/All.java, + tests/regression/bugzilla/Makefile.am, + tests/regression/bugzilla/PR52.java: + Fixes PR52. + * src/vm/array.c (array_objectarray_element_set): Use + builtin_canstore. + + * .hgignore (tests/regression/assertion/*.class) + (tests/regression/assertion/packagetest/*.class) + (tests/regression/bugzilla/*.class): Added. + * configure.ac (AC_CONFIG_FILES): Added + tests/regression/bugzilla/Makefile. + * tests/regression/Makefile.am (SUBDIRS): Added bugzilla. + * tests/regression/bugzilla/All.java: New file. + * tests/regression/bugzilla/Makefile.am: Likewise. + * tests/regression/bugzilla/PR52.java: Likewise. + [a5fe9a36676e] + +2008-03-20 Christian Thalinger + + * src/native/vm/sun/jvm.c, src/vm/array.c: + * src/vm/array.c (array_length_get): Removed + IllegalArgumentException check for size. + * src/native/vm/sun/jvm.c (JVM_NewMultiArray): Explicitely check for + exceptions. + [c6ca807dc249] + + * src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Method.c, src/vm/access.c, + src/vm/access.h: + * src/vm/access.c (access_check_field): Changed signature, use + stacktrace_get_caller_class. (access_check_method): Likewise. + * src/vm/access.h: Likewise. + * src/native/vm/gnu/java_lang_reflect_Field.c (_field_access_check): + Adapted access_check_field call. + * src/native/vm/java_lang_reflect_Constructor.c (newInstance): + Likewise. + * src/native/vm/java_lang_reflect_Method.c (invoke): Likewise. + [b4a54e5c1918] + + * src/vm/array.c: + * src/vm/array.c (array_element_get): Do a null-pointer check. + (array_element_primitive_get): Likewise. + (array_element_primitive_set): Likewise. + (array_objectarray_element_set): Check if the object can be stored + in the array. + [5054ec21e133] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_NewArray): Check for error on + primitive_arrayclass_get_by_name. (JVM_NewMultiArray): Check for + error on array_length_get. + [7d1278cb4b5c] + + * src/vm/array.c: + * src/vm/array.c (array_##name##array_element_get): Fixed + ArrayIndexOutOfBoundsException check. + (array_objectarray_element_get): Likewise. + (array_##name##array_element_set): Likewise. + (array_objectarray_element_set): Likewise. + [8dd39f5428c8] + + * src/vm/array.c: + * src/vm/array.c (array_length_get): Check length and thrown an + exception in case. + [73b479b0dc93] + + * src/vm/primitive.c: + * src/vm/primitive.c (primitive_unbox): Check for NULL values. + [868526f93774] + + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/sun/jvm.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vm/vm.c, src/vmcore/method.c, + src/vmcore/method.h, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vm/jit/stacktrace.c [ENABLE_JAVASE] + (stacktrace_get_caller_class): New function. + * src/vm/jit/stacktrace.h: Likewise. - * src/vm/vm.c (vm_create) [ENABLE_STATISTICS]: #ifdef opt_stat. + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c (getCallingClass): + Use stacktrace_get_caller_class. (getCallingClassLoader): Likewise. + (firstNonNullClassLoader): Use stacktrace_first_nonnull_classloader. -2007-02-13 00:37 twisti + * src/native/vm/sun/jvm.c (JVM_GetCallerClass): Use + stacktrace_get_caller_class. - * src/vm/vm.c (vm_create): Set opt_stat also true for -verbose:memory. - * src/mm/memory.c [ENABLE_THREADS] (threads/threads-common.h): Added. - (memory_thread): Call statistics_print_memory_usage. + * src/vm/vm.c (vm_create): Call method_init. -2007-02-13 00:17 twisti + * src/vmcore/method.c (method_java_lang_reflect_Method_invoke): New + global variable. (method_init): New function. + * src/vmcore/method.h: Likewise. - * src/vm/jit/optimizing/profile.c (native/jni.h): Removed. - (native/include/java_lang_Thread.h): Likewise. - (native/include/java_lang_VMThread.h): Likewise. - (threads/threads-common.h): Added. - (thread_profile): Changed type to threadobject. - (profile_start_thread): Use threads_create_thread. - * src/vm/jit/optimizing/recompile.c: Likewise. - * src/vm/signal.c: Likewise. - * src/vm/finalizer.c: Likewise. - - * src/vm/jit/asmpart.h (threads/native/critical.h): Removed. - (threads/critical.h): Added. - - * src/vmcore/options.c (opt_verbosememory): Added. - * src/vmcore/options.h: Likewise. - - * src/vm/vm.c (XXusage): Added -verbose:memory. - (vm_create): Likewise. Start memory thread. - - * src/cacao/Makefile.am (THREAD_LIB): Changed to - $(top_builddir)/src/threads/libthreads.la. - - * src/mm/memory.c [ENABLE_THREADS] (thread_memory): Added. - [ENABLE_THREADS] (memory_thread): New function. - [ENABLE_THREADS] (memory_start_thread): Likewise. - * src/mm/memory.h [ENABLE_THREADS] (memory_start_thread): Added. - - * src/threads/native/critical.c: Removed. - * src/threads/native/critical.h: Likewise. - * src/threads/critical.c: Added. - * src/threads/critical.h: Likewise. - - * src/threads/threads-common.c: New file. + * src/vmcore/utf8.c (utf_invoke): New global variable. + * src/vmcore/utf8.h: Likewise. + [fd282c9caa0b] + + * src/vm/jit/trace.c: + * src/vm/jit/trace.c (trace_java_call_print_argument): Pass + methodinfo, added sun.misc.Unsafe check. (trace_java_call_enter, + trace_java_call_exit): Pass methodinfo to + trace_java_call_print_argument. + [b6cdad87ff4c] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (putIntVolatile): Implemented. + (putLongVolatile): Likewise. (putOrderedObject): Likewise. + (putOrderedInt): Likewise. (putOrderedLong): Likewise. + (UNSAFE_GET_VOLATILE): Added macro. (UNSAFE_PUT_VOLATILE): Likewise. + (getIntVolatile): Use UNSAFE_GET_VOLATILE. (getLongVolatile + [10f08de2a96c] + + * src/vm/jit/trace.c: + * src/vm/jit/trace.c (trace_java_call_exit): Workaround for + sun.misc.Unsafe.staticFieldBase(). + [08b89131a6f0] + +2008-03-19 Peter Molnar + + * src/lib/Makefile.am, + src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/lib/gnu/gnu/classpath/VMStackWalker.java, + src/lib/gnu/gnu/classpath/VMSystemProperties.java, + src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/gnu/java/lang/VMClassLoader.java, + src/lib/gnu/java/lang/VMString.java, + src/lib/gnu/java/lang/VMThread.java, + src/lib/gnu/java/lang/VMThrowable.java, + src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/java/security/VMAccessController.java, + src/lib/gnu/sun/misc/Unsafe.java, + src/lib/gnu/sun/reflect/ConstantPool.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/ + sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr + c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx + y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/ + lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h, + tests/threadInterrupt.java: + Merging 7971:887db7d64bc9 with 7970:21b063622472. + [d870367cbe49] + + * src/vm/jit/cfg.c, src/vm/jit/jit.c, src/vm/jit/optimizing/ssa3.c, + src/vm/jit/stack.c: + * src/vm/jit/cfg.c (cfg_build): Support for strange basicblocks, + where an IF can be followed by a NOP and GOTO. + * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_SSA]: Adapted for + changes. + * src/vm/jit/optimizing/ssa3.c: Changed a lot. + * src/vm/jit/stack.c (stack_reach_next_block) [STACK_VERBOSE]: More + verbosity to identify basicblocks where an IF can be followed by a + GOTO. + [887db7d64bc9] + +2008-03-19 Christian Thalinger + + * src/threads/native/generic-primitives.h, src/vm/jit/alpha/machine- + instr.h, src/vm/jit/arm/machine-instr.h, src/vm/jit/i386/machine- + instr.h, src/vm/jit/m68k/machine-instr.h, src/vm/jit/mips/machine- + instr.h, src/vm/jit/powerpc/machine-instr.h, src/vm/jit/powerpc64 + /machine-instr.h, src/vm/jit/s390/machine-instr.h, + src/vm/jit/sparc64/machine-instr.h, src/vm/jit/x86_64/machine- + instr.h: + * src/threads/native/generic-primitives.h + (MEMORY_BARRIER_BEFORE_ATOMIC): Removed. + * src/vm/jit/alpha/machine-instr.h, src/vm/jit/arm/machine-instr.h, + src/vm/jit/i386/machine-instr.h, src/vm/jit/m68k/machine-instr.h, + src/vm/jit/mips/machine-instr.h, src/vm/jit/powerpc/machine-instr.h, + src/vm/jit/powerpc64/machine-instr.h, src/vm/jit/s390/machine- + instr.h, src/vm/jit/sparc64/machine-instr.h, src/vm/jit/x86_64 + /machine-instr.h: Likewise. + [21b063622472] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (setMemory): Fixed compiler + warning on 32-bit architectures. (copyMemory): Likewise. + [a7e35749c949] + + * src/threads/native/generic-primitives.h, + src/threads/native/threads.c, src/vm/jit/alpha/machine-instr.h, + src/vm/jit/arm/machine-instr.h, src/vm/jit/i386/machine-instr.h, + src/vm/jit/mips/machine-instr.h, src/vm/jit/powerpc/machine-instr.h, + src/vm/jit/s390/machine-instr.h, src/vm/jit/sparc64/machine-instr.h, + src/vm/jit/x86_64/machine-instr.h: + * src/threads/native/generic-primitives.h (atomic_add): Removed. + * src/threads/native/threads.c [USE_FAKE_ATOMIC_INSTRUCTIONS] + (_atomic_add_lock): Removed. + * src/vm/jit/alpha/machine-instr.h (atomic_add): Removed. + * src/vm/jit/arm/machine-instr.h, src/vm/jit/i386/machine-instr.h, + src/vm/jit/mips/machine-instr.h, src/vm/jit/powerpc/machine-instr.h, + src/vm/jit/s390/machine-instr.h, src/vm/jit/sparc64/machine-instr.h, + src/vm/jit/x86_64/machine-instr.h: Likewise. + [c2f69cf3790e] + +2008-03-18 Christian Thalinger + + * src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c: + * src/native/vm/gnu/java_lang_VMThread.c (interrupt): Use + thread_get_thread. (isInterrupted): Likewise. (nativeSetPriority): + Likewise. (getState): Likewise. + * src/native/vm/sun/jvm.c (threads/threadlist.h): Removed. + (JVM_IsThreadAlive): Use thread_get_thread. (JVM_SetThreadPriority): + Likewise. (JVM_Interrupt): Implemented. (JVM_IsInterrupted): Use + thread_get_thread. + [056edaebc79b] + + * src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.c (thread_get_thread): New function. * src/threads/threads-common.h: Likewise. - * src/threads/Makefile.am (AM_CPPFLAGS): Added. - (LIB): Likewise. - [ENABLE_THREADS] (THREAD_LIB): Likewise. - (noinst_LTLIBRARIES): Likewise. - (libthreads_la_SOURCES): Likewise. - (libthreads_la_LIBADD): Likewise. - - * src/threads/.cvsignore: New file. - - * src/threads/native/threads.c (include "threads/threads-common.h): - Added. - * src/threads/native/threads.h (MIN_PRIORITY, NORM_PRIORITY) - (MAX_PRIORITY): Removed. - - * src/threads/native/Makefile.am (noinst_LTLIBRARIES): Changed to - libthreadsposix.la. - -2007-02-13 00:05 twisti - - * src/vmcore/annotation.c - (annotation_load_attribute_runtimevisibleannotations): Renamed aa to - annotations. - -2007-02-12 13:28 twisti - - * src/vm/jit/emit-common.h (_EMIT_H): Renamed to _EMIT_COMMON_H. - (config.h): Added. - (vm/jit/codegen-common.h): Likewise. - [SIZEOF_VOID_P == 4] (IS_IMM16): Added. - -2007-02-12 10:43 twisti - - * src/vm/jit/alpha/md-abi.c (regs): Renamed to - abi_registers_integer_name. - (md_param_alloc_native): New function. - - * src/vm/jit/alpha/disass.c (vm/jit/abi.h): Added. - (disassinstr): Replaced regs with abi_registers_integer_name. - -2007-02-12 00:34 twisti - - * src/vm/jit/i386/md-abi.c (regs): Renamed to - abi_registers_integer_name. - (md_param_alloc_native): New function. - -2007-02-11 22:17 twisti - - * src/vm/jit/arm/disass.c (stdio.h): Added. - (regs): Removed. - * src/vm/jit/arm/md-abi.c (abi_registers_integer_name): Added. - (md_param_alloc_native): Likewise. - -2007-02-11 21:44 twisti - - * src/vm/jit/codegen-common.c (vm/jit/abi.h): Added. - -2007-02-11 21:41 twisti - - * src/vm/jit/disass.h (regs): Removed. - - * src/vm/jit/show.c (vm/jit/abi.h): Added. - (show_allocation): Renamed regs to abi_registers_integer_name. - -2007-02-11 21:39 twisti - - * src/vm/jit/codegen-common.c (codegen_createnativestub): Call - md_param_alloc_native instead of md_param_alloc. - - * src/vm/jit/powerpc/linux/md-abi.c (assert.h): Added. - (regs): Renamed to abi_registers_integer_name. - (abi_registers_integer_argument, abi_registers_integer_saved) - (abi_registers_integer_temporary, abi_registers_float_name) - (abi_registers_float_argument, abi_registers_float_saved) - (abi_registers_float_temporary): Added. - (md_param_alloc): Reformatted. - (md_param_alloc_native): New function. - -2007-02-11 21:24 twisti - - * src/vmcore/descriptor.c (vm/jit/abi.h): Added. - * src/vmcore/descriptor.h (md_param_alloc): Removed. - - * src/vm/jit/abi.h (abi_registers_integer_name) - (abi_registers_integer_argument, abi_registers_integer_saved) - (abi_registers_integer_temporary, abi_registers_float_name) - (abi_registers_float_argument, abi_registers_float_saved) - (abi_registers_float_temporary): Added. - (md_param_alloc): Likewise. - (md_param_alloc_native): Likewise. - -2007-02-11 21:22 twisti - - * src/native/native.c (native_get_returntype): Removed. - * src/native/native.h: Likewise. - - * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType): Moved - code from native_get_returntype. - -2007-02-11 20:16 twisti - - * src/vm/jit/codegen-common.c (vm/jit/md.h): Added. - -2007-02-11 20:10 twisti - - * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Keep stack 8-byte - aligned. - (emit_verbosecall_exit): Added comment. - * src/vm/jit/arm/asmpart.S (asm_call_jit_compiler): Keep stack 8-byte - aligned. - -2007-02-11 17:52 pm + [ae7763ff1c13] + + * src/classes/gnu/sun/misc/Unsafe.java, + src/native/vm/sun_misc_Unsafe.c: + * src/classes/gnu/sun/misc/Unsafe.java: Imported the OpenJDK 6 + version. + * src/native/vm/sun_misc_Unsafe.c (vmcore/system.h): Added. + (setMemory, copyMemory): Changed to be OpenJDK 6 compatible. + [162965872cfb] + + * contrib/setenvinstalled.in, contrib/setenvsource.in: + * contrib/setenvinstalled.in: Updated BOOTCLASSPATH. + * contrib/setenvsource.in: Likewise. + [ccd8958ff259] + + * .hgignore: + * .hgignore: Removed src/lib/classes/ and src/lib/vm.zip, added + src/classes/classes/ and src/classes/vm.zip. + [3b80e57be422] + + * configure.ac, m4/classpath.m4, src/Makefile.am, + src/classes/Makefile.am, + src/classes/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/classes/gnu/gnu/classpath/VMStackWalker.java, + src/classes/gnu/gnu/classpath/VMSystemProperties.java, + src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/classes/gnu/java/lang/VMClassLoader.java, + src/classes/gnu/java/lang/VMString.java, + src/classes/gnu/java/lang/VMThread.java, + src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java, + src/classes/gnu/java/security/VMAccessController.java, + src/classes/gnu/sun/misc/Unsafe.java, + src/classes/gnu/sun/reflect/ConstantPool.java, + src/classes/gnu/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas + ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy. + java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE + xceptionProxy.java, + src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas + ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/lib/Makefile.am, + src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/lib/gnu/gnu/classpath/VMStackWalker.java, + src/lib/gnu/gnu/classpath/VMSystemProperties.java, + src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/gnu/java/lang/VMClassLoader.java, + src/lib/gnu/java/lang/VMString.java, + src/lib/gnu/java/lang/VMThread.java, + src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/java/security/VMAccessController.java, + src/lib/gnu/sun/misc/Unsafe.java, + src/lib/gnu/sun/reflect/ConstantPool.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/ + sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr + c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx + y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/ + lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/native/include/Makefile.am: + * configure.ac (AC_CONFIG_FILES): Removed src/lib/Makefile, added + src/classes/Makefile. + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Fixed + BOOTCLASSPATH. + * src/Makefile.am (DIST_SUBDIRS): Removed lib, added classes. + (SUBDIRS): Likewise. - * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo): - On s390 get return address from stack also in leaf methods. - * src/vm/jit/codegen-common.c (methodtree_comparator): On s390 - compare addresses as 31 bit integers. - * src/vm/jit/s390/md.c, - src/vm/jit/s390/codegen.c, - src/vm/jit/s390/codegen.h, - src/vm/jit/s390/patcher.c, - src/vm/jit/s390/asmpart.S: Changed a lot, working on s390 port. + * src/classes/Makefile.am, + src/classes/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/classes/gnu/gnu/classpath/VMStackWalker.java, + src/classes/gnu/gnu/classpath/VMSystemProperties.java, + src/classes/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/classes/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/classes/gnu/java/lang/VMClassLoader.java, + src/classes/gnu/java/lang/VMString.java, + src/classes/gnu/java/lang/VMThread.java, + src/classes/gnu/java/lang/reflect/Constructor.java, + src/classes/gnu/java/lang/reflect/Field.java, + src/classes/gnu/java/lang/reflect/Method.java, + src/classes/gnu/java/security/VMAccessController.java, + src/classes/gnu/sun/misc/Unsafe.java, + src/classes/gnu/sun/reflect/ConstantPool.java, + src/classes/gnu/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnu/sun/reflect/annotation/AnnotationType.java, src/clas + ses/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy. + java, src/classes/gnu/sun/reflect/annotation/EnumConstantNotPresentE + xceptionProxy.java, + src/classes/gnu/sun/reflect/annotation/ExceptionProxy.java, src/clas + ses/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/native/include/Makefile.am: Moved from lib. + + * src/lib/Makefile.am, + src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/lib/gnu/gnu/classpath/VMStackWalker.java, + src/lib/gnu/gnu/classpath/VMSystemProperties.java, + src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/gnu/java/lang/VMClassLoader.java, + src/lib/gnu/java/lang/VMString.java, + src/lib/gnu/java/lang/VMThread.java, + src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/java/security/VMAccessController.java, + src/lib/gnu/sun/misc/Unsafe.java, + src/lib/gnu/sun/reflect/ConstantPool.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/ + sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr + c/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProx + y.java, src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, src/ + lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java: + Moved to lib. + [79be8092620d] + + * m4/classpath.m4, tests/regression/Makefile.am, + tests/regression/assertion/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/jasmin/Makefile.am, + tests/regression/native/Makefile.am, + tests/regression/resolving/Makefile.am: + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Set + BOOTCLASSPATH for Makefiles. + * tests/regression/Makefile.am, + tests/regression/assertion/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/jasmin/Makefile.am, + tests/regression/native/Makefile.am, + tests/regression/resolving/Makefile.am (BOOTCLASSPATH): Removed. + [c8c412f3563d] + +2008-03-17 Christian Thalinger + + * src/vm/jit/stacktrace.c: + * Merged with 60f051a3c5ae. + [66c52d0ae7d3] + + * * Merged with b78ab2bd233a. + [60f051a3c5ae] + + * src/vm/jit/m68k/md.h: + * src/vm/jit/m68k/md.h: Replaced codegen_get_pv_from_pc with + methodtree_find. + [17f63c532b66] + + * src/vm/jit/intrp/asmpart.c: + * src/vm/jit/intrp/asmpart.c: Replaced codegen_get_pv_from_pc with + methodtree_find. + [b78ab2bd233a] + + * src/vm/jit/s390/md.c, src/vm/jit/s390/md.h: + * src/vm/jit/s390/md.c: Replaced codegen_get_pv_from_pc with + methodtree_find. + * src/vm/jit/s390/md.h: Likewise. + [ba13719a1aab] + + * src/vm/jit/methodtree.c: + * src/vm/jit/methodtree.c (threads/threads-common.h): Added. + (methodtree_find): Removed unnecessary assert. + [929aa234977f] + + * src/vm/jit/i386/asmpart.S, src/vm/jit/i386/cygwin/md-asm.h, + src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/i386/md.h: + * src/vm/jit/i386/asmpart.S: Replaced codegen_get_pv_from_pc with + methodtree_find. + * src/vm/jit/i386/cygwin/md-asm.h src/vm/jit/i386/darwin/md-asm.h, + src/vm/jit/i386/md.h: Likewise. + [726425cd358a] + +2008-03-13 Christian Thalinger + + * src/vm/jit/Makefile.am, src/vm/jit/code.c, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/methodtree.c, + src/vm/jit/methodtree.h, src/vm/jit/optimizing/profile.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/md.h, src/vm/signal.c, src/vm/vm.c: + * src/vm/jit/methodtree.c: New file. + * src/vm/jit/methodtree.h: Likewise. + * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added methodtree.[ch]. + + * src/vm/jit/codegen-common.c (methodtree): Removed. (codegen_init): + Removed methodtree stuff. (methodtree_comparator): Removed. + (codegen_insertmethod): Likewise. (codegen_get_pv_from_pc): + Likewise. (codegen_get_pv_from_pc_nocheck): Likewise. + (codegen_finish): Call methodtree_insert. + * src/vm/jit/codegen-common.h (methodtree_element): Removed. + (codegen_insertmethod): Likewise. (codegen_get_pv_from_pc): + Likewise. (codegen_get_pv_from_pc_nocheck): Likewise. + + * src/vm/vm.c (vm_create): Call methodtree_init. + + * src/vm/jit/code.c, src/vm/jit/optimizing/profile.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/md.h, src/vm/signal.c: Replaced + codegen_get_pv_from_pc* with methodtree_find*. + [414c5fa5f01e] + + * src/vm/jit/inline/inline.c, src/vm/jit/inline/inline_debug.inc: + * src/vm/jit/inline/inline.c (inline_add_blocknr_reference): + Commented as it's not used and produces a compiler warning. + * src/vm/jit/inline/inline_debug.inc (debug_dump_inline_context): + Likewise. + [9c8901fcff0a] + + * src/lib/Makefile.am, src/lib/gnu/java/lang/VMThrowable.java, + src/native/vm/gnu/java_lang_VMThrowable.c, src/vm/jit/stacktrace.c: + * src/lib/gnu/java/lang/VMThrowable.java: Removed, as the local + changes made years ago are not necessary. + * src/lib/Makefile.am (VM_JAVA_FILES_GNU): Removed + gnu/java/lang/VMThrowable.java. + + * src/native/vm/gnu/java_lang_VMThrowable.c (fillInStackTrace): Use + vmdata instead of vmData. (getStackTrace): Likewise. + * src/vm/jit/stacktrace.c (stacktrace_print_exception) + [WITH_CLASSPATH_GNU]: Likewise. + [ac9fca996d5e] + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_detach_thread): Fixed + compiler warning. + [2f60b3f9a1da] + + * src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_read): + Renamed to md_executionstate_read. + (md_replace_executionstate_write): Renamed to + md_executionstate_write. + [190dab35c7f0] + + * src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/linux/md-os.c (md_replace_executionstate_read): + Renamed to md_executionstate_read. + (md_replace_executionstate_write): Renamed to + md_executionstate_write. + [28eb425cbf17] + + * src/vm/jit/executionstate.c, src/vm/jit/executionstate.h: + * src/vm/jit/executionstate.c: Fixed file comment. + * src/vm/jit/executionstate.h: Fixed copyright. + [d044bbdb3010] + + * src/vm/jit/Makefile.am, src/vm/jit/executionstate.c, + src/vm/jit/executionstate.h, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/executionstate.c: New file. + * src/vm/jit/executionstate.h: Likewise. + * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added + executionstate.[ch]. + + * src/vm/jit/replace.c (replace_executionstate_println): Moved to + executionstate.[ch]. (replace_sanity_check_read_write): Likewise. + * src/vm/jit/replace.h (executionstate_t): Likwise. + (replace_executionstate_println): Likewise. + (md_replace_executionstate_read): Likewise. + (md_replace_executionstate_write): Likewise. + + * src/vm/jit/i386/linux/md-os.c (md_replace_executionstate_read): + Renamed to md_executionstate_read. + (md_replace_executionstate_write): Renamed to + md_executionstate_write. + [015609f9c237] + + * src/vm/jit/alpha/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit): Added thread unsafe + comments. + [fe0f7708d735] + + * src/threads/none/threads.h, src/threads/threads-common.h: + * src/threads/none/threads.h (threads_get_current_object): Changed + return type to java_handle_t. + * src/threads/threads-common.h: Likewise. + [ba1986e7117c] -2007-02-11 10:15 michi + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (TRACEJVMCALLS): Changed to normal macro + instead of a variadic one. + [ac949484e6cd] - * src/vm/jit/replace.c: Fixed includes for options.h and classcache.h - headers. - * src/vm/jit/replace.h: Added forward typedef for rplalloc. + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (PRINTJVMWARNINGS): Changed to normal + macro instead of variadic. (JVM_GetStackTraceDepth): Fixed compiler + warning. (JVM_GetStackTraceElement): Likewise. (JVM_IsThreadAlive): + Likewise. + [4a49aeff7fd7] -2007-02-11 09:21 michi + * src/native/localref.c: + * src/native/localref.c [!NDEBUG] (localref_check_uncleared): Fixed + compiler warning. + [4126ae263bbd] - * src/vm/jit/replace.h: Fixed include for method.h header. +2008-03-12 Christian Thalinger -2007-02-11 00:02 twisti + * src/cacaoh/dummy.c, src/vm/jit/code.c, src/vm/jit/code.h, + src/vm/jit_interface.h, src/vmcore/method.c: + * src/vm/jit/code.c (code_find_codeinfo_for_pc): Use void* instead + of u1*. (code_find_codeinfo_for_pc_nocheck): Likewise. + (code_get_methodinfo_for_pv): Likewise. + * src/vm/jit/code.h: Likewise. + * src/cacaoh/dummy.c (vm/jit/code.h): Added. + (code_get_methodinfo_for_pv): Likewise. + * src/vm/jit_interface.h (code_get_methodinfo_for_pv): Removed. + * src/vmcore/method.c (vm/jit/code.h): Added. + [a2f65e9ce093] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_GetDirectBufferAddress): Fixed compiler + warnings. + [42e52f1166c9] - * src/vm/jit/x86_64/emit.c (emit_verbosecall_enter): Renamed - builtin_trace_args to builtin_verbosecall_enter. - (builtin_verbosecall_exit): Renamed builtin_displaymethodstop to - builtin_verbosecall_exit and changed signature. - - * src/vm/jit/x86_64/md-abi.h (REG_FA0, REG_FA1): Added. + * src/threads/none/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h: + * src/threads/none/threads.h (threads_get_current_object): New + function. (threads_get_current_stackframeinfo): Fixed name to + threads_set_current_stackframeinfo. -2007-02-10 19:06 twisti + * src/threads/threads-common.c (threads_get_current_object): + Removed. + * src/threads/threads-common.h (threads_get_current_object): New + function. (threads_get_current_object): Removed. + + * src/vm/jit/stacktrace.c: Small fix. + * src/vm/jit/stacktrace.h [!ENABLE_THREADS] + (_no_threads_stackframeinfo): Added. + [2b9f0242d4f6] + + * src/native/vm/reflect.c: + * src/native/vm/reflect.c (reflect_field_new): Fixed compiler + warnings. (reflect_method_new): Likewise. + [c71069a7c75a] + + * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/vm.c: + * src/vm/jit/code.c (code_init): Changed signature, use vm_abort + instead of assert. + * src/vm/jit/code.h (code_init): Change signature. + * src/vm/vm.c (vm_create): Call code_init. + [9f0c6db8a687] + +2008-03-12 Stefan Ring + + * src/threads/native/threads.c: + Oh no, it worketh! + + * src/threads/native/threads.c: Include Boehm header on Darwin. + [ac7444e86ffc] + +2008-03-11 Stefan Ring + + * configure.ac, src/mm/boehm-gc/AmigaOS.c, src/mm/boehm- + gc/BCC_MAKEFILE, src/mm/boehm-gc/ChangeLog, src/mm/boehm- + gc/EMX_MAKEFILE, src/mm/boehm-gc/MacOS.c, src/mm/boehm- + gc/Makefile.am, src/mm/boehm-gc/Makefile.direct, src/mm/boehm- + gc/Makefile.dj, src/mm/boehm-gc/NT_MAKEFILE, src/mm/boehm- + gc/NT_STATIC_THREADS_MAKEFILE, src/mm/boehm-gc/NT_THREADS_MAKEFILE, + src/mm/boehm-gc/NT_X64_STATIC_THREADS_MAKEFILE, src/mm/boehm- + gc/OS2_MAKEFILE, src/mm/boehm-gc/PCR-Makefile, src/mm/boehm- + gc/README.QUICK, src/mm/boehm-gc/SMakefile.amiga, src/mm/boehm- + gc/WCC_MAKEFILE, src/mm/boehm-gc/allchblk.c, src/mm/boehm- + gc/alloc.c, src/mm/boehm-gc/autogen.sh, src/mm/boehm-gc/backgraph.c, + src/mm/boehm-gc/bdw-gc.pc.in, src/mm/boehm-gc/blacklst.c, src/mm + /boehm-gc/callprocs, src/mm/boehm-gc/checksums.c, src/mm/boehm- + gc/configure.ac, src/mm/boehm-gc/configure.in, src/mm/boehm- + gc/configure_atomic_ops.sh, src/mm/boehm-gc/cord/cord.am, src/mm + /boehm-gc/cord/de_win.ICO, src/mm/boehm-gc/cord/de_win.c, src/mm + /boehm-gc/darwin_stop_world.c, src/mm/boehm-gc/dbg_mlc.c, src/mm + /boehm-gc/digimars.mak, src/mm/boehm-gc/doc/Makefile.am, src/mm + /boehm-gc/doc/README, src/mm/boehm-gc/doc/README.Mac, src/mm/boehm- + gc/doc/README.changes, src/mm/boehm-gc/doc/README.darwin, src/mm + /boehm-gc/doc/README.environment, src/mm/boehm-gc/doc/README.linux, + src/mm/boehm-gc/doc/README.macros, src/mm/boehm- + gc/doc/README.solaris2, src/mm/boehm-gc/doc/README.win32, src/mm + /boehm-gc/doc/README.win64, src/mm/boehm-gc/doc/doc.am, src/mm + /boehm-gc/doc/gcdescr.html, src/mm/boehm-gc/doc/gcinterface.html, + src/mm/boehm-gc/doc/leak.html, src/mm/boehm-gc/doc/overview.html, + src/mm/boehm-gc/doc/porting.html, src/mm/boehm-gc/dyn_load.c, src/mm + /boehm-gc/finalize.c, src/mm/boehm-gc/gc.mak, src/mm/boehm- + gc/gc_cpp.cc, src/mm/boehm-gc/gc_dlopen.c, src/mm/boehm- + gc/gcc_support.c, src/mm/boehm-gc/gcj_mlc.c, src/mm/boehm- + gc/headers.c, src/mm/boehm-gc/if_mach.c, src/mm/boehm- + gc/if_not_there.c, src/mm/boehm-gc/include/Makefile.am, src/mm + /boehm-gc/include/gc.h, src/mm/boehm-gc/include/gc_alloc.h, src/mm + /boehm-gc/include/gc_allocator.h, src/mm/boehm- + gc/include/gc_config_macros.h, src/mm/boehm-gc/include/gc_cpp.h, + src/mm/boehm-gc/include/gc_gcj.h, src/mm/boehm-gc/include/gc_inl.h, + src/mm/boehm-gc/include/gc_inline.h, src/mm/boehm- + gc/include/gc_local_alloc.h, src/mm/boehm-gc/include/gc_mark.h, + src/mm/boehm-gc/include/gc_pthread_redirects.h, src/mm/boehm- + gc/include/gc_tiny_fl.h, src/mm/boehm-gc/include/gc_typed.h, src/mm + /boehm-gc/include/include.am, src/mm/boehm- + gc/include/new_gc_alloc.h, src/mm/boehm- + gc/include/private/dbg_mlc.h, src/mm/boehm- + gc/include/private/gc_hdrs.h, src/mm/boehm- + gc/include/private/gc_locks.h, src/mm/boehm- + gc/include/private/gc_pmark.h, src/mm/boehm- + gc/include/private/gc_priv.h, src/mm/boehm- + gc/include/private/gcconfig.h, src/mm/boehm- + gc/include/private/msvc_dbg.h, src/mm/boehm- + gc/include/private/pthread_support.h, src/mm/boehm- + gc/include/private/solaris_threads.h, src/mm/boehm- + gc/include/private/specific.h, src/mm/boehm- + gc/include/private/thread_local_alloc.h, src/mm/boehm- + gc/libatomic_ops-1.2/AUTHORS, src/mm/boehm- + gc/libatomic_ops-1.2/COPYING, src/mm/boehm- + gc/libatomic_ops-1.2/ChangeLog, src/mm/boehm- + gc/libatomic_ops-1.2/INSTALL, src/mm/boehm- + gc/libatomic_ops-1.2/Makefile.am, src/mm/boehm- + gc/libatomic_ops-1.2/NEWS, src/mm/boehm-gc/libatomic_ops-1.2/README, + src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh, src/mm/boehm- + gc/libatomic_ops-1.2/configure.ac, src/mm/boehm- + gc/libatomic_ops-1.2/doc/COPYING, src/mm/boehm- + gc/libatomic_ops-1.2/doc/LICENSING.txt, src/mm/boehm- + gc/libatomic_ops-1.2/doc/Makefile.am, src/mm/boehm- + gc/libatomic_ops-1.2/doc/README.txt, src/mm/boehm- + gc/libatomic_ops-1.2/doc/README_malloc.txt, src/mm/boehm- + gc/libatomic_ops-1.2/doc/README_stack.txt, src/mm/boehm- + gc/libatomic_ops-1.2/doc/README_win32.txt, src/mm/boehm- + gc/libatomic_ops-1.2/mkinstalldirs, src/mm/boehm- + gc/libatomic_ops-1.2/src/Makefile.am, src/mm/boehm- + gc/libatomic_ops-1.2/src/Makefile.msft, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops.c, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/generalize-small.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/generalize- + small.template, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/generalize.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/README, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/acquire_release_v + olatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ + aligned_atomic_load_store.h, src/mm/boehm-gc/libatomic_ops-1.2/src/a + tomic_ops/sysdeps/all_acquire_release_volatile.h, src/mm/boehm-gc/li + batomic_ops-1.2/src/atomic_ops/sysdeps/all_aligned_atomic_load_store + .h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/all_atomic_load_store.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ao_t_is_int.h, src/mm + /boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/atomic_load_store.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/char_acquir + e_release_volatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_o + ps/sysdeps/char_atomic_load_store.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/emul_cas.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/alpha.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/arm.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/cris.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/hppa.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/ia64.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/m68k.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/powerpc.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/s390.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/sparc.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/generic_pthread.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc/hppa.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc/ia64.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc/powerpc.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc/ia64.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/int_acquire + _release_volatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_op + s/sysdeps/int_aligned_atomic_load_store.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/int_atomic_load_store.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc/x86_64.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ordered.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ordered_except_wr.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/read_ordered.h, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/short_acquire_rel + ease_volatile.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sy + sdeps/short_aligned_atomic_load_store.h, src/mm/boehm-gc/libatomic_o + ps-1.2/src/atomic_ops/sysdeps/short_atomic_load_store.h, src/mm + /boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/standard_ao_double_t.h, + src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc/sparc.S, src/mm + /boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc/sparc.h, + src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/test_and_se + t_t_is_ao_t.h, src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysd + eps/test_and_set_t_is_char.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops_malloc.c, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops_malloc.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops_stack.c, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops_stack.h, src/mm/boehm- + gc/libatomic_ops-1.2/src/atomic_ops_sysdeps.S, src/mm/boehm- + gc/libatomic_ops-1.2/tests/Makefile.am, src/mm/boehm- + gc/libatomic_ops-1.2/tests/list_atomic.c, src/mm/boehm- + gc/libatomic_ops-1.2/tests/list_atomic.template, src/mm/boehm- + gc/libatomic_ops-1.2/tests/run_parallel.inc, src/mm/boehm- + gc/libatomic_ops-1.2/tests/test_atomic.c, src/mm/boehm- + gc/libatomic_ops-1.2/tests/test_atomic.template, src/mm/boehm- + gc/libatomic_ops-1.2/tests/test_atomic_include.h, src/mm/boehm- + gc/libatomic_ops-1.2/tests/test_malloc.c, src/mm/boehm- + gc/libatomic_ops-1.2/tests/test_stack.c, src/mm/boehm-gc/libtool.m4, + src/mm/boehm-gc/ltconfig, src/mm/boehm-gc/mach_dep.c, src/mm/boehm- + gc/malloc.c, src/mm/boehm-gc/mallocx.c, src/mm/boehm-gc/mark.c, + src/mm/boehm-gc/mark_rts.c, src/mm/boehm-gc/misc.c, src/mm/boehm- + gc/mkinstalldirs, src/mm/boehm-gc/msvc_dbg.c, src/mm/boehm- + gc/new_hblk.c, src/mm/boehm-gc/obj_map.c, src/mm/boehm-gc/os_dep.c, + src/mm/boehm-gc/pc_excludes, src/mm/boehm-gc/pcr_interface.c, src/mm + /boehm-gc/powerpc_darwin_mach_dep.s, src/mm/boehm- + gc/pthread_stop_world.c, src/mm/boehm-gc/pthread_support.c, src/mm + /boehm-gc/ptr_chck.c, src/mm/boehm-gc/real_malloc.c, src/mm/boehm- + gc/reclaim.c, src/mm/boehm-gc/setjmp_t.c, src/mm/boehm- + gc/solaris_pthreads.c, src/mm/boehm-gc/solaris_threads.c, src/mm + /boehm-gc/sparc_mach_dep.S, src/mm/boehm-gc/specific.c, src/mm + /boehm-gc/stubborn.c, src/mm/boehm-gc/tests/leak_test.c, src/mm + /boehm-gc/tests/middle.c, src/mm/boehm-gc/tests/test.c, src/mm + /boehm-gc/tests/test_cpp.cc, src/mm/boehm-gc/tests/tests.am, src/mm + /boehm-gc/tests/thread_leak_test.c, src/mm/boehm- + gc/tests/trace_test.c, src/mm/boehm-gc/thread_local_alloc.c, src/mm + /boehm-gc/threadlibs.c, src/mm/boehm-gc/typd_mlc.c, src/mm/boehm- + gc/version.h, src/mm/boehm-gc/win32_threads.c, src/mm/boehm.c: + Imported and merged Boehm GC 7.0 + [85f594678514] + + * src/mm/boehm.c: + * src/mm/boehm.c: Define GC_DARWIN_THREADS. + [6342939f5ec7] + + * Merge -> trunk + [785419807437] + +2008-03-05 Stefan Ring + + * src/mm/boehm-gc/BCC_MAKEFILE, src/mm/boehm-gc/digimars.mak: + * src/mm/boehm-gc/BCC_MAKEFILE, src/mm/boehm-gc/digimars.mak: + unix2dos'ed the way they were in gc6.8. + [70786a061a3c] + +2008-03-11 Christian Thalinger + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_thread_start_internal): Code + reworked. (threads_thread_start): Likewise. + [28798cbb3598] + + * src/threads/threads-common.c: + * src/threads/threads-common.c [ENABLE_JAVASE] (threadgroup_system, + (threadgroup_main): New variables. (threads_init): Call + thread_create_initial_threadgroups and thread_create_initial_thread. + (thread_create_initial_threadgroups): New function. + (thread_create_initial_thread): Likewise. + (threads_get_current_object): Removed empty-group hack. + [4587829c96e0] + + * src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vmcore/utf8.c + (utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V): Added. + * src/vmcore/utf8.h: Likewise. + [11c519559b6e] + + * src/native/jni.c, src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (vm_created): Added. (vm_create): Set vm_created. + (vm_destroy): Unset vm_created. + * src/vm/vm.h: (vm_created): Added. + * src/native/jni.c (_Jv_JNI_DestroyJavaVM): Added vm_created check. + (_Jv_JNI_AttachCurrentThread): Likewise. (_Jv_JNI_GetEnv): Likewise. + (_Jv_JNI_AttachCurrentThreadAsDaemon): Likewise. + [df45c6a94042] + + * src/cacaoh/cacaoh.c, src/vm/vm.c, src/vmcore/utf8.c, + src/vmcore/utf8.h: + * src/vmcore/utf8.c (utf_main): Added. (utf8_init): Changed + signature. + * src/vmcore/utf8.h: Likewise. + * src/cacaoh/cacaoh.c (main): Removed return value check for + utf8_init. + * src/vm/vm.c (vm_create): Likewise. + [b02fb9ce8032] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h, + src/vm/vm.c: + * src/threads/native/threads.c (method_thread_init): Removed. + (threads_init): Removed. (threads_impl_init): New function. + (threads_attach_current_thread): Renamed method_thread_init to + thread_method_init. + * src/threads/native/threads.h (threads_init): Removed + + * src/threads/threads-common.c (native/native.h): Added. + [ENABLE_JAVASE] (native/include/java_lang_ThreadGroup.h): Likewise. + [WITH_CLASSPATH_GNU] (native/include/java_lang_Throwable.h): + Removed. (toolbox/list.h): Likewise. (vm/exceptions.h): Added. + (vmcore/method.h): Likewise. (thread_method_init): Likewise. + (threads_init): New function. + * src/threads/threads-common.h (thread_method_init): Added. + (threads_init): Likewise. (threads_impl_init): Likewise. + + * src/vm/vm.c (vm_create) [ENABLE_THREADS]: Removed return value + check for threads_init. + [a55398aa6b7a] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create) [!NDEBUG]: Removed conditional, as we want + the config for production builds too. + [634e86c4c855] + +2008-03-10 Christian Thalinger + + * src/threads/native/Makefile.am, src/threads/native/lock.c, + src/threads/native/threadlist-posix.c, src/threads/native/threads.c, + src/threads/threadlist.c, src/threads/threadlist.h, src/threads + /threads-common.c, src/threads/threads-common.h, + src/vm/jit/optimizing/profile.c: + * src/threads/native/threadlist-posix.c: New file. + * src/threads/native/Makefile.am (libthreadsposix_la_SOURCES): Added + threadlist-posix.c. + + * src/threads/native/threads.c (mutex_threads_list): Removed. + (threads_impl_preinit): Removed mutex_threads_list initialization. + (threads_list_lock, threads_list_unlock): Removed. + + * src/threads/threadlist.c (threadlist_init): Call + threadlist_impl_init. + + * src/threads/threadlist.h (threadlist_impl_init, threadlist_lock) + (threadlist_unlock): Added. + + * src/threads/threads-common.h (threads_list_lock) + (threads_list_unlock): Removed. + + * src/threads/native/lock.c, src/threads/threads-common.c, + src/vm/jit/optimizing/profile.c: Use new threadlist_{lock,unlock} + functions. + [f47de576dda1] - * src/vm/builtin.c (builtin_trace_args): Renamed to - builtin_verbosecall_enter. - (builtin_trace_args): Renamed to builtin_verbosecall_enter. - (builtin_displaymethodstop): Renamed to builtin_verbosecall_exit and - changed signature. - * src/vm/builtin.h: Likewise. - - * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Likewise. - (builtin_verbosecall_exit): Likewise. - * src/vm/jit/alpha/emit.c: Likewise. - * src/vm/jit/i386/emit.c: Likewise. - * src/vm/jit/mips/emit.c: Likewise. - * src/vm/jit/powerpc/emit.c: Likewise. - - * src/vm/jit/alpha/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Added. - * src/vm/jit/mips/md-abi.h: Removed multiple defines. - * src/vm/jit/powerpc/linux/md-abi.h (REG_FA0, REG_FA1): Added. - (REG_A0_A1_PACKED): Likewise. - - * src/vm/jit/mips/linux/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - * src/vm/jit/mips/irix/Makefile.am: Likewise. + * src/threads/threads-common.c: + * src/threads/threads-common.c [ENABLE_JAVASE] + (native/include/java_lang_ThreadGroup.h): Only a temporary hack. + [8ba3980d54fa] -2007-02-10 15:11 ajordan + * src/vm/signal.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_TraceTraps): Added. + * src/vmcore/options.h: Likewise. - * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed stack - argument passing. - - * src/vm/jit/sparc64/*: Adapted includes to new cacao structure. + * src/vm/signal.c (signal_handle) [!NDEBUG]: Added opt_TraceTraps + debug output. This is not finished yet. + [ea6e9a832c48] -2007-02-10 14:31 pm + * src/cacaoh/dummy.c, src/vmcore/options.c: + * src/cacaoh/dummy.c (errno.h): Added. (vmcore/system.h): Likewise. + (vm_abort_errno): New function. (vm_abort_errnum): Likewise. - * s390/codegen.c: fix: ICMD_FCMPL generated wrong branch offset - * s390/codegen.h: likewise - * s390/asmpart.S: fix: asm_call_jit_compiler did not remove stack - frame + * src/vmcore/options.c (errno.h): Removed. (options_xx): Use + vm_abort_errno. + [96dddc7f5487] -2007-02-10 00:49 pm + * src/vm/signal.c: + * src/vm/signal.c (errno.h): Removed. (signal_init): Use + vm_abort_errno. (signal_register_signal): Likewise. (signal_thread): + Likewise. + [b85835120e85] - Continued work on S390 codegen. Affected files: - - * s390/codegen.c - * s390/codegen.h - * s390/arch.h - * s390/patcher.c - * s390/asmpart.S + * NEWS: + * NEWS: Added 0.99 news. + [09791a7c5a1b] -2007-02-09 13:20 twisti +2008-03-06 Christian Thalinger - * src/vm/jit/powerpc64/linux/md-os.c: Fixed includes. - * src/vm/jit/powerpc64/linux/md-abi.c: Likewise. - * src/vm/jit/powerpc64/md.c: Likewise. - * src/vm/jit/powerpc64/codegen.c: Likewise. - * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (putObjectVolatile): OK, this time + WITHOUT debug output. Damn. + [f1757b2a1bb3] -2007-02-09 13:00 twisti + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (putObjectVolatile): Implemented. + [a8989730157b] - * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): Added ; after - lock, Darwin's assembler requires that. - (asm_compare_and_swap): Likewise. +2008-03-05 Christian Thalinger -2007-02-09 12:51 twisti + * src/threads/threadlist.c: + * src/threads/threadlist.c (threadlist_index_add): Actually set the + index in the structure. + [70cea5d87e1a] - * src/mm/boehm.c [ENABLE_THREADS] (threads/native/threads.h): Removed. + * src/mm/cacao-gc/rootset.c, src/native/vm/sun/jvm.c, + src/vm/jit/optimizing/profile.c: + * src/mm/cacao-gc/rootset.c (threads/threadlist.h): Added. + (rootset_readout): Use threadlist_* functions. -2007-02-09 12:49 twisti + * src/native/vm/sun/jvm.c (threads/threadlist.h): Added. + (JVM_IsThreadAlive): Use threadlist_* functions. + (JVM_SetThreadPriority): Likewise. (JVM_IsInterrupted): Likewise. - * src/vm/jit/powerpc/linux/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - * src/vm/jit/powerpc/darwin/Makefile.am: Likewise. - * src/vm/jit/powerpc/netbsd/Makefile.am: Likewise. + * src/vm/jit/optimizing/profile.c (threads/threadlist.h): Added. + (profile_thread): Use threadlist_* functions. + [bfdd735b3ecb] -2007-02-09 12:47 twisti + * src/native/vm/Makefile.am, src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h, + src/native/vm/sun/jvm.c, src/threads/threads-common.c, src/threads + /threads-common.h: + * src/native/vm/java_lang_Thread.c: Removed. + * src/native/vm/java_lang_Thread.h: Likewise. - * src/vmcore/class.h (dummy_java_lang_Class): Added. - (classinfo): Use dummy_java_lang_Class. - * src/vm/vm.c (vm_create): Check dummy_java_lang_Class size. + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed + java_lang_Thread.[ch]. -2007-02-09 11:25 twisti + * src/threads/threads-common.c (threads_get_current_object): New + function. + * src/threads/threads-common.h: Likewise. - * src/native/vm/java_lang_Runtime.c [ENABLE_JAVASE] - (runFinalizersOnExit): Added. - * src/native/vm/java_lang_Runtime.h: Likewise. - - * src/native/vm/gnu/java_lang_VMRuntime.c (exit): Renamed argument - par1 to status. - (runFinalizersOnExit): Call _Jv_java_lang_Runtime_runFinalizersOnExit. - -2007-02-09 11:08 twisti - - * src/vm/exceptions.c (exceptions_throw_unsatisfiedlinkerror) - [!ENABLE_JAVASE]: Generate a java.lang.Error. - - * src/native/vm/cldc1.1/java_lang_Class.c (isInstance): Added. - (isAssignableFrom): Likewise. - (isInterface): Likewise. - (isArray): Likewise. - - * src/native/vm/cldc1.1/java_lang_Object.c (hashCode): Likewise. - (notify): Likewise. - (wait): Likewise. - - * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Smaller - implementation changes. - (indexOf__II): Likewise. - (lastIndexOf__II): Likewise. - (indexOf__I): Added. - - * src/native/vm/cldc1.1/java_lang_Thread.c: Header updated. - - * src/native/vm/cldc1.1/java_lang_Runtime.c (exitInternal): Fixed - signature. - (freeMemory): Added. - (totalMemory): Likewise. - (gc): Likewise. - - * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c: New - file. - * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c: - Likewise. - * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES): - Added com_sun_cldc_io_ResourceInputStream.c and - com_sun_cldc_io_j2me_socket_Protocol.c. - - * src/native/vm/java_lang_Runtime.c: New file. - * src/native/vm/java_lang_Runtime.h: Likewise. - * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added - java_lang_Runtime.c and java_lang_Runtime.h. - - - * src/native/vm/java_lang_Class.c: Un-ifdef some functions for CLDC. - * src/native/vm/java_lang_Class.h: Likewise. - - * src/native/vm/gnu/java_lang_VMRuntime.c - (native/vm/java_lang_Runtime.h): Added. - (exit): Call _Jv_java_lang_Runtime function. - (freeMemory): Likewise. - (totalMemory): Likewise. - (gc): Likewise. - - * src/native/vm/java_lang_Object.h [ENABLE_JAVASE] - (native/include/java_lang_Cloneable.h): Only available for JavaSE - configurations. - - * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES): Added - com_sun_cldc_io_ResourceInputStream.h and - com_sun_cldc_io_j2me_socket_Protocol.h. - - * src/native/native.c (dummynativetable) [ENABLE_JAVAME_CLDC1_1]: - Added new functions. - -2007-02-09 10:35 twisti - - * src/vm/jit/alpha/md.c (vm/options.h): Changed to vmcore/options.h. - - * src/vm/jit/alpha/linux/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - * src/vm/jit/alpha/freebsd/Makefile.am: Likewise. - -2007-02-08 12:29 michi - - * src/vm/jit/i386/cygwin/Makefile.am: Changed to unix fileformat. - * src/vm/jit/i386/cygwin/ucontext.h, - src/vm/jit/i386/cygwin/ucontext.c, - src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/md-asm.h: + * src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/sun/jvm.c: + Implemented thread functions directly. + [e0404195c823] + + * configure.ac, m4/classpath.m4: + * configure.ac (AM_CPPFLAGS): Set to CPPFLAGS. + + * m4/classpath.m4 (AC_CHECK_WITH_JNI_MD_H): Preserve CPPFLAGS. + (AC_CHECK_WITH_JNI_H): Likewise. + [285ff795b4ba] + + * src/Makefile.am: + * src/Makefile.am: Changed copyright. + [1c3bd7bb8db1] + + * src/threads/Makefile.am, src/threads/lock-common.h, + src/threads/native/lock.c, src/threads/native/threads.c, + src/threads/threadlist.c, src/threads/threadlist.h, src/threads + /threads-common.c, src/threads/threads-common.h, src/vm/vm.c: + * src/threads/threadlist.c: New file. + * src/threads/threadlist.h: Likewise. + + * src/threads/Makefile.am (libthreads_la_SOURCES): Added + threadlist.[ch]. + + * src/threads/lock-common.h: Changed copyright. + + * src/threads/native/lock.c (threads/threadlist.h): Added. + (threads_lookup_thread_id): Use threadlist_* functions. + + * src/threads/native/threads.c (threads/threadlist.h): Added. + (threads_cast_sendsignals): Use threadlist_* functions. + (threads_stopworld): Likewise. (threads_startworld): Likewise. + (threads_init): Likewise. (threads_attach_current_thread): Likewise. + (threads_join_all_threads): Likewise. + + * src/threads/threads-common.c (threads/threadlist.h): Added. + (list_threads, list_free_threads, list_free_thread_index): Removed. + (thread_index_t): Removed. (threads_preinit): Don't initialize the + thread lists, moved lock_init and critical_init calls into + vm_create. (threads_list_first, threads_list_next): Removed. + (threads_list_get_non_daemons): Likewise. (threads_thread_new, + threads_thread_free): Use threadlist_* functions. + + * src/threads/threads-common.h (threads_list_first): Removed. + (threads_list_next): Likewise. (threads_list_get_non_daemons): Likewise. -2007-02-08 12:14 twisti + * src/vm/vm.c (threads/lock-common.h): Added. + (threads/threadlist.h): Added. (vm_create) [ENABLE_THREADS]: Call + threadlist_init, lock_init and critical_init. + [88c7c1a68bda] - * src/vm/jit/i386/linux/Makefile.am (AM_CPPFLAGS) Added - -I$(top_builddir)/src. - * src/vm/jit/i386/cygwin/Makefile.am: Likewise. - * src/vm/jit/i386/freebsd/Makefile.am: Likewise. - -2007-02-07 22:06 pm - - Continued work on S390 port. - java.lang.ClassLoader.getSystemClassLoader is now compiled, patched, - called and the patcher trigger compilation of another method. - - * jit/s390/emit.c: Likiwise. - * jit/s390/codegen.c: Likewise. - * jit/s390/codegen.h: Likewise. - * jit/s390/md-asm.h: Likewise. - * jit/s390/patcher.c: Likewise. - * jit/s390/asmpart.S: Likewise. - * jit/codegen-common.c: Likewise. - -2007-02-06 12:17 twisti - - * src/native/vm/cldc1.1/Makefile.am: Updated header. - -2007-02-06 10:25 twisti - - * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Implemented. - (indexOf__II): Likewise. - (lastIndexOf__II): Likewise. + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c [WITH_CLASSPATH_CLDC1_1] + (native/include/java_lang_String.h): Added. + [5856f0d523a2] -2007-02-06 09:11 twisti + * configure.ac, m4/classpath.m4, src/native/jni.h: + * configure.ac (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Removed. + [!WITH_JRE_LAYOUT] (AC_CHECK_WITH_CLASSPATH_LIBDIR): Conditional. + (AC_CHECK_WITH_JNI_MD_H): Added. (AC_CHECK_WITH_JNI_H): Likewise. + (AM_CPPFLAGS): Added. - * src/threads/native/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - * src/vm/jit/x86_64/Makefile.am: Likewise. - * src/vm/jit/x86_64/linux/Makefile.am: Likewise. - * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise. + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Removed. + (AC_CHECK_WITH_JNI_MD_H): New macro. (AC_CHECK_WITH_JNI_H): + Likewise. -2007-02-06 08:58 twisti + * src/native/jni.h (__GCJ_JNI_MD_H__): Removed the quick hack. + (CLASSPATH_JNI_MD_H): Removed. (CLASSPATH_JNI_H): Likewise. + (INCLUDE_JNI_MD_H): Added. (INCLUDE_JNI_H): Likewise. + [eab0c7885c52] - * src/vm/jit/powerpc/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef - profiling code. + * src/lib/Makefile.am: + * src/lib/Makefile.am [WITH_CLASSPATH_GNU || WITH_CLASSPATH_CLDC1_1] + (pkgdata_DATA): Only define it for GNU or CLDC-1.1 configurations. + [1d15fd390244] -2007-02-06 08:50 twisti + * src/cacao/Makefile.am: + * src/cacao/Makefile.am (libjvm_la_LDFLAGS): Use -version-info + instead of -release, as the library interface of libjvm.so will not + change. + [46784cb01dc1] - * src/native/vm/Makefile.am (DIST_SUBDIRS): Added missing \. +2008-03-04 Christian Thalinger -2007-02-06 08:49 twisti + * man/Makefile.am: + * man/Makefile.am: Changed copyright. + [46f2ae819ff5] - * src/vm/jit/tools/genoffsets.c (vm/jit/stacktrace.h): Not required, - removed. + * doc/Makefile.am: + * doc/Makefile.am: Changed copyright. + [6c354dd4fcd8] -2007-02-06 08:48 twisti + * contrib/Makefile.am: + * contrib/Makefile.am: Changed copyright. + [3f9fc73789e5] - * src/vm/jit/tools/Makefile.am: Cosmetic changes. + * Makefile.am: + * Makefile.am: Changed copyright. + [23e283b63784] -2007-02-06 08:47 twisti + * NEWS: + * NEWS: Fixed month for 0.99. + [0fc50ddc4a9f] - * src/vm/jit/optimizing/Makefile.am (AM_CPPFLAGS): Added - -I$(top_builddir)/src. - * src/vm/jit/Makefile.am: Likewise. - * src/vm/Makefile.am: Likewise. - * src/mm/Makefile.am: Likewise. +2008-03-03 Christian Thalinger -2007-02-06 06:37 twisti + * NEWS: + * NEWS: Added some 0.99 release notes. + [5b338798aa0b] - * src/vm/jit/linux/md-os.c (thread_restartcriticalsection): Added - missing cast and pass pc to critical_find_restart_point. - * src/vm/jit/freebsd/md-os.c (thread_restartcriticalsection): - Likewise. +2008-03-03 Stefan Ring -2007-02-05 02:04 twisti + * tests/threadInterrupt.java: + Merge -> trunk. + [2fa6a94596b0] - * src/cacaoh/dummy.c (builtin_clone, builtin_isanysubclass) - (builtin_new): Keep compiler happy and return a value. + * src/threads/native/lock.c, src/threads/native/threads.c, + src/threads/native/threads.h: + interrupt() / notify() fix. -2007-02-05 01:07 twisti + * src/threads/native/lock.c (lock_record_wait, lock_record_notify): + Correctly handling the signaled and interrupted flags. - * src/vm/signallocal.h (vm/types.h): Added. - (vm/global.h): Likewise. + * src/threads/native/threads.c (threads_wait_with_timeout) + (threads_wait_with_timeout_relative): No return value, not touching + flags. (threads_check_if_interrupted_and_reset): Now locking the + waitmutex. (threads_sleep): Adapted to change. -2007-02-05 01:06 twisti + * src/threads/native/threads.h (threads_wait_with_timeout_relative): + No return value. + [9ffa63aa1415] - * configure.ac (AC_CONFIG_FILES): Added - src/vm/jit/x86_64/freebsd/Makefile. - - * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added freebsd. - - * src/vm/jit/x86_64/freebsd/md-os.c: New file. - * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise. - * src/vm/jit/x86_64/freebsd/.cvsignore: Likewise. + * tests/threads/waitAndInterrupt.java: + * tests/threads/waitAndInterrupt.java: New test hanging CACAO. + [831d66c6b70a] -2007-02-05 00:52 twisti + * .hgignore, tests/threadInterrupt.java, + tests/threads/threadInterrupt.java: + * .hgignore: Ignoring class files. + * tests/threads: New directory for thread tests. + * tests/threads/threadInterrupt.java: Moved. + [820a5859b970] - * configure.ac (AC_CONFIG_FILES): Added - src/vm/jit/x86_64/linux/Makefile. - - * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added. - (SUBDIRS): Likewise. - (libarch_la_LIBADD): Likewise. - - * src/vm/jit/x86_64/md.c (md_signal_handler_sigsegv) - (md_signal_handler_sigfpe, md_signal_handler_sigusr2) - (thread_restartcriticalsection): Removed. - - * src/vm/jit/x86_64/linux/md-os.c: New file. - * src/vm/jit/x86_64/linux/Makefile.am: Likewise. - * src/vm/jit/x86_64/linux/.cvsignore: Likewise. - -2007-02-04 19:41 pm - - * jit/codegen-common.h: Enabled dseg_adddata for s390. - * jit/dseg.c: Likewise. - * jit/s390/md-abi.h: Continued work on s390 port. - * jit/s390/emit.c: Likewise. - * jit/s390/md.c: Likewise. - * jit/s390/codegen.c: Likewise. - * jit/s390/codegen.h: Likewise. - * jit/s390/md-asm.h: Likewise. - * jit/s390/asmpart.S: Likewise. - * jit/s390/md-abi.c: Likewise. - -2007-02-04 16:08 twisti - - * src/native/jni.c (_Jv_JNI_ExceptionDescribe): Fixed typo. - -2007-02-03 19:51 twisti - - * src/vm/jit/x86_64/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef - instrumentation code. - (createnativestub) [ENABLE_PROFILING]: Likewise. - - * src/vm/jit/x86_64/codegen.h [ENABLE_PROFILING] (PROFILE_CYCLE_START) - (PROFILE_CYCLE_STOP): Added #ifdef. - -2007-02-03 19:34 twisti - - * src/vm/builtin.c [ENABLE_THREADS] (threads/native/threads.h): - Removed. - [ENABLE_THREADS] (threads/native/lock.h): Added. - (builtin_throw_exception): Use exceptions_set_exception. - - * src/vm/finalizer.c (finalizer_run): Likewise. - - * src/vm/signal.c (signal_start_thread): Use #warning instead of - #error (temporarily). - - * src/native/jni.c (_Jv_jni_invokeNative): Use - exceptions_get_exception, and exceptions_clear_exception. - (_Jv_JNI_ExceptionDescribe): Likewise. - (_Jv_JNI_IsAssignableFrom): Use exceptions_set_exception. - (_Jv_JNI_ExceptionOccurred): Use exceptions_get_exception. - (_Jv_JNI_ExceptionCheck): Likewise. - (_Jv_JNI_ExceptionClear): Use exceptions_clear_exception. - -2007-02-02 12:53 twisti - - * src/vm/jit/i386/codegen.c (codegen) [ENABLE_PROFILING]: Profiling - code. - (createnativestub): Likewise. +2008-03-01 Stefan Ring -2007-02-02 12:39 twisti + * .hgignore: + * .hgignore: Ignoring latex output files. + [c68604485dd4] - * src/native/vm/java_lang_Object.c [ENABLE_JAVAME_CLDC1_1] - (native/include/java_lang_String.h): Added. +2008-03-03 Christian Thalinger -2007-02-02 12:28 twisti + * src/lib/Makefile.am: + * src/lib/Makefile.am (EXTRA_DIST): Removed VM_JAVA_FILES, added + VM_JAVA_FILES_GNU, VM_JAVA_FILES_GNU_ANNOTATIONS, + VM_JAVA_FILES_CLDC1_1. (VM_JAVA_FILES): Removed. + (VM_JAVA_FILES_GNU): Added. (VM_JAVA_FILES_GNU_ANNOTATIONS): + Likewise. (VM_JAVA_FILES_CLDC1_1): Likewise. + [ec85f6c4026c] - * src/native/vm/java_lang_Class.h (native/include/java_lang_String.h): - Required by java_lang_Class.h for Java ME. +2008-02-29 Stefan Ring -2007-02-02 11:58 michi + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + Reusing threadobjects. - * src/vm/jit/arm/md-abi.h: Renamed REG_IP to REG_PV (special favor - for twisti). - * src/vm/jit/arm/emit.c, src/vm/jit/arm/codegen.c, - src/vm/jit/arm/codegen.h: - Adapted to the above change. + * src/threads/native/threads.c (threads_impl_thread_new): Removed + and split up into three new functions. (threads_impl_thread_init, + threads_impl_thread_clear) (threads_impl_thread_reuse): New + functions. (threads_impl_thread_free): Disabled. -2007-02-02 00:20 twisti + * src/threads/native/threads.h (threadobject): Added field for free- + list. - * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_PROFILING]: Call - reorder only when profiling. + * src/threads/threads-common.c (threads_preinit, threads_thread_new) + (threads_thread_free): Reuse threadobjects. -2007-02-02 00:10 twisti + * src/threads/threads-common.h: New function declarations. + [d73f6705d7ad] - * src/vm/jit/code.h (codeinfo) [ENABLE_PROFILING]: Made frequency, - bbfrequency, and cycles conditional. - - * src/vm/jit/jit.c (jit_compile) [ENABLE_PROFILING]: Likewise. - (jit_compile_intern) [ENABLE_PROFILING]: Likewise. +2008-02-28 pm -2007-02-02 00:06 twisti + * src/vm/jit/cfg.c: + * src/vm/jit/cfg.c (cfg_add_exceptional_edges): Conditionally + compiling (was forgotten). + [97bbdfcfb666] - * src/vm/jit/optimizing/Makefile.am [ENABLE_PROFILING] - (REORDER_SOURCES): Moved here till we have something better. +2008-02-28 Peter Molnar -2007-02-01 15:35 twisti + * src/vm/jit/jit.c: + Merging 7888. + [42ae5a01ac5a] - * src/vmcore/suck.c (assert.h): Added. - (suck_float): Use assert instead of an exception. - (suck_double): Likewise. + * src/vm/jit/cfg.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa3.c: + * src/vm/jit/cfg.c (cfg_add_exceptional_edges): New function + * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_SSA]: Adapted. + * src/vm/jit/jit.h (struct basicblock) [ENABLE_SSA]: New fileds for + exception handlers in cfg. + * src/vm/jit/optimizing/ssa.c (ssa): Adapted. + * src/vm/jit/optimizing/ssa3.c: Changed a lot, currenly broken. + [5faec567ca14] -2007-02-01 15:27 twisti + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md.c: + * src/vm/jit/s390/asmpart.S (L_offsets): Removed references to + unused functions. + * src/vm/jit/s390/md.c: Including vm/jit/s390/md.h. + [0d5247355a8c] - * src/vmcore/linker.c (link_class_intern): Also align double and s8 - fields to 4-bytes for ARM. +2008-02-27 Stefan Ring -2007-02-01 12:58 twisti + * tests/threadInterrupt.java: + * tests/threadInterrupt.java: Added a test showing a bug in the pre- + sable implementation. + [048e4ed58d94] - * src/vmcore/utf8.c (utf_java_lang_InvocationTargetException): Is - actually called utf_java_lang_reflect_InvocationTargetException. - (utf8_init): Likewise. - - * src/vmcore/utf8.h (utf_java_lang_InvocationTargetException): - Likewise. - - * src/vm/exceptions.c (exceptions_throw_invocationtargetexception): + * src/threads/native/lock.c, src/threads/native/threads.c: + * src/threads/native/threads.c (threads_set_current_threadobject): + Added a few vm_abort_errnum calls. (threads_get_current_thread): Likewise. -2007-02-01 12:29 twisti - - * src/vm/jit/code.c [ENABLE_THREADS] (threads/native/lock.h): Added. + * src/threads/native/lock.c (lock_record_new): Likewise. + (lock_record_free): Likewise. + [40e84a6ae6ea] -2007-02-01 12:02 twisti +2008-02-21 Edwin Steiner - * src/vmcore/method.h (methodinfo): Removed member object. - * src/vm/jit/code.h (codeinfo): Added member object. - - * src/vmcore/loader.c (loader_load_method): Removed - lock_init_object_lock. - (load_newly_created_array): Likewise. - * src/vm/jit/code.c (code_codeinfo_new): Added lock_init_object_lock. - - * src/vm/jit/jit.c (jit_jitdata_new): Changed signature. - (jit_compile): Use codeinfo lock object instead of methodinfo. - (jit_recompile): Changed signature. - * src/vm/jit/jit.h (jit_jitdata_new): Likewise. + * src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/linux/md-os.c (md_replace_executionstate_read): + Fix copy&paste mistake (for reading the PC). + [8af912202925] -2007-01-31 17:45 twisti +2008-02-20 Edwin Steiner - * src/cacaoh/dummy.c (pthread.h): Added. + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/replace.h (executionstate_t): Added 'ra' field for + return address register. Otherwise replacement code for the PowerPC + gets very ugly, as the LR is not part of the intregs on PowerPC. -2007-01-31 17:02 twisti + * src/vm/jit/replace.c (replace_executionstate_println): Added print + statements. (replace_sanity_check_read_write): Check 'ra' field. - * src/toolbox/logging.c (log_start): Uncommented thread pointer stuff. - * src/cacaoh/dummy.c (threads_get_current_threadobject): Added. + * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_read): + Use new 'ra' field. (md_replace_executionstate_write): Likewise. -2007-01-31 17:00 twisti + * src/vm/jit/powerpc/linux/md-os.c (md_replace_executionstate_read): + Implemented for PowerPC/Linux. (md_replace_executionstate_write): + Likewise. + [54cb4d152e6f] - * src/native/jni.c (_Jv_JNI_ThrowNew): Fixed warnings. + * src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_read): + Do not use the assignment operator for the float registers, as the + type conversion messes up their values (they are not 'double' in the + context). (md_replace_executionstate_write): Likewise. + [9a2f257d4326] -2007-01-31 14:05 twisti + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_sanity_check_read_write): New + function. Perform some basic sanity checks of the md_replacement_* + implementations. (replace_me_wrapper): Call above function in + debugging mode. + [401ef412801a] - * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: Updated year. +2008-02-20 Roland Lezuo -2007-01-31 14:04 twisti + * Merged with tip + [1c5d66f62119] - * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (string.h): - Added. - (mm/memory.h): Likewise. +2008-02-19 Roland Lezuo -2007-01-31 10:59 twisti + * Merged with cldc-branch + [eb7a914bf640] - * src/vmcore/loader.c (load_newly_created_array) [ENABLE_JAVASE]: - Fixed interfacescount. +2008-02-19 tbfg -2007-01-31 10:00 twisti + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h: + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Do not overwrite + return address with method to be invoked. - * src/vm/exceptions.c [ENABLE_JAVAME_CLDC1_1](exceptions_new_error): - New function. - (exceptions_asm_new_abstractmethoderror) [!ENABLE_JAVASE]: Use - exceptions_new_error. - (exceptions_throw_virtualmachineerror): Removed. - * src/vm/exceptions.h (exceptions_throw_virtualmachineerror): - Likewise. + * src/vm/jit/m68k/codegen.c (codegen_emit_stub_native): Removed call + to trace function as seen in other archs. -2007-01-31 09:51 twisti - - * src/vm/jit/Makefile.am: Fixed !ENABLE_VERIFER build. - -2007-01-30 13:58 twisti - - * src/vm/jit/arm/emit.c (mm/memory.h): Added. - (vm/global.h): Likewise. - (emit_patcher_stubs): Align stack to 8-byte. - (emit_verbosecall_exit): Smaller optimizations. - - * src/vm/jit/arm/md-abi.h (config.h): Added. - (REG_A1_A2_PACKED): Defined. - - * src/vm/jit/arm/md.c: Fixed includes. - (md_codegen_get_pv_from_pc): Use vm_abort. - - * src/vm/jit/arm/codegen.c: Fixed includes. - (codegen): Align stack to 8-byte. - (createnativestub): Likewise. - - * src/vm/jit/arm/codegen.h (M_ADD_IMM_EXT_MUL4): Added do-while. - (M_SUB_IMM_EXT_MUL4): Likewise. - - * src/vm/jit/arm/patcher.c: Fixed includes. - (patcher_wrapper): Align stack to 8-byte. - * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Likewise. - - * src/vm/jit/arm/md-abi.c: Fixed includes. - -2007-01-30 13:53 twisti - - * src/vm/signal.c (signal_init): Disable signal-thread handling - temporarily. - * src/vm/vm.c (vm_create): Likewise. + * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Fix size for + new compiler trap. + [3f6144729487] -2007-01-29 23:07 twisti +2008-02-15 tbfg - * src/vm/string.c (native/jni.h): Added. - * src/vm/properties.c (native/jni.h): Likewise. - - * src/native/vm/cldc1.1/java_lang_Runtime.c: Includes fixed for - cacaoh-changes. - * src/native/vm/cldc1.1/java_lang_Class.c: Likewise. - - * src/native/vm/java_lang_Class.c [ENABLE_JAVAME_CLDC1_1] - (native/include/java_lang_String.h): Added. - (forName): #ifdef'd loader variable. - - * src/vmcore/class.c (class_resolveclassmethod): Removed Java ME - exception handling, we do that in the exception function itself. - (class_resolveinterfacemethod): Likewise. - * src/vmcore/resolve.c (resolve_method_invokespecial): Likewise. - - * src/vmcore/utf8.c [ENABLE_JAVASE] - (utf_java_lang_AbstractMethodError, utf_java_lang_NoSuchFieldError) - (utf_java_lang_NoSuchMethodError): Removed ifdef. - * src/vmcore/utf8.h: Likewise. + * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-abi.c: + * src/vm/jit/m68k/codegen.c (codegen_emit_stub_native): Handle + builtin correctly. + * src/vm/jit/m68k/linux/md-abi.c (md_param_alloc_native): With 8 bytes + stack slots internally natives need a 4 byte stack slot allocation. + (md_param_alloc): Set index correctly. + [c87ce21ccdf8] -2007-01-29 21:47 ajordan +2008-02-19 Edwin Steiner - * src/vm/jit/sparc64/codegen.h: Fixed double register number packing - and fp compare instruction macros. - * src/vm/jit/sparc64/codegen.c: Fixed fp compares. - Fixed INT2CHAR. - Fixed fp argument saving in createnativestub(). - - * src/vm/jit/sparc64/patcher.c: Implemented get/put field patcher. - - * src/vm/jit/sparc64/md.c: Removed printf. + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_alu_imm_membase): Fix emit_rex + call. + [97f2df303ae7] -2007-01-29 21:39 twisti + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_alul_imm_membase): Fix emit_rex + call. + [0eae2350805d] - * src/vm/jit/i386/emit.c: Includes fixed for cacaoh-changes. - * src/vm/jit/i386/md.c: Likewise. - * src/vm/jit/i386/codegen.c: Likewise. - * src/vm/jit/i386/patcher.c: Likewise. - * src/vm/jit/i386/md-abi.c: Likewise. +2008-02-18 Edwin Steiner -2007-01-29 21:38 twisti + * src/vm/jit/inline/inline.c, src/vmcore/options.c: + * src/vmcore/options.h, src/vmcore/options.c, + src/vm/jit/inline/inline.c: Trace levels for inlining. + [a572dc07befb] - * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): New function. - (asm_memory_barrier): Likewise. + * src/vm/jit/inline/inline.c: + * src/vm/jit/inline/inline.c (inline_transform): Make semantics of + opt_InlineCount less confusing. + [02db2973e156] -2007-01-29 21:37 twisti + * src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/vm.c, + src/vmcore/linker.c, src/vmcore/method.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c, + src/vmcore/linker.c, src/vm/vm.c, src/vm/jit/jit.c, + src/vm/jit/inline/inline.c: Changed inlining options to -XX options. + [fcb2ea727c23] - * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): Changed comment. +2008-02-19 Christian Thalinger -2007-01-29 21:09 twisti + * src/vm/jit/powerpc/linux/md-abi.c: + * src/vm/jit/powerpc/linux/md-abi.c (md_return_alloc): Use switch- + case. + [0b1af4df6ef2] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Use switch-case to + store return values for invokes. + [016cdf940d81] + +2008-02-18 Christian Thalinger + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Use + switch-case for argument copying. + [720c659e4ecc] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Removed variable a, + added variable i. + [bb4a72bd2d52] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Use switch-case when + argument copying for invokes. + [2e2c6db95e46] + + * src/vm/jit/powerpc/codegen.h: + * src/vm/jit/powerpc/codegen.h: Grouped and alpha-sorted the code + generating macros. + [c280412cfc3b] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_gc_from_native): Fixed typo, again. + [897943ebddcc] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_me): Fixed typo. + [273027fcc0d0] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_me): Use + threads_get_current_stackframeinfo(). (replace_gc_from_native): + Likewise. + [28d447c7b5f7] + + * src/mm/cacao-gc/gc.c, src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/sun/jvm.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/threads/threads-common.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.c (stacktrace_get): Changed signature to + take again a stackframeinfo_t. (stacktrace_get_current): New + function. (stacktrace_stackframeinfo_add): Use + threads_get_current_stackframeinfo. + (stacktrace_stackframeinfo_remove): Likewise. + (stacktrace_first_nonnull_classloader): Likewise. + (stacktrace_getClassContext): Likewise. + (stacktrace_get_current_class): Likewise. (stacktrace_get_stack): + Likewise. + * src/vm/jit/stacktrace.h (stacktrace_get): Changed signature. + (stacktrace_get_current): New function. - * src/vm/jit/mips/emit.c: Include fixes for cacaoh-changes. - * src/vm/jit/mips/md.c: Likewise. - * src/vm/jit/mips/codegen.c: Likewise - * src/vm/jit/mips/linux/md-os.c: Likewise - * src/vm/jit/mips/disass.c: Likewise - * src/vm/jit/mips/patcher.c: Likewise - * src/vm/jit/mips/md-abi.c: Likewise + * src/mm/cacao-gc/gc.c (gc_collect): Replaced stacktrace_get with + stacktrace_get_current. + * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace): + Likewise. + * src/native/vm/gnu/java_lang_VMThrowable.c (fillInStackTrace): + Likewise. + * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Likewise. -2007-01-29 20:24 twisti + * src/threads/native/threads.h (STACKFRAMEINFO): Removed. + (threads_get_current_stackframeinfo): New function. + (threads_set_current_stackframeinfo): Likewise. + * src/threads/none/threads.h: Likewise. - * src/vm/jit/alpha/emit.c: Fixed includes for cacaoh-changes. - * src/vm/jit/alpha/codegen.c: Likewise. - * src/vm/jit/alpha/linux/md-os.c: Likewise. - * src/vm/jit/alpha/patcher.c: Likewise. - * src/vm/jit/alpha/md-abi.c: Likewise. - -2007-01-29 19:34 twisti - - * src/native/include/.cvsignore: Ignore all *.h files. - -2007-01-29 19:32 twisti - - * src/vm/jit/x86_64/md.c: Fixed includes for cacaoh-changes. - -2007-01-29 19:28 twisti - - * src/vm/jit/x86_64/emit.c: Fixed includes for cacaoh-changes. - * src/vm/jit/x86_64/codegen.c: Likewise. - * src/vm/jit/x86_64/patcher.c: Likewise. - * src/vm/jit/x86_64/md-abi.c: Likewise. - -2007-01-29 19:15 twisti - - * src/vmcore/stackmap.c [ENABLE_STATISTICS] (vmcore/statistics.h): - Removed ifdef. - * src/vm/jit/jit.c: Likewise. - * src/vm/jit/emit-common.c: Likewise. - -2007-01-29 18:49 twisti - - * This is a rather huge commit, which changes the build order of - various parts to be able to bootstrap cacaoh without any dependencies - on a generated header file. I include the file list from SVN, so we - can see what happened to the files. - - Here we go (D-files were mostly moved to src/vmcore): - - D src/vm/hashtable.h - D src/vm/options.h - M src/vm/properties.h - D src/vm/zip.c - D src/vm/class.c - D src/vm/suck.c - D src/vm/loader.c - M src/vm/builtin.c - M src/vm/string.c - D src/vm/zip.h - D src/vm/class.h - D src/vm/rt-timing.c - D src/vm/suck.h - D src/vm/annotation.c - M src/vm/builtin.h - D src/vm/loader.h - D src/vm/descriptor.c - D src/vm/annotation.h - D src/vm/rt-timing.h - D src/vm/resolve.c - D src/vm/method.c - D src/vm/descriptor.h - M src/vm/finalizer.c - D src/vm/resolve.h - D src/vm/method.h - D src/vm/references.h - D src/vm/classcache.c - D src/vm/statistics.c - D src/vm/classcache.h - D src/vm/statistics.h - M src/vm/initialize.c - M src/vm/access.c - D src/vm/stackmap.c - M src/vm/jit/powerpc/linux/md-abi.c - M src/vm/jit/powerpc/emit.c - M src/vm/jit/powerpc/md.c - M src/vm/jit/powerpc/codegen.c - M src/vm/jit/powerpc/patcher.c - M src/vm/jit/codegen-common.h - M src/vm/jit/abi.h - M src/vm/jit/stack.c - M src/vm/jit/optimizing/profile.c - M src/vm/jit/optimizing/recompile.c - M src/vm/jit/optimizing/ifconv.c - M src/vm/jit/optimizing/ifconv.h - M src/vm/jit/code.c - M src/vm/jit/tools/genoffsets.c - M src/vm/jit/code.h - M src/vm/jit/show.c - M src/vm/jit/dseg.c - M src/vm/jit/verify/typeinfo.h - M src/vm/jit/verify/typecheck-typeinferer.c - M src/vm/jit/verify/typecheck.c - M src/vm/jit/verify/typecheck-stackbased.c - M src/vm/jit/verify/typeinfo.c - M src/vm/jit/dseg.h - M src/vm/jit/loop/loop.h - M src/vm/jit/loop/graph.h - M src/vm/jit/allocator/simplereg.c - M src/vm/jit/parse.c - M src/vm/jit/asmpart.h - M src/vm/jit/stacktrace.c - M src/vm/jit/emit-common.c - M src/vm/jit/jit.c - M src/vm/jit/stacktrace.h - M src/vm/jit/codegen-common.c - M src/vm/jit/jit.h - M src/vm/initialize.h - M src/vm/access.h - D src/vm/stackmap.h - M src/vm/signal.c - M src/vm/exceptions.c - M src/vm/vm.c - D src/vm/field.c - D src/vm/linker.c - M src/vm/exceptions.h - M src/vm/stringlocal.h - D src/vm/utf8.c - D src/vm/field.h - M src/vm/Makefile.am - D src/vm/linker.h - D src/vm/hashtable.c - D src/vm/options.c - D src/vm/utf8.h - M src/vm/properties.c - M src/vm/signallocal.h - M src/cacao/Makefile.am - M src/native/jni.c - M src/native/vm/java_lang_Class.c - M src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c - M src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c - M src/native/vm/gnu/java_security_VMAccessController.c - M src/native/vm/gnu/java_lang_VMClassLoader.c - M src/native/vm/gnu/java_lang_management_VMManagementFactory.c - M src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c - M src/native/vm/gnu/java_lang_VMClass.c - M src/native/vm/gnu/java_lang_VMThread.c - M src/native/vm/gnu/gnu_classpath_VMSystemProperties.c - M src/native/vm/gnu/java_lang_reflect_Method.c - M src/native/vm/gnu/java_lang_VMRuntime.c - M src/native/vm/gnu/java_lang_reflect_Field.c - M src/native/vm/gnu/gnu_classpath_VMStackWalker.c - M - src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c - M src/native/vm/gnu/java_lang_reflect_Constructor.c - M src/native/vm/gnu/java_lang_VMThrowable.c - M src/native/vm/java_lang_Object.c - M src/native/vm/java_lang_Thread.c - D src/native/include/java_lang_Thread.h - D src/native/include/java_lang_Throwable.h - D src/native/include/java_util_Properties.h - D src/native/include/java_lang_VMThread.h - D src/native/include/java_lang_VMThrowable.h - D src/native/include/java_lang_ClassLoader.h - M src/native/include/Makefile.am - D src/native/include/java_lang_Cloneable.h - D src/native/include/java_lang_ThreadGroup.h - D src/native/include/java_lang_Class.h - D src/native/include/java_lang_Object.h - D src/native/include/java_lang_String.h - M src/native/jni.h - M src/native/native.c - M src/native/native.h - A src/toolbox/hashtable.h - M src/toolbox/list.c - M src/toolbox/avl.c - M src/toolbox/logging.c - M src/toolbox/Makefile.am - M src/toolbox/logging.h - A src/toolbox/hashtable.c - M src/mm/gc-common.h - M src/mm/Makefile.am - M src/mm/memory.c - M src/mm/boehm.c - M src/Makefile.am - M src/threads/none/threads.h - M src/threads/none/lock.h - M src/threads/native/threads.h - M src/threads/native/lock.c - M src/threads/native/threads.c - AM src/vmcore - A src/vmcore/options.h - A src/vmcore/zip.c - A src/vmcore/suck.c - A src/vmcore/class.c - A src/vmcore/loader.c - A src/vmcore/zip.h - A src/vmcore/annotation.c - A src/vmcore/suck.h - A src/vmcore/class.h - A src/vmcore/rt-timing.c - A src/vmcore/loader.h - A src/vmcore/descriptor.c - A src/vmcore/resolve.c - A src/vmcore/annotation.h - A src/vmcore/rt-timing.h - A src/vmcore/method.c - A src/vmcore/descriptor.h - A src/vmcore/resolve.h - A src/vmcore/method.h - A src/vmcore/references.h - A src/vmcore/classcache.c - A src/vmcore/statistics.c - A src/vmcore/.cvsignore - A src/vmcore/classcache.h - A src/vmcore/statistics.h - A src/vmcore/stackmap.c - A src/vmcore/stackmap.h - A src/vmcore/field.c - A src/vmcore/linker.c - A src/vmcore/utf8.c - A src/vmcore/field.h - A src/vmcore/Makefile.am - A src/vmcore/linker.h - A src/vmcore/options.c - A src/vmcore/utf8.h - M src/cacaoh/cacaoh.c - M src/cacaoh/headers.h - M src/cacaoh/Makefile.am - M src/cacaoh/headers.c - A src/cacaoh/dummy.c - M configure.ac - -2007-01-29 11:52 twisti - - * src/vm/jit/arm/emit.c [ENABLE_SOFTFLOAT] (emit_load): Implemented. - (emit_store): Changed implementation to be more clear. - (emit_copy): Likewise. - -2007-01-29 10:19 twisti - - * src/vm/jit/arm/codegen.c (codegen): ICMD_DASTORE: bugfix for - softfloat. - -2007-01-28 23:35 twisti - - * src/vm/jit/mips/codegen.c (createcompilerstub): Don't generate a - codeinfo. - -2007-01-28 22:57 twisti - - * src/vm/jit/arm/codegen.c (createcompilerstub): Don't generate a - codeinfo. - -2007-01-27 15:52 twisti - - * configure.ac: Use AC_CHECK_SOFTFLOAT, AC_CHECK_SOFT_FLOAT_CMP and - AC_CHECK_SOFT_DOUBLE_CMP. - * m4/soft.m4: New file. - - * src/vm/builtin.c [!SUPPORT_FLOAT_CMP] (builtin_fcmpl): Added - conditional. - [!SUPPORT_DOUBLE_CMP] (builtin_dcmpl): Likewise. - - * src/vm/builtintable.inc (builtintable_automatic): - [!SUPPORT_FLOAT_CMP] (BUILTIN_fcmpl): Added. - [!SUPPORT_DOUBLE_CMP] (BUILTIN_dcmpl): Likewise. - (builtintable_function): [__MIPS__ && SIZEOF_VOID_P != 4] - (BUILTIN_arraycopy): Added. - - * src/vm/jit/mips/codegen.c (codegen): Added SUPPORT_FLOAT_CMP for - ICMD_FCMPx, and SUPPORT_DOUBLE_CMP for ICMD_DCMPx. - - * src/vm/jit/arm/arch.h (SUPPORT_FLOAT_CMP, SUPPORT_DOUBLE_CMP): - Added. - * src/vm/jit/powerpc/arch.h: Likewise. - * src/vm/jit/sparc64/arch.h: Likewise. - * src/vm/jit/alpha/arch.h: Likewise. - * src/vm/jit/s390/arch.h: Likewise. - * src/vm/jit/mips/arch.h: Likewise. - * src/vm/jit/parisc/arch.h: Likewise. - * src/vm/jit/m68k/arch.h: Likewise. - * src/vm/jit/i386/arch.h: Likewise. - * src/vm/jit/powerpc64/arch.h: Likewise. - * src/vm/jit/x86_64/arch.h: Likewise. - - * src/vm/jit/mips/patcher.c (vm/jit/md.h): Added. - -2007-01-27 13:01 twisti - - * src/vm/loader.c (load_newly_created_array): c->interfacescount was - always set to 0, fixed. - -2007-01-27 00:58 ajordan - - * src/vm/jit/sparc64/emit.c: Moved exception check generation to emit + * src/threads/threads-common.c (threads_dump) [ENABLE_GC_CACAO]: + Added code to suspend and resume the thread (NOTE: Not tested!). + (threads_thread_print_stacktrace): Rewritten to work again. + [fa23c7f74264] + + * src/mm/boehm.c, src/mm/codememory.c, src/native/jni.c, + src/native/localref.c, src/native/native.c, + src/native/vm/nativevm.c, src/threads/native/threads.c, src/threads + /threads-common.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/finalizer.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/recompile.c, src/vm/package.c, + src/vm/primitive.c, src/vm/properties.c, src/vm/signal.c, + src/vm/string.c, src/vmcore/classcache.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/options.c, src/vmcore/options.h, + src/vmcore/primitivecore.c, src/vmcore/suck.c, src/vmcore/utf8.c: + * src/vmcore/options.c (opt_TraceSubsystemInitialization): Added. + * src/vmcore/options.h (TRACESUBSYSTEMINITIALIZATION): New macro. + + * src/mm/boehm.c, src/mm/codememory.c, src/native/jni.c, + src/native/localref.c, src/native/native.c, + src/native/vm/nativevm.c, src/threads/native/threads.c, src/threads + /threads-common.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/finalizer.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/recompile.c, src/vm/package.c, + src/vm/primitive.c, src/vm/properties.c, src/vm/signal.c, + src/vm/string.c, src/vmcore/classcache.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/primitivecore.c, src/vmcore/suck.c, + src/vmcore/utf8.c: Added TRACESUBSYSTEMINITIALIZATION to the *_init functions. - * src/vm/jit/sparc64/codegen.h: Likewise. - * src/vm/jit/sparc64/codegen.c: Likewise. - - * src/vm/jit/sparc64/md.c: Added SPARC specific functions for getting - JIT information from the stack frame. - - * src/vm/jit/sparc64/linux/md-os.c: Fixed icache flushing when start - address is not doubleword aligned. + [6d9f949cf40f] -2007-01-23 13:05 twisti + * src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c: Use int instead of int32_t for opt_* + variables. + * src/vmcore/options.h: Likewise. + [4df71b1bfc9e] - * src/vm/jit/mips/emit.c (emit_patcher_stubs): Use - dseg_add_functionptr instead of dseg_add_address. +2008-02-17 Edwin Steiner -2007-01-22 20:16 twisti + * contrib/vmlog/vmlog_cacao.c: + * contrib/vmlog/vmlog_cacao.c (vmlog_cacao_do_log): Deal with + m->class == NULL. + [0bb3cb112e99] - * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit): - Added missing file://. + * Merged the "edwin-replacement" branch that I pushed accidentally. + [a96003ee3eda] -2007-01-22 17:25 twisti + * src/vm/signal.c: + * src/vm/signal.c (signal_handle): vmlog signal type. + [a73070c07207] - * src/cacao/cacao.c (main): Fixed typo. + * src/vm/signal.c: + * src/vm/signal.c (signal_handle): vmlog signal type. + [4d5807b92748] -2007-01-22 17:22 twisti + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (md_pop_stackframe): New function. + (md_push_stackframe): New function. (replace_pop_activation_record): + Factored out popping of the stack frame into md_pop_stackframe. + (replace_push_activation_record): Factored out pushing of the stack + frame into md_push_stackframe. + [32ee42dff4a2] - * src/lib/vm/reference/gnu/classpath/VMSystemProperties.java: New - file. - - * src/lib/Makefile.am (VM_JAVA_FILES): Added - gnu/classpath/VMSystemProperties.java. - (VM_CLASS_FILES): Likewise. - - * src/native/include/Makefile.am (VM_ZIP): Added. - (DO_HEADER_FILES): Depend on VM_ZIP. +2008-02-16 Edwin Steiner -2007-01-22 17:03 twisti + * src/vm/jit/code.c, src/vm/jit/code.h: + * src/vm/jit/code.h (code_codeinfo_println): New debugging helper. + * src/vm/jit/code.c (code_codeinfo_println): Likewise. + [97ae058719af] - * src/vm/properties.c (properties_get): Search list forward, as we - don't have duplicate entries anymore. - (properties_system_add): New function. - * src/vm/properties.h (properties_system_add): Added. - - * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit): New + * contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h: + * contrib/vmlog/vmlog_cacao.h (vmlog_cacao_signl_type): New function. + * contrib/vmlog/vmlog_cacao.c (vmlog_cacao_signl_type): Likewise. + [ae50a5fdf56f] + +2008-02-15 Edwin Steiner + + * src/vmcore/options.c: + * src/vmcore/options.c (TraceJavaCalls): Remove this option when + vmlog is enabled. (It does not have the expected effect then). + [2015ddd5c931] + + * contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h, + contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h, + src/cacaoh/dummy.c, src/vm/vm.c, src/vmcore/options.c: + * src/vmcore/options.c (options_xx): Integrated vmlog options + handling. + * src/vm/vm.c (vm_create): Changed vmlog init interface. + * src/cacaoh/dummy.c (vmlog_cacao_set_prefix, + vmlog_cacao_set_stringprefix, vmlog_cacao_set_ignoreprefix): Dummies + added. + * contrib/vmlog/vmlog.h, contrib/vmlog/vmlog.c, + contrib/vmlog/vmlog_cacao.h, contrib/vmlog/vmlog_cacao.c: Changed + vmlog init interface. + [921f7f0fd054] + + * contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h: + * contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h: Replaced + the old java_objectheader with java_object_t. Adapted lock function + calls. This makes cacao compile with --enable-vmlog again. + [e7178d529ced] + +2008-02-15 Peter Molnar + + * src/vm/jit/jit.h, src/vm/jit/optimizing/Makefile.am, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa2.c, + src/vm/jit/optimizing/ssa2.h, src/vm/jit/optimizing/ssa3.c, + src/vm/jit/python.c: + * src/vm/jit/jit.h (FOR_EACH_BASICBLOCK, FOR_EACH_SUCCESSOR, + FOR_EACH_PREDECESSOR, FOR_EACH_INSTRUCTION, basicblock_reached): New + symbols. + * src/vm/jit/optimizing/Makefile.am (SSA_SOURCES) [ENABLE_SSA]: AddeAd + ssa3.c + * src/vm/jit/optimizing/ssa.c: Adapted for ssa3.c. + * src/vm/jit/optimizing/ssa2.c: Added copyright header. + * src/vm/jit/optimizing/ssa3.c: New file. Yet another SSA + transofrmation algorithm prototype. + * src/vm/jit/python.c: Removed wrappers for creating variables and + instructions because they were misdesigned. + * src/vm/jit/optimizing/ssa2.h: Removed. + [ceb76d8a7b2b] + +2008-02-15 twisti + + * src/vmcore/field.c: + * src/vmcore/field.c (field_print): Print offset for non-static + fields. + [c77728b36b0d] + +2008-02-14 Christian Thalinger + + * src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h: + * src/vm/jit/powerpc/codegen.h (MI_and, MI_anddot, MI_andi, + MI_lwarx) (MI_or, MI_ordot, MI_ori, MI_subf, MI_subfdot, + MI_stwcxdot, MI_sync): New macros, these machine instruction macros + should make it easier to understand them. + + * src/vm/jit/powerpc/codegen.c: Use new MI macros. + [96c26cc7065f] + +2008-02-14 Peter Molnar + + * src/vm/jit/optimizing/dominators.c: + * src/vm/jit/optimizing/dominators.c: Adapted for changes in + src/mm/dumpmemory.h. + [6a888becb172] + +2008-02-14 Christian Thalinger + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_impl_thread_free): Use + vm_abort_errnum. (threads_list_lock): Likewise. + (threads_list_unlock): Likewise. (threads_mutex_gc_lock): Likewise. + (threads_mutex_gc_unlock): Likewise. (threads_mutex_join_lock): + Likewise. (threads_mutex_join_unlock): Likewise. + (threads_impl_thread_start): Likewise. + [b6e1edd8c04e] + + * src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (vm_abort_errnum): New function. (vm_abort_errno): Use + vm_abort_errnum. + * src/vm/vm.h (vm_abort_errnum): Added. + [60d2963cf5a0] + + * src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (vm_abort_errno): New function. (vmcore/system.h): + Added. (vm_abort): Use system_abort. + + * src/vm/vm.h (stdint.h): Added. (vm_abort_errno): Likewise. + [7437e7e4efd6] + + * configure.ac, src/vmcore/system.h: + * configure.ac (AC_CHECK_FUNCS): Added abort. + + * src/vmcore/system.h (system_abort): New function. + (system_strerror): Likewise. + [fb6e241c3df9] + + * tests/regression/Makefile.am, + tests/regression/assertion/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/jasmin/Makefile.am, + tests/regression/native/Makefile.am, + tests/regression/resolving/Makefile.am: + * tests/regression/Makefile.am: Always use the same bootclasspath + for different configurations, it does not matter. + + * tests/regression/assertion/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/jasmin/Makefile.am, + tests/regression/native/Makefile.am, + tests/regression/resolving/Makefile.am: Likewise + [4574d7b390ca] + + * * Merged with 3683e6f66d90. + [ac5846955a0b] + + * configure.ac, tests/regression/Makefile.am: + * configure.ac (AC_CONFIG_FILES): Re-enabled resolving since Edwin + fixed the tests. + * tests/regression/Makefile.am: Likewise. + [37af3c98ade8] + +2008-02-11 Edwin Steiner + + * tests/regression/resolving/TestController.java, + tests/regression/resolving/test_instance_subtype_violated.java, test + s/regression/resolving/test_param_loading_constraint_violated.java, t + ests/regression/resolving/test_param_loading_constraint_violated_der + ived.java, + tests/regression/resolving/test_param_subtype_violated.java, + tests/regression/resolving/test_return_subtype_ok.java, + tests/regression/resolving/test_return_subtype_violated.java, tests/ + regression/resolving/test_retval_loading_constraint_violated.java, + tests/regression/resolving/test_simple_lazy_load.java: + * tests/regression/resolving/TestController.java: Better error + messages and more convenience methods (needed for following adaption + of tests). + [a6f28893a706] + +2008-02-14 Peter Molnar + + * src/toolbox/Makefile.am, src/toolbox/bitvector.h, src/toolbox/set.c, + src/toolbox/set.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/cfg.c, src/vm/jit/cfg.h, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/optimizing/Makefile.am, + src/vm/jit/optimizing/dominators.c, + src/vm/jit/optimizing/dominators.h, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa2.c, src/vm/jit/optimizing/ssa2.h, + src/vm/jit/python.c, src/vm/jit/python.h, src/vm/jit/show.c: + * src/toolbox/Makefile.am (libtoolbox_la_SOURCES): Added set.[ch] + * src/toolbox/bitvector.h: Added missing include + + * src/toolbox/set.c, src/toolbox/set.h: New file. Set (of pointers) + implementation. + + * src/vm/jit/allocator/simplereg.c [ENABLE_SSA]: Fix for SSA. + + * src/vm/jit/cfg.c, src/vm/jit/cfg.h (cfg_insert_successors, + cfg_add_root): New functions. (cfg_build): Using controlflow + constants rather than opcodes, fixed multiple + predecessors/successors problem. + + * src/vm/jit/jit.c, src/vm/jit/jit.h: Added various inline accessors + for varinfo and instruction. (basicblock [ENABLE_SSA]): Added new + fields. + + * src/vm/jit/optimizing/Makefile.am (SSA_SOURCES): Added ssa2.c. + * src/vm/jit/optimizing/dominators.c, + src/vm/jit/optimizing/dominators.h: Added cleaned up dominator tree + and dominance frontier implementation. + + * src/vm/jit/optimizing/ssa.c: Hooked in cleaned up ssa and + dominators. + + * src/vm/jit/optimizing/ssa2.c, src/vm/jit/optimizing/ssa2.h: New + (temporary) files. Added cleanead up ssa implementation. Currently + renames only locals and passes all dacapo benchmarks. + + * src/vm/jit/python.c. src/vm/jit/python.h: Changed a lot. + + * src/vm/jit/show.c (show_basicblock): Support NULL + bptr->javalocals. + [3683e6f66d90] + +2008-02-14 Christian Thalinger + + * * Merged with fd492236e7ac. + [fb5bf733f6ef] + +2008-02-10 Christian Thalinger + + * src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/native/vm/sun/jvm.c: + * src/native/native.c (native_library_load): New function. + * src/native/native.h: Likewise. -2007-01-22 15:59 twisti - - * src/vm/jit/mips/md.c (md_get_method_patch_address): Fixed compiler - warning. - -2007-01-22 14:02 twisti - - * src/cacao/cacao.c (main): Fixed compiler warning. - -2007-01-22 11:45 twisti - - * src/vm/jit/arm/codegen.c (vm/jit/md.h): Added. - * src/vm/jit/arm/patcher.c (vm/jit/md.h): Likewise. - -2007-01-22 01:43 ajordan - - * src/vm/jit/sparc64/codegen.h: Fixed big disp handling. - * src/vm/jit/sparc64/codegen.c: Likewise. - -2007-01-22 00:58 twisti - - * src/vm/jit/jit.h (md_init, md_get_method_patch_address,) - (md_cacheflush, md_icacheflush, md_dcacheflush, intrp_md_init): - Removed. - - * src/vm/jit/md.h: New file. - * src/vm/jit/Makefile.am (noinst_HEADERS): Added md.h. - - * src/vm/jit/jit.c (vm/jit/md.h): Added. - * src/vm/jit/codegen-common.c (vm/jit/md.h): Likewise. - * src/vm/vm.c (vm/jit/md.h): Likewise. - -2007-01-19 01:13 edwin - - * src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c, - src/vm/jit/jit.c, src/vm/vm.c, src/vm/linker.c, src/vm/options.c, - src/cacaoh/headers.c: Cleaned up inlining options. - - * src/vm/exceptions.c: Removed a left-over use of "useinlining". - - * configure.ac: New configure flag --enable-inlining-debug. + * src/native/vm/java_lang_Runtime.c: Removed. + * src/native/vm/java_lang_Runtime.h: Likewise. -2007-01-18 13:21 twisti + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed + java_lang_Runtime.[ch]. - * src/vm/jit/arm/md-asm.h: Renamed argument defines to start with 0. - * src/vm/jit/arm/asmpart.S: Likewise. + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c + (native/vm/java_lang_Runtime.h): Removed. (loadLibrary): Implemented + directly. -2007-01-18 13:11 twisti + * src/native/vm/cldc1.1/java_lang_Runtime.c (vm/types.h): Removed. + (stdint.h): Added. (mm/gc-common.h): Likewise. + (native/vm/java_lang_Runtime.h): Removed. (vm/vm.h): Added. + (vmcore/utf8.h): Likewise. (exitInternal): Implemented directly. + (freeMemory): Likewise. (totalMemory): Likewise. (gc): Likewise. - * src/vm/vm.c (usage): Removed CACAO options. - (XXusage): New function. - (vm_create): Handle OPT_XX. + * src/native/vm/gnu/java_lang_VMRuntime.c + (native/vm/java_lang_Runtime.h): Removed. (finalizeOnExit): Added. + (exit): Likewise. (freeMemory): Likewise. (totalMemory): Likewise. + (gc): Likewise. (runFinalizersOnExit): Likewise. (nativeLoad): + Likewise. -2007-01-18 12:55 twisti + * src/native/vm/sun/jvm.c (native/vm/java_lang_Runtime.h): Removed. + (JVM_StartThread): Implemented directly. (JVM_SetThreadPriority): + Likewise. (JVM_Sleep): Likewise. (JVM_IsInterrupted): Likewise. + [ca8d8d2c5849] - * src/vm/jit/powerpc/asmpart.S (asm_compare_and_swap): New function. - (asm_memory_barrier): Likewise. +2008-02-09 Christian Thalinger -2007-01-18 11:43 twisti + * m4/annotations.m4: + * m4/annotations.m4 (AC_CHECK_ENABLE_ANNOTATIONS): Changed default + value for different configurations. + (AC_CHECK_ENABLE_ANNOTATIONS_DEFAULT): New function. + [4549e77186f0] - * src/vm/jit/mips/md-asm.h (RESTORE_ARGUMENT_REGISTERS) - (RESTORE_ARGUMENT_REGISTERS, SAVE_TEMPORARY_REGISTERS) - (RESTORE_TEMPORARY_REGISTERS): Added missing float registers. - - * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Changed stack size - for float registers. + * m4/jni.m4: + * m4/jni.m4 (AC_CHECK_ENABLE_JNI): Changed the comment for the + default value. + [a447b8c5bb58] -2007-01-16 22:18 pm + * src/vmcore/loader.h: + * src/vmcore/loader.h (classbuffer): Use stdint data types. + [1e47ce633f93] - Initial import of s390 codegen, codebase is copyed from x86_64. + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_sigsuspend_handler): + Commented. + [d930c08c092e] + + * src/vmcore/options.c: + * src/vmcore/options.c [HAVE_STRING_H] (string.h): Removed. + (vmcore/system.h): Added. (options_get): Use system_* functions. + (options_xxusage): Likewise. + [f88473e0fdfb] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_NewLocalRef): Fixed compiler warning. + (_Jv_JNI_GetObjectField): Likewise. (_Jv_JNI_GetStaticObjectField): + Likewise. (_Jv_JNI_GetDirectBufferAddress): Likewise. + [e101e1fc5cae] + + * src/mm/memory.c: + * src/mm/memory.c (memory_thread): Fixed compiler warning. + [17b0b5f95809] + +2008-02-13 Roland Lezuo + + * src/vm/jit/m68k/md.c, src/vm/jit/m68k/md.h: + (src/vm/jit/m68k/md.c): md_stacktrace_get_returnaddress needs to be + exported. (src/vm/jit/m68k/md.h): Likewise. + [fd492236e7ac] + +2008-02-13 Christian Thalinger + + * src/vm/vm.c: + * src/vm/vm.c (version): Changed copyright message. + [1e10765ce305] + +2008-02-09 Christian Thalinger + + * m4/ac_prog_javac.m4, src/lib/Makefile.am, + tests/regression/Makefile.am, + tests/regression/assertion/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/native/Makefile.am: + * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed jikes and + -bootclasspath. + + * src/lib/Makefile.am (BOOTCLASSPATH): Added. + + * tests/regression/Makefile.am (BOOTCLASSPATH): Likewise. (JAVACMD): + Likewise. (JAVACCMD): Likewise. + + * tests/regression/assertion/Makefile.am: Likewise. + * tests/regression/codepatching/Makefile.am: Likewise. + * tests/regression/native/Makefile.am: Likewise. + [3b3c3e5de94b] + +2008-02-08 Christian Thalinger + + * configure.ac: + * configure.ac (AC_CONFIG_FILES): Removed resolving. + [aae21148aa9b] + + * src/vm/string.c: + * src/vm/string.c (literalstring_free): Commented out, since it's + currently not used. + [3066b22b8c76] + + * configure.ac, src/vm/assertion.c, src/vmcore/system.h: + * configure.ac (AC_CHECK_FUNCS): Added strlen. + + * src/vm/assertion.c [HAVE_STRING_H] (string.h): Removed. + (vmcore/system.h): Added. (assertion_ea_da): Use system_* functions. + Fixed crash: use list_add_last_unsynced instead of list_add_last. + + * src/vmcore/system.h (system_strdup): New function. + (system_strlen): Likewise. + [611f3dff023e] + + * src/vm/jit/arm/Makefile.am, src/vm/jit/i386/Makefile.am, + src/vm/jit/m68k/Makefile.am, src/vm/jit/mips/Makefile.am, + src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc64/Makefile.am, + src/vm/jit/s390/Makefile.am, src/vm/jit/sparc64/Makefile.am, + src/vm/jit/x86_64/Makefile.am: + * src/vm/jit/arm/Makefile.am (libarch_la_SOURCES): Added md.h. + + * src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am, + src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am, + src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am: + Likewise. + [a8894d776f9c] -2007-01-16 12:59 twisti + * src/vm/jit/intrp/Makefile.am: + * src/vm/jit/intrp/Makefile.am ($(BUILT_SOURCES)): Use $(SHELL) to + call vmgenx. + [398ee2cea293] - * src/cacaoh/headers.c (asm_compare_and_swap): Added. - (asm_memory_barrier): Likewise. + * tests/regression/native/Makefile.am: + * tests/regression/native/Makefile.am (JAVAHFLAGS): Added. + [b216ffaa1e84] -2007-01-16 12:52 twisti + * src/vm/vm.c: + * src/vm/vm.c (vm_call_method_objectarray): Fixed compiler warning. + [4849299bd8de] - * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed unused - sizestackframeinfo. +2008-02-07 Stefan Ring -2007-01-16 09:54 twisti + * src/threads/native/lock.c, src/threads/native/lock.h, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/native/lock.c: Fixed copyright message. - * src/vm/jit/asmpart.h (asm_compare_and_swap): Added. - (asm_memory_barrier): Likewise. - - * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): New function. - (asm_memory_barrier): Likewise. + * src/threads/native/lock.h, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h: Likewise. + [2f37becb4a5c] -2007-01-15 10:28 twisti + * src/threads/native/lock.c: + * src/threads/native/lock.c (notify_flc_waiters): Another deadlock + fix. + [d283bd3bbb3d] - * src/vm/jit/powerpc64/codegen.c (codegen): Ported replacement. +2008-02-06 Stefan Ring -2007-01-13 22:54 edwin + * src/threads/native/lock.c: + * src/threads/native/lock.c (lock_monitor_wait, + lock_monitor_notify): Bugfix for previous commit, could cause + threads to hang forever. + [c2c8e3043369] - * src/vm/jit/verify/typecheck-typeinferer.c: Check basic types in - debug mode. + * src/threads/native/lock.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/vm/global.h: + * src/threads/native/lock.c: Implemented Sable extension to tasuki + lock. + * src/threads/native/threads.c: Likewise. + * src/threads/native/threads.h: Likewise. -2007-01-13 22:44 edwin + * src/vm/global.h: Removed hdrflags. + [2988182011bb] - * src/vm/jit/verify/generate.pl: Further changes for the type inferer. - - * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Regenerated. + * Merge (tasuki lock modification backout) + [a80e9dea4e55] -2007-01-13 22:39 edwin + * src/threads/native/lock.c, src/vm/global.h: + Backed out changeset 9c85e9af47c9 + [f79e2f05c4a1] - * src/vm/rt-timing.h: Fixed position of #include "config.h". - (rt_timing_diff_usec): Export. - - * src/vm/rt-timing.c (rt_timing_diff_usec): Export. +2008-02-05 Christian Thalinger -2007-01-13 22:37 edwin + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (vm/exceptions.h): Added. + (exceptions_throw_incompatibleclasschangeerror): Fixed signature. + (exceptions_throw_verifyerror): Likewise. + (exceptions_throw_unsupportedclassversionerror): Likewise. + [37ec16a94863] + + * src/vm/jit/codegen-common.c, src/vm/jit/x86_64/emit.c: + * src/vm/jit/codegen-common.c (codegen_reg_of_var): Removed unused + conditional move code. This will not be implemented in the baseline + compiler. + * src/vm/jit/x86_64/emit.c (emit_store): Likewise. + [458d51359eac] + + * tests/regression/TestAnnotations.java: + * tests/regression/TestAnnotations.java: Fixed copyright header. + [e1d371396063] + +2008-02-04 Gregor Kaufmann + + * configure.ac, src/vm/vm.c, tests/regression/Makefile.am, + tests/regression/assertion/Makefile.am, + tests/regression/assertion/Test.sh, + tests/regression/assertion/disabled.output, + tests/regression/assertion/enabled.output, + tests/regression/assertion/packagetest/testassertions.java, + tests/regression/assertion/testassertions.java: + * configure.ac (AC_CONFIG_FILES): Added + tests/regression/assertion/Makefile - * src/vm/jit/jit.c (jit_compile_intern): Removed unused code and fixed - instrumentation. + * src/vm/vm.c (opts): Added OPT_EA_NOARG, OPT_EA_NOARG (vm_create): + Handle OPT_EA_NOARG, OPT_EA_NOARG -2007-01-13 22:30 edwin + * tests/regression/Makefile.am (SUBDIRS): Added assertion - * src/vm/jit/inline/inline.c: Better inlining decisions. Implemented - knapsack heuristics. More statistics. Refactoring and fixes. - - * src/vm/jit/inline/inline_debug.inc: Fixed to make it compile. + * tests/regression/assertion/Makefile.a: New file -2007-01-13 16:52 ajordan + * tests/regression/assertion/Test.sh: New file - * src/vm/jit/sparc64/md-abi.h: The JIT stackframes now also includes - the 6 parameter slots required when doing a ABI compliant C call. - * src/vm/jit/sparc64/emit.c: Likewise. - * src/vm/jit/sparc64/codegen.c: Likewise. - * src/vm/jit/sparc64/patcher.c: Likewise. - * src/vm/jit/sparc64/asmpart.S: Likewise. - - * src/vm/jit/sparc64/codegen.h: Added include. - - * src/vm/jit/sparc64/md.c: Added method, to get framepointer from - saved register window. (for temporary fix in JIT stack walking) + * tests/regression/assertion/disabled.output: New file -2007-01-12 17:13 twisti + * tests/regression/assertion/enabled.output: New file - * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use - codegen_get_pv_from_pc. + * tests/regression/assertion/packagetest/testassertions.java: New + file -2007-01-11 22:39 twisti + * tests/regression/assertion/testassertions.java: New file + [f00e0894e74b] - * src/vm/jit/mips/md-abi.h: Merged MIPS32 code. - * src/vm/jit/mips/emit.c: Likewise. - * src/vm/jit/mips/codegen.c: Likewise. - * src/vm/jit/mips/codegen.h: Likewise. - * src/vm/jit/mips/linux/md-os.c: Likewise. - * src/vm/jit/mips/asmpart.S: Likewise. - * src/vm/jit/mips/md-abi.c: Likewise. +2008-02-04 Christian Thalinger -2007-01-11 22:36 twisti + * m4/annotations.m4: + * m4/annotations.m4: Build annotations support by default. + [76cce852d53a] - * src/mm/memory.c (mem_realloc): Fixed compiler warning. + * src/mm/cacao-gc/gc.c: + * src/mm/cacao-gc/gc.c (gc_collect) [!NDEBUG]: Fixed compilation. + [5cba4c25093b] -2007-01-11 14:59 twisti + * * Merged with 9c85e9af47c9. + [8f3fbc9270d5] - * file:///ahome/cacao/svn/cacao-m68k/trunk: Moved to... - * file:///ahome/cacao/svn/cacao/trunk/src/vm/jit/m68k: ...here. +2008-01-30 Christian Thalinger -2007-01-11 14:28 twisti + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (native/vm/java_lang_ClassLoader.h): + Removed. + [7b1c5b9fe819] - * src/vm/exceptions.c (exceptions_throw_internalerror): Don't return a - value. - (exceptions_throw_outofmemoryerror): Likewise. + * src/native/jni.c, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_ClassLoader.h: + * src/native/vm/java_lang_ClassLoader.c: Removed. + * src/native/vm/java_lang_ClassLoader.h: Likewise. -2007-01-11 14:22 twisti + * src/native/vm/Makefile.am (CLASSLOADER_SOURCES): Removed. + (libnativevm_la_SOURCES): Removed CLASSLOADER_SOURCES. - * src/vm/jit/arm/emit.c (emit_exception_stubs): Renamed eref to er, - use md_codegen_patch_branch. - - * src/vm/jit/arm/codegen.c (codegen): Use codegen_resolve_branchrefs, - use exceptions_throw_internalerror. - - * src/vm/jit/arm/codegen.h (M_STACK_LOAD_FLT_TYPED): Removed. - (M_STACK_STORE_FLT_TYPED): Likewise. + * src/native/jni.c [ENABLE_JAVASE] + (native/vm/java_lang_ClassLoader.h): Removed. -2007-01-11 14:19 twisti + * src/native/vm/gnu/java_lang_VMClassLoader.c + (native/vm/java_lang_ClassLoader.h): Removed. (defineClass): Moved + implementation here. + [e02ee62bf5fe] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_DefineClassWithSource): Made data + argument non-const. + [7c595dadbd5f] + + * src/native/jni.c, src/native/vm/java_lang_ClassLoader.c, + src/native/vm/sun_misc_Unsafe.c, src/vmcore/class.c, + src/vmcore/class.h: + * src/vmcore/class.c (class_define): Made data argument non-const. + * src/vmcore/class.h: Likewise. + * src/native/jni.c (_Jv_JNI_DefineClass): Likewise. + * src/native/vm/java_lang_ClassLoader.c (defineClass): Likewise. + * src/native/vm/sun_misc_Unsafe.c (defineClass): Likewise. + [6495c4982eec] + + * src/vm/properties.c, src/vmcore/system.h: + * src/vm/properties.c (properties_set): Use system_access. + * src/vmcore/system.h (system_access): New function. + [1b6a824c642d] + + * configure.ac, src/vmcore/suck.c, src/vmcore/system.h: + * configure.ac (AC_CHECK_FUNCS): Added fclose, fread, stat. + + * src/vmcore/suck.c (dirent.h): Removed. (sys/stat.h): Likewise. + (vmcore/system.h): Added. (suck_add_from_property): Use + system_scandir. (suck_start): Use system_fopen, system_stat, + system_fread, system_fclose. + + * src/vmcore/system.h [HAVE_DIRENT_H] (dirent.h): Added. + [HAVE_STDIO_H] (stdio.h): Likewise. [HAVE_SYS_STAT_H] (sys/stat.h): + Likewise. (system_fopen): New function. (system_fclose): Likewise. + (system_fread): Likewise. (system_scandir): Likewise. (system_stat): + Likewise. + [d36156ecb50a] + + * src/vm/properties.c, src/vmcore/system.h: + * src/vm/properties.c [WITH_JRE_LAYOUT] (libgen.h): Removed. + (vmcore/system.h): Added. (properties_set): Use system_dirname. + + * src/vmcore/system.h [WITH_JRE_LAYOUT && HAVE_LIBGEN_H] (libgen.h): + Added. [WITH_JRE_LAYOUT] (system_dirname): New function. + [9c7fe3420ab9] + + * src/native/jni.c: + * src/native/jni.c: Pre-define java_lang_ClassLoader to prevent a + compiler warning for Sun configurations. + [a91f4c3437d5] + +2008-02-03 Stefan Ring + + * src/threads/native/lock.c, src/vm/global.h: + * src/threads/native/lock.c: Modified tasuki lock such that the FLC + bit can be placed in the lockword. Requires atomic instruction at + monitor_exit (slower!). + + * src/vm/global.h: Removed useless hdrflags and FLC bit value. + [9c85e9af47c9] + +2008-02-02 Stefan Ring + + * src/vm/jit/i386/machine-instr.h, src/vm/jit/x86_64/machine-instr.h: + * src/vm/jit/i386/machine-instr.h (MEMORY_BARRIER_AFTER_ATOMIC): Can + become a real NOP. (MEMORY_BARRIER_BEFORE_ATOMIC): Likewise. + + * src/vm/jit/x86_64/machine-instr.h (MEMORY_BARRIER_AFTER_ATOMIC): + Can become a real NOP. (MEMORY_BARRIER_BEFORE_ATOMIC): Likewise. + [fe3e80ca2479] + + * src/vm/signal.c: + * src/vm/signal.c (signal_init): Disable CrashReporter on Darwin. + [9bc8277affc1] + +2008-02-01 Stefan Ring + + * src/threads/native/lock.c: + * src/threads/native/lock.c (lock_monitor_enter): Adjusted memory + barrier. (lock_monitor_exit): Likewise. + [f31015208523] + +2008-01-30 Christian Thalinger + + * src/mm/cacao-gc/gc.c, src/native/native.c, + src/native/vm/gnu/java_lang_VMRuntime.c, src/vm/builtin.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa_rename.c, + src/vm/jit/patcher-common.c, src/vm/jit/replace.c, + src/vm/jit/show.c, src/vm/jit/trace.c, src/vm/vm.c, + src/vmcore/class.c, tests/regression/Makefile.am: + * src/mm/cacao-gc/gc.c: Fixed copyright message. + + * src/native/native.c, src/native/vm/gnu/java_lang_VMRuntime.c, + src/vm/builtin.c, src/vm/jit/intrp/codegen.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa_rename.c, + src/vm/jit/patcher-common.c, src/vm/jit/replace.c, + src/vm/jit/show.c, src/vm/jit/trace.c, src/vm/vm.c, + src/vmcore/class.c, tests/regression/Makefile.am: Likewise. + [c6a257150aa2] + + * src/mm/dumpmemory.c, src/mm/dumpmemory.h, src/mm/memory.h, + src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h: + * Merged with 0da121c758b9. + [b3689d718218] + +2008-01-22 Christian Thalinger + + * * Merged with 03e39cff22db. + [61bb218662ef] + + * m4/assertion.m4, m4/dump.m4, src/mm/codememory.c, + src/mm/codememory.h, src/mm/dumpmemory.c, src/mm/dumpmemory.h, + src/mm/memory.c, src/mm/memory.h, src/native/vm/sun_misc_Unsafe.c, + src/vm/array.c, src/vm/array.h, src/vm/assertion.c, + src/vm/assertion.h, src/vm/jit/exceptiontable.c, + src/vm/jit/exceptiontable.h, src/vm/jit/ir/Makefile.am, + src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h, + src/vm/jit/linenumbertable.c, src/vm/jit/linenumbertable.h, + src/vmcore/system.c, src/vmcore/system.h: + * m4/assertion.m4: Fixed copyright header. + + * m4/dump.m4, src/mm/codememory.c, src/mm/codememory.h, + src/mm/dumpmemory.c, src/mm/dumpmemory.h, src/mm/memory.c, + src/mm/memory.h, src/native/vm/sun_misc_Unsafe.c, src/vm/array.c, + src/vm/array.h, src/vm/assertion.c, src/vm/assertion.h, + src/vm/jit/exceptiontable.c, src/vm/jit/exceptiontable.h, + src/vm/jit/ir/Makefile.am, src/vm/jit/ir/bytecode.c, + src/vm/jit/ir/bytecode.h, src/vm/jit/linenumbertable.c, + src/vm/jit/linenumbertable.h, src/vmcore/system.c, + src/vmcore/system.h: Likewise. + [a8a8474e33d1] + +2008-01-29 Christian Thalinger + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_EEXIST): Defined. (JVM_Open): + Implemented correctly. + [0da121c758b9] + + * src/vm/properties.c: + * src/vm/properties.c (properties_set) [WITH_JRE_LAYOUT]: Set + java.home as HotSpot does, applications like Ant depend on it. + [f517570c02d6] + +2008-01-25 Christian Thalinger + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (native/include/java_lang_Object.h): + Added. [WITH_CLASSPATH_GNU] + (native/include/gnu_classpath_Pointer.h): Likewise. + (stacktrace_print_exception): Fixed compiler warning. + [d129a9a3bd48] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call): Fixed + compiler warning. + [bac5c4672afa] - * configure.ac [ENABLE_STATICVM] (AC_CHECK_LIB(dl)): Only perform the - check if we want a static VM. - (AC_CONFIG_FILES): Added src/vm/jit/arm/Makefile and - src/vm/jit/arm/linux/Makefile. - * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added arm. +2008-01-23 Christian Thalinger -2007-01-11 13:58 twisti + * * Merged with 03e39cff22db. + [2e553378876c] - * Moved loaded arm files. +2008-01-19 Christian Thalinger -2007-01-10 10:08 twisti + * src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h, + src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa_rename.c, src/vm/jit/parse.c: + * src/vm/jit/ir/bytecode.c (bytecode): New table. + * src/vm/jit/ir/bytecode.h (bytecode_t): New structure. - * src/vm/builtin.c (builtin_newarray): Removed debug output. + * src/vm/jit/jit.c (stackreq, jcommandsize, opcode_names): Removed. + * src/vm/jit/jit.h: Likewise. -2007-01-10 10:03 twisti + * src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa_rename.c, + src/vm/jit/parse.c: Use new bytecode table. + [292ffaab432c] + + * src/vm/jit/codegen-common.c, src/vm/jit/jit.c, src/vm/jit/show.c, + src/vm/vm.c: + * Merged with df1b780317c3. + [63d86c604330] + + * src/cacaoh/dummy.c, src/mm/cacao-gc/gc.c, src/mm/dumpmemory.c, + src/mm/dumpmemory.h, src/mm/memory.h, src/native/native.c, + src/native/vm/gnu/java_lang_VMRuntime.c, src/vm/builtin.c, + src/vm/jit/codegen-common.c, src/vm/jit/intrp/codegen.c, + src/vm/jit/jit.c, src/vm/jit/replace.c, src/vm/jit/show.c, + src/vm/jit/trace.c, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/loader.c: + * src/mm/dumpmemory.c (dump_release): Renamed to dumpmemory_release. + (dump_size): Renamed to dumpmemory_marker. + + * src/mm/dumpmemory.h: Likewise. (DMARKER, DRELEASE): New macros. + + * src/cacaoh/dummy.c, src/mm/cacao-gc/gc.c, src/mm/memory.h, + src/native/native.c, src/native/vm/gnu/java_lang_VMRuntime.c, + src/vm/builtin.c, src/vm/jit/codegen-common.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/jit.c, src/vm/jit/replace.c, + src/vm/jit/show.c, src/vm/jit/trace.c, src/vm/vm.c, + src/vmcore/class.c, src/vmcore/loader.c: Use new macros. + [12502d070d2d] + + * tests/regression/Makefile.am: + * tests/regression/Makefile.am (SUBDIRS): Removed resolving. These + test are broken. + [f9ffd12e7a9f] + +2008-01-11 Christian Thalinger + + * src/cacaoh/dummy.c, src/mm/dumpmemory.c, src/mm/dumpmemory.h, + src/vm/jit/verify/typeinfo.h: + * src/mm/dumpmemory.c (dump_alloc): Renamed to dumpmemory_get. + (dumpmemory_alloc): New function. (dump_realloc): Renamed to + dumpmemory_realloc. + + * src/mm/dumpmemory.h (dump_allocation_t): Renamed useddumpsize to + used. (dumpinfo_t): Renamed currentdumpblock to block, + allocateddumpsize to allocated, useddumpsize to used. (DNEW, DMNEW, + DMREALLOC): Defined to new function names. + + * src/cacaoh/dummy.c (dump_alloc): Renamed to dumpmemory_get. + + * src/vm/jit/verify/typeinfo.h (DNEW_TYPEVECTOR): Use DMNEW. + (DMNEW_TYPEVECTOR): Likewise. (TYPEINFO_ALLOCMERGED): Likewise. + [cee30280dee5] + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_handler): Fixed compiler + warning. + [c4732ead00cc] + +2008-01-22 Christian Thalinger + + * src/vm/jit/arm/md.c: + * src/vm/jit/arm/md.c (md_asm_codegen_get_pv_from_pc): Removed. + [03e39cff22db] + +2008-01-17 Peter Molnar + + * src/vm/jit/alpha/codegen.c, src/vm/jit/codegen-common.c, + src/vm/jit/jit.c, src/vm/jit/optimizing/Makefile.am, + src/vm/jit/optimizing/graph.c, src/vm/jit/optimizing/lifetimes.c, + src/vm/jit/optimizing/lsra.c, src/vm/jit/optimizing/lsra.h, + src/vm/jit/optimizing/ssa.c, src/vm/jit/optimizing/ssa.h, + src/vm/jit/optimizing/ssa_phi.c, src/vm/jit/optimizing/ssa_phi.h, + src/vm/jit/optimizing/ssa_rename.c, + src/vm/jit/optimizing/ssa_rename.h, src/vm/jit/show.c, src/vm/vm.c, + src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/alpha/codegen.c, src/vm/jit/codegen-common.c, + src/vm/jit/jit.c, src/vm/jit/show.c, src/vm/vm.c, + src/vmcore/options.c, src/vmcore/options.h: Integrated Christian + Ullrichs changes related to SSA and LSRA. The diff against SVN + version 8144 was carefully integrated. + + * src/vm/jit/optimizing/Makefile.am, src/vm/jit/optimizing/graph.c, + src/vm/jit/optimizing/lifetimes.c, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa.h, src/vm/jit/optimizing/ssa_phi.c, + src/vm/jit/optimizing/ssa_phi.h, src/vm/jit/optimizing/ssa_rename.c, + src/vm/jit/optimizing/ssa_rename.h: Integrated Christian Ullrichs + changes related to SSA and LSRA. Those files were just COPYED and + adapted from his modified SVN 8144 working copy. + + NOTE: Christian Ullrichs SSA+LSRA related changes to the x86_64 + codegenerator are NOT MERGED in this commit. + [df1b780317c3] + + * src/vm/jit/python.c: + * src/vm/jit/python.c: Wrapped control flow and data flow fields and + respective constants for instruction. + [24dc79f2508c] + +2008-01-16 Christian Thalinger + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (getChar, putChar): Implemented. + (copyMemory): Likewise. + [5265504cc4bf] + +2008-01-10 Gregor Kaufmann + + * doc/Makefile.am, doc/assertions.tex: + * doc/Makefile.am (dist_noinst_DATA): Added assertions.tex. + (assertions): New target, creates assertions.dvi. (CLEANFILES): + Added assertions.aux/.dvi/.log/.toc. + + * doc/assertions.tex: New file, documentation of the assertion + implementation. + [eb342d685856] + +2008-01-10 Peter Molnar + + * src/vm/jit/jit.c, src/vm/jit/python.c: + * src/vm/jit/python.c: (python_global_lock) added, (pythonpass_init) + creating python lock, (pythonpass_run) locking python lock. + * src/vm/jit/jit.c [ENABLE_PYTHON]: Changed name of hardcoded + function. + [18d4cf443b7a] - * src/vm/suck.c (suck_add): Use vm_abort instead of - throw_cacao_exception_exit. - (suck_float, suck_double): Use exceptions_throw_internalerror. - - * src/vm/loader.c (load_class_bootstrap): Use vm_abort instead of - throw_cacao_exception_exit. - * src/vm/jit/sparc64/emit.c (emit_patcher_stubs): Likewise. - * src/vm/jit/mips/md.c (md_patch_replacement_point): Likewise. - * src/vm/vm.c (vm_create): Likewise. - - * src/vm/builtin.c (builtin_newarray): Use - exceptions_throw_outofmemoryerror. - - * src/vm/descriptor.c (descriptor_pool_lookup_classref): Use - exceptions_throw_internalerror. - * src/vm/classcache.c (classcache_store_unique): Likewise. - * src/vm/jit/powerpc/codegen.c (codegen): Likewise. - * src/vm/jit/sparc64/codegen.c (codegen): Likewise. - * src/vm/jit/alpha/codegen.c (codegen): Likewise. - * src/vm/jit/mips/codegen.c (codegen): Likewise. - * src/vm/jit/i386/codegen.c (codegen): Likewise. - * src/vm/jit/powerpc64/codegen.c (codegen): Likewise. - * src/vm/jit/intrp/codegen.c (codegen): Likewise. - * src/vm/jit/x86_64/codegen.c (codegen): Likewise. - * src/vm/jit/stack.c (stack_reanalyse_block): Likewise. - (stack_analyse): Likewise. - * src/vm/jit/verify/typeinfo.c (typeinfos_init_from_methoddesc): - Likewise. - (typeinfo_init_component): Likewise. - * src/vm/jit/verify/typecheck-builtins.inc: Likewise. - * src/vm/jit/allocator/lsra.c (lsra_scan_registers_canditates): - Likewise. - * src/vm/jit/allocator/simplereg.c (simplereg_allocate_temporaries): - Likewise. - * src/vm/jit/allocator/liveness.c - (liveness_scan_registers_canditates): Likewise. - - * src/vm/exceptions.c (exceptions_throw_outofmemory_exit): Removed. - (new_internalerror): Removed. - (exceptions_throw_internalerror): Rewritten. - (exceptions_throw_outofmemoryerror): Added. - - * src/vm/exceptions.h: Likewise. - - * src/vm/utf8.c (utf_get_number_of_u2s): Use - exceptions_throw_internalerror instead of throw_cacao_exception_exit. - - * src/native/native.c (native_init): Changed debug output. - - * src/mm/memory.c (memory_checked_alloc): Use vm_abort instead of - exceptions_throw_outofmemory_exit. - (mem_realloc): Changed debug output. - * src/mm/boehm.c (gc_out_of_memory): Use vm_abort and - exceptions_throw_outofmemoryerror. - - * src/cacaoh/cacaoh.c (cacaoh_abort): Added. - (main): Use cacaoh_abort. - - * src/cacaoh/headers.c (throw_cacao_exception_exit): Removed. - (exceptions_throw_outofmemory_exit): Likewise. - (new_internalerror): Renamed to exceptions_throw_internalerror. - (exceptions_throw_outofmemoryerror): Added. - - * src/vm/jit/tools/genoffsets.c (main): Don't print - sizestackframeinfo. - -2007-01-10 09:28 twisti - - * src/vm/jit/parisc/linux/Makefile.am (libmd_la_SOURCES): Commented. - -2007-01-08 23:49 twisti - - * configure.ac: Added GPL header. - -2007-01-08 23:48 twisti - - * src/vm/vm.c (vm_create): Fixed off-by-one bug. - -2007-01-08 16:56 ajordan - - * src/vm/jit/sparc64/codegen.c: Fixed argument passing via the stack - (for JIT methods). - -2007-01-07 20:56 ajordan - - * src/vm/jit/sparc64/codegen.c: Implemented INSTANCEOF and CHECKCAST - ICMDs - * src/vm/jit/sparc64/patcher.c: and their respective patchers. - - * src/vm/jit/sparc64/codegen.h: Added comparison instructions. - - * src/vm/jit/sparc64/linux/md-os.c: Implemented instruction cache - flush for linux. - * src/vm/jit/sparc64/md.c: Likewise. - -2007-01-06 14:29 twisti - - * configure.ac: Check for libdl. - -2007-01-06 14:27 twisti - - * src/cacao/cacao.c (main): Print function name in error output. - -2007-01-06 01:27 edwin - - * src/vm/jit/inline/inline.c: Many refactorings and comments. - -2007-01-04 21:48 twisti - - * src/mm/memory.c (mem_realloc): Use vm_abort. - -2007-01-03 22:39 edwin - - * src/vm/jit/verify/typecheck-typeinferer.c: New type inference pass. - * src/vm/jit/verify/typecheck-typeinferer.h: Likewise. - - * src/vm/jit/verify/typecheck-common.c: Moved code from typecheck.c - that can be shared between the variables-based verifier and the - type inference pass to this file. - * src/vm/jit/verify/typecheck-common.h: Likewise. - - * src/vm/jit/verify/typecheck-multianewarray.inc: Moved code for - type checking/infering MULTIANEWARRAY to this file. - - * src/vm/jit/verify/icmds.c: Adapted for generating the type - infererence pass. - * src/vm/jit/verify/typecheck-invoke.inc: Likewise. - * src/vm/jit/verify/typecheck-fields.inc: Likewise. - * src/vm/jit/verify/typecheck.c: Likewise. - * src/vm/jit/verify/Makefile.am: Likewise. - * src/vm/jit/verify/typecheck-builtins.inc: Likewise. - - * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Generated. - - * src/vm/jit/verify/typecheck-stackbased-gen.inc: Regenerated. - * src/vm/jit/verify/typecheck-variablesbased-gen.inc: Regenerated. - -2007-01-03 22:22 edwin - - * src/vm/jit/verify/icmds.c: Added comments. - - * src/vm/jit/verify/typecheck-stackbased-gen.inc, - src/vm/jit/verify/typecheck-variablesbased-gen.inc: Regenerated. - -2007-01-03 22:20 edwin - - * src/vm/method.c, src/vm/method.h (method_count_implementations): - New function. +2008-01-08 Christian Thalinger -2007-01-03 22:08 edwin + * src/mm/Makefile.am, src/mm/codememory.c, src/mm/codememory.h, + src/mm/dumpmemory.c, src/mm/dumpmemory.h, src/mm/memory.c, + src/mm/memory.h, src/vm/vm.c: + * src/mm/Makefile.am (libmm_la_SOURCES): Added codememory.[ch], + dumpmemory.[ch]. - * src/vm/jit/verify/generate.pl: Added options --typeinferer and - --debug. Prepared for generating the type inference pass. + * src/mm/codememory.c: New file. + * src/mm/codememory.h: Likewise. + * src/mm/dumpmemory.c: Likewise. + * src/mm/dumpmemory.h: Likewise. -2007-01-02 21:52 twisti + * src/mm/memory.c: Moved code and dump memory related stuff into + their respective files. + * src/mm/memory.h: Likewise. - * configure.ac (AC_CONFIG_FILES): Added - src/vm/jit/parisc/linux/Makefile. - * src/vm/jit/parisc/Makefile.am (SUBDIRS): Set to $(OS_DIR). - * src/vm/jit/parisc/linux/Makefile.am: New file. + * src/vm/vm.c (mm/codememory.h): Added. (vm_create): Call + codememory_init instead of memory_init. + [183c2868c78a] -2007-01-02 21:12 edwin + * m4/dump.m4: + * m4/dump.m4: Smaller changes. + [98cf8bd43450] - * src/vm/jit/emit-common.h (emit_replacement_stubs): Only declare - prototype if ENABLE_REPLACEMENT. +2008-01-05 Peter Molnar -2007-01-02 21:11 edwin + * src/vm/jit/jit.c, src/vm/jit/python.c: + * src/vm/jit/jit.c [ENABLE_PYTHON]: Changed name of hardcoded + script. + * src/vm/jit/python.c: Changed a lot. + [72c42e1989b2] - * src/vm/jit/mips/codegen.c (codegen): Use REPLACEMENT_ macros. + * src/vm/jit/s390/asmpart.S: + * src/vm/jit/s390/asmpart.S (asm_vm_call_method): Fixed stack + pointer corruption in case there are stack arguments and an + exception escapes. + [915392590cd3] -2007-01-02 20:50 edwin +2008-01-04 Stefan Ring - * src/vm/jit/jit.c (jit_invalidate_code): Require ENABLE_REPLACEMENT. + * src/vm/jit/i386/asmpart.S: + * src/vm/jit/i386/asmpart.S (asm_handle_exception): Correct offsets + for 16 byte aligned stack. + [0566e94f095d] -2007-01-02 20:40 edwin +2008-01-03 Christian Thalinger - * configure.ac: Added option --enable-replacement. - - * src/vm/jit/Makefile.am: Compile replace.c only for - ENABLE_REPLACEMENT. - - * src/vm/jit/replace.h: Define empty macros unless ENABLE_REPLACEMENT. - - * src/vm/jit/powerpc/emit.c: Enclosed replacement-specific code in - #if ENABLE_REPLACEMENT. - * src/vm/jit/powerpc/md.c: Likewise. - * src/vm/jit/powerpc/asmpart.S: Likewise. - * src/vm/jit/codegen-common.h: Likewise. - * src/vm/jit/sparc64/emit.c: Likewise. - * src/vm/jit/sparc64/md.c: Likewise. - * src/vm/jit/alpha/emit.c: Likewise. - * src/vm/jit/alpha/md.c: Likewise. - * src/vm/jit/alpha/asmpart.S: Likewise. - * src/vm/jit/code.c: Likewise. - * src/vm/jit/code.h: Likewise. - * src/vm/jit/tools/genoffsets.c: Likewise. - * src/vm/jit/show.c: Likewise. - * src/vm/jit/mips/emit.c: Likewise. - * src/vm/jit/mips/md.c: Likewise. + * src/vm/jit/alpha/asmpart.S, src/vm/jit/mips/asmpart.S: + * src/vm/jit/alpha/asmpart.S (asm_vm_call_method): Restore SP also + in exception case. * src/vm/jit/mips/asmpart.S: Likewise. - * src/vm/jit/powerpc64/md.c: Likewise. - * src/vm/jit/powerpc64/asmpart.S: Likewise. - * src/vm/jit/i386/emit.c: Likewise. - * src/vm/jit/i386/md.c: Likewise. - * src/vm/jit/i386/asmpart.S: Likewise. - * src/vm/jit/asmpart.h: Likewise. - * src/vm/jit/x86_64/emit.c: Likewise. - * src/vm/jit/x86_64/md.c: Likewise. - * src/vm/jit/x86_64/asmpart.S: Likewise. - * src/vm/jit/codegen-common.c: Likewise. - * src/vm/jit/jit.h: Likewise. - -2007-01-02 19:40 edwin + [17282b574f08] + + * src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Restore SP also + in exception case. + [846bcfaf0675] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Fixed warning. + (JVM_GetSystemPackage): Likewise. (JVM_NewMultiArray): Likewise. + [e7ab12ab545e] + + * src/native/vm/sun/jvm.c, src/vmcore/system.h: + * changed src/vmcore/system.h [HAVE_SYS_SOCKET_H] (sys/socket.h): + Added. [HAVE_SYS_TYPES_H] (sys/types.h): Likewise. (system_accept): + New function. (system_connect, system_fsync, system_ftruncate, + system_gethostname) (system_getsockname, system_getsockopt, + system_listen, system_lseek) (system_setsockopt, system_shutdown, + system_socket): Likewise. + + * changed src/native/vm/sun/jvm.c: Use new system_* functions. + [f6eb3507d28b] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c: Added return values to all functions. + [bc6940061b57] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (PRINTJVM): Removed. + (native/include/java_lang_Integer.h, + native/include/java_lang_Long.h, native/include/java_lang_Short.h, + native/include/java_lang_Byte.h, + native/include/java_lang_Character.h, + native/include/java_lang_Boolean.h, + native/include/java_lang_Float.h, + native/include/java_lang_Double.h): Likewise. + (JVM_RawMonitorCreate): Fixed typo. + [d296cb58df1c] + + * configure.ac, src/native/vm/sun/jvm.c, src/vmcore/system.h: + * configure.ac (AC_CHECK_FUNCS): Added read, write. + + * src/native/vm/sun/jvm.c (fcntl.h): Removed. (JVM_Open, JVM_Close, + JVM_Read, JVM_Write): Use system_* function. + + * src/vmcore/system.h [HAVE_FCNTL_H] (fcntl.h): Added. + (system_close, system_open, system_read, system_write): New + function. + [eb3186f90670] - * src/vm/jit/i386/codegen.c (codegen): Cleaned up to use REPLACEMENT_ - macros. + * src/native/vm/sun/jvm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_TraceJVMCallsVerbose): Added. + * src/vmcore/options.h: Likewise. -2007-01-02 16:20 twisti + * src/native/vm/sun/jvm.c (TRACEJVMCALLSVERBOSE): New macro. Use + TRACEJVMCALLS in all functions. + [7ac7dbdbce71] - * tests/regression/jctest.java: Print hex numbers too. - * tests/regression/jctest.output: Updated. diff --git a/ChangeLog-2007 b/ChangeLog-2007 new file mode 100644 index 000000000..4e10a8d4a --- /dev/null +++ b/ChangeLog-2007 @@ -0,0 +1,27561 @@ +2007-12-30 Christian Thalinger + + * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/ir/Makefile.am, + src/vm/jit/ir/bytecode.c, src/vm/jit/ir/bytecode.h, + src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/parse.c: + * configure.ac (AC_CONFIG_FILES): Added src/vm/jit/ir/Makefile. + + * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added ir. (SUBDIRS): + Likewise. (libjit_la_LIBADD): Added ir/libir.la. + + * src/vm/jit/ir/Makefile.am: New file. + * src/vm/jit/ir/bytecode.c: Likewise. + * src/vm/jit/ir/bytecode.h: Likewise. + + * src/vm/jit/jit.c (vm/jit/ir/bytecode.h): Added. + * src/vm/jit/jit.h (vm/jit/ir/bytecode.h): Likewise. Use new BC_* + constants in the ICMD-enum. + + * src/vm/jit/parse.c (vm/jit/ir/bytecode.h): Added. (parse): Use new + BC_* constants. + [d8fe2c3ba284] + +2007-12-29 Christian Thalinger + + * src/mm/memory.c, src/vmcore/system.h: + * src/vmcore/system.h (system_mprotect): New function. + [HAVE_SYS_MMAN_H] (sys/mman.h): Added. + + * src/mm/memory.c (vmcore/system.h): Added. (memory_mprotect): Use + system_mprotect. + [3c67f686355c] + +2007-12-28 Christian Thalinger + + * src/vm/jit/powerpc/disass.c: + * src/vm/jit/powerpc/disass.c: Fixed copyright header. (stdint.h): + Added. (vm/types.h): Removed. + [4b313b978a51] + +2007-12-20 Peter Molnar + + * configure.ac, m4/az_python.m4, src/cacao/Makefile.am, + src/vm/jit/Makefile.am, src/vm/jit/jit.c, src/vm/jit/python.c, + src/vm/jit/python.h, src/vm/vm.c: + * configure.ac: Added tests for python. + * m4/az_python.m4: New file. + * src/cacao/Makefile.am src/vm/jit/Makefile.am: [ENABLE_PYTHON] + Building python module and linking with python libs. + * src/vm/jit/jit.c [ENABLE_PYTHON] Calling some python function. + * src/vm/jit/python.c, src/vm/jit/python.h: New files. + * src/vm/vm.c [ENABLE_PYTHON] Initializing python module. + [a54c7d83c58a] + +2007-12-19 Christian Thalinger + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetManagement): Implemented (only + returning NULL). + [4206fab51a24] + + * src/native/native.c, src/native/native.h, src/native/vm/sun/jvm.c: + * src/native/native.c [ENABLE_LTDL] (native_library_close): New + function. + * src/native/native.h: Likewise. + + * src/native/vm/sun/jvm.c (JVM_UnloadLibrary): Implemented. + [59330b2047b9] + +2007-12-16 Stefan Ring + + * m4/debug.m4, m4/dump.m4: + * m4/debug.m4: Changed wording to make some defaults less confusing + (forgot those in previous commit). + * m4/dump.m4: Likewise. + [c06d42a7d559] + +2007-12-10 Christian Thalinger + + * src/native/vm/cldc1.1/java_lang_Throwable.c: + * src/native/vm/cldc1.1/java_lang_Throwable.c (vm/types.h): Removed. + (stdint.h): Added. (native/llni.h): Added. (printStackTrace): Use + new stacktrace functions. (fillInStackTrace): Likewise. + [ca9ac6d29332] + +2007-12-07 Stefan Ring + + * configure.ac, m4/jit.m4, m4/libjvm.m4, m4/ltdl.m4, m4/zlib.m4: + * configure.ac: Changed wording to make some defaults less + confusing. + * m4/jit.m4: Likewise. + * m4/libjvm.m4: Likewise. + * m4/ltdl.m4: Likewise. + * m4/zlib.m4: Likewise. + [9ee28b82c23e] + +2007-12-05 Christian Thalinger + + * src/native/vm/sun/jvm.c, src/vmcore/class.c, src/vmcore/class.h: + * src/native/vm/sun/jvm.c (JVM_GetEnclosingMethodInfo): Implemented. + * src/vmcore/class.c (class_get_enclosingmethod): New function. + * src/vmcore/class.h: Likewise. + [85ece229beb6] + +2007-11-24 Stefan Ring + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c: + * src/vm/jit/i386/codegen.c (codegen_emit, + codegen_emit_stub_native): Repaired 16 byte stack alignment. + + * src/vm/jit/i386/emit.c (emit_verbosecall_enter): Likewise. + [fb2f760c6d47] + +2007-11-21 Peter Molnar + + * doc/handbook/cacao.tex, doc/handbook/java.bib, + doc/handbook/s390.tex: + * doc/handbook/s390.tex: New file, docs for the s390 port. + * doc/handbook/cacao.tex, doc/handbook/java.bib: Added support for + s390.tex. + [1e17747d8ae4] + +2007-11-13 Stefan Ring + + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c: Synched with linux version. + Compiles but doesn't work yet. + [7a9776c7f769] + +2007-11-08 Christian Thalinger + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/stacktrace.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): + Unflag leafmethod. (codegen_generate_stub_native): Likewise. + + * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Added + leafmethod sanity check. + + * src/vm/jit/stacktrace.c (stacktrace_stackframeinfo_add): Use + code_is_leafmethod. + [91f7709c62de] + + * src/vm/jit/m68k/arch.h, src/vm/jit/powerpc64/arch.h, + src/vm/jit/s390/arch.h: + * src/vm/jit/m68k/arch.h: Removed commented HAS_4BYTE_STACKSLOT. + * src/vm/jit/powerpc64/arch.h: Likewise. + * src/vm/jit/s390/arch.h: Likewise. + [adc81880df67] + + * src/native/jni.c: + * src/native/jni.c (TRACEJNICALLS): Don't use a variadic macro but + pass the text to log in parentheses. This also fixes a bug when + only one argument is passed. + [1b6cd680d55a] + + * src/vm/jit/cfg.c, src/vm/jit/cfg.h: + * src/vm/jit/cfg.c: Fixed copyright header. (vm/types.h): Removed. + (vm/global.h): Added. + * src/vm/jit/cfg.h: Likewise. + [568ba9fdd84b] + +2007-11-07 Christian Thalinger + + * src/native/jni.c, src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/sun/jvm.c, src/threads/threads-common.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h: + * src/native/jni.c (_Jv_JNI_FindClass): Renamed + stacktrace_getCurrentClass to stacktrace_get_current_class. + + * src/native/vm/gnu/java_lang_VMThrowable.c (vm/jit/code.h): Added. + (vm/jit/linenumbertable.h): Likewise. (fillInStackTrace): Renamed + stacktrace_fillInStackTrace to stacktrace_get. (getStackTrace): + Rewritten for new stacktrace code. + + * src/native/vm/gnu/java_security_VMAccessController.c (vm/types.h): + Removed. (stdint.h): Added. (vm/builtin.h): Removed. (vm/global.h): + Added. (vmcore/class.h): Removed. (vmcore/options.h): Likewise. + (vmcore/utf8.h): Added. (getStack): Renamed stacktrace_getStack to + stacktrace_get_stack. + + * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Renamed + stacktrace_fillInStackTrace to stacktrace_get. + (JVM_GetStackTraceDepth): Rewritten for new stacktrace code and + added critical section. (JVM_GetStackTraceElement): Rewritten for + new stacktrace code. (JVM_LatestUserDefinedLoader): Implemented. + + * src/threads/threads-common.c (threads_thread_print_stacktrace): + Rewritten for new stacktrace code and added critical section. + + * src/vm/jit/stacktrace.c (stacktrace_entry_add): Removed. + (stacktrace_method_add): Likewise. (stacktrace_stackframeinfo_fill) + [!NDEBUG]: Added debug output. (stacktrace_stackframeinfo_next): + Likewise. (stacktrace_stackframeinfo_end_check): Likewise. + (stacktrace_create): Removed. (stacktrace_fillInStackTrace): + Removed. (stacktrace_depth): New function. (stacktrace_get): + Likewise. (stacktrace_first_nonnull_classloader): Likewise. + (stacktrace_getClassContext): Rewritten. + (stacktrace_getCurrentClass): Renamed to + stacktrace_get_current_class and rewritten. (stacktrace_getStack): + Renamed to stacktrace_get_stack and rewritten. + (stacktrace_print_trace_from_buffer): Renamed to stacktrace_print + and rewritten. (stacktrace_print_exception): Rewritten. + + * src/vm/jit/stacktrace.h (stacktracebuffer): Removed. + (stacktrace_entry): Likewise. (stacktrace_t): New structure. + (stacktrace_entry_t): Likewise. + [6ca3d885a0c3] + +2007-11-07 Michael Starzinger + + * src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/linux/md-os.c (md_replace_executionstate_read): + Implemented. (md_replace_executionstate_write): Likewise. + [be521f46a80f] + +2007-11-06 Christian Thalinger + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Use LLNI macro. + (JVM_GetStackTraceDepth): Likewise and added a comment about missing + critical sections. (JVM_GetStackTraceElement): Likewise. + [3d10f5692560] + +2007-11-05 Christian Thalinger + + * src/vm/jit/Makefile.am, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md.c, + src/vm/jit/alpha/md.h, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/md.c, src/vm/jit/arm/md.h, src/vm/jit/arm/patcher.c, + src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/i386/md.c, src/vm/jit/i386/md.h, src/vm/jit/jit.c, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/md.h, + src/vm/jit/m68k/patcher.c, src/vm/jit/md.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/md.h, src/vm/jit/mips/patcher.c, src/vm/jit/patcher- + common.c, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-asm.h, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc/md.h, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/powerpc64/md.h, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/replace.c, src/vm/jit/s390/md.c, src/vm/jit/s390/md.h, + src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/md.h, + src/vm/jit/sparc64/patcher.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/md.h: + * src/vm/jit/md.h: Removed. + * src/vm/jit/Makefile.am (noinst_HEADERS): Removed md.h. + + * src/vm/jit/asmpart.h (md_asm_codegen_get_pv_from_pc): Added + temporarily. + + * src/vm/jit/codegen-common.c (md.h): Added. (vm/jit/md.h): Removed. + (md_asm_codegen_get_pv_from_pc): Added temporarily. + + * src/vm/jit/codegen-common.h (md_codegen_get_pv_from_pc): Removed. + + * src/vm/jit/jit.c (stdint.h): Added. (md.h): Likewise. + + * src/vm/jit/patcher-common.c (md.h): Added. (vm/jit/md.h): Removed. + * src/vm/jit/replace.c: Likewise. + + * src/vm/jit/stacktrace.c (md.h): Added. + * src/vm/jit/stacktrace.h (md_stacktrace_get_returnaddress): Removed. + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md.c, src/vm/jit/alpha/md.h, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/md.c, src/vm/jit/arm/md.h, + src/vm/jit/arm/patcher.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/i386/md.c, src/vm/jit/i386/md.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/md.h, + src/vm/jit/m68k/patcher.c, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md.c, src/vm/jit/mips/md.h, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-asm.h, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc/md.h, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/powerpc64/md.h, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/md.h, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/md.h, src/vm/jit/sparc64/patcher.c, + src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/md.h (md_stacktrace_get_returnaddress): Made + inline function. (md_codegen_get_pv_from_pc): Likewise. + (md_cacheflush): Likewise. (md_icacheflush): Likewise. + (md_dcacheflush): Likewise. + [d81d9dc006c9] + + * src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/patcher.c: Fixed header. + [60fd68b8284c] + +2007-10-27 Peter Molnar + + * src/vm/jit/linenumbertable.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/md.c: + * src/vm/jit/linenumbertable.c (linenumbertable_create, + linenumbertable_linenumber_for_pc_intern) [__S390__]: Use 31 bits of + addresses as lookup keys. + * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): In case of + exception, use branch (not following) instruction as XPC. + * src/vm/jit/s390/md.c (md_signal_handler_sigill): Fixes to scenario + where JIT compiler fails. + [1a453b2390aa] + +2007-10-27 Christian Thalinger + + * src/vm/jit/code.c, src/vm/jit/code.h: + * src/vm/jit/code.c (vm/jit/methodheader.h): Removed. + (code_get_codeinfo_for_pv): Likewise. + + * src/vm/jit/code.h (assert.h): Added. (vm/jit/methodheader.h): + Likewise. (code_get_codeinfo_for_pv): New function. + [c3b950a4ea8b] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (vm/jit/code.h): Added. + (codegen_finish_native_call): Use code_get_codeinfo_for_pv. + [18a312bfca4b] + +2007-10-26 Christian Thalinger + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Removed codegen_init call, jit_init does + that. + [c5a79c1e4123] + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed + emit_patcher_traps call. + [704dd3fd06bd] + + * src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [4b58514e5dab] + + * src/vm/jit/i386/codegen.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [0d991b1b2a50] + + * src/vm/jit/alpha/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [5ed32ddf5dcb] + +2007-10-25 Christian Thalinger + + * src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (vm/jit/md.h): Removed (accidentally + commited). (md_signal_handler_sigsegv): Removed some code. + [279a6a754037] + + * src/vm/jit/mips/arch.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h, + src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily + added. + + * src/vm/jit/mips/asmpart.S (asm_call_jit_compiler): Removed. + * src/vm/jit/mips/codegen.c (codegen_emit_stub_compiler): Likewise. + + * src/vm/jit/mips/codegen.h (COMPILERSTUB_CODESIZE): Adapted size. + + * src/vm/jit/mips/emit.c (emit_trap_compiler): New function. + + * src/vm/jit/mips/linux/md-os.c (vm/exceptions.h): Added. + (md_signal_handler_sigsegv): Added compiler-by-signals code. + [3e911e512e84] + + * src/vm/jit/alpha/md.c: + * src/vm/jit/alpha/md.c (md_init): Smaller changes. + (md_codegen_get_pv_from_pc): Rewritten. + [8484b2af9cb0] + + * src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/md.h, src/vm/vm.c: + * src/vm/jit/jit.c (vm/jit/md.h): Removed. (jit_init): Call md_init. + + * src/vm/jit/jit.h [ENABLE_JIT] (md_init): Added. [ENABLE_INTRP] + (intrp_md_init): Likewise. + + * src/vm/jit/md.h [ENABLE_JIT] (md_init): Removed. [ENABLE_INTRP] + (intrp_md_init): Likewise. + + * src/vm/vm.c (vm/jit/md.h): Removed. (vm_create): Don't call + md_init. + [86d5f80749fa] + + * src/vm/primitive.c, src/vm/signal.c: + * src/vm/primitive.c (primitive_box): Fixed -O2 wanrings. + * src/vm/signal.c (signal_handle): Likewise. + [e7c1d45ac1cb] + + * src/native/include/Makefile.am: + * src/native/include/Makefile.am (COMMON_HEADER_FILES): Removed + java_util_HashMap and java_util_Map. (JAVASE_HEADER_FILES): Added + java_util_HashMap and java_util_Map. + [775bed4b55e1] + +2007-10-24 Peter Molnar + + * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c: + * src/vm/jit/s390/arch.h (JIT_COMPILER_VIA_SIGNAL): defined. + * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): removed. + * src/vm/jit/s390/codegen.c (codegen_emit_stub_compiler): removed. + * src/vm/jit/s390/emit.c (emit_trap_compiler): new function. + * src/vm/jit/s390/md.c (md_signal_handler_sigill): adapted for + compiler call via signal. + [c49cadfbd476] + +2007-10-24 Christian Thalinger + + * src/vm/exceptions.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.c (stacktrace_print_trace): Renamed to + stacktrace_print_exception. + * src/vm/jit/stacktrace.h: Likewise. + + * src/vm/exceptions.c (exceptions_handle_exception): Likewise. + [8bc0a90cd4f0] + + * src/native/vm/gnu/java_lang_VMThrowable.c: + * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Removed + unused resolving of the init method. + [d9b947897586] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_FillInStackTrace): Use TRACEJVMCALLS. + (JVM_GetStackTraceElement): Likewise. (JVM_IHashCode): Likewise. + [369b6cfa58a6] + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_stackframeinfo_fill): New + function. (stacktrace_stack_walk): Renamed to + stacktrace_stackframeinfo_next. + (stacktrace_stackframeinfo_end_check): New function. + (stacktrace_create): Use new stackframeinfo functions. + [111e59248e76] + + * src/native/include/Makefile.am: + * src/native/include/Makefile.am [ENABLE_ANNOTATIONS] + (JAVASE_HEADER_FILES): Removed java_util_Map.h. + [d5242eb43dbf] + +2007-10-23 Christian Thalinger + + * src/vmcore/linker.c: + * src/vmcore/linker.c (linker_preinit): Define + LINKER_ALIGNMENT_LONG_DOUBLE. (link_class_intern): Added a compile + time check for LINKER_ALIGNMENT_LONG_DOUBLE. + [c8300b439942] + + * src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h: + * src/native/vm/java_lang_Thread.c (interrupt): Removed. + * src/native/vm/java_lang_Thread.h: Likewise. + + * src/native/vm/gnu/java_lang_VMThread.c (interrupt): Use + threads_thread_interrupt. + [9921ebdac86b] + + * src/vm/jit/argument.c: + * src/vm/jit/argument.c (argument_vmarray_from_jvalue): Fixed + warning when compiling with Sun's jni.h. + [9e21a19e371f] + +2007-10-22 Gregor Kaufmann + + * configure.ac, m4/assertion.m4, + src/lib/gnu/java/lang/VMClassLoader.java, + src/native/include/Makefile.am, src/native/jni.h, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/sun/jvm.c, src/vm/Makefile.am, src/vm/assertion.c, + src/vm/assertion.h, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/linker.c, src/vmcore/loader.c: + * configure.ac (AC_CHECK_ENABLE_ASSERTION): Added + + * src/lib/gnu/java/lang/VMClassLoader.java + (packageAssertionStatus0): New function (classAssertionStatus0): + Likewise (defaultUserAssertionStatus): Likewise + (defaultAssertionStatus): Implemented (packageAssertionStatus): + Likewise (classAssertionStatus): Likewise + + * src/native/include/Makefile.am (COMMON_HEADER_FILES): Added + java_util_HashMap.h, java_util_Map.h + + * /src/native/jni.h + (_Jv_JavaVM->Java_java_lang_VMClassLoader_defaultAssertionStatus): + Removed + + * src/native/vm/gnu/java_lang_VMClassLoader.c + (native/include/java_util_HashMap.h): Added + (native/include/java_util_Map.h): Likewise + (native/include/java_lang_Boolean.h): Likewise (toolbox/list.h): + Likewise (vm/assertion.h): Likewise (methods): Added information for + defaultUserAssertionStatus, packageAssertionStatus0, + classAssertionStatus0 + (Java_java_lang_VMClassLoader_defaultAssertionStatus): Implemented + (Java_java_lang_VMClassLoader_defaultUserAssertionStatus): New + function (Java_java_lang_VMClassLoader_packageAssertionStatus0): + Likewise (Java_java_lang_VMClassLoader_classAssertionStatus0): + Likewise + + * src/native/vm/sun/jvm.c (toolbox/list.h): Added (vm/assertion.h): + Likewise (JVM_DesiredAssertionStatus): Implemented + (JVM_AssertionStatusDirectives): Now returns a usable + java.lang.AssertionStatusDirectives object + + * src/vm/Makefile.am (libvm_la_SOURCES): Added assertion.c, + assertion.h + + * src/vm/vm.c (vm/assertion.h): Added (OPT_EA, OPT_DA, OPT_ESA, + OPT_DSA): Now handled by assertion module + + * src/vmcore/class.c (class_java_util_HashMap): Added + + * src/vmcore/class.h (class_java_util_HashMap): Added + + * src/vmcore/linker.c (linker_init): Added linking of + class_java_util_HashMap + + * src/vmcore/loader.c (loader_init): Added loading of + class_java_util_HashMap + + * m4/assertion.m4: New file + + * src/vm/assertion.c: New file + + * src/vm/assertion.h: New file + [dfc311608cdb] + +2007-10-22 Christian Thalinger + + * src/vm/exceptions.c: + * src/vm/exceptions.c (unistd.h): Removed. + [c55e286b6453] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (vmcore/system.h): Added. (exceptions_init): + Use system_getpagesize and system_mmap_anonymous. + [87916090c0dd] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_handle_exception): Changed + signature to use void*. + [0787c3ba398d] + + * src/vm/jit/show.c: + * src/vm/jit/show.c (stdint.h): Added. (SHOW_INT_CONST): Fixed + compiler warnings. + [cf051a1d440f] + + * src/vm/jit/show.c: + * src/vm/jit/show.c (show_basicblock): Pass correct arguments to + linenumbertable_linenumber_for_pc. + [5a06e321fc5b] + +2007-10-22 Roland Lezuo + + * src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/patcher.c: + * changed src/vm/jit/m68k/emit.c (builtin_verbosecall_exit): Use + trace_java_call_exit. + + * changed src/vm/jit/m68k/linux/md-os.c (emit_trap): Fixed a bug. + + * changed src/vm/jit/m68k/patcher.c (md_signal_handler_sigill): Bug. + (PATCH_BACK_ORIGINAL_MCODE): Bug. + [6b8e93fdc96b] + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/system.c, src/vm/system.h: + * changed src/vm/jit/m68k/asmpart.S: Removed unused method header + entries. + + * changed src/vm/jit/m68k/codegen.c (codegen_emit): New + linenumbertables code. + [c76ff711720f] + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/md.c, + src/vm/signal.c, src/vm/signallocal.h, src/vmcore/linker.c: + * changed src/vm/jit/m68k/arch.h (JIT_COMPILER_VIA_SIGNAL): Added. + + * changed src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): + Removed. + + * changed src/vm/jit/m68k/codegen.c (codegen_emit): All + codegen_addpatchref replaced by patcher_add_patch_ref. + + (codegen_emit_stub_native): Use 8 byte stack slots. + + * changed src/vm/jit/m68k/emit.c (emit_verbosecall_enter): New + tracer. (emit_trap_compiler): Added. (emit_trap): Likewise. + + * changed src/vm/jit/m68k/linux/md-abi.c (md_param_alloc): Use 8 + byte stackslots. + + * changed src/vm/jit/m68k/linux/md-os.c (md_init_linux): Removed. + (md_signal_handler_sigsegv): Support for patchers and compiler via + signal added. + + * changed src/vm/jit/m68k/linux/md-os.h (md_init_linux): Removed. + + * changed src/vm/jit/m68k/md.c (md_init): Call to md_init_linux + removed. + + * changed src/vm/signal.c (signal_init): Register sigill for M68K. + + * changed src/vm/signallocal.h (md_signal_handler_sigill): Enabled + for M68K. + + * changed src/vmcore/linker.c (link_class_intern): Enable long 4 + byte alignment. + [a1dc04786217] + +2007-10-22 Christian Thalinger + + * src/threads/none/threads.h: + * src/threads/none/threads.h (stackframeinfo): Removed. + (_no_threads_stackframeinfo): Likewise. + [267fff05a72b] + + * src/vm/jit/show.c: + * src/vm/jit/show.c (show_basicblock): Forgot to use + linenumbertable_linenumber_for_pc. + [b24a7f31a843] + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_jitdata_new) [!ENABLE_THREADS]: Fixed + compilation. + [a8d348dbea79] + + * src/vm/jit/trace.c: + * src/vm/jit/trace.c (trace_java_call_enter): Removed unused + variable. + [4e2ba2f7e85d] + + * src/vm/jit/linenumbertable.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vmcore/statistics.c (count_linenumbertable): New variable. + (size_linenumbertable): Likewise. (statistics_print_memory_usage): + Adapted. + * src/vmcore/statistics.h: Likewise. + + * src/vm/jit/linenumbertable.c [ENABLE_STATISTICS] + (vmcore/options.h): Added [ENABLE_STATISTICS] (vmcore/statistics.h): + Likewise. (linenumbertable_create) [ENABLE_STATISTICS]: Added + statistics calculation. + [6727b0adf84a] + + * src/vm/jit/Makefile.am, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/codegen.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/code.h, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/dseg.c, + src/vm/jit/dseg.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/linenumbertable.c, + src/vm/jit/linenumbertable.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/methodheader.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c: + * src/vm/jit/linenumbertable.c: New file. + * src/vm/jit/linenumbertable.h: Likewise. + * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added + linenumbertable.[ch]. + + * src/vm/jit/code.h (vm/jit/linenumbertable.h): Added. (codeinfo): + Added linenumbertable. + + * src/vm/jit/codegen-common.c (vm/jit/linenumbertable.h): Added. + (codegen_setup): Create linenumbers list. (codegen_reset): Likewise. + (codegen_finish): Removed old linenumber-resolving code and call + linenumbertable_create instead. + + * src/vm/jit/codegen-common.h (codegendata): Removed + linenumberreferences, linenumbertablesizepos, + linenumbertablestartpos, linenumbertab, added linenumbers. + + * src/vm/jit/dseg.c (dseg_addlinenumbertablesize): Removed. + (dseg_addlinenumber): Likewise. (dseg_addlinenumber_inline_start): + Likewise. (dseg_addlinenumber_inline_end): Likewise. + (dseg_createlinenumbertable): Likewise. + (dseg_get_linenumber_from_pc_intern): Likewise. + (dseg_get_linenumber_from_pc): Likewise. + + * src/vm/jit/dseg.h: Likewise (linenumbertable_entry): Removed. + + * src/vm/jit/methodheader.h (LineNumberTableSize) + (LineNumberTableStart): Removed. + + * src/vm/jit/stacktrace.c (vm/jit/linenumbertable.h): Added. + (stacktrace_method_add): Renamed dseg_get_linenumber_from_pc to + linenumbertable_linenumber_for_pc. + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S, + src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S + (asm_vm_call_method): Removed obsolete method-header entries. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c + (vm/jit/linenumbertable.h): Added. (codegen_emit): Removed + dseg_addlinenumbertablesize call, use new linenumbertable functions, + removed dseg_createlinenumbertable. (codegen_emit_stub_native): + Removed obsolete method-header entries. + [d992be0f02d6] + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen_emit): Moved ICMD_POP and + ICMD_POP2 to ICMD_NOP case. + [093ed0794c43] + + * src/vm/array.c, src/vm/array.h: + * src/vm/array.c: Changed copyright. + * src/vm/array.h: Likewise. + [9b71c7a705e9] + +2007-10-20 Peter Molnar + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/disass.c, + src/vm/jit/s390/md.c: + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/disass.c, + src/vm/jit/s390/md.c: Fixed compile warnings. + [2a39b1f8c18d] + +2007-10-19 Michael Starzinger + + * src/vm/jit/x86_64/md-abi.c: + * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_saved): Fixed + severe typo. + [f3c3d927ba54] + +2007-10-19 Christian Thalinger + + * src/vm/properties.c: + * src/vm/properties.c (properties_set) [ENABLE_JAVASE && + WITH_CLASSPATH_GNU]: Fixed endorseddirs length. + [fba8f04fd91f] + +2007-10-18 Christian Thalinger + + * configure.ac, src/vmcore/system.c, src/vmcore/system.h: + * configure.ac (AC_CHECK_HEADERS): Added assert.h, errno.h. + (AC_CHECK_FUNCS): Added memcpy, memset, realloc. + + * src/vmcore/system.c (errno.h): Added. (stdint.h): Likewise. + (string.h): Likewise. (unistd.h): Likewise. (sys/mman.h): Likewise. + (system_mmap_anonymous): New function. + + * src/vmcore/system.h (stdint.h): Added. (stdlib.h): Likewise. + (string.h): Likewise. (unistd.h): Likewise. (system_calloc): New + function. (system_free): Likewise. (system_getpagesize): Likewise. + (system_malloc): Likewise. (system_memcpy): Likewise. + (system_memset): Likewise. (system_realloc): Likewise. + (system_mmap_anonymous): Likewise. + [cfa50d0a150e] + +2007-10-18 Michael Starzinger + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_dump): Ignore NEW threads + while dumping. + [65dc1b64848f] + +2007-10-18 Christian Thalinger + + * src/native/vm/gnu/java_lang_VMRuntime.c, src/native/vm/sun/jvm.c, + src/vm/Makefile.am, src/vm/system.c, src/vm/system.h, + src/vmcore/Makefile.am, src/vmcore/system.c, src/vmcore/system.h: + * src/vm/system.c: Removed. + * src/vm/system.h: Likewise. + * src/vm/Makefile.am (libvm_la_SOURCES): Removed system.[ch]. + + * src/vmcore/system.c: Added. + * src/vmcore/system.h: Likewise. + * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added system.[ch]. + + * src/native/vm/gnu/java_lang_VMRuntime.c (vm/system.h): Renamed to + vmcore/system.h. + * src/native/vm/sun/jvm.c: Likewise. + [28c2716784ad] + +2007-10-18 Michael Starzinger + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_handle_exception): Use LLNI macro + for unlocking synchronized methods during stack unwinding. + [6bd290291ff9] + + * src/vm/builtin.c, src/vm/builtin.h, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md- + os.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/builtin.h (builtin_retrieve_exception): Added prototype. + * src/vm/builtin.c (builtin_retrieve_exception): Implemented. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use + above builtin. + * src/vm/jit/i386/linux/md-os.c, + * src/vm/jit/powerpc/darwin/md-os.c, + * src/vm/jit/powerpc/linux/md-os.c, + * src/vm/jit/powerpc64/linux/md-os.c, + * src/vm/jit/x86_64/linux/md-os.c: Likewise. + [20827c0dbb8e] + +2007-10-18 Christian Thalinger + + * * Merged with 5c4efabb7787. + [4e1e7758b87a] + +2007-10-14 Christian Thalinger + + * src/vm/jit/dseg.h: + * src/vm/jit/dseg.h (dseg_exception_entry): Removed. + [35647a987380] + +2007-10-18 Michael Starzinger + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_create_replacement_points): Removed + bogus flag tampering of codeinfo. + [5c4efabb7787] + +2007-10-17 Roland Lezuo + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/patcher.c, src/vm/jit + /patcher-common.h, src/vmcore/linker.c: + * changed src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Removed. + * changed src/vm/jit/m68k/codegen.c (patcher.h): Include removed. + (emit_codegen): Replaced emit_patcher_stubs by emit_patcher_trap. + (codegen_emit_stub_native): Likewise. + + * changed src/vm/jit/m68k/emit.c (emit_patcher_stubs): Removed. + + * changed src/vm/jit/m68k/patcher.c + (patcher_resolve_classref_to_classinfo): Ported to new patcher + signature. + + * changed src/vm/jit/patcher-common.h: Enabled new patchers for + __M68K__. + + * changed src/vmcore/linker.c (linker_preinit): __M68K__ has 4 byte + long alignment. + [b1e5181f9e58] + +2007-10-17 Christian Thalinger + + * src/vm/properties.c: + * src/vm/properties.c (properties_set) [ENABLE_JAVASE && + WITH_CLASSPATH_SUN]: Set java.ext.dirs and java.ext.endorsed + properly. + [455021c09495] + +2007-10-14 Christian Thalinger + + * src/vm/jit/intrp/codegen.c: + * src/vm/jit/intrp/codegen.c (intrp_codegen): Ported methodheader + changes (IsSync, exception table). + [b19e41db4eca] + + * src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/sun/jvm.c, + src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_stack_walk): Changed return + type to bool, fill the temporary stackframe info with the values + from the stackframe info chain, if available. (stacktrace_create): + Don't include fillInStackTrace and init methods in the trace (as + HotSpot does). + + * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): Removed + fillInStackTrace and init checks. + + * src/native/vm/sun/jvm.c (JVM_GetStackTraceDepth): Use + TRACEJVMCALLS, check for NPE, check if backtrace is NULL. + [e2c1b1f539de] + + * src/vm/system.c, src/vm/system.h: + * src/vm/system.c: Changed copyright to CACAOVM. + * src/vm/system.h: Likewise. + [5db6925c6843] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Removed unused + variable ex. + [1a1bf81aba73] + + * src/vm/exceptions.c, src/vm/jit/Makefile.am, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/dseg.c, + src/vm/jit/exceptiontable.c, src/vm/jit/exceptiontable.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/methodheader.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c: + * src/vm/jit/exceptiontable.c: New file. + * src/vm/jit/exceptiontable.h: Likewise. + + * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added + exceptiontable.[ch]. + + * src/vm/exceptions.c (exceptions_handle_exception): Use new + exception table. + + * src/vm/jit/code.h (vm/jit/exceptiontable.h): Added. (codeinfo): + Added exceptiontable. + + * src/vm/jit/codegen-common.c (codegen_finish): Call + exceptiontable_create. + + * src/vm/jit/dseg.c (dseg_addlinenumbertablesize): Removed padding. + + * src/vm/jit/methodheader.h (ExTableSize, ExTableStart): Removed. + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S, + src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S + (asm_vm_call_method): Removed exception table stuff. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c + (codegen_emit): Likewise. + [33a0fdfa4121] + +2007-10-13 Christian Thalinger + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Use + jit_jitdata_new, this is more safe. (codegen_generate_stub_native): + Likewise. + [cd5057db2ddd] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_handle_exception): Handle the + asm_vm_call_method special case outside the loop checking for code + == NULL. + [63c8a32690c6] + + * src/vm/exceptions.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/i386/codegen.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/x86_64/codegen.c: + * src/vm/exceptions.c (exceptions_handle_exception): Use + code->synchronizedoffset directly for all architectures. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c + (codegen_emit): Set code->synchronizedoffset to rd->memuse * 8. + [16ddb27b00ef] + + * src/vm/exceptions.c, src/vm/jit/arm/codegen.c: + * src/vm/exceptions.c (exceptions_handle_exception) [__ARM__]: Added + #ifdef to the -8 path. + + * src/vm/jit/arm/codegen.c (codegen_emit): Added +1 to rd->memuse + for synchronizedoffset. + [303bfaab95ac] + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/md.c, src/vm/jit/dseg.c, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/methodheader.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/methodheader.h (IsSync): Removed. + + * src/vm/jit/dseg.c (dseg_addlinenumbertablesize): Removed one of + the paddings. + + * src/vm/jit/arm/md.c (md_codegen_get_pv_from_pc): Commented the + IsLeaf-check (this should be removed). + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S, + src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S + (asm_vm_call_method): Removed IsSync from method-header. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c + (codegen_emit): Removed IsSync-dummy entry. + [b9a4396d7410] + + * src/vm/exceptions.c, src/vm/jit/allocator/lsra.c, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/code.c, src/vm/jit/code.h, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/code.h (codeinfo): Added synchronizedoffset + (temporarily). + + * src/vm/exceptions.c (exceptions_handle_exception): Don't use + IsSync but code->synchronizedoffset. + + * src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/code.c: Use code_is_synchronized. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c: Use + code_is_synchronized and set code->synchronizedoffset. + [b2916cc961d6] + +2007-10-13 Michael Starzinger + + * src/vm/jit/Makefile.am: + * src/vm/jit/Makefile.am (noinst_HEADERS): Removed patcher.h + [29b2f2887b40] + + * src/threads/lock-common.h, src/threads/native/lock.c, src/vm/jit + /codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit/emit- + common.h, src/vm/jit/patcher-common.h, src/vm/jit/patcher.h: + * src/threads/lock-common.h (lock_get_initial_lock_word): Removed + prototype. + * src/threads/native/lock.c (lock_get_initial_lock_word): Removed. + + * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed. + * src/vm/jit/codegen-common.h (patchref) Removed structure. + (codegendata): Removed patchrefs. (codegen_add_patch_ref): Removed + prototype. + + * src/vm/jit/emit-common.h (emit_patcher_stubs): Removed prototype. + + * src/vm/jit/patcher-common.h: Removed ifdefs around patcher + function macros. + + * src/vm/jit/patcher.h: Removed file. + [1fe0cccd3f9e] + +2007-10-13 Christian Thalinger + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed + patcher stub. + [fb92cc407e44] + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [a85035fe3af1] + +2007-10-13 Michael Starzinger + + * src/vm/vm.c: + * src/vm/vm.c (vm_call_method_objectarray): Moved primitive_box into + the native world. + [daaf716e707f] + +2007-10-13 Christian Thalinger + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_stack_walk): Use the flags in + codeinfo to check for leaf-methods.< + [88cf8bfaa9ae] + + * src/native/jvmti/jvmti.c, src/vm/jit/replace.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.h (stackframeinfo_t): Removed method, added + code. + + * src/native/jvmti/jvmti.c, src/vm/jit/replace.c, + src/vm/jit/stacktrace.c: Likewise. + [5ac994bd30b6] + + * src/mm/cacao-gc/gc.c, src/native/jvmti/jvmti.c, + src/threads/native/threads.h, src/threads/threads-common.c, + src/vm/exceptions.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/codegen.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/replace.c, + src/vm/jit/replace.h, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/x86_64/codegen.c, src/vm/signal.c: + * src/vm/jit/stacktrace.h (stackframeinfo): Renamed to + stackframeinfo_t. + + * src/mm/cacao-gc/gc.c, src/native/jvmti/jvmti.c, + src/threads/native/threads.h, src/threads/threads-common.c, + src/vm/exceptions.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/codegen.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/replace.c, + src/vm/jit/replace.h, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/codegen.c, + src/vm/signal.c: Likewise. + [cff7e69a6d3e] + +2007-10-13 Michael Starzinger + + * src/threads/native/threads.c, src/threads/threads-common.c: + * src/threads/native/threads.c: Fixed some compiler warnings. + * src/threads/threads-common.c: Likewise. + [ddee8a127826] + + * tests/gc/LockRecords.java, tests/gc/Makefile, + tests/gc/NativeWeakRef.java, tests/gc/native.c: + * tests/gc/LockRecords.java: Added additional cleanup pass after + waiting. + * tests/gc/Makefile: Added NativeWeakRef testcase. + * tests/gc/NativeWeakRef.java: Added new testcase. + * tests/gc/native.c: Added native methods for NativeWeakRef testcase. + [eb85b412deb5] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, + src/threads/native/threads.c, src/threads/threads-common.h: + * src/mm/cacao-gc/gc.c (gc_global_lock): Removed obsolete global + lock. (gc_collect): Use GC mutex as global gc lock. + (gc_reference_register_intern, gc_reference_unregister_intern): Use + GC mutex to lock the reference lists. + + * src/mm/cacao-gc/gc.h (GC_MUTEX_LOCK, GC_MUTEX_UNLOCK): Added + macros. + + * src/threads/native/threads.c [ENABLE_GC_CACAO] (mutex_gc): Added + GC mutex. [ENABLE_GC_CACAO] (threads_mutex_gc_lock, + threads_mutex_gc_unlock): Implemented. + + * src/threads/threads-common.h [ENABLE_GC_CACAO] + (threads_mutex_gc_lock, threads_mutex_gc_unlock): Added prototypes. + [49eb4810d097] + + * src/vm/string.c: + * src/vm/string.c (javastring_toutf): Added check for empty strings. + [8c1dc97f1d6a] + +2007-10-13 Christian Thalinger + + * src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/ssa.c, src/vm/jit/parse.c, src/vm/jit/parse.h, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/replace.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/show.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/stack.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c: + * src/vm/jit/jit.h (jitdata): Removed isleafmethod. + + * src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/ssa.c, src/vm/jit/parse.c, src/vm/jit/parse.h, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/replace.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/show.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/stack.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c: Replaced jd->isleafmethod with + code_is_leafmethod. + [14e3f40c0673] + +2007-10-12 Michael Starzinger + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/mark.c, + src/mm/cacao-gc/rootset.c, src/mm/gc-common.h, + src/threads/native/lock.c: + * src/mm/cacao-gc/gc.c (gc_reflist_weak): Added list for weak + references. (gc_weakreference_register, + gc_weakreference_unregister): Implemented. (gc_collect): Added + preliminary call to lock_hashtable_cleanup. + + * src/mm/cacao-gc/gc.h (gc_reflist_weak): Added. + + * src/mm/cacao-gc/mark.c (mark_post): Added postprocessing function. + + * src/mm/cacao-gc/rootset.c (rootset_from_globals): Add weak + references. (reftype_names): Adapted to new enumeration. + + * src/mm/gc-common.h: Reference types are now enumerated. + (gc_weakreference_register, gc_weakreference_unregister): Added + prototypes. + + * src/threads/native/lock.c [ENABLE_GC_CACAO] + (lock_hashtable_cleanup): Added. (lock_record_new, lock_record_free) + [ENABLE_GC_CACAO]: Register and unregister references to lock object + with the GC (as weak references). + [fb2f8cea78af] + + * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/replace.c: + * src/vm/jit/code.c (code_get_codeinfo_for_pv): Added new function. + (code_find_codeinfo_for_pc): Use above function. + (code_get_methodinfo_for_pv): Likewise. + + * src/vm/jit/code.h (code_get_codeinfo_for_pv): Added prototype. + + * src/vm/jit/replace.c (replace_pop_activation_record): Use above + function. (replace_patch_method_pointer): Likewise. + (replace_pop_native_frame): Skip native stubs with new sfi + correctly. (replace_push_native_frame): Likewise. + [8a4d773ffcee] + + * * Merged with rev 974c36a815eb. + [7a0bc326262a] + + * src/cacaoh/headers.h, src/vm/string.c, src/vm/stringlocal.h: + * src/cacaoh/headers.h (literalstring_free): Removed obsolete + prototype. + + * src/vm/stringlocal.h (literalstring_u2, literalstring_free): + Likewise. + + * src/vm/string.c (heapstring_t): Added typedef. + (stringtable_update): Adapted for handles. (javastring_tochar): Code + cleanup. (javastring_toutf): Code cleanup. (literalstring_u2): Made + static and adapted for handles. (literalstring_free): Likewise. + (javastring_intern): Code cleanup and added comments. + [f52d56ea383b] + +2007-10-12 Christian Thalinger + + * configure.ac, src/native/vm/sun/jvm.c: + * configure.ac (AC_CHECK_FUNCS): Added ftruncate. + + * src/native/vm/sun/jvm.c (JVM_DefineClassWithSource): Handle when + name is NULL properly. (JVM_Lseek): Use TRACEJVMCALLS. + (JVM_SetLength): Implemented. + [974c36a815eb] + +2007-10-11 Christian Thalinger + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_detach_thread): Fixed CLDC + build. + [03703b6d4855] + +2007-10-09 Christian Thalinger + + * src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [8d1744a5a128] + + * * Merged with b23caa4282a5. + [8f008c01aec4] + + * tests/regression/Makefile.am: + * tests/regression/Makefile.am (SOURCE_FILES): Removed + extest_clinit.java. + [e9d81d59eea6] + + * * Merged with 3b6c3b177749. + [b23caa4282a5] + + * tests/regression/extest_clinit.java: + * Merged with 59ff46a9e236. + [d6f8c68e5b5f] + + * src/vm/jit/code.h: + * src/vm/jit/code.h (stdint.h): Added. (CODE_FLAG_SYNCHRONIZED): New + flag. (code_is_synchronized): New function. + (code_flag_synchronized): Likewise. (code_unflag_synchronized): + Likewise. + [eed84225afd7] + +2007-10-09 Roland Lezuo + + * tests/regression/extest_clinit.java: + Merged? + [3b6c3b177749] + + * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, src/vm/jit/patcher- + common.h: + (codegen_emit_stub_builtin): Removed. (codegen_emit_stub_native): + Ported to new interface. + + Ported to new interface, removed warnings. + (md_signal_handler_sigill): Likewise. + + (offset.h): Removed. + + (PATCH_BACK_ORIGINAL_MCODE): Added. (patcher_patch_back): Removed. + (patcher_patch_code): Added. (patcher_*): Use patchref_t instead of + void *sp everywhere. + [1f374ab123d9] + +2007-10-09 Michael Starzinger + + * src/vm/system.c: + * src/vm/system.c [__DARWIN__]: Fixed includes. + [3fc50ec37a00] + + * src/threads/native/lock.c, src/vm/finalizer.c, src/vmcore/options.c, + src/vmcore/options.h, tests/gc/LockRecords.java: + * src/vm/finalizer.c (finalizer_run): Fixed for handles and added + boehm-hack. (finalizer_thread, finalizer_notify): Added debug + output. + + * src/vmcore/options.c (opt_DebugFinalizer): Added debug switch. + * src/vmcore/options.h (opt_DebugFinalizer): Likewise. + + * src/threads/native/lock.c (lock_hashtable_remove): Also frees the + lock record. (lock_record_finalizer): Same as for finalizer_run + above. (lock_hashtable_get) [ENABLE_GC_BOEHM]: Fixed registration of + finalizer. + + * tests/gc/LockRecords.java: Added new testcase for lock records + cleanup. + [59ff46a9e236] + + * src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/vm/gnu/java_lang_reflect_Field.c + (cacao_get_field_address) Removed. (_field_access_check, + _field_get_type, _field_set_type): Added new functions. + (Java_java_lang_reflect_Field_XXX): Adapted to above changes and + thereby fixing it for handles. + + * src/native/vm/gnu/java_lang_reflect_Method.c: Just removed bogus + casting. + [2ba3107ae158] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Fixed compiler warning. + (_Jv_JNI_GetXXXField, _Jv_JNI_SetXXXField): Fixed for handles. + (_Jv_JNI_GetStaticObjectField, _Jv_JNI_SetStaticObjectField): + Likewise. (_Jv_JNI_SetObjectArrayElement): Adapted to new + builtin_canstore. (_Jv_JNI_NewGlobalRef): Made LLNI critical + sections smaller to avoid deadlock. + [5e87139265f5] + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_detach_thread): Fixed debug + output and compiler warning. + [06ec3216cf7d] + +2007-10-08 Christian Thalinger + + * src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h, + src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/powerpc/darwin/md- + os.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-os.c: + * src/vm/jit/powerpc/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily + added. + + * src/vm/jit/powerpc/asmpart.S (asm_call_jit_compiler): Removed. + (L_jit_asm_compile$stub): Likewise. + (L_exceptions_get_and_clear_exception$stub): Likewise. + + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_compiler): + Removed. + + * src/vm/jit/powerpc/codegen.h (COMPILERSTUB_CODESIZE): Adapted + size. + + * src/vm/jit/powerpc/darwin/md-asm.h (asm_call_jit_compiler): + Removed. (exceptions_get_and_clear_exception): Likewise. + (jit_asm_compile): Likewise. + + * src/vm/jit/powerpc/emit.c (emit_trap_compiler): New function. + + * src/vm/jit/powerpc/darwin/md-os.c (md_signal_handler_sigsegv): + Added compiler-by-signals code. + * src/vm/jit/powerpc/linux/md-os.c: Likewise. + [598cc626e0ee] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [e4601e449e45] + + * tests/regression/extest.2output, tests/regression/extest.java, + tests/regression/extest_clinit.java: + * tests/regression/extest.java: Updated a bit and added another + testcase. + * tests/regression/extest.2output: Updated. + * tests/regression/extest_clinit.java: Removed. + [a95b70c0cad9] + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_stackframeinfo_add) [!NDEBUG]: + Added DebugStackFrameInfo output. + (stacktrace_stackframeinfo_remove): Likewise. + (stacktrace_stack_walk): Bugfix when a patcher in a leaf-method + causes an exception. + [cdbe094feb17] + +2007-10-08 Michael Starzinger + + * src/vm/builtin.c, src/vm/builtin.h: + * src/vm/builtin.c: Major cleanup of code and commentes, to much to + list here, please accept my apologies for this short commit message. + Everything is Handles-ready now. + + * src/vm/builtin.h: Adapted signatures of builtins and added vim + boilerplate. + [da567e175ac6] + + * src/native/llni.h, src/threads/native/lock.h, src/vm/finalizer.c, + src/vm/jit/optimizing/recompile.c: + * src/native/llni.h (LLNI_QUICKWRAP): Added new macro. + + * src/threads/native/lock.h: Use above macro for internal locking. + (LOCK_WAIT_FOREVER, LOCK_NOTIFY): Added new macros. + + * src/vm/finalizer.c: Use internal locking macros throughout the + code. + * src/vm/jit/optimizing/recompile.c: Likewise. + [6d2627458877] + +2007-10-08 Christian Thalinger + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_create_replacement_points): Use new + code inline functions. (replace_pop_activation_record): Likewise. + (replace_push_activation_record): Likewise. + [cd0843508cff] + +2007-10-08 Michael Starzinger + + * src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_verbosecall_exit): Fixed comments. + [fbf41207864f] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Moved localref_table_init from + vm_createjvm. + [b924c9f5250c] + + * src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/gnu/java_lang_VMObject.c, src/native/vm/sun/jvm.c: + * src/native/vm/cldc1.1/java_lang_Object.c + (Java_java_lang_Object_notify): Adapted to new locking function + signatures. (Java_java_lang_Object_notifyAll): Likewise. + (Java_java_lang_Object_wait): Likewise. + + * src/native/vm/gnu/java_lang_VMObject.c + (Java_java_lang_VMObject_notify): Adapted to new locking function + signatures. (Java_java_lang_VMObject_notifyAll): Likewise. + (Java_java_lang_VMObject_wait): Likewise. + + * src/native/vm/sun/jvm.c (JVM_MonitorWait): Adapted to new locking + function signatures. (JVM_MonitorNotify): Likewise. + (JVM_MonitorNotifyAll): Likewise. + [6540073cf5a9] + +2007-10-08 Christian Thalinger + + * * Merged with ad640e81c710. + [890fd7ef3d91] + + * src/vm/jit/code.h, src/vm/jit/jit.c: + * src/vm/jit/code.h (codeinfo): Renamed codeflags to flags. + (CODE_IS_VALID, CODE_IS_INVALID, CODE_IS_LEAFMETHOD) + (CODE_SETFLAG_INVALID, CODE_SETFLAG_LEAFMETHOD): Removed. + (code_is_invalid, code_flag_invalid, code_unflag_invalid): New + inline function. (code_is_leafmethod, code_flag_leafmethod, + code_unflag_leafmethod): Likewise. + + * src/vm/jit/jit.c (jit_invalidate_code): Use new inline functions. + (jit_get_current_code): Likewise. + [79af8d668a13] + +2007-10-08 Michael Starzinger + + * src/cacaoh/dummy.c, src/threads/lock-common.h, + src/threads/native/lock.c: + * src/threads/lock-common.h: Changed signature of most locking + functions to take handles as arguments. + + * src/cacaoh/dummy.c: Adapted to new signatures. + + * src/threads/native/lock.c: Adapted to new signatures and added + LLNI critical sections. Will slow down locking for [ENABLE_HANDLES + && ENABLE_GC_CACAO]. (lock_lockword_get). Implemented. + (lock_lockword_set): Implemented. + [ad640e81c710] + + * src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.h: + * src/vm/jit/alpha/emit.c (emit_verbosecall_enter): Adapted to use + new tracer. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/alpha/md-abi.h (TRACE_ARGS_NUM): Removed. + [9e38d84cc222] + + * src/native/llni.c, src/native/llni.h: + * src/native/llni.h (LLNI_CRITICAL_START_THREAD): Added faster + macro. (LLNI_CRITICAL_END_THREAD): Likewise. + + * src/native/llni.c (llni_critical_start_thread): Implemented faster + function. (llni_critical_end_thread): Likewise. + [8cbaddb63fe3] + + * src/native/llni.h: + * src/native/llni.h (LLNI_field_set_ref): Fixed problem with NULL + references. + [c765f13d96ff] + +2007-10-07 Michael Starzinger + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_print_argument): Removed obsolete + function. (builtin_verbosecall_enter): Made a dummy function, use + new tracer. (builtin_verbosecall_exit): Likewise. + [88b3f386c93a] + + * src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-abi.h: + * src/vm/jit/powerpc64/emit.c (emit_verbosecall_enter): Adapted to + use new tracer. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/powerpc64/linux/md-abi.h (TRACE_ARGS_NUM): Removed. + [53674e362433] + + * src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.h: + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Adapted to use new + tracer. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/arm/md-abi.h (TRACE_ARGS_NUM): Removed. + [b630de06148c] + + * src/vm/jit/i386/emit.c, src/vm/jit/i386/md-abi.h: + * src/vm/jit/i386/emit.c (emit_verbosecall_enter): Adapted to use + new tracer. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/i386/md-abi.h (TRACE_ARGS_NUM): Removed. + [14c64bfb5899] + + * src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/powerpc/netbsd/md- + abi.h, src/vm/jit/s390/md-abi.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.h: + * src/vm/jit/x86_64/emit.c (emit_verbosecall_enter): Adapted to use + new tracer. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/x86_64/md-abi.h (TRACE_ARGS_NUM): Removed. + + * src/vm/jit/s390/md-abi.h (TRACE_ARGS_NUM): Removed, already uses + new tracer. + + * src/vm/jit/powerpc/darwin/md-abi.h (TRACE_ARGS_NUM): Likewise. + * src/vm/jit/powerpc/linux/md-abi.h (TRACE_ARGS_NUM): Likewise. + * src/vm/jit/powerpc/netbsd/md-abi.h (TRACE_ARGS_NUM): Likewise. + + * src/vm/jit/powerpc/emit.c (vm/builtin.h): Removed obsolete + include. + [274bd505a69b] + +2007-10-06 Michael Starzinger + + * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.h (threads_thread_get_object): Added. + (threads_thread_set_object): Added. + + * src/threads/threads-common.c: Use above functions throughout the + code. + + * src/threads/native/threads.c: Likewise. + + * src/native/vm/java_lang_Thread.c: Likewise. + (_Jv_java_lang_Thread_start): Fixed compiler warning. + (_Jv_java_lang_Thread_currentThread) [ENABLE_JAVASE]: Fixed for + handles. + [01272c7b7f7e] + + * src/native/jni.c, src/native/llni.h, src/vm/builtin.c: + * src/native/llni.h (LLNI_objectarray_element_set) Removed. + (LLNI_objectarray_element_get) Removed. + + * src/native/jni.c: Use array_objectarray functions throughout the + code. + * src/vm/builtin.c: Likewise. + [841ec0d005f8] + + * src/native/jni.c, src/native/localref.c: + * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Handle NULL references + correctly. + * src/native/localref.c (localref_add, localref_del): Added assertion. + [1b879af9b08e] + +2007-10-06 Christian Thalinger + + * src/vm/jit/jit.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/jit.c (jit_compile_intern): Use native_method_resolve + and check for exception. + + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Removed + patcher stuff. + [3fceed4e5c71] + + * src/native/native.c, src/native/native.h, src/vm/jit/patcher- + common.c: + * src/native/native.c (native_resolve_function): Renamed to + native_method_resolve. + * src/native/native.h: Likewise. + + * src/vm/jit/patcher-common.c (patcher_resolve_native_function): + Likewise. + [fd16ab5d87f1] + + * src/vm/jit/allocator/simplereg.c, src/vm/jit/jit.h, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/show.c, src/vm/jit/stack.c, src/vm/jit/verify/icmds.c: + * src/vm/jit/allocator/simplereg.c (ICMD_IF_FCMPxx, + ICMD_IF_FCMPL_xx): Removed. + * src/vm/jit/jit.h: Likewise. + * src/vm/jit/powerpc/codegen.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/show.c: Likewise. + * src/vm/jit/stack.c: Likewise. + * src/vm/jit/verify/icmds.c: Likewise. + [ba6af13783a8] + +2007-10-03 Michael Starzinger + + * src/cacaoh/dummy.c, src/vm/array.c, src/vm/jit/argument.c, + src/vm/jit/stacktrace.c: + * src/vm/array.c (array_objectarray_element_set): Fixed for handles. + (array_objectarray_element_get): Likewise. + + * src/cacaoh/dummy.c (array_objectarray_element_set): Do not use + LLNI_objectarray macros. (array_objectarray_element_get): Likewise. + + * src/vm/jit/argument.c: Use array_objectarray functions instead of + LLNI_objectarray. + + * src/vm/jit/stacktrace.c: Likewise. + [a4856d5695d8] + +2007-10-03 Christian Thalinger + + * src/vm/exceptions.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, src/vm/signal.c: + * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo): + Removed. (stacktrace_create_extern_stackframeinfo): Renamed to + stacktrace_stackframeinfo_add. (stacktrace_remove_stackframeinfo): + Renamed to stacktrace_stackframeinfo_remove. + * src/vm/jit/stacktrace.h: Likewise. + + * src/vm/exceptions.c, src/vm/jit/codegen-common.c, + src/vm/jit/jit.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/sparc64/patcher.c, src/vm/signal.c: Renamed functions as + above. + [25cf57814a88] + +2007-10-03 Michael Starzinger + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Fixed + stackframesize for (md->paramcount == 0 && md->returntype != + TYPE_VOID) cases. + [a7482a807f1e] + + * src/native/localref.c, src/vmcore/options.c, src/vmcore/options.h: + * src/native/localref.c: Improved debug output with + -XX:+DebugLocalReferences. (localref_check_uncleared): Implemented. + + * src/vmcore/options.c (opt_DebugLocalReferences): Added. + * src/vmcore/options.h (opt_DebugLocalReferences): Likewise. + [8e0d054d7791] + +2007-10-03 Christian Thalinger + + * src/vm/jit/codegen-common.c, src/vm/jit/stacktrace.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call): Renamed + currentsp to sp, removed javara, use + stacktrace_create_extern_stackframeinfo instead of + stacktrace_create_native_stackframeinfo. + (codegen_finish_native_call): Renamed currentsp to sp. + + * src/vm/jit/stacktrace.c (stdint.h): Added. + (stacktrace_create_extern_stackframe): Always get methodinfo and + store it in stackframeinfo. + (stacktrace_create_native_stackframeinfo): Removed. + (stacktrace_add_entry): Renamed to stacktrace_entry_add, made + inline. (stacktrace_add_method): Renamed to stacktrace_method_add, + made inline. (stacktrace_stack_walk): New function. + (stacktrace_create): Completely rewritten. + [e61772b09f4d] + +2007-10-03 Michael Starzinger + + * src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/java_lang_VMThrowable.c, src/native/vm/sun/jvm.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.c (stacktrace_fillInStackTrace): Returns a + bytearray. (stacktrace_print_trace): Does not use + stacktracecontainer anymore. + + * src/vm/jit/stacktrace.h (stacktracecontainer): Removed. + (stacktrace_fillInStackTrace): Adapted prototype to above change. + + * src/native/vm/cldc1.1/java_lang_Throwable.c: Adapted to above + changes. + * src/native/vm/gnu/java_lang_VMThrowable.c: Likewise. + * src/native/vm/sun/jvm.c: Likewise. + [d528eb08966a] + +2007-10-03 Christian Thalinger + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_compile_handle): Removed unused variable. + [417ec2928806] + + * src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/codegen.h, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c: + * src/vm/jit/powerpc64/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily + added. + + * src/vm/jit/powerpc64/asmpart.S (asm_call_jit_compiler): Removed. + * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_compiler): + Likewise. + + * src/vm/jit/powerpc64/codegen.h (COMPILERSTUB_CODESIZE): Adapted + size. + + * src/vm/jit/powerpc64/emit.c (emit_trap_compiler): New function. + + * src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv): + Added compiler-by-signals code. + [f7859b7aea62] + + * src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily + added. + + * src/vm/jit/alpha/asmpart.S (asm_call_jit_compiler): Removed. + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_compiler): Likewise. + + * src/vm/jit/alpha/codegen.h (COMPILERSTUB_CODESIZE): Adapted size. + + * src/vm/jit/alpha/emit.c (emit_trap_compiler): New function. + + * src/vm/jit/alpha/linux/md-os.c (vm/exceptions.h): Added. + (md_signal_handler_sigsegv): Added compiler-by-signals code. + [41acab1bbc53] + +2007-10-03 Michael Starzinger + + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/java_lang_Class.c, src/vm/vm.c: + * src/vm/vm.c: Use array_objectarray functions instead of + LLNI_objectarray. + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c: Likewise. + * src/native/vm/gnu/java_lang_VMThrowable.c: Likewise. + * src/native/vm/java_lang_Class.c: Likewise. + [dfd4ba44560b] + +2007-10-03 Christian Thalinger + + * src/vm/jit/m68k/md.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/s390/md.c: + * src/vm/jit/m68k/md.c (md_codegen_patch_branch): Removed. + * src/vm/jit/powerpc64/md.c: Likewise. + * src/vm/jit/s390/md.c: Likewise. + [74debb2c5834] + +2007-10-03 Michael Starzinger + + * src/vm/builtintable.inc: + * src/vm/builtintable.inc (builtintable_internal): Added preliminary + entry for builtin_multianewarray. + [4728593261f4] + + * src/mm/memory.h, src/native/localref.c, src/vmcore/class.c, + src/vmcore/field.c: + * src/mm/memory.h [ENABLE_GC_BOEHM]: GCNEW macros are available for + boehm only. + + * src/native/localref.c: Adapted ifdefs to above change. + + * src/vmcore/class.c: Adapted ifdefs to above change. (class_free): + Fixed, fields array get freed properly. + + * src/vmcore/field.c: Adapted ifdefs to above change. (field_free): + Implemented, field value memory gets freed. + [c33e0df79652] + +2007-10-01 Michael Starzinger + + * src/native/vm/reflect.c: + * src/native/vm/reflect.c [ENABLE_ANNOTATIONS]: Fixed includes. + [fc72108d11a3] + + * doc/Makefile.am, doc/handbook/Makefile.am: + * doc/Makefile.am: Fixed clean target to work properly. + * doc/handbook/Makefile.am: Likewise. + [a380a08533a3] + +2007-10-01 Christian Thalinger + + * src/vm/jit/i386/md.c: + * src/vm/jit/i386/md.c (vm/vm.h): Added. + (md_jit_method_patch_address): Rewritten to new proposed version. + [ec8797d1e6e4] + + * src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Set PV + and XPC correctly. + [6a09e13f9f75] + + * src/vm/jit/i386/emit.c: + * src/vm/jit/i386/emit.c (emit_verbosecall_enter): Use M_CLTD. + [c476a916878f] + + * src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/x86_64/linux/md-os.c, + src/vm/signal.c: + * src/vm/jit/jit.c (jit_compile_handle): Changed signature. + * src/vm/jit/jit.h: Likewise. + + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Set + PV and XPC correctly. + + * src/vm/signal.c (signal_handle): Get the methodinfo pointer and + pass it to jit_compile_handle. + [005f80121869] + + * src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/i386/emit.c, src/vm/jit/i386/emit.h, + src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/arch.h (JIT_COMPILER_VIA_SIGNAL): Temporarily + added. + + * src/vm/jit/i386/asmpart.S (asm_call_jit_compiler): Removed. + + * src/vm/jit/i386/codegen.c (codegen_emit_stub_compiler): Likewise. + + * src/vm/jit/i386/codegen.h (COMPILERSTUB_CODESIZE): Adapted size. + (M_BYTE1, M_BYTE2): New macros. (M_CLTD, M_RET, M_NOP): Use M_BYTE1. + (M_UD2): Use M_BYTE2. + + * src/vm/jit/i386/emit.c (emit_trap_compiler): New function. + (emit_trap): Use macros. (emit_cltd, emit_ret, emit_nop): Removed. + * src/vm/jit/i386/emit.h (emit_cltd, emit_ret, emit_nop): Likewise. + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Added + JIT compiler code. + [67dda8c1dc3d] + + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_trap_compiler): Fixed comment. + [a3ff74c5b8b0] + + * src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): + Removed debug output. + [79001d4e5c15] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_InitProperties): Fixed warning. + [f91157763a26] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (vm/system.h): Added. + (JVM_ActiveProcessorCount): Implemented. + [121bbaac9f59] + + * src/native/vm/gnu/java_lang_VMRuntime.c, src/vm/Makefile.am, + src/vm/system.c, src/vm/system.h: + * src/native/vm/gnu/java_lang_VMRuntime.c (vm/system.h): Added. + (availableProcessors): Use system_processors_online. + + * src/vm/Makefile.am (libvm_la_SOURCES): Added system.[ch]. + + * src/vm/system.c: New file. + * src/vm/system.h: Likewise. + [3215b4903941] + + * src/vm/jit/jit.c, src/vm/vm.c: + * src/vm/jit/jit.c (jit_compile_handle): Fixed warning. + * src/vm/vm.c (vm_abort_disassemble): Likewise. + [294eb7f45035] + + * src/native/vm/sun/jvm.c, src/vmcore/class.h: + * src/native/vm/sun/jvm.c (JVM_SetClassSigners): Implemented. + * src/vmcore/class.h (classinfo) [WITH_CLASSPATH_SUN]: Added signers. + [3fd887e6e438] + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_compile_intern) [WITH_CLASSPATH_SUN]: Don't + verify sub-classes of sun/reflect/MagicAccessorImpl. + [51ab7abeebc5] + +2007-09-29 Peter Molnar + + * src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/patcher.c + (patcher_checkcast_instanceof_interface): Fix error introduced in + changeset 7586. + [d5b33f1afb30] + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/codegen.h: Added functions for instruction parsing + and manipulation, added opcode defines. + * src/vm/jit/s390/codegen.c (codegen_emit): Replaced handcrafted + machined code patching by marco. + * src/vm/jit/s390/emit.c (emit_branch): Likewise. + * src/vm/jit/s390/md.c (md_jit_method_patch_address, + md_signal_handler_sigsegv, md_signal_handler_sigill, + md_signal_handler_sigfpe): Replaced handcrafted machine code parsing + and patching by calls to new functions. + * src/vm/jit/s390/patcher.c (patcher_invokeinterface, + patcher_invokevirtual, patcher_get_putfield): Likewise. + [4a9b0a8de18b] + +2007-09-29 Christian Thalinger + + * src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/emit-common.h, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/x86_64/arch.h, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c: + * src/vm/jit/asmpart.h [!JIT_COMPILER_VIA_SIGNAL] + (asm_call_jit_compiler): Added #ifdef. + + * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler) + [JIT_COMPILER_VIA_SIGNAL]: Added new code. + + * src/vm/jit/codegen-common.h [!JIT_COMPILER_VIA_SIGNAL] + (codegen_emit_stub_compiler): Added #ifdef. + + * src/vm/jit/emit-common.h (emit_trap_compiler): Added. + + * src/vm/jit/jit.c [!JIT_COMPILER_VIA_SIGNAL] (jit_asm_compile): + Added #ifdef. (jit_compile_handle): New function. + + * src/vm/jit/jit.h (vm/jit/stacktrace.h): Added. + [!JIT_COMPILER_VIA_SIGNAL] (jit_asm_compile): Added #ifdef. + + * src/vm/jit/x86_64/arch.h (JIT_COMPILER_VIA_SIGNAL): Added + temporarily. + + * src/vm/jit/x86_64/asmpart.S (asm_call_jit_compiler): Removed. + + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_compiler): Removed. + * src/vm/jit/x86_64/codegen.h (COMPILERSTUB_CODESIZE): Adapted. + + * src/vm/jit/x86_64/emit.c (emit_trap_compiler): New function. + + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Added + JIT compiler handling code. + * src/vm/signal.c (signal_handle): Likewise. + [1625eb0b4231] + + * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c, src/vm/jit/i386/md.c, + src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/m68k/md.c, + src/vm/jit/md.h, src/vm/jit/mips/md.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/replace.c, + src/vm/jit/s390/md.c, src/vm/jit/sparc64/md.c, + src/vm/jit/x86_64/md.c: + * src/vm/jit/md.h (md_get_method_patch_address): Removed. + * src/vm/jit/jit.h (md_jit_method_patch_address): Added. + + * src/vm/jit/jit.c (jit_asm_compile): Call + md_jit_method_patch_address with new signature. + + * src/vm/jit/replace.c (replace_patch_future_calls): Likewise. + + * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c, src/vm/jit/i386/md.c, + src/vm/jit/m68k/md.c, src/vm/jit/mips/md.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/s390/md.c, + src/vm/jit/sparc64/md.c, src/vm/jit/x86_64/md.c: Tried to fix the + includes. (md_get_method_patch_address): Renamed to + md_jit_method_patch_address and changed the signature. + [5a0a7be1c61c] + + * src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/codegen.h (M_MEM_GET_Opcode): New macro. + (M_MEM_GET_A): Renamed to M_MEM_GET_Ra to be consistent with + handbook. (M_MEM_GET_B): Renamed to M_MEM_GET_Rb. (M_MEM_GET_DISP): + Renamed to M_MEM_GET_Memory_disp. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use + new macro names. + [01d55d426e53] + + * src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c [ENABLE_DISASSEMBLER] (vm/jit/disass.h): Added. + (vm_abort_disassemble): New function. + * src/vm/vm.h (vm_abort_disassemble): Likewise. + [3666493a0162] + +2007-09-28 Christian Thalinger + + * src/native/jni.c: + * src/native/jni.c: Merged with 93595e0b477d. + [e03e02f0135d] + + * src/vm/jit/powerpc/asmpart.S: + * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Don't fake a + Java call, because we don't patch this call anymore (TODO: all other + architectures as well). + [93595e0b477d] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_GetEnv): Use jni_version_check. + [4194e7194975] + + * src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/darwin/md-asm.h: + * src/vm/jit/powerpc/asmpart.S + (L_stacktrace_create_extern_stackframeinfo$stub): Removed. + (L_stacktrace_remove_stackframeinfo$stub): Likewise. + (L_replace_me$stub): Likewise. + (L_replace_build_execution_state$stub): Likewise. + (L_replace_free_safestack$stub): Likewise. + + * src/vm/jit/powerpc/darwin/md-asm.h (jumptable_int, + jumptable_long): Removed. (asm_patcher_wrapper): Likewise. + (patcher_wrapper): Likewise. (replace_me): Likewise. + (replace_build_execution_state): Likewise. (replace_free_safestack): + Likewise. (stacktrace_create_extern_stackframeinfo): Likewise. + (stacktrace_remove_stackframeinfo): Likewise. + [1eea65d453be] + +2007-09-28 Michael Starzinger + + * src/mm/cacao-gc/rootset.c, src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_gc_into_native): Implemented. + * src/mm/cacao-gc/rootset.c (rootset_writeback): Use above function. + [f324661aa9c8] + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/mark.c: + * src/mm/cacao-gc/compact.c (compact_thread_classes): Removed + obsolete function. + * src/mm/cacao-gc/mark.c (mark_classes): Likewise. + [70164b6b8eac] + + * src/vm/jit/argument.c, src/vm/vm.c: + * src/vm/jit/argument.c: Added missing method comments. + (vm/exceptions.h): Removed include. + (argument_vmarray_from_objectarray): Do not throw exceptions, but + return NULL. + + * src/vm/vm.c (vm_call_method_objectarray): Adapted to above changes + and fixed nativeworld sections. + [d7d6dadc37c5] + +2007-09-28 Christian Thalinger + + * src/vm/jit/jit.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/jit.c (TRACECOMPILERCALLS): New macro. (jit_compile): + Use TRACECOMPILERCALLS. (jit_compile_intern): Removed some + DEBUG_JIT_COMPILEVERBOSE. + + * src/vmcore/options.c (opt_TraceCompilerCalls): New variable. + (options_xx): Handle opt_TraceCompilerCalls. + * src/vmcore/options.h (opt_TraceCompilerCalls): Added. + [0d92a96dd835] + +2007-09-27 Peter Molnar + + * src/vm/jit/s390/codegen.h: + * src/vm/jit/s390/codegen.h (N_BRANCH_MIN, N_BRANCH_MAX): Fix + (muliply by 2). + [b2999afc3d91] + +2007-09-27 Michael Starzinger + + * src/vm/jit/argument.c, src/vm/vm.c: + * src/vm/jit/argument.c (argument_vmarray_store_adr): Fixed for + handles. + * src/vm/vm.c (vm_call_array): Likewise. + [ced954316377] + + * src/native/jni.c, src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (vm_call_array): Made static, removed compiler call. + (vm_call_method_objectarray): Added. (vm_call_method_valist): Added + nativeworld macros, added compiler call. (vm_call_method_jvalue): + Likewise. + + * src/vm/vm.h (vm_call_array): Removed prototypes. + (vm_call_method_objectarray): Added prototype. + + * src/native/jni.c (_Jv_jni_invokeNative): Moved parts to vm.c for + clearness. + [a39b92f53b6a] + +2007-09-27 Christian Thalinger + + * src/vm/jit/code.c: + * src/vm/jit/code.c (code_get_methodinfo_for_pv): Return NULL if + code is NULL (asm_vm_call_method). + [351e6063c865] + +2007-09-27 Michael Starzinger + + * src/threads/threads-common.c: + * src/threads/threads-common.c (vmcore/options.h): Fixed include. + [d1a28f42c379] + +2007-09-27 Christian Thalinger + + * src/mm/memory.c, src/mm/memory.h: + * src/mm/memory.c (memory_mprotect): Fixed signature, manpage is + wrong about the signature of mprotect. + * src/mm/memory.h: Likewise. + [06d06747d56c] + +2007-09-27 Michael Starzinger + + * src/native/jni.c, src/vm/jit/argument.c, src/vm/jit/argument.h, + src/vm/vm.c, src/vm/vm.h: + * src/vm/jit/argument.c (argument_vmarray_store_int), + (argument_vmarray_store_lng), (argument_vmarray_store_flt), + (argument_vmarray_store_dbl), (argument_vmarray_store_adr), + (argument_vmarray_from_valist), (argument_vmarray_from_jvalue), + (argument_vmarray_from_objectarray): Moved from vm.c to this file. + + * src/vm/jit/argument.h (argument_vmarray_from_valist): Added + prototype. (argument_vmarray_from_jvalue): Likewise. + (argument_vmarray_from_objectarray): Likewise. + + * src/vm/vm.c: See above! + + * src/vm/vm.h (vm_array_from_objectarray): Removed prototype. + + * src/native/jni.c (_Jv_jni_invokeNative): Adapted to above changes. + [cac920852cf7] + +2007-09-27 Christian Thalinger + + * src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_is_primitive, class_is_anonymousclass, + class_is_array, class_is_interface, class_is_localclass, + class_is_memberclass, class_get_classloader, class_get_superclass): + Moved to class.h and made them static inline. + * src/vmcore/class.h: Likewise. + [42bf0070c359] + +2007-09-27 Michael Starzinger + + * src/threads/lock-common.h, src/toolbox/logging.c: + * src/threads/lock-common.h: Removed obsolete comment. + * src/toolbox/logging.c (threads/threads-common.h): Added include. + [efd01191b1ee] + + * src/mm/gc-common.h, src/native/jni.c, + src/native/vm/gnu/java_lang_VMSystem.c, src/threads/native/lock.c, + src/vmcore/loader.c: + * src/mm/gc-common.h (heap_hashcode): Added inline function. + + * src/native/jni.c: Use above function throughout file. + * src/native/vm/gnu/java_lang_VMSystem.c: Likewise. + * src/threads/native/lock.c: Likewise. + * src/vmcore/loader.c: Likewise. + [7e2d5fdf3012] + +2007-09-26 Christian Thalinger + + * src/threads/native/lock.c, src/vm/global.h: + * src/threads/native/lock.c: Renamed monitorPtr to lockword in the + whole file. (stdint.h): Added. + + * src/vm/global.h (stdint.h): Added. (java_object_t): Renamed + monitorPtr to lockword and changed the type to uintptr_t. + [853865d3df15] + +2007-09-26 Michael Starzinger + + * src/threads/native/threads.c, src/threads/threads-common.c: + * src/threads/native/threads.c (threads_init): Removed obsolete call + to register references with the GC. + + * src/threads/threads-common.c (threads_thread_new): Also register + reference to exception object with the GC. + [019681a01270] + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/threads/native/threads.c: Improved debug output. + * src/threads/threads-common.c: Likewise. + + * src/threads/threads-common.h (DEBUGTHREADS): Added. + + * src/vm/vm.c (vm_create): Removed -verbose:threads option. + + * src/vmcore/options.c (opt_DebugThreads): Added -XX:+DebugThreads + option. + * src/vmcore/options.h (opt_DebugThreads): Likewise. + [4ab0c57483a9] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/native/threads.h (native/include/java_lang_Thread.h): + Removed. (threadobject): The object pointer is of type java_object_t + now. + + * src/threads/native/threads.c: Adapted to above changes and use + LLNI macros. + + * src/threads/threads-common.h (threads_thread_start): Changed + signature to not use java_lang_Thread anymore. + + * src/threads/threads-common.c: Adapted to above changes and use + LLNI macros. (threads_preinit): Fixed corruption of + mainthread->flags. + [26e085a276e8] + +2007-09-25 Michael Starzinger + + * src/vm/jit/alpha/md.c, src/vm/jit/i386/md.c, src/vm/jit/mips/md.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/replace.c, src/vm/jit/sparc64/md.c, + src/vm/jit/x86_64/md.c: + * src/vm/jit/alpha/md.c (md_patch_replacement_point): Removed debug + code. + * src/vm/jit/i386/md.c: Likewise. + * src/vm/jit/mips/md.c: Likewise. + * src/vm/jit/powerpc/md.c: Likewise. + * src/vm/jit/powerpc64/md.c: Likewise. + * src/vm/jit/sparc64/md.c: Likewise. + * src/vm/jit/x86_64/md.c: Likewise. + + * src/vm/jit/replace.c (replace_activate_replacement_points) + [ENABLE_DISASSEMBLER]: Improved debug. + (replace_deactivate_replacement_points) [ENABLE_DISASSEMBLER]: + Likewise. + [778ca7b0994f] + + * src/native/localref.c, src/native/localref.h, src/vm/jit/argument.c, + src/vm/jit/argument.h, src/vm/jit/codegen-common.c: + * src/native/localref.c [ENABLE_HANDLES] (localref_native_exit): + Implemented. (localref_native_enter): Renamed from localref_fill. + + * src/native/localref.h (localref_native_exit): Added prototype. + (localref_native_enter): Renamed from localref_fill. + + * src/vm/jit/argument.c (argument_jitreturn_store): Implemented. + + * src/vm/jit/argument.h (argument_jitreturn_store): Added prototype. + + * src/vm/jit/codegen-common.c (codegen_start_native_call): Improved + comments and adapted to above changes. (codegen_finish_native_call): + Likewise. + [cb9745650425] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (llni_critical_start, llni_critical_end): + Removed aborts. + [e73922f2480c] + + * src/vm/signal.c: + * src/vm/signal.c (signal_handle): Wrap and unwrap references + correctly. + [a9c206e70c58] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_find_replacement_point_for_pc): + Fixed assertion. (replace_me_wrapper): Simplified search for + replacement point. + [fd550f06fd83] + + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/alpha/linux/md-os.c (md_replace_executionstate_write): + Fixed compiler warning. + + * src/vm/jit/x86_64/linux/md-os.c (md_replace_executionstate_read): + Implemented. (md_replace_executionstate_write): Likewise. + [437c4ce74de8] + + * src/vm/jit/i386/arch.h, src/vm/jit/x86_64/arch.h: + * src/vm/jit/i386/arch.h (REPLACEMENT_PATCH_SIZE): Adapted to new + trap mcode. + * src/vm/jit/x86_64/arch.h (REPLACEMENT_PATCH_SIZE): Likewise. + [cdd632019391] + + * src/vm/jit/codegen-common.c, src/vm/jit/replace.c, + src/vm/jit/replace.h, src/vm/signal.c: + * src/vm/jit/codegen-common.c (codegen_set_replacement_point): Add + NOPs if replacement testing mode is enabled. + + * src/vm/jit/replace.c (replace_me_wrapper): Finished + implementation. (replace_me): Major code cleanup. Removed safestack + stuff. (replace_build_execution_state): Likewise. + (replace_activate_replacement_points): Adapted changes from previous + rev. (replace_deactivate_replacement_points): Likewise. + (replace_alloc_safestack): Removed. (replace_free_safestack): + Removed. + + * src/vm/jit/replace.h (replace_safestack_t): Removed. + (md_replace_executionstate_read): Added prototype. + (md_replace_executionstate_write): Likewise. + + * src/vm/signal.c (signal_handle): Adapted to new + replace_me_wrapper. + [a97a8699e3f3] + + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md- + os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md-os.c, + src/vm/signal.c, src/vm/signallocal.h: + * src/vm/signallocal.h (signal_handle): Changed signature. + + * src/vm/signal.c (signal_handles): Create stackframeinfo here. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): + Adapted to new signature and removed stackframeinfo creation. + + * src/vm/jit/arm/linux/md-os.c: Likewise. + * src/vm/jit/i386/darwin/md-os.c: Likewise. + * src/vm/jit/i386/linux/md-os.c: Likewise. + * src/vm/jit/m68k/linux/md-os.c: Likewise. + * src/vm/jit/mips/irix/md-os.c: Likewise. + * src/vm/jit/mips/linux/md-os.c: Likewise. + * src/vm/jit/powerpc/darwin/md-os.c: Likewise. + * src/vm/jit/powerpc/linux/md-os.c: Likewise. + * src/vm/jit/powerpc64/linux/md-os.c: Likewise. + * src/vm/jit/s390/md.c: Likewise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + * src/vm/jit/sparc64/solaris/md-os.c: Likewise. + * src/vm/jit/x86_64/linux/md-os.c: Likewise. + [60c0ebbe4e43] + +2007-09-24 Michael Starzinger + + * src/vm/jit/i386/asmpart.S, src/vm/jit/i386/cygwin/md-asm.h, + src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/darwin/md-asm.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/i386/asmpart.S (asm_replacement_in, + asm_replacement_out): Removed obsolete functions. + + * src/vm/jit/i386/cygwin/md-asm.h: Likewise. + * src/vm/jit/i386/darwin/md-asm.h: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/powerpc/asmpart.S: Likewise. + * src/vm/jit/powerpc/darwin/md-asm.h: Likewise. + * src/vm/jit/powerpc64/asmpart.S: Likewise. + * src/vm/jit/s390/asmpart.S: Likewise. + * src/vm/jit/x86_64/asmpart.S: Likewise. + [b740aa39a6b3] + + * src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/emit.c (emit_replacement_stubs): Removed obsolete + function. + * src/vm/jit/i386/linux/md-os.c: Reordered functions in file. + [ee8508729ad0] + + * src/vm/jit/alpha/md.c, src/vm/jit/i386/md.c, src/vm/jit/mips/md.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/s390/md.c, src/vm/jit/sparc64/md.c, + src/vm/jit/x86_64/md.c: + * src/vm/jit/alpha/md.c (md_patch_replacement_point): Changed + signature. + + * src/vm/jit/i386/md.c: Likewise. + * src/vm/jit/mips/md.c: Likewise. + * src/vm/jit/powerpc/md.c: Likewise. + * src/vm/jit/powerpc64/md.c: Likewise. + * src/vm/jit/s390/md.c: Likewise. + * src/vm/jit/sparc64/md.c: Likewise. + * src/vm/jit/x86_64/md.c: Likewise. + [8607a4e4bab5] + + * src/vm/jit/jit.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_REPLACEMENT]: + Activate replacement points after code generation if testing option + is given. + + * src/vmcore/options.c [ENABLE_REPLACEMENT] (opt_TestReplacement): + Added replacement testing option. + + * src/vmcore/options.h [ENABLE_REPLACEMENT] (opt_TestReplacement): + Likewise. + [b4b8349d4df5] + +2007-09-23 Christian Thalinger + + * src/vmcore/statistics.c, src/vmcore/statistics.h: + * src/vmcore/statistics.c (size_stacksize): New variable. + (statistics_print_memory_usage): Print new variable. + * src/vmcore/statistics.h (size_stacksize): Added. + [9ffe8678ac20] + + * src/mm/memory.c, src/mm/memory.h: + * src/mm/memory.c (memory_mprotect): New function. + * src/mm/memory.h: Likewise. + [9b7a3aee74a4] + + * src/vm/signal.c: + * src/vm/signal.c (signal_handle): Fixed debug output. + [18e1db4a4dd2] + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_impl_thread_start): Print + error of return value (errno is not set by pthread functions). + [1735a75ea91f] + + * src/threads/threads-common.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/threads/threads-common.c (list_threads_free): Renamed to + list_free_thread_index. (thread_index_t): New type. + (threads_preinit): Initialize list_free_thread_index. + (threads_thread_new): Use list_free_thread_index + (threads_thread_free): Likewise and free the threadobject. + + * src/vmcore/statistics.c (stdint.h): Added. (size_thread_index_t): + Likewise. (statistics_print_memory_usage): Print + size_thread_index_t. + * src/vmcore/statistics.h (stdint.h): Added. (size_thread_index_t): + Likewise. + [7938bddb23fe] + +2007-09-22 Peter Molnar + + * src/vm/jit/codegen-common.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/md-abi.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call, + codegen_finish_native_call) [__S390__]: Adapted for s390. + * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Adapted for + builtin stubs. + * src/vm/jit/s390/md-abi.c (md_param_alloc_native): On stack arguments + are now already set off by the linkage area size. + [cdba3e10f470] + + * src/vm/jit/s390/emit.c: + * src/vm/jit/s390/emit.c (emit_verbosecall_enter, + emit_verbosecall_exit): Adapted to modified trace_java_call_enter + and trace_jave_call_exit. + [b0b2a8ecfb7e] + +2007-09-21 Christian Thalinger + + * configure.ac, src/native/vm/sun/jvm.c: + * configure.ac (AC_CHECK_FUNCS): Added getsockopt. + + * src/native/vm/sun/jvm.c (stdint.h): Added. (sys/types.h): + Likewise. (JVM_HoldsLock): Implemented. (JVM_SocketAvailable): + Likewise. (JVM_GetSockOpt): Likewise. (JVM_SetSockOpt) + [HAVE_SETSOCKOPT]: Added #ifdef. + [808f939f7d6c] + + * src/vm/jit/alpha/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Save and + restore floats as float so the trace functions can print them + correctly. + [08f6e263bf88] + + * src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_DebugStackTrace): Changed type to int. + (options_xx): Forgot to handle opt_DebugStackTrace. + * src/vmcore/options.h (opt_DebugStackTrace): Changed type to int. + [c6701c057d02] + +2007-09-20 Christian Thalinger + + * src/vmcore/class.c: + * src/vmcore/class.c [!NDEBUG] + (class_classref_or_classinfo_println): Added missing #ifdef. + [0216ea4e581b] + +2007-09-19 Christian Thalinger + + * src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vmcore/loader.c (loader_init): Don't use utf_java_lang_System. + + * src/vmcore/utf8.c (utf_java_lang_System): Removed. (utf8_init): + Likewise. + * src/vmcore/utf8.h: Likewise. + [3c0f5dc5dd40] + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/vm.c: + * src/vm/exceptions.c (exceptions_init): Changed return value to + void, removed class_java_lang_Throwable loading and linking. + (exceptions_throw_linkageerror): Removed unused variable o. + + * src/vm/exceptions.h (exceptions_init): Changed return value to + void. (new_exception_utfmessage): Removed. + + * src/vm/vm.c (vm_create): Don't check return value of + exceptions_init. + [c91eb1105dd8] + + * src/cacaoh/dummy.c, src/vm/exceptions.c, src/vm/initialize.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/cacaoh/dummy.c (vm_initializing): Added. + + * src/vm/exceptions.c (exceptions_init): Removed all class loads and + links. (exceptions_abort): New function. (exceptions_new_class): + Removed. (exceptions_throw_class): Likewise. + (exceptions_new_class_utf): Likewise. (exceptions_throw_class_utf): + Likewise. (exceptions_throw_classnotfoundexception): Use + exceptions_throw_utf_utf. (exceptions_throw_noclassdeffounderror): + Likewise. (exceptions_throw_linkageerror): Likewise. + (exceptions_throw_nosuchmethoderror): Likewise. + (exceptions_throw_unsatisfiedlinkerror: Likewise. + (exceptions_new_classcastexception): Use exceptions_new_utf_utf. + (exceptions_throw_outofmemoryerror): Use exceptions_throw_utf. + (exceptions_throw_nullpointerexception): Likewise. + (exceptions_new_nullpointerexception): Use exceptions_new_utf. + (exceptions_classnotfoundexception_to_noclassdeffounderror): Load + java/lang/ClassNotFoundException explicitly. + + * src/vm/initialize.c (initialize_class_intern): Load + java/lang/Exception explicitly. + + * src/vmcore/class.c (class_java_lang_Error): Removed. + (class_java_lang_LinkageError): Likewise. + (class_java_lang_NoClassDefFoundError): Likewise. + (class_java_lang_OutOfMemoryError): Likewise. + (class_java_lang_VirtualMachineError): Likewise. + (class_java_lang_Exception): Likewise. + (class_java_lang_ClassCastException): Likewise. + (class_java_lang_ClassNotFoundException): Likewise. + * src/vmcore/class.h: Likewise. + + * src/vmcore/linker.c (linker_init): Added class_java_lang_Throwable + and class_java_lang_VMThrowable. + + * src/vmcore/loader.c (loader_preinit): Don't check for error on + load_class_bootstrap, this is now done in the exception functions. + (loader_init): Likewise. (load_class_bootstrap): Removed + utf_java_lang_Object check. + + * src/vmcore/utf8.c (utf_java_lang_VMThrowable): Removed. + * src/vmcore/utf8.h: Likewise. + [f6e46b5abdac] + + * src/vm/properties.c, src/vm/properties.h: + * src/vm/properties.c (properties_dump): New function. + * src/vm/properties.h: Likewise. + [3fe0447f57b7] + +2007-09-18 Mathias Panzenboeck + + * doc/Makefile.am, doc/annotations.tex, doc/jsr.bib: + * doc/Makefile.am (dist_noinst_DATA): Added annotations.tex and + jsr.bib (annotations): New target which creates annotations.dvi + (clean): Clean the annotations.aux/.bbl/.dvi/... files. + + * doc/annotations.tex: New file. This is the documentation of the + annotations support implementation. + + * doc/jsr.bib: New file. Contains bibtex reference for JSR202. + [cbc7fae03947] + +2007-09-18 Christian Thalinger + + * src/cacaoh/cacaoh.c, src/vm/vm.c, src/vm/vm.h, src/vmcore/linker.c, + src/vmcore/options.c, src/vmcore/options.h: + * src/cacaoh/cacaoh.c (main): Removed linkverbose. + + * src/vm/vm.c (vm_printconfig): Made static. (vm_create): Call + vm_printconfig after the VM is initialized. + * src/vm/vm.h (vm_printconfig): Removed. + + * src/vmcore/linker.c (TRACELINKCLASS): New macro. + (link_class_intern): Use TRACELINKCLASS. + + * src/vmcore/options.c (linkverbose): Removed. (opt_TraceLinkClass): + Added. (options_xx): OPT_PrintConfig: Don't call vm_printconfig, + OPT_TraceLinkClass: Added. + * src/vmcore/options.h (linkverbose): Removed. (opt_TraceLinkClass): + Added. + [b6b94c056c1d] + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_handler) [!NDEBUG]: #ifdef'ed + debug output. + [c61a9af5c9b5] + + * src/threads/native/lock.c: + * src/threads/native/lock.c (lock_record_notify): Ignore already + signaled threads. + [2c60bb7d3a11] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetClassAccessFlags): Use + TRACEJVMCALLS. + [6d11c71489c9] + +2007-09-17 Christian Thalinger + + * configure.ac, src/native/vm/sun/jvm.c: + * configure.ac (AC_CHECK_FUNCS): Added fsync. + * src/native/vm/sun/jvm.c (JVM_Sync): Implemented. + [3bd273a402ef] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (staticFieldOffset): Return 0. + (staticFieldBase): Return the pointer to value. + [0e6f95db8141] + +2007-09-16 Christian Thalinger + + * src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/sun/jvm.c, src/vmcore/class.c, src/vmcore/class.h: + * src/native/vm/gnu/java_lang_VMClass.c (getModifiers): Use + class_get_modifiers. + * src/native/vm/sun/jvm.c (JVM_GetClassModifiers): Likewise. + + * src/native/vm/java_lang_Class.c (class_get_modifiers): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + + * src/vmcore/class.c (class_get_modifiers): New function. + * src/vmcore/class.h: Likewise. + [3438316160b3] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetStackAccessControlContext): Use + TRACEJVMCALLS. (JVM_AssertionStatusDirectives): Likewise. + [3fcf29d58b0f] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_IsThreadAlive): Use LLNI_equals. + [86b85d556a58] + + * * Merged with 5a268f292149. + [07d1c81692ee] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_NewWeakGlobalRef): Use TRACEJNICALLS. + (_Jv_JNI_DeleteWeakGlobalRef): Likewise. + [741ac9cf4529] + +2007-09-16 Mathias Panzenboeck + + * src/native/llni.h: + * src/native/llni.h (LLNI_equals): Added macro. + [5a268f292149] + +2007-09-16 Christian Thalinger + + * src/cacaoh/dummy.c, src/native/vm/sun/jvm.c, src/vm/Makefile.am, + src/vm/package.c, src/vm/package.h, src/vm/vm.c, + src/vmcore/loader.c, src/vmcore/options.c, src/vmcore/options.h: + * src/cacaoh/dummy.c (package_add): New function. + + * src/native/vm/sun/jvm.c (vm/package.h): Added. + (JVM_GetSystemPackage): Implemented. + + * src/vm/Makefile.am (libvm_la_SOURCES): Added package.[ch]. + + * src/vm/package.c: New file. + * src/vm/package.h: Likewise. + + * src/vm/vm.c (vm/package.h): Added. (vm_create): Call package_init. + + * src/vmcore/loader.c (vm/package.h): Added. (load_class_bootstrap): + Call package_add. + + * src/vmcore/options.c (opt_DebugPackage): Added. (options_xx): + Likewise. + * src/vmcore/options.h (opt_DebugPackage): Added. + [e91bea6d1b62] + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_detach_thread): Notify all + threads waiting on the Java thread-object. + [db035cf768f7] + + * src/mm/nogc.c: + * src/mm/nogc.c [HAVE_SYS_MMAN_H] (sys/mman.h): Added #ifdef. + (heap_alloc_uncollectable): Added additional parameter for + heap_alloc. (gc_init) [HAVE_MMAP]: Added #ifdef. + [231910498e40] + +2007-09-15 Christian Thalinger + + * src/vmcore/class.c: + * src/vmcore/class.c (class_set_packagename): Added '/' to the + internal package name. + [44ff14c3e9a6] + + * src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h, + src/native/vm/sun/jvm.c: + * src/native/vm/java_lang_Thread.c (isAlive): Removed. + * src/native/vm/java_lang_Thread.h: Likewise. + + * src/native/vm/cldc1.1/java_lang_Thread.c (stdint.h): Added. + (isAlive): Use threads_thread_is_alive. + + * src/native/vm/sun/jvm.c (JVM_IsThreadAlive): Likewise. + [bc11be8a1e7c] + +2007-09-14 Christian Thalinger + + * src/vm/vm.c: + * src/vm/vm.c (vm_array_from_objectarray): TYPE_LNG: Added missing + primitive_type_get_by_wrapperclass to get type (fixes JBoss). + [395643eaf5e9] + + * src/vm/vm.c: + * src/vm/vm.c (vm_array_from_objectarray): Removed illegal_arg label + and throw exception directly. This makes it easier for debugging + and newer compilers can optimize that. + [2b62829628e6] + + * src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.c (threads_thread_state_runnable): + Don't change the state if the current state is + THREAD_STATE_TERMINATED. (threads_thread_state_waiting): Likewise. + (threads_thread_state_timed_waiting): Likewise. + (threads_thread_is_alive): Smaller changes. + * src/threads/threads-common.h (threads_thread_is_alive): Likewise. + [1307fac97706] + + * src/threads/native/lock.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/threads/native/lock.c (LOCK_LOG): Removed. (DEBUGLOCKS): New + macro. (lock_record_new): Added DEBUGLOCKS. (lock_record_free): + Likewise. (lock_hashtable_grow): Likewise. (lock_hashtable_get): + Likewise. (lock_inflate): Likewise. (lock_monitor_enter): Likewise. + (lock_monitor_exit): Likewise. (lock_record_wait): Likewise. + (lock_record_notify): Likewise. + + * src/vmcore/options.c (opt_DebugLocks): Added. (options_xx): + Likewise. + * src/vmcore/options.h (opt_DebugLocks): Added. + [ab953b0c5ac1] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (getShort): New function. + (putLong): Likewise. (getDouble): Likewise. (putDouble): Likewise. + [d4deff26f6d1] + + * src/threads/native/lock.c, src/threads/native/lock.h: + * src/threads/native/lock.c (toolbox/list.h): Added. + (lock_record_t): Create waiters list. (lock_record_free): Free + waiters list. (lock_record_add_waiter): Use list. + (lock_record_remove_waiter): Likewise. (lock_record_notify): + Likewise. + + * src/threads/native/lock.h (toolbox/list.h): Added. + (lock_waiter_t): Removed next, added linkage. (lock_record_t): + Changed waiters to a list_t. + [ff6d5c593e7f] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c [WITH_CLASSPATH_SUN] + (native/include/java_lang_Object.h, + native/include/java_lang_String.h, + native/include/java_nio_ByteBuffer.h, + native/include/java_lang_ClassLoader.h): Added. + [d04eadb70c7f] + +2007-09-14 Mathias Panzenboeck + + * src/vmcore/annotation.c: + * src/vmcore/annotation.c: Fixed comment. + [3bc1be6d9164] + +2007-09-14 Christian Thalinger + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_wait_with_timeout): Renamed + thread to t. + [00f8940164ee] + +2007-09-13 Christian Thalinger + + * src/toolbox/list.c, src/toolbox/list.h: + * src/toolbox/list.c (list_free): New function. (list_lock): + Likewise. (list_unlock): Likewise. + * src/toolbox/list.h: Likewise. + [70f5642b3e83] + + * src/vm/exceptions.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vm/exceptions.c (exceptions_get_exception): Simplyfied. + (exceptions_set_exception): Added debug output. + (exceptions_clear_exception): Use explicit implementation and added + debug output. (exceptions_get_and_clear_exception): Only clear when + an exception is set. + + * src/vmcore/options.c (opt_DebugExceptions): Added. (options_xx): + Likewise. + * src/vmcore/options.h: Likewise. + [8456a18d18be] + +2007-09-13 Michael Starzinger + + * src/threads/native/lock.c: + * src/threads/native/lock.c (lock_record_wait): No longer throws and + exception but returns a boolean value indicating the interruption. + (lock_monitor_enter): Ignore interruption of lock_record_wait. + (lock_monitor_wait): Throw an exception if interrupted. + [3433056d2e6e] + +2007-09-13 Christian Thalinger + + * src/cacaoh/headers.h, src/threads/native/threads.h, + src/threads/none/threads.h, src/vm/exceptions.c, + src/vm/jit/inline/inline.c: + * src/cacaoh/headers.h (_exceptionptr): Removed. + + * src/threads/native/threads.h (exceptionptr): Removed. + * src/threads/none/threads.h: Likewise. + + * src/vm/exceptions.c (exceptions_get_exception): Rewritten to use + threadobject directly. (exceptions_set_exception): Likewise. + + * src/vm/jit/inline/inline.c (inline_transform) + [INLINE_VERIFY_RESULT]: Use exceptions_clear_exception. + [3bd4728a8c59] + +2007-09-13 Michael Starzinger + + * src/vm/jit/arm/asmpart.S: + * src/vm/jit/arm/asmpart.S (asm_exceptionptr): Removed. + [f6cbcaf2f4fc] + +2007-09-13 tbfg + + * src/vm/jit/powerpc64/asmpart.S: + Removed misleading comment about copying stuff from linux kernel. + This was true, but the implementation has been removed and the ppc + solution was adapted for pp64. + [5f48da04a418] + +2007-09-13 Michael Starzinger + + * src/vm/jit/show.c, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vm/vm.c (vm_create): Removed obsolete -se option. + * src/vm/jit/show.c (show_method): No longer show exception stubs. + * src/vmcore/options.c (opt_showexceptionstubs): Removed. + * src/vmcore/options.h (opt_showexceptionstubs): Likewise. + [76dad440809f] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h: + * src/vm/jit/arm/codegen.h: Major code cleanup and support VFP + instructions. + * src/vm/jit/arm/codegen.c: Adapted to above changes. + [979eaad7469b] + + * src/native/vm/sun/jvm.c, src/vm/jit/s390/codegen.c, src/vm/vm.c, + src/vmcore/options.c, src/vmcore/options.h: + * Merged with michi branch at rev 21fd42e049a3. + [4d32767b4c1d] + + * src/vm/builtintable.inc: + * src/vm/builtintable.inc (builtintable_internal): Create builtin + stubs for LOCK_monitor_enter and LOCK_monitor_exit, because they + throw exceptions. This will slow down Cacao, we need the fast-path + or inline those builtins! + [21fd42e049a3] + + * src/vm/jit/arm/asmpart.S: + * src/vm/jit/arm/asmpart.S (asm_cacheflush): Code cleanup and + support for EABI syscall calling conventions. + [4933a3684852] + +2007-09-12 Peter Molnar + + * src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Replaced N_* + code generation macros by alpha-like M_* ones. + [5a4e35cb3ab5] + +2007-09-12 Mathias Panzenboeck + + * src/vmcore/annotation.c: + * src/vmcore/annotation.c (LLNI_objectarray_copy): Removed macro. + (annotation_bytearrays_resize): Use MCOPY instead of my own macro. + [86a989abbdea] + +2007-09-12 Peter Molnar + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c: + * src/vm/jit/s390/asmpart.S src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c: Changed + JIT ABI on s390: R0 is now REG_ITMP3, R12 is a saved register, + REG_ITMPs are reordered, REG_ITMP1_XPTR is now REG_ITMP3_XPTR, + REG_ITMP2_XPC is now REG_ITMP1_XPC. + [75ecbbddead3] + +2007-09-12 Mathias Panzenboeck + + * src/native/llni.h, src/vmcore/annotation.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/field.c, src/vmcore/method.c: + * src/native/llni.h (LLNI_classinfo_field_get): New macro. + (LLNI_classinfo_field_set): Likewise. + + * src/vmcore/annotation.c (LLNI_objectarray_copy): New macro. This + macro will be replaced by a appropriate array_* function once such a + function exists. (annotation_bytearrays_resize): Use above macro and + improved variable naming. (annotation_bytearrays_insert): Changed + type of parameter 1 and return type and improved variable naming. + (annotation_load_attribute_body): Use LLNI_CRITICAL_START and + LLNI_CRITICAL_END. + (annotation_load_method_attribute_annotationdefault): Use + LLNI_classinfo_field_get and LLNI_classinfo_field_set macros. (annot + ation_load_method_attribute_runtimevisibleparameterannotations): + Likewise. + (annotation_load_method_attribute_runtimevisibleannotations): + Likewise. + (annotation_load_field_attribute_runtimevisibleannotations): + Likewise. + (annotation_load_class_attribute_runtimevisibleannotations): Use + LLNI_classinfo_field_set macro. + + * src/vmcore/class.c (class_get_annotations): Use + LLNI_classinfo_field_get macro. + + * src/vmcore/class.h (classinfo.annotations), + (classinfo.method_annotations), + (classinfo.method_parameterannotations), + (classinfo.method_annotationdefaults), + (classinfo.field_annotations): Changed type to java_object_t*. + + * src/vmcore/field.c (native/llni.h): Added include. + (field_get_annotations): Use LLNI_classinfo_field_get macro. + + * src/vmcore/method.c (method_get_annotations): Use + LLNI_classinfo_field_get macro. (method_get_parameterannotations): + Likewise. (method_get_annotationdefault): Likewise. + [b49f32206108] + +2007-09-12 Christian Thalinger + + * src/native/jni.c, src/native/jni.h, src/native/vm/sun/jvm.c, + src/vm/vm.c: + * src/native/jni.c (jni_version_check): New function. + * src/native/jni.h: Likewise. + + * src/native/vm/sun/jvm.c (JVM_IsSupportedJNIVersion): Use + jni_version_check. + * src/vm/vm.c (vm_create): Likewise. + [6b9b172f7f02] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Initialize properties list before + handling + -XX options handling. + [066d4ccbfde9] + + * src/vm/properties.c, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vm/properties.c (properties_add) [!NDEBUG]: Added debug + output. + + * src/vm/vm.c (opts): Removed XX. (vm_create): Call options_xx + almost as first function, so we can enable debugging from all stuff. + + * src/vmcore/options.c (opt_DebugProperties): New option. + (options_xx): Changed signature and parse all options in the array. + * src/vmcore/options.h (opt_DebugProperties): Added. (options_xx): + Changed signature. + [313f2b9ea69f] + +2007-09-12 Michael Starzinger + + * src/threads/native/threads.c, src/vm/jit/mips/codegen.c: + * src/threads/native/threads.c: Renamed bogus __MIPS__ ifdefs to + __IRIX__. + + * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_BUILTIN stub + calling. (codegen_emit_stub_native): Adapted to new signature and + builtin stubs. + [3e3a6881ae1e] + +2007-09-12 Peter Molnar + + * Merged 7484:52fc709fd248. + [ab50703b66af] + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390 + /md-asm.h: + * src/vm/jit/s390/codegen.c (codegen_emit_stub_native): Changed some + N_MOV to M_MOV. + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-asm.h, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md-abi.c: Reverted [7237:9a2ce00b716e] + where f4 and f6 were made callee saved. + [2842827952fd] + +2007-09-12 Michael Starzinger + + * src/vm/jit/patcher-common.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vm/jit/patcher-common.c: Improved comments. (patcher_handler): + Enabled use of -XX:+DebugPatcher. + + * src/vmcore/options.c (opt_DebugPatcher): Added and set by above + debug flag. + * src/vmcore/options.h (opt_DebugPatcher): Added. + [52fc709fd248] + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit + /codegen-common.c: + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_builtin): Removed. + (codegen_emit_stub_native): Adapted to new signature and builtins. + + * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Adapted to + new signature. + + * src/vm/jit/alpha/codegen.c (codegen_start_native_call) + [__ALPHA__]: Call tracing is done from here now. + (codegen_finish_native_call) [__ALPHA__]: Likewise. + [75ee30764b92] + +2007-09-12 Christian Thalinger + + * src/native/vm/Makefile.am, + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_util_concurrent_atomic_AtomicLong.h, + src/native/vm/sun/jvm.c: + * src/native/vm/Makefile.am + (JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES): Removed. + (libnativevm_la_SOURCES): Removed + JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES. + + * src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c + (native/vm/java_util_concurrent_atomic_AtomicLong.h): Removed. + (native/include/java_util_concurrent_atomic_AtomicLong.h): Added. + (methods): VMSupportsCS8: Use + Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8. + (Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8): New + function. + + * src/native/vm/sun/jvm.c + (native/vm/java_util_concurrent_atomic_AtomicLong.h): Removed. + (JVM_SupportsCX8): Just return 0 for now. + + * src/native/vm/java_util_concurrent_atomic_AtomicLong.c: Removed. + * src/native/vm/java_util_concurrent_atomic_AtomicLong.h: Likewise. + [063194d7fa99] + + * src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h: + * src/native/vm/cldc1.1/java_lang_Class.c (methods): isInterface: + Use Java_java_lang_Class_isInterface. (isInterface): New function. + + * src/native/vm/gnu/java_lang_VMClass.c (vm/exceptions.h): Added. + (vm/stringlocal.h): Likewise. (isInterface): Use class_is_interface. + (getInterfaces): Use class_get_interfaces. (getDeclaredClasses): Use + class_get_declaredclasses. (throwException): Use + exceptions_set_exception. (getClassSignature): Implemented directly. + + * src/native/vm/java_lang_Class.c (isInterface): Removed. + (getInterfaces): Likewise. (getDeclaredClasses): Likewise. + (throwException): Likewise. (getClassSignature): Likewise. + * src/native/vm/java_lang_Class.h: Likewise. + [7b4ace71939e] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetClassSignature): Use + LLNI_classinfo_unwrap and java_handle_t. + [e95f6b9676ca] + +2007-09-12 Mathias Panzenboeck + + * src/native/vm/java_lang_Class.c: + * Merged with default branch at rev 8806c9bebf3e. + [f30b107daf01] + + * src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/annotation/AnnotationType.java, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/vmcore/annotation.c, + src/vmcore/class.c, src/vmcore/field.c, src/vmcore/method.c, + src/vmcore/utf8.c, tests/regression/MinimalClassReflection.java: + * src/vmcore/annotation.c: Improved comments. + (annotation_bytearrays_resize), (annotation_bytearrays_insert), + (annotation_load_method_attribute_annotationdefault), (annotation_lo + ad_method_attribute_runtimevisibleparameterannotations), + (annotation_load_class_attribute_runtimevisibleannotations), + (annotation_load_method_attribute_runtimevisibleannotations), + (annotation_load_field_attribute_runtimevisibleannotations): + Restructured so that when it comes to the point when I have to use + LLNI macros for accessing the java objects I store in classinfo I + will have not much to do. + + * src/lib/gnu/java/lang/reflect/Constructor.java: Improved comments. + * src/lib/gnu/java/lang/reflect/Field.java: Likewise. + * src/lib/gnu/java/lang/reflect/Method.java: Likewise. + * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Likewise. + * src/lib/gnu/sun/reflect/annotation/AnnotationType.java: Likewise. + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Method.c: Likewise. + * src/native/vm/gnu/sun_reflect_ConstantPool.c: Likewise. + * src/native/vm/java_lang_Class.c: Likewise. + * src/native/vm/reflect.c: Likewise. + * src/native/vm/sun/jvm.c: Likewise. + * src/vmcore/class.c: Likewise. + * src/vmcore/field.c: Likewise. + * src/vmcore/method.c: Likewise. + * src/vmcore/utf8.c: Likewise. + * tests/regression/MinimalClassReflection.java: Likewise. + [ddc0f25c5fad] + +2007-09-11 Christian Thalinger + + * src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h: + * src/native/vm/gnu/java_lang_VMClass.c (getSuperclass): Use + class_get_superclass. + * src/native/vm/java_lang_Class.c (getSuperclass): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + [8806c9bebf3e] + + * src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h: + * src/native/vm/gnu/java_lang_VMClass.c (isPrimitive): Use + class_is_primitive. + * src/native/vm/java_lang_Class.c (isPrimitive): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + [11d19ca12473] + +2007-09-11 Michael Starzinger + + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/vm/properties.c: + * src/vm/properties.c (properties_set) [WITH_JRE_LAYOUT]: Fixed old + variable. + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c + (Java_gnu_classpath_VMSystemProperties_postInit) [WITH_JRE_LAYOUT]: + Likewise. + [bbd10f4c3e87] + + * src/vm/jit/arm/patcher.c, src/vm/jit/mips/codegen.c: + * Merged with default branch at rev bac772081960. + [26f4007804bb] + + * src/vm/jit/arm/disass.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/disass.h: + * src/vm/jit/disass.h (global.h): Added. + + * src/vm/jit/arm/disass.c (disass_pseudo_instr): Implemented. + (disassinstr): Call above function. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Better + debug output. + [c41a6282ec30] + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): + Stubs are generated for all archs now. [__POWERPC64__]: Enabled + tracing of native and builtin stubs. + + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Adapted + to new signature. + + * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): + Likewise. Removed tracing code. Rewrote argument register saving and + restoring code. + [808d21867a99] + +2007-09-11 Christian Thalinger + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit_stub_native): Fixed offset + of result saving and restoring (hint: MIPS32 has a PA). + [bac772081960] + +2007-09-11 Michael Starzinger + + * src/vm/jit/alpha/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit): ICMD_BUILTIN no longer + checks for exceptions, this is done by the stub itself. Stubs are + called now. + + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/s390/codegen.c: Likewise. + * src/vm/jit/sparc64/codegen.c: Likewise. + [cc75afc2b563] + +2007-09-11 Christian Thalinger + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Set + skipparams and pass it to codegen_emit_stub_native. + (codegen_generate_stub_native): Likewise. + * src/vm/jit/codegen-common.h (codegen_emit_stub_native): Changed + signature. + + * src/vm/jit/i386/codegen.c (codegen_emit): ICMD_BUILTIN: Removed + emit_exception_check. (codegen_emit_stub_builtin): Removed. + (codegen_emit_stub_native): Changed signature. + * src/vm/jit/x86_64/codegen.c: Likewise. + [001bda7ec5c8] + +2007-09-08 Christian Thalinger + + * src/vm/jit/x86_64/patcher.c: + * src/vm/jit/x86_64/patcher.c (patcher_resolve_native_function): + Removed. + [fc26f752bd43] + + * src/vm/jit/patcher-common.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/patcher.c, src/vm/signal.c, src/vm/signallocal.h: + * src/vm/jit/patcher-common.h: Added __X86_64__ ifdef. + * src/vm/signal.c (signal_init): Likewise. + * src/vm/signallocal.h: Likewise. + + * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed. + + * src/vm/jit/x86_64/codegen.c (vm/jit/patcher.h): Removed. (vm/jit + /patcher-common.h): Added. (codegen_emit): Implemented patchers-by- + signal and load data from data segment instead of moving inline. + (codegen_emit_stub_native): Likewise. (codegen_emit_stub_compiler): + Quick hack for ALD. + + * src/vm/jit/x86_64/codegen.h (PATCHER_CALL_SIZE): Changed to 2. + (PATCHER_NOPS): Likewise. (M_ALD): Handle RIP properly. + + * src/vm/jit/x86_64/emit.c (vm/jit/patcher-common.h): Added. + (emit_patcher_stubs): Removed. (emit_trap): Emit UD2. + + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigill): New + function. + + * src/vm/jit/x86_64/patcher.c (vm/jit/patcher.h): Removed. (vm/jit + /patcher-common.h): Added. (patcher_wrapper): Removed. + (PATCH_BACK_ORIGINAL_MCODE): New macro. (patcher_patch_code): New + function. (patcher_resolve_classref_to_classinfo): Likewise. + (patcher_resolve_classref_to_vftbl): Likewise. + (patcher_resolve_classref_to_flags): Likewise. + (patcher_resolve_native_function): Likewise. (patcher_aconst): + Removed. (patcher_builtin_multianewarray): Likewise. + (patcher_builtin_arraycheckcast): Likewise. + (patcher_checkcast_instanceof_flags): Likewise. + (patcher_checkcast_class): Likewise. (patcher_instanceof_class): + Likewise. (patcher_clinit): Likewise. (patcher_athrow_areturn): + Likewise. (patcher_resolve_native): Likewise. + [1aca46b07127] + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_add_patch_ref): Added + lastmcodeptr code. This can be removed when we don't use UD2 on i386 + and x86_64 anymore. + [3adba9571bcd] + +2007-09-08 Michael Starzinger + + * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/patcher.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Loads + function pointer from data segment now. + + * src/vm/jit/patcher-common.c (patcher_resolve_native_function): + Implemented generalized version. + + * src/vm/jit/alpha/patcher.c (patcher_resolve_native_function): + Removed obsolete function. + + * src/vm/jit/arm/patcher.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/mips/patcher.c: Likewise. + * src/vm/jit/powerpc/patcher.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + [18dcc80c8e9e] + + * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c: + * src/vm/jit/alpha/md.c (md_dcacheflush): Added dummy function. + * src/vm/jit/arm/md.c (md_dcacheflush): Does nothing now. + [4fff503b29e5] + +2007-09-07 Michael Starzinger + + * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/patcher.c, src/vm/jit/mips/patcher.c, src/vm/jit + /patcher-common.c, src/vm/jit/patcher-common.h, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/patcher.c: + * src/vm/jit/patcher-common.h (patcher_patch_code): Added prototype. + + * src/vm/jit/patcher-common.c (patcher_handle) [TRACE_PATCHER]: + Improved debug. (patcher_initialize_class): Implemented generalized + version. (patcher_resolve_class): Likewise. + + * src/vm/jit/alpha/patcher.c (patcher_patch_code): Implemented. + (patcher_initialize_class): Removed obsolete patcher function. + (patcher_resolve_class): Likewise. + + * src/vm/jit/arm/patcher.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/mips/patcher.c: Likewise. + * src/vm/jit/powerpc/patcher.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + [876be29c51a6] + +2007-09-08 Michael Starzinger + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c: + * src/vm/jit/arm/codegen.c: Removed patcher NOPs creation, this is + done by the patcher_add_patch_ref function itself. + + * src/vm/jit/arm/patcher.c: Patcher NOPs are triggered by the + opt_shownops flag. + [2855f422cb84] + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen_emit_stub_builtin): Removed. + (codegen_emit_stub_native): Deals with builtin stubs as well now. + [5914becb88b2] + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/codegen-common.c (codegen_disassemble_stub): Renamed + and works with builtin stubs as well. + (codegen_generate_stub_builtin) [ENABLE_DISASSEMBLER]: Stub gets + disassembled. (codegen_generate_stub_native) [ENABLE_DISASSEMBLER]: + Likewise. + + * src/vm/jit/codegen-common.h (codegen_disassemble_stub): Renamed. + + * src/vm/vm.c: Removed old option flag opt_shownativestub. + + * src/vmcore/options.h [ENABLE_DISASSEMBLER] (opt_DisassembleStubs): + Added. + + * src/vmcore/options.c [ENABLE_DISASSEMBLER] (opt_DisassembleStubs): + Added and included into options list. + [cc83f2f16624] + +2007-09-08 Christian Thalinger + + * src/vm/jit/x86_64/patcher.c: + * src/vm/jit/x86_64/patcher.c (patcher_resolve_native_function): + Removed. + [bbee0a3c3f34] + + * src/vm/jit/patcher-common.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/patcher.c, src/vm/signal.c, src/vm/signallocal.h: + * src/vm/jit/patcher-common.h: Added __X86_64__ ifdef. + * src/vm/signal.c (signal_init): Likewise. + * src/vm/signallocal.h: Likewise. + + * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed. + + * src/vm/jit/x86_64/codegen.c (vm/jit/patcher.h): Removed. (vm/jit + /patcher-common.h): Added. (codegen_emit): Implemented patchers-by- + signal and load data from data segment instead of moving inline. + (codegen_emit_stub_native): Likewise. (codegen_emit_stub_compiler): + Quick hack for ALD. + + * src/vm/jit/x86_64/codegen.h (PATCHER_CALL_SIZE): Changed to 2. + (PATCHER_NOPS): Likewise. (M_ALD): Handle RIP properly. + + * src/vm/jit/x86_64/emit.c (vm/jit/patcher-common.h): Added. + (emit_patcher_stubs): Removed. (emit_trap): Emit UD2. + + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigill): New + function. + + * src/vm/jit/x86_64/patcher.c (vm/jit/patcher.h): Removed. (vm/jit + /patcher-common.h): Added. (patcher_wrapper): Removed. + (PATCH_BACK_ORIGINAL_MCODE): New macro. (patcher_patch_code): New + function. (patcher_resolve_classref_to_classinfo): Likewise. + (patcher_resolve_classref_to_vftbl): Likewise. + (patcher_resolve_classref_to_flags): Likewise. + (patcher_resolve_native_function): Likewise. (patcher_aconst): + Removed. (patcher_builtin_multianewarray): Likewise. + (patcher_builtin_arraycheckcast): Likewise. + (patcher_checkcast_instanceof_flags): Likewise. + (patcher_checkcast_class): Likewise. (patcher_instanceof_class): + Likewise. (patcher_clinit): Likewise. (patcher_athrow_areturn): + Likewise. (patcher_resolve_native): Likewise. + [0d8acddb33d2] + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_add_patch_ref): Added + lastmcodeptr code. This can be removed when we don't use UD2 on i386 + and x86_64 anymore. + [5f39dedf7b68] + +2007-09-08 Michael Starzinger + + * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/patcher.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Loads + function pointer from data segment now. + + * src/vm/jit/patcher-common.c (patcher_resolve_native_function): + Implemented generalized version. + + * src/vm/jit/alpha/patcher.c (patcher_resolve_native_function): + Removed obsolete function. + + * src/vm/jit/arm/patcher.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/mips/patcher.c: Likewise. + * src/vm/jit/powerpc/patcher.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + [8586d2a077ef] + + * src/vm/jit/alpha/md.c, src/vm/jit/arm/md.c: + * src/vm/jit/alpha/md.c (md_dcacheflush): Added dummy function. + * src/vm/jit/arm/md.c (md_dcacheflush): Does nothing now. + [8b25e9581736] + + * * Merged with default branch at rev ce451bbfaf18. + [a001beae1804] + +2007-09-07 Michael Starzinger + + * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/patcher.c, src/vm/jit/mips/patcher.c, src/vm/jit + /patcher-common.c, src/vm/jit/patcher-common.h, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/patcher.c: + * src/vm/jit/patcher-common.h (patcher_patch_code): Added prototype. + + * src/vm/jit/patcher-common.c (patcher_handle) [TRACE_PATCHER]: + Improved debug. (patcher_initialize_class): Implemented generalized + version. (patcher_resolve_class): Likewise. + + * src/vm/jit/alpha/patcher.c (patcher_patch_code): Implemented. + (patcher_initialize_class): Removed obsolete patcher function. + (patcher_resolve_class): Likewise. + + * src/vm/jit/arm/patcher.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/mips/patcher.c: Likewise. + * src/vm/jit/powerpc/patcher.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + [5912fd263053] + + * src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/codegen.h, src/vm/jit/i386/emit.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/patcher.c, src/vm/jit + /patcher-common.h, src/vm/jit/patcher.h, src/vm/signal.c, + src/vm/signallocal.h: + * src/vm/jit/i386/emit.c (emit_patcher_stubs): Removed, this is + obsolete. (emit_trap): Fixed trap instruction. + + * src/vm/jit/i386/asmpart.S (asm_patcher_wrapper): Removed, this is + obsolete. + + * src/vm/jit/i386/patcher.c: Adapted patchers to new signature for + traps. (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/i386/codegen.h (PATCHER_CALL_SIZE, PATCHER_NOPS): + Adapted to new trap instruction. + + * src/vm/jit/i386/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions via traps + and adapted to above change. + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigill): + Implemented. + + * src/vm/jit/patcher-common.h [__I386__]: Enabled new patcher stuff. + + * src/vm/jit/patcher.h [__I386__]: Defined away old patcher stuff. + + * src/vm/signal.c (signal_init) [__I386__]: Install SIGILL handler + now. + + * src/vm/signallocal.h [__I386__] (md_signal_handler_sigill): + Enabled prototype. + [ce451bbfaf18] + +2007-09-07 Christian Thalinger + + * * Merged with 79e3a1932e59. + [7d26a3fdc72c] + + * src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/emit.h: + * src/vm/jit/x86_64/codegen.h (M_BYTE1, M_BYTE2): New macros. + (M_UD2): Added. (M_RET, M_NOP): Use M_BYTE1. + + * src/vm/jit/x86_64/emit.c (emit_ret): Removed. (emit_nop): + Likewise. + * src/vm/jit/x86_64/emit.h: Likewise. + [5f0db0ae7ffe] + +2007-09-07 Michael Starzinger + + * src/vmcore/loader.c: + * src/vmcore/loader.c (load_class_from_classloader): Fixed + classloader issues. + [79e3a1932e59] + + * src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/gnu/java_lang_VMSystem.c, src/native/vm/sun/jvm.c, + src/vm/builtin.c, src/vm/builtin.h: + * src/vm/builtin.c (builtin_arraycopy): Returns void instead of bool + now. + * src/vm/builtin.h (builtin_arraycopy): Adapted signature. + * src/native/vm/cldc1.1/java_lang_System.c: Removed obsolete void + case. + * src/native/vm/gnu/java_lang_VMSystem.c: Likewise. + * src/native/vm/sun/jvm.c: Likewise. + [e8610bdc4cd2] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Removed exception + check for ICMD_BUILTIN because of the new stubs. + (codegen_emit_stub_builtin): Removed obsolete function. + (codegen_emit_stub_native): Checks for m->flags instead of nmd being + NULL. + [29c6007441f2] + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h: + * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): Pass + bte->md to native stub emmiter. (codegen_stub_builtin_enter): + Removed. (codegen_stub_builtin_exit): Likewise. + + * src/vm/jit/codegen-common.h: Removed obsolete prototypes. + [c4eab7fd33e2] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Ported + for builtins. + [9fd540662096] + + * src/vm/jit/trace.c: + * src/vm/jit/trace.c (trace_java_call_enter): Can handle m->class == + NULL now and prints flag for builtin method stubs. + (trace_java_call_exit): Likewise. + [d5d8d96798c5] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Calls + same emmiter function as for native methods now. + (codegen_stub_builtin_enter): Disabled. (codegen_stub_builtin_exit): + Disabled. + [3a5220bcb252] + + * src/vmcore/method.h: + * src/vmcore/method.h (method_new_builtin): Fixed typo in function + prototype. + [63861f87010d] + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_create): Skip entries for + builtin stubs. + [4e96d91ad089] + + * src/vm/builtin.c, src/vm/builtin.h, src/vm/jit/codegen-common.c, + src/vm/jit/codegen-common.h, src/vmcore/method.c, + src/vmcore/method.h: + * src/vm/builtin.c (builtintable_init): Create methodinfos for + builtins. + * src/vm/builtin.h (builtintable_entry): Added forward typedef. + * src/vmcore/method.h (method_new_builtin): Added prototype. + * src/vmcore/method.c (method_new_builtin): Implemented. + * src/vm/jit/codegen-common.h (codegen_generate_stub_builtin): Changed + sig. + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Pass + methodinfo. + [e3cc0027dbdd] + +2007-09-06 Michael Starzinger + + * src/native/localref.c, src/vm/jit/Makefile.am, + src/vm/jit/argument.c, src/vm/jit/argument.h, src/vm/jit/trace.c: + * src/vm/jit/argument.c: Added file for argument array handling. + * src/vm/jit/argument.h: Likewise. + + * src/vm/jit/Makefile.am (libjit_la_SOURCES): Added above two files. + + * src/vm/jit/trace.c: Moved array handling functions to argument.c + and adapted to new name and signature. + + * src/native/localref.c (localref_fill): Likewise. + [f596a20dd95f] + + * src/vm/jit/powerpc64/patcher.c: + * src/vm/jit/powerpc64/patcher.c: Removed obsolete patcher + functions. + [90715e4cfa31] + + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c, src/vmcore/class.c, + src/vmcore/loader.c, src/vmcore/loader.h: + * src/vmcore/loader.h (classloader) [!ENABLE_HANDLES]: Classloader + is a object. + + * src/vmcore/loader.c (loader_hashtable_classloader_add) + [!ENABLE_HANDLES]: Return classloader object instead of entry. Added + some debug output. (loader_hashtable_classloader_find): Likewise. + + * src/vmcore/class.c (class_get_classloader): No need to + differentiate between handles or not-handles. + + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c: Fixed bogus + classloader usages. + [0b269fbf04cd] + +2007-09-06 Christian Thalinger + + * src/native/native.c: + * src/native/native.c (native_resolve_function): Use + class_get_classloader. + [7d5cec8c47b8] + +2007-09-06 Michael Starzinger + + * src/vm/jit/patcher-common.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/patcher.c: + * src/vm/jit/patcher-common.h: Removed obsolete patcher function + defines. + + * src/vm/jit/powerpc64/codegen.c: Used newer patcher function names. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/s390/codegen.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + [81ec7f8de378] + + * src/vm/jit/patcher-common.h, src/vm/jit/patcher.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/patcher.c: + * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed, this is + obsolete. (emit_trap): Fixed trap instruction: + + * src/vm/jit/powerpc64/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions and + adapted to above change. + + * src/vm/jit/powerpc64/patcher.c: Adapted patchers to new signature + for traps. (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/powerpc64/asmpart.S (asm_patcher_wrapper): Removed, + this is obsolete. + + * src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv): + Only calls the exception handling if exception object present. + + * src/vm/jit/patcher-common.h [__POWERPC64__]: Enabled new patcher + stuff. + + * src/vm/jit/patcher.h [__POWERPC64__]: Defined away old patcher + stuff. + [6bc2f1d20c58] + +2007-09-06 Christian Thalinger + + * * Merged with 269162803388. + [5cb77df28b85] + + * src/native/vm/Makefile.am, src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h, + src/native/vm/sun/jvm.c: + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed + java_lang_Object.[ch]. + + * src/native/vm/java_lang_Object.c: Removed. + * src/native/vm/java_lang_Object.h: Likewise. + + * src/native/vm/cldc1.1/java_lang_Object.c + (native/vm/java_lang_Object.h): Removed. (threads/lock-common.h): + Added. (vm/exceptions.h): Likewise. (getClass): Use LLNI_class_get. + (notify): Use lock_notify_object. (notifyAll): Use + lock_notify_all_object. (wait): Use lock_wait_for_object. + + * src/native/vm/gnu/java_lang_VMObject.c (native/llni.h): Added. + (native/vm/java_lang_Object.h): Removed. (threads/lock-common.h): + Added. (vm/builtin.h): Likewise. (vm/exceptions.h): Likewise. + (getClass): Use LLNI_class_get. (clone): Use builtin_clone. + (notify): Use lock_notify_object. (notifyAll): Use + lock_notify_all_object. (wait): Use lock_wait_for_object. + + * src/native/vm/sun/jvm.c (native/vm/java_lang_Object.h): Removed. + (JVM_MonitorWait): Use lock_wait_for_object. (JVM_MonitorNotify): + Use lock_notify_object. (JVM_MonitorNotifyAll): Use + lock_notify_all_object. + [483fb5dd71d3] + +2007-09-05 Michael Starzinger + + * src/vm/jit/codegen-common.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [__X86_64__]: Tracer for native methods is called from here now. + (codegen_finish_native_call) [__X86_64__]: Likewise. + + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Removed + verbosecall tracer. + [269162803388] + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit + /codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/x86_64/codegen.c: + * src/vm/jit/codegen-common.h (codegen_finish_native_call): Changes + signature. + + * src/vm/jit/codegen-common.c (codegen_finish_native_call): Takes + the same arguments as the enter pendant now. + + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Adapted to + new signature mentioned above. + + * src/vm/jit/arm/codegen.c: Likewise. + * src/vm/jit/i386/codegen.c: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise. + * src/vm/jit/powerpc/codegen.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/s390/codegen.c: Likewise. + * src/vm/jit/x86_64/codegen.c: Likewise. + [3d7dd4ddb484] + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/trace.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [__POWERPC__]: Tracer for native methods is called from here now. + + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_native): Removed + verbosecall enter tracer. + + * src/vm/jit/powerpc/emit.c (emit_verbosecall_enter, + emit_verbosecall_exit): Adapted to new tracer functions. + + * src/vm/jit/trace.c (_array_load_param, _array_load_return_value): + Optimized passing of register arguments. + [75c295a0dd45] + +2007-09-05 Mathias Panzenboeck + + * src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/sun/jvm.c, tests/regression/jasmin/runtest, + tests/regression/jasmin/show: + * changed src/native/vm/sun/jvm.c: Throw IllegalArgumentException in + all ConstantPool.get*At(int) methods as expected by OpenJDK. + + * changed src/native/vm/gnu/sun_reflect_ConstantPool.c: Likewise. + [614a7af9d894] + +2007-09-05 Christian Thalinger + + * src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h: + * src/native/vm/java_lang_Class.c (getDeclaringClass): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + * src/native/vm/gnu/java_lang_VMClass.c (getDeclaringClass): Use + class_get_declaringclass. + [4481d9c381a3] + + * src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h: + * src/native/vm/java_lang_Class.c (isArray): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + * src/native/vm/cldc1.1/java_lang_Class.c (isArray): New function. + * src/native/vm/gnu/java_lang_VMClass.c (isArray): Use class_is_array. + [10a1c5e2a7ca] + + * src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (mm/memory.h): Added. (md_init): Use + int instead of u1 for GCNEW. + [88289982f1fd] + + * configure.ac, m4/debug.m4, m4/dump.m4, m4/gc.m4, m4/intrp.m4: + * configure.ac (AC_CHECK_ENABLE_INTRP): Added. (AC_CHECK_ENABLE_GC): + Likewise. (AC_CHECK_ENABLE_DEBUG): Likewise. (AC_CHECK_ENABLE_DUMP): + Likewise. + + * m4/debug.m4: New file. + * m4/dump.m4: Likewise. + * m4/gc.m4: Likewise. + * m4/intrp.m4: Likewise. + [9af6482b9325] + + * configure.ac, src/cacao/Makefile.am, src/cacao/cacao.c, + src/native/Makefile.am, src/native/include/Makefile.am, + src/native/native.c, src/native/native.h, + src/native/tools/Makefile.am, src/native/tools/gennativetable.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/intrp/java.vmg, src/vm/jit/intrp/patcher.c, + src/vm/jit/jit.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.h, + src/vm/jit/patcher.h, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/patcher.c, src/vm/properties.c: + * configure.ac (static-classpath): Removed. + + * src/cacao/Makefile.am, src/native/Makefile.am, + src/native/include/Makefile.am: Removed WITH_STATIC_CLASSPATH if's. + + * src/native/native.c (native_findfunction): Removed. + * src/native/native.h (nativeref, nativecompref): Removed. + (native_findfunction): Removed. + + * src/native/tools/Makefile.am: Removed. + * src/native/tools/gennativetable.c: Likewise. + + * src/cacao/cacao.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/patcher.c, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/patcher.c, src/vm/jit/intrp/java.vmg, + src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, src/vm/jit + /patcher-common.h, src/vm/jit/patcher.h, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c, + src/vm/properties.c: Removed WITH_STATIC_CLASSPATH #ifdef's. + [d2a378158a66] + +2007-09-05 Michael Starzinger + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/rootset.c, src/vmcore/options.c, src/vmcore/options.h: + * src/mm/cacao-gc/rootset.c (rootset_readout): Ignore threads in + state new. + + * src/mm/cacao-gc/heap.c (heap_alloc): Wrap reference befor + returning. (heap_alloc_intern): Respect stress-test option flag. + + * src/mm/cacao-gc/gc.c (gc_collect): Respect debug rootset option + flag. + + * src/vmcore/options.h [ENABLE_GC_CACAO] (opt_GCDebugRootSet): + Added. [ENABLE_GC_CACAO] (opt_GCStress): Likewise. + + * src/vmcore/options.c (options_xx) [ENABLE_GC_CACAO]: Parse above + two options. + [2e34e2e4d7ce] + +2007-09-05 Christian Thalinger + + * * Merged with 3aaaa9f60c5d. + [ec7e530caf47] + + * * Merge with 405cda264bce. + [9216d09f671d] + + * * Not sure what this commit should do, let's see. + [8a98984ca196] + + * src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/sun/jvm.c, src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_get_classloader): New function. + * src/vmcore/class.h: Likewise. + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getClassLoader): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + * src/native/vm/gnu/java_lang_VMClass.c (getClassLoader): Use + class_get_classloader. + * src/native/vm/sun/jvm.c (JVM_GetClassLoader): Likewise. + [bd4ae591dcc4] + +2007-09-05 Michael Starzinger + + * src/native/llni.h, src/native/vm/reflect.c, src/vm/builtin.c: + * src/native/llni.h: Fixed a lot of compiler warnings. + + * src/native/vm/reflect.c (reflect_field_new): Removed bogus cast. + (reflect_method_new): Likewise. + + * src/vm/builtin.c (builtin_multianewarray): Fixed compiler warning. + [3aaaa9f60c5d] + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit + /codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call): Return + class argument for static native methods. + + * src/vm/jit/codegen-common.h (codegen_start_native_call): Adapted + signature. + + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Class + argument is no longer placed onto the data segment. + + * src/vm/jit/arm/codegen.c: Likewise. + * src/vm/jit/i386/codegen.c: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise. + * src/vm/jit/powerpc/codegen.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/s390/codegen.c: Likewise. + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/x86_64/codegen.c: Likewise. + [405cda264bce] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_handle_exception): Restructured to + create sfi. + [f23b2db94198] + + * src/mm/cacao-gc/heap.h, src/mm/cacao-gc/mark.c: + * src/mm/cacao-gc/heap.h (FOREACH_OBJECT_REF): Adapted to new + classinfo->super. + * src/mm/cacao-gc/mark.c (mark_recursive): Likewise. + [ba936361b758] + + * src/native/localref.c, src/native/localref.h, src/vm/jit/codegen- + common.c, src/vm/jit/trace.c: + * src/native/localref.h (localref_fill): Added prototype. + + * src/native/localref.c (localref_fill): Implemented. + (localref_frame_push): Fixed compiler warning. (_array_store_param): + Added temporarily. + + * src/vm/jit/trace.c (_array_load_param): Made non-static. + + * src/vm/jit/codegen-common.c (codegen_start_native_call): Call + localref_fill. + [ded869549a11] + +2007-09-05 Christian Thalinger + + * * Merged with 291b838f1aed. + [575e21f5ffea] + + * tests/regression/jasmin/runtest, tests/regression/jasmin/show: + * tests/regression/jasmin/runtest: Make executable. + * tests/regression/jasmin/show: Likewise. + [a1b55f522e0d] + +2007-09-04 Michael Starzinger + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): Added + workaround for builtins returning booleans to indicate exceptions. + + * src/vm/jit/powerpc/codegen.c (codegen_emit_stub_builtin): + Workaround was moved to codegen-common.c to keep codegens clean. + [291b838f1aed] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (Java_sun_misc_Unsafe_defineClass) + [ENABLE_HANDLES]: Fixed array access. + (Java_sun_misc_Unsafe_allocateInstance): Fixed compiler warning. + [37c9348bdbe5] + +2007-09-04 edwin + + * src/vmcore/class.c: + * src/vmcore/class.c (classref_or_classinfo_println): Fixed infinite + recursion. + [4c27eb92e935] + +2007-09-04 Michael Starzinger + + * tests/regression/native/testarguments.c: + * tests/regression/native/testarguments.c: Adapted testcase to + support handles. + [59b815ba5555] + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, src/vm/jit + /codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/x86_64/codegen.c: + * src/vm/jit/codegen-common.h (codegen_start_native_call): Changed + signature. + + * src/vm/jit/codegen-common.c (codegen_start_native_call): Takes + less arguments now and computes values by itself. This makes the + codegens simpler. + + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Adapted to + new signature mentioned above. + + * src/vm/jit/arm/codegen.c: Likewise. + * src/vm/jit/i386/codegen.c: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise. + * src/vm/jit/powerpc/codegen.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/s390/codegen.c: Likewise. + * src/vm/jit/x86_64/codegen.c: Likewise. + [109ce828d62d] + + * tests/gc/NativeGlobalRef.java, tests/gc/native.c: + * tests/gc/NativeGlobalRef.java: Improved testcase. + * tests/gc/native.c: Likewise. + [12a8c1a6d1a7] + +2007-09-03 Michael Starzinger + + * src/native/localref.c: + * src/native/localref.c (localref_del): Go through all local frames. + [c492fcf2fcc8] + + * src/vm/exceptions.c: + src/vm/exceptions.c (exceptions_asm_new_abstractmethoderror): Unwrap + exception. + [72076f9da934] + + * src/vm/jit/stacktrace.c, src/vmcore/options.c: + * src/vm/jit/stacktrace.c (stacktrace_create): Enabled + -XX:+DebugStackTrace. + * src/vmcore/options.c (options_XX): Added some descriptions. + [d2642fe48c1d] + +2007-09-03 Christian Thalinger + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_DetachCurrentThread): We need to pop all + frames before we can destroy the table. + [07bc83b81257] + + * src/vm/jit/trace.c: + * src/vm/jit/trace.c (native/jni.h): Added. + [6f33e8199e8a] + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/linux/md-os.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin) + [__POWERPC__]: Define added. + * src/vm/jit/powerpc/codegen.c (codegen_emit): ICMD_BUILTIN: Use stub. + (codegen_emit_stub_builtin): New function. + (codegen_emit_stub_native): Fixed some offsets. + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigusr1): New + function. + [60976e6fae32] + +2007-09-03 Mathias Panzenboeck + + * merge with branch e6c59621d39a + [3912aedf3af4] + + * tests/regression/TestAnnotations.java: + * tests/regression/TestAnnotations.java: Removed umlauts. + [55d7d537bef0] + +2007-09-03 Michael Starzinger + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_FindClassFromClassLoader): Add CL to + hashtable. (JVM_DefineClassWithSource): Likewise. + (JVM_FindLoadedClass): Likewise. + [e6c59621d39a] + + * src/vm/builtin.c, src/vm/exceptions.c, src/vm/jit/trace.c, + src/vm/jit/trace.h: + * src/vm/builtin.c (methodindent, callcount): Removed static + variables. (builtin_throw_exception): Use trace_exception_builtin. + (builtin_verbosecall_enter): Use thread-specific variables. + (builtin_verbosecall_exit): Likewise. + + * src/vm/exceptions.c (exceptions_handle_exception): Fixed + methodindent for java call traces. + + * src/vm/jit/trace.c: Added comments and minor cleanups. + (trace_exception_builtin): Implemented (moved from builtin.c). + + * src/vm/jit/trace.h (trace_exception_builtin): Added prototype. + [9e9d2b28cfea] + + * src/vm/jit/powerpc/emit.c: + * src/vm/jit/powerpc/emit.c (emit_verbosecall_exit) [__DARWIN__]: + Fixed passing of methodinfo argument. + [a64cbc7fdf34] + + * src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc, + src/vm/exceptions.h, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/emit-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/stack.c, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, src/vm/signal.c: + * src/vm/builtin.c (builtin_canstore): Throw an ArrayStoreException. + (builtin_fast_canstore): Do not throw any exceptions. + + * src/vm/builtin.h (BUILTIN_canstore): Removed. + + * src/vm/builtintable.inc: Adapted entry for builtin_canstore. + + * src/vm/exceptions.h (EXCEPTION_HARDWARE_ARRAYSTORE): Added. + + * src/vm/signal.c (signal_handle): Added case for + ArrayStoreException. + + * src/vm/jit/emit-common.h (emit_arraystore_check): Added prototype. + + * src/vm/jit/stack.c (stack_analyse): ICMD_AASTORE now uses fast + canstore. + + * src/vm/jit/alpha/codegen.c (codegen_emit): ICMD_AASTORE uses fast + canstore. + * src/vm/jit/alpha/emit.c (emit_arraystore_check): Implemented. + + * src/vm/jit/arm/codegen.c: Likewise. + * src/vm/jit/arm/emit.c: Likewise. + * src/vm/jit/i386/codegen.c: Likewise. + * src/vm/jit/i386/emit.c: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/m68k/emit.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise. + * src/vm/jit/mips/emit.c: Likewise. + * src/vm/jit/powerpc/codegen.c: Likewise. + * src/vm/jit/powerpc/emit.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/powerpc64/emit.c: Likewise. + * src/vm/jit/s390/codegen.c: Likewise. + * src/vm/jit/s390/emit.c: Likewise. + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/sparc64/emit.c: Likewise. + * src/vm/jit/x86_64/codegen.c: Likewise. + * src/vm/jit/x86_64/emit.c: Likewise. + [e87c6675ff29] + + * src/vm/array.c: + * src/vm/array.c (array_length_get): Better use LLNI_class_get here. + [4076f8bfb9f5] + +2007-09-03 Mathias Panzenboeck + + * THIRDPARTY, src/lib/Makefile.am, src/lib/gnu/sun/reflect/annotation/ + EnumConstantNotPresentExceptionProxy.java, + src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java: + * THIRDPARTY: Added copyright notice for newly imported files. + + * src/lib/Makefile.am (VM_JAVA_FILES) [ENABLE_ANNOTATIONS]: Added + $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java + and $(top_srcdir)/src/lib/gnu/sun/reflect/annotation/EnumConstantNot + PresentExceptionProxy.java (VM_CLASS_FILES) [ENABLE_ANNOTATIONS]: + Added classes/sun/reflect/annotation/ExceptionProxy.class and classe + s/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.class + + * src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentException + Proxy.java: Imported from OpenJDK. This file was only an + unimplemented stub in GNU Classpath. + + * src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java: Likewise. + [0ac069bf6d22] + +2007-09-02 Christian Thalinger + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_FindClass) [ENABLE_JAVAME_CLDC1_1]: + Implemented. + [737aa9376ba1] + + * src/cacaoh/headers.c, src/vm/initialize.c, src/vm/jit/verify + /typecheck-invoke.inc, src/vm/jit/verify/typeinfo.c, + src/vm/resolve.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/primitivecore.c: + * src/vmcore/class.h (classinfo): Changed type of super and + interfaces to classinfo*. + * src/cacaoh/headers.c (printfields): Removed .cls for super class + and/or interfaces. + * src/vm/initialize.c (initialize_class_intern): Likewise. + * src/vm/jit/verify/typecheck-invoke.inc: Likewise. + * src/vm/jit/verify/typeinfo.c (interface_extends_interface): + Likewise. (typeinfo_merge_nonarrays): Likewise. + * src/vm/resolve.c (resolve_method_invokespecial_lookup): Likwise. + * src/vmcore/class.c (class_free): Likewise. (class_resolvemethod): + Likewise. (class_resolveinterface_intern): Likewise. + (class_resolveclassmethod): Likewise. (class_findfield): Likewise. + (class_resolvefield_int): Likewise. (class_get_interfaces): + Likewise. (class_issubclass): Likewise. (class_get_superclass): + Likewise. (class_showmethods): Likewise. (class_showmethods): + Likewise. (class_resolve_superclass): Removed. + * src/vmcore/linker.c (linker_init): Removed .cls for super class + and/or interfaces. (linker_compute_subclasses): Likewise. + (linker_addinterface): Likewise. (link_class_intern): Moved verifier + checks into classfile parsing stage. + * src/vmcore/loader.c (vm/resolve.h): Added. + (load_class_from_classbuffer_intern): Resolve super class and super + interfaces during loading. This is also done by the RI. + (load_newly_created_array): Removed .cls for super class and/or + interfaces. + * src/vmcore/primitivecore.c (primitive_init): Likewise. + [6a2784fb3be7] + + * .hgignore: + * .hgignore: Ignore files in tests/. + [0d0a9bd7bf72] + +2007-09-01 Michael Starzinger + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (llni.h): Added. + (codegen_stub_builtin_exit): Use stacktrace function to remove + stackframeinfo. (codegen_finish_native_call): Likewise. Unwrap + exception object before return. + [cc6e8e021e70] + + * src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + tests/StackTraceBig.java: + * src/vm/jit/stacktrace.h (stacktracebuffer): Entries are stored + inside stb now. (stacktracecontainer): Removed data field. + + * src/vm/jit/stacktrace.c (stacktrace_add_entry) Adapted to above + changes. (stacktrace_add_method): Likewise. (stacktrace_create): + Likewise. (stacktrace_fillInStackTrace): Stacktracebuffer can be + copied at once. + + * tests/StackTraceBig.java: Added testcase for large stacktraces. + [42b041b8ea05] + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_canstore): Fixed severe typo. + [fc721266fcd8] + + * src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c, + src/vm/jit/trace.c, src/vm/jit/trace.h: + * src/vm/builtin.c: Use LLNI macros throughout the file. + (builtin_fast_canstore): Previously builtin_canstore. + (builtin_canstore): Implemented. (builtin_trace_exception): Moved to + trace.c. + + * src/vm/builtin.h: Fixed prototypes. + + * src/vm/exceptions.c (exceptions_handle_exception): Use + trace_exception instead of builtin. + + * src/vm/jit/trace.c (trace_exception): Added (moved from + builtin.c). + + * src/vm/jit/trace.h (trace_exception): Added prototype. + [e2c8ed46c130] + +2007-08-31 Michael Starzinger + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/trace.c, + src/vm/vm.c: + * src/vm/jit/trace.c (trace_java_call_print_argument): Deals with + java_object_t. + + * src/vm/exceptions.h (exceptions_asm_new_abstractmethoderror): + Fixed prototype. + + * src/vm/exceptions.c: Use LLNI_class_get throughout file. + (exceptions_get_exception): Wrap exception object. + (exceptions_set_exception): Unwrap exception object. + + * src/vm/vm.c: Use LLNI_class_get throughout file. + [f7ad5f22979c] + + * src/cacaoh/dummy.c, src/native/include/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c: + * src/cacaoh/dummy.c (array_objectarray_element_set): Fixed for + handles. (array_objectarray_element_get): Likewise. + (builtin_anewarray): Likewise. (builtin_newarray_byte): Likewise. + (localref_add): Added. + + * src/native/include/Makefile.am [ENABLE_ANNOTATIONS]: Create + java_util_Map.h. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Use above + header. + * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Method.c: Likewise. + [aaaac3a75526] + + * src/native/vm/java_lang_ClassLoader.c: + * src/native/vm/java_lang_ClassLoader.c + (_Jv_java_lang_ClassLoader_defineClass): Removed bugging assertion. + It seems defineClass can take NULL as classloader. + [058fbd6b9a45] + + * src/native/jni.c, tests/regression/native/checkjni.c, + tests/regression/native/checkjni.java, + tests/regression/native/checkjni.output: + * src/native/jni.c (_Jv_JNI_GetObjectField): Fixed implementation + for handles. (_Jv_JNI_SetObjectField): Likewise. + + * tests/regression/native/checkjni.c: Added testcase for above + change. + * tests/regression/native/checkjni.java: Likewise. + * tests/regression/native/checkjni.output: Adapted output to above + changes. + [f2aaccf82e27] + + * src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): Removed + obsolete assertion. + + * src/vm/jit/m68k/codegen.c (codegen_emit_stub_builtin): Likewise. + [245c495034d6] + + * * Merged with exact-gc branch at rev 2d4098fc2ea4. + [70720e99787f] + + * src/lib/Makefile.am, src/native/vm/Makefile.am, + src/native/vm/java_lang_String.c, src/native/vm/java_lang_String.h: + * src/lib/Makefile.am: Fixed another merge problem. + * src/native/vm/Makefile.am: Removed resurrected files. + * src/native/vm/java_lang_String.c: Removed resurrected file. + * src/native/vm/java_lang_String.h: Likewise. + [2d4098fc2ea4] + + * src/vmcore/class.c: + * src/vmcore/class.c (class_free): Fixed another merge problem (thx + to panzi). + [0ff8641a2a6d] + + * src/native/vm/gnu/java_lang_VMClassLoader.c: + * src/native/vm/gnu/java_lang_VMClassLoader.c + (Java_java_lang_VMClassLoader_findLoadedClass): Add classloader to + hashtable instead of searching for it. + [7789ad4e3f25] + + * src/threads/native/threads.c, src/vm/jit/codegen-common.c: + * src/threads/native/threads.c (threads_stopworld) [__DARWIN__]: + Disabled. (threads_startworld) [__DARWIN__]: Likewise. + + * src/vm/jit/codegen-common.c (codegen_generate_stub_builtin): + Disabled for archs where codegen_emit_stub_builtin is not yet + implemented. + [123b52988611] + + * tests/gc/ClassUnload.java: + * tests/gc/ClassUnload.java: Added testcase for class unloading. + [7ef9d758714e] + + * src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_String.c, src/vm/access.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h: + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_invokeNative): Fixed LLNI macro + usage. + + * src/native/vm/java_lang_String.c (_Jv_java_lang_String_intern): + Wrap interned strings into a handle. + + * src/vm/access.c (access_check_field): Use LLNI macro for array + access. (access_check_method): Likewise. + + * src/vm/jit/stacktrace.c (stacktrace_getClassContext): Likewise. + (stacktrace_getStack): Likewise. + + * src/vm/jit/stacktrace.h (md-abi.h): Added missing include. + [2bda8b53eb85] + + * src/mm/cacao-gc/heap.c, src/vm/jit/codegen-common.c: + * src/mm/cacao-gc/heap.c (heap_alloc_intern) [!NDEBUG]: Added sanity + check. + + * src/vm/jit/codegen-common.c (codegen_stub_builtin_enter): Removed + native-world flag manipulation. (codegen_stub_builtin_exit): + Likewise. (codegen_start_native_call): Likewise. + (codegen_finish_native_call): Likewise. + [f561e7cc5606] + + * configure.ac, src/native/jni.c, + src/native/vm/java_lang_ClassLoader.c, src/native/vm/nativevm.c, + src/vmcore/loader.c: + * configure.ac: Added missing newline. + * src/native/jni.c: Fixed some merge problems + * src/native/vm/java_lang_ClassLoader.c: Likewise. + * src/native/vm/nativevm.c: Likewise. + * src/vmcore/loader.c: Likewise. + [3a5cad64b925] + + * tests/regression/native/checkjni.c, + tests/regression/native/checkjni.java, + tests/regression/native/checkjni.output: + * tests/regression/native/checkjni.java: Added some new JNI + testcases. + * tests/regression/native/checkjni.c: Likewise. + * tests/regression/native/checkjni.output: Adapted output to new + testcases. + [45a390db1fc6] + +2007-08-30 Michael Starzinger + + * src/mm/cacao-gc/copy.c, src/mm/cacao-gc/copy.h, src/mm/cacao- + gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-gc/heap.c, src/mm + /cacao-gc/heap.h, src/mm/cacao-gc/mark.h, src/mm/cacao-gc/region.c, + src/mm/cacao-gc/region.h, src/mm/cacao-gc/rootset.c, src/mm/cacao- + gc/rootset.h, src/native/llni.c, src/native/vm/java_lang_String.c, + src/native/vm/java_lang_String.h, src/vm/jit/m68k/codegen.h: + * Removed leftover Id tags. + [6b7f509fc859] + + * AUTHORS, ChangeLog, NEWS, configure.ac, contrib/log2xml.pl, + m4/classpath.m4, src/Makefile.am, src/cacaoh/cacaoh.c, + src/cacaoh/dummy.c, src/cacaoh/headers.c, src/lib/Makefile.am, + src/mm/boehm-gc/callprocs, src/mm/boehm-gc/cord/de_win.ICO, src/mm + /boehm-gc/doc/README.arm.cross, src/mm/boehm- + gc/pthread_stop_world.c, src/mm/boehm-gc/win32_threads.c, + src/mm/boehm.c, src/mm/cacao-gc/Makefile.am, src/mm/cacao- + gc/compact.c, src/mm/cacao-gc/compact.h, src/mm/cacao-gc/gc.c, + src/mm/cacao-gc/gc.h, src/mm/cacao-gc/mark.c, src/mm/gc-common.h, + src/mm/memory.c, src/mm/memory.h, src/mm/nogc.c, + src/native/Makefile.am, src/native/include/Makefile.am, + src/native/jni.c, src/native/jni.h, src/native/llni.h, + src/native/localref.c, src/native/localref.h, src/native/native.c, + src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c, + src/threads/critical.c, src/threads/native/lock.c, + src/threads/native/lock.h, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h, + src/toolbox/avl.c, src/toolbox/avl.h, src/toolbox/list.c, + src/toolbox/list.h, src/vm/Makefile.am, src/vm/access.c, + src/vm/access.h, src/vm/builtin.c, src/vm/builtin.h, + src/vm/builtintable.inc, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/finalizer.c, src/vm/global.h, src/vm/jit/Makefile.am, + src/vm/jit/abi.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/alpha/md.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/arch.h, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/arm/md.c, src/vm/jit/arm/patcher.c, src/vm/jit/asmpart.h, + src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/codegen-common.c, + src/vm/jit/codegen-common.h, src/vm/jit/disass-common.c, + src/vm/jit/disass.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h, + src/vm/jit/emit-common.c, src/vm/jit/emit-common.h, + src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/patcher.c, + src/vm/jit/intrp/peephole-gen, src/vm/jit/intrp/vmgenx, + src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/mips/arch.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/patcher.c, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c, + src/vm/jit/parse.h, src/vm/jit/patcher.h, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc/darwin/md-abi.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/codegen.h, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/Makefile.am, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md- + abi.h, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/reg.c, src/vm/jit/replace.c, src/vm/jit/replace.h, + src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/disass.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c, src/vm/jit/s390/tests/dacapo.status, + src/vm/jit/s390/tests/tests.java.pp, src/vm/jit/show.c, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/stack.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/trace.c, src/vm/jit/trace.h, + src/vm/jit/verify/generate.pl, src/vm/jit/verify/typecheck- + stackbased.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/arch.h, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h, + src/vm/primitive.c, src/vm/primitive.h, src/vm/properties.c, + src/vm/resolve.c, src/vm/resolve.h, src/vm/signal.c, + src/vm/signallocal.h, src/vm/string.c, src/vm/stringlocal.h, + src/vm/vm.c, src/vm/vm.h, src/vmcore/Makefile.am, + src/vmcore/annotation.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/classcache.c, src/vmcore/classcache.h, + src/vmcore/descriptor.c, src/vmcore/descriptor.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c, + src/vmcore/linker.h, src/vmcore/loader.c, src/vmcore/loader.h, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/rt-timing.c, src/vmcore/rt- + timing.h, src/vmcore/statistics.c, src/vmcore/statistics.h, + src/vmcore/utf8.c, src/vmcore/utf8.h, src/vmcore/zip.c, + tests/regression/Makefile.am, tests/regression/jasmin/runtest, + tests/regression/jasmin/show, tests/regression/native/Makefile.am, + tests/regression/native/testarguments.c, + tests/regression/native/testarguments.java, + tests/regression/resolving/Makefile.am: + * Merged with default branch at rev 16f3633aaa5a. + [5580183476bc] + + * * Dummy commit to fix conversion problems with some files. + [2a3f176c1847] + +2007-08-30 Christian Thalinger + + * src/native/jni.c: + * src/native/jni.c (native/include/java_lang_Byte.h, + native/include/java_lang_Character.h, + native/include/java_lang_Short.h, + native/include/java_lang_Integer.h, + native/include/java_lang_Boolean.h, native/include/java_lang_Long.h, + native/include/java_lang_Float.h, + native/include/java_lang_Double.h): Removed. [WITH_CLASSPATH_SUN] + (class_sun_nio_ch_DirectBuffer) (class_java_nio_DirectByteBuffer, + dbb_init): Added. (jni_init) [WITH_CLASSPATH_SUN]: Added direct- + buffer stuff. (_Jv_JNI_ExceptionOccurred): Added TRACEJNICALLS. + (_Jv_JNI_ToReflectedMethod): Likewise. (_Jv_JNI_GetStaticMethodID): + Likewise. (_Jv_JNI_DestroyJavaVM): Likewise. + (_Jv_JNI_ExceptionDescribe): Fixed bug. + (_Jv_JNI_NewDirectByteBuffer) [WITH_CLASSPATH_SUN]: Implemented. + (_Jv_JNI_GetDirectBufferAddress): Likewise. + [16f3633aaa5a] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (getFloat): Implemented. + (getShort): Likewise. (getFloat): Likewise. + [e93f7beb4914] + + * src/native/jni.c, src/native/vm/sun/jvm.c: + * src/native/jni.c (_Jv_JNI_GetVersion): Return JNI_VERSION_1_6. + (GetObjectRefType): New function. (_Jv_JNINativeInterface): Added + jni_GetObjectRefType. + * src/native/vm/sun/jvm.c (JVM_IsSupportedJNIVersion): Added + JNI_VERSION_1_6. + [1f464780e928] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (getLong): Implemented. (putByte): + Likewise. (putShort): Likewise. (setMemory): Likewise. + [6543e757c0dd] + +2007-08-29 Mathias Panzenboeck + + * merge with b3167e4ef780 + [6ca1619ca330] + + * merge branch + [b3167e4ef780] + + * src/vmcore/annotation.c: + * src/vmcore/annotations.c (vmcore/loader.h): Added include. + [b15974c0c943] + +2007-08-28 Mathias Panzenboeck + + * src/native/vm/java_lang_Class.c, src/vmcore/annotation.c: + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getDeclaredAnnotations): Removed unnecessary + exceptions_get_exception() check. + + * src/vmcore/annotation.c (annotation_bytearrays_resize): Fixed + comment. + [487da8dcec58] + +2007-08-29 Michael Starzinger + + * src/threads/native/threads.h, src/threads/none/threads.h, + src/vm/jit/stacktrace.c: + * src/threads/native/threads.h: Added THREAD_NATIVEWORLD macros. + * src/threads/none/threads.h: Likewise. + * src/vm/jit/stacktrace.c (stacktrace_remove_stackframeinfo): Use + above macros. (stacktrace_create_extern_stackframe): Likewise. + (stacktrace_create_native_stackframe): Likewise. + [3cf6b87e4849] + +2007-08-29 Christian Thalinger + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_NewArray): Added NPE check. + (JVM_NewMultiArray): Implemented, but needs review at a later point. + [dc9b6899f051] + + * src/vmcore/loader.c: + * src/vmcore/loader.c (load_class_from_classbuffer): Renamed to + load_class_from_classbuffer_intern. (load_class_from_classbuffer): + New function. + [812cc24606bb] + + * src/vmcore/loader.c, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vmcore/loader.c (load_class_from_classloader) + [WITH_CLASSPATH_SUN]: Call loadClassInternal. + * src/vmcore/utf8.c (utf_loadClassInternal): Added. (utf8_init): + Initialize utf_loadClassInternal. + * src/vmcore/utf8.h (utf_loadClassInternal): Added. + [7065d8389571] + + * src/cacaoh/cacaoh.c, src/vm/primitive.h, src/vm/vm.c, + src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c, + src/vmcore/loader.h, src/vmcore/primitivecore.c: + * src/cacaoh/cacaoh.c (main): Added loader_preinit call. + + * src/vm/primitive.h (primitive_init): Changed return type to void. + (primitive_postinit): New function. + + * src/vm/vm.c (vm_create): Use new init functions. + + * src/vmcore/linker.c (stdint.h): Added. (linker_preinit): New + function. (linker_init): Moved basic stuff into linker_preinit, call + vm_abort if error occurred. + + * src/vmcore/linker.h (linker_preinit): New function. (linker_init): + Changed return type to void. + + * src/vmcore/loader.c (loader_preinit): New function. (loader_init): + Moved basic stuff into loader_preinit, call vm_abort if error + occurred. + + * src/vmcore/loader.h (loader_preinit): New function. (loader_init): + Changed return type to void. + + * src/vmcore/primitivecore.c (vm/vm.h): Added. (primitive_init): + Load and link primitive-type classes and array-class ASAP, this is + important for annotations. (primitive_postinit): New function. + [b562aa714e92] + +2007-08-28 Christian Thalinger + + * src/vmcore/annotation.c: + * src/vmcore/annotation.c (stdint.h): Added. + [0dbc39d08b63] + +2007-08-28 Mathias Panzenboeck + + * src/vmcore/field.c, src/vmcore/method.c: + * src/vmcore/field.c (vm/array.h): Added include. (mm/memory.h): + Removed doubled include. (field_get_annotations): Added cast for + array_length_get()s parameter. + + * src/vmcore/method.c (vm/array.h): Added include. + (method_get_annotations): Added cast for array_length_get()s + parameter. (method_get_parameterannotations): Added cast for + array_length_get()s parameter. (method_get_annotationdefault): Added + cast for array_length_get()s parameter. + [d6a85336983a] + +2007-08-27 Mathias Panzenboeck + + * src/vmcore/annotation.c, src/vmcore/annotation.h: + * src/vmcore/annotation.c (annotation_bytearrays_resize): Removed + unused variables. + + * src/vmcore/annotation.h: Sorted includes. (vmcore/utf8.h): Removed + include. + [6aee3768a843] + + * autogen.sh, src/cacaoh/dummy.c, src/mm/boehm-gc/autogen.sh, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/vmcore/annotation.c, + src/vmcore/annotation.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/field.c, src/vmcore/loader.c, src/vmcore/method.c, + src/vmcore/utf8.c, src/vmcore/utf8.h: + * autogen.sh: Made executeable. + + * src/cacaoh/dummy.c (mm/memory.h): Added include. (native/llni.h): + Added include. (array_objectarray_element_get): Added dummy + implementation. (array_objectarray_element_set): Added dummy + implementation. (array_length_get): Added dummy implementation. + (builtin_anewarray): Added dummy implementation using MNEW. + (builtin_newarray_byte): Added dummy implementation using MNEW. + (primitive_arrayclass_get_by_type): Added dummy implementation. + + * src/mm/boehm-gc/autogen.sh: Made executeable. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (Java_java_lang_reflect_Constructor_declaredAnnotations): Removed + unused variable o. + (Java_java_lang_reflect_Constructor_getParameterAnnotations): + Removed unused variable o. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (Java_java_lang_reflect_Field_declaredAnnotations): Removed unused + variable o. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_getDefaultValue): Removed unused + variable o. (Java_java_lang_reflect_Method_declaredAnnotations): + Removed unused variable o. + (Java_java_lang_reflect_Method_getParameterAnnotations): Removed + unused variable o. + + * src/native/vm/gnu/sun_reflect_ConstantPool.c + (_Jv_sun_reflect_ConstantPool_init): Removed usage of global string + utf_sun_reflect_ConstantPool. + + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS]: Sorted includes. + (_Jv_java_lang_Class_getDeclaredAnnotations): Fixed comment. + + * src/vmcore/annotation.c (native/llni.h): Added include. + (vm/array.h): Added include. (vm/builtin.h): Added include. + (vm/primitive.h): Added include. (annotation_bytearray_new): + Removed. (annotation_bytearray_free): Removed. + (annotation_bytearrays_new): Removed. (annotation_bytearrays_free): + Removed. (annotation_bytearrays_resize): Made static and now + java_handle_objectarray_t is used instead of my own array type. + (annotation_bytearrays_insert): Made static and now + java_handle_objectarray_t is used instead of my own array type. + (annotation_load_attribute_body): Using java_handle_bytearray_t + instead of my own array type. + (annotation_load_method_attribute_annotationdefault): Using + java_handle_bytearray_t and java_handle_objectarray_t instead of my + own array types. (annotation_load_method_attribute_runtimevisiblepar + ameterannotations): Using java_handle_bytearray_t and + java_handle_objectarray_t instead of my own array types. + (annotation_load_method_attribute_runtimevisibleannotations): Using + java_handle_bytearray_t and java_handle_objectarray_t instead of my + own array types. + (annotation_load_field_attribute_runtimevisibleannotations): Using + java_handle_bytearray_t and java_handle_objectarray_t instead of my + own array types. + + * src/vmcore/annotation.h (annotation_bytearray_t): Removed. + (annotation_bytearrays_t): Removed. (annotation_bytearray_new): + Removed. (annotation_bytearray_free): Removed. + (annotation_bytearrays_new): Removed. + (annotation_bytearrays_resize): Removed. + (annotation_bytearrays_insert): Removed. + (annotation_bytearrays_free): Removed. + + * src/vmcore/class.c + (class_sun_reflect_annotation_AnnotationParser): Is only declared + when WITH_CLASSPATH_GNU is defined. (class_free) + [ENABLE_ANNOTATIONS]: Removed usage of annotation_bytearray*_free() + functions. (class_get_annotations): Don't have to copy anything now, + just return the java_handle_bytearray_t. + + * src/vmcore/class.h (classinfo): Fixed comments. (classinfo) + [ENABLE_ANNOTATIONS]: Now using java_handle_bytearray_t and + java_handle_objectarray_t instead of my own array types. + + * src/vmcore/loader.c (loader_init): Removed usage of global string + utf_sun_reflect_ConstantPool and + utf_sun_reflect_annotation_AnnotationParser. + + * src/vmcore/field.c (vm/array.h): Added include. + (field_get_annotations): Don't have to copy anything now, just + return the java_handle_bytearray_t. + + * src/vmcore/method.c (vm/array.h): Added include. + (method_get_annotations): Don't have to copy anything now, just + return the java_handle_bytearray_t. + (method_get_parameterannotations): Don't have to copy anything now, + just return the java_handle_bytearray_t. + (method_get_annotationdefault): Don't have to copy anything now, + just return the java_handle_bytearray_t. + + * src/vmcore/utf8.c (utf_sun_reflect_ConstantPool): Removed. + (utf_sun_reflect_annotation_AnnotationParser): Removed. + + * src/vmcore/utf8.h (utf_sun_reflect_ConstantPool): Removed. + (utf_sun_reflect_annotation_AnnotationParser): Removed. + [3e20268e098e] + +2007-08-27 Christian Thalinger + + * src/vm/jit/show.c: + * src/vm/jit/show.c (show_icmd): ICMD_MULTIANEWARRAY: Print class + name. + [1d28f69443d0] + + * Makefile.am, autogen.sh, configure.ac, contrib/Makefile.am, + contrib/log2xml.pl, doc/Makefile.am, doc/handbook/Makefile.am, + m4/annotations.m4, m4/cacaoh.m4, m4/java.m4, m4/jit.m4, m4/jni.m4, + m4/jre-layout.m4, m4/libjvm.m4, m4/ltdl.m4, m4/soft.m4, + m4/staticvm.m4, m4/threads.m4, m4/zlib.m4, man/Makefile.am, + src/Makefile.am, src/cacao/Makefile.am, src/cacao/cacao.c, + src/cacaoh/Makefile.am, src/cacaoh/cacaoh.c, src/cacaoh/dummy.c, + src/cacaoh/headers.c, src/cacaoh/headers.h, src/fdlibm/Makefile.am, + src/lib/Makefile.am, src/lib/gnu/java/lang/VMClassLoader.java, + src/mm/Makefile.am, src/mm/boehm-gc/autogen.sh, src/mm/boehm- + gc/callprocs, src/mm/boehm-gc/cord/de_win.ICO, src/mm/boehm- + gc/doc/README.arm.cross, src/mm/boehm-gc/win32_threads.c, + src/mm/boehm.c, src/mm/cacao-gc/Makefile.am, src/mm/cacao- + gc/compact.c, src/mm/cacao-gc/compact.h, src/mm/cacao-gc/gc.c, + src/mm/cacao-gc/gc.h, src/mm/cacao-gc/mark.c, src/mm/gc-common.h, + src/mm/memory.c, src/mm/memory.h, src/mm/nogc.c, + src/native/Makefile.am, src/native/include/Makefile.am, + src/native/jni.c, src/native/jni.h, src/native/jvmti/Makefile.am, + src/native/jvmti/cacaodbg.c, src/native/jvmti/cacaodbg.h, + src/native/jvmti/cacaodbgserver.c, + src/native/jvmti/cacaodbgserver.h, src/native/jvmti/dbg.h, + src/native/jvmti/jvmti.c, src/native/jvmti/jvmti.h, + src/native/llni.h, src/native/localref.c, src/native/localref.h, + src/native/native.c, src/native/native.h, + src/native/tools/Makefile.am, src/native/tools/gennativetable.c, + src/native/vm/Makefile.am, src/native/vm/cldc1.1/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/java_lang_Math.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/Makefile.am, src/native/vm/gnu/VMjdwp.c, + src/native/vm/gnu/VMjdwp.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMFrame.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMMethod.c, + src/native/vm/gnu/gnu_classpath_jdwp_VMVirtualMachine.c, src/native/ + vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_ClassLoader.h, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h, + src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_Thread.h, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h, + src/native/vm/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_util_concurrent_atomic_AtomicLong.h, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/reflect.c, src/native/vm/reflect.h, + src/native/vm/sun/Makefile.am, src/native/vm/sun/jvm.c, + src/native/vm/sun_misc_Unsafe.c, src/scripts/Makefile.am, + src/scripts/java.in, src/threads/Makefile.am, + src/threads/critical.c, src/threads/critical.h, src/threads/lock- + common.h, src/threads/native/Makefile.am, src/threads/native + /generic-primitives.h, src/threads/native/lock.c, + src/threads/native/lock.h, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/Makefile.am, + src/threads/none/lock.h, src/threads/none/threads.h, src/threads + /threads-common.c, src/threads/threads-common.h, + src/toolbox/Makefile.am, src/toolbox/avl.c, src/toolbox/avl.h, + src/toolbox/bitvector.c, src/toolbox/bitvector.h, + src/toolbox/chain.c, src/toolbox/chain.h, src/toolbox/hashtable.c, + src/toolbox/hashtable.h, src/toolbox/list.c, src/toolbox/list.h, + src/toolbox/logging.c, src/toolbox/logging.h, src/toolbox/tree.c, + src/toolbox/tree.h, src/toolbox/util.c, src/toolbox/util.h, + src/toolbox/worklist.c, src/toolbox/worklist.h, src/vm/Makefile.am, + src/vm/access.c, src/vm/access.h, src/vm/array.c, src/vm/array.h, + src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc, src/vm + /cycles-stats.c, src/vm/cycles-stats.h, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/finalizer.c, src/vm/finalizer.h, + src/vm/global.h, src/vm/initialize.c, src/vm/initialize.h, + src/vm/jit/Makefile.am, src/vm/jit/abi-asm.h, src/vm/jit/abi.h, + src/vm/jit/allocator/Makefile.am, src/vm/jit/allocator/liveness.c, + src/vm/jit/allocator/liveness.h, src/vm/jit/allocator/lsra.c, + src/vm/jit/allocator/lsra.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/allocator/simplereg.h, src/vm/jit/alpha/Makefile.am, + src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h, + src/vm/jit/alpha/disass.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/freebsd/Makefile.am, src/vm/jit/alpha/freebsd/md- + os.c, src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/alpha/md-abi.c, src/vm/jit/alpha/md-abi.h, + src/vm/jit/alpha/md-asm.h, src/vm/jit/alpha/md.c, + src/vm/jit/alpha/md.h, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/Makefile.am, src/vm/jit/arm/arch.h, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/disass.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/Makefile.am, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md-asm.h, + src/vm/jit/arm/md.c, src/vm/jit/arm/patcher.c, src/vm/jit/asmpart.h, + src/vm/jit/cfg.c, src/vm/jit/cfg.h, src/vm/jit/code.c, + src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/codegen- + common.h, src/vm/jit/disass-common.c, src/vm/jit/disass.h, + src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/emit-common.c, + src/vm/jit/emit-common.h, src/vm/jit/i386/Makefile.am, + src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h, + src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/darwin/Makefile.am, + src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/i386/darwin/md-os.c, + src/vm/jit/i386/disass.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/emit.h, src/vm/jit/i386/freebsd/Makefile.am, + src/vm/jit/i386/freebsd/md-asm.h, src/vm/jit/i386/freebsd/md-os.c, + src/vm/jit/i386/linux/Makefile.am, src/vm/jit/i386/linux/md-asm.h, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/i386/md-abi.h, src/vm/jit/i386/md.c, + src/vm/jit/i386/patcher.c, src/vm/jit/inline/Makefile.am, + src/vm/jit/inline/inline.c, src/vm/jit/inline/inline.h, + src/vm/jit/intrp/Makefile.am, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/codegen.h, + src/vm/jit/intrp/disass.c, src/vm/jit/intrp/dynamic-super.c, + src/vm/jit/intrp/engine.c, src/vm/jit/intrp/engine1.c, + src/vm/jit/intrp/engine2.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/intrp/md.c, src/vm/jit/intrp/patcher.c, src/vm/jit/intrp + /peephole-gen, src/vm/jit/intrp/vmgenx, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/loop/Makefile.am, + src/vm/jit/loop/analyze.c, src/vm/jit/loop/analyze.h, + src/vm/jit/loop/graph.c, src/vm/jit/loop/graph.h, + src/vm/jit/loop/loop.c, src/vm/jit/loop/loop.h, + src/vm/jit/loop/tracing.c, src/vm/jit/loop/tracing.h, + src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/disass.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/emit.h, + src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/machine-instr.h, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, src/vm/jit/md.h, + src/vm/jit/methodheader.h, src/vm/jit/mips/Makefile.am, + src/vm/jit/mips/arch.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h, + src/vm/jit/mips/disass.c, src/vm/jit/mips/emit.c, + src/vm/jit/mips/irix/Makefile.am, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/linux/Makefile.am, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-abi.h, src/vm/jit/mips + /md-asm.h, src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, + src/vm/jit/mips/uclinux/Makefile.am, src/vm/jit/mips/uclinux/md- + os.c, src/vm/jit/optimizing/Makefile.am, + src/vm/jit/optimizing/dominators.c, + src/vm/jit/optimizing/dominators.h, src/vm/jit/optimizing/graph.c, + src/vm/jit/optimizing/graph.h, src/vm/jit/optimizing/ifconv.c, + src/vm/jit/optimizing/ifconv.h, src/vm/jit/optimizing/lifetimes.c, + src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/profile.h, src/vm/jit/optimizing/recompile.c, + src/vm/jit/optimizing/recompile.h, src/vm/jit/optimizing/reorder.c, + src/vm/jit/optimizing/reorder.h, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa.h, src/vm/jit/parisc/Makefile.am, + src/vm/jit/parisc/arch.h, src/vm/jit/parisc/linux/Makefile.am, + src/vm/jit/parisc/md-abi.h, src/vm/jit/parisc/md.c, + src/vm/jit/parse.c, src/vm/jit/parse.h, src/vm/jit/patcher-common.c, + src/vm/jit/patcher-common.h, src/vm/jit/patcher.h, + src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc/darwin/Makefile.am, + src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md- + abi.h, src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/powerpc/darwin + /md-os.c, src/vm/jit/powerpc/disass.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/Makefile.am, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/powerpc/linux + /md-asm.h, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/netbsd/Makefile.am, + src/vm/jit/powerpc/netbsd/md-abi.c, src/vm/jit/powerpc/netbsd/md- + abi.h, src/vm/jit/powerpc/netbsd/md-asm.h, src/vm/jit/powerpc/netbsd + /md-os.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/powerpc64/disass.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/Makefile.am, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md- + abi.h, src/vm/jit/powerpc64/linux/md-asm.h, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/reg.c, src/vm/jit/reg.h, + src/vm/jit/replace.c, src/vm/jit/replace.h, + src/vm/jit/s390/Makefile.am, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/disass.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/schedule/Makefile.am, src/vm/jit/schedule/schedule.c, + src/vm/jit/schedule/schedule.h, src/vm/jit/show.c, + src/vm/jit/show.h, src/vm/jit/sparc64/Makefile.am, + src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/disass.c, src/vm/jit/sparc64/emit-arch.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/emit.h, + src/vm/jit/sparc64/linux/Makefile.am, src/vm/jit/sparc64/linux/md- + os.c, src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/md-asm.h, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c, + src/vm/jit/sparc64/solaris/Makefile.am, src/vm/jit/sparc64/solaris + /md-os.c, src/vm/jit/stack.c, src/vm/jit/stack.h, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/trace.c, src/vm/jit/trace.h, + src/vm/jit/verify/Makefile.am, src/vm/jit/verify/generate.pl, + src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-builtins.inc, + src/vm/jit/verify/typecheck-common.c, src/vm/jit/verify/typecheck- + common.h, src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify + /typecheck-invoke.inc, src/vm/jit/verify/typecheck- + multianewarray.inc, src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typecheck-typeinferer.c, src/vm/jit/verify + /typecheck-typeinferer.h, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typecheck.h, src/vm/jit/verify/typeinfo.c, + src/vm/jit/verify/typeinfo.h, src/vm/jit/x86_64/Makefile.am, + src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h, + src/vm/jit/x86_64/disass.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/freebsd/Makefile.am, + src/vm/jit/x86_64/freebsd/md-os.c, + src/vm/jit/x86_64/linux/Makefile.am, src/vm/jit/x86_64/linux/md- + os.c, src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md-abi.h, + src/vm/jit/x86_64/md-asm.h, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h, + src/vm/primitive.c, src/vm/primitive.h, src/vm/properties.c, + src/vm/properties.h, src/vm/resolve.c, src/vm/resolve.h, + src/vm/signal.c, src/vm/signallocal.h, src/vm/string.c, + src/vm/stringlocal.h, src/vm/types.h, src/vm/vm.c, src/vm/vm.h, + src/vmcore/Makefile.am, src/vmcore/annotation.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, + src/vmcore/classcache.h, src/vmcore/descriptor.c, + src/vmcore/descriptor.h, src/vmcore/field.c, src/vmcore/field.h, + src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c, + src/vmcore/loader.h, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h, + src/vmcore/primitivecore.c, src/vmcore/references.h, src/vmcore/rt- + timing.c, src/vmcore/rt-timing.h, src/vmcore/stackmap.c, + src/vmcore/stackmap.h, src/vmcore/statistics.c, + src/vmcore/statistics.h, src/vmcore/suck.c, src/vmcore/suck.h, + src/vmcore/utf8.c, src/vmcore/utf8.h, src/vmcore/zip.c, + src/vmcore/zip.h, tests/Makefile.am, tests/regression/Makefile.am, + tests/regression/MinimalClassReflection.java, + tests/regression/TestAnnotations.java, + tests/regression/codepatching/Makefile.am, + tests/regression/fptest.java, tests/regression/jasmin/Makefile.am, + tests/regression/jasmin/runtest, tests/regression/jasmin/show, + tests/regression/jctest.java, tests/regression/native/Makefile.am, + tests/regression/native/checkjni.c, + tests/regression/native/checkjni.java, + tests/regression/native/test.c, tests/regression/native/test.java, + tests/regression/native/testarguments.c, + tests/regression/native/testarguments.java, + tests/regression/native/testgetobjectclass0.c, + tests/regression/native/testgetobjectclass0.java, + tests/regression/resolving/Makefile.am, + tests/regression/resolving/classes1/Makefile.am, + tests/regression/resolving/classes2/Makefile.am, + tests/regression/resolving/classes3/Makefile.am: + * Removed all Id tags. + [777633d18b4c] + + * src/vm/vm.c: + * src/vm/vm.c (vm_printconfig): Better and correct output. + [660822b1af20] + + * .hgignore: + * Added *~. + [c8678806a55c] + +2007-08-25 Christian Thalinger + + * .hgignore: + * .hgignore: New file. + [42382aa1e7b5] + +2007-08-22 twisti + + * src/vm/vm.c, src/vmcore/suck.c: + * src/vm/vm.c (vm_create) [ENABLE_JAVASE]: Removed #ifdef for + setting sun.boot.class.path and java.boot.class.path. + * src/vmcore/suck.c (suck_add_from_property): Likewise. + [69da96539daa] + + * src/vm/properties.c, src/vm/vm.c, src/vmcore/suck.c: + * src/vm/vm.c (vm_create): Free properties after they have been + replaced. + * src/vmcore/suck.c (suck_add_from_property): Likewise. + + * src/vm/properties.c (properties_set): Smaller changes. + [c92f5716cba2] + + * src/threads/native/threads.c, src/vm/properties.c: + * src/vm/properties.c (properties_set): Fixed build for CLDC-1.1, + removed getenv of JAVA_HOME. + + * src/threads/native/threads.c (threads_detach_thread): Fixed build + for CLDC-1.1. + [b8e9f732a292] + + * src/native/vm/nativevm.c, src/vm/properties.c, src/vm/vm.c: + * src/vm/vm.c [WITH_JRE_LAYOUT] (libgen.h, unistd.h): Removed. + + * src/vm/properties.c (errno.h): Added. [WITH_JRE_LAYOUT] + (libgen.h): Likewise. (properties_set) [WITH_CLASSPATH_SUN]: Set + sun.boot.library.path property. + + * src/native/vm/nativevm.c (vm/properties.h): Added. + (nativevm_preinit) [WITH_CLASSPATH_SUN]: Use properties_get to get + sun.boot.library.path. + [a764c454c91c] + +2007-08-22 pm + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c: + * src/vm/jit/s390/codegen.h: Cleanup. + * src/vm/jit/s390/codegen.c (codegen_emit): Tryed to improove ACONST. + * src/vm/jit/s390/emit.c (emit_copy): Use MVC (memcpy instruction) for + memory to memory copy. + [870ff292761c] + +2007-08-22 twisti + + * src/vm/properties.c, src/vm/properties.h, src/vm/vm.c, src/vm/vm.h, + src/vmcore/suck.c: + * src/vm/properties.c (list_properties_entry): Renamed to + list_properties_entry_t. (properties_init): Only initialize the + list. (properties_set): New function to set default properties + (don't use JAVA_HOME to set java.home). + + * src/vm/properties.h (vm/types.h): Removed. (stdint.h): Added. + (properties_init): Changed signature. (properties_set): New + function. + + * src/vm/vm.c (cacao_prefix): Removed. (cacao_libjvm): Likewise. + (classpath_libdir): Likewise. (_Jv_bootclasspath): Likewise. + (_Jv_classpath): Likewise. (_Jv_java_library_path): Likewise. + (specificmethodname): Likewise. (specificsignature): Likewise. + (startit): Likewise. (vm_printconfig): Use properties_get to get + properties. (vm_create): Moved properties stuff into properties_set. + + * src/vm/vm.h (cacao_prefix): Removed. (cacao_libjvm): Likewise. + (classpath_libdir): Likewise. (_Jv_bootclasspath): Likewise. + (_Jv_classpath): Likewise. (_Jv_java_library_path): Likewise. + + * src/vmcore/suck.c (suck_add_from_property): Use properties_get to + manipulate bootclasspath. + [b0bc14174f72] + + * m4/classpath.m4: + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Fixed typo. + [232c19c34670] + + * src/vm/vm.c: + * src/vm/vm.c (native/include/java_lang_Byte.h, + native/include/java_lang_Character.h, + native/include/java_lang_Short.h, + native/include/java_lang_Integer.h, + native/include/java_lang_Boolean.h, native/include/java_lang_Long.h, + native/include/java_lang_Float.h, + native/include/java_lang_Double.h): Removed. + [aab3d93b5630] + + * configure.ac: + * configure.ac (AC_CHECK_HEADERS): Added libgen.h. (AC_CHECK_FUNCS): + Added dirname, readlink. + [0cbbe3bcc3cd] + +2007-08-22 panzi + + * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.h (class_get_annotations): Added. This function + encapsulates the access to the annotations field of the classinfo + struct. It is defined even if ENABLE_ANNOTATIONS is not, but just + returns NULL in that case. + + * src/vmcore/class.c (class_get_annotations): Added. + + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getDeclaredAnnotations): Now uses + class_get_annotations(). + + * src/native/vm/sun/jvm.c (JVM_GetClassAnnotations): Now uses + class_get_annotations(). + [ae07ae0272eb] + + * m4/annotations.m4: + * m4/annotations.m4: Fixed comment. + [38e9d135d38d] + + * src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/reflect.c, src/native/vm/sun/jvm.c, + src/vmcore/annotation.h, src/vmcore/class.h: + * src/lib/gnu/java/lang/reflect/Method.java (declaredAnnotations): + Added generic type parameters to Class. + + * src/lib/gnu/java/lang/reflect/Field.java (declaredAnnotations): + Added generic type parameters to Class. + + * src/lib/gnu/java/lang/reflect/Constructor.java + (declaredAnnotations): Added generic type parameters to Class. + + * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Fixed + formatting. + * src/native/vm/gnu/sun_reflect_ConstantPool.c + (Java_sun_reflect_ConstantPool_getMemberRefInfoAt0): Fixed + formatting of log output. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_getDefaultValue), + (Java_java_lang_reflect_Method_declaredAnnotations), + (Java_java_lang_reflect_Method_getParameterAnnotations): Use + LLNI_class_get macro. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (Java_java_lang_reflect_Method_declaredAnnotations): Use + LLNI_class_get macro. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (Java_java_lang_reflect_Method_declaredAnnotations), + (Java_java_lang_reflect_Method_getParameterAnnotations): Use + LLNI_class_get macro. + + * src/native/vm/sun/jvm.c (JVM_GetClassConstantPool): Fixed + formatting of log output. + + * src/native/vm/reflect.c (reflect_get_declaredannotatios): Fixed + comment. + + * src/vmcore/class.h (classinfo): Added comments for annottation + fields. + + * src/vmcore/annotation.h (annotation_t), (element_value_t): Removed + unused structs. + [81a831b87f1b] + +2007-08-21 michi + + * src/mm/cacao-gc/gc.c: + * src/mm/cacao-gc/gc.c (gc_init) [ENABLE_HANDLES]: Added offset + check for global reference entries. + [759632de7c01] + + * src/native/jni.c, src/native/localref.c, src/native/localref.h: + * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Moved code to + localref_del. + + * src/native/localref.c (localref_add): Minor code cleanup. + (localref_del): Moved from jni.c and adapted to work with handles. + + * src/native/localref.h (localref_del): Minor signature change. + [356dbd0bd1d9] + + * src/native/jni.c: + * src/native/jni.c: Used LLNI_classinfo_wrap to return classes. + (_Jv_JNI_IsSameObject): Fixed implementation for handles. + (_Jv_JNI_NewLocalRef): Likewise. (_Jv_JNI_SetObjectArrayElement): + Use builtin_canstore correctly. (_Jv_JNI_NewGlobalRef): Correct + implementation for handles. (_Jv_JNI_DeleteGlobalRef): Likewise. + [5efc6830b6ab] + +2007-08-21 twisti + + * src/vm/properties.c: + * src/vm/properties.c (properties_init): Moved setting java.home + into WITH_CLASSPATH_GNU, otherwise it's done twice for + WITH_CLASSPATH_SUN. + [46d825b9cb5f] + +2007-08-21 michi + + * src/native/jni.c, src/vm/access.c: + * src/native/jni.c: Fixed LLNI macro usage. + [1293d58652ab] + +2007-08-21 twisti + + * src/native/jni.c, src/native/vm/java_lang_ClassLoader.c, + src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_define): Added protection domain to + signature. (class_resolve_superclass): Some changes (not yet + correct). (class_issubclass): Added assert to see if super is + resolved. + + * src/vmcore/class.h (classinfo) [ENABLE_JAVASE && + WITH_CLASSPATH_SUN]: Added protectiondomain. + + * src/native/jni.c (_Jv_JNI_DefineClass): Pass protection domain to + class_define. + * src/native/vm/java_lang_ClassLoader.c (defineClass): Likewise. + + * src/native/vm/sun_misc_Unsafe.c (unistd.h): Added. (vm/builtin.h): + Likewise. (putShort__Ljava_lang_Object_2JS): Implemented. + (putFloat__Ljava_lang_Object_2JF): Likewise (putInt__JI): Likewise + (pageSize): Likewise (allocateInstance): Likewise (getLongVolatile): + Likewise (defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoade + r_2Ljava_security_ProtectionDomain_2): Pass protection domain to + class_define. + + * src/native/vm/sun/jvm.c (threads/threads-common.h): Added. + (vm/signallocal.h): Likewise. (PRINTJVMWARNINGS): New macro (not + enabled yet). (JVM_MaxMemory): Implemented. (JVM_EnableCompiler): + Likewise. (JVM_DisableCompiler): Likewise. (JVM_ResolveClass): + Likewise. (JVM_GetClassSignature): Likewise. (JVM_Yield): Likewise. + (JVM_GetThreadStateValues): Likewise. (JVM_GetThreadStateNames): + Likewise. (JVM_RegisterSignal): Likewise. (JVM_FindSignal): + Likewise. (JVM_DefineClassWithSource): Pass protection domain to + class_define. (JVM_DesiredAssertionStatus): Return false for now. + (JVM_Available): Only ioctl is a correct implementation. + [2f9138ad6203] + + * src/vm/access.c: + * src/vm/access.c (access_is_accessible_class) [WITH_CLASSPATH_SUN]: + Check for referer, not cls. (access_is_accessible_member) + [WITH_CLASSPATH_SUN]: Check for referer, not declarer. + [ea54fff4a82a] + + * src/native/vm/java_lang_Object.c: + * src/native/vm/java_lang_Object.c (wait): Check for ms < 0. + [e1591b347c35] + +2007-08-21 panzi + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetArrayLength): Now using function + array_length_get(). (JVM_GetArrayElement): Now using function + array_element_get(). (JVM_SetArrayElement): Implemented by using + function array_element_set(). + [debb26635ceb] + +2007-08-21 twisti + + * src/vm/array.c, src/vm/array.h: + * src/vm/array.c (vm/exceptions.h): Added. (vm/primitive.h): + Likewise. (array_element_get): New function. (array_element_set): + Likewise. (array_element_primitive_get): Cast to specific array- + type. (array_element_primitive_set): New function. + (ARRAY_TYPEARRAY_ELEMENT_GET): Added NPE and AIOOBE checks. + (ARRAY_TYPEARRAY_ELEMENT_SET): New macro. (array_length_get): New + function. + + * src/vm/array.h (array_element_get): New function. + (array_element_set): Likewise. (array_booleanarray_element_get, + array_bytearray_element_get, array_chararray_element_get, + array_shortarray_element_get, array_intarray_element_get, + array_longarray_element_get, array_floatarray_element_get, + array_doublearray_element_get, array_objectarray_element_get): + Changed signature. (array_booleanarray_element_set, + array_bytearray_element_set, array_chararray_element_set, + array_shortarray_element_set, array_intarray_element_set, + array_longarray_element_set, array_floatarray_element_set, + array_doublearray_element_set, array_objectarray_element_set): New + function. (array_length_get): Likewise. + [49c86ae5ddb0] + + * src/vm/properties.c: + * src/vm/properties.c (properties_init) [WITH_CLASSPATH_SUN]: + Removed debug output. + [e229dd128d49] + + * configure.ac, src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/vm/properties.c: + * configure.ac (AC_CHECK_FUNCS): Added access. + * src/vm/properties.c (unistd.h): Added. (properties_init) + [WITH_CLASSPATH_SUN]: Find correct java.home. + [927d02909913] + +2007-08-21 michi + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_Thread.c, src/vm/primitive.c, + src/vm/properties.c: + * src/vm/properties.c (properties_system_add): Use LLNI macros. + (properties_system_add_all): Likewise. + + * src/vm/primitive.c (primitive_unbox): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Fixed + assertion. + + * src/native/vm/java_lang_Thread.c: Fixed LLNI macro usage. + [11f7b49dda5d] + +2007-08-21 panzi + + * THIRDPARTY: + * THIRDPARTY (src/lib/gnu/sun/reflect/ConstantPool.java), + (src/lib/gnu/sun/reflect/annotation/AnnotationParser.java), + (src/lib/gnu/sun/reflect/annotation/AnnotationType.java), (src/lib/g + nu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java) + , (src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.j + ava): These files are licensed by sun under the GPLv2. + [8073f3ac70ea] + +2007-08-21 twisti + + * src/native/vm/nativevm.c: + * src/native/vm/nativevm.c [WITH_CLASSPATH_SUN] (string.h): Added. + [WITH_CLASSPATH_SUN] (mm/memory.h): Likewise. (nativevm_preinit) + [WITH_CLASSPATH_SUN]: Use classpath_libdir variable instead of + CLASSPATH_LIBDIR. This is correct for WITH_JRE_LAYOUT. + [44950c9ac1f3] + +2007-08-21 michi + + * m4/classpath.m4, src/cacaoh/headers.c: + * src/cacaoh/headers.c (HEAP_PREFIX): Added define. (printtype): + Added arguments prefix and infix. (printfields): Pass correct prefix + for reference types. (printmethod): Pass correct infix for array + types. (headerfile_generate): Print correct prefix for heap object. + (headerfile_generate) [ENABLE_HANDLES]: Also create struct typedef + for handle. + [1cde84324121] + +2007-08-21 twisti + + * m4/classpath.m4: + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_LIBDIR): Set + CLASSPATH_LIBDIR correctly for OpenJDK. + [f59871a923da] + + * configure.ac, m4/staticvm.m4: + * configure.ac (AC_CHECK_ENABLE_STATICVM): Added. + * m4/staticvm.m4: New file. + [575b17df5444] + +2007-08-21 michi + + * src/cacaoh/dummy.c, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, + src/mm/cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h, src/mm/gc- + common.h, src/native/jni.c, src/threads/native/threads.c, + src/threads/threads-common.c, src/vmcore/loader.c: + * src/mm/cacao-gc/gc.h (list_gcref_entry_t): Renamed type to + reftype. [!ENABLE_HANDLES]: Added development break. + + * src/mm/cacao-gc/gc.c (gc_reference_register): Added reftype to + arguments. + + * src/mm/gc-common.h: Added reftype defines. + * src/mm/cacao-gc/rootset.h: Removed reftype defines. + + * src/mm/cacao-gc/rootset.c: Adapted to changes. + + * src/vmcore/loader.c (loader_hashtable_classloader_add): Pass + reftype to GC. + * src/native/jni.c (_Jv_JNI_NewGlobalRef): Likewise. + * src/threads/native/threads.c (threads_init): Likewise. + * src/threads/threads-common.c (threads_thread_new): Likewise. + (threads_thread_print_info) [WITH_CLASSPATH_GNU]: Fixed thread name + printing. + + * src/cacaoh/dummy.c (gc_reference_register): Adapted dummy function + to new sig. + [3c38a2ccdc4f] + +2007-08-20 twisti + + * m4/jre-layout.m4: + * m4/jre-layout.m4: Set Id keyword. + [187bc2030109] + + * configure.ac, m4/jre-layout.m4: + * configure.ac (AC_CHECK_WITH_JRE_LAYOUT): Added. + * m4/jre-layout.m4: New file. + [29b158e22fc7] + +2007-08-20 michi + + * src/mm/boehm.c, src/vm/jit/replace.h: + * src/mm/boehm.c (heap_alloc_uncollectable): Fixed typo. + * src/vm/jit/replace.h [!ENABLE_REPLACEMENT]: Added missing defines. + [95bd9c1f25ad] + +2007-08-20 twisti + + * src/native/llni.h, src/vm/signal.c: + * src/vm/signal.c (signal_thread): Removed debug output. + (signal_thread_handler): Likewise. + [1cb05b99b528] + +2007-08-20 michi + + * src/vmcore/loader.c: + * src/vmcore/loader.c: Fixed typos, LLNI_direct is called + LLNI_DIRECT. + [0def6a684fde] + + * src/cacaoh/dummy.c, src/native/Makefile.am, src/native/llni.c, + src/native/llni.h, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/native/Makefile.am: Added llni.c. + + * src/native/llni.c: Added new file. (llni_critical_start, + llni_critical_end): Implemented. + + * src/native/llni.h: Major cleanup of LLNI macros + (LLNI_CRITICAL_START, LLNI_CRITICAL_END): Added. + + * src/cacaoh/dummy.c (llni_critical_start, llni_critical_end): Added + dummies. + [af75957ea4fa] + +2007-08-20 twisti + + * src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vmcore/utf8.c (utf_uncaughtException): Added. + (utf_java_lang_Thread_java_lang_Throwable__V): Likewise. + (utf8_init): Initialize new variables. + * src/vmcore/utf8.h: Likewise. + [3ab11f4e0235] + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_init) [WITH_CLASSPATH_SUN]: + Added code to initialize the thread. (threads_startup_thread): + Ignore the return value of threads_detach_thread. + (threads_detach_thread) [ENABLE_JAVASE]: Implemented + UncaughtExceptionHandler stuff. + [65df7c9c179f] + +2007-08-20 michi + + * src/native/localref.c: + * src/native/localref.c (localref_add): Disabled debug output. + [97af6afc71f6] + + * src/native/jni.c, src/native/localref.c, src/native/localref.h: + * src/native/localref.c (localref_add): Implemented (moved parts + from jni.c). [!NDEBUG] (localref_dump): Improved debug output. + + * src/native/localref.h: Added prototypes. + + * src/native/jni.c (_Jv_JNI_NewLocalRef): Now uses localref_add. + [e792a0c22d3d] + + * src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getClassLoader) [ENABLE_HANDLES]: Fixed + implementation. + + * src/native/vm/gnu/java_lang_VMSystem.c + (Java_java_lang_VMSystem_identityHashCode) [ENABLE_GC_CACAO]: + Likewise. + [3d0ca306dc19] + + * src/native/jni.c, src/native/localref.c, src/native/localref.h, + src/vm/vm.c: + * src/native/localref.c (localref_table_destroy): Added (moved from + jni.c). Improved documentation. + + * src/native/localref.h: Likewise. + + * src/native/jni.c (jni_free_localref_table): Removed. + + * src/vm/vm.c (vm_createjvm): Added comment about localreftable. + [329d0c1a2734] + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Fixed bug + in stackframesize calculation. + [d759d431071b] + + * src/cacaoh/dummy.c, src/mm/cacao-gc/heap.h, + src/threads/native/threads.c, src/threads/threads-common.c, + src/vm/builtin.c, src/vm/builtin.h, src/vm/signal.c: + * src/vm/signal.c (signal_init): Use signal_register_signal to + register SIGUSR1. + + * src/vm/builtin.c: Adapted to changes on trunk. + * src/vm/builtin.h: Likewise. + * src/mm/cacao-gc/heap.h: Likewise. + * src/threads/threads-common.c: Likewise. + * src/threads/native/threads.c: Likewise. + * src/cacaoh/dummy.c: Likewise. + [173e158ebcbc] + + * configure.ac, src/mm/cacao-gc/gc.c, src/vm/global.h, + src/vmcore/loader.c: + * configure.ac: Checks for --enable-handles and sets define + accordingly. + + * src/vm/global.h (java_handle_t): Changed ifdef to use + ENABLE_HANDLES. + + * src/vmcore/loader.c (load_class_from_classloader): Likewise + + * src/mm/cacao-gc/gc.c (gc_init) [ENABLE_HANDLES]: Ifdefed offset + check of indirection cells. + [78bdf2b86dea] + + * configure.ac, src/Makefile.am, src/lib/Makefile.am, + src/native/include/Makefile.am, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/java_lang_String.c, src/native/vm/java_lang_String.h, + src/threads/threads-common.h, src/vm/builtin.c, + src/vm/builtintable.inc, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, src/vm/jit/trace.c, + src/vm/jit/trace.h, src/vm/properties.c, src/vm/stringlocal.h, + src/vmcore/zip.c: + * src/vm/builtin.c (builtintable_init): Create builtin stubs for + builtintable_function as well. + + * src/vm/builtintable.inc (builtintable_function): Create stubs for + arraycopy. + [2120e8901106] + +2007-08-19 twisti + + * src/native/vm/Makefile.am, src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_String.c, + src/native/vm/java_lang_String.h, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/vm/string.c, src/vm/stringlocal.h: + * src/vm/string.c (javastring_intern): New function. + (javastring_print): Likewise. + * src/vm/stringlocal.h + + * src/native/vm/java_lang_String.c: Removed. + * src/native/vm/java_lang_String.h: Likewise. + + * src/native/vm/cldc1.1/java_lang_String.c (intern): Use + javastring_intern. + + * src/native/vm/java_lang_Class.c (native/vm/java_lang_String.h): + Removed. + + * src/native/vm/gnu/java_lang_VMString.c + (native/vm/java_lang_String.h): Removed. (intern): Use + javastring_intern. + + * src/native/vm/sun/jvm.c (native/vm/java_lang_String.h): Removed. + (JVM_GetSystemPackage): Added debug output. + + * src/native/vm/reflect.c (native/vm/java_lang_String.h): Removed. + (reflect_field_new): Use javastring_intern. (reflect_method_new): + Likewise. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Removed + java_lang_String.[ch]. + [92115007d820] + + * src/threads/threads-common.h: + * src/threads/threads-common.h (THREAD_STATE_*): Changed to be + compatible with OpenJDK (range 1-6). + [c0232448e92f] + + * src/vm/signal.c, src/vm/signallocal.h: + * src/vm/signal.c (signal_init) [!WITH_CLASSPATH_SUN]: Only block + SIGINT for non-Sun configurations. (signal_thread): Use + signal_thread_handler. (signal_thread_handler): New function. + + * src/vm/signallocal.h (signal_thread_handler): New function. + [35c1b5347341] + + * src/vm/primitive.c: + * src/vm/primitive.c (primitive_box): Handle PRIMITIVETYPE_VOID + type. (primitive_unbox): Likewise. + [076fc6bc3012] + +2007-08-19 pm + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/emit.c: + * src/vm/jit/s390/asmpart.S: Made all function calls PIC (see bug + 41), general cleanup. + * src/vm/jit/s390/emit.c (emit_verbosecall_enter): Save and restore + temporary registers for leaf methods. + [0ab89839950f] + +2007-08-19 twisti + + * configure.ac, src/vm/properties.c, src/vm/vm.c: + * configure.ac (JAVA_ARCH): Added. + + * src/vm/vm.c (opts): Added Xverify:none (should be handled better). + (vm_create) [WITH_JRE_LAYOUT && WITH_CLASSPATH_SUN]: Implemented. + + * src/vm/properties.c (properties_init) [WITH_CLASSPATH_GNU]: Use + JAVA_ARCH. + [1e132391622d] + + * src/vmcore/linker.c: + * src/vmcore/linker.c (link_class): Check for CLASS_LINKING. + (link_class_intern): Removed CLASS_LINKED check, but added an + assert. + [986a66aea815] + +2007-08-19 panzi + + * src/native/vm/sun/jvm.c, tests/regression/Makefile.am, + tests/regression/TestAnnotations.java, + tests/regression/TestAnnotations.output: + * src/native/vm/sun/jvm.c (JVM_GetArrayElement): Using + array_xxxarray_element_get functions now. + + * tests/regression/TestAnnotations.output: Added. + + * tests/regression/Makefile.am (SOURCE_FILES): Added + TestAnnotations.java. (EXTRA_DIST): Added TestAnnotations.output. + (OUTPUT_JAVA_TESTS): Added TestAnnotations. + + * tests/regression/TestAnnotations.java: Added detailed test cases + for annotations support. + [23f039edde88] + +2007-08-19 pm + + * src/vm/builtin.c, src/vm/jit/s390/md.c, src/vm/jit/trace.c, + src/vm/jit/trace.h: + * vm/builtin.c (builtin_trace_exception) [__s390__]: Decrement + TRACEJAVACALLINDENT instead of methodindent. + * vm/jit/trace.h: Adapted file to coding conventions. + * vm/jit/trace.c: Likewise. + * vm/jit/s390/md.c (md_dump_context) Fixed printing of java method at + failing address, (md_signal_handler_sigsegv) added missing default + branch to switch. + [512e17a366d4] + +2007-08-18 twisti + + * src/Makefile.am, src/lib/Makefile.am, + src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java, + src/native/include/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, src/vmcore/zip.c, + src/vmcore/zip.h: + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c + (zip_read_resource, file_read_resource, + Java_com_sun_cldc_io_ResourceInputStream_open, + Java_com_sun_cldc_io_ResourceInputStream_bytesRemain, + Java_com_sun_cldc_io_ResourceInputStream_readByte, + Java_com_sun_cldc_io_ResourceInputStream_readBytes, + Java_com_sun_cldc_io_ResourceInputStream_clone): Used LLNI macros, + implemented missing methods + + * src/native/vm/cldc1.1/java_lang_Object.c (native/llni.h): Added + * src/native/vm/cldc1.1/java_lang_Class.c: Likewise + + * src/native/vm/cldc1.1/java_lang_String.c + (Java_java_lang_String_hashCode, Java_java_lang_String_indexOf__I, + Java_java_lang_String_indexOf__II, + Java_java_lang_String_lastIndexOf__I + Java_java_lang_String_lastIndexOf__II, Java_java_lang_String_equals, + Java_java_lang_String_intern): Used LLNI macros + * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c + (Java_com_sun_cldc_io_j2me_socket_Protocol_open0, + Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf, + Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf): Likewise + + * src/native/vm/cldc1.1/java_lang_System.c + (Java_java_lang_System_arraycopy): Replaced java_arrayheader by + java_handle_t. + + * src/vmcore/zip.c: Moved LFH struct to zip.h. + * src/vmcore/zip.h: Likewise. + + * src/lib/cldc1.1/com/sun/cldchi/jvm/FileDescriptor.java: New file. + + * src/lib/Makefile.am: Changed to build vm.zip for cldc1.1. + * src/native/include/Makefile.am: Likewise. + * src/Makefile.am: Likewise. + [2fc98ecf203f] + +2007-08-17 twisti + + * src/native/vm/gnu/sun_reflect_ConstantPool.c: + * src/native/vm/gnu/sun_reflect_ConstantPool.c: Added Id keyword. + [3d57b610af51] + + * src/native/vm/gnu/sun_reflect_ConstantPool.c: + * src/native/vm/gnu/sun_reflect_ConstantPool.c (native/llni.h): + Added. (boilerplate): Likewise. + [71fc7522fbbd] + + * src/native/llni.h, src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/reflect.c, src/native/vm/sun/jvm.c, + src/vm/Makefile.am, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/string.c, src/vmcore/class.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.h, + src/vmcore/method.c, src/vmcore/method.h, + tests/regression/Makefile.am: + * src/vmcore/class.h (classinfo): Removed ENABLE_JAVASE for + enclosingclass and enclosingmethod. I don't think we can save that + much memory for CLDC configurations and it keeps the codebase + cleaner. + [6845be9d4d5c] + +2007-08-17 michi + + * NEWS, src/native/jni.c, src/native/llni.h, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c, + src/vm/Makefile.am, src/vm/array.c, src/vm/array.h, + src/vm/builtin.c, src/vm/global.h, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/verify/typecheck- + stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/primitive.c, src/vm/primitive.h, src/vm/string.c, + src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c, + src/vmcore/linker.h, src/vmcore/loader.c, src/vmcore/method.c, + src/vmcore/method.h, tests/regression/Makefile.am, + tests/regression/MinimalClassReflection.java, + tests/regression/MinimalClassReflection.output: + Merged revisions 8321-8342 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8322 | twisti | 2007-08-16 17:54:38 +0200 (Thu, 16 Aug + 2007) | 16 lines + + * src/vmcore/method.c (method_get_annotations): Always enable the + method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code + calling this function simpler. (method_get_parameterannotations): + Likewise. (method_get_annotationdefault): Likewise. + + * src/vmcore/method.h (method_get_annotations): Removed + ENABLE_ANNOTATIONS. (method_get_parameterannotations): Likewise. + (method_get_annotationdefault): Likewise. + + * src/native/vm/reflect.c (reflect_constructor_new): Always call + method-annotations functions. (reflect_field_new): Likewise. + (reflect_method_new): Likewise. ........ r8323 | twisti | + 2007-08-16 18:01:05 +0200 (Thu, 16 Aug 2007) | 3 lines + + * src/native/vm/sun/jvm.c (JVM_FindPrimitiveClass): Use + TRACEJVMCALLS and a better implementation. ........ r8325 | + twisti | 2007-08-16 19:25:47 +0200 (Thu, 16 Aug 2007) | 7 lines + + * src/vmcore/field.c (field_get_annotations): Always enable the + method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code + calling this function simpler. + + * src/vmcore/field.h (field_get_annotations): Removed + ENABLE_ANNOTATIONS. ........ r8326 | twisti | 2007-08-16 19:45:49 + +0200 (Thu, 16 Aug 2007) | 12 lines + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (declaredAnnotations): Use byte-array handle. Don't check for this + == NULL , this cannot happen. (getParameterAnnotations): + Likewise. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (declaredAnnotations): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (declaredAnnotations): Likewise. (getParameterAnnotations): + Likewise. ........ r8327 | twisti | 2007-08-16 19:52:48 +0200 + (Thu, 16 Aug 2007) | 8 lines + + * src/vm/primitive.c (primitive_type_get_by_wrapperclass): New + function. (primitive_unbox): Changed signature. + * src/vm/primitive.h: Likewise. + + * src/vm/vm.c (vm_array_from_objectarray): Rewritten to use + primitive-unbox function. ........ r8328 | twisti | 2007-08-16 + 19:56:19 +0200 (Thu, 16 Aug 2007) | 3 lines + + * src/vm/vm.c (vm_array_from_objectarray): Use + primitive_type_get_by_wrapperclass (typo). Removed debug output. + ........ r8329 | twisti | 2007-08-16 19:57:27 +0200 (Thu, 16 Aug + 2007) | 3 lines + + * src/vm/vm.c (XXusage): Commented. We don't use it anymore but + we keep it to know which switches still need to be converted. + ........ r8330 | twisti | 2007-08-16 20:15:51 +0200 (Thu, 16 Aug + 2007) | 25 lines + + * src/vm/array.c: New file. + * src/vm/array.h: Likewise. + + * src/vm/Makefile.am (libvm_la_SOURCES): Added array.[ch]. + + * src/vm/builtin.c, src/vm/string.c, src/vm/jit/verify + /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typeinfo.c, src/vmcore/linker.c (vm/array.h): + Added. + + * src/vm/primitive.h (ARRAYTYPE_*): Moved to vm/array.h + + * src/vmcore/class.c (class_get_componenttype): New function. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (getComponentType): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + + * src/native/vm/gnu/java_lang_VMClass.c (getComponentType): Call + class_get_componenttype. + * src/native/vm/sun/jvm.c (JVM_GetComponentType): Likewise. ........ + r8331 | panzi | 2007-08-16 21:21:39 +0200 (Thu, 16 Aug 2007) | 16 + lines + + * src/native/vm/sun/jvm.c (vm/array.h): Added include. + (vm/global.h): Added include. (JVM_FindPrimitiveClass): Parameter + name shadowed type utf. (JVM_GetComponentType): Missing variable + classinfo* c. (JVM_GetClassAnnotations): java_bytearray -> + java_handle_bytearray_t. (JVM_GetFieldAnnotations): java_bytearray + -> java_handle_bytearray_t. (JVM_GetMethodAnnotations): + java_bytearray -> java_handle_bytearray_t. + (JVM_GetMethodDefaultAnnotationValue): java_bytearray -> + java_handle_bytearray_t. (JVM_GetMethodParameterAnnotations): + java_bytearray -> java_handle_bytearray_t. (JVM_GetArrayLength): + java_arrayheader -> java_array_t. (JVM_GetArrayElement): Updated + types, renamed wrong named variable. + + * src/vmcore/linker.h: (_vftbl): Fixed formatting of comment. + ........ r8332 | panzi | 2007-08-16 21:29:42 +0200 (Thu, 16 Aug + 2007) | 5 lines + + * src/native/vm/sun/jvm.c (JVM_GetArrayElement): Used + exceptions_new_arrayindexoutofboundsexception where + exceptions_throw_arrayindexoutofboundsexception should have been + used. ........ r8333 | pm | 2007-08-16 23:46:32 +0200 (Thu, 16 Aug + 2007) | 2 lines + + * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Return NULL + as default. ........ r8334 | ajordan | 2007-08-17 00:10:43 +0200 + (Fri, 17 Aug 2007) | 5 lines + + * src/vm/jit/sparc64/codegen.h: Improved overflow checking. + + * src/vm/jit/sparc64/codegen.c (check_13bit_imm): Likewise. + (codegen_emit): Fixed ICDM_TABLESWITCH for large negative values. + ........ r8338 | panzi | 2007-08-17 22:03:06 +0200 (Fri, 17 Aug + 2007) | 10 lines + + * tests/regression/MinimalClassReflection.output: New file. + * tests/regression/MinimalClassReflection.java: New file. This adds + tests for some reflection methods like + java.lang.Class.isLocal/.isMember/.isAnonymous/.getDeclaringClass + etc. + + * tests/regression/Makefile.am (SOURCE_FILES): Added + MinimalClassReflection.java. (EXTRA_DIST): Added + MinimalClassReflection.output. (OUTPUT_JAVA_TESTS): Added + MinimalClassReflection. ........ r8339 | twisti | 2007-08-17 + 23:21:51 +0200 (Fri, 17 Aug 2007) | 37 lines + + * src/vm/global.h (ACC_CLASS_MEMBER): New define. + (ACC_CLASS_ANONYMOUS): Likewise. + + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getEnclosingClass): Removed. + (_Jv_java_lang_Class_getEnclosingMethod_intern): Use + class_get_enclosingclass. + + * src/native/vm/java_lang_Class.h + (_Jv_java_lang_Class_getEnclosingClass): Removed. + + * src/native/vm/gnu/java_lang_VMClass.c (stdint.h): Added. + (vmcore/class.h): Likewise. (methods): Enabled isAnonymousClass, + isLocalClass and isMemberClass. + (Java_java_lang_VMClass_getEnclosingClass): Use + class_get_enclosingclass. (isAnonymousClass): Implemented. + (isLocalClass): Likewise. (isMemberClass): Likewise. + + * src/vmcore/class.c (class_load_attributes): Set ACC_CLASS_MEMBER + and ACC_CLASS_ANONYMOUS flags. (class_is_anonymousclass): New + function. (class_is_localclass): Likewise. + (class_is_memberclass): Likewise. (class_get_declaredclasses): + Check if outer is NULL. (class_get_declaringclass): Rewritten to + use c->declaringclass. (class_get_enclosingclass): New function. + + * src/vmcore/class.h (classinfo): Added declaringclass.( + (class_is_anonymousclass): New function. (class_is_localclass): + Likewise. (class_is_memberclass): Likewise. + (class_get_enclosingclass): Likewise. + + * NEWS: Added news. ........ r8340 | twisti | 2007-08-17 + 23:28:29 +0200 (Fri, 17 Aug 2007) | 2 lines + + * src/native/vm/gnu/java_lang_VMClass.c (getEnclosingClass): Typo. + ........ r8341 | michi | 2007-08-17 23:32:01 +0200 (Fri, 17 Aug + 2007) | 21 lines + + * src/native/llni.h (LLNI_classinfo_wrap, LLNI_classinfo_unwrap): + Added new macros. + + Used above two LLNI macros throughout the codebase: + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/cldc1.1/java_lang_Class.c + * src/native/vm/cldc1.1/java_lang_Object.c + * src/native/vm/java_lang_Class.c + * src/native/vm/java_lang_Object.c + * src/native/vm/gnu/java_lang_VMClassLoader.c + * src/native/vm/gnu/java_lang_VMClass.c + * src/native/vm/gnu/sun_reflect_ConstantPool.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/java_lang_reflect_Field.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/sun/jvm.c + * src/native/vm/reflect.c + * src/vmcore/loader.c ........ + [240844a0096e] + + * src/mm/cacao-gc/heap.c, src/mm/cacao-gc/heap.h, src/mm/cacao- + gc/mark.c, src/native/llni.h, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + tests/regression/Makefile.am: + * src/mm/cacao-gc/heap.c: Adapted to changes on trunk. + * src/mm/cacao-gc/heap.h: Likewise. + * src/mm/cacao-gc/mark.c: Likewise. + [494586254561] + + * src/native/jni.c, src/native/llni.h, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c, + src/vmcore/loader.c: + * src/native/llni.h (LLNI_classinfo_wrap, LLNI_classinfo_unwrap): + Added new macros. + + Used above two LLNI macros throughout the codebase: + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/cldc1.1/java_lang_Class.c + * src/native/vm/cldc1.1/java_lang_Object.c + * src/native/vm/java_lang_Class.c + * src/native/vm/java_lang_Object.c + * src/native/vm/gnu/java_lang_VMClassLoader.c + * src/native/vm/gnu/java_lang_VMClass.c + * src/native/vm/gnu/sun_reflect_ConstantPool.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/java_lang_reflect_Field.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/sun/jvm.c + * src/native/vm/reflect.c + * src/vmcore/loader.c + [4ad817520fb4] + +2007-08-17 twisti + + * src/native/vm/gnu/java_lang_VMClass.c: + * src/native/vm/gnu/java_lang_VMClass.c (getEnclosingClass): Typo. + [2ef182095ae1] + + * NEWS, src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/vm/global.h, src/vmcore/class.c, src/vmcore/class.h: + * src/vm/global.h (ACC_CLASS_MEMBER): New define. + (ACC_CLASS_ANONYMOUS): Likewise. + + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getEnclosingClass): Removed. + (_Jv_java_lang_Class_getEnclosingMethod_intern): Use + class_get_enclosingclass. + + * src/native/vm/java_lang_Class.h + (_Jv_java_lang_Class_getEnclosingClass): Removed. + + * src/native/vm/gnu/java_lang_VMClass.c (stdint.h): Added. + (vmcore/class.h): Likewise. (methods): Enabled isAnonymousClass, + isLocalClass and isMemberClass. + (Java_java_lang_VMClass_getEnclosingClass): Use + class_get_enclosingclass. (isAnonymousClass): Implemented. + (isLocalClass): Likewise. (isMemberClass): Likewise. + + * src/vmcore/class.c (class_load_attributes): Set ACC_CLASS_MEMBER + and ACC_CLASS_ANONYMOUS flags. (class_is_anonymousclass): New + function. (class_is_localclass): Likewise. (class_is_memberclass): + Likewise. (class_get_declaredclasses): Check if outer is NULL. + (class_get_declaringclass): Rewritten to use c->declaringclass. + (class_get_enclosingclass): New function. + + * src/vmcore/class.h (classinfo): Added declaringclass.( + (class_is_anonymousclass): New function. (class_is_localclass): + Likewise. (class_is_memberclass): Likewise. + (class_get_enclosingclass): Likewise. + + * NEWS: Added news. + [182b913bd9cf] + +2007-08-17 panzi + + * tests/regression/Makefile.am, + tests/regression/MinimalClassReflection.java, + tests/regression/MinimalClassReflection.output: + * tests/regression/MinimalClassReflection.output: New file. + * tests/regression/MinimalClassReflection.java: New file. This adds + tests for some reflection methods like + java.lang.Class.isLocal/.isMember/.isAnonymous/.getDeclaringClass + etc. + + * tests/regression/Makefile.am (SOURCE_FILES): Added + MinimalClassReflection.java. (EXTRA_DIST): Added + MinimalClassReflection.output. (OUTPUT_JAVA_TESTS): Added + MinimalClassReflection. + [1aaec4ee70e9] + +2007-08-17 michi + + * src/native/native.c, src/native/native.h: + * src/native/native.h (hashtable_library_loader_entry): Classloader + is represented by the classloader typedef. + + * src/native/native.c (native_library_add, native_library_find): + Classloader does not need to be registered again. + [ee38e3ef5c76] + + * src/vmcore/class.h: + * src/vmcore/class.h (classinfo): Added missing endif. + [f4bf74880e4f] + + * src/native/jni.c, src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/sun_misc_Unsafe.c, src/vm/Makefile.am, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/primitive.c, src/vm/primitive.h, src/vm/string.c, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.h, + src/vmcore/loader.c: + * src/vmcore/loader.c (load_class_from_classloader) + [!ENABLE_GC_CACAO]: Pass object instead of classloader entry to + function. + + * src/native/jni.c (_Jv_JNI_DefineClass): Register classloader. + + * src/native/vm/gnu/java_lang_VMRuntime.c + (Java_java_lang_VMRuntime_nativeLoad): Likewise. + + * src/native/vm/sun_misc_Unsafe.c + (Java_sun_misc_Unsafe_defineClass): Likewise. + + * src/native/vm/gnu/java_lang_VMClassLoader.c + (Java_java_lang_VMClassLoader_findLoadedClass): Search for + classloader instead of adding a new one. + + * src/native/vm/java_lang_Class.c: Fixed compiler warning. + + * src/native/vm/java_lang_ClassLoader.c: Likewise. + [7e8c5c18b712] + +2007-08-16 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h: + * src/vm/jit/sparc64/codegen.h: Improved overflow checking. + + * src/vm/jit/sparc64/codegen.c (check_13bit_imm): Likewise. + (codegen_emit): Fixed ICDM_TABLESWITCH for large negative values. + [8036df17dadb] + +2007-08-16 pm + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Return NULL as + default. + [db907e41086f] + +2007-08-16 panzi + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetArrayElement): Used + exceptions_new_arrayindexoutofboundsexception where + exceptions_throw_arrayindexoutofboundsexception should have been + used. + [33a38fdcba8e] + + * src/native/vm/sun/jvm.c, src/vmcore/linker.h: + * src/native/vm/sun/jvm.c (vm/array.h): Added include. + (vm/global.h): Added include. (JVM_FindPrimitiveClass): Parameter + name shadowed type utf. (JVM_GetComponentType): Missing variable + classinfo* c. (JVM_GetClassAnnotations): java_bytearray -> + java_handle_bytearray_t. (JVM_GetFieldAnnotations): java_bytearray + -> java_handle_bytearray_t. (JVM_GetMethodAnnotations): + java_bytearray -> java_handle_bytearray_t. + (JVM_GetMethodDefaultAnnotationValue): java_bytearray -> + java_handle_bytearray_t. (JVM_GetMethodParameterAnnotations): + java_bytearray -> java_handle_bytearray_t. (JVM_GetArrayLength): + java_arrayheader -> java_array_t. (JVM_GetArrayElement): Updated + types, renamed wrong named variable. + + * src/vmcore/linker.h: (_vftbl): Fixed formatting of comment. + [e13b6e6c0d15] + +2007-08-16 twisti + + * src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/sun/jvm.c, src/vm/Makefile.am, src/vm/array.c, + src/vm/array.h, src/vm/builtin.c, src/vm/jit/verify/typecheck- + stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/primitive.h, src/vm/string.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/linker.c: + * src/vm/array.c: New file. + * src/vm/array.h: Likewise. + + * src/vm/Makefile.am (libvm_la_SOURCES): Added array.[ch]. + + * src/vm/builtin.c, src/vm/string.c, src/vm/jit/verify/typecheck- + typeinferer.c, src/vm/jit/verify/typecheck.c, src/vm/jit/verify + /typecheck-stackbased.c, src/vm/jit/verify/typeinfo.c, + src/vmcore/linker.c (vm/array.h): Added. + + * src/vm/primitive.h (ARRAYTYPE_*): Moved to vm/array.h + + * src/vmcore/class.c (class_get_componenttype): New function. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (getComponentType): Removed. + * src/native/vm/java_lang_Class.h: Likewise. + + * src/native/vm/gnu/java_lang_VMClass.c (getComponentType): Call + class_get_componenttype. + * src/native/vm/sun/jvm.c (JVM_GetComponentType): Likewise. + [1f7cf6d1342f] + + * src/vm/vm.c: + * src/vm/vm.c (XXusage): Commented. We don't use it anymore but we + keep it to know which switches still need to be converted. + [0a022dbb5571] + + * src/vm/vm.c: + * src/vm/vm.c (vm_array_from_objectarray): Use + primitive_type_get_by_wrapperclass (typo). Removed debug output. + [7c74a6c74478] + + * src/vm/primitive.c, src/vm/primitive.h, src/vm/vm.c: + * src/vm/primitive.c (primitive_type_get_by_wrapperclass): New + function. (primitive_unbox): Changed signature. + * src/vm/primitive.h: Likewise. + + * src/vm/vm.c (vm_array_from_objectarray): Rewritten to use + primitive-unbox function. + [d1bb1464fa01] + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (declaredAnnotations): Use byte-array handle. Don't check for this + == NULL , this cannot happen. (getParameterAnnotations): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Field.c (declaredAnnotations): + Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (declaredAnnotations): Likewise. (getParameterAnnotations): + Likewise. + [a671d0338b15] + + * src/vmcore/field.c, src/vmcore/field.h: + * src/vmcore/field.c (field_get_annotations): Always enable the + method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code + calling this function simpler. + + * src/vmcore/field.h (field_get_annotations): Removed + ENABLE_ANNOTATIONS. + [43879e6b20c2] + +2007-08-16 michi + + * src/mm/cacao-gc/gc.c, src/native/vm/reflect.c, + src/native/vm/sun/jvm.c, src/vm/global.h, src/vmcore/loader.c, + src/vmcore/loader.h, src/vmcore/method.c, src/vmcore/method.h: + * src/vm/global.h [ENABLE_GC_CACAO] (java_handle_t): Made the handle + an its array pendants real indirection cells. + + * src/mm/cacao-gc/gc.c (gc_init): Check the offset of the + indirection cells. + + * src/vmcore/loader.h (hashtable_classloader_entry): Added attention + notice about the entry used as indirection cell. + + * src/vmcore/loader.c (loader_hashtable_classloader_add): Used LLNI + critical sections to search and register classloader objects. + (loader_hashtable_classloader_find): Likewise. + [6d7c2d0e5a6d] + +2007-08-16 twisti + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_FindPrimitiveClass): Use + TRACEJVMCALLS and a better implementation. + [53db5a1b83ed] + + * src/native/vm/reflect.c, src/vmcore/method.c, src/vmcore/method.h: + * src/vmcore/method.c (method_get_annotations): Always enable the + method, but return NULL for !ENABLE_ANNOTATIONS. This keeps code + calling this function simpler. (method_get_parameterannotations): + Likewise. (method_get_annotationdefault): Likewise. + + * src/vmcore/method.h (method_get_annotations): Removed + ENABLE_ANNOTATIONS. (method_get_parameterannotations): Likewise. + (method_get_annotationdefault): Likewise. + + * src/native/vm/reflect.c (reflect_constructor_new): Always call + method-annotations functions. (reflect_field_new): Likewise. + (reflect_method_new): Likewise. + [dd8e95b3b98a] + +2007-08-16 michi + + * configure.ac, src/cacaoh/dummy.c, src/cacaoh/headers.c, + src/cacaoh/headers.h, src/native/jni.c, src/native/jni.h, + src/native/localref.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_ClassLoader.h, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h, + src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/vm/access.c, src/vm/builtin.c, src/vm/builtin.h, + src/vm/exceptions.c, src/vm/global.h, src/vm/jit/Makefile.am, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, src/vm/signal.c, src/vm/signallocal.h, + src/vm/string.c, src/vm/stringlocal.h, src/vm/vm.c, src/vm/vm.h, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/field.c, + src/vmcore/field.h, src/vmcore/linker.c, src/vmcore/method.c, + src/vmcore/method.h: + Merged revisions 8299-8320 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8300 | michi | 2007-08-13 12:23:20 +0200 (Mon, 13 Aug + 2007) | 2 lines + + * src/native/localref.c (localref_table_remove): Fixed assertion. + ........ r8301 | twisti | 2007-08-13 15:34:12 +0200 (Mon, 13 Aug + 2007) | 5 lines + + * configure.ac (dl): Check for dl before all other stuff. + (AC_CHECK_ENABLE_LIBJVM): Added. + + * m4/libjvm.m4: New file. ........ r8303 | twisti | 2007-08-13 + 21:01:52 +0200 (Mon, 13 Aug 2007) | 2 lines + + * src/vm/exceptions.c (exceptions_print_exception): Fixed typo. + ........ r8304 | pm | 2007-08-14 21:57:20 +0200 (Tue, 14 Aug 2007) + | 9 lines + + * src/threads/none/threads.h [!defined(NDEBUG)] + (_no_threads_tracejavacallindent, _no_threads_tracejavacallcount, + TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added. + * src/threads/native/threads.h [!defined(NDEBUG)] (threadinfo): Added + tracejavacallindent, tracejavacallcount members. + (TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added. + * src/threads/native/threads.c: Likewise. + * src/vm/jit/trace.h New file. + * src/vm/jit/trace.c: Likewise. + * src/vm/jit/Makefile.am (libjit_la_SOURCES): added trace.h and + trace.c. + * src/vm/jit/s390/emit.c (emit_verbosecall_enter): adpated to use + trace_java_call_enter, (emit_verbosecall_exit): adapted to use + trace_java_call_exit. ........ r8305 | panzi | 2007-08-15 15:49:26 + +0200 (Wed, 15 Aug 2007) | 34 lines + + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getDeclaredAnnotations): Use LLNI_* macro. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_getDefaultValue): Use LLNI_* macros. + (Java_java_lang_reflect_Method_declaredAnnotations): Use LLNI_* + macros. (Java_java_lang_reflect_Method_getParameterAnnotations): + Use LLNI_* macros. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (Java_java_lang_reflect_Field_declaredAnnotations): Use LLNI_* + macros. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (Java_java_lang_reflect_Constructor_declaredAnnotations): Use LLNI_* + macros. + (Java_java_lang_reflect_Constructor_getParameterAnnotations): Use + LLNI_* macros. + + * src/native/vm/sun/jvm.c (native/llni.h): Added include. + (JVM_GetFieldAnnotations): Use LLNI_* macros. + (JVM_GetMethodAnnotations): Use LLNI_* macros. + (JVM_GetMethodDefaultAnnotationValue): Use LLNI_* macros. + (JVM_GetMethodParameterAnnotations): Use LLNI_* macros. + (JVM_GetClassConstantPool): Use LLNI_* macros. + + * src/native/vm/reflect.c (reflect_constructor_new): Forgot to + set annotations and parameterAnnotations attributes for GNU + Classpath. (reflect_get_declaredannotatios): Use LLNI_* macros. + (reflect_get_parameterannotations): Use LLNI_* macros. + + * src/native/vm/reflect.h (reflect_get_declaredannotatios): Now + the caller has to set the declaredAnnotations attribute of the + according object itself, because the LLNI_* macros can't get the + address of an field. ........ r8306 | twisti | 2007-08-15 16:47:11 + +0200 (Wed, 15 Aug 2007) | 5 lines + + * src/vm/signal.c (signal_init): Cast to functionptr to fix + warnings. (signal_register_signal): Changed signature. + + * src/vm/signallocal.h (signal_register_signal): Likewise. + ........ r8307 | twisti | 2007-08-15 17:20:47 +0200 (Wed, 15 Aug + 2007) | 7 lines + + * src/vmcore/class.c (class_get_interfaces): New function. + * src/vmcore/class.h (class_get_interfaces): Likewise. + + * src/native/vm/java_lang_Class.c (getSuperclass): Cast return + value. (getInterfaces): Use class_get_interfaces. + * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Likewise. ........ + r8308 | pm | 2007-08-15 18:03:28 +0200 (Wed, 15 Aug 2007) | 2 lines + + * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Argument to + ioctl is int *. ........ r8309 | twisti | 2007-08-15 18:42:52 + +0200 (Wed, 15 Aug 2007) | 10 lines + + * src/vmcore/class.c (vm/builtin.h): Added. + (class_get_declaredclasses): New function. + + * src/vmcore/class.h (class_get_declaredclasses): Likewise. + + * src/native/vm/java_lang_Class.c (getDeclaredClasses): Use + class_get_declaredclasses. + + * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Likewise. + ........ r8310 | twisti | 2007-08-15 18:49:03 +0200 (Wed, 15 Aug + 2007) | 3 lines + + * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Bugfix, forgot + to set c. ........ r8311 | panzi | 2007-08-15 19:03:40 +0200 + (Wed, 15 Aug 2007) | 20 lines + + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. + + * src/native/vm/gnu/sun_reflect_ConstantPool.c + (vm/stringlocal.h): Added include. + (Java_sun_reflect_ConstantPool_getClassAtIfLoaded0): Removed wrong + call of the macro TRACEJVMCALLS. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_getDefaultValue): Added proper casts + so gcc don't give me warnings. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + [ENABLE_ANNOTATIONS] (vm/exceptions.h): Added include. + + * src/native/vm/sun/jvm.c (JVM_ConstantPoolGetStringAt): + Corrected cast. (JVM_ConstantPoolGetUTF8At): Corrected cast. + (JVM_GetArrayElement): Using primitive_box_* functions. ........ + r8312 | twisti | 2007-08-16 00:10:22 +0200 (Thu, 16 Aug 2007) | 2 + lines + + * src/native/jni.c (native/localref.h): Added. ........ r8313 | + twisti | 2007-08-16 00:11:35 +0200 (Thu, 16 Aug 2007) | 4 lines + + * src/native/localref.c: Added Id keyword. + * src/native/localref.h: Likewise. + * src/native/llni.h: Likewise. ........ r8314 | twisti | 2007-08-16 + 00:18:44 +0200 (Thu, 16 Aug 2007) | 2 lines + + * src/vm/jit/codegen-common.c (native/localref.h): Added. ........ + r8315 | panzi | 2007-08-16 00:49:20 +0200 (Thu, 16 Aug 2007) | 28 + lines + + * src/native/vm/reflect.c (reflect_constructor_new): Allocation + of the java_bytearray is now done in the method_get_* functions. + (reflect_field_new): Allocation of the java_bytearray is now done in + the field_get_* functions. (reflect_method_new): Allocation of + the java_bytearray is now done in the method_get_* functions. + Added use of LLNI_field_* macros. + + * src/vmcore/method.c (method_get_annotations): Do allocation of + the java_bytearray here. (method_get_parameterannotations): Do + allocation of the java_bytearray here. + (method_get_annotationdefault): Do allocation of the java_bytearray + here. + + * src/vmcore/method.h (method_get_annotations): This function + now returns java_bytearray*. (method_get_parameterannotations): + This function now returns java_bytearray*. + (method_get_annotationdefault): This function now returns + java_bytearray*. + + * src/vmcore/field.c (vm/builtin.h): Added include. + (field_get_annotations): Do allocation of the java_bytearray here. + + * src/vmcore/field.h (field_get_annotations): This function now + returns java_bytearray*. + + * src/cacaoh/dummy.c (builtin_newarray_byte): Added. ........ + r8316 | ajordan | 2007-08-16 01:32:57 +0200 (Thu, 16 Aug 2007) | 6 + lines + + * src/vm/jit/sparc64/codegen.h: Added M_SAVE_REG and 13-bit + overflow checking. + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed stack + increasing for large stackframe sizes. (check_13bit_imm): Added + for overflow checking. ........ r8317 | pm | 2007-08-16 08:53:26 + +0200 (Thu, 16 Aug 2007) | 2 lines + + * src/vm/jit/trace (_array_load_param) [SIZEOF_VOID_P == 8]: + Bugfix, forgotten obsolete stack_offset. ........ r8318 | michi | + 2007-08-16 12:05:34 +0200 (Thu, 16 Aug 2007) | 70 lines + + * src/native/llni.h: Added macros for array handling. + + * src/vm/global.h: Added typedefs for array handles. Renamed array + types. + + Use LLNI macros for array access and adapted to above changes: + * src/vm/access.c + * src/vm/jit/arm/emit.c + * src/vm/jit/arm/codegen.c + * src/vm/jit/powerpc/emit.c + * src/vm/jit/powerpc/codegen.c + * src/vm/jit/sparc64/emit.c + * src/vm/jit/sparc64/codegen.c + * src/vm/jit/alpha/emit.c + * src/vm/jit/alpha/codegen.c + * src/vm/jit/s390/emit.c + * src/vm/jit/s390/codegen.c + * src/vm/jit/mips/emit.c + * src/vm/jit/mips/codegen.c + * src/vm/jit/m68k/emit.c + * src/vm/jit/m68k/codegen.c + * src/vm/jit/powerpc64/emit.c + * src/vm/jit/powerpc64/codegen.c + * src/vm/jit/i386/emit.c + * src/vm/jit/i386/codegen.c + * src/vm/jit/x86_64/emit.c + * src/vm/jit/x86_64/codegen.c + * src/vm/jit/stacktrace.c + * src/vm/jit/stacktrace.h + * src/vm/builtin.c + * src/vm/string.c + * src/vm/builtin.h + * src/vm/exceptions.c + * src/vm/vm.c + * src/vm/stringlocal.h + * src/vm/vm.h + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/java_lang_reflect_Constructor.h + * src/native/vm/java_lang_ClassLoader.h + * src/native/vm/java_lang_Class.c + * src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c + * src/native/vm/gnu/java_security_VMAccessController.c + * src/native/vm/gnu/java_lang_VMClassLoader.c + * src/native/vm/gnu/java_lang_management_VMManagementFactory.c + * src/native/vm/gnu/java_lang_VMClass.c + * src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c + * src/native/vm/gnu/sun_reflect_ConstantPool.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c + * src/native/vm/gnu/java_lang_VMSystem.c + * src/native/vm/gnu/java_lang_reflect_Constructor.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/java_lang_Class.h + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/sun/jvm.c + * src/native/vm/reflect.c + * src/native/vm/java_lang_reflect_Method.c + * src/native/vm/reflect.h + * src/native/vm/java_lang_reflect_Constructor.c + * src/native/vm/java_lang_reflect_Method.h + * src/native/jni.h + * src/vmcore/class.c + * src/vmcore/class.h + * src/vmcore/method.c + * src/vmcore/method.h + * src/vmcore/linker.c + * src/cacaoh/headers.h + * src/cacaoh/dummy.c + * src/cacaoh/headers.c ........ r8319 | michi | 2007-08-16 12:43:43 + +0200 (Thu, 16 Aug 2007) | 5 lines + + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getDeclaredFields): Fixed postincrement of + array index. (_Jv_java_lang_Class_getDeclaredMethods): Likewise. + (_Jv_java_lang_Class_getDeclaredConstructors): Likewise. ........ + r8320 | michi | 2007-08-16 13:35:14 +0200 (Thu, 16 Aug 2007) | 4 + lines + + * src/vm/jit/allocator/simplereg.c (simplereg_free): Index into + memcopycount is divided by SIZE_OF_STACKSLOT now. + (simplereg_allocate_temporaries): Likewise. ........ + [e7e3dbee216f] + + * src/vm/jit/allocator/simplereg.c: + * src/vm/jit/allocator/simplereg.c (simplereg_free): Index into + memcopycount is divided by SIZE_OF_STACKSLOT now. + (simplereg_allocate_temporaries): Likewise. + [f7cbb35f5009] + + * src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getDeclaredFields): Fixed postincrement of + array index. (_Jv_java_lang_Class_getDeclaredMethods): Likewise. + (_Jv_java_lang_Class_getDeclaredConstructors): Likewise. + [5319d51e8c06] + + * src/cacaoh/dummy.c, src/cacaoh/headers.c, src/cacaoh/headers.h, + src/native/jni.c, src/native/jni.h, src/native/llni.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_ClassLoader.h, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h, src/native/vm/reflect.c, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c, + src/native/vm/sun_misc_Unsafe.c, src/vm/access.c, src/vm/builtin.c, + src/vm/builtin.h, src/vm/exceptions.c, src/vm/global.h, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/string.c, src/vm/stringlocal.h, src/vm/vm.c, src/vm/vm.h, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c, + src/vmcore/method.c, src/vmcore/method.h: + * src/native/llni.h: Added macros for array handling. + + * src/vm/global.h: Added typedefs for array handles. Renamed array + types. + + Use LLNI macros for array access and adapted to above changes: + * src/vm/access.c + * src/vm/jit/arm/emit.c + * src/vm/jit/arm/codegen.c + * src/vm/jit/powerpc/emit.c + * src/vm/jit/powerpc/codegen.c + * src/vm/jit/sparc64/emit.c + * src/vm/jit/sparc64/codegen.c + * src/vm/jit/alpha/emit.c + * src/vm/jit/alpha/codegen.c + * src/vm/jit/s390/emit.c + * src/vm/jit/s390/codegen.c + * src/vm/jit/mips/emit.c + * src/vm/jit/mips/codegen.c + * src/vm/jit/m68k/emit.c + * src/vm/jit/m68k/codegen.c + * src/vm/jit/powerpc64/emit.c + * src/vm/jit/powerpc64/codegen.c + * src/vm/jit/i386/emit.c + * src/vm/jit/i386/codegen.c + * src/vm/jit/x86_64/emit.c + * src/vm/jit/x86_64/codegen.c + * src/vm/jit/stacktrace.c + * src/vm/jit/stacktrace.h + * src/vm/builtin.c + * src/vm/string.c + * src/vm/builtin.h + * src/vm/exceptions.c + * src/vm/vm.c + * src/vm/stringlocal.h + * src/vm/vm.h + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/java_lang_reflect_Constructor.h + * src/native/vm/java_lang_ClassLoader.h + * src/native/vm/java_lang_Class.c + * src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c + * src/native/vm/gnu/java_security_VMAccessController.c + * src/native/vm/gnu/java_lang_VMClassLoader.c + * src/native/vm/gnu/java_lang_management_VMManagementFactory.c + * src/native/vm/gnu/java_lang_VMClass.c + * src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c + * src/native/vm/gnu/sun_reflect_ConstantPool.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c + * src/native/vm/gnu/java_lang_VMSystem.c + * src/native/vm/gnu/java_lang_reflect_Constructor.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/java_lang_Class.h + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/sun/jvm.c + * src/native/vm/reflect.c + * src/native/vm/java_lang_reflect_Method.c + * src/native/vm/reflect.h + * src/native/vm/java_lang_reflect_Constructor.c + * src/native/vm/java_lang_reflect_Method.h + * src/native/jni.h + * src/vmcore/class.c + * src/vmcore/class.h + * src/vmcore/method.c + * src/vmcore/method.h + * src/vmcore/linker.c + * src/cacaoh/headers.h + * src/cacaoh/dummy.c + * src/cacaoh/headers.c + [63b0fd7cb5fe] + +2007-08-16 pm + + * src/vm/jit/trace.c: + * src/vm/jit/trace (_array_load_param) [SIZEOF_VOID_P == 8]: Bugfix, + forgotten obsolete stack_offset. + [8cc3e076fe29] + +2007-08-15 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h: + * src/vm/jit/sparc64/codegen.h: Added M_SAVE_REG and 13-bit overflow + checking. + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed stack + increasing for large stackframe sizes. (check_13bit_imm): Added for + overflow checking. + [13ba271dab74] + +2007-08-15 panzi + + * src/cacaoh/dummy.c, src/native/vm/reflect.c, src/vmcore/field.c, + src/vmcore/field.h, src/vmcore/method.c, src/vmcore/method.h: + * src/native/vm/reflect.c (reflect_constructor_new): Allocation of + the java_bytearray is now done in the method_get_* functions. + (reflect_field_new): Allocation of the java_bytearray is now done in + the field_get_* functions. (reflect_method_new): Allocation of the + java_bytearray is now done in the method_get_* functions. Added use + of LLNI_field_* macros. + + * src/vmcore/method.c (method_get_annotations): Do allocation of the + java_bytearray here. (method_get_parameterannotations): Do + allocation of the java_bytearray here. + (method_get_annotationdefault): Do allocation of the java_bytearray + here. + + * src/vmcore/method.h (method_get_annotations): This function now + returns java_bytearray*. (method_get_parameterannotations): This + function now returns java_bytearray*. + (method_get_annotationdefault): This function now returns + java_bytearray*. + + * src/vmcore/field.c (vm/builtin.h): Added include. + (field_get_annotations): Do allocation of the java_bytearray here. + + * src/vmcore/field.h (field_get_annotations): This function now + returns java_bytearray*. + + * src/cacaoh/dummy.c (builtin_newarray_byte): Added. + [3b41bdd55de9] + +2007-08-15 twisti + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (native/localref.h): Added. + [0ca38e055cda] + + * src/native/llni.h, src/native/localref.c, src/native/localref.h: + * src/native/localref.c: Added Id keyword. + * src/native/localref.h: Likewise. + * src/native/llni.h: Likewise. + [e3fab8d4159d] + + * src/native/jni.c: + * src/native/jni.c (native/localref.h): Added. + [b605fe201191] + +2007-08-15 panzi + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c: + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. + + * src/native/vm/gnu/sun_reflect_ConstantPool.c (vm/stringlocal.h): + Added include. (Java_sun_reflect_ConstantPool_getClassAtIfLoaded0): + Removed wrong call of the macro TRACEJVMCALLS. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_getDefaultValue): Added proper casts + so gcc don't give me warnings. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + [ENABLE_ANNOTATIONS] (vm/exceptions.h): Added include. + + * src/native/vm/sun/jvm.c (JVM_ConstantPoolGetStringAt): Corrected + cast. (JVM_ConstantPoolGetUTF8At): Corrected cast. + (JVM_GetArrayElement): Using primitive_box_* functions. + [8cfa30fdde8a] + +2007-08-15 twisti + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Bugfix, forgot + to set c. + [aed11214ae7d] + + * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (vm/builtin.h): Added. + (class_get_declaredclasses): New function. + + * src/vmcore/class.h (class_get_declaredclasses): Likewise. + + * src/native/vm/java_lang_Class.c (getDeclaredClasses): Use + class_get_declaredclasses. + + * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Likewise. + [3d3963d5c803] + +2007-08-15 pm + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Argument to + ioctl is int *. + [235e3ac93356] + +2007-08-15 twisti + + * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_get_interfaces): New function. + * src/vmcore/class.h (class_get_interfaces): Likewise. + + * src/native/vm/java_lang_Class.c (getSuperclass): Cast return + value. (getInterfaces): Use class_get_interfaces. + * src/native/vm/sun/jvm.c (JVM_GetClassInterfaces): Likewise. + [94c9ff4847c9] + + * src/vm/signal.c, src/vm/signallocal.h: + * src/vm/signal.c (signal_init): Cast to functionptr to fix + warnings. (signal_register_signal): Changed signature. + + * src/vm/signallocal.h (signal_register_signal): Likewise. + [17e72f4ecf1e] + +2007-08-15 panzi + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, src/native/vm/reflect.c, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c: + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getDeclaredAnnotations): Use LLNI_* macro. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (Java_java_lang_reflect_Method_getDefaultValue): Use LLNI_* macros. + (Java_java_lang_reflect_Method_declaredAnnotations): Use LLNI_* + macros. (Java_java_lang_reflect_Method_getParameterAnnotations): Use + LLNI_* macros. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (Java_java_lang_reflect_Field_declaredAnnotations): Use LLNI_* + macros. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (Java_java_lang_reflect_Constructor_declaredAnnotations): Use LLNI_* + macros. + (Java_java_lang_reflect_Constructor_getParameterAnnotations): Use + LLNI_* macros. + + * src/native/vm/sun/jvm.c (native/llni.h): Added include. + (JVM_GetFieldAnnotations): Use LLNI_* macros. + (JVM_GetMethodAnnotations): Use LLNI_* macros. + (JVM_GetMethodDefaultAnnotationValue): Use LLNI_* macros. + (JVM_GetMethodParameterAnnotations): Use LLNI_* macros. + (JVM_GetClassConstantPool): Use LLNI_* macros. + + * src/native/vm/reflect.c (reflect_constructor_new): Forgot to set + annotations and parameterAnnotations attributes for GNU Classpath. + (reflect_get_declaredannotatios): Use LLNI_* macros. + (reflect_get_parameterannotations): Use LLNI_* macros. + + * src/native/vm/reflect.h (reflect_get_declaredannotatios): Now the + caller has to set the declaredAnnotations attribute of the according + object itself, because the LLNI_* macros can't get the address of an + field. + [3b8fc6b76377] + +2007-08-14 pm + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/none/threads.h, src/vm/jit/Makefile.am, + src/vm/jit/s390/emit.c, src/vm/jit/trace.c, src/vm/jit/trace.h: + * src/threads/none/threads.h [!defined(NDEBUG)] + (_no_threads_tracejavacallindent, _no_threads_tracejavacallcount, + TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added. + * src/threads/native/threads.h [!defined(NDEBUG)] (threadinfo): Added + tracejavacallindent, tracejavacallcount members. + (TRACEJAVACALLINDENT, TRACEJAVACALLCOUNT): added. + * src/threads/native/threads.c: Likewise. + * src/vm/jit/trace.h New file. + * src/vm/jit/trace.c: Likewise. + * src/vm/jit/Makefile.am (libjit_la_SOURCES): added trace.h and + trace.c. + * src/vm/jit/s390/emit.c (emit_verbosecall_enter): adpated to use + trace_java_call_enter, (emit_verbosecall_exit): adapted to use + trace_java_call_exit. + [e821a274bf95] + +2007-08-13 twisti + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_print_exception): Fixed typo. + [bbb18ba6a16a] + +2007-08-13 michi + + * configure.ac, src/mm/cacao-gc/compact.c, src/mm/cacao-gc/copy.c, + src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao- + gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/region.c, src/mm + /cacao-gc/region.h, src/mm/cacao-gc/rootset.c, src/mm/cacao- + gc/rootset.h, src/mm/gc-common.h: + * src/mm/gc-common.h, + * src/mm/cacao-gc/gc.h, + * src/mm/cacao-gc/final.h, + * src/mm/cacao-gc/rootset.c, + * src/mm/cacao-gc/rootset.h, + * src/mm/cacao-gc/copy.c, + * src/mm/cacao-gc/heap.c, + * src/mm/cacao-gc/heap.h, + * src/mm/cacao-gc/region.c, + * src/mm/cacao-gc/compact.c, + * src/mm/cacao-gc/region.h, + * src/mm/cacao-gc/gc.c, + * src/mm/cacao-gc/final.c, + * src/mm/cacao-gc/mark.c: Adapted to changes on trunk. + [18edffcb5990] + +2007-08-13 twisti + + * configure.ac, m4/libjvm.m4: + * configure.ac (dl): Check for dl before all other stuff. + (AC_CHECK_ENABLE_LIBJVM): Added. + + * m4/libjvm.m4: New file. + [cdad3888d438] + +2007-08-13 michi + + * src/native/localref.c: + * src/native/localref.c (localref_table_remove): Fixed assertion. + [25f64eca9e36] + + * NEWS, configure.ac, m4/ac_prog_javac.m4, m4/classpath.m4, + src/cacaoh/dummy.c, src/cacaoh/headers.c, src/cacaoh/headers.h, + src/lib/Makefile.am, src/mm/memory.c, src/native/Makefile.am, + src/native/include/Makefile.am, src/native/jni.c, src/native/jni.h, + src/native/localref.c, src/native/native.c, src/native/native.h, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h, src/native/vm/sun_misc_Unsafe.c, + src/threads/critical.c, src/threads/native/lock.c, + src/threads/native/lock.h, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/threads/threads-common.c, src/toolbox/avl.c, src/toolbox/avl.h, + src/toolbox/hashtable.c, src/toolbox/hashtable.h, + src/toolbox/list.h, src/toolbox/util.c, src/vm/Makefile.am, + src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/finalizer.c, src/vm/global.h, + src/vm/initialize.c, src/vm/jit/Makefile.am, + src/vm/jit/alpha/Makefile.am, src/vm/jit/alpha/arch.h, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/Makefile.am, src/vm/jit/arm/arch.h, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/arm/patcher.c, src/vm/jit/asmpart.h, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/dseg.c, src/vm/jit + /emit-common.c, src/vm/jit/emit-common.h, + src/vm/jit/i386/Makefile.am, src/vm/jit/i386/arch.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md.c, + src/vm/jit/i386/patcher.c, src/vm/jit/jit.h, + src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/Makefile.am, src/vm/jit/mips/arch.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/patcher.h, + src/vm/jit/powerpc/Makefile.am, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md- + asm.h, src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/replace.c, src/vm/jit/replace.h, + src/vm/jit/s390/Makefile.am, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/arch.h, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/solaris/md-os.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/tools/Makefile.am, src/vm/jit/tools/genoffsets.c, + src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify + /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/Makefile.am, + src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/properties.c, + src/vm/properties.h, src/vm/resolve.c, src/vm/signal.c, + src/vm/signallocal.h, src/vm/string.c, src/vm/stringlocal.h, + src/vm/vm.c, src/vm/vm.h, src/vmcore/Makefile.am, + src/vmcore/annotation.c, src/vmcore/annotation.h, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/classcache.c, + src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/field.h, + src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/primitive.c, + src/vmcore/primitive.h, src/vmcore/suck.h, src/vmcore/utf8.c, + src/vmcore/utf8.h, tests/rtIn/at/dms/kjc/Main, tests/rtMissedIn0: + Merged revisions 8245-8298 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8246 | michi | 2007-07-31 13:36:03 +0200 (Tue, 31 Jul + 2007) | 2 lines + + * src/vm/jit/sparc64/md.c: Fixed file header. ........ r8247 | + michi | 2007-07-31 14:06:44 +0200 (Tue, 31 Jul 2007) | 10 lines + + * src/vm/jit/arm/arch.h, src/vm/jit/powerpc/arch.h, + src/vm/jit/sparc64/arch.h, src/vm/jit/alpha/arch.h, + src/vm/jit/s390/arch.h, src/vm/jit/mips/arch.h, + src/vm/jit/powerpc64/arch.h, src/vm/jit/i386/arch.h, + src/vm/jit/x86_64/arch.h (REPLACEMENT_STUB_SIZE): Removed obsolete + define. + + * src/vm/jit/powerpc/md.c, src/vm/jit/sparc64/md.c, + src/vm/jit/alpha/md.c, src/vm/jit/mips/md.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/i386/md.c, + src/vm/jit/x86_64/md.c (md_patch_replacement_point): We have to + use trap instructions here. ........ r8248 | twisti | 2007-07-31 + 14:47:11 +0200 (Tue, 31 Jul 2007) | 6 lines + + * configure.ac: Only check AC_PROG_JAVAC and AC_PROG_JAR for + CLDC-1.1 and GNU. + + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed + default value for different configurations.. ........ r8249 | + panzi | 2007-07-31 14:59:03 +0200 (Tue, 31 Jul 2007) | 257 lines + + * src/lib/gnu/java/lang/reflect/Method.java (annotations): + Added. (parameterAnnotations): Added. (annotationDefault): + Added. + + * src/lib/gnu/java/lang/reflect/Field.java (annotations): Added. + + * src/lib/gnu/sun/reflect: New directory. + * src/lib/gnu/sun/reflect/generics: New directory. + * src/lib/gnu/sun/reflect/generics/parser: New directory. + * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java: + New file. + + * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: + New file. This class parses type signatures and returns the acording + type as a java.lang.Class instance. + + * src/lib/gnu/sun/reflect/ConstantPool.java [WITH_CLASSPATH_GNU]: + New file. + + * src/lib/gnu/sun/reflect/annotation: New directory. + * src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionPr + oxy.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK. + + * + src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java + [WITH_CLASSPATH_GNU]: Copied file from OpenJDK. + + * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java + [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so + it can be used with GNU Classpath. [WITH_CLASSPATH_GNU] + (parseAnnotationsIntoArray): Added for convenience. + [WITH_CLASSPATH_GNU] (parseAnnotationDefault): Added for + convenience. + + * src/lib/gnu/sun/reflect/annotation/AnnotationType.java + [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so + it can be used with GNU Classpath. [WITH_CLASSPATH_GNU] + (annotationTypes): Added to emulate + sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and + sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType(). + + * src/lib/Makefile.am [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]: + Added classes needed by annotations support. + + * src/native/vm/nativevm.h [ENABLE_ANNOTATIONS] + (_Jv_sun_reflect_ConstantPool_init): Added. + + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (vmcore/annotation.h): Include added. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Include added. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (_Jv_java_lang_Class_getDeclaredAnnotations): Implemented. + + * src/native/vm/gnu/java_lang_VMClass.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] + (Java_java_lang_VMClass_getDeclaredAnnotations): Implemented. + + * src/native/vm/gnu/sun_reflect_ConstantPool.c + [ENABLE_ANNOTATIONS]: Added implementation of + sun.reflect.ConstantPool class. This is an copy of the according + functions from src/native/vm/sun/jvm.c for I don't know how to + unify it better (needs to be discussed). + + * src/native/vm/gnu/java_lang_reflect_Method.c + [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. + [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): + Added include. [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_getDefaultValue): Implemented. + + * src/native/vm/gnu/Makefile.am [ENABLE_ANNOTATIONS] + (SUN_REFLECT_SOURCES): Added sun_reflect_ConstantPool.c + + * src/native/vm/java_lang_Class.h [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): + Added. + + * src/native/vm/sun/jvm.c (assert.h): Added include. + (native/include/java_lang_Integer.h): Added include. + (native/include/java_lang_Long.h): Added include. + (native/include/java_lang_Short.h): Added include. + (native/include/java_lang_Byte.h): Added include. + (native/include/java_lang_Character.h): Added include. + (native/include/java_lang_Boolean.h): Added include. + (native/include/java_lang_Float.h): Added include. + (native/include/java_lang_Double.h): Added include. + [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): + Added include. (JVM_GetDeclaringClass): Implemented. + (JVM_GetClassAnnotations) [ENABLE_ANNOTATIONS]: Implemented. + (JVM_GetFieldAnnotations): Implemented. + (JVM_GetMethodAnnotations): Implemented. + (JVM_GetMethodDefaultAnnotationValue): Implemented. + (JVM_GetMethodParameterAnnotations): Implemented. + [ENABLE_ANNOTATIONS] (JVM_GetClassConstantPool): Implemented. + (JVM_ConstantPoolGetSize): Implemented. + (JVM_ConstantPoolGetClassAt): Implemented. + (JVM_ConstantPoolGetClassAtIfLoaded): Implemented. + (JVM_ConstantPoolGetMethodAt): Implemented. + (JVM_ConstantPoolGetMethodAtIfLoaded): Implemented. + (JVM_ConstantPoolGetFieldAt): Implemented. + (JVM_ConstantPoolGetFieldAtIfLoaded): Implemented. + (JVM_ConstantPoolGetIntAt): Implemented. + (JVM_ConstantPoolGetLongAt): Implemented. + (JVM_ConstantPoolGetFloatAt): Implemented. + (JVM_ConstantPoolGetDoubleAt): Implemented. + (JVM_ConstantPoolGetStringAt): Implemented. + (JVM_ConstantPoolGetUTF8At): Implemented. (JVM_GetArrayElement): + Quickly implemented (will be rewritten by twisti). I needed this + function in a testcase and not directly for annotations support. + + * src/native/vm/reflect.c [ENABLE_ANNOTATIONS] (mm/memmory.h): + Added include. (reflect_constructor_new) [ENABLE_ANNOTATIONS]: + Load annotations and parameter annotations. (reflect_field_new) + [ENABLE_ANNOTATIONS]: Load annotations. (reflect_method_new) + [ENABLE_ANNOTATIONS]: Load annotations, parameter annotations and + annotation default value. + + * src/native/vm/nativevm.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (_Jv_sun_reflect_ConstantPool_init): Added + call. + + * src/native/include/Makefile.am [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (JAVASE_HEADER_FILES): Added + sun_reflect_ConstantPool.h + + * src/vmcore/class.c [ENABLE_ANNOTATIONS] + (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + (class_sun_reflect_annotation_AnnotationParser): Added. + (class_load_attributes) [ENABLE_ANNOTATIONS]: Load annotations. + (class_free) [ENABLE_ANNOTATIONS]: Free annotations. + + * src/vmcore/loader.c (loader_init) [ENABLE_ANNOTATIONS]: Load + class_sun_reflect_ConstantPool. (loader_init) [ENABLE_ANNOTATIONS] + [WITH_CLASSPATH_GNU]: Load + class_sun_reflect_annotation_AnnotationParser. + + * src/vmcore/annotation.c [!ENABLE_ANNOTATIONS]: Error: annotation + support has to be enabled when compling this file. (assert.h): + Added include. (toolbox/logging.h): Added include. + (annotation_bytearray_new): Added. (annotation_bytearray_free): + Added. (annotation_bytearrays_new): Added. + (annotation_bytearrays_resize): Added. + (annotation_bytearrays_insert): Added. + (annotation_bytearrays_free): Added. + (annotation_load_attribute_body): Added. Maybe this function should + be called loader_load_attribute_body and located in + vmcore/loader.c? + (annotation_load_method_attribute_annotationdefault): Added. (anno + tation_load_method_attribute_runtimevisibleparameterannotations): + Added. (annotation_load_method_attribute_runtimeinvisibleparameter + annotations): Added. + (annotation_load_class_attribute_runtimevisibleannotations): Added. + (annotation_load_class_attribute_runtimeinvisibleannotations): + Added. + (annotation_load_method_attribute_runtimevisibleannotations): Added. + (annotation_load_method_attribute_runtimeinvisibleannotations): + Added. + (annotation_load_field_attribute_runtimevisibleannotations): Added. + (annotation_load_field_attribute_runtimeinvisibleannotations): + Added. + + * src/vmcore/class.h [ENABLE_ANNOTATIONS] + (runtimevisibleannotationscount): Removed. [ENABLE_ANNOTATIONS] + (runtimevisibleannotations): Removed. [ENABLE_ANNOTATIONS] + (annotations): Added. Bytearray of the unparsed annotations or + NULL if none. [ENABLE_ANNOTATIONS] (method_annotations): Added. + Array of bytearrays of method annotations. This Array is only as + big as needed or NULL if there are no method annotations at all. + [ENABLE_ANNOTATIONS] (method_parameterannotations): Added. Array of + bytearrays of method parameter annotations. This Array is only as + big as needed or NULL if there are no method parameter annotations + at all. [ENABLE_ANNOTATIONS] (method_annotationdefaults): Added. + Array of bytearrays of method annotation default values. This + Array is only as big as needed or NULL if there are no method + annotation default values at all. [ENABLE_ANNOTATIONS] + (field_annotations): Added. Array of bytearrays of field + annotations. This Array is only as big as needed or NULL if there + are no field annotations at all. [ENABLE_ANNOTATIONS] + (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + [WITH_CLASSPATH_GNU] + (class_sun_reflect_annotation_AnnotationParser): Added. + + * src/vmcore/annotation.h (annotation_bytearray_t): Added. Used + to store unparsed (parameter-) annotations or unparsed annotation + default values in. (annotation_bytearrays_t): Added. Array of + bytearrays. (annotation_bytearray_new): Added. + (annotation_bytearray_free): Added. (annotation_bytearrays_new): + Added. (annotation_bytearrays_resize): Added. + (annotation_bytearrays_insert): Added. + (annotation_bytearrays_free): Added. + (annotation_load_class_attribute_runtimeinvisibleannotations): + Added. + (annotation_load_method_attribute_runtimevisibleannotations): Added. + (annotation_load_method_attribute_runtimeinvisibleannotations): + Added. + (annotation_load_field_attribute_runtimevisibleannotations): Added. + (annotation_load_field_attribute_runtimeinvisibleannotations): + Added. (annotation_load_method_attribute_annotationdefault): + Added. (annotation_load_method_attribute_runtimevisibleparameteran + notations): Added. (annotation_load_method_attribute_runtimeinvi + sibleparameterannotations): Added. + + * src/vmcore/method.c (method_load) [ENABLE_ANNOTATIONS]: Load + annotations, parameter annotations and annotation default values. + [ENABLE_ANNOTATIONS] (method_get_annotations): Added. + [ENABLE_ANNOTATIONS] (method_get_parameterannotations): Added. + [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added. + + * src/vmcore/method.h [ENABLE_ANNOTATIONS] + (method_get_annotations): Added. [ENABLE_ANNOTATIONS] + (method_get_parameterannotations): Added. [ENABLE_ANNOTATIONS] + (method_get_annotationdefault): Added. + + * src/vmcore/field.c (mm/memory.h): Added include. + (vmcore/annotations.h): Added include. (field_load) + [ENABLE_ANNOTATIONS]: Laod annotations. [ENABLE_ANNOTATIONS] + (field_get_annotations): Added. + + * src/vmcore/utf8.c [ENABLE_ANNOTATIONS] + (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeVisibleParameterAnnotations): Added. + [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations): + Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added. + [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] + (utf_sun_reflect_annotation_AnnotationParser): Added. + + * src/vmcore/field.h [ENABLE_ANNOTATIONS] + (field_get_annotations): Added. + + * src/vmcore/Makefile.am [ENABLE_ANNOTATIONS] + (ANNOTATION_SOURCES): Only compile annotations sources when + annotations are enabled. + + * src/vmcore/utf8.h [ENABLE_ANNOTATIONS] + (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeVisibleParameterAnnotations): Added. + [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations): + Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added. + [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] + (utf_sun_reflect_annotation_AnnotationParser): Added. + + * configure.ac (ENABLE_ANNOTATIONS): Added configure option + --enable-annotations. ........ r8250 | twisti | 2007-07-31 + 15:16:43 +0200 (Tue, 31 Jul 2007) | 3 lines + + * m4/annotations.m4: New file. + * configure.ac: Use AC_CHECK_ENABLE_ANNOTATIONS. ........ r8251 | pm + | 2007-08-01 17:26:59 +0200 (Wed, 01 Aug 2007) | 9 lines + + * jit/patcher.h: Added #error if included on s390. + * jit/patcher-common.h: Made declarations visible on s390. + * jit/s390/asmpart.S (asm_patcher_wrapper): removed. + * jit/s390/emit.c (emit_patcher_stubs): removed, (emit_patcher_traps): + added. + * jit/s390/codegen.h (PATCHER_LONGBRANCHES_NOPS_SKIP, + PATCHER_LONGBRANCHES_NOPS): removed, (PATCHER_CALL_SIZE, + PATCHER_NOPS, PATCHER_NOPS_SKIP) adapted to patching via signals. + * jit/s390/codegen.c (codegen_emit, codegen_emit_stub_native): Adapted + to paching via signals. + * jit/s390/md.c (md_signal_handler_sigill, md_signal_handler_sigsegv): + added support for exceptions_new_hardware_exception returning NULL. + * jit/s390/patcher.c: Adapted to paching via signals. ........ r8252 + | twisti | 2007-08-02 00:47:17 +0200 (Thu, 02 Aug 2007) | 5 lines + + * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed -1.5 from ecj. + + * src/lib/Makefile.am (vm.zip): Added -source 1.5 -target 1.5. + Thanks to Mark Wielaard. ........ r8253 | twisti | 2007-08-02 + 16:46:00 +0200 (Thu, 02 Aug 2007) | 2 lines + + * src/native/vm/sun/jvm.c (JVM_RaiseSignal): New function. + ........ r8254 | pm | 2007-08-03 20:43:30 +0200 (Fri, 03 Aug 2007) + | 3 lines + + * src/vm/jit/patcher-common.c (patcher_handler): Call + LOCK_MONITOR_EXIT instead of LOCK_MONITOR_ENTER in double-patching + handler code. ........ r8255 | michi | 2007-08-03 21:06:37 +0200 + (Fri, 03 Aug 2007) | 7 lines + + * src/vm/jit/patcher-common.c (patcher_list_reset): Added. + (patcher_add_patch_ref) [!NDEBUG]: Added sanity check. + + * src/vm/jit/patcher-common.h (patcher_list_reset): Added. + + * src/vm/jit/codegen-common.c (codegen_reset): Resets the patcher + list. ........ r8256 | twisti | 2007-08-05 12:58:21 +0200 (Sun, 05 + Aug 2007) | 3 lines + + * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Use + HotSpot-compatible code. ........ r8257 | twisti | 2007-08-05 + 13:04:21 +0200 (Sun, 05 Aug 2007) | 4 lines + + * src/vm/jit/patcher-common.c (stdint.h): Added. + (patcher_list_free): Removed unused variable pr. + (patcher_add_patch_ref): Fixed warning. ........ r8258 | edwin | + 2007-08-05 22:15:27 +0200 (Sun, 05 Aug 2007) | 2 lines + + * src/vm/jit/replace.c (replace_new_sourceframe): Fixed + documentation. ........ r8259 | edwin | 2007-08-05 22:41:25 +0200 + (Sun, 05 Aug 2007) | 3 lines + + * src/vm/jit/replace.c (replace_read_executionstate): Improved + comments. (replace_write_executionstate): Likewise. ........ + r8260 | michi | 2007-08-06 14:19:01 +0200 (Mon, 06 Aug 2007) | 13 + lines + + * src/vm/jit/emit-common.c (emit_patcher_traps): Added. + + * src/vm/jit/emit-common.h (emit_trap): Added prototype. + + * src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to + emit-common). (emit_trap): Implemented. + + * src/vm/jit/arm/emit.c: Likewise. + + * src/vm/jit/powerpc/emit.c: Likewise. + + * src/vm/jit/s390/emit.c: Likewise. ........ r8261 | michi | + 2007-08-06 14:42:31 +0200 (Mon, 06 Aug 2007) | 3 lines + + * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed + obsolete code about PATCHER_LONGBRANCHES_NOPS. ........ r8262 | + panzi | 2007-08-06 14:44:01 +0200 (Mon, 06 Aug 2007) | 97 lines + + * src/lib/gnu/java/lang/reflect/Method.java + (java.lang.annotation.Annotation): Added import. (java.util.Map): + Added import. (sun.refelct.annotation.AnnotationParser): Added + import. (declaredAnnotations): Added field (inspired by OpenJDK). + (getAnnotation): Added method. (getDeclaredAnnotations): Added + method. (declaredAnnotations): Added method (inspired by OpenJDK). + (getParameterAnnotations): Added method. + + * src/lib/gnu/java/lang/reflect/Field.java + (java.lang.annotation.Annotation): Added import. (java.util.Map): + Added import. (sun.refelct.annotation.AnnotationParser): Added + import. (declaredAnnotations): Added field (inspired by OpenJDK). + (getAnnotation): Added method. (getDeclaredAnnotations): Added + method. (declaredAnnotations): Added method (inspired by OpenJDK). + + * src/lib/gnu/java/lang/reflect/Constructor.java: Copied file + from GNU Classpath. (java.lang.annotation.Annotation): Added + import. (java.util.Map): Added import. + (sun.refelct.annotation.AnnotationParser): Added import. + (declaredAnnotations): Added field (inspired by OpenJDK). + (getAnnotation): Added method. (getDeclaredAnnotations): Added + method. (declaredAnnotations): Added method (inspired by OpenJDK). + (getParameterAnnotations): Added method. + + * + src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java: + Removed. + + * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: + Removed. I figured out which class of GNU Classpath to use to + replace this self written class. + + * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: + Added a few comments. + (sun.reflect.generics.parser.SignatureParser): Removed import. + (sun.reflect.generics.parser.SignatureFormatError): Removed import. + (gnu.java.lang.reflect.FieldSignatureParser): Added import. + (parseParameterAnnotations): Added method. (parseSig): Changed + method so it uses GNU Classpaths FieldSignatureParser. + + * src/lib/Makefile.am (VM_JAVA_FILES): Added + $(top_srcdir)/src/lib/gnu/java/lang/reflect/Constructor.java + (VM_CLASS_FILES): Added classes/java/lang/reflect/Constructor.class + + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): + Cache methodinfo for + sun.reflect.annotation.AnnotationParser.parseAnnotationsIntoArray. + + * src/native/vm/gnu/java_lang_reflect_Method.c + [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include. + [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. + [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_getDefaultValue): Cache methodinfo + for sun.reflect.annotation.AnnotationParser.parseDefaultValue. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_declaredAnnotations): Added. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_getParameterAnnotations): Added. + + * src/native/vm/gnu/java_lang_reflect_Field.c + [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): + Added include. [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added + include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Field_declaredAnnotations): Added. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. + [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): + Added include. [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added + include. [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. + [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Constructor_declaredAnnotations): Added. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Constructor_getParameterAnnotations): Added. + + * src/native/vm/reflect.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Added include. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added. + + * src/native/vm/reflect.h [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (reflect_get_declaredannotatios): Added. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (reflect_get_parameterannotations): Added. + + * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Implemented + (needed by a testcase of mine). + + * src/vmcore/method.c (method_get_parametercount): Added. This + function gets the parameter count of a method (not counting the + this pointer of non-static methods). Returns -1 in case of an error. + + * src/vmcore/method.h (method_get_parametercount): Added. ........ + r8263 | twisti | 2007-08-06 16:41:05 +0200 (Mon, 06 Aug 2007) | 3 + lines + + * src/vm/jit/mips/arch.h (SUPPORT_PASS_FLOATARGS_IN_INTREGS): + Removed duplicate define. ........ r8264 | twisti | 2007-08-06 + 18:02:28 +0200 (Mon, 06 Aug 2007) | 33 lines + + * src/vm/jit/patcher-common.h: Added __MIPS__ for new patcher + functions. + + * src/vm/jit/patcher.h: Added __MIPS__ to include-check. + + * src/vm/jit/mips/emit.c (vm/jit/patcher-common.h): Added. + (emit_patcher_stubs): Removed. (emit_trap): Added. + + * src/vm/jit/mips/codegen.c (vm/jit/patcher.h): Removed. (vm/jit + /patcher-common.h): Added. (codegen_emit): Replaced + codegen_add_patch_ref with patcher_add_patch_ref, and + emit_patcher_stubs with emit_patcher_traps. + (codegen_emit_stub_native): Likewise. + + * src/vm/jit/mips/codegen.h (PATCHER_CALL_INSTRUCTIONS): Changed + to 1. (PATCHER_CALL_SIZE): Changed to 1*4. (PATCHER_NOPS): Emit + only one NOP. + + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Check + for exception, set PC in trap-case. + + * src/vm/jit/mips/irix/md-os.c (md_signal_handler_sigsegv): Check + for exception. + + * src/vm/jit/mips/patcher.c: Renamed function to new patcher + functions, and use patcher references. (vm/jit/patcher.h): + Removed. (vm/jit/patcher-common.h): Added (patcher_wrapper): + Removed. + + * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Removed. + ........ r8265 | twisti | 2007-08-06 18:10:42 +0200 (Mon, 06 Aug + 2007) | 3 lines + + * src/vm/jit/emit-common.c: Set Id keyword. + * src/vm/jit/emit-common.h: Likewise. ........ r8266 | twisti | + 2007-08-07 10:26:38 +0200 (Tue, 07 Aug 2007) | 3 lines + + * src/threads/threads-common.c (threads_preinit): Fixed compiler + warning. ........ r8267 | twisti | 2007-08-07 13:07:48 +0200 (Tue, + 07 Aug 2007) | 4 lines + + * src/vm/jit/i386/emit.c (emit_trap): New function. + * src/vm/jit/powerpc64/emit.c: Likewise. + * src/vm/jit/x86_64/emit.c: Likewise. ........ r8268 | twisti | + 2007-08-07 15:24:43 +0200 (Tue, 07 Aug 2007) | 34 lines + + * src/vmcore/field.c (mm/memory.h): Added. (vm/global.h): + Likewise. (field_load): Allocate value memory only for static and + final fields. + + * src/vmcore/field.h (fieldinfo): Made value a pointer. + + * src/vmcore/loader.c (load_class_from_classbuffer): Allocate + fieldinfo's on the C heap. + + * src/native/jni.c: fieldinfo->value is now a pointer. + * src/native/vm/sun_misc_Unsafe.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c: + Likewise. ........ r8269 | twisti | 2007-08-07 21:21:33 +0200 + (Tue, 07 Aug 2007) | 3 lines + + * tests/rtMissedIn0: Removed. + * tests/rtIn: Likewise. ........ r8270 | twisti | 2007-08-08 + 15:57:12 +0200 (Wed, 08 Aug 2007) | 49 lines + + * src/vm/vm.c (vm_array_store_flt): Handle __POWERPC__ correctly. + (vm_vmargs_from_valist): Removed. (vm_vmargs_from_jvalue): + Likewise. (vm_vmargs_from_objectarray): Likewise. + (vm_call_method_vmarg): Likewise. (vm_call_method_int_vmarg): + Likewise. (vm_call_method_int_valist): Likewise. + (vm_call_method_int_jvalue): Likewise. + (vm_call_method_long_vmarg): Likewise. + (vm_call_method_long_valist): Likewise. + (vm_call_method_long_jvalue): Likewise. + (vm_call_method_float_vmarg): Likewise. + (vm_call_method_float_valist): Likewise. + (vm_call_method_float_jvalue): Likewise. + (vm_call_method_double_vmarg): Likewise. + (vm_call_method_double_valist): Likewise. + (vm_call_method_double_jvalue): Likewise. (vm_call_method_valist): + Removed old implementation. (vm_call_method_jvalue): Likewise. + + * src/vm/vm.h: Removed old prototypes. + * src/vm/jit/asmpart.h: Likewise. + + * src/vm/exceptions.c (exceptions_handle_exception) [__POWERPC__]: + Get monitor object correctly (talk to Michi because of ARM). + + * src/native/jni.c (_Jv_jni_invokeNative): Removed old + implementation. + + * src/vm/jit/powerpc/linux/md-abi.c (md_param_alloc): Use 8-byte + stackslots. (md_param_alloc_native): Implemented native ABI. + + * src/vm/jit/powerpc/emit.c (emit_load): Merged TYPE_FLT and + TYPE_DBL. (emit_store): Likewise + * src/vm/jit/powerpc/darwin/md-abi.c: Likewise. + + * src/vm/jit/powerpc/arch.h (HAS_4BYTE_STACKSLOT): Removed. + (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY): + Likewise. + + * src/vm/jit/powerpc/codegen.c: Implemented 8-byte stackslots, + always load and store float-values as double (PowerPC's internal + register representation is the same). + + * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Use new + argument array. (asm_handle_exception): Restore callee-saved + registers from the correct location. ........ r8271 | twisti | + 2007-08-08 16:07:56 +0200 (Wed, 08 Aug 2007) | 7 lines + + * src/vm/vm.h (vm_arg): Removed. + + * src/vm/jit/tools/genoffsets.c (main): Removed sizevmarg, + offvmargtype and offvmargdata. + + * src/vm/jit/m68k/md.c (md_init): Removed some obsolete checks. + ........ r8272 | twisti | 2007-08-08 16:55:00 +0200 (Wed, 08 Aug + 2007) | 7 lines + + * src/threads/threads-common.c (stdint.h): Added. + (threads_thread_free): Also save and restore the thread state (this + is required for CLDC1.1, but is generally a good idea). + + * src/native/vm/java_lang_Thread.c (isAlive) + [WITH_CLASSPATH_CLDC1_1]: Check for NULL. ........ r8273 | + twisti | 2007-08-08 17:33:15 +0200 (Wed, 08 Aug 2007) | 8 lines + + * src/vmcore/class.c (class_isanysubclass): Don't use + ASM_GETCLASSVALUES_ATOMIC anymore, we will change that to use the + class-renumbering lock. + + * src/vm/builtin.c (builtin_canstore): Likewise. + (builtin_canstore_onedim): Likewise. + (builtin_canstore_onedim_class): Likewise. ........ r8274 | twisti + | 2007-08-08 17:58:17 +0200 (Wed, 08 Aug 2007) | 45 lines + + * src/vm/jit/tools: Removed. + + * configure.ac (AC_CONFIG_FILES): Removed + src/vm/jit/tools/Makefile. + * src/vm/jit/Makefile.am (DIST_SUBDIRS): Removed tools. (SUBDIRS): + Likewise. + + * src/threads/critical.c (stdint.h): Added. (vm/jit/asmpart.h): + Removed. (critical_init): Don't call + critical_register_asm_critical_sections. + (critical_register_asm_critical_sections): Removed. + + * src/vm/jit/asmpart.h (ASM_GETCLASSVALUES_ATOMIC): Removed. + (asm_criticalsections): Likewise. (asm_getclassvalues_atomic): + Likewise. (intrp_asm_getclassvalues_atomic): Likewise. + + * src/vm/jit/alpha/Makefile.am, src/vm/jit/arm/Makefile.am, + src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am, + src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am, + src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am + (BUILT_SOURCES): Removed (CLEANFILES): Likewise. (offsets.h): + Likewise. + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S, + src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S + (offsets.h): Removed. (asm_getclassvalues_atomic): Likewise. + (asm_criticalsections): Likewise. + + * src/vm/jit/powerpc/darwin/md-asm.h (asm_criticalsections): + Removed. (asm_getclassvalues_atomic): Likewise. ........ r8275 | + twisti | 2007-08-08 18:05:40 +0200 (Wed, 08 Aug 2007) | 12 lines + + * src/vm/jit/alpha, src/vm/jit/arm, src/vm/jit/i386, + src/vm/jit/m68k, src/vm/jit/mips, src/vm/jit/parisc, + src/vm/jit/powerpc, src/vm/jit/powerpc64, src/vm/jit/s390, + src/vm/jit/sparc64, src/vm/jit/x86_64 (svn:ignore): Removed + offsets.h. ........ r8276 | twisti | 2007-08-08 18:09:14 +0200 + (Wed, 08 Aug 2007) | 2 lines + + * src/vm/jit/arm/asmpart.S (offsets.h): Removed. ........ r8277 + | michi | 2007-08-08 18:42:11 +0200 (Wed, 08 Aug 2007) | 9 lines + + * src/vmcore/linker.c (linker_compute_subclasses): Added attention + notice about the locking mechanism. + + * src/vmcore/class.c (class_isanysubclass): Uses + linker_classrenumber_lock now. + + * src/vm/builtin.c (builtin_canstore): Likewise. + (builtin_canstore_onedim): Likewise. + (builtin_canstore_onedim_class): Likewise. ........ r8278 | michi + | 2007-08-08 19:10:18 +0200 (Wed, 08 Aug 2007) | 5 lines + + * src/vm/jit/s390/emit.c (emit_replacement_stubs): Removed + obsolete function. + * src/vm/jit/s390/codegen.c (codegen_emit): Do not create replacement + stubs. + * src/vm/jit/replace.c (replace_me): No longer call + asm_replacement_in. + * src/vm/jit/asmpart.h [ENABLE_REPLACEMENT]: Removed obsolete + prototypes. ........ r8279 | michi | 2007-08-09 11:36:57 +0200 + (Thu, 09 Aug 2007) | 7 lines + + * src/vm/jit/alpha/linux/md-os.c [ENABLE_REPLACEMENT] + (md_replace_executionstate_read): Implemented. + [ENABLE_REPLACEMENT] (md_replace_executionstate_write): Likewise. + + * src/vm/jit/alpha/asmpart.S (asm_replacement_out): Removed. + (asm_replacement_in): Likewise. ........ r8280 | twisti | + 2007-08-09 13:28:51 +0200 (Thu, 09 Aug 2007) | 2 lines + + * NEWS: Added 0.99 release and some news. ........ r8281 | + twisti | 2007-08-09 14:09:17 +0200 (Thu, 09 Aug 2007) | 2 lines + + * NEWS: Added news. ........ r8282 | twisti | 2007-08-09 + 14:18:47 +0200 (Thu, 09 Aug 2007) | 7 lines + + * src/vm/signal.c (vm/types.h): Removed. (signal_init): Use + signal_register_signal. (signal_register_signal): New function. + + * src/vm/signallocal.h (vm/types.h): Removed. + (signal_register_signal): New function. ........ r8283 | twisti | + 2007-08-09 17:10:05 +0200 (Thu, 09 Aug 2007) | 30 lines + + * src/vm/exceptions.c (toolbox/logging.h): Removed. + (vm/jit/disass.h): Likewise. (exceptions_new_hardware_exception): + Likewise. + + * src/vm/exceptions.h (exceptions_new_hardware_exception): + Likewise. + + * src/vm/signal.c (stdint.h): Added. (toolbox/logging.h): + Likewise. (vm/jit/codegen-common.h): Likewise. + (vm/jit/disass.h): Likewise. (vm/jit/patcher-common.h): Likewise. + (signal_handle): New function. + + * src/vm/signallocal.h (signal_handle): Likewise. + + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md- + os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md- + os.c: Use new signal_handle function. ........ r8284 | michi | + 2007-08-10 10:58:39 +0200 (Fri, 10 Aug 2007) | 26 lines + + * src/native/llni.h: Added LLNI (low level native interface). + + Use LLNI macros throughout the whole codebase: + * src/vm/jit/stacktrace.c + * src/vm/string.c + * src/vm/builtin.c + * src/vm/exceptions.c + * src/vm/vm.c + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/java_lang_Class.c + * src/native/vm/java_lang_String.c + * src/native/vm/java_lang_Object.c + * src/native/vm/gnu/java_lang_VMThread.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/java_lang_reflect_Field.c + * src/native/vm/gnu/java_lang_reflect_Constructor.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/java_lang_Thread.c + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/reflect.c + * src/native/vm/java_lang_reflect_Method.c + * src/native/vm/java_lang_reflect_Constructor.c + * src/threads/threads-common.c + * src/threads/native/threads.c ........ r8285 | michi | 2007-08-10 + 11:20:04 +0200 (Fri, 10 Aug 2007) | 5 lines + + * src/native/vm/gnu/java_lang_reflect_Method.c: Fixed merge + problem in previous revision 8284. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. + ........ r8286 | michi | 2007-08-10 12:46:17 +0200 (Fri, 10 Aug + 2007) | 9 lines + + * src/vm/jit/powerpc/patcher.c (patcher_get_putfield): Fixed + severe bug for unalligned long field offsets. + + * src/vmcore/linker.c [__POWERPC__ && __DARWIN__]: Long fields are + 4-byte alligned in structs. + + * src/vm/jit/patcher-common.c [TRACE_PATCHER]: Left patcher trace + code hanging around, might come handy again. ........ r8287 | + twisti | 2007-08-10 17:10:29 +0200 (Fri, 10 Aug 2007) | 2 lines + + * src/native/jni.c (_Jv_JNI_FromReflectedField): Added missing ;. + ........ r8288 | twisti | 2007-08-10 17:12:00 +0200 (Fri, 10 Aug + 2007) | 34 lines + + * src/vmcore/primitive.c: Removed. + * src/vmcore/primitive.h: Likewise. + + * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Removed + primitive.[ch]. + + * src/vmcore/primitivecore.c: New file. + * src/vm/primitive.c: Likwise. + * src/vm/primitive.h: Likewise. + + * src/vm/Makefile.am (libvm_la_SOURCES): Added primitive.[ch]. + + * src/cacaoh/dummy.c (vm/primitive.h): Added. + (primitive_class_get_by_type): New function. + (primitive_class_get_by_char): Likewise. + + * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vm/builtin.c, src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/resolve.c, src/vm/string.c, src/vm/vm.c, + src/vmcore/descriptor.c, src/vmcore/field.c, + src/vmcore/linker.c, src/vmcore/loader.c: Changed primitive.h + include. ........ r8289 | twisti | 2007-08-10 17:18:05 +0200 (Fri, + 10 Aug 2007) | 3 lines + + * src/native/vm/reflect.c (reflect_field_new): Fixed compilation. + (reflect_method_new): Likewise. ........ r8290 | twisti | + 2007-08-11 12:25:40 +0200 (Sat, 11 Aug 2007) | 6 lines + + * src/native/vm/sun/jvm.c (JVM_GC): Call GC-call directly, use + TRACEJVMCALLS. (JVM_TotalMemory): Likewise. (JVM_FreeMemory): + Likewise. (JVM_NewArray): Use TRACEJVMCALLS. ........ r8291 | + twisti | 2007-08-11 12:43:45 +0200 (Sat, 11 Aug 2007) | 41 lines + + * src/vm/primitive.c (native/jni.h): Added. (native/llni.h): + Likewise. (native/include/java_lang_Boolean.h, + native/include/java_lang_Byte.h, native/include/java_lang_Short.h, + native/include/java_lang_Character.h, + native/include/java_lang_Integer.h, + native/include/java_lang_Long.h, native/include/java_lang_Float.h, + native/include/java_lang_Double.h): Likewise. (vm/builtin.h): + Likewise. (vm/vm.h): Likewise. (primitive_box): New function. + (primitive_unbox): Likewise. (PRIMITIVE_BOX_TYPE): New macro for + primitive_box_xxx functions. (PRIMITIVE_UNBOX_TYPE): New macro for + primitive_unbox_xxx functions. + + * src/vm/primitive.h (primitive_box): Added. (primitive_unbox): + Likewise. (primitive_box_boolean, primitive_box_byte, + primitive_box_char, primitive_box_short, primitive_box_int, + primitive_box_long, primitive_box_float, primitive_box_double): + Likewise. (primitive_unbox_boolean, primitive_unbox_byte, + primitive_unbox_char, primitive_unbox_short, + primitive_unbox_int, primitive_unbox_long, + primitive_unbox_float, primitive_unbox_double): Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Use primitive-box + functions. + + * src/native/vm/gnu/java_lang_reflect_Field.c (get): Likewise. + ........ r8292 | twisti | 2007-08-11 14:39:28 +0200 (Sat, 11 Aug + 2007) | 13 lines + + * src/vm/vm.c (VM_CALL_METHOD): New macro. + (VM_CALL_METHOD_VALIST): Likewise. (VM_CALL_METHOD_JVALUE): + Likewise. (VM_CALL_ARRAY): Likewise. + + * src/vm/vm.h (vm_call_method_int): Changed return type to + stdint-type. (vm_call_method_int_valist): Likewise. + (vm_call_method_int_jvalue): Likewise. (vm_call_method_long): + Likewise. (vm_call_method_long_valist): Likewise. + (vm_call_method_long_jvalue): Likewise. ........ r8293 | twisti | + 2007-08-11 14:40:22 +0200 (Sat, 11 Aug 2007) | 2 lines + + * src/vm/vm.h: Set Id keyword. ........ r8294 | ajordan | + 2007-08-11 15:42:25 +0200 (Sat, 11 Aug 2007) | 6 lines + + * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): Fixed + pending issue from regoff change. + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Likewise. + + * src/vm/jit/sparc64/emit.c (emit_trap): Added. ........ r8295 | + michi | 2007-08-11 19:57:24 +0200 (Sat, 11 Aug 2007) | 106 lines + + * src/vm/global.h (java_handle_t): Added typedef. + (java_object_t): New name for what was formerly known as + java_objectheader. + + Adapted to above changes and decided where to use handles: + * src/vm/initialize.c + * src/vm/properties.h + * src/vm/jit/arm/codegen.c + * src/vm/jit/powerpc/codegen.c + * src/vm/jit/codegen-common.h + * src/vm/jit/sparc64/codegen.c + * src/vm/jit/sparc64/patcher.c + * src/vm/jit/alpha/codegen.c + * src/vm/jit/optimizing/recompile.c + * src/vm/jit/patcher-common.c + * src/vm/jit/s390/codegen.c + * src/vm/jit/show.c + * src/vm/jit/patcher-common.h + * src/vm/jit/mips/codegen.c + * src/vm/jit/patcher.h + * src/vm/jit/m68k/codegen.c + * src/vm/jit/powerpc64/codegen.c + * src/vm/jit/i386/codegen.c + * src/vm/jit/i386/patcher.c + * src/vm/jit/replace.c + * src/vm/jit/asmpart.h + * src/vm/jit/x86_64/codegen.c + * src/vm/jit/x86_64/patcher.c + * src/vm/jit/replace.h + * src/vm/jit/stacktrace.c + * src/vm/jit/stacktrace.h + * src/vm/jit/codegen-common.c + * src/vm/jit/jit.h + * src/vm/builtin.c + * src/vm/string.c + * src/vm/primitive.c + * src/vm/builtin.h + * src/vm/signal.c + * src/vm/primitive.h + * src/vm/exceptions.c + * src/vm/vm.c + * src/vm/finalizer.c + * src/vm/exceptions.h + * src/vm/stringlocal.h + * src/vm/vm.h + * src/vm/properties.c + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c + * src/native/vm/cldc1.1/java_lang_Class.c + * src/native/vm/cldc1.1/java_lang_String.c + * src/native/vm/cldc1.1/java_lang_Object.c + * src/native/vm/cldc1.1/java_lang_System.c + * src/native/vm/cldc1.1/java_lang_Throwable.c + * src/native/vm/java_lang_Class.c + * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c + * src/native/vm/gnu/java_lang_VMClassLoader.c + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/java_lang_VMRuntime.c + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c + * src/native/vm/gnu/java_lang_reflect_Field.c + * src/native/vm/gnu/java_lang_reflect_Constructor.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/java_lang_Object.c + * src/native/vm/java_lang_String.c + * src/native/vm/java_lang_Thread.c + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/sun/jvm.c + * src/native/vm/reflect.c + * src/native/vm/java_lang_Runtime.c + * src/native/vm/java_lang_reflect_Method.c + * src/native/vm/reflect.h + * src/native/vm/java_lang_Runtime.h + * src/native/vm/java_lang_reflect_Constructor.c + * src/native/jni.h + * src/native/native.c + * src/native/native.h + * src/toolbox/hashtable.h + * src/toolbox/util.c + * src/toolbox/list.h + * src/toolbox/avl.c + * src/toolbox/avl.h + * src/toolbox/hashtable.c + * src/mm/memory.c + * src/threads/none/threads.h + * src/threads/threads-common.c + * src/threads/lock-common.h + * src/threads/native/threads.h + * src/threads/native/lock.c + * src/threads/native/threads.c + * src/threads/native/lock.h + * src/vmcore/class.c + * src/vmcore/loader.c + * src/vmcore/suck.h + * src/vmcore/class.h + * src/vmcore/loader.h + * src/vmcore/method.c + * src/vmcore/method.h + * src/vmcore/classcache.c + * src/vmcore/classcache.h + * src/vmcore/linker.c + * src/vmcore/linker.h + * src/cacaoh/headers.h + * src/cacaoh/dummy.c + * src/cacaoh/headers.c ........ r8296 | pm | 2007-08-12 00:38:38 + +0200 (Sun, 12 Aug 2007) | 11 lines + + * src/vm/exceptions.c (exceptions_handle_exception) [__S390__]: + Synchronization object is at SP - IsSync - 8. + * src/vm/vm.c (vm_array_store_flt) [__S390__]: Float value is in bytes + 4-7 of uint64_t. + * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-asm.h: Changed a lot for 8 byte stackslots. ........ r8297 | + michi | 2007-08-12 02:02:48 +0200 (Sun, 12 Aug 2007) | 35 lines + + * src/native/localref.c: Added new file. + * src/native/localref.h: Likewise. + + * src/native/Makefile.am: Added above two files. + + * src/vm/jit/codegen-common.c (codegen_start_native_call) + (codegen_finish_native_call): Use separate function to deal with + localrefs. + + * src/native/jni.h: Moved localref stuff to own file. + * src/native/jni.c: Likewise. (JNI_CALL_VIRTUAL_METHOD): Added new + macro. (JNI_CALL_NONVIRTUAL_METHOD): Likewise. (JNI_GET_FIELD): + Likewise. (JNI_SET_FIELD): Likewise. (JNI_CALL_STATIC_METHOD): + Likewise. (JNI_GET_STATIC_FIELD): Likewise. + (JNI_SET_STATIC_FIELD): Likewise. (JNI_NEW_ARRAY): Likewise. + (JNI_GET_ARRAY_ELEMENTS): Likewise. (JNI_RELEASE_ARRAY_ELEMENTS): + Likewise. (JNI_GET_ARRAY_REGION): Likewise. + (JNI_SET_ARRAY_REGION): Likewise. + + * src/threads/native/threads.h, + * src/vm/jit/arm/codegen.c, + * src/vm/jit/powerpc/codegen.c, + * src/vm/jit/sparc64/codegen.c, + * src/vm/jit/alpha/codegen.c, + * src/vm/jit/s390/codegen.c, + * src/vm/jit/mips/codegen.c, + * src/vm/jit/m68k/codegen.c, + * src/vm/jit/powerpc64/codegen.c, + * src/vm/jit/i386/codegen.c, + * src/vm/jit/x86_64/codegen.c: Added missing include. ........ r8298 + | pm | 2007-08-12 20:49:16 +0200 (Sun, 12 Aug 2007) | 7 lines + + * src/vm/jit/dseg.c (dseg_get_linenumber_from_pc) [__S390__]: + Clear most significant bit of passed pc parameter. + * src/vm/jit/s390/asmpart.S (asm_handle_exception): Rewritten to be + wrapper for md_handle_exception. + * src/vm/jit/s390/md.c (md_handle_exception): New function. + * src/vm/jit/s390/md-abi.h (FLT_SAV_CNT): 2, (FLT_RES_CNT): 0. + * src/vm/jit/s390/md-abi.c (abi_registers_float_saved): Added f4 and + f6, (nregdescfloat): Made f4 and f6 saved registers. ........ + [f2f83a695e10] + +2007-08-12 pm + + * src/vm/jit/dseg.c, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md- + abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md.c: + * src/vm/jit/dseg.c (dseg_get_linenumber_from_pc) [__S390__]: Clear + most significant bit of passed pc parameter. + * src/vm/jit/s390/asmpart.S (asm_handle_exception): Rewritten to be + wrapper for md_handle_exception. + * src/vm/jit/s390/md.c (md_handle_exception): New function. + * src/vm/jit/s390/md-abi.h (FLT_SAV_CNT): 2, (FLT_RES_CNT): 0. + * src/vm/jit/s390/md-abi.c (abi_registers_float_saved): Added f4 and + f6, (nregdescfloat): Made f4 and f6 saved registers. + [9a2ce00b716e] + +2007-08-12 michi + + * src/native/Makefile.am, src/native/jni.c, src/native/jni.h, + src/native/localref.c, src/native/localref.h, + src/threads/native/threads.h, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c, + src/vm/vm.c: + * src/native/localref.c: Added new file. + * src/native/localref.h: Likewise. + + * src/native/Makefile.am: Added above two files. + + * src/vm/jit/codegen-common.c (codegen_start_native_call) + (codegen_finish_native_call): Use separate function to deal with + localrefs. + + * src/native/jni.h: Moved localref stuff to own file. + * src/native/jni.c: Likewise. (JNI_CALL_VIRTUAL_METHOD): Added new + macro. (JNI_CALL_NONVIRTUAL_METHOD): Likewise. (JNI_GET_FIELD): + Likewise. (JNI_SET_FIELD): Likewise. (JNI_CALL_STATIC_METHOD): + Likewise. (JNI_GET_STATIC_FIELD): Likewise. (JNI_SET_STATIC_FIELD): + Likewise. (JNI_NEW_ARRAY): Likewise. (JNI_GET_ARRAY_ELEMENTS): + Likewise. (JNI_RELEASE_ARRAY_ELEMENTS): Likewise. + (JNI_GET_ARRAY_REGION): Likewise. (JNI_SET_ARRAY_REGION): Likewise. + + * src/threads/native/threads.h, + * src/vm/jit/arm/codegen.c, + * src/vm/jit/powerpc/codegen.c, + * src/vm/jit/sparc64/codegen.c, + * src/vm/jit/alpha/codegen.c, + * src/vm/jit/s390/codegen.c, + * src/vm/jit/mips/codegen.c, + * src/vm/jit/m68k/codegen.c, + * src/vm/jit/powerpc64/codegen.c, + * src/vm/jit/i386/codegen.c, + * src/vm/jit/x86_64/codegen.c: Added missing include. + [144c435f4cfb] + +2007-08-11 pm + + * src/vm/exceptions.c, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-asm.h, src/vm/jit/s390/md.c, src/vm/vm.c: + * src/vm/exceptions.c (exceptions_handle_exception) [__S390__]: + Synchronization object is at SP - IsSync - 8. + * src/vm/vm.c (vm_array_store_flt) [__S390__]: Float value is in bytes + 4-7 of uint64_t. + * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md- + asm.h: Changed a lot for 8 byte stackslots. + [a9830fedc342] + +2007-08-11 michi + + * src/cacaoh/dummy.c, src/cacaoh/headers.c, src/cacaoh/headers.h, + src/mm/memory.c, src/native/jni.c, src/native/jni.h, + src/native/native.c, src/native/native.h, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/native/vm/java_lang_String.c, + src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/reflect.c, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c, + src/native/vm/sun_misc_Unsafe.c, src/threads/lock-common.h, + src/threads/native/lock.c, src/threads/native/lock.h, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/none/threads.h, src/threads/threads-common.c, + src/toolbox/avl.c, src/toolbox/avl.h, src/toolbox/hashtable.c, + src/toolbox/hashtable.h, src/toolbox/list.h, src/toolbox/util.c, + src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/finalizer.c, src/vm/global.h, + src/vm/initialize.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/asmpart.h, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/patcher.c, src/vm/jit/jit.h, + src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/patcher-common.c, + src/vm/jit/patcher-common.h, src/vm/jit/patcher.h, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/replace.c, src/vm/jit/replace.h, + src/vm/jit/s390/codegen.c, src/vm/jit/show.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c, + src/vm/primitive.c, src/vm/primitive.h, src/vm/properties.c, + src/vm/properties.h, src/vm/signal.c, src/vm/string.c, + src/vm/stringlocal.h, src/vm/vm.c, src/vm/vm.h, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, + src/vmcore/classcache.h, src/vmcore/linker.c, src/vmcore/linker.h, + src/vmcore/loader.c, src/vmcore/loader.h, src/vmcore/method.c, + src/vmcore/method.h, src/vmcore/suck.h: + * src/vm/global.h (java_handle_t): Added typedef. (java_object_t): + New name for what was formerly known as java_objectheader. + + Adapted to above changes and decided where to use handles: + * src/vm/initialize.c + * src/vm/properties.h + * src/vm/jit/arm/codegen.c + * src/vm/jit/powerpc/codegen.c + * src/vm/jit/codegen-common.h + * src/vm/jit/sparc64/codegen.c + * src/vm/jit/sparc64/patcher.c + * src/vm/jit/alpha/codegen.c + * src/vm/jit/optimizing/recompile.c + * src/vm/jit/patcher-common.c + * src/vm/jit/s390/codegen.c + * src/vm/jit/show.c + * src/vm/jit/patcher-common.h + * src/vm/jit/mips/codegen.c + * src/vm/jit/patcher.h + * src/vm/jit/m68k/codegen.c + * src/vm/jit/powerpc64/codegen.c + * src/vm/jit/i386/codegen.c + * src/vm/jit/i386/patcher.c + * src/vm/jit/replace.c + * src/vm/jit/asmpart.h + * src/vm/jit/x86_64/codegen.c + * src/vm/jit/x86_64/patcher.c + * src/vm/jit/replace.h + * src/vm/jit/stacktrace.c + * src/vm/jit/stacktrace.h + * src/vm/jit/codegen-common.c + * src/vm/jit/jit.h + * src/vm/builtin.c + * src/vm/string.c + * src/vm/primitive.c + * src/vm/builtin.h + * src/vm/signal.c + * src/vm/primitive.h + * src/vm/exceptions.c + * src/vm/vm.c + * src/vm/finalizer.c + * src/vm/exceptions.h + * src/vm/stringlocal.h + * src/vm/vm.h + * src/vm/properties.c + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c + * src/native/vm/cldc1.1/java_lang_Class.c + * src/native/vm/cldc1.1/java_lang_String.c + * src/native/vm/cldc1.1/java_lang_Object.c + * src/native/vm/cldc1.1/java_lang_System.c + * src/native/vm/cldc1.1/java_lang_Throwable.c + * src/native/vm/java_lang_Class.c + * src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c + * src/native/vm/gnu/java_lang_VMClassLoader.c + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/java_lang_VMRuntime.c + * src/native/vm/gnu/gnu_classpath_VMStackWalker.c + * src/native/vm/gnu/java_lang_reflect_Field.c + * src/native/vm/gnu/java_lang_reflect_Constructor.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/java_lang_Object.c + * src/native/vm/java_lang_String.c + * src/native/vm/java_lang_Thread.c + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/sun/jvm.c + * src/native/vm/reflect.c + * src/native/vm/java_lang_Runtime.c + * src/native/vm/java_lang_reflect_Method.c + * src/native/vm/reflect.h + * src/native/vm/java_lang_Runtime.h + * src/native/vm/java_lang_reflect_Constructor.c + * src/native/jni.h + * src/native/native.c + * src/native/native.h + * src/toolbox/hashtable.h + * src/toolbox/util.c + * src/toolbox/list.h + * src/toolbox/avl.c + * src/toolbox/avl.h + * src/toolbox/hashtable.c + * src/mm/memory.c + * src/threads/none/threads.h + * src/threads/threads-common.c + * src/threads/lock-common.h + * src/threads/native/threads.h + * src/threads/native/lock.c + * src/threads/native/threads.c + * src/threads/native/lock.h + * src/vmcore/class.c + * src/vmcore/loader.c + * src/vmcore/suck.h + * src/vmcore/class.h + * src/vmcore/loader.h + * src/vmcore/method.c + * src/vmcore/method.h + * src/vmcore/classcache.c + * src/vmcore/classcache.h + * src/vmcore/linker.c + * src/vmcore/linker.h + * src/cacaoh/headers.h + * src/cacaoh/dummy.c + * src/cacaoh/headers.c + [be809e5a11d0] + +2007-08-11 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.c: + * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): Fixed pending + issue from regoff change. + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Likewise. + + * src/vm/jit/sparc64/emit.c (emit_trap): Added. + [9ca4d7cfc72d] + +2007-08-11 twisti + + * src/vm/vm.h: + * src/vm/vm.h: Set Id keyword. + [be91580c1d11] + + * src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (VM_CALL_METHOD): New macro. (VM_CALL_METHOD_VALIST): + Likewise. (VM_CALL_METHOD_JVALUE): Likewise. (VM_CALL_ARRAY): + Likewise. + + * src/vm/vm.h (vm_call_method_int): Changed return type to stdint- + type. (vm_call_method_int_valist): Likewise. + (vm_call_method_int_jvalue): Likewise. (vm_call_method_long): + Likewise. (vm_call_method_long_valist): Likewise. + (vm_call_method_long_jvalue): Likewise. + [bf3f6683be8c] + + * src/native/jni.c, src/native/vm/gnu/java_lang_reflect_Field.c, + src/vm/primitive.c, src/vm/primitive.h: + * src/vm/primitive.c (native/jni.h): Added. (native/llni.h): + Likewise. (native/include/java_lang_Boolean.h, + native/include/java_lang_Byte.h, native/include/java_lang_Short.h, + native/include/java_lang_Character.h, + native/include/java_lang_Integer.h, native/include/java_lang_Long.h, + native/include/java_lang_Float.h, + native/include/java_lang_Double.h): Likewise. (vm/builtin.h): + Likewise. (vm/vm.h): Likewise. (primitive_box): New function. + (primitive_unbox): Likewise. (PRIMITIVE_BOX_TYPE): New macro for + primitive_box_xxx functions. (PRIMITIVE_UNBOX_TYPE): New macro for + primitive_unbox_xxx functions. + + * src/vm/primitive.h (primitive_box): Added. (primitive_unbox): + Likewise. (primitive_box_boolean, primitive_box_byte, + primitive_box_char, primitive_box_short, primitive_box_int, + primitive_box_long, primitive_box_float, primitive_box_double): + Likewise. (primitive_unbox_boolean, primitive_unbox_byte, + primitive_unbox_char, primitive_unbox_short, primitive_unbox_int, + primitive_unbox_long, primitive_unbox_float, + primitive_unbox_double): Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Use primitive-box + functions. + + * src/native/vm/gnu/java_lang_reflect_Field.c (get): Likewise. + [23a46bc80fdd] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_GC): Call GC-call directly, use + TRACEJVMCALLS. (JVM_TotalMemory): Likewise. (JVM_FreeMemory): + Likewise. (JVM_NewArray): Use TRACEJVMCALLS. + [537eb6a207c4] + +2007-08-10 twisti + + * src/native/vm/reflect.c: + * src/native/vm/reflect.c (reflect_field_new): Fixed compilation. + (reflect_method_new): Likewise. + [27deec01d70f] + + * src/cacaoh/dummy.c, src/native/jni.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vm/Makefile.am, src/vm/builtin.c, src/vm/jit/verify/typecheck- + stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/primitive.c, src/vm/primitive.h, src/vm/resolve.c, + src/vm/string.c, src/vm/vm.c, src/vmcore/Makefile.am, + src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/primitive.c, src/vmcore/primitive.h, + src/vmcore/primitivecore.c: + * src/vmcore/primitive.c: Removed. + * src/vmcore/primitive.h: Likewise. + + * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Removed + primitive.[ch]. + + * src/vmcore/primitivecore.c: New file. + * src/vm/primitive.c: Likwise. + * src/vm/primitive.h: Likewise. + + * src/vm/Makefile.am (libvm_la_SOURCES): Added primitive.[ch]. + + * src/cacaoh/dummy.c (vm/primitive.h): Added. + (primitive_class_get_by_type): New function. + (primitive_class_get_by_char): Likewise. + + * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vm/builtin.c, src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/resolve.c, src/vm/string.c, src/vm/vm.c, + src/vmcore/descriptor.c, src/vmcore/field.c, src/vmcore/linker.c, + src/vmcore/loader.c: Changed primitive.h include. + [42d1724d0ac8] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_FromReflectedField): Added missing ;. + [650582ff466a] + +2007-08-10 michi + + * src/vm/jit/patcher-common.c, src/vm/jit/powerpc/patcher.c, + src/vmcore/linker.c: + * src/vm/jit/powerpc/patcher.c (patcher_get_putfield): Fixed severe + bug for unalligned long field offsets. + + * src/vmcore/linker.c [__POWERPC__ && __DARWIN__]: Long fields are + 4-byte alligned in structs. + + * src/vm/jit/patcher-common.c [TRACE_PATCHER]: Left patcher trace + code hanging around, might come handy again. + [40bd4faac269] + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/vm/gnu/java_lang_reflect_Method.c: Fixed merge problem + in previous revision 8284. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. + [26177c366515] + + * src/native/jni.c, src/native/llni.h, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_String.c, + src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/reflect.c, + src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c, + src/threads/threads-common.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/jit/stacktrace.c, src/vm/string.c, src/vm/vm.c: + * src/native/llni.h: Added LLNI (low level native interface). + + Use LLNI macros throughout the whole codebase: + * src/vm/jit/stacktrace.c + * src/vm/string.c + * src/vm/builtin.c + * src/vm/exceptions.c + * src/vm/vm.c + * src/native/jni.c + * src/native/vm/java_lang_ClassLoader.c + * src/native/vm/java_lang_Class.c + * src/native/vm/java_lang_String.c + * src/native/vm/java_lang_Object.c + * src/native/vm/gnu/java_lang_VMThread.c + * src/native/vm/gnu/java_lang_reflect_Method.c + * src/native/vm/gnu/java_lang_reflect_Field.c + * src/native/vm/gnu/java_lang_reflect_Constructor.c + * src/native/vm/gnu/java_lang_VMThrowable.c + * src/native/vm/java_lang_Thread.c + * src/native/vm/sun_misc_Unsafe.c + * src/native/vm/reflect.c + * src/native/vm/java_lang_reflect_Method.c + * src/native/vm/java_lang_reflect_Constructor.c + * src/threads/threads-common.c + * src/threads/native/threads.c + [7abb5f785e04] + +2007-08-09 twisti + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md- + os.c, src/vm/jit/x86_64/linux/md-os.c, src/vm/signal.c, + src/vm/signallocal.h: + * src/vm/exceptions.c (toolbox/logging.h): Removed. + (vm/jit/disass.h): Likewise. (exceptions_new_hardware_exception): + Likewise. + + * src/vm/exceptions.h (exceptions_new_hardware_exception): Likewise. + + * src/vm/signal.c (stdint.h): Added. (toolbox/logging.h): Likewise. + (vm/jit/codegen-common.h): Likewise. (vm/jit/disass.h): Likewise. + (vm/jit/patcher-common.h): Likewise. (signal_handle): New function. + + * src/vm/signallocal.h (signal_handle): Likewise. + + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/powerpc/darwin/md-os.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc64/linux/md- + os.c, src/vm/jit/s390/md.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/linux/md-os.c: + Use new signal_handle function. + [782800380bb8] + + * src/vm/signal.c, src/vm/signallocal.h: + * src/vm/signal.c (vm/types.h): Removed. (signal_init): Use + signal_register_signal. (signal_register_signal): New function. + + * src/vm/signallocal.h (vm/types.h): Removed. + (signal_register_signal): New function. + [55ce6c52817b] + + * NEWS: + * NEWS: Added news. + [d615712a54cb] + + * NEWS: + * NEWS: Added 0.99 release and some news. + [bb055927a1b4] + +2007-08-09 michi + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/linux/md-os.c [ENABLE_REPLACEMENT] + (md_replace_executionstate_read): Implemented. [ENABLE_REPLACEMENT] + (md_replace_executionstate_write): Likewise. + + * src/vm/jit/alpha/asmpart.S (asm_replacement_out): Removed. + (asm_replacement_in): Likewise. + [0e6fe86aa40d] + +2007-08-08 michi + + * src/vm/jit/asmpart.h, src/vm/jit/replace.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c: + * src/vm/jit/s390/emit.c (emit_replacement_stubs): Removed obsolete + function. + * src/vm/jit/s390/codegen.c (codegen_emit): Do not create replacement + stubs. + * src/vm/jit/replace.c (replace_me): No longer call + asm_replacement_in. + * src/vm/jit/asmpart.h [ENABLE_REPLACEMENT]: Removed obsolete + prototypes. + [a336a3194fe3] + + * src/vm/builtin.c, src/vmcore/class.c, src/vmcore/linker.c: + * src/vmcore/linker.c (linker_compute_subclasses): Added attention + notice about the locking mechanism. + + * src/vmcore/class.c (class_isanysubclass): Uses + linker_classrenumber_lock now. + + * src/vm/builtin.c (builtin_canstore): Likewise. + (builtin_canstore_onedim): Likewise. + (builtin_canstore_onedim_class): Likewise. + [2173a4b92ae4] + +2007-08-08 twisti + + * src/vm/jit/arm/asmpart.S: + * src/vm/jit/arm/asmpart.S (offsets.h): Removed. + [7864c8165337] + + * configure.ac, src/threads/critical.c, src/vm/jit/Makefile.am, + src/vm/jit/alpha/Makefile.am, src/vm/jit/alpha/asmpart.S, + src/vm/jit/arm/Makefile.am, src/vm/jit/arm/asmpart.S, + src/vm/jit/asmpart.h, src/vm/jit/i386/Makefile.am, + src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/Makefile.am, + src/vm/jit/m68k/asmpart.S, src/vm/jit/mips/Makefile.am, + src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/Makefile.am, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/darwin/md-asm.h, + src/vm/jit/powerpc64/Makefile.am, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/s390/Makefile.am, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/tools/Makefile.am, src/vm/jit/tools/genoffsets.c, + src/vm/jit/x86_64/Makefile.am, src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/tools: Removed. + + * configure.ac (AC_CONFIG_FILES): Removed src/vm/jit/tools/Makefile. + * src/vm/jit/Makefile.am (DIST_SUBDIRS): Removed tools. (SUBDIRS): + Likewise. + + * src/threads/critical.c (stdint.h): Added. (vm/jit/asmpart.h): + Removed. (critical_init): Don't call + critical_register_asm_critical_sections. + (critical_register_asm_critical_sections): Removed. + + * src/vm/jit/asmpart.h (ASM_GETCLASSVALUES_ATOMIC): Removed. + (asm_criticalsections): Likewise. (asm_getclassvalues_atomic): + Likewise. (intrp_asm_getclassvalues_atomic): Likewise. + + * src/vm/jit/alpha/Makefile.am, src/vm/jit/arm/Makefile.am, + src/vm/jit/i386/Makefile.am, src/vm/jit/m68k/Makefile.am, + src/vm/jit/mips/Makefile.am, src/vm/jit/powerpc/Makefile.am, + src/vm/jit/powerpc64/Makefile.am, src/vm/jit/s390/Makefile.am, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/x86_64/Makefile.am + (BUILT_SOURCES): Removed (CLEANFILES): Likewise. (offsets.h): + Likewise. + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/m68k/asmpart.S, + src/vm/jit/mips/asmpart.S, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S + (offsets.h): Removed. (asm_getclassvalues_atomic): Likewise. + (asm_criticalsections): Likewise. + + * src/vm/jit/powerpc/darwin/md-asm.h (asm_criticalsections): + Removed. (asm_getclassvalues_atomic): Likewise. + [62317689105b] + + * src/vm/builtin.c, src/vmcore/class.c: + * src/vmcore/class.c (class_isanysubclass): Don't use + ASM_GETCLASSVALUES_ATOMIC anymore, we will change that to use the + class-renumbering lock. + + * src/vm/builtin.c (builtin_canstore): Likewise. + (builtin_canstore_onedim): Likewise. + (builtin_canstore_onedim_class): Likewise. + [60640d7b8794] + + * src/native/vm/java_lang_Thread.c, src/threads/threads-common.c: + * src/threads/threads-common.c (stdint.h): Added. + (threads_thread_free): Also save and restore the thread state (this + is required for CLDC1.1, but is generally a good idea). + + * src/native/vm/java_lang_Thread.c (isAlive) + [WITH_CLASSPATH_CLDC1_1]: Check for NULL. + [4478b69824a6] + + * src/vm/jit/m68k/md.c, src/vm/jit/tools/genoffsets.c, src/vm/vm.h: + * src/vm/vm.h (vm_arg): Removed. + + * src/vm/jit/tools/genoffsets.c (main): Removed sizevmarg, + offvmargtype and offvmargdata. + + * src/vm/jit/m68k/md.c (md_init): Removed some obsolete checks. + [90eedc2247c7] + + * src/native/jni.c, src/vm/exceptions.c, src/vm/jit/asmpart.h, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (vm_array_store_flt): Handle __POWERPC__ correctly. + (vm_vmargs_from_valist): Removed. (vm_vmargs_from_jvalue): Likewise. + (vm_vmargs_from_objectarray): Likewise. (vm_call_method_vmarg): + Likewise. (vm_call_method_int_vmarg): Likewise. + (vm_call_method_int_valist): Likewise. (vm_call_method_int_jvalue): + Likewise. (vm_call_method_long_vmarg): Likewise. + (vm_call_method_long_valist): Likewise. + (vm_call_method_long_jvalue): Likewise. + (vm_call_method_float_vmarg): Likewise. + (vm_call_method_float_valist): Likewise. + (vm_call_method_float_jvalue): Likewise. + (vm_call_method_double_vmarg): Likewise. + (vm_call_method_double_valist): Likewise. + (vm_call_method_double_jvalue): Likewise. (vm_call_method_valist): + Removed old implementation. (vm_call_method_jvalue): Likewise. + + * src/vm/vm.h: Removed old prototypes. + * src/vm/jit/asmpart.h: Likewise. + + * src/vm/exceptions.c (exceptions_handle_exception) [__POWERPC__]: + Get monitor object correctly (talk to Michi because of ARM). + + * src/native/jni.c (_Jv_jni_invokeNative): Removed old + implementation. + + * src/vm/jit/powerpc/linux/md-abi.c (md_param_alloc): Use 8-byte + stackslots. (md_param_alloc_native): Implemented native ABI. + + * src/vm/jit/powerpc/emit.c (emit_load): Merged TYPE_FLT and + TYPE_DBL. (emit_store): Likewise + * src/vm/jit/powerpc/darwin/md-abi.c: Likewise. + + * src/vm/jit/powerpc/arch.h (HAS_4BYTE_STACKSLOT): Removed. + (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY): + Likewise. + + * src/vm/jit/powerpc/codegen.c: Implemented 8-byte stackslots, + always load and store float-values as double (PowerPC's internal + register representation is the same). + + * src/vm/jit/powerpc/asmpart.S (asm_vm_call_method): Use new + argument array. (asm_handle_exception): Restore callee-saved + registers from the correct location. + [ebe852e9b203] + +2007-08-07 twisti + + * tests/rtIn/at/dms/kjc/Main, tests/rtMissedIn0: + * tests/rtMissedIn0: Removed. + * tests/rtIn: Likewise. + [f86792ac8455] + + * src/native/jni.c, src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/sun_misc_Unsafe.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/patcher.c, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/patcher.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/patcher.c, src/vmcore/field.c, src/vmcore/field.h, + src/vmcore/loader.c: + * src/vmcore/field.c (mm/memory.h): Added. (vm/global.h): Likewise. + (field_load): Allocate value memory only for static and final + fields. + + * src/vmcore/field.h (fieldinfo): Made value a pointer. + + * src/vmcore/loader.c (load_class_from_classbuffer): Allocate + fieldinfo's on the C heap. + + * src/native/jni.c: fieldinfo->value is now a pointer. + * src/native/vm/sun_misc_Unsafe.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/patcher.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/patcher.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/patcher.c: Likewise. + [49bab45fbf51] + + * src/vm/jit/i386/emit.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/x86_64/emit.c: + * src/vm/jit/i386/emit.c (emit_trap): New function. + * src/vm/jit/powerpc64/emit.c: Likewise. + * src/vm/jit/x86_64/emit.c: Likewise. + [d544fbdb5d62] + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_preinit): Fixed compiler + warning. + [d070b6565b63] + +2007-08-06 twisti + + * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h: + * src/vm/jit/emit-common.c: Set Id keyword. + * src/vm/jit/emit-common.h: Likewise. + [1b592a73a3b0] + + * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/patcher.c, src/vm/jit/patcher-common.h, + src/vm/jit/patcher.h: + * src/vm/jit/patcher-common.h: Added __MIPS__ for new patcher + functions. + + * src/vm/jit/patcher.h: Added __MIPS__ to include-check. + + * src/vm/jit/mips/emit.c (vm/jit/patcher-common.h): Added. + (emit_patcher_stubs): Removed. (emit_trap): Added. + + * src/vm/jit/mips/codegen.c (vm/jit/patcher.h): Removed. (vm/jit + /patcher-common.h): Added. (codegen_emit): Replaced + codegen_add_patch_ref with patcher_add_patch_ref, and + emit_patcher_stubs with emit_patcher_traps. + (codegen_emit_stub_native): Likewise. + + * src/vm/jit/mips/codegen.h (PATCHER_CALL_INSTRUCTIONS): Changed to + 1. (PATCHER_CALL_SIZE): Changed to 1*4. (PATCHER_NOPS): Emit only + one NOP. + + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Check + for exception, set PC in trap-case. + + * src/vm/jit/mips/irix/md-os.c (md_signal_handler_sigsegv): Check + for exception. + + * src/vm/jit/mips/patcher.c: Renamed function to new patcher + functions, and use patcher references. (vm/jit/patcher.h): Removed. + (vm/jit/patcher-common.h): Added (patcher_wrapper): Removed. + + * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Removed. + [3927f23b8cb3] + + * src/vm/jit/mips/arch.h: + * src/vm/jit/mips/arch.h (SUPPORT_PASS_FLOATARGS_IN_INTREGS): + Removed duplicate define. + [db0217c3ef05] + +2007-08-06 panzi + + * src/lib/Makefile.am, src/lib/gnu/java/lang/reflect/Constructor.java, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java, + src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, src/native/vm/reflect.c, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c, + src/vmcore/annotation.c, src/vmcore/method.c, src/vmcore/method.h: + * src/lib/gnu/java/lang/reflect/Method.java + (java.lang.annotation.Annotation): Added import. (java.util.Map): + Added import. (sun.refelct.annotation.AnnotationParser): Added + import. (declaredAnnotations): Added field (inspired by OpenJDK). + (getAnnotation): Added method. (getDeclaredAnnotations): Added + method. (declaredAnnotations): Added method (inspired by OpenJDK). + (getParameterAnnotations): Added method. + + * src/lib/gnu/java/lang/reflect/Field.java + (java.lang.annotation.Annotation): Added import. (java.util.Map): + Added import. (sun.refelct.annotation.AnnotationParser): Added + import. (declaredAnnotations): Added field (inspired by OpenJDK). + (getAnnotation): Added method. (getDeclaredAnnotations): Added + method. (declaredAnnotations): Added method (inspired by OpenJDK). + + * src/lib/gnu/java/lang/reflect/Constructor.java: Copied file from + GNU Classpath. (java.lang.annotation.Annotation): Added import. + (java.util.Map): Added import. + (sun.refelct.annotation.AnnotationParser): Added import. + (declaredAnnotations): Added field (inspired by OpenJDK). + (getAnnotation): Added method. (getDeclaredAnnotations): Added + method. (declaredAnnotations): Added method (inspired by OpenJDK). + (getParameterAnnotations): Added method. + + * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java: + Removed. + + * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: + Removed. I figured out which class of GNU Classpath to use to + replace this self written class. + + * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java: Added a + few comments. (sun.reflect.generics.parser.SignatureParser): Removed + import. (sun.reflect.generics.parser.SignatureFormatError): Removed + import. (gnu.java.lang.reflect.FieldSignatureParser): Added import. + (parseParameterAnnotations): Added method. (parseSig): Changed + method so it uses GNU Classpaths FieldSignatureParser. + + * src/lib/Makefile.am (VM_JAVA_FILES): Added + $(top_srcdir)/src/lib/gnu/java/lang/reflect/Constructor.java + (VM_CLASS_FILES): Added classes/java/lang/reflect/Constructor.class + + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): + Cache methodinfo for + sun.reflect.annotation.AnnotationParser.parseAnnotationsIntoArray. + + * src/native/vm/gnu/java_lang_reflect_Method.c [ENABLE_ANNOTATIONS] + (native/vm/reflect.h): Added include. [ENABLE_ANNOTATIONS] + (declaredAnnotations): Added method. [ENABLE_ANNOTATIONS] + (getParameterAnnotations): Added method. [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_getDefaultValue): Cache methodinfo + for sun.reflect.annotation.AnnotationParser.parseDefaultValue. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_declaredAnnotations): Added. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_getParameterAnnotations): Added. + + * src/native/vm/gnu/java_lang_reflect_Field.c [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Added include. + [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include. + [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Field_declaredAnnotations): Added. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + [ENABLE_ANNOTATIONS] (vm/vm.h): Added include. [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Added include. + [ENABLE_ANNOTATIONS] (native/vm/reflect.h): Added include. + [ENABLE_ANNOTATIONS] (declaredAnnotations): Added method. + [ENABLE_ANNOTATIONS] (getParameterAnnotations): Added method. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Constructor_declaredAnnotations): Added. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Constructor_getParameterAnnotations): Added. + + * src/native/vm/reflect.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (vm/vm.h): Added include. [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Added include. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added. + + * src/native/vm/reflect.h [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (reflect_get_declaredannotatios): Added. [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (reflect_get_parameterannotations): Added. + + * src/native/vm/sun/jvm.c (JVM_GetDeclaredClasses): Implemented + (needed by a testcase of mine). + + * src/vmcore/method.c (method_get_parametercount): Added. This + function gets the parameter count of a method (not counting the this + pointer of non-static methods). Returns -1 in case of an error. + + * src/vmcore/method.h (method_get_parametercount): Added. + [f5cb5fb3404e] + +2007-08-06 michi + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed + obsolete code about PATCHER_LONGBRANCHES_NOPS. + [1bc6a2ee1f2d] + + * src/vm/jit/alpha/emit.c, src/vm/jit/arm/emit.c, src/vm/jit/emit- + common.c, src/vm/jit/emit-common.h, src/vm/jit/powerpc/emit.c, + src/vm/jit/s390/emit.c: + * src/vm/jit/emit-common.c (emit_patcher_traps): Added. + + * src/vm/jit/emit-common.h (emit_trap): Added prototype. + + * src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to + emit-common). (emit_trap): Implemented. + + * src/vm/jit/arm/emit.c: Likewise. + + * src/vm/jit/powerpc/emit.c: Likewise. + + * src/vm/jit/s390/emit.c: Likewise. + [346f9ec5827a] + +2007-08-05 edwin + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_read_executionstate): Improved + comments. (replace_write_executionstate): Likewise. + [6aec81ae2149] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_new_sourceframe): Fixed + documentation. + [77f8bf7f70b4] + +2007-08-05 twisti + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (stdint.h): Added. + (patcher_list_free): Removed unused variable pr. + (patcher_add_patch_ref): Fixed warning. + [e43253cb24fb] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_Available) [FIONREAD]: Use HotSpot- + compatible code. + [5142a17c3bc0] + +2007-08-03 michi + + * src/vm/jit/codegen-common.c, src/vm/jit/patcher-common.c, src/vm/jit + /patcher-common.h: + * src/vm/jit/patcher-common.c (patcher_list_reset): Added. + (patcher_add_patch_ref) [!NDEBUG]: Added sanity check. + + * src/vm/jit/patcher-common.h (patcher_list_reset): Added. + + * src/vm/jit/codegen-common.c (codegen_reset): Resets the patcher + list. + [26187f44fa78] + +2007-08-03 pm + + * src/vm/jit/patcher-common.c: + * src/vm/jit/patcher-common.c (patcher_handler): Call + LOCK_MONITOR_EXIT instead of LOCK_MONITOR_ENTER in double-patching + handler code. + [df81594b92d3] + +2007-08-02 twisti + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_RaiseSignal): New function. + [bfad8af45e64] + +2007-08-01 twisti + + * m4/ac_prog_javac.m4, src/lib/Makefile.am: + * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Removed -1.5 from ecj. + + * src/lib/Makefile.am (vm.zip): Added -source 1.5 -target 1.5. + Thanks to Mark Wielaard. + [a38b1afb2c67] + +2007-08-01 pm + + * src/vm/jit/patcher-common.h, src/vm/jit/patcher.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c: + * jit/patcher.h: Added #error if included on s390. + * jit/patcher-common.h: Made declarations visible on s390. + * jit/s390/asmpart.S (asm_patcher_wrapper): removed. + * jit/s390/emit.c (emit_patcher_stubs): removed, (emit_patcher_traps): + added. + * jit/s390/codegen.h (PATCHER_LONGBRANCHES_NOPS_SKIP, + PATCHER_LONGBRANCHES_NOPS): removed, (PATCHER_CALL_SIZE, + PATCHER_NOPS, PATCHER_NOPS_SKIP) adapted to patching via signals. + * jit/s390/codegen.c (codegen_emit, codegen_emit_stub_native): Adapted + to paching via signals. + * jit/s390/md.c (md_signal_handler_sigill, md_signal_handler_sigsegv): + added support for exceptions_new_hardware_exception returning NULL. + * jit/s390/patcher.c: Adapted to paching via signals. + [d5451a151292] + +2007-07-31 twisti + + * configure.ac, m4/annotations.m4: + * m4/annotations.m4: New file. + * configure.ac: Use AC_CHECK_ENABLE_ANNOTATIONS. + [cf7daf180ded] + +2007-07-31 panzi + + * configure.ac, src/lib/Makefile.am, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/sun/reflect/ConstantPool.java, + src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, + src/lib/gnu/sun/reflect/annotation/AnnotationType.java, src/lib/gnu/ + sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, sr + c/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java, + src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java, + src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java, + src/native/include/Makefile.am, src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_reflect_ConstantPool.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/reflect.c, src/native/vm/sun/jvm.c, + src/vmcore/Makefile.am, src/vmcore/annotation.c, + src/vmcore/annotation.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/utf8.c, + src/vmcore/utf8.h: + * src/lib/gnu/java/lang/reflect/Method.java (annotations): Added. + (parameterAnnotations): Added. (annotationDefault): Added. + + * src/lib/gnu/java/lang/reflect/Field.java (annotations): Added. + + * src/lib/gnu/sun/reflect: New directory. + * src/lib/gnu/sun/reflect/generics: New directory. + * src/lib/gnu/sun/reflect/generics/parser: New directory. + * src/lib/gnu/sun/reflect/generics/parser/SignatureFormatError.java: + New file. + + * src/lib/gnu/sun/reflect/generics/parser/SignatureParser.java: New + file. This class parses type signatures and returns the acording + type as a java.lang.Class instance. + + * src/lib/gnu/sun/reflect/ConstantPool.java [WITH_CLASSPATH_GNU]: + New file. + + * src/lib/gnu/sun/reflect/annotation: New directory. + * src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionPr + oxy.java [WITH_CLASSPATH_GNU]: Copied file from OpenJDK. + + * + src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java + [WITH_CLASSPATH_GNU]: Copied file from OpenJDK. + + * src/lib/gnu/sun/reflect/annotation/AnnotationParser.java + [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so + it can be used with GNU Classpath. [WITH_CLASSPATH_GNU] + (parseAnnotationsIntoArray): Added for convenience. + [WITH_CLASSPATH_GNU] (parseAnnotationDefault): Added for + convenience. + + * src/lib/gnu/sun/reflect/annotation/AnnotationType.java + [WITH_CLASSPATH_GNU]: Copied file from OpenJDK and changed a bit so + it can be used with GNU Classpath. [WITH_CLASSPATH_GNU] + (annotationTypes): Added to emulate + sun.misc.SharedSecrets.getJavaLangAccess().getAnnotationType() and + sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType(). + + * src/lib/Makefile.am [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS]: + Added classes needed by annotations support. + + * src/native/vm/nativevm.h [ENABLE_ANNOTATIONS] + (_Jv_sun_reflect_ConstantPool_init): Added. + + * src/native/vm/java_lang_Class.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (vmcore/annotation.h): Include added. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Include added. + [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (_Jv_java_lang_Class_getDeclaredAnnotations): Implemented. + + * src/native/vm/gnu/java_lang_VMClass.c [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] + (Java_java_lang_VMClass_getDeclaredAnnotations): Implemented. + + * src/native/vm/gnu/sun_reflect_ConstantPool.c [ENABLE_ANNOTATIONS]: + Added implementation of sun.reflect.ConstantPool class. This is an + copy of the according functions from src/native/vm/sun/jvm.c for I + don't know how to unify it better (needs to be discussed). + + * src/native/vm/gnu/java_lang_reflect_Method.c [ENABLE_ANNOTATIONS] + (vm/vm.h): Added include. [ENABLE_ANNOTATIONS] + (native/include/sun_reflect_ConstantPool.h): Added include. + [ENABLE_ANNOTATIONS] + (Java_java_lang_reflect_Method_getDefaultValue): Implemented. + + * src/native/vm/gnu/Makefile.am [ENABLE_ANNOTATIONS] + (SUN_REFLECT_SOURCES): Added sun_reflect_ConstantPool.c + + * src/native/vm/java_lang_Class.h [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (_Jv_java_lang_Class_getDeclaredAnnotations): + Added. + + * src/native/vm/sun/jvm.c (assert.h): Added include. + (native/include/java_lang_Integer.h): Added include. + (native/include/java_lang_Long.h): Added include. + (native/include/java_lang_Short.h): Added include. + (native/include/java_lang_Byte.h): Added include. + (native/include/java_lang_Character.h): Added include. + (native/include/java_lang_Boolean.h): Added include. + (native/include/java_lang_Float.h): Added include. + (native/include/java_lang_Double.h): Added include. + [ENABLE_ANNOTATIONS] (native/include/sun_reflect_ConstantPool.h): + Added include. (JVM_GetDeclaringClass): Implemented. + (JVM_GetClassAnnotations) [ENABLE_ANNOTATIONS]: Implemented. + (JVM_GetFieldAnnotations): Implemented. (JVM_GetMethodAnnotations): + Implemented. (JVM_GetMethodDefaultAnnotationValue): Implemented. + (JVM_GetMethodParameterAnnotations): Implemented. + [ENABLE_ANNOTATIONS] (JVM_GetClassConstantPool): Implemented. + (JVM_ConstantPoolGetSize): Implemented. + (JVM_ConstantPoolGetClassAt): Implemented. + (JVM_ConstantPoolGetClassAtIfLoaded): Implemented. + (JVM_ConstantPoolGetMethodAt): Implemented. + (JVM_ConstantPoolGetMethodAtIfLoaded): Implemented. + (JVM_ConstantPoolGetFieldAt): Implemented. + (JVM_ConstantPoolGetFieldAtIfLoaded): Implemented. + (JVM_ConstantPoolGetIntAt): Implemented. + (JVM_ConstantPoolGetLongAt): Implemented. + (JVM_ConstantPoolGetFloatAt): Implemented. + (JVM_ConstantPoolGetDoubleAt): Implemented. + (JVM_ConstantPoolGetStringAt): Implemented. + (JVM_ConstantPoolGetUTF8At): Implemented. (JVM_GetArrayElement): + Quickly implemented (will be rewritten by twisti). I needed this + function in a testcase and not directly for annotations support. + + * src/native/vm/reflect.c [ENABLE_ANNOTATIONS] (mm/memmory.h): Added + include. (reflect_constructor_new) [ENABLE_ANNOTATIONS]: Load + annotations and parameter annotations. (reflect_field_new) + [ENABLE_ANNOTATIONS]: Load annotations. (reflect_method_new) + [ENABLE_ANNOTATIONS]: Load annotations, parameter annotations and + annotation default value. + + * src/native/vm/nativevm.c [WITH_CLASSPATH_GNU] [ENABLE_ANNOTATIONS] + (_Jv_sun_reflect_ConstantPool_init): Added call. + + * src/native/include/Makefile.am [WITH_CLASSPATH_GNU] + [ENABLE_ANNOTATIONS] (JAVASE_HEADER_FILES): Added + sun_reflect_ConstantPool.h + + * src/vmcore/class.c [ENABLE_ANNOTATIONS] + (class_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + (class_sun_reflect_annotation_AnnotationParser): Added. + (class_load_attributes) [ENABLE_ANNOTATIONS]: Load annotations. + (class_free) [ENABLE_ANNOTATIONS]: Free annotations. + + * src/vmcore/loader.c (loader_init) [ENABLE_ANNOTATIONS]: Load + class_sun_reflect_ConstantPool. (loader_init) [ENABLE_ANNOTATIONS] + [WITH_CLASSPATH_GNU]: Load + class_sun_reflect_annotation_AnnotationParser. + + * src/vmcore/annotation.c [!ENABLE_ANNOTATIONS]: Error: annotation + support has to be enabled when compling this file. (assert.h): Added + include. (toolbox/logging.h): Added include. + (annotation_bytearray_new): Added. (annotation_bytearray_free): + Added. (annotation_bytearrays_new): Added. + (annotation_bytearrays_resize): Added. + (annotation_bytearrays_insert): Added. (annotation_bytearrays_free): + Added. (annotation_load_attribute_body): Added. Maybe this function + should be called loader_load_attribute_body and located in + vmcore/loader.c? + (annotation_load_method_attribute_annotationdefault): Added. (annota + tion_load_method_attribute_runtimevisibleparameterannotations): + Added. (annotation_load_method_attribute_runtimeinvisibleparameteran + notations): Added. + (annotation_load_class_attribute_runtimevisibleannotations): Added. + (annotation_load_class_attribute_runtimeinvisibleannotations): + Added. (annotation_load_method_attribute_runtimevisibleannotations): + Added. + (annotation_load_method_attribute_runtimeinvisibleannotations): + Added. (annotation_load_field_attribute_runtimevisibleannotations): + Added. + (annotation_load_field_attribute_runtimeinvisibleannotations): + Added. + + * src/vmcore/class.h [ENABLE_ANNOTATIONS] + (runtimevisibleannotationscount): Removed. [ENABLE_ANNOTATIONS] + (runtimevisibleannotations): Removed. [ENABLE_ANNOTATIONS] + (annotations): Added. Bytearray of the unparsed annotations or NULL + if none. [ENABLE_ANNOTATIONS] (method_annotations): Added. Array of + bytearrays of method annotations. This Array is only as big as + needed or NULL if there are no method annotations at all. + [ENABLE_ANNOTATIONS] (method_parameterannotations): Added. Array of + bytearrays of method parameter annotations. This Array is only as + big as needed or NULL if there are no method parameter annotations + at all. [ENABLE_ANNOTATIONS] (method_annotationdefaults): Added. + Array of bytearrays of method annotation default values. This Array + is only as big as needed or NULL if there are no method annotation + default values at all. [ENABLE_ANNOTATIONS] (field_annotations): + Added. Array of bytearrays of field annotations. This Array is only + as big as needed or NULL if there are no field annotations at all. + [ENABLE_ANNOTATIONS] (class_sun_reflect_ConstantPool): Added. + [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] + (class_sun_reflect_annotation_AnnotationParser): Added. + + * src/vmcore/annotation.h (annotation_bytearray_t): Added. Used to + store unparsed (parameter-) annotations or unparsed annotation + default values in. (annotation_bytearrays_t): Added. Array of + bytearrays. (annotation_bytearray_new): Added. + (annotation_bytearray_free): Added. (annotation_bytearrays_new): + Added. (annotation_bytearrays_resize): Added. + (annotation_bytearrays_insert): Added. (annotation_bytearrays_free): + Added. + (annotation_load_class_attribute_runtimeinvisibleannotations): + Added. (annotation_load_method_attribute_runtimevisibleannotations): + Added. + (annotation_load_method_attribute_runtimeinvisibleannotations): + Added. (annotation_load_field_attribute_runtimevisibleannotations): + Added. + (annotation_load_field_attribute_runtimeinvisibleannotations): + Added. (annotation_load_method_attribute_annotationdefault): Added. ( + annotation_load_method_attribute_runtimevisibleparameterannotations) + : Added. (annotation_load_method_attribute_runtimeinvisibleparameter + annotations): Added. + + * src/vmcore/method.c (method_load) [ENABLE_ANNOTATIONS]: Load + annotations, parameter annotations and annotation default values. + [ENABLE_ANNOTATIONS] (method_get_annotations): Added. + [ENABLE_ANNOTATIONS] (method_get_parameterannotations): Added. + [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added. + + * src/vmcore/method.h [ENABLE_ANNOTATIONS] (method_get_annotations): + Added. [ENABLE_ANNOTATIONS] (method_get_parameterannotations): + Added. [ENABLE_ANNOTATIONS] (method_get_annotationdefault): Added. + + * src/vmcore/field.c (mm/memory.h): Added include. + (vmcore/annotations.h): Added include. (field_load) + [ENABLE_ANNOTATIONS]: Laod annotations. [ENABLE_ANNOTATIONS] + (field_get_annotations): Added. + + * src/vmcore/utf8.c [ENABLE_ANNOTATIONS] + (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeVisibleParameterAnnotations): Added. + [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations): + Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added. + [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] + (utf_sun_reflect_annotation_AnnotationParser): Added. + + * src/vmcore/field.h [ENABLE_ANNOTATIONS] (field_get_annotations): + Added. + + * src/vmcore/Makefile.am [ENABLE_ANNOTATIONS] (ANNOTATION_SOURCES): + Only compile annotations sources when annotations are enabled. + + * src/vmcore/utf8.h [ENABLE_ANNOTATIONS] + (utf_sun_reflect_ConstantPool): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeInvisibleAnnotations): Added. [ENABLE_ANNOTATIONS] + (utf_RuntimeVisibleParameterAnnotations): Added. + [ENABLE_ANNOTATIONS] (utf_RuntimeInvisibleParameterAnnotations): + Added. [ENABLE_ANNOTATIONS] (utf_AnnotationDefault): Added. + [ENABLE_ANNOTATIONS] [WITH_CLASSPATH_GNU] + (utf_sun_reflect_annotation_AnnotationParser): Added. + + * configure.ac (ENABLE_ANNOTATIONS): Added configure option + --enable-annotations. + [ab4f34149780] + +2007-07-31 twisti + + * configure.ac, m4/classpath.m4: + * configure.ac: Only check AC_PROG_JAVAC and AC_PROG_JAR for + CLDC-1.1 and GNU. + + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_CLASSES): Changed default + value for different configurations.. + [d7d167268026] + +2007-07-31 michi + + * src/vm/jit/alpha/arch.h, src/vm/jit/alpha/md.c, + src/vm/jit/arm/arch.h, src/vm/jit/i386/arch.h, src/vm/jit/i386/md.c, + src/vm/jit/mips/arch.h, src/vm/jit/mips/md.c, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/md.c, + src/vm/jit/s390/arch.h, src/vm/jit/sparc64/arch.h, + src/vm/jit/sparc64/md.c, src/vm/jit/x86_64/arch.h, + src/vm/jit/x86_64/md.c: + * src/vm/jit/arm/arch.h, src/vm/jit/powerpc/arch.h, + src/vm/jit/sparc64/arch.h, src/vm/jit/alpha/arch.h, + src/vm/jit/s390/arch.h, src/vm/jit/mips/arch.h, + src/vm/jit/powerpc64/arch.h, src/vm/jit/i386/arch.h, + src/vm/jit/x86_64/arch.h (REPLACEMENT_STUB_SIZE): Removed obsolete + define. + + * src/vm/jit/powerpc/md.c, src/vm/jit/sparc64/md.c, + src/vm/jit/alpha/md.c, src/vm/jit/mips/md.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/i386/md.c, + src/vm/jit/x86_64/md.c (md_patch_replacement_point): We have to use + trap instructions here. + [ae987e4ea783] + + * src/vm/jit/sparc64/md.c: + * src/vm/jit/sparc64/md.c: Fixed file header. + [97bdf942d526] + + * THIRDPARTY, m4/ac_prog_javac.m4, src/cacaoh/dummy.c, src/mm/boehm.c, + src/native/include/Makefile.am, src/native/jni.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.h, + src/threads/threads-common.h, src/vm/access.c, src/vm/builtin.c, + src/vm/builtintable.inc, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/global.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/asmpart.h, src/vm/jit/code.h, src/vm/jit/codegen- + common.c, src/vm/jit/emit-common.h, src/vm/jit/i386/arch.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/md.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/patcher.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/darwin/md- + os.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/replace.c, src/vm/jit/replace.h, src/vm/jit/s390/arch.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/linux/md-os.c, src/vm/jit_interface.h, + src/vm/properties.c, src/vm/properties.h, src/vm/string.c, + src/vm/vm.c, src/vm/vm.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/descriptor.c, src/vmcore/descriptor.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h, src/vmcore/primitive.c, + src/vmcore/primitive.h, src/vmcore/statistics.c, + src/vmcore/statistics.h, src/vmcore/suck.c: + Merged revisions 8187-8244 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8189 | ajordan | 2007-07-07 14:03:38 +0200 (Sat, 07 Jul + 2007) | 2 lines + + * src/vm/jit/sparc64/solaris/md-os.c: Implemented hardware + exception handling. ........ r8190 | twisti | 2007-07-08 15:42:06 + +0200 (Sun, 08 Jul 2007) | 4 lines + + * src/vm/jit/powerpc/linux/md-abi.c (vm/types.h): Removed. + (stdint.h): Added and use stdint-types in this file. (_ALIGN): + Removed and use ALIGN_2 in this file. ........ r8191 | twisti | + 2007-07-08 17:15:53 +0200 (Sun, 08 Jul 2007) | 8 lines + + * src/vm/jit/powerpc/emit.c (stdint.h): Added + (emit_verbosecall_enter): Reimplemented (this implementation is much + simpler and maybe should be extended to trace also arguments on the + stack). Darwin support is still missing. + + * src/vm/jit/powerpc/darwin/md-abi.h (TRACE_ARGS_NUM): Changed to + 4. + * src/vm/jit/powerpc/linux/md-abi.h (TRACE_ARGS_NUM): Likewise. + ........ r8192 | twisti | 2007-07-09 13:18:48 +0200 (Mon, 09 Jul + 2007) | 3 lines + + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): + Fixed typo. ........ r8193 | twisti | 2007-07-09 16:37:49 +0200 + (Mon, 09 Jul 2007) | 2 lines + + * src/vm/global.h (ALIGN_2): Use logical arithmetic. ........ + r8194 | twisti | 2007-07-10 15:44:37 +0200 (Tue, 10 Jul 2007) | 9 + lines + + * src/vmcore/options.c (opt_TraceJavaCalls): Added. + (options_XX): Added opt_TraceJavaCalls. (options_xx): Likewise. + + * src/vmcore/options.h (opt_TraceJavaCalls): Added. + + * src/vm/vm.c (XXusage): Removed -verbose:call. (vm_create): + Likewise. ........ r8195 | pm | 2007-07-11 13:27:55 +0200 (Wed, 11 + Jul 2007) | 3 lines + + * src/vm/jit/s390/codegen.c (codegen_emit): Extended maximal + interface table offset from 12 bit to 16 bit in + ICMD_INVOKEINTERFACE. + * src/vm/jit/s390/patcher.c (patcher_invokeinterface): Likewise. + ........ r8196 | twisti | 2007-07-11 15:54:21 +0200 (Wed, 11 Jul + 2007) | 5 lines + + * src/vm/jit/powerpc/codegen.c (codegen_emit): Fixed bug when + taking out double arguments. (codegen_emit_stub_native): Use + switch-case for saving and restoring argument registers. ........ + r8197 | twisti | 2007-07-11 21:17:04 +0200 (Wed, 11 Jul 2007) | 3 + lines + + * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Fixed stack + alignment. ........ r8198 | twisti | 2007-07-12 09:16:24 +0200 + (Thu, 12 Jul 2007) | 10 lines + + * src/vm/jit/alpha/asmpart.S (asm_vm_call_method): Rewritten for + new argument passing. + + * src/vm/jit/alpha/md-abi.c (md_param_alloc): Set pd->index. + + * src/native/jni.c: Added __ALPHA__ ifdef. + * src/vm/vm.c: Likewise. + * src/vm/vm.h: Likewise. + * src/vm/jit/asmpart.h: Likewise. ........ r8199 | michi | + 2007-07-13 02:39:49 +0200 (Fri, 13 Jul 2007) | 7 lines + + * src/vmcore/statistics.h (size_patchref): Added. + * src/vmcore/statistics.c (size_patchref): Added. + (statistics_print_memory_usage): Print size of patcher references. + + * src/vm/jit/patcher-common.c (patcher_add_patch_ref, + patcher_list_free) [ENABLE_STATISTICS] Set size of patcher + references accordingly. ........ r8200 | twisti | 2007-07-15 + 11:47:21 +0200 (Sun, 15 Jul 2007) | 2 lines + + * src/vm/vm.c: Build fix. ........ r8201 | twisti | 2007-07-15 + 12:37:50 +0200 (Sun, 15 Jul 2007) | 9 lines + + * src/vmcore/primitive.c (stdint.h): Added. + (primitive_arrayclass_get_by_name): New function. + + * src/vmcore/primitive.h (stdint.h): Added. + (primitive_arrayclass_get_by_name): Likewise. + + * src/native/vm/sun/jvm.c (JVM_NewArray): Implemented handling for + primitive arrays. ........ r8202 | twisti | 2007-07-15 14:08:18 + +0200 (Sun, 15 Jul 2007) | 3 lines + + * src/native/include/Makefile.am [WITH_CLASSPATH_SUN] + (JAVASE_HEADER_FILES): Added sun_reflect_ConstantPool.h. ........ + r8203 | twisti | 2007-07-15 14:30:04 +0200 (Sun, 15 Jul 2007) | 16 + lines + + * src/vmcore/primitive.c (primitive_class_is_primitive): Removed. + * src/vmcore/primitive.h: Likewise. + + * src/vmcore/class.c (class_is_primitive): New function. + (class_isanysubclass): Use class_is_primitive. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (isPrimitive): Use + class_is_primitive. (getDeclaringClass): Likewise. + (getDeclaredClasses): Likewise. + + * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Likewise. + (JVM_IsPrimitiveClass): Likewise. (JVM_NewArray): Likewise. + ........ r8204 | twisti | 2007-07-15 14:44:22 +0200 (Sun, 15 Jul + 2007) | 4 lines + + * src/native/vm/sun/jvm.c (JVM_ArrayCopy): Fixed warnings. + (JVM_GetStackTraceElement): Likewise. (JVM_FindLoadedClass): + Likewise. ........ r8205 | twisti | 2007-07-15 14:45:40 +0200 + (Sun, 15 Jul 2007) | 2 lines + + * src/native/vm/sun/jvm.c: Set Id keyword. ........ r8206 | + twisti | 2007-07-15 16:26:33 +0200 (Sun, 15 Jul 2007) | 7 lines + + * src/vmcore/options.c (opt_TraceJVMCalls): Added. + * src/vmcore/options.h: Likewise. + + * src/native/vm/sun/jvm.c (vmcore/options.h): Added. + (DEBUG_JVM): Renamed to TRACEJVMCALLS. (JVM_GetArrayLength): + Implemented. ........ r8207 | twisti | 2007-07-16 17:18:32 +0200 + (Mon, 16 Jul 2007) | 6 lines + + * src/vmcore/class.c (class_get_declaringclass): New function. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (getDeclaringClass): Use + class_get_declaringclass. ........ r8208 | twisti | 2007-07-17 + 11:06:22 +0200 (Tue, 17 Jul 2007) | 3 lines + + * src/native/jni.c (TRACEJNICALLS): Added but still unused. + (JNI_GetCreatedJavaVMs): Implemented. ........ r8209 | twisti | + 2007-07-17 22:13:23 +0200 (Tue, 17 Jul 2007) | 9 lines + + * src/vmcore/class.c (vm/resolve.h): Added. (class_define): + Changed signature. + * src/vmcore/class.h (class_define): Likewise. + + * src/native/jni.c (_Jv_JNI_DefineClass): Bug fix, use + class_define. + + * src/native/vm/java_lang_ClassLoader.c (defineClass): Use + class_define. ........ r8210 | twisti | 2007-07-18 14:51:00 +0200 + (Wed, 18 Jul 2007) | 50 lines + + * src/vm/jit/allocator/simplereg.c: Replaced HAS_4BYTE_STACKSLOT + with SIZEOF_VOID_P == 4. + + * src/vm/jit/i386/emit.c (vm/jit/abi.h): Added. + (emit_verbosecall_enter): Changed to 8-byte stackslots. + + * src/vm/jit/i386/codegen.c (codegen_emit): Changed to 8-byte + stackslots. (codegen_emit_stub_native): Likewise. + + * src/vm/jit/i386/arch.h (HAS_4BYTE_STACKSLOT): Removed. + (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY): + Likewise. + + * src/vm/jit/i386/asmpart.S (asm_vm_call_method): Rewritten for + new argument passing. (asm_handle_exception): Use 8-byte + stackslots. + + * src/vm/jit/i386/md-abi.c (md_param_alloc): Use 8-byte stackslots + and set pd->index. (md_param_alloc_native): New function. + + * src/vm/global.h (ALIGN_EVEN): New macro. (ALIGN_ODD): + Likewise. (ALIGN_2): Defined to ALIGN_EVEN. + + * src/vm/builtintable.inc (builtintable_function): Removed #ifdef + for java.lang.VMSystem.arraycopy, this works now correctly. + + * src/vm/builtin.c (builtintable_init): Set ACC_METHOD_BUILTIN + when parsing the decriptor. + + * src/vm/jit_interface.h (md_param_alloc_native): Added. + + * src/vm/exceptions.c (exceptions_handle_exception): Temporarily + added __I386__ to get the monitor object correctly. + + * src/vmcore/descriptor.c + (descriptor_pool_parse_method_descriptor): Check for + ACC_METHOD_BUILTIN flag. (descriptor_params_from_paramtypes): + Likewise. + + * src/cacaoh/dummy.c (md_param_alloc_native): Added. + + * src/vm/jit/asmpart.h: Added __I386__ ifdef. + * src/vm/vm.c: Likewise. + * src/vm/vm.h: Likewise. + * src/native/jni.c: Likewise. (_Jv_jni_invokeNative): Check for + exception too when vm_array_from_objectarray returns. ........ + r8211 | michi | 2007-07-18 21:52:23 +0200 (Wed, 18 Jul 2007) | 25 + lines + + * src/vm/jit/replace.h (REPLACEMENT_EMIT_STUBS): Removed macro. + + * src/vm/jit/emit-common.h (emit_replacement_stubs): Removed. + + * src/vm/jit/arm/emit.c, + * src/vm/jit/arm/codegen.c, + * src/vm/jit/powerpc/emit.c, + * src/vm/jit/powerpc/codegen.c, + * src/vm/jit/sparc64/emit.c, + * src/vm/jit/sparc64/codegen.c, + * src/vm/jit/alpha/emit.c, + * src/vm/jit/alpha/codegen.c, + * src/vm/jit/s390/emit.c, + * src/vm/jit/mips/emit.c, + * src/vm/jit/mips/codegen.c, + * src/vm/jit/m68k/codegen.c, + * src/vm/jit/powerpc64/emit.c, + * src/vm/jit/powerpc64/codegen.c, + * src/vm/jit/i386/emit.c, + * src/vm/jit/i386/codegen.c, + * src/vm/jit/x86_64/emit.c, + * src/vm/jit/x86_64/codegen.c (emit_replacement_stubs): Removed. + (codegen_emit): Do not create replacement stubs anymore. ........ + r8212 | twisti | 2007-07-18 21:59:32 +0200 (Wed, 18 Jul 2007) | 14 + lines + + * src/vm/vm.c (opts): Added -XX. (usage): Small text change. + + * src/vmcore/options.c (opt_DebugStackFrameInfo): Added. + (opt_DebugStackTrace): Likewise. (options_XX): Added type and some + documentation. (options_xxusage): New function. (options_xx): Do + more error checking. + + * src/vmcore/options.h (option_t): Added type and renamed option + to value. (opt_DebugStackFrameInfo): Added. + (opt_DebugStackTrace): Likewise. ........ r8213 | michi | + 2007-07-18 22:08:26 +0200 (Wed, 18 Jul 2007) | 5 lines + + * src/vmcore/options.h (opt_replace_verbose): Removed. + * src/vmcore/options.c (opt_replace_verbose): Removed. + * src/vm/vm.c [ENABLE_INLINING]: Removed options -ir and -iR, this is + now called -XX:TraceReplacement. ........ r8214 | michi | + 2007-07-18 22:27:12 +0200 (Wed, 18 Jul 2007) | 2 lines + + * src/vmcore/options.c (options_XX): Fixed -XX:TraceReplacement. + ........ r8215 | michi | 2007-07-18 22:31:21 +0200 (Wed, 18 Jul + 2007) | 6 lines + + * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT]: Removed + obsolet pointer to replacementstubs. + + * src/vm/jit/codegen-common.c (codegen_finish) + [ENABLE_REPLACEMENT]: Do not resolve pointer to replacementstubs. + ........ r8216 | michi | 2007-07-19 15:51:21 +0200 (Thu, 19 Jul + 2007) | 20 lines + + * src/vm/jit/powerpc/emit.c (emit_patcher_traps): Formerly known + as emit_patcher_stubs, now emits traps instead of stubs. + + * src/vm/jit/powerpc/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions and + adapted to above change. + + * src/vm/jit/powerpc/patcher.c: Adapted patchers to new signature + for traps. (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/powerpc/asmpart.S (asm_patcher_wrapper): Removed, + this is obsolete. + + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Only calls the exception handling if exception object present. + + * src/vm/jit/powerpc/darwin/md-os.c (md_signal_handler_sigsegv): + Likewise. + + * src/vm/jit/patcher-common.h [__POWERPC__]: Enabled new patcher + stuff. + + * src/vm/jit/patcher.h [__POWERPC__]: Defined away old patcher + stuff. ........ r8217 | michi | 2007-07-19 17:44:41 +0200 (Thu, 19 + Jul 2007) | 3 lines + + * src/vm/jit/arm/md-os.c (md_signal_handler_sigsegv): Added + additional debug output. ........ r8218 | michi | 2007-07-19 + 18:33:19 +0200 (Thu, 19 Jul 2007) | 5 lines + + * src/vm/jit/s390/md.c (md_get_method_patch_address): Fixed + cornercase for replacement. + + * src/vm/jit/m68k/md.c (md_get_method_patch_address): Likewise. + ........ r8219 | twisti | 2007-07-20 18:52:11 +0200 (Fri, 20 Jul + 2007) | 6 lines + + * src/vmcore/class.c (class_get_superclass): New function. + * src/vmcore/class.h: Likewise. + + * src/native/jni.c (_Jv_JNI_GetSuperclass): Use + class_get_superclass. + * src/native/vm/java_lang_Class.c (getSuperclass): Likewise. ........ + r8220 | twisti | 2007-07-22 17:37:52 +0200 (Sun, 22 Jul 2007) | 8 + lines + + * src/vmcore/options.c (opt_TraceJNICalls): Added. + * src/vmcore/options.h: Likewise. + + * src/native/jni.c (TRACEJNICALLS): Enabled. + (_Jv_JNI_GetStringLength): Added TRACEJNICALLS. + (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFLength): + Likewise. ........ r8221 | twisti | 2007-07-22 21:31:41 +0200 + (Sun, 22 Jul 2007) | 3 lines + + * src/native/jni.c (_Jv_JNI_GetSuperclass): Fixed TRACEJNICALLS. + (_Jv_JNI_GetStringUTFRegion): Bugfix, start at offset to copy data. + ........ r8222 | twisti | 2007-07-22 22:07:55 +0200 (Sun, 22 Jul + 2007) | 3 lines + + * src/threads/native/threads.h (threads_yield): Removed. + * src/threads/threads-common.h (threads_yield): Added. ........ + r8223 | twisti | 2007-07-22 22:43:05 +0200 (Sun, 22 Jul 2007) | 3 + lines + + * src/vmcore/class.c (class_get_signature): New function. + * src/vmcore/class.h: Likewise. ........ r8224 | twisti | 2007-07-23 + 21:07:48 +0200 (Mon, 23 Jul 2007) | 2 lines + + * src/vmcore/class.h (classinfo): Removed unused listnode. + ........ r8225 | twisti | 2007-07-23 23:33:16 +0200 (Mon, 23 Jul + 2007) | 5 lines + + * src/native/vm/sun_misc_Unsafe.c (vm/stringlocal.h): Added. + (putInt): New function. (getObject): Likewise. (defineClass): + Likewise. ........ r8226 | twisti | 2007-07-24 10:21:23 +0200 + (Tue, 24 Jul 2007) | 4 lines + + * src/native/vm/sun_misc_Unsafe.c [WITH_CLASSPATH_SUN] + (native/include/java_security_ProtectionDomain.h): Removed #ifdef. + (defineClass) [WITH_CLASSPATH_GNU]: Renamed pd to protectionDomain. + ........ r8227 | twisti | 2007-07-24 13:55:07 +0200 (Tue, 24 Jul + 2007) | 16 lines + + * src/vmcore/loader.c (vmcore/field.h): Added. (load_field): + Removed. (load_class_from_classbuffer): Call field_load. + + * src/vmcore/field.c (stdint.h): Added. (vm/exceptions.h): + Likewise. (vm/stringlocal.h): Likewise. (vm/vm.h): Likewise. + (vmcore/descriptor.h): Likewise. (vmcore/loader.h): Likewise. + (vmcore/options.h): Likewise. (vmcore/suck.h): Likewise. + (field_load): New function. + + * src/vmcore/field.h (field_load): Added. ........ r8228 | + twisti | 2007-07-24 14:37:25 +0200 (Tue, 24 Jul 2007) | 12 lines + + * src/vmcore/loader.c (vmcore/method.h): Added. + (loader_load_method): Removed. (load_class_from_classbuffer): Call + method_load. + + * src/vmcore/method.c (stdint.h): Added. (threads/lock-common): + Likewise. (vm/exceptions.h): Likewise. (vmcore/suck.h): + Likewise. (method_load): New function. + + * src/vmcore/method.h (method_load): Added. ........ r8229 | + twisti | 2007-07-24 20:42:44 +0200 (Tue, 24 Jul 2007) | 2 lines + + * src/vmcore/field.h (vmcore/loader.h): Added. ........ r8230 | + twisti | 2007-07-25 10:23:10 +0200 (Wed, 25 Jul 2007) | 9 lines + + * src/vm/string.c, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/loader.c, src/vmcore/options.c, + src/vmcore/options.h: Removed eager-loading stuff (as it was broken + anyways). ........ r8231 | twisti | 2007-07-25 16:21:24 +0200 + (Wed, 25 Jul 2007) | 6 lines + + * src/vmcore/class.c [ENABLE_JAVASE] (class_get_signature): Only + for JavaSE. + * src/vmcore/class.h: Likewise. + + * src/vmcore/method.h (vmcore/loader.h): Added. ........ r8232 | + twisti | 2007-07-25 16:51:40 +0200 (Wed, 25 Jul 2007) | 4 lines + + * src/vmcore/descriptor.c (vm/vm.h): Added. + (descriptor_to_basic_type): Code cleanup. (descriptor_typesize): + Likewise. ........ r8233 | twisti | 2007-07-25 17:11:20 +0200 + (Wed, 25 Jul 2007) | 5 lines + + * src/vmcore/descriptor.c (descriptor_to_basic_type): Changed + return type to int. (descriptor_typesize): Likewise. + * src/vmcore/descriptor.h: Likewise. ........ r8234 | twisti | + 2007-07-26 10:21:25 +0200 (Thu, 26 Jul 2007) | 4 lines + + * src/vmcore/linker.c (dummy_alignment_long_t): New structure. + (dummy_alignment_double_t): Likewise. (linker_init): Added + long/double alignment check. ........ r8235 | twisti | 2007-07-26 + 10:29:24 +0200 (Thu, 26 Jul 2007) | 3 lines + + * THIRDPARTY: Fixed classes path, added contrib/mapfile-vers- + product, src/lib/gnu/sun/misc/Unsafe.java ........ r8236 | + twisti | 2007-07-27 12:18:17 +0200 (Fri, 27 Jul 2007) | 22 lines + + * src/vm/vm.c (version): Removed configuration output. + (vm_printconfig): New function. (vm_create): Set bootclasspath and + classpath whenever changed and don't call properties_postinit. + This fixes a bug with + -Djava.class.path. + * src/vm/vm.h (vm_printconfig): Added. + + * src/vm/properties.c (properties_init): Set java.vm.info for all + JavaSE configurations. (properties_postinit): Removed. + * src/vm/properties.h (properties_postinit): Likewise. + + * src/vmcore/options.c (opt_PrintConfig): Added. (options_xx): + Likewise. + * src/vmcore/options.h (opt_PrintConfig): Likewise. + + * src/vmcore/suck.c (suck_add_from_property): Reset the + bootclasspath after it changed. + + * src/cacaoh/dummy.c (properties_add): New dummy. + (vm_printconfig): Likewise. ........ r8237 | twisti | 2007-07-27 + 18:15:29 +0200 (Fri, 27 Jul 2007) | 16 lines + + * src/vmcore/class.c (class_sun_reflect_MagicAccessorImpl): Added. + (class_issubclass): Don't get super-class directly, it can be + unresolved. Use class_get_superclass. + + * src/vmcore/class.h (class_sun_reflect_MagicAccessorImpl): Added. + + * src/vmcore/loader.c (loader_init): Load + class_sun_reflect_MagicAccessorImpl. + + * src/vmcore/linker.c (linker_init): Link + class_sun_reflect_MagicAccessorImpl. + + * src/vm/access.c (access_is_accessible_class) + [WITH_CLASSPATH_SUN]: Added sun/reflect/MagicAccessorImpl check. + (access_is_accessible_member): Likewise. ........ r8238 | twisti | + 2007-07-27 20:41:53 +0200 (Fri, 27 Jul 2007) | 4 lines + + * src/vmcore/class.c (class_resolve_superclass): New function. + (class_issubclass): Use class_resolve_superclass. + (class_get_superclass): Likewise. ........ r8239 | twisti | + 2007-07-29 21:21:18 +0200 (Sun, 29 Jul 2007) | 3 lines + + * src/vm/vm.c (vm_create) [WITH_CLASSPATH_SUN]: Set bootclasspath + as HotSpot does. ........ r8240 | pm | 2007-07-29 22:36:47 +0200 + (Sun, 29 Jul 2007) | 7 lines + + * src/vm/jit/replace.c: Enaled replacement on s390. + * src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c: Changed a lot: implemented profiling, fixed + bugs found by mauve, begun work on replacament. ........ r8241 | + twisti | 2007-07-30 11:26:31 +0200 (Mon, 30 Jul 2007) | 4 lines + + * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Try javac as first + compiler. Left jikes in there so configure can finish on machines + where we don't have a javac or ecj. ........ r8242 | twisti | + 2007-07-31 10:45:35 +0200 (Tue, 31 Jul 2007) | 4 lines + + * src/mm/boehm.c (heap_allocate): Call + GC_REGISTER_FINALIZER_NO_ORDER instead of GC_REGISTER_FINALIZER. + This fixes the GC heap memory leak seen with e.g. Jetty. ........ + r8243 | michi | 2007-07-31 10:57:54 +0200 (Tue, 31 Jul 2007) | 21 + lines + + * src/vm/exceptions.c (exceptions_new_hardware_exception): Do not + create sfi. + * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed + signature. + + * src/vm/jit/arm/linux/md-os.c + * src/vm/jit/powerpc/linux/md-os.c + * src/vm/jit/powerpc/darwin/md-os.c + * src/vm/jit/sparc64/linux/md-os.c + * src/vm/jit/sparc64/solaris/md-os.c + * src/vm/jit/alpha/linux/md-os.c + * src/vm/jit/s390/md.c + * src/vm/jit/mips/linux/md-os.c + * src/vm/jit/mips/irix/md-os.c + * src/vm/jit/m68k/linux/md-os.c + * src/vm/jit/powerpc64/linux/md-os.c + * src/vm/jit/i386/darwin/md-os.c + * src/vm/jit/i386/linux/md-os.c + * src/vm/jit/x86_64/linux/md-os.c: Signal handlers create the sfi + now. Adapted to above changes. Exception object variable is now + called "e" on all archs. ........ r8244 | michi | 2007-07-31 + 11:30:28 +0200 (Tue, 31 Jul 2007) | 4 lines + + * src/vm/jit/replace.c (replace_me_wrapper): Added. + * src/vm/jit/replace.h (replace_me_wrapper): Added. + * src/vm/exceptions.c (exceptions_new_hardware_exception): Call above + function. ........ + [ec6d259e4518] + + * src/vm/exceptions.c, src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/replace.c (replace_me_wrapper): Added. + * src/vm/jit/replace.h (replace_me_wrapper): Added. + * src/vm/exceptions.c (exceptions_new_hardware_exception): Call above + function. + [dd4bd5f7600f] + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md- + os.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/exceptions.c (exceptions_new_hardware_exception): Do not + create sfi. + * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed + signature. + + * src/vm/jit/arm/linux/md-os.c + * src/vm/jit/powerpc/linux/md-os.c + * src/vm/jit/powerpc/darwin/md-os.c + * src/vm/jit/sparc64/linux/md-os.c + * src/vm/jit/sparc64/solaris/md-os.c + * src/vm/jit/alpha/linux/md-os.c + * src/vm/jit/s390/md.c + * src/vm/jit/mips/linux/md-os.c + * src/vm/jit/mips/irix/md-os.c + * src/vm/jit/m68k/linux/md-os.c + * src/vm/jit/powerpc64/linux/md-os.c + * src/vm/jit/i386/darwin/md-os.c + * src/vm/jit/i386/linux/md-os.c + * src/vm/jit/x86_64/linux/md-os.c: Signal handlers create the sfi now. + Adapted to above changes. Exception object variable is now called + "e" on all archs. + [02a065687d24] + +2007-07-31 twisti + + * src/mm/boehm.c: + * src/mm/boehm.c (heap_allocate): Call + GC_REGISTER_FINALIZER_NO_ORDER instead of GC_REGISTER_FINALIZER. + This fixes the GC heap memory leak seen with e.g. Jetty. + [1dfe39d5388f] + +2007-07-30 twisti + + * m4/ac_prog_javac.m4: + * m4/ac_prog_javac.m4 (AC_PROG_JAVAC): Try javac as first compiler. + Left jikes in there so configure can finish on machines where we + don't have a javac or ecj. + [03f3342458a9] + +2007-07-29 pm + + * src/vm/jit/replace.c, src/vm/jit/s390/arch.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c: + * src/vm/jit/replace.c: Enaled replacement on s390. + * src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c: Changed a lot: implemented profiling, fixed + bugs found by mauve, begun work on replacament. + [e58b898d27e9] + +2007-07-29 twisti + + * src/vm/vm.c: + * src/vm/vm.c (vm_create) [WITH_CLASSPATH_SUN]: Set bootclasspath as + HotSpot does. + [931286015662] + +2007-07-27 twisti + + * src/vmcore/class.c: + * src/vmcore/class.c (class_resolve_superclass): New function. + (class_issubclass): Use class_resolve_superclass. + (class_get_superclass): Likewise. + [f523912ffb36] + + * src/vm/access.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/loader.c: + * src/vmcore/class.c (class_sun_reflect_MagicAccessorImpl): Added. + (class_issubclass): Don't get super-class directly, it can be + unresolved. Use class_get_superclass. + + * src/vmcore/class.h (class_sun_reflect_MagicAccessorImpl): Added. + + * src/vmcore/loader.c (loader_init): Load + class_sun_reflect_MagicAccessorImpl. + + * src/vmcore/linker.c (linker_init): Link + class_sun_reflect_MagicAccessorImpl. + + * src/vm/access.c (access_is_accessible_class) [WITH_CLASSPATH_SUN]: + Added sun/reflect/MagicAccessorImpl check. + (access_is_accessible_member): Likewise. + [f8cb3cfe7a30] + + * src/cacaoh/dummy.c, src/vm/properties.c, src/vm/properties.h, + src/vm/vm.c, src/vm/vm.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/suck.c: + * src/vm/vm.c (version): Removed configuration output. + (vm_printconfig): New function. (vm_create): Set bootclasspath and + classpath whenever changed and don't call properties_postinit. This + fixes a bug with + -Djava.class.path. + * src/vm/vm.h (vm_printconfig): Added. + + * src/vm/properties.c (properties_init): Set java.vm.info for all + JavaSE configurations. (properties_postinit): Removed. + * src/vm/properties.h (properties_postinit): Likewise. + + * src/vmcore/options.c (opt_PrintConfig): Added. (options_xx): + Likewise. + * src/vmcore/options.h (opt_PrintConfig): Likewise. + + * src/vmcore/suck.c (suck_add_from_property): Reset the + bootclasspath after it changed. + + * src/cacaoh/dummy.c (properties_add): New dummy. (vm_printconfig): + Likewise. + [e0faa4cf75a1] + +2007-07-26 twisti + + * THIRDPARTY: + * THIRDPARTY: Fixed classes path, added contrib/mapfile-vers- + product, src/lib/gnu/sun/misc/Unsafe.java + [b36b7d0fe3ef] + + * src/vmcore/linker.c: + * src/vmcore/linker.c (dummy_alignment_long_t): New structure. + (dummy_alignment_double_t): Likewise. (linker_init): Added + long/double alignment check. + [8122b21bcc2c] + +2007-07-25 twisti + + * src/vmcore/descriptor.c, src/vmcore/descriptor.h: + * src/vmcore/descriptor.c (descriptor_to_basic_type): Changed return + type to int. (descriptor_typesize): Likewise. + * src/vmcore/descriptor.h: Likewise. + [7cb8e297edcf] + + * src/vmcore/descriptor.c: + * src/vmcore/descriptor.c (vm/vm.h): Added. + (descriptor_to_basic_type): Code cleanup. (descriptor_typesize): + Likewise. + [60fed621bcbf] + + * src/vmcore/class.c, src/vmcore/class.h, src/vmcore/method.h: + * src/vmcore/class.c [ENABLE_JAVASE] (class_get_signature): Only for + JavaSE. + * src/vmcore/class.h: Likewise. + + * src/vmcore/method.h (vmcore/loader.h): Added. + [c1489229706f] + + * src/vm/string.c, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/loader.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vm/string.c, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/loader.c, src/vmcore/options.c, + src/vmcore/options.h: Removed eager-loading stuff (as it was broken + anyways). + [5867a4482f05] + +2007-07-24 twisti + + * src/vmcore/field.h: + * src/vmcore/field.h (vmcore/loader.h): Added. + [cfdc335e6834] + + * src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h: + * src/vmcore/loader.c (vmcore/method.h): Added. + (loader_load_method): Removed. (load_class_from_classbuffer): Call + method_load. + + * src/vmcore/method.c (stdint.h): Added. (threads/lock-common): + Likewise. (vm/exceptions.h): Likewise. (vmcore/suck.h): Likewise. + (method_load): New function. + + * src/vmcore/method.h (method_load): Added. + [3b822b675cae] + + * src/vmcore/field.c, src/vmcore/field.h, src/vmcore/loader.c: + * src/vmcore/loader.c (vmcore/field.h): Added. (load_field): + Removed. (load_class_from_classbuffer): Call field_load. + + * src/vmcore/field.c (stdint.h): Added. (vm/exceptions.h): Likewise. + (vm/stringlocal.h): Likewise. (vm/vm.h): Likewise. + (vmcore/descriptor.h): Likewise. (vmcore/loader.h): Likewise. + (vmcore/options.h): Likewise. (vmcore/suck.h): Likewise. + (field_load): New function. + + * src/vmcore/field.h (field_load): Added. + [251b0a971fed] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c [WITH_CLASSPATH_SUN] + (native/include/java_security_ProtectionDomain.h): Removed #ifdef. + (defineClass) [WITH_CLASSPATH_GNU]: Renamed pd to protectionDomain. + [ea135360488b] + +2007-07-23 twisti + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (vm/stringlocal.h): Added. + (putInt): New function. (getObject): Likewise. (defineClass): + Likewise. + [7203affa0097] + + * src/vmcore/class.h: + * src/vmcore/class.h (classinfo): Removed unused listnode. + [3ff1aad8b73c] + +2007-07-22 twisti + + * src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_get_signature): New function. + * src/vmcore/class.h: Likewise. + [880cb019c874] + + * src/threads/native/threads.h, src/threads/threads-common.h: + * src/threads/native/threads.h (threads_yield): Removed. + * src/threads/threads-common.h (threads_yield): Added. + [12761839a9fd] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_GetSuperclass): Fixed TRACEJNICALLS. + (_Jv_JNI_GetStringUTFRegion): Bugfix, start at offset to copy data. + [d3a41ccae208] + + * src/native/jni.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_TraceJNICalls): Added. + * src/vmcore/options.h: Likewise. + + * src/native/jni.c (TRACEJNICALLS): Enabled. + (_Jv_JNI_GetStringLength): Added TRACEJNICALLS. + (_Jv_JNI_NewStringUTF): Likewise. (_Jv_JNI_GetStringUTFLength): + Likewise. + [352b9420e7ec] + +2007-07-20 twisti + + * src/native/jni.c, src/native/vm/java_lang_Class.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_get_superclass): New function. + * src/vmcore/class.h: Likewise. + + * src/native/jni.c (_Jv_JNI_GetSuperclass): Use + class_get_superclass. + * src/native/vm/java_lang_Class.c (getSuperclass): Likewise. + [0e51eac71071] + +2007-07-19 michi + + * src/vm/jit/m68k/md.c, src/vm/jit/s390/md.c: + * src/vm/jit/s390/md.c (md_get_method_patch_address): Fixed + cornercase for replacement. + + * src/vm/jit/m68k/md.c (md_get_method_patch_address): Likewise. + [669f79995095] + + * src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/md-os.c (md_signal_handler_sigsegv): Added + additional debug output. + [0ca11e0b148b] + + * src/vm/jit/patcher-common.h, src/vm/jit/patcher.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/patcher.c: + * src/vm/jit/powerpc/emit.c (emit_patcher_traps): Formerly known as + emit_patcher_stubs, now emits traps instead of stubs. + + * src/vm/jit/powerpc/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions and + adapted to above change. + + * src/vm/jit/powerpc/patcher.c: Adapted patchers to new signature + for traps. (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/powerpc/asmpart.S (asm_patcher_wrapper): Removed, this + is obsolete. + + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Only + calls the exception handling if exception object present. + + * src/vm/jit/powerpc/darwin/md-os.c (md_signal_handler_sigsegv): + Likewise. + + * src/vm/jit/patcher-common.h [__POWERPC__]: Enabled new patcher + stuff. + + * src/vm/jit/patcher.h [__POWERPC__]: Defined away old patcher + stuff. + [5feca9dd36ee] + +2007-07-18 michi + + * src/vm/jit/code.h, src/vm/jit/codegen-common.c: + * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT]: Removed obsolet + pointer to replacementstubs. + + * src/vm/jit/codegen-common.c (codegen_finish) [ENABLE_REPLACEMENT]: + Do not resolve pointer to replacementstubs. + [6a3a569589cb] + + * src/vmcore/options.c: + * src/vmcore/options.c (options_XX): Fixed -XX:TraceReplacement. + [6ca74617e290] + + * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.h (opt_replace_verbose): Removed. + * src/vmcore/options.c (opt_replace_verbose): Removed. + * src/vm/vm.c [ENABLE_INLINING]: Removed options -ir and -iR, this is + now called -XX:TraceReplacement. + [503ca78a9980] + +2007-07-18 twisti + + * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vm/vm.c (opts): Added -XX. (usage): Small text change. + + * src/vmcore/options.c (opt_DebugStackFrameInfo): Added. + (opt_DebugStackTrace): Likewise. (options_XX): Added type and some + documentation. (options_xxusage): New function. (options_xx): Do + more error checking. + + * src/vmcore/options.h (option_t): Added type and renamed option to + value. (opt_DebugStackFrameInfo): Added. (opt_DebugStackTrace): + Likewise. + [90b1f890ec50] + +2007-07-18 michi + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/emit- + common.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/replace.h, + src/vm/jit/s390/emit.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c: + * src/vm/jit/replace.h (REPLACEMENT_EMIT_STUBS): Removed macro. + + * src/vm/jit/emit-common.h (emit_replacement_stubs): Removed. + + * src/vm/jit/arm/emit.c, + * src/vm/jit/arm/codegen.c, + * src/vm/jit/powerpc/emit.c, + * src/vm/jit/powerpc/codegen.c, + * src/vm/jit/sparc64/emit.c, + * src/vm/jit/sparc64/codegen.c, + * src/vm/jit/alpha/emit.c, + * src/vm/jit/alpha/codegen.c, + * src/vm/jit/s390/emit.c, + * src/vm/jit/mips/emit.c, + * src/vm/jit/mips/codegen.c, + * src/vm/jit/m68k/codegen.c, + * src/vm/jit/powerpc64/emit.c, + * src/vm/jit/powerpc64/codegen.c, + * src/vm/jit/i386/emit.c, + * src/vm/jit/i386/codegen.c, + * src/vm/jit/x86_64/emit.c, + * src/vm/jit/x86_64/codegen.c (emit_replacement_stubs): Removed. + (codegen_emit): Do not create replacement stubs anymore. + [4b35cbd82eab] + +2007-07-18 twisti + + * src/cacaoh/dummy.c, src/native/jni.c, src/vm/builtin.c, + src/vm/builtintable.inc, src/vm/exceptions.c, src/vm/global.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/asmpart.h, + src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/jit/i386 + /md-abi.c, src/vm/jit_interface.h, src/vm/vm.c, src/vm/vm.h, + src/vmcore/descriptor.c: + * src/vm/jit/allocator/simplereg.c: Replaced HAS_4BYTE_STACKSLOT + with SIZEOF_VOID_P == 4. + + * src/vm/jit/i386/emit.c (vm/jit/abi.h): Added. + (emit_verbosecall_enter): Changed to 8-byte stackslots. + + * src/vm/jit/i386/codegen.c (codegen_emit): Changed to 8-byte + stackslots. (codegen_emit_stub_native): Likewise. + + * src/vm/jit/i386/arch.h (HAS_4BYTE_STACKSLOT): Removed. + (ALIGN_LONGS_IN_MEMORY): Likewise. (ALIGN_DOUBLES_IN_MEMORY): + Likewise. + + * src/vm/jit/i386/asmpart.S (asm_vm_call_method): Rewritten for new + argument passing. (asm_handle_exception): Use 8-byte stackslots. + + * src/vm/jit/i386/md-abi.c (md_param_alloc): Use 8-byte stackslots + and set pd->index. (md_param_alloc_native): New function. + + * src/vm/global.h (ALIGN_EVEN): New macro. (ALIGN_ODD): Likewise. + (ALIGN_2): Defined to ALIGN_EVEN. + + * src/vm/builtintable.inc (builtintable_function): Removed #ifdef + for java.lang.VMSystem.arraycopy, this works now correctly. + + * src/vm/builtin.c (builtintable_init): Set ACC_METHOD_BUILTIN when + parsing the decriptor. + + * src/vm/jit_interface.h (md_param_alloc_native): Added. + + * src/vm/exceptions.c (exceptions_handle_exception): Temporarily + added __I386__ to get the monitor object correctly. + + * src/vmcore/descriptor.c (descriptor_pool_parse_method_descriptor): + Check for ACC_METHOD_BUILTIN flag. + (descriptor_params_from_paramtypes): Likewise. + + * src/cacaoh/dummy.c (md_param_alloc_native): Added. + + * src/vm/jit/asmpart.h: Added __I386__ ifdef. + * src/vm/vm.c: Likewise. + * src/vm/vm.h: Likewise. + * src/native/jni.c: Likewise. (_Jv_jni_invokeNative): Check for + exception too when vm_array_from_objectarray returns. + [d8c3d6cb993f] + +2007-07-17 twisti + + * src/native/jni.c, src/native/vm/java_lang_ClassLoader.c, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (vm/resolve.h): Added. (class_define): Changed + signature. + * src/vmcore/class.h (class_define): Likewise. + + * src/native/jni.c (_Jv_JNI_DefineClass): Bug fix, use class_define. + + * src/native/vm/java_lang_ClassLoader.c (defineClass): Use + class_define. + [e181022e65d4] + + * src/native/jni.c: + * src/native/jni.c (TRACEJNICALLS): Added but still unused. + (JNI_GetCreatedJavaVMs): Implemented. + [704d5895a3e2] + +2007-07-16 twisti + + * src/native/vm/java_lang_Class.c, src/vmcore/class.c, + src/vmcore/class.h: + * src/vmcore/class.c (class_get_declaringclass): New function. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (getDeclaringClass): Use + class_get_declaringclass. + [1d90dbbeee2b] + +2007-07-15 twisti + + * src/native/vm/sun/jvm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_TraceJVMCalls): Added. + * src/vmcore/options.h: Likewise. + + * src/native/vm/sun/jvm.c (vmcore/options.h): Added. (DEBUG_JVM): + Renamed to TRACEJVMCALLS. (JVM_GetArrayLength): Implemented. + [e98518f9a80f] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c: Set Id keyword. + [62b76fb297f1] + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_ArrayCopy): Fixed warnings. + (JVM_GetStackTraceElement): Likewise. (JVM_FindLoadedClass): + Likewise. + [61524839b386] + + * src/native/vm/java_lang_Class.c, src/native/vm/sun/jvm.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/primitive.c, + src/vmcore/primitive.h: + * src/vmcore/primitive.c (primitive_class_is_primitive): Removed. + * src/vmcore/primitive.h: Likewise. + + * src/vmcore/class.c (class_is_primitive): New function. + (class_isanysubclass): Use class_is_primitive. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (isPrimitive): Use + class_is_primitive. (getDeclaringClass): Likewise. + (getDeclaredClasses): Likewise. + + * src/native/vm/sun/jvm.c (JVM_GetProtectionDomain): Likewise. + (JVM_IsPrimitiveClass): Likewise. (JVM_NewArray): Likewise. + [512da3c719eb] + + * src/native/include/Makefile.am: + * src/native/include/Makefile.am [WITH_CLASSPATH_SUN] + (JAVASE_HEADER_FILES): Added sun_reflect_ConstantPool.h. + [2594b1bb74d6] + + * src/native/vm/sun/jvm.c, src/vmcore/primitive.c, + src/vmcore/primitive.h: + * src/vmcore/primitive.c (stdint.h): Added. + (primitive_arrayclass_get_by_name): New function. + + * src/vmcore/primitive.h (stdint.h): Added. + (primitive_arrayclass_get_by_name): Likewise. + + * src/native/vm/sun/jvm.c (JVM_NewArray): Implemented handling for + primitive arrays. + [9d632e7741a1] + + * src/vm/vm.c: + * src/vm/vm.c: Build fix. + [a0bab80178fe] + +2007-07-13 michi + + * src/vm/jit/patcher-common.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vmcore/statistics.h (size_patchref): Added. + * src/vmcore/statistics.c (size_patchref): Added. + (statistics_print_memory_usage): Print size of patcher references. + + * src/vm/jit/patcher-common.c (patcher_add_patch_ref, + patcher_list_free) [ENABLE_STATISTICS] Set size of patcher + references accordingly. + [a08b6b8ca02b] + +2007-07-12 twisti + + * src/native/jni.c, src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/md- + abi.c, src/vm/jit/asmpart.h, src/vm/vm.c, src/vm/vm.h: + * src/vm/jit/alpha/asmpart.S (asm_vm_call_method): Rewritten for new + argument passing. + + * src/vm/jit/alpha/md-abi.c (md_param_alloc): Set pd->index. + + * src/native/jni.c: Added __ALPHA__ ifdef. + * src/vm/vm.c: Likewise. + * src/vm/vm.h: Likewise. + * src/vm/jit/asmpart.h: Likewise. + [e797b7ba8cef] + +2007-07-11 twisti + + * src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Fixed stack + alignment. + [83e9597727e8] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Fixed bug when taking + out double arguments. (codegen_emit_stub_native): Use switch-case + for saving and restoring argument registers. + [c1098e0c7614] + +2007-07-11 pm + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/codegen.c (codegen_emit): Extended maximal + interface table offset from 12 bit to 16 bit in + ICMD_INVOKEINTERFACE. + * src/vm/jit/s390/patcher.c (patcher_invokeinterface): Likewise. + [f6bf38c6c8ef] + +2007-07-10 twisti + + * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_TraceJavaCalls): Added. (options_XX): + Added opt_TraceJavaCalls. (options_xx): Likewise. + + * src/vmcore/options.h (opt_TraceJavaCalls): Added. + + * src/vm/vm.c (XXusage): Removed -verbose:call. (vm_create): + Likewise. + [9d27af991ee3] + +2007-07-09 twisti + + * src/vm/global.h: + * src/vm/global.h (ALIGN_2): Use logical arithmetic. + [95411b1de43b] + + * src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): Fixed + typo. + [81577d9b7a70] + +2007-07-08 twisti + + * src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.h: + * src/vm/jit/powerpc/emit.c (stdint.h): Added + (emit_verbosecall_enter): Reimplemented (this implementation is much + simpler and maybe should be extended to trace also arguments on the + stack). Darwin support is still missing. + + * src/vm/jit/powerpc/darwin/md-abi.h (TRACE_ARGS_NUM): Changed to 4. + * src/vm/jit/powerpc/linux/md-abi.h (TRACE_ARGS_NUM): Likewise. + [76e8134d9547] + + * src/vm/jit/powerpc/linux/md-abi.c: + * src/vm/jit/powerpc/linux/md-abi.c (vm/types.h): Removed. + (stdint.h): Added and use stdint-types in this file. (_ALIGN): + Removed and use ALIGN_2 in this file. + [2f63d1dad075] + +2007-07-07 ajordan + + * src/vm/jit/sparc64/solaris/md-os.c: + * src/vm/jit/sparc64/solaris/md-os.c: Implemented hardware exception + handling. + [f8def35f35a7] + +2007-07-06 michi + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/codegen.c (codegen_emit): ICMD_BUILTIN now calls + stubs. (codegen_emit_stub_builtin): Implemented. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigusr1): + Implemented. + [8e1026b0065a] + +2007-07-05 michi + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/md.c, src/vm/jit/code.c, + src/vm/jit/code.h, src/vm/jit/patcher.h, src/vm/jit/replace.c: + Merged revisions 8183-8186 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8184 | michi | 2007-07-05 23:11:01 +0200 (Thu, 05 Jul + 2007) | 5 lines + + * src/vm/jit/code.c (code_get_stack_frame_size): Removed. + * src/vm/jit/code.h: Likewise. + + * src/vm/jit/replace.c: Use code->stackframesize instead of above + function. ........ r8185 | michi | 2007-07-05 23:34:47 +0200 (Thu, + 05 Jul 2007) | 3 lines + + * src/vm/jit/arm/md.c (md_get_method_patch_address): Added the + replacement magic about mptr being NULL sometimes. ........ + r8186 | michi | 2007-07-06 01:48:16 +0200 (Fri, 06 Jul 2007) | 18 + lines + + * src/vm/jit/alpha/emit.c (emit_patcher_traps): Formerly known + as emit_patcher_stubs, now emits traps instead of stubs. + + * src/vm/jit/alpha/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions and + adapted to above change. + + * src/vm/jit/alpha/patcher.c: Adapted patchers to new signature + for traps. (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/alpha/asmpart.S (asm_patcher_wrapper): Removed, this + is obsolete. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Only + calls the exception handling if exception object present. + + * src/vm/jit/patcher-common.h [__ALPHA__]: Enabled new patcher + stuff. + + * src/vm/jit/patcher.h [__ALPHA__]: Defined away old patcher + stuff. ........ + [a3741372872e] + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/patcher-common.h, + src/vm/jit/patcher.h: + * src/vm/jit/alpha/emit.c (emit_patcher_traps): Formerly known as + emit_patcher_stubs, now emits traps instead of stubs. + + * src/vm/jit/alpha/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions and + adapted to above change. + + * src/vm/jit/alpha/patcher.c: Adapted patchers to new signature for + traps. (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/alpha/asmpart.S (asm_patcher_wrapper): Removed, this is + obsolete. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Only + calls the exception handling if exception object present. + + * src/vm/jit/patcher-common.h [__ALPHA__]: Enabled new patcher + stuff. + + * src/vm/jit/patcher.h [__ALPHA__]: Defined away old patcher stuff. + [a1c06d17e926] + + * src/vm/jit/arm/md.c: + * src/vm/jit/arm/md.c (md_get_method_patch_address): Added the + replacement magic about mptr being NULL sometimes. + [141abc4a7bad] + + * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/replace.c: + * src/vm/jit/code.c (code_get_stack_frame_size): Removed. + * src/vm/jit/code.h: Likewise. + + * src/vm/jit/replace.c: Use code->stackframesize instead of above + function. + [2a910eb769bf] + + * src/vm/jit/arm/codegen.c: + Merged revisions 8179-8182 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8182 | michi | 2007-07-05 22:36:16 +0200 (Thu, 05 Jul + 2007) | 2 lines + + * src/vm/jit/arm/codegen.c (codegen_emit): Replacement points are + created. ........ + [7d9eb0c5b094] + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen_emit): Replacement points are + created. + [668663c17f9d] + + * src/mm/cacao-gc/gc.h, src/threads/native/threads.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/linux/md-os.c: + * src/threads/native/threads.c: Fixed bogus ifdef. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigusr1): + Implemented. + + * src/vm/jit/arm/codegen.c (codegen_emit): ICMD_BUILTIN now calls + stubs. (codegen_emit_stub_builtin): Implemented. + (codegen_emit_stub_native) [ENABLE_GC_CACAO]: Saved registers are + stored in sfi. + + * src/mm/cacao-gc/gc.h: Added ARM to ported architecture list. + [70c7e9fae365] + + * src/mm/cacao-gc/gc.c: + * src/mm/cacao-gc/gc.c (gc_reference_register): Fixed problem with + threads_init. + [1f0a1f599bf5] + + * configure.ac, src/mm/boehm.c, src/mm/nogc.c, src/native/jni.c, + src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_Runtime.c, src/native/vm/sun_misc_Unsafe.c, + src/vm/builtin.c, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/global.h, src/vm/jit/Makefile.am, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/patcher.c, + src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/codegen-common.c, + src/vm/jit/emit-common.h, src/vm/jit/i386/darwin/Makefile.am, + src/vm/jit/i386/darwin/md-os.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/i386/patcher.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/parse.c, src/vm/jit/patcher.h, src/vm/jit/powerpc/darwin + /md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/tests/dacapo.status, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/solaris/md-os.c, + src/vm/jit/stacktrace.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/x86_64/linux/md-os.c, + src/vm/vm.c, src/vm/vm.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/options.c: + Merged revisions 8137-8178 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8139 | twisti | 2007-06-24 12:12:27 +0200 (Sun, 24 Jun + 2007) | 3 lines + + * src/vm/jit/stacktrace.c (stacktrace_print_trace): Handle + WITH_CLASSPATH_SUN properly. ........ r8142 | pm | 2007-06-25 + 20:58:11 +0200 (Mon, 25 Jun 2007) | 3 lines + + * src/vm/jit/s390/tests/jasmin.status: Added. ........ r8143 | + twisti | 2007-06-26 17:47:43 +0200 (Tue, 26 Jun 2007) | 3 lines + + * src/vm/jit/i386/patcher.c (patcher_builtin_multianewarray): + Dont' patch function address. ........ r8144 | pm | 2007-06-26 + 23:16:35 +0200 (Tue, 26 Jun 2007) | 3 lines + + * src/vm/jit/s390/tests/dacapo.status: Added more dacapo eclipse + results. ........ r8145 | michi | 2007-06-27 10:54:10 +0200 (Wed, + 27 Jun 2007) | 16 lines + + * src/vm/jit/patcher-common.h: Added. + * src/vm/jit/patcher-common.t: Added. + * src/vm/jit/Makefile.am: Added above two files. + + * src/vm/jit/code.h (codeinfo): Added patcher list. + * src/vm/jit/code.c (code_codeinfo_new, code_codeinfo_free): Patcher + list is created and freed together with codeinfo. + + * src/vm/jit/codegen-common.c (codegen_finish): Absolute PCs for + patchers are resolved. + + * src/vm/jit/emit-common.h (emit_patcher_traps): Added prototype. + + * src/vm/exception.c (exceptions_new_hardware_exception): Patcher + handler is called if needed. ........ r8146 | michi | 2007-06-27 + 11:04:17 +0200 (Wed, 27 Jun 2007) | 3 lines + + * src/vm/exceptions.h: Added EXCEPTION_HARDWARE_COMPILER. + * src/vm/exceptions.c (exceptions_init): Made check clearer. ........ + r8147 | twisti | 2007-06-27 11:23:24 +0200 (Wed, 27 Jun 2007) | 2 + lines + + * src/native/vm/gnu/java_lang_VMRuntime.c (unistd.h): Added. + ........ r8149 | twisti | 2007-06-27 15:26:49 +0200 (Wed, 27 Jun + 2007) | 3 lines + + * src/native/vm/sun_misc_Unsafe.c (putObject): New function. + (park): New function, but not implemented. ........ r8150 | twisti + | 2007-06-27 20:35:40 +0200 (Wed, 27 Jun 2007) | 6 lines + + * src/mm/boehm.c (gc_init): Set GC_all_interior_pointers to 0 and + call GC_INIT very late. + + * src/vm/vm.c (vm_create): Initialze the GC before all other + subsystems. ........ r8151 | pm | 2007-06-27 22:08:30 +0200 (Wed, + 27 Jun 2007) | 2 lines + + * src/vm/jit/s390/codegen.c (codegen_emit): Replace some + load/stores by a mvc. ........ r8152 | pm | 2007-06-27 22:37:45 + +0200 (Wed, 27 Jun 2007) | 2 lines + + * src/vm/jit/s390/codegen.c (codegen_emit): Fix profiling code. + ........ r8153 | ajordan | 2007-06-27 22:56:03 +0200 (Wed, 27 Jun + 2007) | 12 lines + + * src/vm/jit/sparc64/md-abi.h: Removed faulty register offset + multiplication from REG_WINDOW_TRANSPOSE. + + * src/vm/jit/sparc64/asmpart.S: fixed offsets.h include. + + * src/vm/jit/sparc64/solaris/macro_rename.h: Added include, + which renames the REG_SP defined from Solaris sys headers to + REG_SP_SOLARIS and defines mine. + * src/vm/jit/sparc64/emit.c: Used here. + * src/vm/jit/sparc64/codegen.c: Used here. + * src/vm/jit/sparc64/patcher.c: Used here. ........ r8154 | ajordan + | 2007-06-27 22:56:57 +0200 (Wed, 27 Jun 2007) | 2 lines + + * configure.ac: Added librt for SPARC/Solaris. ........ r8155 | + ajordan | 2007-06-27 23:53:44 +0200 (Wed, 27 Jun 2007) | 6 lines + + * src/vm/builtin.c (builtin_f2l): Added for DISABLE_GC. + (builtin_d2l): Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Added SPARC to defines, + corrected bitwise & for ARM. ........ r8156 | ajordan | + 2007-06-28 00:07:28 +0200 (Thu, 28 Jun 2007) | 2 lines + + * configure.ac: Check for librt should only be done on Solaris. + ........ r8157 | michi | 2007-06-28 00:12:32 +0200 (Thu, 28 Jun + 2007) | 3 lines + + * src/vm/vm.c: Fixed messed up ifdefs introduced with M68K. + * src/vm/vm.h: Likewise. ........ r8158 | ajordan | 2007-06-28 + 02:01:34 +0200 (Thu, 28 Jun 2007) | 6 lines + + * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added absolute + offsets for native arguments (reguse * 8). + + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Adapted + to change above. ........ r8159 | michi | 2007-06-28 02:31:31 + +0200 (Thu, 28 Jun 2007) | 5 lines + + * src/vm/jit/verify/typecheck-typeinferer.c: Removed patcher.h + include. + * src/vm/jit/verify/typecheck.c: Likewise. + * src/vm/jit/parse.c: Likewise. + * src/vm/builtin.c: Likewise. ........ r8160 | michi | 2007-06-28 + 03:52:19 +0200 (Thu, 28 Jun 2007) | 26 lines + + * src/vm/jit/arm/emit.c (emit_patcher_traps): Formerly known as + emit_patcher_stubs, now emits traps instead of stubs. + + * src/vm/jit/arm/codegen.c (codegen_emit, + codegen_emit_stub_native): Call the new patcher functions and + adapted to above change. + + * src/vm/jit/arm/patcher.c: Adapted patchers to new signature for + traps. (patcher_get_putfield): Fixed severe bug for long values. + (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/arm/codegen.h (M_TRAP): Added. + + * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Removed, this is + obsolete. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Only + calls the exception handling if exception object present. + + * src/vm/jit/patcher-common.c: Fixed includes. + + * src/vm/jit/patcher-common.h [__ARM__]: Added prototypes for + patcher functions. (patchref_t): Added datap. + + * src/vm/jit/patcher.h [__ARM__]: Defined away old patcher stuff. + + * src/vm/jit/codegen-common.c (codegen_finish): Resolves pr->datap + as well. ........ r8161 | twisti | 2007-06-28 12:30:08 +0200 (Thu, + 28 Jun 2007) | 11 lines + + * src/vm/global.h (ACC_CLASS_REFERENCE_MASK): Added. + (ACC_CLASS_SOFT_REFERENCE): Renamed to ACC_CLASS_REFERENCE_SOFT. + (ACC_CLASS_WEAK_REFERENCE): Renamed to ACC_CLASS_REFERENCE_WEAK. + (ACC_CLASS_PHANTOM_REFERENCE): Renamed to + ACC_CLASS_REFERENCE_PHANTOM. + + * src/vmcore/class.c (class_create_classinfo): Flag + soft/weak/phantom reference classes. + + * src/vmcore/linker.c (link_class_intern): Inherit the reference + flags. ........ r8162 | twisti | 2007-06-28 15:40:37 +0200 (Thu, + 28 Jun 2007) | 2 lines + + * src/native/vm/sun/jvm.c: Added copyright header. ........ + r8163 | twisti | 2007-06-29 20:53:55 +0200 (Fri, 29 Jun 2007) | 16 + lines + + * configure.ac (AC_CHECK_HEADERS): Added netdb.h, ucontext.h. + (AC_CHECK_FUNCS): Added gethostbyname, htons, malloc, recv, send. + (AC_CHECK_ENABLE_ZLIB): Moved code to function. + (AC_CHECK_ENABLE_LTDL): Likewise. + + * m4/zlib.m4: New file. + * m4/ltdl.m4: Likewise. + + * src/native/native.c [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added + #ifdef. [ENABLE_LTDL] (hashtable_library): Likewise. + (native_init) [ENABLE_LTDL]: Likewise. [ENABLE_LTDL] + (native_library_open): Likewise. [ENABLE_LTDL] + (native_library_add): Likewise. [ENABLE_LTLD] + (native_library_find): Likewise. ........ r8164 | twisti | + 2007-06-29 20:56:08 +0200 (Fri, 29 Jun 2007) | 2 lines + + * src/native/native.c (native_library_find): Typo. ........ + r8165 | twisti | 2007-06-29 21:02:08 +0200 (Fri, 29 Jun 2007) | 4 + lines + + * src/native/vm/java_lang_Runtime.c [ENABLE_LTDL && HAVE_LTDL_H] + (ltdl.h): Added #ifdef. (loadLibrary) [ENABLE_LTDL]: Likewise. + ........ r8166 | twisti | 2007-06-29 21:45:17 +0200 (Fri, 29 Jun + 2007) | 9 lines + + * src/native/native.c: Removed wrong comment. + + * src/native/native.h [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added + #ifdef. [ENABLE_LTDL] (hashtable_library_loader_entry): Likewise. + [ENABLE_LTDL] (hashtable_library_name_entry): Likewise. + [ENABLE_LTDL] (native_library_open, native_library_add) + (native_library_find): Likewise. ........ r8167 | twisti | + 2007-06-29 22:27:41 +0200 (Fri, 29 Jun 2007) | 3 lines + + * src/native/native.h (hashtable_library_name_entry): Moved up, + build fix. ........ r8168 | twisti | 2007-06-30 14:20:48 +0200 + (Sat, 30 Jun 2007) | 2 lines + + * src/mm/nogc.c (vm/vm.h): Added. ........ r8169 | twisti | + 2007-06-30 14:33:50 +0200 (Sat, 30 Jun 2007) | 18 lines + + * src/vmcore/class.c (class_is_array): New function. + (class_is_interface): Likewise. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (stdint.h): Added. + (isInterface): Made JNI function, use class_is_interface. + (isArray): Made JNI function, use class_is_array. + * src/native/vm/java_lang_Class.h: Likewise. + + * src/native/vm/cldc1.1/java_lang_Class.c (methods): Register + common methods for isInterface and isArray. (isInterface): + Removed. (isArray): Likewise. + + * src/native/vm/gnu/java_lang_VMClass.c (isInterface): Changed to + JNI call. (isArray): Likewise. ........ r8170 | twisti | + 2007-06-30 16:03:18 +0200 (Sat, 30 Jun 2007) | 23 lines + + * src/native/jni.c [ENABLE_JAVASE] (native/vm/reflect.h): Added. + (_Jv_JNI_ToReflectedMethod): Implemented. + + * src/native/vm/java_lang_Class.c [ENABLE_JAVASE] + (native/vm/reflect.h): Added. (getDeclaredFields): Use + reflect_field_new. (getDeclaredMethods): Use reflect_method_new. + (getDeclaredConstructors): Use reflect_constructor_new. + (getEnclosingConstructor): Use reflect_constructor_new. + (getEnclosingMethod): Use reflect_method_new. + + * src/native/vm/sun/jvm.c (jio_vsnprintf): Added count check. + (jio_snprintf): Implemented. (JVM_IsInterface): Use + class_is_interface. (JVM_IsArrayClass): Use class_is_array. + (JVM_InvokeMethod): Disabled debug output. + + * src/native/vm/reflect.c: New file. + * src/native/vm/reflect.h: Likewise. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] (REFLECT_SOURCES): + Added. (libnativevm_la_SOURCES): Added REFLECT_SOURCES. ........ + r8171 | twisti | 2007-06-30 16:13:58 +0200 (Sat, 30 Jun 2007) | 2 + lines + + * src/native/vm/reflect.c: Fixed includes. ........ r8172 | + twisti | 2007-06-30 16:14:52 +0200 (Sat, 30 Jun 2007) | 3 lines + + * src/native/vm/reflect.c: Added Id keyword. + * src/native/vm/reflect.h: Likewise. ........ r8173 | twisti | + 2007-06-30 19:40:09 +0200 (Sat, 30 Jun 2007) | 3 lines + + * src/native/vm/sun/jvm.c (JVM_Available): Fixed return value + (seems it's a boolean value, 1 is OK, 0 is error). ........ + r8174 | twisti | 2007-07-01 19:49:25 +0200 (Sun, 01 Jul 2007) | 2 + lines + + * src/vmcore/options.c (options_xx): Fixed warnings. ........ + r8175 | twisti | 2007-07-02 16:07:24 +0200 (Mon, 02 Jul 2007) | 3 + lines + + * src/vm/exceptions.c (exceptions_init) [!(__ARM__ && __LINUX__)]: + Don't mmap page 0x0 on arm-linux. ........ r8176 | twisti | + 2007-07-03 17:43:14 +0200 (Tue, 03 Jul 2007) | 3 lines + + * src/vm/jit/i386/darwin/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. ........ r8177 | twisti | 2007-07-03 + 18:05:27 +0200 (Tue, 03 Jul 2007) | 3 lines + + * src/native/vm/sun_misc_Unsafe.c (methods): Added unpark. + (unpark): New function, but unimplemented. ........ r8178 | michi + | 2007-07-05 13:13:20 +0200 (Thu, 05 Jul 2007) | 22 lines + + * src/vm/exceptions.c (exceptions_new_hardware_exception): + Stackframeinfo block is now on the stack of the signal handler + function. + + * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed + signature. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Passes + sfi to exceptions function. + + * src/vm/jit/powerpc/linux/md-os.c: Likewise. + * src/vm/jit/powerpc/darwin/md-os.c: Likewise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + * src/vm/jit/sparc64/solaris/md-os.c: Likewise. + * src/vm/jit/alpha/linux/md-os.c: Likewise. + * src/vm/jit/s390/md.c: Likewise. + * src/vm/jit/mips/linux/md-os.c: Likewise. + * src/vm/jit/mips/irix/md-os.c: Likewise. + * src/vm/jit/m68k/linux/md-os.c: Likewise. + * src/vm/jit/powerpc64/linux/md-os.c: Likewise. + * src/vm/jit/i386/darwin/md-os.c: Likewise. + * src/vm/jit/i386/linux/md-os.c: Likewise. + * src/vm/jit/x86_64/linux/md-os.c: Likewise. ........ + [45996bcfca93] + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/alpha/linux/md- + os.c, src/vm/jit/arm/linux/md-os.c, src/vm/jit/i386/darwin/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/mips/irix/md-os.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/md.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/solaris/md- + os.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/exceptions.c (exceptions_new_hardware_exception): + Stackframeinfo block is now on the stack of the signal handler + function. + + * src/vm/exceptions.h (exceptions_new_hardware_exception): Changed + signature. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Passes + sfi to exceptions function. + + * src/vm/jit/powerpc/linux/md-os.c: Likewise. + * src/vm/jit/powerpc/darwin/md-os.c: Likewise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + * src/vm/jit/sparc64/solaris/md-os.c: Likewise. + * src/vm/jit/alpha/linux/md-os.c: Likewise. + * src/vm/jit/s390/md.c: Likewise. + * src/vm/jit/mips/linux/md-os.c: Likewise. + * src/vm/jit/mips/irix/md-os.c: Likewise. + * src/vm/jit/m68k/linux/md-os.c: Likewise. + * src/vm/jit/powerpc64/linux/md-os.c: Likewise. + * src/vm/jit/i386/darwin/md-os.c: Likewise. + * src/vm/jit/i386/linux/md-os.c: Likewise. + * src/vm/jit/x86_64/linux/md-os.c: Likewise. + [ed15bb556f62] + +2007-07-03 twisti + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (methods): Added unpark. (unpark): + New function, but unimplemented. + [5c5f4a6dbe96] + + * src/vm/jit/i386/darwin/Makefile.am: + * src/vm/jit/i386/darwin/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + [d090c160bd9d] + +2007-07-02 twisti + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_init) [!(__ARM__ && __LINUX__)]: + Don't mmap page 0x0 on arm-linux. + [00c88ae777e6] + +2007-07-01 twisti + + * src/vmcore/options.c: + * src/vmcore/options.c (options_xx): Fixed warnings. + [eb45b5e3c073] + +2007-06-30 twisti + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c (JVM_Available): Fixed return value (seems + it's a boolean value, 1 is OK, 0 is error). + [4432ee1ce926] + + * src/native/vm/reflect.c, src/native/vm/reflect.h: + * src/native/vm/reflect.c: Added Id keyword. + * src/native/vm/reflect.h: Likewise. + [046c821f97fd] + + * src/native/vm/reflect.c: + * src/native/vm/reflect.c: Fixed includes. + [f0af119deb56] + + * src/native/jni.c, src/native/vm/Makefile.am, + src/native/vm/java_lang_Class.c, src/native/vm/reflect.c, + src/native/vm/reflect.h, src/native/vm/sun/jvm.c: + * src/native/jni.c [ENABLE_JAVASE] (native/vm/reflect.h): Added. + (_Jv_JNI_ToReflectedMethod): Implemented. + + * src/native/vm/java_lang_Class.c [ENABLE_JAVASE] + (native/vm/reflect.h): Added. (getDeclaredFields): Use + reflect_field_new. (getDeclaredMethods): Use reflect_method_new. + (getDeclaredConstructors): Use reflect_constructor_new. + (getEnclosingConstructor): Use reflect_constructor_new. + (getEnclosingMethod): Use reflect_method_new. + + * src/native/vm/sun/jvm.c (jio_vsnprintf): Added count check. + (jio_snprintf): Implemented. (JVM_IsInterface): Use + class_is_interface. (JVM_IsArrayClass): Use class_is_array. + (JVM_InvokeMethod): Disabled debug output. + + * src/native/vm/reflect.c: New file. + * src/native/vm/reflect.h: Likewise. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] (REFLECT_SOURCES): + Added. (libnativevm_la_SOURCES): Added REFLECT_SOURCES. + [79479048da5d] + + * src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_is_array): New function. + (class_is_interface): Likewise. + * src/vmcore/class.h: Likewise. + + * src/native/vm/java_lang_Class.c (stdint.h): Added. (isInterface): + Made JNI function, use class_is_interface. (isArray): Made JNI + function, use class_is_array. + * src/native/vm/java_lang_Class.h: Likewise. + + * src/native/vm/cldc1.1/java_lang_Class.c (methods): Register common + methods for isInterface and isArray. (isInterface): Removed. + (isArray): Likewise. + + * src/native/vm/gnu/java_lang_VMClass.c (isInterface): Changed to + JNI call. (isArray): Likewise. + [acb7df19a892] + + * src/mm/nogc.c: + * src/mm/nogc.c (vm/vm.h): Added. + [63946b83b797] + +2007-06-29 twisti + + * src/native/native.h: + * src/native/native.h (hashtable_library_name_entry): Moved up, + build fix. + [d52db4d05f7f] + + * src/native/native.c, src/native/native.h: + * src/native/native.c: Removed wrong comment. + + * src/native/native.h [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added + #ifdef. [ENABLE_LTDL] (hashtable_library_loader_entry): Likewise. + [ENABLE_LTDL] (hashtable_library_name_entry): Likewise. + [ENABLE_LTDL] (native_library_open, native_library_add) + (native_library_find): Likewise. + [37f54ade6767] + + * src/native/vm/java_lang_Runtime.c: + * src/native/vm/java_lang_Runtime.c [ENABLE_LTDL && HAVE_LTDL_H] + (ltdl.h): Added #ifdef. (loadLibrary) [ENABLE_LTDL]: Likewise. + [d4bf1a094f8c] + + * src/native/native.c: + * src/native/native.c (native_library_find): Typo. + [bab9a7c581a5] + + * configure.ac, m4/ltdl.m4, m4/zlib.m4, src/native/native.c: + * configure.ac (AC_CHECK_HEADERS): Added netdb.h, ucontext.h. + (AC_CHECK_FUNCS): Added gethostbyname, htons, malloc, recv, send. + (AC_CHECK_ENABLE_ZLIB): Moved code to function. + (AC_CHECK_ENABLE_LTDL): Likewise. + + * m4/zlib.m4: New file. + * m4/ltdl.m4: Likewise. + + * src/native/native.c [ENABLE_LTDL && HAVE_LTDL_H] (ltdl.h): Added + #ifdef. [ENABLE_LTDL] (hashtable_library): Likewise. (native_init) + [ENABLE_LTDL]: Likewise. [ENABLE_LTDL] (native_library_open): + Likewise. [ENABLE_LTDL] (native_library_add): Likewise. + [ENABLE_LTLD] (native_library_find): Likewise. + [89167cd086a1] + +2007-06-28 twisti + + * src/native/vm/sun/jvm.c: + * src/native/vm/sun/jvm.c: Added copyright header. + [e28a66594929] + + * src/vm/global.h, src/vmcore/class.c, src/vmcore/linker.c: + * src/vm/global.h (ACC_CLASS_REFERENCE_MASK): Added. + (ACC_CLASS_SOFT_REFERENCE): Renamed to ACC_CLASS_REFERENCE_SOFT. + (ACC_CLASS_WEAK_REFERENCE): Renamed to ACC_CLASS_REFERENCE_WEAK. + (ACC_CLASS_PHANTOM_REFERENCE): Renamed to + ACC_CLASS_REFERENCE_PHANTOM. + + * src/vmcore/class.c (class_create_classinfo): Flag + soft/weak/phantom reference classes. + + * src/vmcore/linker.c (link_class_intern): Inherit the reference + flags. + [a26a9d65db4f] + +2007-06-28 michi + + * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/arm/patcher.c, src/vm/jit + /codegen-common.c, src/vm/jit/patcher-common.c, src/vm/jit/patcher- + common.h, src/vm/jit/patcher.h: + * src/vm/jit/arm/emit.c (emit_patcher_traps): Formerly known as + emit_patcher_stubs, now emits traps instead of stubs. + + * src/vm/jit/arm/codegen.c (codegen_emit, codegen_emit_stub_native): + Call the new patcher functions and adapted to above change. + + * src/vm/jit/arm/patcher.c: Adapted patchers to new signature for + traps. (patcher_get_putfield): Fixed severe bug for long values. + (patcher_wrapper): Removed, this is obsolete. + + * src/vm/jit/arm/codegen.h (M_TRAP): Added. + + * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Removed, this is + obsolete. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Only + calls the exception handling if exception object present. + + * src/vm/jit/patcher-common.c: Fixed includes. + + * src/vm/jit/patcher-common.h [__ARM__]: Added prototypes for + patcher functions. (patchref_t): Added datap. + + * src/vm/jit/patcher.h [__ARM__]: Defined away old patcher stuff. + + * src/vm/jit/codegen-common.c (codegen_finish): Resolves pr->datap + as well. + [dd42a4fb91a1] + + * src/vm/builtin.c, src/vm/jit/parse.c, src/vm/jit/verify/typecheck- + typeinferer.c, src/vm/jit/verify/typecheck.c: + * src/vm/jit/verify/typecheck-typeinferer.c: Removed patcher.h + include. + * src/vm/jit/verify/typecheck.c: Likewise. + * src/vm/jit/parse.c: Likewise. + * src/vm/builtin.c: Likewise. + [a728115da0ec] + +2007-06-28 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c: + * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added absolute + offsets for native arguments (reguse * 8). + + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Adapted + to change above. + [9cfebf36e941] + +2007-06-27 michi + + * src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c: Fixed messed up ifdefs introduced with M68K. + * src/vm/vm.h: Likewise. + [8eadc67728d1] + +2007-06-27 ajordan + + * configure.ac: + * configure.ac: Check for librt should only be done on Solaris. + [aaba5c87ffb0] + + * src/native/jni.c, src/vm/builtin.c: + * src/vm/builtin.c (builtin_f2l): Added for DISABLE_GC. + (builtin_d2l): Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Added SPARC to defines, + corrected bitwise & for ARM. + [bddcdeb22dc9] + + * configure.ac: + * configure.ac: Added librt for SPARC/Solaris. + [923534fb6691] + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/patcher.c, + src/vm/jit/sparc64/solaris/macro_rename.h: + * src/vm/jit/sparc64/md-abi.h: Removed faulty register offset + multiplication from REG_WINDOW_TRANSPOSE. + + * src/vm/jit/sparc64/asmpart.S: fixed offsets.h include. + + * src/vm/jit/sparc64/solaris/macro_rename.h: Added include, which + renames the REG_SP defined from Solaris sys headers to + REG_SP_SOLARIS and defines mine. + * src/vm/jit/sparc64/emit.c: Used here. + * src/vm/jit/sparc64/codegen.c: Used here. + * src/vm/jit/sparc64/patcher.c: Used here. + [2f8525b7b726] + +2007-06-27 pm + + * src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen_emit): Fix profiling code. + [692df92fc20d] + + * src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen_emit): Replace some load/stores + by a mvc. + [ae968da74f36] + +2007-06-27 twisti + + * src/mm/boehm.c, src/vm/vm.c: + * src/mm/boehm.c (gc_init): Set GC_all_interior_pointers to 0 and + call GC_INIT very late. + + * src/vm/vm.c (vm_create): Initialze the GC before all other + subsystems. + [7e6bf309d25b] + + * src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/sun_misc_Unsafe.c (putObject): New function. (park): + New function, but not implemented. + [3a5a36091d6b] + + * src/native/vm/gnu/java_lang_VMRuntime.c: + * src/native/vm/gnu/java_lang_VMRuntime.c (unistd.h): Added. + [748708276827] + +2007-06-27 michi + + * src/vm/exceptions.c, src/vm/exceptions.h: + * src/vm/exceptions.h: Added EXCEPTION_HARDWARE_COMPILER. + * src/vm/exceptions.c (exceptions_init): Made check clearer. + [943f3069095d] + + * src/vm/exceptions.c, src/vm/jit/Makefile.am, src/vm/jit/code.c, + src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/emit- + common.h, src/vm/jit/patcher-common.c, src/vm/jit/patcher-common.h: + * src/vm/jit/patcher-common.h: Added. + * src/vm/jit/patcher-common.t: Added. + * src/vm/jit/Makefile.am: Added above two files. + + * src/vm/jit/code.h (codeinfo): Added patcher list. + * src/vm/jit/code.c (code_codeinfo_new, code_codeinfo_free): Patcher + list is created and freed together with codeinfo. + + * src/vm/jit/codegen-common.c (codegen_finish): Absolute PCs for + patchers are resolved. + + * src/vm/jit/emit-common.h (emit_patcher_traps): Added prototype. + + * src/vm/exception.c (exceptions_new_hardware_exception): Patcher + handler is called if needed. + [e4ced3dc9153] + +2007-06-26 pm + + * src/vm/jit/s390/tests/dacapo.status: + * src/vm/jit/s390/tests/dacapo.status: Added more dacapo eclipse + results. + [4ceab82084f8] + +2007-06-26 twisti + + * src/vm/jit/i386/patcher.c: + * src/vm/jit/i386/patcher.c (patcher_builtin_multianewarray): Dont' + patch function address. + [1a440facfdcb] + +2007-06-25 pm + + * src/vm/jit/s390/tests/jasmin.status: + * src/vm/jit/s390/tests/jasmin.status: Added. + [ea95a0a32e67] + +2007-06-25 michi + + * src/native/vm/gnu/java_lang_VMClassLoader.c: + * src/native/vm/gnu/java_lang_VMClassLoader.c + (Java_java_lang_VMClassLoader_findLoadedClass): Fixed bug with + classloader entry not being registered. + [f7a82b765b39] + + * src/vm/jit/stacktrace.c, src/vmcore/class.c, src/vmcore/class.h: + * src/vmcore/class.c (class_define, class_array_of): Fixed compiler + warnings. + * src/vmcore/class.h: Likewise. + [a14a956dfda2] + +2007-06-24 twisti + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_print_trace): Handle + WITH_CLASSPATH_SUN properly. + [6d8488b06f3f] + +2007-06-22 michi + + * src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): Adapted to + multiplied regoff value. + + * src/vm/jit/m68k/codegen.c (codegen_emit_stub_builtin): Likewise. + [e4de9c874bd6] + + * configure.ac, m4/classpath.m4, src/cacao/Makefile.am, + src/lib/Makefile.am, src/native/include/Makefile.am, + src/native/jni.c, src/native/jni.h, src/native/native.c, + src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h, + src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h, src/native/vm/sun_misc_Unsafe.c, + src/threads/native/threads.c, src/threads/threads-common.c, + src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/asmpart.h, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/replace.c, + src/vm/properties.c, src/vm/vm.c, src/vm/vm.h, src/vmcore/class.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/utf8.c, src/vmcore/utf8.h: + Merged revisions 8123-8136 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8125 | twisti | 2007-06-21 12:02:14 +0200 (Thu, 21 Jun + 2007) | 4 lines + + * configure.ac (AC_CHECK_HEADERS): Added sys/socket.h. + (AC_CHECK_FUNCS): Added accept, close, connect, getsockname, listen, + setsockopt, shutdown, socket. ........ r8126 | twisti | 2007-06-21 + 12:42:35 +0200 (Thu, 21 Jun 2007) | 2 lines + + * configure.ac (AC_CHECK_FUNCS): Added gethostname. ........ + r8127 | michi | 2007-06-21 13:55:56 +0200 (Thu, 21 Jun 2007) | 19 + lines + + * src/vm/jit/arm/arch.h: Removed HAS_4BYTE_STACKSLOT, + ALIGN_LONGS_IN_MEMORY and ALIGN_DOUBLES_IN_MEMORY. + + * src/vm/jit/arm/md-abi.c (md_param_alloc): Changed to 8-byte + stackslots and set pd->index correctly. + + * src/vm/jit/arm/codegen.c: Changed to 8-byte stackslots (spilled + regs and arguments only). + + * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Reimplemented to + fit new argument passing. Changed to 8-byte stackslots. + + * src/vm/vm.c (vm_array_store_flt, vm_array_store_dbl) + [SUPPORT_PASS_FLOATARGS_IN_INTREGS]: Fixed. + + * src/vm/vm.c: Added ARM ifdefs. + * src/vm/vm.h: Added ARM ifdefs. + * src/native/jni.c: Added ARM ifdefs. ........ r8128 | tbfg | + 2007-06-21 18:29:53 +0200 (Thu, 21 Jun 2007) | 11 lines + + * src/vm/jit/m68k/linux/md-abi.h: Prepared 8 byte stackslots. + * src/vm/jit/m68k/linux/md-abi.c: Likewise. + * src/vm/jit/m68k/emit.c: Likewise. + * src/vm/jit/m68k/arch.h: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/m68k/asmpart.S: Likewise. + * src/vm/jit/asmpart.h: Likewise. + * src/vm/vm.c: Likewise. + * src/vm/vm.h: Likewise. + * src/native/jni.c: Likewise. ........ r8130 | twisti | 2007-06-22 + 10:50:37 +0200 (Fri, 22 Jun 2007) | 5 lines + + * src/vmcore/options.c (opt_ThreadStackSize): Added. + (options_xx): Option and values are seperated by '=', not by ':' + (let's keep compatible to Sun). + * src/vmcore/options.h (opt_ThreadStackSize): Added. ........ r8131 + | tbfg | 2007-06-22 11:37:00 +0200 (Fri, 22 Jun 2007) | 3 lines + + * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Fixed for 8 + byte stack slots. + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Fixed location of + method address. ........ r8132 | twisti | 2007-06-22 13:15:47 + +0200 (Fri, 22 Jun 2007) | 44 lines + + * configure.ac, contrib/mapfile-vers-product, m4/classpath.m4, + src/cacao/Makefile.am, src/lib/Makefile.am, + src/lib/gnu/java/lang/reflect, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, src/lib/gnu/sun, + src/lib/gnu/sun/misc, src/lib/gnu/sun/misc/Unsafe.java, + src/native/include/Makefile.am, src/native/jni.c, + src/native/jni.h, src/native/native.c, src/native/native.h, + src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, + src/native/vm/java_lang_Object.h, + src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/sun, src/native/vm/sun/Makefile.am, + src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c, + src/threads/native/threads.c, src/threads/threads-common.c, + src/vm/properties.c, src/vm/vm.c, src/vm/vm.h, + src/vmcore/class.h, src/vmcore/field.c, src/vmcore/field.h, + src/vmcore/utf8.c, src/vmcore/utf8.h: Initial support for using + OpenJDK libraries as Java core libraries. ........ r8133 | + twisti | 2007-06-22 15:29:38 +0200 (Fri, 22 Jun 2007) | 2 lines + + * m4/classpath.m4: Added Id keyword. ........ r8134 | twisti | + 2007-06-22 16:49:10 +0200 (Fri, 22 Jun 2007) | 8 lines + + * src/vmcore/options.c (opt_MaxPermSize): Added. (opt_PermSize): + Likewise. (options_xx): Check for +/- for boolean options (still + some work left). + + * src/vmcore/options.h (opt_MaxPermSize): Added. (opt_PermSize): + Likewise. ........ r8135 | twisti | 2007-06-22 17:31:05 +0200 + (Fri, 22 Jun 2007) | 6 lines + + * src/lib/gnu/sun/misc/Unsafe.java: Updated to openjdk rev239. + + * src/native/vm/sun_misc_Unsafe.c (arrayBaseOffset): Implemented. + (arrayIndexScale): Likewise. (addressSize): Likewise. ........ + r8136 | michi | 2007-06-22 18:33:40 +0200 (Fri, 22 Jun 2007) | 2 + lines + + * src/vm/jit/replace.c: Adapted to multiplied regoff value. + ........ + [ee178e550972] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c: Adapted to multiplied regoff value. + [373d83e92ed6] + +2007-06-22 twisti + + * src/lib/gnu/sun/misc/Unsafe.java, src/native/vm/sun_misc_Unsafe.c: + * src/lib/gnu/sun/misc/Unsafe.java: Updated to openjdk rev239. + + * src/native/vm/sun_misc_Unsafe.c (arrayBaseOffset): Implemented. + (arrayIndexScale): Likewise. (addressSize): Likewise. + [c5b2654c4c94] + + * src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_MaxPermSize): Added. (opt_PermSize): + Likewise. (options_xx): Check for +/- for boolean options (still + some work left). + + * src/vmcore/options.h (opt_MaxPermSize): Added. (opt_PermSize): + Likewise. + [53a39efe485c] + + * m4/classpath.m4: + * m4/classpath.m4: Added Id keyword. + [fa591512630b] + + * configure.ac, contrib/mapfile-vers-product, m4/classpath.m4, + src/cacao/Makefile.am, src/lib/Makefile.am, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, + src/lib/gnu/sun/misc/Unsafe.java, src/native/include/Makefile.am, + src/native/jni.c, src/native/jni.h, src/native/native.c, + src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h, + src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h, src/native/vm/sun/Makefile.am, + src/native/vm/sun/jvm.c, src/native/vm/sun_misc_Unsafe.c, + src/threads/native/threads.c, src/threads/threads-common.c, + src/vm/properties.c, src/vm/vm.c, src/vm/vm.h, src/vmcore/class.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/utf8.c, + src/vmcore/utf8.h: + * configure.ac, contrib/mapfile-vers-product, m4/classpath.m4, + src/cacao/Makefile.am, src/lib/Makefile.am, + src/lib/gnu/java/lang/reflect, + src/lib/gnu/java/lang/reflect/Field.java, + src/lib/gnu/java/lang/reflect/Method.java, src/lib/gnu/sun, + src/lib/gnu/sun/misc, src/lib/gnu/sun/misc/Unsafe.java, + src/native/include/Makefile.am, src/native/jni.c, src/native/jni.h, + src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Object.h, + src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Method.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h, src/native/vm/sun, + src/native/vm/sun/Makefile.am, src/native/vm/sun/jvm.c, + src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c, + src/threads/threads-common.c, src/vm/properties.c, src/vm/vm.c, + src/vm/vm.h, src/vmcore/class.h, src/vmcore/field.c, + src/vmcore/field.h, src/vmcore/utf8.c, src/vmcore/utf8.h: Initial + support for using OpenJDK libraries as Java core libraries. + [5c68a9a5b5d5] + +2007-06-22 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Fixed for 8 byte + stack slots. + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Fixed location of + method address. + [cb59a39154b8] + +2007-06-22 twisti + + * src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (opt_ThreadStackSize): Added. (options_xx): + Option and values are seperated by '=', not by ':' (let's keep + compatible to Sun). + * src/vmcore/options.h (opt_ThreadStackSize): Added. + [246c9137b7c3] + +2007-06-22 ajordan + + * src/mm/cacao-gc/gc.h, src/vm/jit/arm/arch.h, + src/vm/jit/arm/asmpart.S, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/patcher.c: + * src/mm/cacao-gc/gc.h: Added SPARC64 to the architectures that + support exactGC + + * src/vm/jit/sparc64/emit.c (emit_replacement_stubs): Added stub- + like implementation only non-trappable GC points will work. + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Added replacement + points. (codegen_emit_stub_builtin): Implemented. + + * src/vm/jit/sparc64/patcher.c (patcher_wrapper): Temp debug print, + to see when extern sfi is created. + [d1caef8d8461] + +2007-06-21 tbfg + + * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/vm.c, src/vm/vm.h: + * src/vm/jit/m68k/linux/md-abi.h: Prepared 8 byte stackslots. + * src/vm/jit/m68k/linux/md-abi.c: Likewise. + * src/vm/jit/m68k/emit.c: Likewise. + * src/vm/jit/m68k/arch.h: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/m68k/asmpart.S: Likewise. + * src/vm/jit/asmpart.h: Likewise. + * src/vm/vm.c: Likewise. + * src/vm/vm.h: Likewise. + * src/native/jni.c: Likewise. + [92d6c9308a31] + +2007-06-21 michi + + * src/native/jni.c, src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c, src/vm/vm.c, + src/vm/vm.h: + * src/vm/jit/arm/arch.h: Removed HAS_4BYTE_STACKSLOT, + ALIGN_LONGS_IN_MEMORY and ALIGN_DOUBLES_IN_MEMORY. + + * src/vm/jit/arm/md-abi.c (md_param_alloc): Changed to 8-byte + stackslots and set pd->index correctly. + + * src/vm/jit/arm/codegen.c: Changed to 8-byte stackslots (spilled + regs and arguments only). + + * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Reimplemented to + fit new argument passing. Changed to 8-byte stackslots. + + * src/vm/vm.c (vm_array_store_flt, vm_array_store_dbl) + [SUPPORT_PASS_FLOATARGS_IN_INTREGS]: Fixed. + + * src/vm/vm.c: Added ARM ifdefs. + * src/vm/vm.h: Added ARM ifdefs. + * src/native/jni.c: Added ARM ifdefs. + [039c70e75777] + +2007-06-21 twisti + + * configure.ac: + * configure.ac (AC_CHECK_FUNCS): Added gethostname. + [c4fdd1a8ed28] + + * configure.ac, src/cacaoh/cacaoh.c, src/cacaoh/headers.c, + src/native/include/Makefile.am, src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/asmpart.h, src/vm/jit/i386/emit.c, src/vm/jit/i386/md- + abi.c, src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/md-abi.c, + src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/tools/genoffsets.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c, + src/vm/resolve.c, src/vm/string.c, src/vmcore/descriptor.c, + src/vmcore/descriptor.h, src/vmcore/linker.h, src/vmcore/method.c, + src/vmcore/method.h, src/vmcore/options.c, src/vmcore/options.h, + src/vmcore/statistics.c, src/vmcore/statistics.h, src/vmcore/utf8.c, + src/vmcore/utf8.h, tests/regression/native/testarguments.c, + tests/regression/native/testarguments.java: + * configure.ac (AC_CHECK_HEADERS): Added sys/socket.h. + (AC_CHECK_FUNCS): Added accept, close, connect, getsockname, listen, + setsockopt, shutdown, socket. + [80f35ffa2a7b] + +2007-06-21 michi + + * src/mm/cacao-gc/heap.h: + * src/mm/cacao-gc/heap.h: Fixed includes. + [52beee5c1394] + +2007-06-20 michi + + * configure.ac, src/cacaoh/cacaoh.c, src/cacaoh/dummy.c, + src/cacaoh/headers.c, src/mm/memory.c, + src/native/include/Makefile.am, src/native/jni.c, + src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/gnu/Makefile.am, src/native/vm/gnu/gnu_java_lang_manag + ement_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h, + src/native/vm/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_util_concurrent_atomic_AtomicLong.h, + src/native/vm/nativevm.c, src/native/vm/nativevm.h, + src/native/vm/sun_misc_Unsafe.c, src/threads/native/threads.c, + src/threads/threads-common.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/global.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md- + abi.c, src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, src/vm/jit + /emit-common.c, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/md-abi.c, src/vm/jit/jit.h, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/disass.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/md.c, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin + /md-abi.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/powerpc/netbsd/md-abi.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-abi.c, + src/vm/jit/replace.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/dacapo.status, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md-abi.h, src/vm/jit/tools/genoffsets.c, + src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify + /typecheck-stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c, + src/vm/resolve.c, src/vm/string.c, src/vm/vm.c, src/vm/vm.h, + src/vmcore/Makefile.am, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/descriptor.c, src/vmcore/descriptor.h, + src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/primitive.c, + src/vmcore/primitive.h, src/vmcore/statistics.c, + src/vmcore/statistics.h, src/vmcore/utf8.c, src/vmcore/utf8.h, + tests/regression/native/testarguments.c, + tests/regression/native/testarguments.java, + tests/regression/native/testarguments.output: + Merged revisions 8056-8122 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8058 | twisti | 2007-06-10 21:30:25 +0200 (Sun, 10 Jun + 2007) | 2 lines + + * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Indent. + ........ r8059 | twisti | 2007-06-10 21:31:28 +0200 (Sun, 10 Jun + 2007) | 4 lines + + * src/vm/vm.c (vm_vmargs_from_valist): Use TYPE_-defines instead + of PRIMITIVETYPE_ ones. (vm_vmargs_from_jvalue): Likewise. + ........ r8060 | twisti | 2007-06-10 22:00:40 +0200 (Sun, 10 Jun + 2007) | 48 lines + + * src/vm/global.h (PRIMITIVETYPE_*): Removed. (ARRAYTYPE_*): + Likewise. + + * src/vm/jit/verify/typecheck-typeinferer.c (vmcore/primitive.h): + Added. + * src/vm/jit/verify/typecheck.c: Likewise. + * src/vm/jit/verify/typecheck-stackbased.c: Likewise. + * src/vm/jit/verify/typeinfo.c: Likewise. + * src/vm/builtin.c: Likewise. + * src/native/jni.c: Likewise. + * src/native/vm/gnu/java_lang_VMClassLoader.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. + * src/vmcore/descriptor.c: Likewise. + + * src/vm/string.c (vmcore/primitive.h): Added. + (stringtable_update): Use new primitive functions. + + * src/vm/resolve.c: Likewise. (resolve_class_from_typedesc): Use + new primitive functions. + + * src/vm/vm.c (vmcore/primitive.h): Added. (vm_create): Call + primitive_init. + + * src/native/vm/java_lang_Class.c (vmcore/primitive.h): Added. + (isPrimitive): Use primitive_class_is_primitive. + (getDeclaringClass): Likewise. (getDeclaredClasses): Likewise. + (getComponentType): Use primitive_class_get_by_type. + + * src/vmcore/class.c (class_is_primitive): Removed. + (class_primitive_get): Removed. + * src/vmcore/class.c: Likewise. + + * src/vmcore/primitive.c: New file. + * src/vmcore/primitive.h: Likewise. + + * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added + primitive.[ch]. + + * src/vmcore/linker.c (vmcore/primitive.h): Added. + (primitivetype_table): Removed. (linker_init): Removed + link_primitivetype_table call. (link_primitivetype_table): + Removed. + + * src/vmcore/linker.h (primitivetypeinfo): Removed. + (primitivetype_table): Removed. + + * src/vm/jit/verify/typecheck-builtins.inc: Removed Contact, + Authors from header. ........ r8061 | twisti | 2007-06-11 + 09:59:36 +0200 (Mon, 11 Jun 2007) | 3 lines + + * src/vmcore/primitive.c (primitive_class_get_by_char): New + function. + * src/vmcore/primitive.h (primitive_class_get_by_char): Added. + ........ r8062 | twisti | 2007-06-11 10:12:14 +0200 (Mon, 11 Jun + 2007) | 59 lines + + * src/vm/resolve.c (resolve_class_from_name): Call + exceptions_classnotfoundexception_to_noclassdeffounderror in + exception case. + + * src/vm/exceptions.c (vmcore/method.h): Added. + (exceptions_throw_utf_throwable): Added object-initialize code. + (exceptions_throw_utf_exception): Likewise. + (exceptions_throw_noclassdeffounderror_cause): New function. + (classnotfoundexception_to_noclassdeffounderror): Renamed to + exceptions_classnotfoundexception_to_noclassdeffounderror. + (exceptions_print_stacktrace): Don't use exceptionptr directly. + + * src/vm/exceptions.h + (exceptions_throw_noclassdeffounderror_cause): Added. + (classnotfoundexception_to_noclassdeffounderror): Renamed to + exceptions_classnotfoundexception_to_noclassdeffounderror. + + * src/vm/vm.c (opts): Added XX:. (vm_create): Likewise. + (vm_run): Call exceptions_throw_noclassdeffounderror_cause when + main-class is not found. + + * src/native/vm/java_lang_Class.c (forName): Don't convert + exception. + + * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass): + Use primitive_class_get_by_char. (loadClass): Don't convert + exception. + + * src/native/native.c (native_new_and_init_string): Use + class_findmethod instead of class_resolveclassmethod. + (native_new_and_init_throwable): Removed. + (native_new_and_init_exception): Likewise. + + * src/native/native.h (native_new_and_init_throwable): Removed. + (native_new_and_init_exception): Likewise. + + * src/vmcore/class.c (class_array_of): Smaller code changes. + + * src/vmcore/loader.c (vmcore/primitive.h): Added. + (load_class_from_classloader): Don't convert exception. + (load_class_bootstrap): Throw ClassNotFoundException instead of + NoClassDefFoundError. (load_newly_created_array): Likewise, check + if primitive-array type is valid. + + * src/vmcore/utf8.c (utf_initCause): Added. + (utf_java_lang_Throwable__java_lang_Throwable): Likewise. + (utf8_init): Initialize new variables. + + * src/vmcore/utf8.h (utf_initCause): Added. + (utf_java_lang_Throwable__java_lang_Throwable): Likewise. + + * src/cacaoh/dummy.c (exceptions_throw_classnotfoundexception): + New function. (classnotfoundexception_to_noclassdeffounderror): + Removed. + + * src/vmcore/options.c (options_xx): New function. + * src/vmcore/options.h (options_xx): Added. ........ r8063 | twisti + | 2007-06-11 16:44:58 +0200 (Mon, 11 Jun 2007) | 6 lines + + * src/vmcore/method.c (method_returntype_get): New function. + * src/vmcore/method.h (method_returntype_get): Added. + + * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType): + Use method_returntype_get. ........ r8064 | twisti | 2007-06-11 + 17:11:01 +0200 (Mon, 11 Jun 2007) | 11 lines + + * src/native/vm/java_lang_reflect_Method.c: New file. + * src/native/vm/java_lang_reflect_Method.h: Likewise. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (JAVA_LANG_REFLECT_METHOD_SOURCES): Added + (libnativevm_la_SOURCES): Added JAVA_LANG_REFLECT_METHOD_SOURCES. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (native/vm/java_lang_reflect_Method.h): Added. (invokeNative): Use + _Jv_java_lang_reflect_Method_invoke. ........ r8065 | pm | + 2007-06-11 17:22:09 +0200 (Mon, 11 Jun 2007) | 3 lines + + * src/vm/jit/s390/emit.c (emit_load_s1_notzero, + emit_load_s2_notzero, emit_load_s1_but, emit_load_s2_but): Correctly + handle float regissters. + * src/vm/jit/s390/tests/dacapo.status: Include dacapo lusearch + results. ........ r8066 | twisti | 2007-06-12 11:08:12 +0200 (Tue, + 12 Jun 2007) | 4 lines + + * src/vm/vm.c (opts): Added OPT_EA, OPT_DA. (usage): Print help + for OPT_EA, OPT_DA. (vm_create): Ignore OPT_EA, OPT_DA. ........ + r8067 | twisti | 2007-06-12 14:32:18 +0200 (Tue, 12 Jun 2007) | 4 + lines + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Added asserts for declaringClass and slot. + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): + Likewise. ........ r8068 | pm | 2007-06-12 17:50:35 +0200 (Tue, 12 + Jun 2007) | 5 lines + + * src/vm/jits/390/codegen.h (N_BRC_BACK_PATCH, N_LTEBR, N_LTDBR, + N_LTXBR, DD_0, ..., DD_3): added, (M_CVTFI, M_CVTDI) changed to + round to nearest. + * src/vm/jits/390/codegen.c (codegen_emit): In ICMD_F2I and ICMD_D2I + correct handling of corner cases, ICMD_LALOAD fix. + * src/vm/jit/s390/md.c (md_dump_context): Include information on java + method in dump. + * src/vm/jits/390/tests/dacapo.status: Noted dacapo eclipse results. + ........ r8069 | twisti | 2007-06-13 16:08:24 +0200 (Wed, 13 Jun + 2007) | 4 lines + + * src/native/jni.c (stdint.h): Added. + (_Jv_jni_vmargs_from_objectarray): Use stdint-types, use global + class variables. ........ r8070 | twisti | 2007-06-13 16:26:41 + +0200 (Wed, 13 Jun 2007) | 16 lines + + * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Removed. + (_Jv_jni_invokeNative): Use vm_vmargs_from_objectarray. + + * src/vm/vm.c (stdint.h): Added. + (native/include/java_lang_Byte.h) + (native/include/java_lang_Character.h) + (native/include/java_lang_Short.h) + (native/include/java_lang_Integer.h) + (native/include/java_lang_Boolean.h) + (native/include/java_lang_Long.h) + (native/include/java_lang_Float.h) + (native/include/java_lang_Double.h): Likewise. + (vm_vmargs_from_objectarray): New function. + + * src/vm/vm.h (vm_vmargs_from_objectarray): Added. ........ + r8071 | twisti | 2007-06-13 19:37:55 +0200 (Wed, 13 Jun 2007) | 3 + lines + + * src/vm/jit/tools/genoffsets.c (main): Removed some obsolete + stuff. + * src/vm/jit/m68k/md.c (md_init): Removed offobjvftbl check. ........ + r8072 | twisti | 2007-06-13 20:31:19 +0200 (Wed, 13 Jun 2007) | 4 + lines + + * tests/regression/native/testarguments.java, + tests/regression/native/testarguments.c, + tests/regression/native/testarguments.output: Added address test. + ........ r8073 | twisti | 2007-06-13 23:54:27 +0200 (Wed, 13 Jun + 2007) | 4 lines + + * src/vm/jit/tools/genoffsets.c (vmcore/class.h): Removed. + (vmcore/linker.h): Likewise. (vmcore/method.h): Likewise. ........ + r8074 | twisti | 2007-06-14 00:27:17 +0200 (Thu, 14 Jun 2007) | 43 + lines + + * src/vm/jit/mips/asmpart.S (asm_vm_call_method): Rewritten for + new argument passing. + + * src/vm/jit/mips/md-abi.c (stdarg.h): Added. (mm/memory.h): + Likewise. (md_param_alloc): Set pd->index. + + * src/vm/jit/asmpart.h (stdint.h): Added new function prototypes. + + * src/vm/vm.c (md-abi.h): Added. (vm_array_store_int): New + function. (vm_array_store_lng): Likewise. (vm_array_store_flt): + Likewise. (vm_array_store_dbl): Likewise. (vm_array_store_adr): + Likewise. (vm_array_from_valist): Likewise. + (vm_array_from_jvalue): Likewise. (vm_array_from_objectarray): + Likewise. (vm_call_method_valist): New version added. + (vm_call_method_jvalue): Likewise. (vm_call_array): New function. + (vm_call_int_array): Likewise. (vm_call_method_int_valist): New + version added. (vm_call_method_int_jvalue): Likewise. + (vm_call_method_long_valist): Likewise. + (vm_call_method_long_jvalue): Likewise. (vm_call_long_array): New + function. (vm_call_method_float_vmarg): Added vm_abort. + (vm_call_method_double_vmarg): Likwise. + + * src/vm/vm.h (stdarg.h): Added. (vmcore/class.h): Likewise. + (vmcore/method.h): Likewise. (vm_array_from_objectarray): + Likewise. (vm_call_array): Likewise. (vm_call_int_array): + Likewise. (vm_call_long_array): Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Added new version. + + * src/vmcore/descriptor.h (stdint.h): Added. (paramdesc): Added + index field (this is temporarily). ........ r8075 | twisti | + 2007-06-14 02:38:53 +0200 (Thu, 14 Jun 2007) | 3 lines + + * src/vm/jit/mips/asmpart.S (asm_vm_call_method) + [!WORDS_BIGENDIAN]: Fixed bug (use lw instead of ld), better code + in the stack copy loop. ........ r8076 | twisti | 2007-06-14 + 11:35:31 +0200 (Thu, 14 Jun 2007) | 2 lines + + * src/vm/vm.c: Fixed typos. ........ r8077 | twisti | 2007-06-14 + 11:44:12 +0200 (Thu, 14 Jun 2007) | 8 lines + + * src/vm/vm.c (arch.h): Added. (vm/jit/abi-asm.h): Likewise. + (vm_array_store_int): Use ARG_CNT define. (vm_array_store_dbl): + Likewise. (vm_array_store_flt): Likewise. (vm_array_store_dbl): + Likewise. (vm_array_store_adr) [HAS_ADDRESS_REGISTER_FILE]: + Changed offset. ........ r8078 | twisti | 2007-06-14 12:20:02 + +0200 (Thu, 14 Jun 2007) | 2 lines + + * src/vm/vm.c (vm_call_method_long_vmarg): Removed vm_abort. + ........ r8079 | twisti | 2007-06-14 13:06:48 +0200 (Thu, 14 Jun + 2007) | 3 lines + + * src/vm/vm.c (vm_array_from_objectarray): For TYPE_ADR param can + be NULL, that's ok (jboss is a testcase for that). ........ + r8080 | twisti | 2007-06-14 13:12:11 +0200 (Thu, 14 Jun 2007) | 10 + lines + + * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Rewritten for + new argument passing. + + * src/vm/jit/x86_64/md-abi.c (md_param_alloc): Set pd->index. + + * src/vm/vm.c: Added __X86_64__ ifdef. + * src/vm/vm.h: Likewise. + * src/native/jni.c: Likewise. + * src/vm/jit/asmpart.h: Likewise. ........ r8081 | tbfg | 2007-06-14 + 14:07:03 +0200 (Thu, 14 Jun 2007) | 4 lines + + src/vm/jit/m68k/disass.c: Changed bfd_mach_mcf_isa_b_float_emac to + bfd_mach_mcfv4e as needed for newer binutils. ........ r8082 | + tbfg | 2007-06-14 14:10:49 +0200 (Thu, 14 Jun 2007) | 6 lines + + * src/vm/jit/emit-common.c: Added emit_branch statistics. + * src/vmcore/statistics.c: Likewise. + * src/vmcore/statistics.h: Added count_emit_branch, + count_emit_branch_8bit, count_emit_branch_16bit, + count_emit_branch_32bit, count_emit_branch_64bit. ........ r8085 | + tbfg | 2007-06-14 17:12:54 +0200 (Thu, 14 Jun 2007) | 2 lines + + * src/vm/jit/emit-common.c: Fixed warning related to STATISTICS. + ........ r8086 | twisti | 2007-06-14 17:31:54 +0200 (Thu, 14 Jun + 2007) | 3 lines + + * src/vmcore/loader.c: Removed commented + exceptions_throw_noclassdeffounderror calls. ........ r8087 | + twisti | 2007-06-14 18:01:12 +0200 (Thu, 14 Jun 2007) | 6 lines + + * src/vm/exceptions.c (exceptions_get_exception) + (exceptions_set_exception, exceptions_clear_exception) + (exceptions_get_and_clear_exception): Moved these low leve function + to the top of the file. + * src/vm/exceptions.h: Likewise. ........ r8088 | twisti | + 2007-06-14 18:05:42 +0200 (Thu, 14 Jun 2007) | 2 lines + + * src/native/vm/java_lang_Class.c (forName): Removed unused + variables. ........ r8089 | twisti | 2007-06-14 18:06:31 +0200 + (Thu, 14 Jun 2007) | 2 lines + + * src/native/vm/java_lang_Class.c: Added Id keyword. ........ + r8090 | twisti | 2007-06-14 18:07:37 +0200 (Thu, 14 Jun 2007) | 3 + lines + + * src/vm/exceptions.c: Don't use exceptionptr directly anymore, + access it only with functions. ........ r8091 | twisti | + 2007-06-14 18:10:33 +0200 (Thu, 14 Jun 2007) | 3 lines + + * src/threads/native/threads.c: Don't use exceptionptr directly + anymore. ........ r8092 | twisti | 2007-06-14 18:12:35 +0200 (Thu, + 14 Jun 2007) | 3 lines + + * src/native/native.c (native_findfunction): Use + exceptions_throw_unsatisfiedlinkerror. ........ r8093 | twisti | + 2007-06-14 18:51:44 +0200 (Thu, 14 Jun 2007) | 5 lines + + * src/vm/jit/emit-common.c (emit_bccz) [STATISTICS]: Is called + ENABLE_STATISTICS. (emit_label_bccz): Likewise. (emit_label): + Likewise. ........ r8094 | ajordan | 2007-06-16 03:15:41 +0200 + (Sat, 16 Jun 2007) | 15 lines + + * src/vmcore/statistics.h: Added more fine grained spill + statistics. + * src/vmcore/statistics.c: Likewise. + + * src/vm/jit/jit.h: New defines for spill statistics. Old ones are + deprecated, won't increase the counters. + + * src/vm/jit/codegen-common.c (codegen_increase): Defined SPARC64 + for 2-instr-patcher-stub-call workaround. + (codegen_add_patch_ref): Likewise. (codegen_reg_of_var): Removed + obsolete spill counting. + + * src/vm/jit/sparc64/emit.c: Changed for new spill statistics. + * src/vm/jit/sparc64/linux/md-os.c (md_critical_section_restart): + Fixed. ........ r8095 | ajordan | 2007-06-16 21:56:19 +0200 (Sat, + 16 Jun 2007) | 6 lines + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Improved integer + argument passing by swapping variable allocation instead of + copying. + + * src/vm/jit/sparc64/md-abi.h: Turned %i0 into saved reg. + * src/vm/jit/sparc64/md-abi.c: Likewise. ........ r8096 | pm | + 2007-06-17 15:45:58 +0200 (Sun, 17 Jun 2007) | 8 lines + + * src/vm/jit/s390/asmpart.S src/vm/jit/s390/codegen.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/dacapo.status: Optimized loads from data + segment: the procedure vector now always points 4092 bytes before + the data segment, so a lot of loads have a positive displacement. + Removed dead code. ........ r8097 | pm | 2007-06-17 16:50:16 +0200 + (Sun, 17 Jun 2007) | 3 lines + + * src/vm/jit/s390/codegen.c (codegen_emit): More data segment load + optimalisations. + * src/vm/jit/s390/md.c (md_get_method_patch_address): Adapt to changes + in codegen_emit. ........ r8099 | tbfg | 2007-06-18 20:26:58 +0200 + (Mon, 18 Jun 2007) | 20 lines + + * src/vm/jit/powerpc64/linux/md-abi.c (md_param_alloc): Set index. + + * src/vm/jit/powerpc64/asmpart.S (asm_vm_call_method): New + parameter format, do not call asm_jit_compile any more. + + * src/vm/jit/asmpart.h: Enable new parameter format function + prototypes. + + * src/vm/vm.h: Likewise. + + * src/vm/vm.c (vm_array_store_int): Although ppc64 is big endian + do not big endianize the new parameter format. + (vm_array_store_flt): Likewise. (vm_array_store_adr): Likewise. + (vm_vmargs_from_valist): ppc64 like alpha uses doubles everywhere. + (vm_vmargs_from_jvalue): When HAS_ADDRESS_REGISTER_FILE is defined + address register arguments are between float and memuse. + + * src/native/jni.c: Enable new parameter function calling. + ........ r8100 | twisti | 2007-06-18 22:18:14 +0200 (Mon, 18 Jun + 2007) | 7 lines + + * src/vm/exceptions.c (exceptions_throw_utf_throwable): Call + (Ljava/lang/Throwable;)V initializer and resolve the method with + class_resolveclassmethod to get possible exceptions. + (exceptions_throw_utf_cause): New function. + (exceptions_throw_noclassdeffounderror_cause): Use + exceptions_throw_utf_cause. ........ r8101 | twisti | 2007-06-19 + 20:07:59 +0200 (Tue, 19 Jun 2007) | 4 lines + + * src/cacaoh/dummy.c [ENABLE_THREADS] (pthread.h): Removed. + (threads/threads-common.h): Added. [ENABLE_THREADS] + (threads_current_threadobject_key): Added #ifdef. ........ r8102 | + twisti | 2007-06-19 20:09:16 +0200 (Tue, 19 Jun 2007) | 2 lines + + * src/cacaoh/dummy.c: Added Id keyword. ........ r8103 | twisti + | 2007-06-19 21:43:00 +0200 (Tue, 19 Jun 2007) | 21 lines + + * src/native/vm/nativevm.c (nativevm_init) [ENABLE_JAVASE && + WITH_CLASSPATH_GNU]: Call + _Jv_java_util_concurrent_atomic_AtomicLong_init. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES): Added. + (libnativevm_la_SOURCES): Added + JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES. + + * src/native/vm/java_util_concurrent_atomic_AtomicLong.c: New + file. + * src/native/vm/java_util_concurrent_atomic_AtomicLong.h: Likewise. + + * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): + Added java_util_concurrent_atomic_AtomicLong.c. + + * src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c: New + file. + + * src/native/include/Makefile.am (JAVASE_HEADER_FILES): Added + java_util_concurrent_atomic_AtomicLong.h. ........ r8104 | twisti + | 2007-06-19 23:15:00 +0200 (Tue, 19 Jun 2007) | 5 lines + + * src/cacaoh/dummy.c (stdint.h): Added. (vm/types.h): Removed + and replaced all old types with stdint ones. (threads/threads- + common.h): Removed. [ENABLE_THREADS] + (threads_current_threadobject_key): Removed. ........ r8105 | + twisti | 2007-06-19 23:47:51 +0200 (Tue, 19 Jun 2007) | 3 lines + + * src/cacaoh/headers.c (stdint.h): Added and use stdint-types. + (vm/types.h): Removed. ........ r8106 | twisti | 2007-06-20 + 00:50:17 +0200 (Wed, 20 Jun 2007) | 11 lines + + * src/vm/vm.c (vm_call_float_array): New function. + (vm_call_method_float_valist): Likewise. + (vm_call_method_float_jvalue): Likewise. (vm_call_double_array): + Likewise. (vm_call_method_double_valist): Likewise. + (vm_call_method_double_jvalue): Likewise. + + * src/vm/vm.h: Defined new functions. + * src/vm/jit/asmpart.h: Likewise. + * src/native/jni.c: Use new functions. ........ r8107 | twisti | + 2007-06-20 13:11:59 +0200 (Wed, 20 Jun 2007) | 3 lines + + * src/vm/vm.c (vm_array_store_int) [SIZEOF_VOID_P == 4]: Only do + the integer shift on 32-bit architectures. ........ r8108 | + ajordan | 2007-06-20 14:05:26 +0200 (Wed, 20 Jun 2007) | 11 lines + + * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added pd->index + setting. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Get + parameters from new array. + + * src/vm/jit/asmpart.h: Enable new parameter passing for SPARC64. + * src/vm/vm.h: Likewise. + * src/vm/vm.c: Likewise. (vm_array_store_flt): For SPARC, shift + float arguments on stack to low word too. ........ r8109 | twisti + | 2007-06-20 14:22:56 +0200 (Wed, 20 Jun 2007) | 3 lines + + * src/native/vm/nativevm.h [ENABLE_JAVASE && WITH_CLASSPATH_GNU]: + Added _Jv_java_util_concurrent_atomic_AtomicLong_init. ........ + r8110 | twisti | 2007-06-20 14:24:32 +0200 (Wed, 20 Jun 2007) | 3 + lines + + * src/cacaoh/cacaoh.c (HEAP_MAXSIZE, HEAP_STARTSIZE): Removed. + (main): Removed heapmaxsize, heapstartsize. ........ r8111 | + twisti | 2007-06-20 15:51:38 +0200 (Wed, 20 Jun 2007) | 10 lines + + * src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanI + mpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/sun_misc_Unsafe.c: Use stdint-types because of + conflicts with generated header files. ........ r8112 | twisti | + 2007-06-20 19:54:36 +0200 (Wed, 20 Jun 2007) | 28 lines + + * src/vm/vm.c (XXusage): Removed -verbose:memory. (vm_create): + Likewise. + + * src/mm/memory.c (memory_thread): Rewritten to use new variables. + + * src/vmcore/options.c (errno.h): Added. (stdint.h): Likewise + (stdio.h): Likewise. (stdlib.h): Likewise. (opt_verbosememory): + Removed. (opt_ProfileGCMemoryUsage): Added. + (opt_ProfileMemoryUsage): Likewise. + (opt_ProfileMemoryUsageGNUPlot): Likewise. (options_XX): Likewise. + (options_xx): Implemented. + + * src/vmcore/options.h (stdint.h): Added. (option_t): Likewise. + (opt_ProfileGCMemoryUsage): Likewise. (opt_ProfileMemoryUsage): + Likewise. (opt_ProfileMemoryUsageGNUPlot): Likewise. + (options_xx): Changed signature. + + * src/vmcore/statistics.c (statistics_print_gc_memory_usage): + Rewritten to use new variables and GNU Plot output. + + * configure.ac (AC_CHECK_FUNCS): Added atoi, atol, strchr, + strncmp. ........ r8113 | twisti | 2007-06-20 20:05:39 +0200 (Wed, + 20 Jun 2007) | 5 lines + + * src/vmcore/statistics.c (statistics_print_gc_memory_usage): Call + fflush. + + * configure.ac (AC_CHECK_FUNCS): Added fflush, fopen, fprintf. + ........ r8114 | twisti | 2007-06-20 20:57:41 +0200 (Wed, 20 Jun + 2007) | 3 lines + + * src/threads/threads-common.c (threads_preinit): Added another + linuxthreads check. ........ r8115 | michi | 2007-06-20 21:14:05 + +0200 (Wed, 20 Jun 2007) | 41 lines + + * src/vm/vm.c (vm_array_store_int, vm_array_store_adr, + vm_array_store_lng, vm_array_store_flt, vm_array_store_dbl): Uses + pd->index for inmemory arguments. + + * src/vm/jit/allocator/simplereg.c: The regoff value is a real + offset (multiplied by the stackslot size) for inmemory variables + now. + + * src/vm/jit/arm/md-abi.c (md_param_alloc): Set pd->regoff as + described above. + * src/vm/jit/arm/emit.c: Adapted to above changes. + * src/vm/jit/arm/codegen.c: Adapted to above changes. + + * src/vm/jit/powerpc/linux/md-abi.c, + * src/vm/jit/powerpc/netbsd/md-abi.c, + * src/vm/jit/powerpc/emit.c, + * src/vm/jit/powerpc/darwin/md-abi.c, + * src/vm/jit/powerpc/codegen.c, + * src/vm/jit/sparc64/emit.c, + * src/vm/jit/sparc64/md-abi.h, + * src/vm/jit/sparc64/codegen.c, + * src/vm/jit/sparc64/md-abi.c, + * src/vm/jit/alpha/emit.c, + * src/vm/jit/alpha/codegen.c, + * src/vm/jit/alpha/md-abi.c, + * src/vm/jit/s390/emit.c, + * src/vm/jit/s390/codegen.c, + * src/vm/jit/s390/md-abi.c, + * src/vm/jit/mips/emit.c, + * src/vm/jit/mips/codegen.c, + * src/vm/jit/mips/md-abi.c, + * src/vm/jit/m68k/emit.c, + * src/vm/jit/m68k/linux/md-abi.c, + * src/vm/jit/m68k/codegen.c, + * src/vm/jit/powerpc64/linux/md-abi.c, + * src/vm/jit/powerpc64/emit.c, + * src/vm/jit/powerpc64/codegen.c, + * src/vm/jit/i386/emit.c, + * src/vm/jit/i386/codegen.c, + * src/vm/jit/i386/md-abi.c, + * src/vm/jit/x86_64/emit.c, + * src/vm/jit/x86_64/codegen.c, + * src/vm/jit/x86_64/md-abi.c: Likewise. ........ r8116 | michi | + 2007-06-20 22:30:56 +0200 (Wed, 20 Jun 2007) | 5 lines + + * src/vm/jit/arm/codegen.c (codegen_emit, + codegen_emit_stub_native): Changed cd->stackframesize from + wordcount to bytecount. + + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Adapted to above + change. ........ r8117 | pm | 2007-06-20 23:20:53 +0200 (Wed, 20 + Jun 2007) | 3 lines + + * src/vm/jit/s390/codegen.h, src/vm/jit/s390/codegen.c + (codegen_emit): Support another hercules bug in F2D. ........ + r8119 | twisti | 2007-06-21 00:05:10 +0200 (Thu, 21 Jun 2007) | 3 + lines + + * src/vmcore/statistics.c (statistics_print_gc_memory_usage): + Different print-format for different pointer-sizes. ........ r8120 + | twisti | 2007-06-21 00:11:24 +0200 (Thu, 21 Jun 2007) | 13 lines + + * src/vmcore/options.c (opt_verboseexception): Removed. + (opt_TraceExceptions): Added. (options_xx): Handle + OPT_TraceExceptions. + + * src/vmcore/options.h (opt_verboseexception): Removed. + (opt_TraceExceptions): Added. + + * src/vm/exceptions.c (exceptions_handle_exception): Replaced + opt_verboseexception with opt_TraceExceptions. + + * src/vm/vm.c (XXusage): Removed opt_verboseexception. + (vm_create): Likewise. ........ r8121 | michi | 2007-06-21 + 01:32:34 +0200 (Thu, 21 Jun 2007) | 7 lines + + * src/vmcore/options.c [ENABLE_REPLACEMENT] + (opt_TraceReplacement): Added. (options_xx) [ENABLE_REPLACEMENT]: + Handle OPT_TraceReplacement. + + * src/vmcore/options.h [ENABLE_REPLACEMENT] + (opt_TraceReplacement): Added. + + * src/vm/jit/replace.c: Use opt_TraceReplacement mentioned above. + ........ + [5a4d93ab7f2c] + + * tests/gc/ClassInit.java: + * tests/gc/ClassInit.java: Changed trigger for static initializer + from method call to field access. + [5d0cef9e0809] + + * src/vm/jit/replace.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c [ENABLE_REPLACEMENT] (opt_TraceReplacement): + Added. (options_xx) [ENABLE_REPLACEMENT]: Handle + OPT_TraceReplacement. + + * src/vmcore/options.h [ENABLE_REPLACEMENT] (opt_TraceReplacement): + Added. + + * src/vm/jit/replace.c: Use opt_TraceReplacement mentioned above. + [0574b7bc889f] + +2007-06-20 twisti + + * src/vm/exceptions.c, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vmcore/options.c (opt_verboseexception): Removed. + (opt_TraceExceptions): Added. (options_xx): Handle + OPT_TraceExceptions. + + * src/vmcore/options.h (opt_verboseexception): Removed. + (opt_TraceExceptions): Added. + + * src/vm/exceptions.c (exceptions_handle_exception): Replaced + opt_verboseexception with opt_TraceExceptions. + + * src/vm/vm.c (XXusage): Removed opt_verboseexception. (vm_create): + Likewise. + [3f0c7cb2010b] + + * src/vmcore/statistics.c: + * src/vmcore/statistics.c (statistics_print_gc_memory_usage): + Different print-format for different pointer-sizes. + [141899315be7] + +2007-06-20 michi + + * src/cacaoh/headers.c, src/mm/cacao-gc/gc.c, + src/native/include/Makefile.am, src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h, src/native/vm/sun_misc_Unsafe.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c, src/vm/jit/arm + /md-abi.c, src/vm/jit/i386/emit.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/darwin/md-abi.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-abi.c, + src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/emit.c: + * src/mm/cacao-gc/gc.c (gc_reference_unregister): Added. + [7d6280a0a94a] + +2007-06-20 pm + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h: + * src/vm/jit/s390/codegen.h, src/vm/jit/s390/codegen.c + (codegen_emit): Support another hercules bug in F2D. + [ffd633a37b0f] + +2007-06-20 michi + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c: + * src/vm/jit/arm/codegen.c (codegen_emit, codegen_emit_stub_native): + Changed cd->stackframesize from wordcount to bytecount. + + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Adapted to above + change. + [8456c270e754] + + * src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md- + abi.c, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/md-abi.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin + /md-abi.c, src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/powerpc/netbsd/md-abi.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c, src/vm/vm.c: + * src/vm/vm.c (vm_array_store_int, vm_array_store_adr, + vm_array_store_lng, vm_array_store_flt, vm_array_store_dbl): Uses + pd->index for inmemory arguments. + + * src/vm/jit/allocator/simplereg.c: The regoff value is a real + offset (multiplied by the stackslot size) for inmemory variables + now. + + * src/vm/jit/arm/md-abi.c (md_param_alloc): Set pd->regoff as + described above. + * src/vm/jit/arm/emit.c: Adapted to above changes. + * src/vm/jit/arm/codegen.c: Adapted to above changes. + + * src/vm/jit/powerpc/linux/md-abi.c, + * src/vm/jit/powerpc/netbsd/md-abi.c, + * src/vm/jit/powerpc/emit.c, + * src/vm/jit/powerpc/darwin/md-abi.c, + * src/vm/jit/powerpc/codegen.c, + * src/vm/jit/sparc64/emit.c, + * src/vm/jit/sparc64/md-abi.h, + * src/vm/jit/sparc64/codegen.c, + * src/vm/jit/sparc64/md-abi.c, + * src/vm/jit/alpha/emit.c, + * src/vm/jit/alpha/codegen.c, + * src/vm/jit/alpha/md-abi.c, + * src/vm/jit/s390/emit.c, + * src/vm/jit/s390/codegen.c, + * src/vm/jit/s390/md-abi.c, + * src/vm/jit/mips/emit.c, + * src/vm/jit/mips/codegen.c, + * src/vm/jit/mips/md-abi.c, + * src/vm/jit/m68k/emit.c, + * src/vm/jit/m68k/linux/md-abi.c, + * src/vm/jit/m68k/codegen.c, + * src/vm/jit/powerpc64/linux/md-abi.c, + * src/vm/jit/powerpc64/emit.c, + * src/vm/jit/powerpc64/codegen.c, + * src/vm/jit/i386/emit.c, + * src/vm/jit/i386/codegen.c, + * src/vm/jit/i386/md-abi.c, + * src/vm/jit/x86_64/emit.c, + * src/vm/jit/x86_64/codegen.c, + * src/vm/jit/x86_64/md-abi.c: Likewise. + [41d0774d6ee9] + +2007-06-20 twisti + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_preinit): Added another + linuxthreads check. + [a183143f5c1a] + + * configure.ac, src/vmcore/statistics.c: + * src/vmcore/statistics.c (statistics_print_gc_memory_usage): Call + fflush. + + * configure.ac (AC_CHECK_FUNCS): Added fflush, fopen, fprintf. + [73c72b5efd77] + + * configure.ac, src/mm/memory.c, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/statistics.c: + * src/vm/vm.c (XXusage): Removed -verbose:memory. (vm_create): + Likewise. + + * src/mm/memory.c (memory_thread): Rewritten to use new variables. + + * src/vmcore/options.c (errno.h): Added. (stdint.h): Likewise + (stdio.h): Likewise. (stdlib.h): Likewise. (opt_verbosememory): + Removed. (opt_ProfileGCMemoryUsage): Added. + (opt_ProfileMemoryUsage): Likewise. (opt_ProfileMemoryUsageGNUPlot): + Likewise. (options_XX): Likewise. (options_xx): Implemented. + + * src/vmcore/options.h (stdint.h): Added. (option_t): Likewise. + (opt_ProfileGCMemoryUsage): Likewise. (opt_ProfileMemoryUsage): + Likewise. (opt_ProfileMemoryUsageGNUPlot): Likewise. (options_xx): + Changed signature. + + * src/vmcore/statistics.c (statistics_print_gc_memory_usage): + Rewritten to use new variables and GNU Plot output. + + * configure.ac (AC_CHECK_FUNCS): Added atoi, atol, strchr, strncmp. + [8aa5208d23bd] + + * src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl. + c, src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImp + l.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/sun_misc_Unsafe.c: Use stdint-types because of + conflicts with generated header files. + [d0c0f1a0f680] + + * src/cacaoh/cacaoh.c: + * src/cacaoh/cacaoh.c (HEAP_MAXSIZE, HEAP_STARTSIZE): Removed. + (main): Removed heapmaxsize, heapstartsize. + [c8bedeb53fee] + + * src/native/vm/nativevm.h: + * src/native/vm/nativevm.h [ENABLE_JAVASE && WITH_CLASSPATH_GNU]: + Added _Jv_java_util_concurrent_atomic_AtomicLong_init. + [7bf2b70fdd20] + +2007-06-20 ajordan + + * src/vm/jit/asmpart.h, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/md-abi.c, src/vm/vm.c, src/vm/vm.h: + * src/vm/jit/sparc64/md-abi.c (md_param_alloc): Added pd->index + setting. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Get parameters + from new array. + + * src/vm/jit/asmpart.h: Enable new parameter passing for SPARC64. + * src/vm/vm.h: Likewise. + * src/vm/vm.c: Likewise. (vm_array_store_flt): For SPARC, shift float + arguments on stack to low word too. + [cad4c8459a15] + +2007-06-20 twisti + + * src/vm/vm.c: + * src/vm/vm.c (vm_array_store_int) [SIZEOF_VOID_P == 4]: Only do the + integer shift on 32-bit architectures. + [ec7d71eb14ce] + +2007-06-19 twisti + + * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/vm.c, src/vm/vm.h: + * src/vm/vm.c (vm_call_float_array): New function. + (vm_call_method_float_valist): Likewise. + (vm_call_method_float_jvalue): Likewise. (vm_call_double_array): + Likewise. (vm_call_method_double_valist): Likewise. + (vm_call_method_double_jvalue): Likewise. + + * src/vm/vm.h: Defined new functions. + * src/vm/jit/asmpart.h: Likewise. + * src/native/jni.c: Use new functions. + [cd1486e9e61f] + + * src/cacaoh/headers.c: + * src/cacaoh/headers.c (stdint.h): Added and use stdint-types. + (vm/types.h): Removed. + [0961a76da1a7] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (stdint.h): Added. (vm/types.h): Removed and + replaced all old types with stdint ones. (threads/threads-common.h): + Removed. [ENABLE_THREADS] (threads_current_threadobject_key): + Removed. + [30a74a4f0cf4] + + * src/native/include/Makefile.am, src/native/vm/Makefile.am, + src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_util_concurrent_atomic_AtomicLong.c, + src/native/vm/java_util_concurrent_atomic_AtomicLong.h, + src/native/vm/nativevm.c: + * src/native/vm/nativevm.c (nativevm_init) [ENABLE_JAVASE && + WITH_CLASSPATH_GNU]: Call + _Jv_java_util_concurrent_atomic_AtomicLong_init. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES): Added. + (libnativevm_la_SOURCES): Added + JAVA_UTIL_CONCURRENT_ATOMIC_ATOMICLONG_SOURCES. + + * src/native/vm/java_util_concurrent_atomic_AtomicLong.c: New file. + * src/native/vm/java_util_concurrent_atomic_AtomicLong.h: Likewise. + + * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): Added + java_util_concurrent_atomic_AtomicLong.c. + + * src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c: New + file. + + * src/native/include/Makefile.am (JAVASE_HEADER_FILES): Added + java_util_concurrent_atomic_AtomicLong.h. + [8c4969ee5afa] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c: Added Id keyword. + [958a5b301f5f] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c [ENABLE_THREADS] (pthread.h): Removed. (threads + /threads-common.h): Added. [ENABLE_THREADS] + (threads_current_threadobject_key): Added #ifdef. + [1fc81716c8fb] + +2007-06-18 twisti + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_throw_utf_throwable): Call + (Ljava/lang/Throwable;)V initializer and resolve the method with + class_resolveclassmethod to get possible exceptions. + (exceptions_throw_utf_cause): New function. + (exceptions_throw_noclassdeffounderror_cause): Use + exceptions_throw_utf_cause. + [57608e101f88] + +2007-06-18 tbfg + + * src/native/jni.c, src/vm/jit/asmpart.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/linux/md-abi.c, + src/vm/vm.c, src/vm/vm.h: + * src/vm/jit/powerpc64/linux/md-abi.c (md_param_alloc): Set index. + + * src/vm/jit/powerpc64/asmpart.S (asm_vm_call_method): New parameter + format, do not call asm_jit_compile any more. + + * src/vm/jit/asmpart.h: Enable new parameter format function + prototypes. + + * src/vm/vm.h: Likewise. + + * src/vm/vm.c (vm_array_store_int): Although ppc64 is big endian do + not big endianize the new parameter format. (vm_array_store_flt): + Likewise. (vm_array_store_adr): Likewise. (vm_vmargs_from_valist): + ppc64 like alpha uses doubles everywhere. (vm_vmargs_from_jvalue): + When HAS_ADDRESS_REGISTER_FILE is defined address register arguments + are between float and memuse. + + * src/native/jni.c: Enable new parameter function calling. + [4f8863624904] + +2007-06-17 pm + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/md.c: + * src/vm/jit/s390/codegen.c (codegen_emit): More data segment load + optimalisations. + * src/vm/jit/s390/md.c (md_get_method_patch_address): Adapt to changes + in codegen_emit. + [49542d2724ed] + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/dacapo.status: + * src/vm/jit/s390/asmpart.S src/vm/jit/s390/codegen.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/dacapo.status: Optimized loads from data + segment: the procedure vector now always points 4092 bytes before + the data segment, so a lot of loads have a positive displacement. + Removed dead code. + [4fb65c7793af] + +2007-06-16 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md-abi.h: + * src/vm/jit/sparc64/codegen.c (codegen_emit): Improved integer + argument passing by swapping variable allocation instead of copying. + + * src/vm/jit/sparc64/md-abi.h: Turned %i0 into saved reg. + * src/vm/jit/sparc64/md-abi.c: Likewise. + [c57b32bcb804] + + * src/vm/jit/codegen-common.c, src/vm/jit/jit.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vmcore/statistics.c, src/vmcore/statistics.h: + * src/vmcore/statistics.h: Added more fine grained spill statistics. + * src/vmcore/statistics.c: Likewise. + + * src/vm/jit/jit.h: New defines for spill statistics. Old ones are + deprecated, won't increase the counters. + + * src/vm/jit/codegen-common.c (codegen_increase): Defined SPARC64 + for 2-instr-patcher-stub-call workaround. (codegen_add_patch_ref): + Likewise. (codegen_reg_of_var): Removed obsolete spill counting. + + * src/vm/jit/sparc64/emit.c: Changed for new spill statistics. + * src/vm/jit/sparc64/linux/md-os.c (md_critical_section_restart): + Fixed. + [c3a6554d62ff] + +2007-06-14 twisti + + * src/vm/jit/emit-common.c: + * src/vm/jit/emit-common.c (emit_bccz) [STATISTICS]: Is called + ENABLE_STATISTICS. (emit_label_bccz): Likewise. (emit_label): + Likewise. + [196f9b2253bc] + + * src/native/native.c: + * src/native/native.c (native_findfunction): Use + exceptions_throw_unsatisfiedlinkerror. + [f45e4f47064e] + + * src/threads/native/threads.c: + * src/threads/native/threads.c: Don't use exceptionptr directly + anymore. + [95acc7abb942] + + * src/vm/exceptions.c: + * src/vm/exceptions.c: Don't use exceptionptr directly anymore, + access it only with functions. + [ad9435047576] + + * src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c: Added Id keyword. + [4f5335e1c9b5] + + * src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c (forName): Removed unused + variables. + [e4fb080b640a] + + * src/vm/exceptions.c, src/vm/exceptions.h: + * src/vm/exceptions.c (exceptions_get_exception) + (exceptions_set_exception, exceptions_clear_exception) + (exceptions_get_and_clear_exception): Moved these low leve function + to the top of the file. + * src/vm/exceptions.h: Likewise. + [9687cfa0b8da] + + * src/vmcore/loader.c: + * src/vmcore/loader.c: Removed commented + exceptions_throw_noclassdeffounderror calls. + [33ad7340e017] + +2007-06-14 tbfg + + * src/vm/jit/emit-common.c: + * src/vm/jit/emit-common.c: Fixed warning related to STATISTICS. + [5851e39c5e3b] + +2007-06-14 michi + + * src/mm/cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h: + * src/mm/cacao-gc/rootset.h (rootset_t): Removed ss and es from + rootset. + * src/mm/cacao-gc/rootset.c: Adapted to above changes. + [44759f6a2609] + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/copy.c, src/mm/cacao- + gc/heap.c, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/rootset.c, src/mm + /cacao-gc/rootset.h, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/jit/asmpart.h, + src/vm/jit/m68k/disass.c, src/vm/jit/mips/asmpart.S, src/vm/jit/mips + /md-abi.c, src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/tests/dacapo.status, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/md-abi.c, + src/vm/resolve.c, src/vm/string.c, src/vmcore/descriptor.c, + src/vmcore/descriptor.h, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/mm/cacao-gc/rootset.h (rootset_entry_t) Added. Rootsets can be + resized. + * src/mm/cacao-gc/rootset.c (rootset_resize) Added. + + * src/mm/cacao-gc/copy.c: Adapted to above changes. + * src/mm/cacao-gc/heap.c: Likewise. + * src/mm/cacao-gc/compact.c: Likewise. + * src/mm/cacao-gc/mark.c: Likewise. + [3669240563a0] + +2007-06-14 tbfg + + * src/vm/jit/emit-common.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vm/jit/emit-common.c: Added emit_branch statistics. + * src/vmcore/statistics.c: Likewise. + * src/vmcore/statistics.h: Added count_emit_branch, + count_emit_branch_8bit, count_emit_branch_16bit, + count_emit_branch_32bit, count_emit_branch_64bit. + [e83bd9ae9d95] + + * src/vm/jit/m68k/disass.c: + src/vm/jit/m68k/disass.c: Changed bfd_mach_mcf_isa_b_float_emac to + bfd_mach_mcfv4e as needed for newer binutils. + [f5e047be233b] + +2007-06-14 twisti + + * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/md-abi.c, src/vm/vm.c, src/vm/vm.h: + * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method): Rewritten for + new argument passing. + + * src/vm/jit/x86_64/md-abi.c (md_param_alloc): Set pd->index. + + * src/vm/vm.c: Added __X86_64__ ifdef. + * src/vm/vm.h: Likewise. + * src/native/jni.c: Likewise. + * src/vm/jit/asmpart.h: Likewise. + [72c74af0daa4] + + * src/vm/vm.c: + * src/vm/vm.c (vm_array_from_objectarray): For TYPE_ADR param can be + NULL, that's ok (jboss is a testcase for that). + [326564bdb23d] + + * src/vm/vm.c: + * src/vm/vm.c (vm_call_method_long_vmarg): Removed vm_abort. + [744695dcd490] + + * src/vm/vm.c: + * src/vm/vm.c (arch.h): Added. (vm/jit/abi-asm.h): Likewise. + (vm_array_store_int): Use ARG_CNT define. (vm_array_store_dbl): + Likewise. (vm_array_store_flt): Likewise. (vm_array_store_dbl): + Likewise. (vm_array_store_adr) [HAS_ADDRESS_REGISTER_FILE]: Changed + offset. + [5d8d0edf973d] + + * src/vm/vm.c: + * src/vm/vm.c: Fixed typos. + [b5c9d3729e96] + + * src/vm/jit/mips/asmpart.S: + * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [!WORDS_BIGENDIAN]: + Fixed bug (use lw instead of ld), better code in the stack copy + loop. + [c47fed9cc15c] + +2007-06-13 twisti + + * src/native/jni.c, src/vm/jit/asmpart.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/md-abi.c, src/vm/vm.c, src/vm/vm.h, + src/vmcore/descriptor.h: + * src/vm/jit/mips/asmpart.S (asm_vm_call_method): Rewritten for new + argument passing. + + * src/vm/jit/mips/md-abi.c (stdarg.h): Added. (mm/memory.h): + Likewise. (md_param_alloc): Set pd->index. + + * src/vm/jit/asmpart.h (stdint.h): Added new function prototypes. + + * src/vm/vm.c (md-abi.h): Added. (vm_array_store_int): New function. + (vm_array_store_lng): Likewise. (vm_array_store_flt): Likewise. + (vm_array_store_dbl): Likewise. (vm_array_store_adr): Likewise. + (vm_array_from_valist): Likewise. (vm_array_from_jvalue): Likewise. + (vm_array_from_objectarray): Likewise. (vm_call_method_valist): New + version added. (vm_call_method_jvalue): Likewise. (vm_call_array): + New function. (vm_call_int_array): Likewise. + (vm_call_method_int_valist): New version added. + (vm_call_method_int_jvalue): Likewise. (vm_call_method_long_valist): + Likewise. (vm_call_method_long_jvalue): Likewise. + (vm_call_long_array): New function. (vm_call_method_float_vmarg): + Added vm_abort. (vm_call_method_double_vmarg): Likwise. + + * src/vm/vm.h (stdarg.h): Added. (vmcore/class.h): Likewise. + (vmcore/method.h): Likewise. (vm_array_from_objectarray): Likewise. + (vm_call_array): Likewise. (vm_call_int_array): Likewise. + (vm_call_long_array): Likewise. + + * src/native/jni.c (_Jv_jni_invokeNative): Added new version. + + * src/vmcore/descriptor.h (stdint.h): Added. (paramdesc): Added + index field (this is temporarily). + [e69592257712] + + * src/vm/jit/tools/genoffsets.c: + * src/vm/jit/tools/genoffsets.c (vmcore/class.h): Removed. + (vmcore/linker.h): Likewise. (vmcore/method.h): Likewise. + [044505816e1d] + + * tests/regression/native/testarguments.c, + tests/regression/native/testarguments.java, + tests/regression/native/testarguments.output: + * tests/regression/native/testarguments.java, + tests/regression/native/testarguments.c, + tests/regression/native/testarguments.output: Added address test. + [328942132afd] + + * src/vm/jit/m68k/md.c, src/vm/jit/tools/genoffsets.c: + * src/vm/jit/tools/genoffsets.c (main): Removed some obsolete stuff. + * src/vm/jit/m68k/md.c (md_init): Removed offobjvftbl check. + [3a5d14dca2b6] + + * src/native/jni.c, src/vm/vm.c, src/vm/vm.h: + * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Removed. + (_Jv_jni_invokeNative): Use vm_vmargs_from_objectarray. + + * src/vm/vm.c (stdint.h): Added. (native/include/java_lang_Byte.h) + (native/include/java_lang_Character.h) + (native/include/java_lang_Short.h) + (native/include/java_lang_Integer.h) + (native/include/java_lang_Boolean.h) + (native/include/java_lang_Long.h) (native/include/java_lang_Float.h) + (native/include/java_lang_Double.h): Likewise. + (vm_vmargs_from_objectarray): New function. + + * src/vm/vm.h (vm_vmargs_from_objectarray): Added. + [80db4c9bf082] + + * src/native/jni.c: + * src/native/jni.c (stdint.h): Added. + (_Jv_jni_vmargs_from_objectarray): Use stdint-types, use global + class variables. + [27afbf410bf3] + +2007-06-12 pm + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/tests/dacapo.status: + * src/vm/jits/390/codegen.h (N_BRC_BACK_PATCH, N_LTEBR, N_LTDBR, + N_LTXBR, DD_0, ..., DD_3): added, (M_CVTFI, M_CVTDI) changed to + round to nearest. + * src/vm/jits/390/codegen.c (codegen_emit): In ICMD_F2I and ICMD_D2I + correct handling of corner cases, ICMD_LALOAD fix. + * src/vm/jit/s390/md.c (md_dump_context): Include information on java + method in dump. + * src/vm/jits/390/tests/dacapo.status: Noted dacapo eclipse results. + [9e9ea1b2157d] + +2007-06-12 twisti + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Added asserts for declaringClass and slot. + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): + Likewise. + [0ac5a66c2fe9] + + * src/vm/vm.c: + * src/vm/vm.c (opts): Added OPT_EA, OPT_DA. (usage): Print help for + OPT_EA, OPT_DA. (vm_create): Ignore OPT_EA, OPT_DA. + [f9e8cfb36fa9] + +2007-06-11 pm + + * src/vm/jit/s390/emit.c, src/vm/jit/s390/tests/dacapo.status: + * src/vm/jit/s390/emit.c (emit_load_s1_notzero, + emit_load_s2_notzero, emit_load_s1_but, emit_load_s2_but): Correctly + handle float regissters. + * src/vm/jit/s390/tests/dacapo.status: Include dacapo lusearch + results. + [1db7e718b606] + +2007-06-11 twisti + + * src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.c, + src/native/vm/java_lang_reflect_Method.h: + * src/native/vm/java_lang_reflect_Method.c: New file. + * src/native/vm/java_lang_reflect_Method.h: Likewise. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (JAVA_LANG_REFLECT_METHOD_SOURCES): Added (libnativevm_la_SOURCES): + Added JAVA_LANG_REFLECT_METHOD_SOURCES. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (native/vm/java_lang_reflect_Method.h): Added. (invokeNative): Use + _Jv_java_lang_reflect_Method_invoke. + [789e9c2528f9] + + * src/native/vm/gnu/java_lang_reflect_Method.c, src/vmcore/method.c, + src/vmcore/method.h: + * src/vmcore/method.c (method_returntype_get): New function. + * src/vmcore/method.h (method_returntype_get): Added. + + * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType): Use + method_returntype_get. + [58a2095b54fd] + + * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/java_lang_Class.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/resolve.c, src/vm/vm.c, + src/vmcore/class.c, src/vmcore/loader.c, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vm/resolve.c (resolve_class_from_name): Call + exceptions_classnotfoundexception_to_noclassdeffounderror in + exception case. + + * src/vm/exceptions.c (vmcore/method.h): Added. + (exceptions_throw_utf_throwable): Added object-initialize code. + (exceptions_throw_utf_exception): Likewise. + (exceptions_throw_noclassdeffounderror_cause): New function. + (classnotfoundexception_to_noclassdeffounderror): Renamed to + exceptions_classnotfoundexception_to_noclassdeffounderror. + (exceptions_print_stacktrace): Don't use exceptionptr directly. + + * src/vm/exceptions.h (exceptions_throw_noclassdeffounderror_cause): + Added. (classnotfoundexception_to_noclassdeffounderror): Renamed to + exceptions_classnotfoundexception_to_noclassdeffounderror. + + * src/vm/vm.c (opts): Added XX:. (vm_create): Likewise. (vm_run): + Call exceptions_throw_noclassdeffounderror_cause when main-class is + not found. + + * src/native/vm/java_lang_Class.c (forName): Don't convert + exception. + + * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass): + Use primitive_class_get_by_char. (loadClass): Don't convert + exception. + + * src/native/native.c (native_new_and_init_string): Use + class_findmethod instead of class_resolveclassmethod. + (native_new_and_init_throwable): Removed. + (native_new_and_init_exception): Likewise. + + * src/native/native.h (native_new_and_init_throwable): Removed. + (native_new_and_init_exception): Likewise. + + * src/vmcore/class.c (class_array_of): Smaller code changes. + + * src/vmcore/loader.c (vmcore/primitive.h): Added. + (load_class_from_classloader): Don't convert exception. + (load_class_bootstrap): Throw ClassNotFoundException instead of + NoClassDefFoundError. (load_newly_created_array): Likewise, check if + primitive-array type is valid. + + * src/vmcore/utf8.c (utf_initCause): Added. + (utf_java_lang_Throwable__java_lang_Throwable): Likewise. + (utf8_init): Initialize new variables. + + * src/vmcore/utf8.h (utf_initCause): Added. + (utf_java_lang_Throwable__java_lang_Throwable): Likewise. + + * src/cacaoh/dummy.c (exceptions_throw_classnotfoundexception): New + function. (classnotfoundexception_to_noclassdeffounderror): Removed. + + * src/vmcore/options.c (options_xx): New function. + * src/vmcore/options.h (options_xx): Added. + [116a6286baf0] + + * src/vmcore/primitive.c, src/vmcore/primitive.h: + * src/vmcore/primitive.c (primitive_class_get_by_char): New + function. + * src/vmcore/primitive.h (primitive_class_get_by_char): Added. + [1c2e447571f7] + +2007-06-10 twisti + + * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/vm/builtin.c, src/vm/global.h, + src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify + /typecheck-stackbased.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/resolve.c, src/vm/string.c, src/vm/vm.c, + src/vmcore/Makefile.am, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/descriptor.c, src/vmcore/linker.c, src/vmcore/linker.h, + src/vmcore/primitive.c, src/vmcore/primitive.h: + * src/vm/global.h (PRIMITIVETYPE_*): Removed. (ARRAYTYPE_*): + Likewise. + + * src/vm/jit/verify/typecheck-typeinferer.c (vmcore/primitive.h): + Added. + * src/vm/jit/verify/typecheck.c: Likewise. + * src/vm/jit/verify/typecheck-stackbased.c: Likewise. + * src/vm/jit/verify/typeinfo.c: Likewise. + * src/vm/builtin.c: Likewise. + * src/native/jni.c: Likewise. + * src/native/vm/gnu/java_lang_VMClassLoader.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Field.c: Likewise. + * src/vmcore/descriptor.c: Likewise. + + * src/vm/string.c (vmcore/primitive.h): Added. (stringtable_update): + Use new primitive functions. + + * src/vm/resolve.c: Likewise. (resolve_class_from_typedesc): Use new + primitive functions. + + * src/vm/vm.c (vmcore/primitive.h): Added. (vm_create): Call + primitive_init. + + * src/native/vm/java_lang_Class.c (vmcore/primitive.h): Added. + (isPrimitive): Use primitive_class_is_primitive. + (getDeclaringClass): Likewise. (getDeclaredClasses): Likewise. + (getComponentType): Use primitive_class_get_by_type. + + * src/vmcore/class.c (class_is_primitive): Removed. + (class_primitive_get): Removed. + * src/vmcore/class.c: Likewise. + + * src/vmcore/primitive.c: New file. + * src/vmcore/primitive.h: Likewise. + + * src/vmcore/Makefile.am (libvmcore_la_SOURCES): Added + primitive.[ch]. + + * src/vmcore/linker.c (vmcore/primitive.h): Added. + (primitivetype_table): Removed. (linker_init): Removed + link_primitivetype_table call. (link_primitivetype_table): Removed. + + * src/vmcore/linker.h (primitivetypeinfo): Removed. + (primitivetype_table): Removed. + + * src/vm/jit/verify/typecheck-builtins.inc: Removed Contact, Authors + from header. + [b966330e73b9] + + * src/vm/vm.c: + * src/vm/vm.c (vm_vmargs_from_valist): Use TYPE_-defines instead of + PRIMITIVETYPE_ ones. (vm_vmargs_from_jvalue): Likewise. + [6b6e8f657076] + + * configure.ac, src/native/jni.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/jit/s390/emit.c, src/vmcore/linker.h, + src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/native/jni.c (_Jv_jni_vmargs_from_objectarray): Indent. + [9a477c778729] + +2007-06-10 michi + + * tests/gc/ClassInit.java: + * tests/gc/ClassInit: Testcase for static class initializers works + correct now. + [81ab1163d960] + + * configure.ac, m4/classpath.m4, src/native/jni.c, + src/native/native.c, src/native/native.h, + src/native/vm/java_lang_ClassLoader.c, src/vm/builtin.c, + src/vm/builtin.h, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/jit/s390/emit.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/linker.h, src/vmcore/utf8.c, + src/vmcore/utf8.h: + Merged revisions 8034-8055 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8041 | twisti | 2007-06-07 18:21:11 +0200 (Thu, 07 Jun + 2007) | 4 lines + + * configure.ac (AC_CHECK_HEADERS): Check for sys/select.h, + sys/stat.h, sys/types.h. (AC_CHECK_FUNCS): Check for fstat, + ioctl, select. ........ r8042 | twisti | 2007-06-07 19:43:29 +0200 + (Thu, 07 Jun 2007) | 9 lines + + * src/vmcore/class.c (class_primitive_get): New function. + * src/vmcore/class.h (class_primitive_get): Added. + + * src/vmcore/linker.c (primitivetype_table): Changed layout. + (link_primitivetype_table): Store UTF-8 name in table. + + * src/vmcore/linker.h (primitivetypeinfo): Changed layout, added + cname, changed name to UTF-8. ........ r8043 | twisti | 2007-06-07 + 21:22:31 +0200 (Thu, 07 Jun 2007) | 2 lines + + * configure.ac (AC_CHECK_FUNCS): Added open, strerror. ........ + r8044 | twisti | 2007-06-07 21:24:35 +0200 (Thu, 07 Jun 2007) | 5 + lines + + * src/vm/builtin.c (builtin_nanotime): New function. + (builtin_currenttimemillis): Use builtin_nanotime. + + * src/vm/builtin.h (builtin_nanotime): Added. ........ r8045 | + twisti | 2007-06-07 23:52:21 +0200 (Thu, 07 Jun 2007) | 2 lines + + * src/native/jni.c (_Jv_JNI_FatalError): Changed error message. + ........ r8046 | pm | 2007-06-08 00:02:16 +0200 (Fri, 08 Jun 2007) + | 4 lines + + * src/vm/jit/s390/emit.c (emit_verbosecall_enter): Fix passing of + float argument 2 to builtin_verbosecall_enter. + * src/vm/builtin.c (builtin_print_argument): Fix malfunctioning + conversion from s8 to float on s390. ........ r8047 | twisti | + 2007-06-08 00:20:37 +0200 (Fri, 08 Jun 2007) | 13 lines + + * src/vmcore/utf8.c (utf_java_security_PrivilegedActionException): + Added. (utf8_init): Initialize + utf_java_security_PrivilegedActionException. + + * src/vmcore/utf8.h (utf_java_security_PrivilegedActionException): + Added. + + * src/vm/exceptions.c + (exceptions_throw_privilegedactionexception): New function. + + * src/vm/exceptions.h + (exceptions_throw_privilegedactionexception): Added. ........ + r8048 | twisti | 2007-06-08 00:41:54 +0200 (Fri, 08 Jun 2007) | 11 + lines + + * src/vmcore/utf8.c (utf_java_lang_Exception__V): Added. + (utf8_init): Initialize utf_java_lang_Exception__V. + * src/vmcore/utf8.h (utf_java_lang_Exception__V): Added. + + * src/vm/exceptions.c (exceptions_throw_utf_exception): New + function. (exceptions_throw_privilegedactionexception): Use + exceptions_throw_utf_exception. + + * src/native/native.c (native_new_and_init_exception): New + function. + * src/native/native.h (native_new_and_init_exception): Added. ........ + r8049 | twisti | 2007-06-08 01:30:45 +0200 (Fri, 08 Jun 2007) | 6 + lines + + * src/vmcore/class.c (class_define): New function. + * src/vmcore/class.h (class_define): Added. + + * src/native/vm/java_lang_ClassLoader.c (defineClass): Use + class_define. ........ r8050 | twisti | 2007-06-08 22:04:34 +0200 + (Fri, 08 Jun 2007) | 2 lines + + * configure.ac (AC_CHECK_FUNCS): Added lseek. ........ r8051 | + twisti | 2007-06-08 22:42:54 +0200 (Fri, 08 Jun 2007) | 3 lines + + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Check for + jni_md.h too. ........ + [6563526e7ae9] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/region.c: + * src/mm/cacao-gc/heap.c (heap_update_references, + heap_increase_size): Added. + * src/mm/cacao-gc/region.c (region_resize): Added. + * src/mm/cacao-gc/gc.c (gc_collect): Heap gets resized if it's too + small. + + * src/mm/cacao-gc/gc.c (gc_reference_register): Can be called + without gc_init. + [761f70b4c073] + + * src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Fixed typo. + [06e3c947f614] + + * src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getClassLoader): Handle indirection cell of + bootstrap classloader properly. + [ec40a38a4415] + + * configure.ac, m4/classpath.m4, src/threads/native/threads.c, + src/threads/threads-common.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/jit/s390/emit.c, src/vmcore/linker.h, + src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/threads/threads-common.c [ENABLE_GC_CACAO]: References to + java.lang.Thread now get registered uppon threadobject creation. + + * src/threads/native/threads.c (threads_init) [ENABLE_GC_CACAO]: + Register mainthreadobject with the GC as well. + [f27ccfc9cef4] + +2007-06-08 twisti + + * m4/classpath.m4: + * m4/classpath.m4 (AC_CHECK_WITH_CLASSPATH_INCLUDEDIR): Check for + jni_md.h too. + [a7ff8e5056a1] + + * configure.ac: + * configure.ac (AC_CHECK_FUNCS): Added lseek. + [2570912c4f23] + +2007-06-07 twisti + + * src/native/vm/java_lang_ClassLoader.c, src/vmcore/class.c, + src/vmcore/class.h: + * src/vmcore/class.c (class_define): New function. + * src/vmcore/class.h (class_define): Added. + + * src/native/vm/java_lang_ClassLoader.c (defineClass): Use + class_define. + [d07d76fc4127] + + * src/native/native.c, src/native/native.h, src/vm/exceptions.c, + src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vmcore/utf8.c (utf_java_lang_Exception__V): Added. + (utf8_init): Initialize utf_java_lang_Exception__V. + * src/vmcore/utf8.h (utf_java_lang_Exception__V): Added. + + * src/vm/exceptions.c (exceptions_throw_utf_exception): New + function. (exceptions_throw_privilegedactionexception): Use + exceptions_throw_utf_exception. + + * src/native/native.c (native_new_and_init_exception): New function. + * src/native/native.h (native_new_and_init_exception): Added. + [51375f51d27f] + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vmcore/utf8.c, + src/vmcore/utf8.h: + * src/vmcore/utf8.c (utf_java_security_PrivilegedActionException): + Added. (utf8_init): Initialize + utf_java_security_PrivilegedActionException. + + * src/vmcore/utf8.h (utf_java_security_PrivilegedActionException): + Added. + + * src/vm/exceptions.c (exceptions_throw_privilegedactionexception): + New function. + + * src/vm/exceptions.h (exceptions_throw_privilegedactionexception): + Added. + [91d976c76ab3] + +2007-06-07 pm + + * src/vm/builtin.c, src/vm/jit/s390/emit.c: + * src/vm/jit/s390/emit.c (emit_verbosecall_enter): Fix passing of + float argument 2 to builtin_verbosecall_enter. + * src/vm/builtin.c (builtin_print_argument): Fix malfunctioning + conversion from s8 to float on s390. + [519598ee5f7c] + +2007-06-07 twisti + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_FatalError): Changed error message. + [55e700ed2709] + + * src/vm/builtin.c, src/vm/builtin.h: + * src/vm/builtin.c (builtin_nanotime): New function. + (builtin_currenttimemillis): Use builtin_nanotime. + + * src/vm/builtin.h (builtin_nanotime): Added. + [401776117493] + + * configure.ac: + * configure.ac (AC_CHECK_FUNCS): Added open, strerror. + [ca72c4495369] + + * src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c, + src/vmcore/linker.h: + * src/vmcore/class.c (class_primitive_get): New function. + * src/vmcore/class.h (class_primitive_get): Added. + + * src/vmcore/linker.c (primitivetype_table): Changed layout. + (link_primitivetype_table): Store UTF-8 name in table. + + * src/vmcore/linker.h (primitivetypeinfo): Changed layout, added + cname, changed name to UTF-8. + [2b7b6493b36c] + + * configure.ac: + * configure.ac (AC_CHECK_HEADERS): Check for sys/select.h, + sys/stat.h, sys/types.h. (AC_CHECK_FUNCS): Check for fstat, ioctl, + select. + [b6e5f1303df2] + +2007-06-07 michi + + * src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Add syncslots to + the rootset. + [c98b52b5c6d7] + + * src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/x86_64/codegen.c: + * src/vm/jit/m68k/codegen.c (codegen_emit): Enabled rplpoints for + ICMD_BUILTIN. + * src/vm/jit/i386/codegen.c: Likewise. + * src/vm/jit/x86_64/codegen.c: Likewise. + [e61e24193720] + + * src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/replace.c (replace_create_replacement_points) + [ENABLE_GC_CACAO]: Create replacement points for builtin invokations + as well. + + * src/vm/jit/replace.h: Added REPLACEMENT_POINT_FORGC_BUILTIN and + REPLACEMENT_POINT_FORGC_BUILTIN_RETURN. + [b8cd6ed9311c] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c: Fixed some compiler wanings and verbose + output. + * src/mm/cacao-gc/gc.c: Likewise. + [95f567f2e31b] + + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/rootset.c: + * src/mm/cacao-gc/rootset.c (rootset_from_classes): Fixed alignment + problem. + [5e61c8496d97] + + * src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Fixed verbose + output. + [45b51e706e2e] + + * src/vm/jit/m68k/linux/md-abi.c: + Merged revisions 8027-8033 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r8032 | tbfg | 2007-06-07 13:23:52 +0200 (Thu, 07 Jun + 2007) | 2 lines + + * src/vm/jit/m68k/linux/md-abi.c: Additional defines for address + registers. ........ + [10960ea13d78] + + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_find_replacement_point): Fixed + assertion. + * src/mm/cacao-gc/gc.h [__M68K__]: Added this architecture. + * src/mm/cacao-gc/heap.c (heap_alloc_intern): Removed debug code. + [bdb055d25777] + +2007-06-07 tbfg + + * src/vm/jit/m68k/linux/md-abi.c: + * src/vm/jit/m68k/linux/md-abi.c: Additional defines for address + registers. + [807254ee68f7] + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/md.c: + * linux/md-os.c (md_signal_handler_sigusr1): Implemented. + * emit.c (emit_replacement_stubs): Partially implemented. + * md.c (md_init): Disabled santiy checks. + * arch.h (REPLACEMENT_PATCH_SIZE): Defined to 0 for now. + * codegen.c (codegen_emit_stub_builtin): Implemented. + [a1f4488c6d64] + +2007-06-07 michi + + * src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigusr1): + Implemented. + [aa3f16d05963] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_pop_native_frame, + replace_push_native_frame) [HAS_ADDRESS_REGISTER_FILE]: Adapted to + restore saved address registers as well. + [987c8ac0539f] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c (rootset_readout): Use thread list + instead of table. + * src/mm/cacao-gc/gc.c (gc_collect): Fixed deadlock with threads_dump. + [7fb4b86acc7a] + + * ChangeLog, NEWS, configure.ac, src/mm/boehm-gc/pthread_stop_world.c, + src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/sun_misc_Unsafe.c, + src/native/vm/java_lang_Class.c, src/threads/critical.c, + src/threads/native/lock.c, src/threads/native/lock.h, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/none/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/access.c, src/vm/access.h, + src/vm/builtin.c, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/emit- + common.h, src/vm/jit/i386/linux/md-os.c, src/vm/jit/jit.c, + src/vm/jit/mips/Makefile.am, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/optimizing/ifconv.c, + src/vm/jit/optimizing/profile.c, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md- + abi.h, src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux + /md-os.c, src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/replace.c, + src/vm/jit/replace.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, src/vm/jit/show.c, + src/vm/jit/show.h, src/vm/jit/sparc64/Makefile.am, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/machine-instr.h, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-asm.h, + src/vm/jit/sparc64/md.c, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/md.c, src/vm/resolve.c, src/vm/signal.c, + src/vm/signallocal.h, src/vm/string.c, src/vm/stringlocal.h, + src/vm/vm.c, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/linker.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/statistics.c, + src/vmcore/statistics.h, src/vmcore/utf8.c, src/vmcore/utf8.h: + Merged revisions 7940-8026 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7941 | twisti | 2007-05-23 13:59:51 +0200 (Wed, 23 May + 2007) | 6 lines + + * src/vm/exceptions.c (new_exception_int): Removed. + * src/vm/exceptions.h (new_exception_int): Likewise. + + * src/native/native.c (native_new_and_init_int): Likewise. + * src/native/native.h (native_new_and_init_int): Likewise. ........ + r7942 | twisti | 2007-05-23 14:40:31 +0200 (Wed, 23 May 2007) | 24 + lines + + * src/vm/exceptions.c (threads/lock-common.h): Added. + [ENABLE_THREADS] (threads/native/threads.h): Removed. + [!ENABLE_THREADS] (threads/none/threads.h): Likewise. (threads + /threads-common.h): Added. (new_exception_message): Removed. + (exceptions_throw_classcircularityerror): Use + exceptions_throw_utf_utf. (exceptions_throw_classformaterror): + Likewise. (classnotfoundexception_to_noclassdeffounderror): Fixed + warning. (exceptions_throw_incompatibleclasschangeerror): Use + exceptions_throw_utf_utf. (exceptions_throw_internalerror): + Likewise. (exceptions_throw_unsupportedclassversionerror): + Likewise. (exceptions_throw_verifyerror): Likewise. + (exceptions_throw_verifyerror_for_stack): Likewise. + (exceptions_new_arithmeticexception): Likewise. + (exceptions_new_classcastexception): Use exceptions_new_class_utf. + (exceptions_print_exception): Fixed warnings. + + * src/vmcore/utf8.c (utf_division_by_zero): Added. (utf8_init): + Likewise. + + * src/vmcore/utf8.h (utf_division_by_zero): Likewise. ........ + r7943 | twisti | 2007-05-23 15:09:28 +0200 (Wed, 23 May 2007) | 4 + lines + + * src/vmcore/linker.c (linker_compute_subclasses): We don't ship + the critical-section stuff with this release, since it's broken on + some architectures because of boehm. ........ r7944 | tbfg | + 2007-05-23 16:15:00 +0200 (Wed, 23 May 2007) | 3 lines + + * src/vm/jit/powerpc64/emit.c (MCODECHECK): Increase values to fix + canary corruption. + * src/vm/jit/powerpc64/codegen.c (MCODECHECK): Increase values to fix + canary corruption. ........ r7945 | twisti | 2007-05-23 17:25:18 + +0200 (Wed, 23 May 2007) | 5 lines + + * src/vm/jit/powerpc64/codegen.c (codegen_emit): ICMD_INSTANCEOF: + Removed unused supervftbl. + + * src/vm/jit/emit-common.h [__POWERPC64__] (emit_bnan): Enabled. + ........ r7946 | twisti | 2007-05-23 17:43:53 +0200 (Wed, 23 May + 2007) | 2 lines + + * configure.ac (OPT_CFLAGS): Changed to -O2. ........ r7947 | + twisti | 2007-05-23 17:57:41 +0200 (Wed, 23 May 2007) | 4 lines + + * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Fixed + warning. + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): + Likewise. ........ r7948 | twisti | 2007-05-23 18:00:13 +0200 + (Wed, 23 May 2007) | 3 lines + + * src/vm/exceptions.c (exceptions_new_hardware_exception): Fixed + warning. ........ r7949 | twisti | 2007-05-23 19:46:27 +0200 (Wed, + 23 May 2007) | 2 lines + + * src/vm/jit/jit.c (jit_compile_intern): Fixed typo. ........ + r7950 | twisti | 2007-05-23 19:51:04 +0200 (Wed, 23 May 2007) | 2 + lines + + * src/vm/vm.c (vm_create): Use vm_abort for profile_start_thread. + ........ r7951 | twisti | 2007-05-23 19:51:43 +0200 (Wed, 23 May + 2007) | 3 lines + + * src/vm/jit/optimizing/profile.c (profile_thread): Replaced + table- with list-functions. ........ r7952 | twisti | 2007-05-23 + 19:53:13 +0200 (Wed, 23 May 2007) | 2 lines + + * src/vm/jit/optimizing/profile.c: Set Id keyword. ........ + r7953 | twisti | 2007-05-23 19:56:59 +0200 (Wed, 23 May 2007) | 3 + lines + + * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass): + Return NULL in error case. ........ r7954 | twisti | 2007-05-23 + 19:58:18 +0200 (Wed, 23 May 2007) | 3 lines + + * src/threads/native/lock.c: Set Id keyword. + * src/threads/native/lock.h: Likewise. ........ r7955 | twisti | + 2007-05-23 20:05:26 +0200 (Wed, 23 May 2007) | 8 lines + + * src/vm/jit/arm/linux/md-os.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/x86_64/linux/md- + os.c (md_critical_section_restart): Removed debug output. ........ + r7956 | twisti | 2007-05-23 20:08:42 +0200 (Wed, 23 May 2007) | 3 + lines + + * src/vmcore/statistics.c (statistics_print_memory_usage): Smaller + output changes. ........ r7957 | twisti | 2007-05-23 20:28:01 + +0200 (Wed, 23 May 2007) | 2 lines + + * src/vm/jit/mips/Makefile.am (DIST_SUBDIRS): Added uclinux. + ........ r7958 | twisti | 2007-05-23 21:11:10 +0200 (Wed, 23 May + 2007) | 3 lines + + * src/vm/jit/powerpc64/linux/md-os.c + (md_critical_section_restart): Fixed typo. ........ r7959 | + twisti | 2007-05-23 21:37:26 +0200 (Wed, 23 May 2007) | 5 lines + + * src/threads/threads-common.h (THREAD_STATE_NEW) + (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING) + (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Start states + with 1, so we can catch unset states. ........ r7960 | twisti | + 2007-05-24 00:04:49 +0200 (Thu, 24 May 2007) | 2 lines + + * configure.ac (AM_INIT_AUTOMAKE): Added dist-bzip2. ........ + r7961 | ajordan | 2007-05-24 00:54:38 +0200 (Thu, 24 May 2007) | 4 + lines + + * src/vm/jit/sparc64/Makefile.am: md-asm.h was not properly + added to noinst_HEADERS. ........ r7962 | ajordan | 2007-05-24 + 01:56:59 +0200 (Thu, 24 May 2007) | 3 lines + + * src/vm/jit/sparc64/Makefile.am: Added missing emit.h. ........ + r7963 | twisti | 2007-05-24 12:21:16 +0200 (Thu, 24 May 2007) | 42 + lines + + * src/threads/threads-common.c (mm/memory.h): Added. + (toolbox/list.h): Likewise. (threads_table): Removed. + (list_threads, list_threads_free): Added. (threads_preinit): + Initialize lists. (threads_table_init): Removed. + (threads_table_add): Likewise. (threads_table_remove): Likewise. + (threads_table_get): Likewise. (threads_table_get_threads): + Likewise. (threads_table_get_non_daemons): Likewise. + (threads_table_first): Likewise. (threads_table_next): Likewise. + (threads_table_dump): Likewise. (threads_list_first): New + function. (threads_list_next): Likewise. + (threads_list_get_non_daemons): Likewise. (threads_thread_new): + Likewise. (threads_thread_free): Likewise. + (threads_thread_print_info): Added state-assert, print thread index. + (threads_thread_state_runnable): New function. + (threads_thread_state_waiting): Likewise. + (threads_thread_state_timed_waiting): Likewise. + (threads_thread_state_terminated): Likewise. (threads_dump): Use + threads-list functions. + + * src/threads/threads-common.h: Likewise. + (threads_table_entry_t): Removed. (threads_table_t): Likewise. + + * src/threads/native/threads.c (mutex_threads_table): Renamed to + mutex_threads_list. (threads_cast_sendsignals): Use threads-list + functions. (threads_table_lock): Renamed to threads_list_lock. + (threads_table_unlock): Renamed to threads_list_unlock. + (threads_startup_thread): Use threads-state functions. + (threads_detach_thread): Likewise. (threads_wait_with_timeout): + Likewise. (threads_join_all_threads): Use threads-list functions. + + * src/threads/native/threads.h (threadobject): Added linkage. + ........ r7964 | twisti | 2007-05-24 12:23:42 +0200 (Thu, 24 May + 2007) | 3 lines + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Fixed + warning. ........ r7965 | michi | 2007-05-24 15:25:41 +0200 (Thu, + 24 May 2007) | 3 lines + + * src/vmcore/linker.c (link_class_intern) [__ARM_EABI__]: Fixed + field alignment bug. Double and Long fields are 8-byte aligned + with EABI. ........ r7966 | pm | 2007-05-25 14:41:03 +0200 (Fri, + 25 May 2007) | 24 lines + + * src/vm/jit/show.h (show_filters_init, show_filters_apply, + show_filters_test_verbosecall_enter, + show_filters_test_verbosecall_exit): Added. + * src/vm/jit/show.c: Likewise. + * src/vm/jit/jit.c (jit_compile_intern): Honour filters. + * src/vm/jit/codegen-common.c (codegen_add_patch_ref, + codegen_generate_stub_native): Honour PATCHER_LONGBRANCHES_NOPS if + defined, honour filters. + * src/vm/builtin.c (builtin_trace_exception, + builtin_verbosecall_enter, builtin_verbosecall_exit): Honour + filters. + * src/vm/signal.c (signal_init): Register SIGILL handler on s390. + * src/vm/vm.c: Handle -XXfi, -XXfe, -XXfm commandline options. + * src/vm/signallocal.h (md_signal_handler_sigill): Forward declare on + s390. + * src/threads/none/threads.h (_no_threads_filterverbosecallctr, + FILTERVERBOSECALLCTR): Added. + * src/threads/native/threads.h (struct threadobject): Added + filterverbosecallctr. + * src/threads/native/threads.c (threads_impl_thread_new): Initialize + filterverbosecallctr. + * src/threads/critical.c (critical_comparator): On s390, clear bit 32 + of pointer when comparing. + * src/vmcore/options.h (opt_filter_verbosecall_include, + opt_filter_verbosecall_exclude, opt_filter_show_method): Added. + * src/vmcore/options.c: Likewise. + * src/vmcore/method.h (struct methodinfo): Added filtermatches. + * configure.ac: If no NDEBUG and regex.h header is present, define + ENABLE_DEBUG_FILTER. + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/tests/dacapo.status, src/vm/jit/s390/patcher.c: + Changed a lot. ........ r7967 | twisti | 2007-05-25 17:03:46 +0200 + (Fri, 25 May 2007) | 3 lines + + * src/vm/string.c (javastring_new_from_utf_buffer): Made static. + * src/vm/stringlocal.h (javastring_new_from_utf_buffer): Removed. + ........ r7968 | twisti | 2007-05-25 17:05:04 +0200 (Fri, 25 May + 2007) | 3 lines + + * src/vm/jit/powerpc/md.c (md_get_method_patch_address): Fixed + warning, use vm_abort. ........ r7969 | twisti | 2007-05-25 + 17:05:57 +0200 (Fri, 25 May 2007) | 3 lines + + * src/vm/jit/optimizing/ifconv.c (vm/vm.h): Added. + (ifconv_static): Fixed warning, use vm_abort. ........ r7970 | + twisti | 2007-05-25 17:23:56 +0200 (Fri, 25 May 2007) | 5 lines + + * src/threads/threads-common.c (threads_thread_start_internal) + [WITH_CLASSPATH_CLDC1_1]: Set name to NULL, but this needs a fix. + (threads_thread_print_info) [ENABLE_JAVAME_CLDC1_1]: Set name to + utf_null. ........ r7971 | pm | 2007-05-26 17:26:06 +0200 (Sat, 26 + May 2007) | 2 lines + + * contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to + determine endianess. ........ r7972 | ajordan | 2007-05-28 + 02:05:04 +0200 (Mon, 28 May 2007) | 11 lines + + * src/vm/jit/sparc64/codegen.h: Removed asserts for stores with + sethi. + + * src/vm/jit/sparc64/codegen.c: Added code to fill with nops when + a patcher is right at the end of a basic block. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method_end): Returning + 0 when an exception occurs. + + * src/vm/jit/sparc64/md.c (md_get_method_patch_address): Improved + handling of mptr loads when a sethi is involved. ........ r7973 + | twisti | 2007-05-29 11:03:56 +0200 (Tue, 29 May 2007) | 10 lines + + * src/vm/exceptions.c (exceptions_throw_illegalaccessexception): + Changed signature. + * src/vm/exceptions.h: Likewise. + + * src/vm/resolve.c (resolve_class_from_name): Make utf8-string out + of exception message. (resolve_subtype_check): Likewise. + (resolve_field_verifier_checks): Likewise. + (resolve_method_verifier_checks): Likewise. ........ r7974 | + twisti | 2007-05-29 13:30:20 +0200 (Tue, 29 May 2007) | 3 lines + + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed warnings, + some indent. ........ r7975 | pm | 2007-05-29 13:44:02 +0200 + (Tue, 29 May 2007) | 3 lines + + * src/vm/jit/show.c (vm/vm.h) add missing include, + (_no_threads_filterverbosecallctr) fix type: u2 instead of u4 + ........ r7976 | twisti | 2007-05-29 14:22:55 +0200 (Tue, 29 May + 2007) | 24 lines + + * src/vm/access.c (string.h): Added. (mm/memory.h): Likewise. + (vmcore/field.h): Likewise. (vmcore/method.h): Likewise. + (access_check_member): Removed. (access_check_field): New + function. (access_check_method): Likewise. + + * src/vm/access.h (vmcore/field.h): Added. (vmcore/method.h): + Likewise. (access_check_member): Removed. (access_check_field): + New function. (access_check_method): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): + Call access_check_method instead of access_check_member. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (cacao_get_field_address): Call access_check_field instead of + access_check_member. ........ r7977 | twisti | 2007-05-29 14:34:20 + +0200 (Tue, 29 May 2007) | 6 lines + + * src/vm/signal.c (signal_init): Changed signature. + * src/vm/signallocal.h (signal_init): Likewise. + + * src/vm/vm.c (vm_create): Call signal_init right after gc_init + and check return value. ........ r7978 | twisti | 2007-05-30 + 16:09:10 +0200 (Wed, 30 May 2007) | 7 lines + + * src/vm/signal.c (mm/boehm-gc/include/gc.h): Added. + (GC_suspend_handler): Defined. (GC_restart_handler): Likewise. + (signal_thread): Add the Boehm-GC signals to the mask and call the + appropriate Boehm-function. This is a workaround for the Boehm- + LinuxThreads bug. ........ r7979 | twisti | 2007-05-30 17:52:00 + +0200 (Wed, 30 May 2007) | 3 lines + + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed --disable- + debug build. ........ r7980 | twisti | 2007-05-30 18:01:09 +0200 + (Wed, 30 May 2007) | 4 lines + + * src/vm/jit/powerpc64/md.c (md_get_method_patch_address): Use + vm_abort and fixed warning. (md_codegen_get_pv_from_pc): Likewise. + ........ r7981 | twisti | 2007-05-30 21:43:36 +0200 (Wed, 30 May + 2007) | 9 lines + + * src/mm/boehm-gc/pthread_stop_world.c (cacao_suspendhandler): + Commented. (GC_suspend_handler): Commented cacao_suspendhandler + call. (GC_signum1, GC_signum2): Define for all configurations + (hope that works). + + * src/threads/native/threads.c: Commented all critical-sections + code, as it does not work anyway and it does not compile + everywhere. ........ r7982 | twisti | 2007-05-30 22:01:49 +0200 + (Wed, 30 May 2007) | 6 lines + + * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Fixed + typo. + + * src/vm/jit/powerpc64/emit.c [!NDEBUG] (emit_verbosecall_enter) + (emit_verbosecall_exit): Only compile conditionally. ........ + r7983 | twisti | 2007-05-30 22:04:42 +0200 (Wed, 30 May 2007) | 3 + lines + + * src/vm/resolve.c (resolve_subtype_check): Don't free the memory + before it's used. ........ r7984 | twisti | 2007-05-30 22:30:00 + +0200 (Wed, 30 May 2007) | 7 lines + + * src/threads/native/threads.c (threads_impl_preinit): Initialize + mutex_threads_list. (threads_impl_table_init): Removed. + (threads_impl_table_init, threads_list_unlock): Fixed debug message. + + * src/threads/threads-common.h (threads_impl_table_init): Removed. + ........ r7985 | twisti | 2007-05-30 22:40:23 +0200 (Wed, 30 May + 2007) | 3 lines + + * src/mm/boehm-gc/pthread_stop_world.c (GC_signum1, GC_signum2): + No it did not work, reverted rev7981. ........ r7986 | twisti | + 2007-05-30 22:45:43 +0200 (Wed, 30 May 2007) | 3 lines + + * src/vm/builtin.c (math.h): Removed because we don't need it as + we include fdlibm.h and it does not work on some OSs, like Darwin. + ........ r7987 | twisti | 2007-05-30 22:51:50 +0200 (Wed, 30 May + 2007) | 4 lines + + * src/vm/signal.c (signal_thread) [!__DARWIN__]: Don't do the + GC_signum stuff on Darwin (should also be done on Solaris, but let's + wait how the exact-GC is doing). ........ r7988 | twisti | + 2007-05-30 22:53:56 +0200 (Wed, 30 May 2007) | 4 lines + + * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin + /md-abi.h: Removed Contact, Authors, Changes from header. ........ + r7989 | twisti | 2007-05-30 23:04:42 +0200 (Wed, 30 May 2007) | 4 + lines + + * src/vm/jit/powerpc/asmpart.S [ENABLE_REPLACEMENT] (L_replace_me) + (L_replace_build_execution_state, L_replace_free_safestack): Only if + replacement is enabled, otherwise we get a linker error. ........ + r7990 | twisti | 2007-05-30 23:05:20 +0200 (Wed, 30 May 2007) | 3 + lines + + * src/vm/jit/powerpc/darwin/md-os.c + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. ........ r7991 | twisti | 2007-05-30 + 23:59:29 +0200 (Wed, 30 May 2007) | 3 lines + + * ChangeLog: Updated. + * ChangeLog-2006: New file. ........ r7992 | twisti | 2007-05-31 + 00:01:38 +0200 (Thu, 31 May 2007) | 2 lines + + * NEWS: Added some 0.98 release notes. ........ r7993 | twisti | + 2007-05-31 00:32:43 +0200 (Thu, 31 May 2007) | 2 lines + + * src/vm/jit/powerpc64/emit.c (emit_branch): Removed debug output. + ........ r7994 | twisti | 2007-05-31 18:10:58 +0200 (Thu, 31 May + 2007) | 2 lines + + * src/vm/vm.c (vm_create): Added comment. ........ r7995 | + twisti | 2007-06-01 00:45:19 +0200 (Fri, 01 Jun 2007) | 2 lines + + * src/vm/signal.c: Reverted rev7978. ........ r7996 | twisti | + 2007-06-01 01:05:51 +0200 (Fri, 01 Jun 2007) | 15 lines + + * m4/ac_pthreads_implementation.m4: New file. + + * m4/threads.m4 (AC_CHECK_ENABLE_THREADS): Call + AC_CHECK_PTHREADS_IMPLEMENTATION for posix and linux. + + * configure.ac (AC_CHECK_HEADERS): Added stdlib.h. + (AC_CHECK_FUNCS): Added confstr, strstr. + + * src/vm/signal.c (signal_init) [!PTHREADS_IS_LINUXTHREADS]: Only + block the signals if we are not on LinuxThreads. (signal_thread): + Set state accordingly. + + * src/vm/vm.c (vm_create) [!PTHREADS_IS_LINUXTHREADS]: Only start + signal-thread if we are not on LinuxThreads. ........ r7997 | + twisti | 2007-06-01 01:26:23 +0200 (Fri, 01 Jun 2007) | 5 lines + + * src/vm/jit/mips/irix/md-os.c (vm/jit/mips/codegen.h): Added. + (md_signal_handler_sigsegv): Updated to new exception-handling. + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. ........ r7998 | twisti | 2007-06-01 + 02:29:51 +0200 (Fri, 01 Jun 2007) | 16 lines + + * m4/ac_pthreads_implementation.m4: Reverted rev7996. + * m4/threads.m4: Likewise. + + * src/threads/threads-common.c [__LINUX__] + (threads_pthreads_implementation_nptl): Added. (threads_preinit) + [__LINUX__]: Check which thread-implementation we are using. + + * src/threads/threads-common.h [__LINUX__] + (threads_pthreads_implementation_nptl): Added. + + * src/vm/signal.c (signal_init) [__LINUX__]: Check for + threads_pthreads_implementation_nptl. + + * src/vm/vm.c (vm_create) [__LINUX__]: Likewise. ........ r7999 + | ajordan | 2007-06-01 02:45:04 +0200 (Fri, 01 Jun 2007) | 12 lines + + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed + the way float arguments are preserved over + codegen_start_native_call. + * src/vm/jit/sparc64/md-abi.c (codegen_start_native_call): Likewise. + + * src/vm/jit/sparc64/machine-instr.h (compare_and_swap): Changed + inline assembly, so it survives gcc optimization. + + * src/vm/jit/sparc64/asmpart.S (asm_patcher_wrapper): Saving and + restoring float return register. + * src/vm/jit/sparc64/md-asm.h: Likewise. ........ r8000 | ajordan | + 2007-06-01 21:34:56 +0200 (Fri, 01 Jun 2007) | 2 lines + + * src/vm/signal.c: Added ifdefs to fix compiling with disabled + threads. ........ r8001 | pm | 2007-06-02 19:47:30 +0200 (Sat, 02 + Jun 2007) | 9 lines + + * contrib/vmlog/vmlogfilter.c: Added a tool that filters a vmlog + log file the same way as -XXfi and -XXfx do. + + * contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h + (vmlog_thread_log_append): Made not-static. + + * contrib/vmlog/Makefile.am, configure.ac: Conditional building + of vmlogfilter if ENABLE_VMLOG is set and regex.h present. ........ + r8002 | pm | 2007-06-03 20:24:44 +0200 (Sun, 03 Jun 2007) | 2 lines + + * configure.ac: Fix broken regex.h test. ........ r8003 | twisti + | 2007-06-03 20:42:09 +0200 (Sun, 03 Jun 2007) | 16 lines + + * src/threads/threads-common.c (threads_thread_start_internal): + Changed order of initialization stuff, so we can leave the join- + mutex very early. (threads_thread_start): Likewise. + + * src/threads/native/threads.c (threads_mutex_join_lock): New + function. (threads_mutex_join_unlock): Likewise. + (threads_attach_current_thread): Changed order of initialization + stuff, so we can leave the join-mutex very early. + (threads_detach_thread): Send the signal inside the join-mutex. + (threads_join_all_threads): Use join-mutex functions. + + * src/threads/threads-common.h (threads_mutex_join_lock): Added. + (threads_mutex_join_unlock): Likewise. ........ r8004 | twisti | + 2007-06-04 14:59:04 +0200 (Mon, 04 Jun 2007) | 3 lines + + * src/vm/signal.c (signal_init): Use if-vm_abort instead of + assert. + * src/vm/exceptions.h: Changed hardware-exception comment accordingly. + ........ r8005 | twisti | 2007-06-04 15:12:56 +0200 (Mon, 04 Jun + 2007) | 9 lines + + * src/vm/signal.c (unistd.h): Removed. (sys/mman.h): Likewise. + (signal_init): Moved mmap of page 0x0 and the hardware-exceptions + check into exceptions_init. + + * src/vm/exceptions.c (unistd.h): Added. (sys/mman.h): Likewise. + (exceptions_init): See above. ........ r8006 | twisti | 2007-06-05 + 09:40:49 +0200 (Tue, 05 Jun 2007) | 20 lines + + * src/vmcore/statistics.c (count_calls_java_to_native): Added. + (count_calls_native_to_java): Likewise. + (count_native_function_calls): Removed. (nativeinvokation): + Likewise. (print_stats): Print new variables. + + * src/vmcore/statistics.h (count_calls_java_to_native): Added. + (count_calls_native_to_java): Likewise. (nativeinvokation): + Removed. + + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [ENABLE_STATISTICS]: Increase count_calls_java_to_native. + + * src/vm/vm.c (vm_call_method_vmarg) [ENABLE_STATISTICS]: Increase + count_calls_native_to_java. (vm_call_method_int_vmarg): Likewise. + (vm_call_method_long_vmarg): Likewise. + (vm_call_method_float_vmarg): Likewise. + (vm_call_method_double_vmarg): Likewise. ........ r8007 | twisti | + 2007-06-05 09:42:57 +0200 (Tue, 05 Jun 2007) | 2 lines + + * src/vm/vm.c (vmcore/statistics.h): Added. ........ r8008 | + twisti | 2007-06-05 09:44:38 +0200 (Tue, 05 Jun 2007) | 2 lines + + * src/vm/vm.c: Set Id keyword. ........ r8009 | twisti | + 2007-06-05 09:56:35 +0200 (Tue, 05 Jun 2007) | 2 lines + + * src/vm/jit/mips/codegen.c (codegen_emit): Small code-layout + change. ........ r8010 | twisti | 2007-06-05 11:00:30 +0200 (Tue, + 05 Jun 2007) | 3 lines + + * src/vm/jit/mips/codegen.c (codegen_emit): Use FLTMOVE and + DBLMOVE to save some moves. ........ r8011 | twisti | 2007-06-05 + 12:06:18 +0200 (Tue, 05 Jun 2007) | 12 lines + + * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 4]: + Use internally a different calling convention. It's the same as on + n64 with register skipping and, but with long alignment (as on + ARM). (md_param_alloc_native) [SIZEOF_VOID_P == 4]: Use the o32 + ABI. + + * src/vm/jit/mips/codegen.c (codegen_emit) [SIZEOF_VOID_P == 4]: + Changes for new internal calling conventions. + (codegen_emit_stub_native) [SIZEOF_VOID_P == 4]: Likewise. + + * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [SIZEOF_VOID_P == + 4]: Adjusted reserved stack-space to 4*4. ........ r8012 | + twisti | 2007-06-05 12:14:29 +0200 (Tue, 05 Jun 2007) | 3 lines + + * src/vm/jit/mips/md-abi.c (md_param_alloc_native) + [SIZEOF_VOID_P == 8]: Fixed compilation. ........ r8013 | twisti | + 2007-06-05 12:19:09 +0200 (Tue, 05 Jun 2007) | 3 lines + + * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 8]: + Use reguse instead of i. ........ r8014 | twisti | 2007-06-05 + 14:53:30 +0200 (Tue, 05 Jun 2007) | 3 lines + + * src/vm/jit/codegen-common.c [__ARM__] (md-abi.h): Removed. + (codegen_reg_of_var) [__ARM__]: Removed split-code. ........ r8015 + | twisti | 2007-06-05 22:58:11 +0200 (Tue, 05 Jun 2007) | 10 lines + + * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): + Removed sun_misc_Unsafe.c. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (SUN_MISC_UNSAFE_SOURCES): Added. (libnativevm_la_SOURCES): + Added SUN_MISC_UNSAFE_SOURCES. + + * src/native/vm/gnu/sun_misc_Unsafe.c: Removed. + * src/native/vm/sun_misc_Unsafe.c: Added. ........ r8016 | twisti | + 2007-06-06 00:11:12 +0200 (Wed, 06 Jun 2007) | 5 lines + + * src/native/native.c (native_init): Check nativevm_init return + value. + + * src/native/vm/nativevm.c (nativevm_init): Changed signature. + * src/native/vm/nativevm.h (nativevm_init): Likewise. ........ r8017 + | twisti | 2007-06-06 01:46:59 +0200 (Wed, 06 Jun 2007) | 10 lines + + * src/native/vm/gnu/java_lang_VMString.c + (native/vm/java_lang_String.h): Added. (intern): Call + _Jv_java_lang_String_intern. + + * src/native/vm/java_lang_String.c: New file. + * src/native/vm/java_lang_String.h: Likewise. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + java_lang_String.[ch]. ........ r8018 | twisti | 2007-06-06 + 11:24:22 +0200 (Wed, 06 Jun 2007) | 2 lines + + * configure.ac (AC_INIT): Changed version to 0.98. ........ + r8019 | twisti | 2007-06-06 11:26:00 +0200 (Wed, 06 Jun 2007) | 2 + lines + + * ChangeLog: Updated. ........ r8022 | twisti | 2007-06-06 + 13:31:28 +0200 (Wed, 06 Jun 2007) | 3 lines + + * configure.ac (AC_INIT): Changed version to 0.98+svn. + (OPT_CFLAGS): Changed to -O0. ........ r8023 | twisti | 2007-06-06 + 19:19:17 +0200 (Wed, 06 Jun 2007) | 2 lines + + * NEWS: Fixed 0.98 release date. ........ r8024 | twisti | + 2007-06-06 19:23:42 +0200 (Wed, 06 Jun 2007) | 8 lines + + * src/vmcore/class.c (class_is_primitive): New function. + * src/vmcore/class.h (class_is_primitive): Added. + + * src/native/vm/java_lang_Class.c (isPrimitive): Use + class_is_primitive. (getDeclaringClass): Likewise. + (getDeclaredClasses): Likewise. ........ r8025 | michi | + 2007-06-07 10:51:54 +0200 (Thu, 07 Jun 2007) | 8 lines + + * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT, + HAS_ADDRESS_REGISTER_FILE]: Added savedadrcount. + + * src/vm/jit/replace.c [HAS_ADDRESS_REGISTER_FILE]: Added support + for address registers. + + * src/vm/jit/replace.h [HAS_ADDRESS_REGISTER_FILE]: Likewise. + ........ r8026 | twisti | 2007-06-07 11:04:51 +0200 (Thu, 07 Jun + 2007) | 15 lines + + * src/native/vm/gnu/java_lang_reflect_Constructor.c (methods): + Install _Jv_- functions directly. (getModifiersInternal): + Removed. (getParameterTypes): Likewise. (getExceptionTypes): + Likewise. (constructNative): Call + _Jv_java_lang_reflect_Constructor_newInstance. (getSignature): + Removed. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES): Added. + (libnativevm_la_SOURCES): Added + JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES. + + * src/native/vm/java_lang_reflect_Constructor.c: New file. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. ........ + [f14d326b56fe] + +2007-06-07 twisti + + * src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.c, + src/native/vm/java_lang_reflect_Constructor.h: + * src/native/vm/gnu/java_lang_reflect_Constructor.c (methods): + Install _Jv_- functions directly. (getModifiersInternal): Removed. + (getParameterTypes): Likewise. (getExceptionTypes): Likewise. + (constructNative): Call + _Jv_java_lang_reflect_Constructor_newInstance. (getSignature): + Removed. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES): Added. + (libnativevm_la_SOURCES): Added + JAVA_LANG_REFLECT_CONSTRUCTOR_SOURCES. + + * src/native/vm/java_lang_reflect_Constructor.c: New file. + * src/native/vm/java_lang_reflect_Constructor.h: Likewise. + [6960350b0edd] + +2007-06-07 michi + + * src/vm/jit/code.h, src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/code.h (codeinfo) [ENABLE_REPLACEMENT, + HAS_ADDRESS_REGISTER_FILE]: Added savedadrcount. + + * src/vm/jit/replace.c [HAS_ADDRESS_REGISTER_FILE]: Added support + for address registers. + + * src/vm/jit/replace.h [HAS_ADDRESS_REGISTER_FILE]: Likewise. + [4a6ecb69f8b5] + +2007-06-06 twisti + + * src/native/vm/java_lang_Class.c, src/vmcore/class.c, + src/vmcore/class.h: + * src/vmcore/class.c (class_is_primitive): New function. + * src/vmcore/class.h (class_is_primitive): Added. + + * src/native/vm/java_lang_Class.c (isPrimitive): Use + class_is_primitive. (getDeclaringClass): Likewise. + (getDeclaredClasses): Likewise. + [7a59a4145783] + + * NEWS: + * NEWS: Fixed 0.98 release date. + [eef3556c431c] + + * configure.ac: + * configure.ac (AC_INIT): Changed version to 0.98+svn. (OPT_CFLAGS): + Changed to -O0. + [98ba45471b0c] + + * ChangeLog: + * ChangeLog: Updated. + [430cdebdf7d1] [cacao-0.98] + + * configure.ac: + * configure.ac (AC_INIT): Changed version to 0.98. + [55dc961e7162] + +2007-06-05 twisti + + * src/native/vm/Makefile.am, src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/java_lang_String.c, src/native/vm/java_lang_String.h: + * src/native/vm/gnu/java_lang_VMString.c + (native/vm/java_lang_String.h): Added. (intern): Call + _Jv_java_lang_String_intern. + + * src/native/vm/java_lang_String.c: New file. + * src/native/vm/java_lang_String.h: Likewise. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + java_lang_String.[ch]. + [5d0584628b96] + + * src/native/native.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h: + * src/native/native.c (native_init): Check nativevm_init return + value. + + * src/native/vm/nativevm.c (nativevm_init): Changed signature. + * src/native/vm/nativevm.h (nativevm_init): Likewise. + [757bca0bff3a] + + * src/native/vm/Makefile.am, src/native/vm/gnu/Makefile.am, + src/native/vm/gnu/sun_misc_Unsafe.c, + src/native/vm/sun_misc_Unsafe.c: + * src/native/vm/gnu/Makefile.am (libnativevmcore_la_SOURCES): + Removed sun_misc_Unsafe.c. + + * src/native/vm/Makefile.am [ENABLE_JAVASE] + (SUN_MISC_UNSAFE_SOURCES): Added. (libnativevm_la_SOURCES): Added + SUN_MISC_UNSAFE_SOURCES. + + * src/native/vm/gnu/sun_misc_Unsafe.c: Removed. + * src/native/vm/sun_misc_Unsafe.c: Added. + [95d583480799] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c [__ARM__] (md-abi.h): Removed. + (codegen_reg_of_var) [__ARM__]: Removed split-code. + [3ab646d8b0e1] + + * src/vm/jit/mips/md-abi.c: + * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 8]: + Use reguse instead of i. + [643220e47422] + + * src/vm/jit/mips/md-abi.c: + * src/vm/jit/mips/md-abi.c (md_param_alloc_native) [SIZEOF_VOID_P == + 8]: Fixed compilation. + [5f2d418385a3] + + * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/md-abi.c: + * src/vm/jit/mips/md-abi.c (md_param_alloc) [SIZEOF_VOID_P == 4]: + Use internally a different calling convention. It's the same as on + n64 with register skipping and, but with long alignment (as on ARM). + (md_param_alloc_native) [SIZEOF_VOID_P == 4]: Use the o32 ABI. + + * src/vm/jit/mips/codegen.c (codegen_emit) [SIZEOF_VOID_P == 4]: + Changes for new internal calling conventions. + (codegen_emit_stub_native) [SIZEOF_VOID_P == 4]: Likewise. + + * src/vm/jit/mips/asmpart.S (asm_vm_call_method) [SIZEOF_VOID_P == + 4]: Adjusted reserved stack-space to 4*4. + [f3dfa2fb1f08] + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit): Use FLTMOVE and DBLMOVE + to save some moves. + [6e02854739d1] + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit): Small code-layout + change. + [397770a510c4] + + * src/vm/vm.c: + * src/vm/vm.c: Set Id keyword. + [d1945a7fc00f] + + * src/vm/vm.c: + * src/vm/vm.c (vmcore/statistics.h): Added. + [a834dcae9a0b] + + * src/vm/jit/codegen-common.c, src/vm/vm.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vmcore/statistics.c (count_calls_java_to_native): Added. + (count_calls_native_to_java): Likewise. + (count_native_function_calls): Removed. (nativeinvokation): + Likewise. (print_stats): Print new variables. + + * src/vmcore/statistics.h (count_calls_java_to_native): Added. + (count_calls_native_to_java): Likewise. (nativeinvokation): Removed. + + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [ENABLE_STATISTICS]: Increase count_calls_java_to_native. + + * src/vm/vm.c (vm_call_method_vmarg) [ENABLE_STATISTICS]: Increase + count_calls_native_to_java. (vm_call_method_int_vmarg): Likewise. + (vm_call_method_long_vmarg): Likewise. (vm_call_method_float_vmarg): + Likewise. (vm_call_method_double_vmarg): Likewise. + [cbcd525d01cc] + +2007-06-04 twisti + + * src/vm/exceptions.c, src/vm/signal.c: + * src/vm/signal.c (unistd.h): Removed. (sys/mman.h): Likewise. + (signal_init): Moved mmap of page 0x0 and the hardware-exceptions + check into exceptions_init. + + * src/vm/exceptions.c (unistd.h): Added. (sys/mman.h): Likewise. + (exceptions_init): See above. + [ef8a5cde695e] + + * src/vm/exceptions.h, src/vm/signal.c: + * src/vm/signal.c (signal_init): Use if-vm_abort instead of assert. + * src/vm/exceptions.h: Changed hardware-exception comment accordingly. + [d6d44453fb52] + +2007-06-03 twisti + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h: + * src/threads/threads-common.c (threads_thread_start_internal): + Changed order of initialization stuff, so we can leave the join- + mutex very early. (threads_thread_start): Likewise. + + * src/threads/native/threads.c (threads_mutex_join_lock): New + function. (threads_mutex_join_unlock): Likewise. + (threads_attach_current_thread): Changed order of initialization + stuff, so we can leave the join-mutex very early. + (threads_detach_thread): Send the signal inside the join-mutex. + (threads_join_all_threads): Use join-mutex functions. + + * src/threads/threads-common.h (threads_mutex_join_lock): Added. + (threads_mutex_join_unlock): Likewise. + [31785a69c5f9] + +2007-06-03 pm + + * configure.ac: + * configure.ac: Fix broken regex.h test. + [5f7300fa2cb5] + +2007-06-02 pm + + * configure.ac, contrib/vmlog/Makefile.am, contrib/vmlog/vmlog.c, + contrib/vmlog/vmlog.h, contrib/vmlog/vmlogfilter.c: + * contrib/vmlog/vmlogfilter.c: Added a tool that filters a vmlog log + file the same way as -XXfi and -XXfx do. + + * contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h + (vmlog_thread_log_append): Made not-static. + + * contrib/vmlog/Makefile.am, configure.ac: Conditional building of + vmlogfilter if ENABLE_VMLOG is set and regex.h present. + [2903e00a87aa] + +2007-06-01 ajordan + + * src/vm/signal.c: + * src/vm/signal.c: Added ifdefs to fix compiling with disabled + threads. + [fa34a45c2d1e] + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/machine-instr.h, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md-asm.h: + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed the + way float arguments are preserved over codegen_start_native_call. + * src/vm/jit/sparc64/md-abi.c (codegen_start_native_call): Likewise. + + * src/vm/jit/sparc64/machine-instr.h (compare_and_swap): Changed + inline assembly, so it survives gcc optimization. + + * src/vm/jit/sparc64/asmpart.S (asm_patcher_wrapper): Saving and + restoring float return register. + * src/vm/jit/sparc64/md-asm.h: Likewise. + [02b890228951] + +2007-06-01 twisti + + * m4/ac_pthreads_implementation.m4, m4/threads.m4, src/threads + /threads-common.c, src/threads/threads-common.h, src/vm/signal.c, + src/vm/vm.c: + * m4/ac_pthreads_implementation.m4: Reverted rev7996. + * m4/threads.m4: Likewise. + + * src/threads/threads-common.c [__LINUX__] + (threads_pthreads_implementation_nptl): Added. (threads_preinit) + [__LINUX__]: Check which thread-implementation we are using. + + * src/threads/threads-common.h [__LINUX__] + (threads_pthreads_implementation_nptl): Added. + + * src/vm/signal.c (signal_init) [__LINUX__]: Check for + threads_pthreads_implementation_nptl. + + * src/vm/vm.c (vm_create) [__LINUX__]: Likewise. + [87faa8691e61] + +2007-05-31 twisti + + * src/vm/jit/mips/irix/md-os.c: + * src/vm/jit/mips/irix/md-os.c (vm/jit/mips/codegen.h): Added. + (md_signal_handler_sigsegv): Updated to new exception-handling. + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. + [2a7547f40594] + + * configure.ac, m4/ac_pthreads_implementation.m4, m4/threads.m4, + src/vm/signal.c, src/vm/vm.c: + * m4/ac_pthreads_implementation.m4: New file. + + * m4/threads.m4 (AC_CHECK_ENABLE_THREADS): Call + AC_CHECK_PTHREADS_IMPLEMENTATION for posix and linux. + + * configure.ac (AC_CHECK_HEADERS): Added stdlib.h. (AC_CHECK_FUNCS): + Added confstr, strstr. + + * src/vm/signal.c (signal_init) [!PTHREADS_IS_LINUXTHREADS]: Only + block the signals if we are not on LinuxThreads. (signal_thread): + Set state accordingly. + + * src/vm/vm.c (vm_create) [!PTHREADS_IS_LINUXTHREADS]: Only start + signal-thread if we are not on LinuxThreads. + [80c6b89148d7] + + * src/vm/signal.c: + * src/vm/signal.c: Reverted rev7978. + [6e1ee16a0ebd] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Added comment. + [3860a183b0cb] + +2007-05-30 twisti + + * src/vm/jit/powerpc64/emit.c: + * src/vm/jit/powerpc64/emit.c (emit_branch): Removed debug output. + [a2b2fb137c74] + + * NEWS: + * NEWS: Added some 0.98 release notes. + [c990ac936f72] + + * ChangeLog, ChangeLog-2006: + * ChangeLog: Updated. + * ChangeLog-2006: New file. + [2eed586043b9] + + * src/vm/jit/powerpc/darwin/md-os.c: + * src/vm/jit/powerpc/darwin/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [948ea5d4594b] + + * src/vm/jit/powerpc/asmpart.S: + * src/vm/jit/powerpc/asmpart.S [ENABLE_REPLACEMENT] (L_replace_me) + (L_replace_build_execution_state, L_replace_free_safestack): Only if + replacement is enabled, otherwise we get a linker error. + [01bba61ca238] + + * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md- + abi.h: + * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md- + abi.h: Removed Contact, Authors, Changes from header. + [bf03068d9128] + + * src/vm/signal.c: + * src/vm/signal.c (signal_thread) [!__DARWIN__]: Don't do the + GC_signum stuff on Darwin (should also be done on Solaris, but let's + wait how the exact-GC is doing). + [84f89c49bbb4] + + * src/vm/builtin.c: + * src/vm/builtin.c (math.h): Removed because we don't need it as we + include fdlibm.h and it does not work on some OSs, like Darwin. + [bd9c55a421a3] + + * src/mm/boehm-gc/pthread_stop_world.c: + * src/mm/boehm-gc/pthread_stop_world.c (GC_signum1, GC_signum2): No + it did not work, reverted rev7981. + [1a4919b18fd5] + + * src/threads/native/threads.c, src/threads/threads-common.h: + * src/threads/native/threads.c (threads_impl_preinit): Initialize + mutex_threads_list. (threads_impl_table_init): Removed. + (threads_impl_table_init, threads_list_unlock): Fixed debug message. + + * src/threads/threads-common.h (threads_impl_table_init): Removed. + [e361eaf3e9ab] + + * src/vm/resolve.c: + * src/vm/resolve.c (resolve_subtype_check): Don't free the memory + before it's used. + [52dbef0b9bb3] + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c: + * src/vm/jit/powerpc64/codegen.c (codegen_emit_stub_native): Fixed + typo. + + * src/vm/jit/powerpc64/emit.c [!NDEBUG] (emit_verbosecall_enter) + (emit_verbosecall_exit): Only compile conditionally. + [5c9b9bf65ba8] + + * src/mm/boehm-gc/pthread_stop_world.c, src/threads/native/threads.c: + * src/mm/boehm-gc/pthread_stop_world.c (cacao_suspendhandler): + Commented. (GC_suspend_handler): Commented cacao_suspendhandler + call. (GC_signum1, GC_signum2): Define for all configurations (hope + that works). + + * src/threads/native/threads.c: Commented all critical-sections + code, as it does not work anyway and it does not compile everywhere. + [77e8f7fc7c33] + + * src/vm/jit/powerpc64/md.c: + * src/vm/jit/powerpc64/md.c (md_get_method_patch_address): Use + vm_abort and fixed warning. (md_codegen_get_pv_from_pc): Likewise. + [01f38d93be79] + + * src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed --disable- + debug build. + [c4fa7f33ae53] + + * src/vm/signal.c: + * src/vm/signal.c (mm/boehm-gc/include/gc.h): Added. + (GC_suspend_handler): Defined. (GC_restart_handler): Likewise. + (signal_thread): Add the Boehm-GC signals to the mask and call the + appropriate Boehm-function. This is a workaround for the Boehm- + LinuxThreads bug. + [40593e6fd1fc] + +2007-05-29 twisti + + * src/vm/signal.c, src/vm/signallocal.h, src/vm/vm.c: + * src/vm/signal.c (signal_init): Changed signature. + * src/vm/signallocal.h (signal_init): Likewise. + + * src/vm/vm.c (vm_create): Call signal_init right after gc_init and + check return value. + [ad80c85a863f] + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c, + src/vm/access.h: + * src/vm/access.c (string.h): Added. (mm/memory.h): Likewise. + (vmcore/field.h): Likewise. (vmcore/method.h): Likewise. + (access_check_member): Removed. (access_check_field): New function. + (access_check_method): Likewise. + + * src/vm/access.h (vmcore/field.h): Added. (vmcore/method.h): + Likewise. (access_check_member): Removed. (access_check_field): New + function. (access_check_method): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): Call + access_check_method instead of access_check_member. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Field.c + (cacao_get_field_address): Call access_check_field instead of + access_check_member. + [bb462c48ac9e] + +2007-05-29 pm + + * src/vm/jit/show.c: + * src/vm/jit/show.c (vm/vm.h) add missing include, + (_no_threads_filterverbosecallctr) fix type: u2 instead of u4 + [e78f2ffacfe6] + +2007-05-29 twisti + + * src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Fixed warnings, + some indent. + [d1845bf4f0b3] + + * src/vm/exceptions.c, src/vm/exceptions.h, src/vm/resolve.c: + * src/vm/exceptions.c (exceptions_throw_illegalaccessexception): + Changed signature. + * src/vm/exceptions.h: Likewise. + + * src/vm/resolve.c (resolve_class_from_name): Make utf8-string out + of exception message. (resolve_subtype_check): Likewise. + (resolve_field_verifier_checks): Likewise. + (resolve_method_verifier_checks): Likewise. + [7972804c2663] + +2007-05-28 ajordan + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/md.c: + * src/vm/jit/sparc64/codegen.h: Removed asserts for stores with + sethi. + + * src/vm/jit/sparc64/codegen.c: Added code to fill with nops when a + patcher is right at the end of a basic block. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method_end): Returning 0 + when an exception occurs. + + * src/vm/jit/sparc64/md.c (md_get_method_patch_address): Improved + handling of mptr loads when a sethi is involved. + [d069ba5f06d5] + +2007-05-26 pm + + * contrib/vmlog/vmlog.c: + * contrib/vmlog/vmlog.c: Use autoconf define WORDS_BIGENDIAN to + determine endianess. + [3e68881c72bf] + +2007-05-25 twisti + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_thread_start_internal) + [WITH_CLASSPATH_CLDC1_1]: Set name to NULL, but this needs a fix. + (threads_thread_print_info) [ENABLE_JAVAME_CLDC1_1]: Set name to + utf_null. + [2dd12a05fb5c] + + * src/vm/jit/optimizing/ifconv.c: + * src/vm/jit/optimizing/ifconv.c (vm/vm.h): Added. (ifconv_static): + Fixed warning, use vm_abort. + [bb500a776fbe] + + * src/vm/jit/powerpc/md.c: + * src/vm/jit/powerpc/md.c (md_get_method_patch_address): Fixed + warning, use vm_abort. + [74ab9b837f4c] + + * src/vm/string.c, src/vm/stringlocal.h: + * src/vm/string.c (javastring_new_from_utf_buffer): Made static. + * src/vm/stringlocal.h (javastring_new_from_utf_buffer): Removed. + [c65dcab97e76] + +2007-05-25 pm + + * configure.ac, src/threads/critical.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/vm/builtin.c, src/vm/jit/codegen-common.c, src/vm/jit/jit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c, src/vm/jit/s390/tests/dacapo.status, + src/vm/jit/show.c, src/vm/jit/show.h, src/vm/signal.c, + src/vm/signallocal.h, src/vm/vm.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/show.h (show_filters_init, show_filters_apply, + show_filters_test_verbosecall_enter, + show_filters_test_verbosecall_exit): Added. + * src/vm/jit/show.c: Likewise. + * src/vm/jit/jit.c (jit_compile_intern): Honour filters. + * src/vm/jit/codegen-common.c (codegen_add_patch_ref, + codegen_generate_stub_native): Honour PATCHER_LONGBRANCHES_NOPS if + defined, honour filters. + * src/vm/builtin.c (builtin_trace_exception, + builtin_verbosecall_enter, builtin_verbosecall_exit): Honour + filters. + * src/vm/signal.c (signal_init): Register SIGILL handler on s390. + * src/vm/vm.c: Handle -XXfi, -XXfe, -XXfm commandline options. + * src/vm/signallocal.h (md_signal_handler_sigill): Forward declare on + s390. + * src/threads/none/threads.h (_no_threads_filterverbosecallctr, + FILTERVERBOSECALLCTR): Added. + * src/threads/native/threads.h (struct threadobject): Added + filterverbosecallctr. + * src/threads/native/threads.c (threads_impl_thread_new): Initialize + filterverbosecallctr. + * src/threads/critical.c (critical_comparator): On s390, clear bit 32 + of pointer when comparing. + * src/vmcore/options.h (opt_filter_verbosecall_include, + opt_filter_verbosecall_exclude, opt_filter_show_method): Added. + * src/vmcore/options.c: Likewise. + * src/vmcore/method.h (struct methodinfo): Added filtermatches. + * configure.ac: If no NDEBUG and regex.h header is present, define + ENABLE_DEBUG_FILTER. + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/tests/dacapo.status, src/vm/jit/s390/patcher.c: + Changed a lot. + [606e1b6afbeb] + +2007-05-24 michi + + * src/vmcore/linker.c: + * src/vmcore/linker.c (link_class_intern) [__ARM_EABI__]: Fixed + field alignment bug. Double and Long fields are 8-byte aligned with + EABI. + [c57105969efc] + +2007-05-24 twisti + + * src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): Fixed + warning. + [9841538af60f] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.c (mm/memory.h): Added. + (toolbox/list.h): Likewise. (threads_table): Removed. (list_threads, + list_threads_free): Added. (threads_preinit): Initialize lists. + (threads_table_init): Removed. (threads_table_add): Likewise. + (threads_table_remove): Likewise. (threads_table_get): Likewise. + (threads_table_get_threads): Likewise. + (threads_table_get_non_daemons): Likewise. (threads_table_first): + Likewise. (threads_table_next): Likewise. (threads_table_dump): + Likewise. (threads_list_first): New function. (threads_list_next): + Likewise. (threads_list_get_non_daemons): Likewise. + (threads_thread_new): Likewise. (threads_thread_free): Likewise. + (threads_thread_print_info): Added state-assert, print thread index. + (threads_thread_state_runnable): New function. + (threads_thread_state_waiting): Likewise. + (threads_thread_state_timed_waiting): Likewise. + (threads_thread_state_terminated): Likewise. (threads_dump): Use + threads-list functions. + + * src/threads/threads-common.h: Likewise. (threads_table_entry_t): + Removed. (threads_table_t): Likewise. + + * src/threads/native/threads.c (mutex_threads_table): Renamed to + mutex_threads_list. (threads_cast_sendsignals): Use threads-list + functions. (threads_table_lock): Renamed to threads_list_lock. + (threads_table_unlock): Renamed to threads_list_unlock. + (threads_startup_thread): Use threads-state functions. + (threads_detach_thread): Likewise. (threads_wait_with_timeout): + Likewise. (threads_join_all_threads): Use threads-list functions. + + * src/threads/native/threads.h (threadobject): Added linkage. + [7119004b7671] + +2007-05-23 ajordan + + * src/vm/jit/sparc64/Makefile.am: + * src/vm/jit/sparc64/Makefile.am: Added missing emit.h. + [d043608db272] + + * src/vm/jit/sparc64/Makefile.am: + * src/vm/jit/sparc64/Makefile.am: md-asm.h was not properly added to + noinst_HEADERS. + [a888e4ae3e58] + +2007-05-23 twisti + + * configure.ac: + * configure.ac (AM_INIT_AUTOMAKE): Added dist-bzip2. + [b4f4c4d4a840] + + * src/threads/threads-common.h: + * src/threads/threads-common.h (THREAD_STATE_NEW) + (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING) + (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Start states + with 1, so we can catch unset states. + [a1aa7edd50d1] + + * src/vm/jit/powerpc64/linux/md-os.c: + * src/vm/jit/powerpc64/linux/md-os.c (md_critical_section_restart): + Fixed typo. + [5e15a6dbd074] + + * src/vm/jit/mips/Makefile.am: + * src/vm/jit/mips/Makefile.am (DIST_SUBDIRS): Added uclinux. + [4dc3d033c6ec] + + * src/vmcore/statistics.c: + * src/vmcore/statistics.c (statistics_print_memory_usage): Smaller + output changes. + [8f1740856eee] + + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/arm/linux/md-os.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/x86_64/linux/md-os.c + (md_critical_section_restart): Removed debug output. + [ad67481e544b] + + * src/threads/native/lock.c, src/threads/native/lock.h: + * src/threads/native/lock.c: Set Id keyword. + * src/threads/native/lock.h: Likewise. + [88a0496626f3] + + * src/native/vm/gnu/java_lang_VMClassLoader.c: + * src/native/vm/gnu/java_lang_VMClassLoader.c (getPrimitiveClass): + Return NULL in error case. + [fbb5d46a541f] + + * src/vm/jit/optimizing/profile.c: + * src/vm/jit/optimizing/profile.c: Set Id keyword. + [11900f141992] + + * src/vm/jit/optimizing/profile.c: + * src/vm/jit/optimizing/profile.c (profile_thread): Replaced table- + with list-functions. + [ede8f3f4cb22] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Use vm_abort for profile_start_thread. + [ed4f1df2d4de] + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_compile_intern): Fixed typo. + [73e13518e0df] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_new_hardware_exception): Fixed + warning. + [679f3b09928b] + + * src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c: + * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Fixed + warning. + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigsegv): + Likewise. + [215c17677a9c] + + * configure.ac: + * configure.ac (OPT_CFLAGS): Changed to -O2. + [a6ea45496841] + + * src/vm/jit/emit-common.h, src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (codegen_emit): ICMD_INSTANCEOF: + Removed unused supervftbl. + + * src/vm/jit/emit-common.h [__POWERPC64__] (emit_bnan): Enabled. + [8db39c7b9644] + +2007-05-23 tbfg + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c: + * src/vm/jit/powerpc64/emit.c (MCODECHECK): Increase values to fix + canary corruption. + * src/vm/jit/powerpc64/codegen.c (MCODECHECK): Increase values to fix + canary corruption. + [595305514350] + +2007-05-23 twisti + + * src/vmcore/linker.c: + * src/vmcore/linker.c (linker_compute_subclasses): We don't ship the + critical-section stuff with this release, since it's broken on some + architectures because of boehm. + [e817500e30d3] + + * src/vm/exceptions.c, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vm/exceptions.c (threads/lock-common.h): Added. + [ENABLE_THREADS] (threads/native/threads.h): Removed. + [!ENABLE_THREADS] (threads/none/threads.h): Likewise. (threads + /threads-common.h): Added. (new_exception_message): Removed. + (exceptions_throw_classcircularityerror): Use + exceptions_throw_utf_utf. (exceptions_throw_classformaterror): + Likewise. (classnotfoundexception_to_noclassdeffounderror): Fixed + warning. (exceptions_throw_incompatibleclasschangeerror): Use + exceptions_throw_utf_utf. (exceptions_throw_internalerror): + Likewise. (exceptions_throw_unsupportedclassversionerror): Likewise. + (exceptions_throw_verifyerror): Likewise. + (exceptions_throw_verifyerror_for_stack): Likewise. + (exceptions_new_arithmeticexception): Likewise. + (exceptions_new_classcastexception): Use exceptions_new_class_utf. + (exceptions_print_exception): Fixed warnings. + + * src/vmcore/utf8.c (utf_division_by_zero): Added. (utf8_init): + Likewise. + + * src/vmcore/utf8.h (utf_division_by_zero): Likewise. + [b52c2cca5b7d] + + * src/native/native.c, src/native/native.h, src/vm/exceptions.c, + src/vm/exceptions.h: + * src/vm/exceptions.c (new_exception_int): Removed. + * src/vm/exceptions.h (new_exception_int): Likewise. + + * src/native/native.c (native_new_and_init_int): Likewise. + * src/native/native.h (native_new_and_init_int): Likewise. + [6992a69c370d] + +2007-05-23 michi + + * src/native/include/Makefile.am, src/native/jni.c, src/vm/global.h, + src/vm/jit/abi.h, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/arm/patcher.c, src/vm/jit/codegen-common.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/patcher.c, src/vm/jit/x86_64/md.c: + Merged revisions 7918-7939 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7926 | twisti | 2007-05-21 10:27:06 +0200 (Mon, 21 May + 2007) | 12 lines + + * src/native/jni.c (_Jv_jni_CallLongMethodA): New function. + (_Jv_jni_CallFloatMethodA): Likewise. (_Jv_jni_CallDoubleMethodA): + Likewise. (_Jv_JNI_CallStaticBooleanMethodA): Implemented. + (_Jv_JNI_CallStaticByteMethodA): Likewise. + (_Jv_JNI_CallStaticCharMethodA): Likewise. + (_Jv_JNI_CallStaticShortMethodA): Likewise. + (_Jv_JNI_CallStaticIntMethodA): Likewise. + (_Jv_JNI_CallStaticLongMethodA): Likewise. + (_Jv_JNI_CallStaticFloatMethodA): Likewise. + (_Jv_JNI_CallStaticDoubleMethodA): Likewise. ........ r7927 | + twisti | 2007-05-21 10:48:46 +0200 (Mon, 21 May 2007) | 3 lines + + * src/native/include/Makefile.am (CLEANFILES): Simply clean an *.h + files. ........ r7929 | michi | 2007-05-21 13:45:31 +0200 (Mon, 21 + May 2007) | 8 lines + + * src/vm/jit/arm/codegen.h (M_EORLE): Added. + + * src/vm/jit/arm/codegen.c (codegen_emit): Fixed superindex + overflow for ICMD_INSTANCEOF and ICMD_CHECKCAST. + + * src/vm/jit/arm/patcher.c + (patcher_checkcast_instanceof_interface): Adapted patcher to above + changes. ........ r7930 | twisti | 2007-05-21 16:40:32 +0200 (Mon, + 21 May 2007) | 2 lines + + * src/vm/global.h (ALIGN_2): Added. ........ r7931 | twisti | + 2007-05-21 16:42:28 +0200 (Mon, 21 May 2007) | 6 lines + + * src/vm/jit/arm/md-abi.c (md_param_alloc): Use EABI internally. + (ALIGN_2): Removed. + + * src/vm/jit/arm/codegen.c (codegen_emit): Removed SPLIT-stuff. + * src/vm/jit/arm/emit.c (emit_store): Likewise. ........ r7932 | + michi | 2007-05-22 09:00:57 +0200 (Tue, 22 May 2007) | 3 lines + + * src/vm/jit/arm/md-abi.c (md_param_alloc): Align stack arguments + as well. + * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Use EABI internally. + ........ r7933 | michi | 2007-05-22 09:21:08 +0200 (Tue, 22 May + 2007) | 2 lines + + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Removed obsolete + SPLIT-stuff. ........ r7934 | michi | 2007-05-22 12:07:21 +0200 + (Tue, 22 May 2007) | 2 lines + + * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed + obsolete SPLIT-stuff. ........ r7935 | twisti | 2007-05-22 + 13:18:15 +0200 (Tue, 22 May 2007) | 3 lines + + * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Replaced + assert with vm_abort. ........ r7938 | tbfg | 2007-05-23 11:37:37 + +0200 (Wed, 23 May 2007) | 5 lines + + * src/vm/jit/abi.h (abi_registers_address_name): Added. + (abi_registers_address_argument): Likewise. + (abi_registers_address_saved): Likewise. + (abi_registers_address_temporary): Likewise. ........ r7939 | tbfg + | 2007-05-23 11:40:05 +0200 (Wed, 23 May 2007) | 13 lines + + * src/vm/jit/m68k/codegen.c (codegen_emit): Remove NOP after each + ICMD. Add NOP generation at end of basci block when patcher is + longer than instruction to be patched. + + * src/vm/jit/m68k/patcher.c (patcher_get_putfield): Implemented. + + * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Correct + value. + + * src/vm/jit/codegen-common.c (codegen_increase): Enable NOP after + patcher generation at end of basic block. ........ + [5e9239c03966] + +2007-05-23 tbfg + + * src/vm/jit/codegen-common.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/codegen.c (codegen_emit): Remove NOP after each + ICMD. Add NOP generation at end of basci block when patcher is + longer than instruction to be patched. + + * src/vm/jit/m68k/patcher.c (patcher_get_putfield): Implemented. + + * src/vm/jit/m68k/codegen.h (COMPILERSTUB_CODESIZE): Correct value. + + * src/vm/jit/codegen-common.c (codegen_increase): Enable NOP after + patcher generation at end of basic block. + [c06959f336b9] + + * src/vm/jit/abi.h: + * src/vm/jit/abi.h (abi_registers_address_name): Added. + (abi_registers_address_argument): Likewise. + (abi_registers_address_saved): Likewise. + (abi_registers_address_temporary): Likewise. + [3c252b5dfa38] + +2007-05-23 michi + + * src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.h (stackframeinfo) [ENABLE_GC_CACAO]: Added + adrregs for HAS_ADDRESS_REGISTER_FILE architectures. + [30fcc084af90] + +2007-05-22 michi + + * src/vm/builtintable.inc, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/md-abi.c, + src/vm/jit/arm/patcher.c, src/vm/jit/x86_64/md.c: + * src/vm/builtintable.inc (builtintable_internal): Enabled builtin + stubs for ICMD_NEWARRAY and ICMD_ANEWARRAY. + [4f994b75bad7] + +2007-05-22 twisti + + * src/vm/jit/x86_64/md.c: + * src/vm/jit/x86_64/md.c (md_get_method_patch_address): Replaced + assert with vm_abort. + [1753c1c0dfb9] + +2007-05-22 michi + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen_emit_stub_native): Removed + obsolete SPLIT-stuff. + [cbbe265fb1ac] + + * src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Removed obsolete + SPLIT-stuff. + [d78bb0141f66] + + * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/md-abi.c: + * src/vm/jit/arm/md-abi.c (md_param_alloc): Align stack arguments as + well. + * src/vm/jit/arm/asmpart.S (asm_vm_call_method): Use EABI internally. + [3942d11bd5a8] + +2007-05-21 twisti + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md- + abi.c: + * src/vm/jit/arm/md-abi.c (md_param_alloc): Use EABI internally. + (ALIGN_2): Removed. + + * src/vm/jit/arm/codegen.c (codegen_emit): Removed SPLIT-stuff. + * src/vm/jit/arm/emit.c (emit_store): Likewise. + [9a3a5bb37f48] + + * src/vm/global.h: + * src/vm/global.h (ALIGN_2): Added. + [63d9afde94b7] + +2007-05-21 michi + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/patcher.c: + * src/vm/jit/arm/codegen.h (M_EORLE): Added. + + * src/vm/jit/arm/codegen.c (codegen_emit): Fixed superindex overflow + for ICMD_INSTANCEOF and ICMD_CHECKCAST. + + * src/vm/jit/arm/patcher.c (patcher_checkcast_instanceof_interface): + Adapted patcher to above changes. + [9d9deb8bb043] + + * src/mm/cacao-gc/mark.c, src/native/include/Makefile.am: + * src/mm/cacao-gc/mark.c (mark_me): Ifdefed statistics assertion. + [5c577e7dc152] + +2007-05-21 twisti + + * src/native/include/Makefile.am: + * src/native/include/Makefile.am (CLEANFILES): Simply clean an *.h + files. + [5a05843da368] + + * src/native/jni.c, src/native/jni.h: + * src/native/jni.c (_Jv_jni_CallLongMethodA): New function. + (_Jv_jni_CallFloatMethodA): Likewise. (_Jv_jni_CallDoubleMethodA): + Likewise. (_Jv_JNI_CallStaticBooleanMethodA): Implemented. + (_Jv_JNI_CallStaticByteMethodA): Likewise. + (_Jv_JNI_CallStaticCharMethodA): Likewise. + (_Jv_JNI_CallStaticShortMethodA): Likewise. + (_Jv_JNI_CallStaticIntMethodA): Likewise. + (_Jv_JNI_CallStaticLongMethodA): Likewise. + (_Jv_JNI_CallStaticFloatMethodA): Likewise. + (_Jv_JNI_CallStaticDoubleMethodA): Likewise. + [2d2693b5fc01] + +2007-05-21 michi + + * src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): This + function is no longer GC-specific, removed assertion. + [06b76ff22ce6] + + * src/mm/cacao-gc/heap.c, src/mm/cacao-gc/mark.c, src/mm/cacao- + gc/rootset.c, src/mm/cacao-gc/rootset.h: + * src/mm/cacao-gc/rootset.c (rootset_from_globals): Uses registered + references instead of Cacao-internal structures now. + (rootset_readout) [ENABLE_THREADS]: Adapted to new threads table. + + * src/mm/cacao-gc/rootset.h: Minor changes. + * src/mm/cacao-gc/heap.c: Likewise. + * src/mm/cacao-gc/mark.c: Likewise. + [efe66624fb2e] + +2007-05-20 michi + + * src/cacaoh/dummy.c, src/threads/threads-common.c, + src/vmcore/linker.c: + * src/threads/threads-common.c (threads_thread_new) + [ENABLE_GC_CACAO]: Initialize GC-specific field. + (threads_thread_start_internal): Register reference with the GC. + (threads_thread_start): Likewise. + + * src/vmcore/linker.c: Functions are now called threads_stopworld + and threads_startworld. + + * src/cacaoh/dummy.c: Likewise. + [c75b79edb8ef] + + * src/threads/native/threads.c: + * src/threads/native/threads.c: Major fix after messed up merge from + trunk, sorry for not beeing more precise here. + [946bdd0b169e] + + * src/cacaoh/dummy.c, src/native/jni.c, src/native/jni.h, + src/vmcore/loader.c, src/vmcore/loader.h: + * src/cacaoh/dummy.c (gc_reference_register): Added. + + * src/vmcore/loader.c (hashtable_classloader): Made it static again. + (loader_hashtable_classloader_add) [ENABLE_GC_CACAO]: Registers + reference with the GC. + + * src/native/jni.c (hashtable_global_ref): Made it static again. + (_Jv_JNI_NewGlobalRef) [ENABLE_GC_CACAO]: Registers reference with + the GC. (_Jv_JNI_DeleteGlobalRef) [ENABLE_GC_CACAO]: Unregisters + above reference. + [7ea5ce46fe14] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/gc-common.h: + * src/mm/gc-common.h (gc_reference_register, + gc_reference_unregister): Added prototypes. + + * src/mm/cacao-gc/gc.h (list_gcref_entry_t): Added. + + * src/mm/cacao-gc/gc.c (gc_reflist): Added. (gc_reference_register): + Implemented. + [8bc119ebad52] + + * src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h: + * src/mm/cacao-gc/final.h: Renamed final_entry to + list_final_entry_t. + * src/mm/cacao-gc/final.c: Likewise. + [33e5ba33c62c] + + * .cvsignore, configure.ac, contrib/.cvsignore, + contrib/check_dangerous_printf.pl, doc/.cvsignore, + doc/handbook/.cvsignore, man/.cvsignore, src/.cvsignore, + src/cacao/.cvsignore, src/cacaoh/.cvsignore, src/cacaoh/dummy.c, + src/fdlibm/.cvsignore, src/lib/.cvsignore, src/lib/Makefile.am, + src/lib/vm/reference/gnu/classpath/VMStackWalker.java, + src/lib/vm/reference/gnu/classpath/VMSystemProperties.java, src/lib/ + vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java, src/l + ib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/vm/reference/java/lang/VMClassLoader.java, + src/lib/vm/reference/java/lang/VMString.java, + src/lib/vm/reference/java/lang/VMThread.java, + src/lib/vm/reference/java/lang/VMThrowable.java, + src/lib/vm/reference/java/security/VMAccessController.java, + src/mm/.cvsignore, src/mm/boehm-gc/.cvsignore, src/mm/boehm- + gc/doc/.cvsignore, src/mm/boehm-gc/include/.cvsignore, src/mm/boehm- + gc/include/gc.h, src/mm/cacao-gc/.cvsignore, src/mm/memory.c, + src/mm/memory.h, src/native/.cvsignore, + src/native/include/.cvsignore, src/native/jni.c, + src/native/jvmti/.cvsignore, src/native/native.c, + src/native/native.h, src/native/tools/.cvsignore, + src/native/vm/.cvsignore, src/native/vm/Makefile.am, + src/native/vm/cldc1.1/.cvsignore, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/java_lang_Math.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/.cvsignore, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/ + gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/sun_misc_Unsafe.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h, + src/scripts/.cvsignore, src/threads/.cvsignore, + src/threads/Makefile.am, src/threads/critical.c, + src/threads/critical.h, src/threads/native/.cvsignore, + src/threads/native/lock.c, src/threads/native/lock.h, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/none/.cvsignore, src/threads/none/lock.h, src/threads + /threads-common.c, src/threads/threads-common.h, + src/toolbox/.cvsignore, src/toolbox/avl.c, src/toolbox/avl.h, + src/toolbox/hashtable.c, src/toolbox/list.c, src/toolbox/list.h, + src/toolbox/worklist.c, src/toolbox/worklist.h, src/vm/.cvsignore, + src/vm/Makefile.am, src/vm/builtin.c, src/vm/finalizer.c, + src/vm/initialize.c, src/vm/jit/.cvsignore, + src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/freebsd/.cvsignore, + src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/arm/.cvsignore, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/.cvsignore, + src/vm/jit/arm/linux/md-os.c, src/vm/jit/codegen-common.c, + src/vm/jit/codegen-common.h, src/vm/jit/dseg.h, src/vm/jit/emit- + common.h, src/vm/jit/i386/.cvsignore, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/darwin/.cvsignore, src/vm/jit/i386/darwin/md-os.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/freebsd/.cvsignore, + src/vm/jit/i386/linux/.cvsignore, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/inline/.cvsignore, src/vm/jit/inline/Makefile.am, + src/vm/jit/inline/inline.c, src/vm/jit/inline/inline.h, + src/vm/jit/intrp/.cvsignore, src/vm/jit/jit.c, + src/vm/jit/loop/.cvsignore, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/machine-instr.h, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/mips/.cvsignore, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/irix/.cvsignore, + src/vm/jit/mips/linux/.cvsignore, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/optimizing/.cvsignore, + src/vm/jit/optimizing/dominators.c, src/vm/jit/optimizing/graph.c, + src/vm/jit/optimizing/graph.h, src/vm/jit/optimizing/lifetimes.c, + src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa.h, src/vm/jit/parisc/.cvsignore, + src/vm/jit/parisc/linux/.cvsignore, src/vm/jit/parse.c, + src/vm/jit/patcher.h, src/vm/jit/powerpc/.cvsignore, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/darwin/.cvsignore, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/.cvsignore, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/netbsd/.cvsignore, + src/vm/jit/powerpc64/.cvsignore, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/powerpc64/linux + /md-os.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/.cvsignore, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/disass.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390 + /machine-instr.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c, src/vm/jit/schedule/.cvsignore, + src/vm/jit/show.c, src/vm/jit/sparc64/.cvsignore, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/.cvsignore, src/vm/jit/sparc64/linux/md- + os.c, src/vm/jit/sparc64/machine-instr.h, src/vm/jit/sparc64/md- + abi.c, src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md-asm.h, + src/vm/jit/sparc64/solaris/.cvsignore, src/vm/jit/sparc64/solaris + /md-os.c, src/vm/jit/stack.c, src/vm/jit/stacktrace.c, + src/vm/jit/tools/.cvsignore, src/vm/jit/verify/.cvsignore, + src/vm/jit/x86_64/.cvsignore, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/freebsd/.cvsignore, + src/vm/jit/x86_64/linux/.cvsignore, src/vm/jit/x86_64/linux/md-os.c, + src/vm/signal.c, src/vm/string.c, src/vm/vm.c, + src/vmcore/.cvsignore, src/vmcore/class.c, src/vmcore/classcache.c, + src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/statistics.c, + src/vmcore/statistics.h, src/vmcore/suck.c, src/vmcore/utf8.c, + tests/.cvsignore, tests/Makefile.am, tests/regression/.cvsignore, + tests/regression/codepatching/.cvsignore, + tests/regression/native/.cvsignore, tests/stack/.cvsignore: + Merged revisions 7797-7917 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7799 | twisti | 2007-04-24 01:03:31 +0200 (Tue, 24 Apr + 2007) | 4 lines + + * configure.ac: Removed --enable-threads checks and call instead + AC_CHECK_ENABLE_THREADS. + * m4/threads.m4: New file. ........ r7800 | twisti | 2007-04-24 + 01:39:11 +0200 (Tue, 24 Apr 2007) | 2 lines + + * .cvsignore: Removed. ........ r7801 | twisti | 2007-04-24 + 01:51:37 +0200 (Tue, 24 Apr 2007) | 74 lines + + * contrib/.cvsignore, doc/.cvsignore, doc/handbook/.cvsignore, + man/.cvsignore, src/.cvsignore, src/cacao/.cvsignore, + src/cacaoh/.cvsignore, src/fdlibm/.cvsignore, + src/lib/.cvsignore, src/mm/.cvsignore, src/mm/boehm- + gc/.cvsignore, src/mm/boehm-gc/doc/.cvsignore, src/mm/boehm- + gc/include/.cvsignore, src/mm/cacao-gc/.cvsignore, + src/native/.cvsignore, src/native/include/.cvsignore, + src/native/jvmti/.cvsignore, src/native/tools/.cvsignore, + src/native/vm/.cvsignore, src/native/vm/cldc1.1/.cvsignore, + src/native/vm/gnu/.cvsignore, src/scripts/.cvsignore, + src/threads/.cvsignore, src/threads/none/.cvsignore, + src/threads/posix/.cvsignore, src/toolbox/.cvsignore, + src/vm/.cvsignore, src/vm/jit/.cvsignore, + src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore, + src/vm/jit/alpha/freebsd/.cvsignore, + src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/arm/.cvsignore, + src/vm/jit/arm/linux/.cvsignore, src/vm/jit/i386/.cvsignore, + src/vm/jit/i386/cygwin/.cvsignore, + src/vm/jit/i386/darwin/.cvsignore, + src/vm/jit/i386/freebsd/.cvsignore, + src/vm/jit/i386/linux/.cvsignore, src/vm/jit/inline/.cvsignore, + src/vm/jit/intrp/.cvsignore, src/vm/jit/loop/.cvsignore, + src/vm/jit/m68k/.cvsignore, src/vm/jit/m68k/linux/.cvsignore, + src/vm/jit/mips/.cvsignore, src/vm/jit/mips/irix/.cvsignore, + src/vm/jit/mips/linux/.cvsignore, + src/vm/jit/optimizing/.cvsignore, src/vm/jit/parisc/.cvsignore, + src/vm/jit/parisc/linux/.cvsignore, src/vm/jit/powerpc/.cvsignore, + src/vm/jit/powerpc/darwin/.cvsignore, + src/vm/jit/powerpc/linux/.cvsignore, + src/vm/jit/powerpc/netbsd/.cvsignore, + src/vm/jit/powerpc64/.cvsignore, + src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/s390/.cvsignore, + src/vm/jit/schedule/.cvsignore, src/vm/jit/sparc64/.cvsignore, + src/vm/jit/sparc64/linux/.cvsignore, + src/vm/jit/sparc64/solaris/.cvsignore, + src/vm/jit/tools/.cvsignore, src/vm/jit/verify/.cvsignore, + src/vm/jit/x86_64/.cvsignore, + src/vm/jit/x86_64/freebsd/.cvsignore, + src/vm/jit/x86_64/linux/.cvsignore, src/vmcore/.cvsignore, + tests/.cvsignore, tests/regression/.cvsignore, + tests/regression/codepatching/.cvsignore, + tests/regression/jasmin/.cvsignore, + tests/regression/native/.cvsignore, tests/stack/.cvsignore: + Removed. ........ r7802 | tbfg | 2007-04-24 12:20:05 +0200 (Tue, + 24 Apr 2007) | 2 lines + + * threads.m4: Fixed a typo ........ r7803 | twisti | 2007-04-24 + 16:23:40 +0200 (Tue, 24 Apr 2007) | 3 lines + + * src/threads/threads-common.c (threads_dump): Also print integer + thread id, so it's easier to compare with the ones from gdb. + ........ r7804 | twisti | 2007-04-24 16:29:20 +0200 (Tue, 24 Apr + 2007) | 3 lines + + * src/threads/threads-common.c: Set Id keyword. + * src/threads/threads-common.h: Likewise. ........ r7805 | twisti | + 2007-04-25 13:47:15 +0200 (Wed, 25 Apr 2007) | 12 lines + + * src/threads/threads-common.c (threads_create_thread) + [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE. + (threads_start_javathread) [ENABLE_GC_BOEHM]: Likewise. + + * src/threads/native/threads.c (threads_preinit) + [ENABLE_GC_BOEHM]: Likewise. (threads_init): Removed resizing- + of-threadobject code, we don't need it anymore. + (threads_attach_current_thread) [ENABLE_GC_BOEHM]: Use + GCNEW_UNCOLLECTABLE. (threads_detach_thread) [ENABLE_GC_BOEHM]: + Use GCFREE. ........ r7806 | twisti | 2007-04-25 13:54:32 +0200 + (Wed, 25 Apr 2007) | 3 lines + + * src/threads/native/threads.c (threads_init): Use variable t + instead of mainthreadobj->object, makes code simpler. ........ + r7807 | twisti | 2007-04-25 16:24:18 +0200 (Wed, 25 Apr 2007) | 3 + lines + + * contrib: Ignore TAGS. + * contrib/vmlog: Likewise. ........ r7808 | twisti | 2007-04-25 + 17:12:20 +0200 (Wed, 25 Apr 2007) | 6 lines + + * src/native/native.c (native/include/java_lang_Object.h): Include + always. [ENABLE_JAVAME_CLDC1_1] + (native/include/com_sun_cldc_io_ResourceInputStream.h) + (native/include/com_sun_cldc_io_j2me_socket_Protocol.h): Added. + ........ r7809 | twisti | 2007-04-25 17:14:34 +0200 (Wed, 25 Apr + 2007) | 3 lines + + * src/threads/native/threads.c (threads_preinit): We always need + variable t. ........ r7810 | stefan | 2007-04-25 18:39:03 +0200 + (Wed, 25 Apr 2007) | 2 lines + + * src/vmcore/linker.c (linker_init): added missing + lock_init_object_lock. ........ r7811 | twisti | 2007-04-25 + 20:33:30 +0200 (Wed, 25 Apr 2007) | 23 lines + + * src/threads/threads-common.c (threads_create_thread): Renamed to + threads_thread_create_internal and a new function. + (threads_start_javathread): Use threads_create_thread. + + * src/threads/threads-common.h (threads_create_thread): Changed + signature. (threads_thread_create_internal): Added. + + * src/threads/native/threads.c (threads_set_current_threadobject): + Made non-static. (threads_init_threadobject): Likewise, use + threads_create_thread. (threads_init): Cleanup. + (threads_startup_thread): Likewise. + (threads_attach_current_thread): Use threads_create_thread. + + * src/vm/jit/optimizing/profile.c (profile_start_thread): Replaced + threads_create_thread with threads_thread_create_internal. + * src/vm/jit/optimizing/recompile.c (recompile_start_thread): + Likewise. + * src/vm/signal.c (signal_start_thread): Likewise. + * src/vm/finalizer.c (finalizer_start_thread): Likewise. + * src/mm/memory.c (memory_start_thread): Likewise. ........ r7812 | + twisti | 2007-04-25 20:51:03 +0200 (Wed, 25 Apr 2007) | 2 lines + + * src/mm/memory.h: Updated copyright header. ........ r7813 | + twisti | 2007-04-25 21:20:13 +0200 (Wed, 25 Apr 2007) | 35 lines + + * src/threads/lock-common.h: New file. + + * src/threads/native/lock.h: Removed function prototypes. + * src/threads/none/lock.h (LOCK_INIT_OBJECT_LOCK): Added. + + * src/mm/memory.c, src/native/jni.c, src/native/native.c, + src/native/vm/java_lang_Object.c, + src/native/vm/java_lang_Thread.c, src/threads/Makefile.am, + src/threads/native/threads.c, src/threads/threads-common.c, + src/toolbox/avl.c, src/toolbox/hashtable.c, src/toolbox/list.c, + src/vm/builtin.c, src/vm/finalizer.c, src/vm/initialize.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c, + src/vm/jit/patcher.h, src/vm/jit/show.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/string.c, src/vmcore/class.c, src/vmcore/classcache.c, + src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/suck.c, + src/vmcore/utf8.c: Updated headers. ........ r7814 | twisti | + 2007-04-25 21:36:15 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/powerpc/linux/md-abi.c + (abi_registers_float_temporary): Fixed number of registers. + ........ r7815 | twisti | 2007-04-25 21:37:11 +0200 (Wed, 25 Apr + 2007) | 3 lines + + * src/vm/jit/powerpc/codegen.c: Fixed lock include. + * src/vm/jit/powerpc/emit.c: Likewise. ........ r7816 | twisti | + 2007-04-25 21:38:46 +0200 (Wed, 25 Apr 2007) | 2 lines + + * src/vm/jit/powerpc/emit.c: Set Id keyword. ........ r7817 | + twisti | 2007-04-25 21:42:50 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/powerpc64/codegen.c: Changed lock includes. + * src/vm/jit/powerpc64/emit.c: Likewise. ........ r7818 | twisti | + 2007-04-25 21:47:50 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/i386/codegen.c: Changed lock include. + * src/vm/jit/i386/emit.c: Likewise. ........ r7819 | twisti | + 2007-04-25 21:54:01 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Use + md->params to save and restore argument registers. ........ r7820 + | twisti | 2007-04-25 21:55:34 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/alpha/codegen.c: Changed lock include. + * src/vm/jit/alpha/emit.c: Likewise. ........ r7821 | twisti | + 2007-04-25 21:56:30 +0200 (Wed, 25 Apr 2007) | 2 lines + + * src/vm/jit/alpha/emit.c: Set Id keyword. ........ r7822 | + twisti | 2007-04-25 22:02:14 +0200 (Wed, 25 Apr 2007) | 5 lines + + * src/vm/jit/arm/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + ........ r7823 | twisti | 2007-04-25 22:03:04 +0200 (Wed, 25 Apr + 2007) | 3 lines + + * src/vm/jit/arm/codegen.c: Changed lock include. + * src/vm/jit/arm/emit.c: Likewise. ........ r7824 | twisti | + 2007-04-25 22:07:37 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/mips/codegen.c: Changed lock includes. + * src/vm/jit/mips/emit.c: Likewise. ........ r7825 | twisti | + 2007-04-25 22:31:57 +0200 (Wed, 25 Apr 2007) | 11 lines + + * src/threads/threads-common.c (threads_start_javathread): Changed + signature. + + * src/threads/lock-common.h (threads/threads-common.h): Added. + [ENABLE_THREADS]: Only define functions when threads are enabled. + + * src/threads/threads-common.h + (native/include/java_lang_Thread.h): Removed. [ENABLE_THREADS]: + Only define functions when threads are enabled. + (threads_start_javathread): Changed signature. ........ r7826 | + twisti | 2007-04-25 22:56:16 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/threads/threads-common.c (threads_dump) [!SIZEOF_VOID_P == + 8]: Fixed warning. ........ r7827 | twisti | 2007-04-25 23:03:44 + +0200 (Wed, 25 Apr 2007) | 6 lines + + * src/threads/lock-common.h (threads/threads-common.h): Removed + that header again and added a comment about not including thread + headers. + + * src/threads/threads-common.c (threads_start_javathread): + Reverted. + * src/threads/threads-common.h (threads_start_javathread): Likewise. + ........ r7828 | stefan | 2007-04-25 23:23:57 +0200 (Wed, 25 Apr + 2007) | 3 lines + + * src/vm/jit/i386/darwin/md-os.c: attempt at porting the exception + changes (see r7596 & r7648). ........ r7829 | stefan | + 2007-04-25 23:47:00 +0200 (Wed, 25 Apr 2007) | 3 lines + + * src/vm/jit/i386/darwin/md-os.c: added threads/threads-common.h, + removed vm/jit/i386/md-abi.h ........ r7830 | twisti | 2007-04-26 + 13:14:39 +0200 (Thu, 26 Apr 2007) | 28 lines + + * src/threads/threads-common.c (threads/critical.h): Added. + (threads/native/threads.h): Removed. (threads_table): Added. + (threads_preinit): New function. (threads_table_init): Moved from + implementation file. (threads_table_add): Likewise. + (threads_table_remove): Likewise. (threads_table_dump): Likewise. + + * src/threads/threads-common.h (threads_table_entry_t) + (threads_table_t): Added. (threads_preinit): Likewise. + (threads_table_add): Likewise. (threads_table_remove): Likewise. + (threads_impl_preinit): Likewise. (threads_init_threadobject): + Likewise. + + * src/threads/native/threads.c (threads_table): Removed. + (threads_preinit): Renamed to threads_impl_preinit. + (threads_table_init): Removed. (threads_table_add): Likewise. + (threads_table_remove): Likewise. (threads_table_dump): Likewise. + + * src/threads/native/threads.h (threads_table_entry_t) + (threads_table_t): Removed. (threads_preinit): Likewise. ........ + r7831 | twisti | 2007-04-26 14:48:16 +0200 (Thu, 26 Apr 2007) | 23 + lines + + * src/threads/threads-common.c (threads_thread_create_internal): + Renamed to threads_thread_start_internal and start the thread. + (threads_start_javathread): Renamed to threads_thread_start. + * src/threads/threads-common.h: Likewise. + + * src/threads/native/threads.c (threads_start_thread): Renamed to + threads_impl_thread_start. + + * src/mm/memory.c (thread_memory): Removed. + (memory_start_thread): Call threads_thread_start_internal. + + * src/vm/finalizer.c (thread_finalizer): Removed. + (finalizer_start_thread): Call threads_thread_start_internal. + + * src/vm/signal.c (thread_signal): Removed. + (signal_start_thread): Call threads_thread_start_internal. + + * src/vm/jit/optimizing/profile.c (thread_profile): Removed. + (profile_start_thread): Call threads_thread_start_internal. + + * src/vm/jit/optimizing/recompile.c (thread_recompile): Removed. + (recompile_start_thread): Call threads_thread_start_internal. + ........ r7832 | twisti | 2007-04-26 15:06:16 +0200 (Thu, 26 Apr + 2007) | 3 lines + + * src/native/vm/java_lang_Thread.c (start): Renamed + threads_start_javathread to threads_thread_start. ........ r7833 | + twisti | 2007-04-26 15:07:05 +0200 (Thu, 26 Apr 2007) | 2 lines + + * src/native/vm/java_lang_Thread.c: Set Id keyword. ........ + r7834 | twisti | 2007-04-26 15:32:08 +0200 (Thu, 26 Apr 2007) | 3 + lines + + * src/vm/vm.c [ENABLE_THREADS] (threads/native/threads.h): + Removed. (threads/threads-common.h): Added. ........ r7835 | + twisti | 2007-04-26 15:43:08 +0200 (Thu, 26 Apr 2007) | 7 lines + + * src/vm/jit/inline/inline.h (config.h): Added. (inline_inline): + Likewise. + + * src/vm/jit/jit.c (threads/threads-common.h): Added. + [ENABLE_INLINING] (vm/jit/inline/inline.h): Likewise. + [ENABLE_THREADS] (threads/native/threads.h): Removed. ........ + r7836 | ajordan | 2007-04-27 03:37:06 +0200 (Fri, 27 Apr 2007) | 9 + lines + + * src/vm/jit/sparc64/emit.c: Keeping stack 16-byte aligned when + calling C/native functions from the stack. (Solaris requires this) + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/sparc64/codegen.h: Likewise. + + * src/vm/jit/sparc64/md-abi.c: Removed zero sized abi_register_* + arrays. (not allowed in ISO C) + + * src/vm/jit/sparc64/solaris/md-os.c: Preliminary hardware + exception handling. (untested) ........ r7837 | tbfg | 2007-04-27 + 10:43:06 +0200 (Fri, 27 Apr 2007) | 27 lines + + * src/vm/jit/m68k/emit.c (emit_arrayindexoutofbounds_check): + Fixed. + * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): AIOOB + fixed. Editor boiler plate added. + + * src/vm/jit/m68k/linux/md-os.h: Editor boiler plate. + + * src/vm/jit/m68k/linux/md-abi.c: Likewise. + + * src/vm/jit/m68k/md.c: Likewise. + + * src/vm/jit/m68k/machine-instr.h: Likewise. + + * src/vm/jit/m68k/patcher.c: Editor boiler plate. + (patcher_invokeinterface): Implemented. (patcher_get_putfield): + Implemented. (patcher_resolve_class): Implemented. + (patcher_get_putstatic): Implemented. + + * src/vm/jit/m68k/codegen.c: Editor boiler plate. + (ICMD_GETSTATIC): Added patcher. (ICMD_AASTORE): Fixed. + + * src/vm/jit/m68k/asmpart.S: Editor boiler plate. + (asm_vm_call_method_exception_handler): Fixed used register. + Return values in %d0 and %a0 as gcc sometimes expects pointers in + %a0. ........ r7838 | ajordan | 2007-04-28 14:59:58 +0200 (Sat, 28 + Apr 2007) | 3 lines + + * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Fixed + stack alignement in first save. ........ r7839 | pm | 2007-04-30 + 00:46:56 +0200 (Mon, 30 Apr 2007) | 15 lines + + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/machine-instr.h, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h, + src/vm/jit/s390/md-asm.h, src/vm/jit/s390/disass.c, + src/vm/jit/s390/patcher.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/md-abi.c: Adapted S390 port to changes from + branches/twisti (hardware exceptions, emit_branch, abi_registers_*), + jctest works again. Cleaned up almost all dead x86_64 code. ........ + r7840 | tbfg | 2007-04-30 12:53:13 +0200 (Mon, 30 Apr 2007) | 31 + lines + + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed. + (emit_arithmetic_check): Implemented. + + * src/vm/jit/m68k/md.c (md_get_method_patch_address): Changed + invoking register. (md_stacktrace_get_returnaddress): Fix for + linking words on stack. + + * src/vm/jit/m68k/codegen.c (IUSHRCONST): Fix. (ICMD_IOR): + Implemented. (ICMD_IORCONST): Likewise. (ICMD_IXOR): Likewise. + (ICMD_IXORCONST): Likewise. (ICMD_INVOKEVIRTUAL): Changed invoking + register. (ICMD_INVOKEINTERFACE): Likewise. + + * src/vm/jit/m68k/patcher.c (patcher_invokevirtual): Changed + invoking register. + + * src/vm/jit/m68k/asmpart.S + (asm_vm_call_method_exception_handler): Proper stack restauration. + (L_asm_call_jit_compiler_exception): Implemented. + (asm_patcher_wrapper): Fixses. (L_asm_patcher_wrapper_exception): + Implemented. + + * src/vm/jit/m68k/codegen.h (M_IXOR): Added. (M_IOR_IMM): Added. + (M_IXOR_IMM): Added. + + * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): + Comment and further m68k stuff. ........ r7841 | twisti | + 2007-04-30 13:58:57 +0200 (Mon, 30 Apr 2007) | 3 lines + + * src/vm/jit/inline/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. ........ r7842 | tbfg | 2007-04-30 14:44:47 + +0200 (Mon, 30 Apr 2007) | 3 lines + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Restore + registers correctly. ........ r7843 | tbfg | 2007-05-01 15:00:12 + +0200 (Tue, 01 May 2007) | 22 lines + + * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): + Support EXCEPTION_HARDWARE_ARITHMETIC. + + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Use corret opcode for + word forms. + + * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Implemented. + (ICMD_IREMPOW2): Implemented. (ICMD_ISHLCONST): Fixed. + (ICMD_ISHRCONST): Fixed. (ICMD_IUSHRCONST): Fixed. + (ICMD_SALOAD): Signextension fix. (ICMD_LALOAD): Implemented. + (ICMD_LASTORE): Fixed. (ICMD_IASTORE): Fixed. + (ICMD_MULITANEWARRAY): Fixed. + + * src/vm/jit/m68k/codegen.h (M_IADDX): Added. (M_IXOR): Fixed. + (M_BCS): Fixed. ........ r7844 | pm | 2007-05-01 17:46:22 +0200 + (Tue, 01 May 2007) | 3 lines + + * src/vm/jit/emit-common.h (BRANCH_LABEL_6): Added. ........ + r7845 | pm | 2007-05-01 18:05:07 +0200 (Tue, 01 May 2007) | 3 lines + + * src/vm/jit/s390/codegen.c (codegen_emit): Use new emit_label and + emit_label_* functions. + * src/vm/jit/s390/disass.c (disass_pseudo_instr): Nicer formatting for + ill pseudo instruction. ........ r7846 | pm | 2007-05-01 18:14:00 + +0200 (Tue, 01 May 2007) | 2 lines + + * src/vm/jit/s390/codegen.h (gen_bound_check, + gen_nullptr_check_intern, gen_bound_check, N_LONG_0): Remove because + obsolete. ........ r7847 | ajordan | 2007-05-01 19:35:55 +0200 + (Tue, 01 May 2007) | 6 lines + + * src/vm/jit/sparc64/codegen.h: Removed unused var_to_reg_int + define. + + * src/vm/jit/sparc64/codegen.c: Fixed JIT float argument passing + via stack. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call): Fixed integer + argument passing via stack args. ........ r7848 | pm | 2007-05-01 + 23:40:26 +0200 (Tue, 01 May 2007) | 8 lines + + * src/vm/jit/s390/md.c (md_dump_context): Added. Fatal signals now + print the context and a stacktrace. + * src/vm/jit/s390/emit.h (emit_restore_pv): Added. Fixes bug where + REG_PV recalculation uses dseg value to recalculate REG_PV. + * src/vm/jit/s390/emit.c: Likewise. + * src/vm/jit/s390/codegen.h (N_RI, N_RI2): Test immediate operand for + correct signedness. + * src/vm/jit/s390/codegen.c (codegen_emit): Use emit_restore_pv for + REG_PV recalculation/ + * src/vm/jit/s390/disass.c (disass_pseudo_instr): Fix formating. + * src/vm/jit/s390/tests/dacapo.status: Added. ........ r7849 | + twisti | 2007-05-02 11:57:22 +0200 (Wed, 02 May 2007) | 6 lines + + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Added uClibc support. (md_signal_handler_sigtrap): Likewise. + (md_signal_handler_sigusr2): Likewise. + (thread_restartcriticalsection): Likewise. ........ r7850 | twisti + | 2007-05-02 18:21:12 +0200 (Wed, 02 May 2007) | 37 lines + + * src/threads/threads-common.c (threads_preinit): Create and + initialize the main-thread. (threads_table_init): Changed + signature, insert main-thread and maintain a used list too. + (threads_table_add): Use locking and maintain used list. + (threads_table_remove): Likewise. (threads_table_get): New + function. (threads_table_get_non_daemons): Likewise. + (threads_table_first): Likewise. (threads_table_next): Likewise. + [!NDEBUG] (threads_table_dump): Use log_* functions. + (threads_dump): Use threads-table and functions. + + * src/threads/threads-common.h (threads_table_entry_t): Made a + struct and renamed nextfree to next. (threads_table_get): Added + (threads_table_get_non_daemons): Likewise. (threads_table_first): + Likewise. (threads_table_next): Likewise. [!NDEBUG] + (threads_table_dump): Likewise. (threads_impl_table_init): + Likewise. (threads_table_lock): Likewise. + (threads_table_unlock): Likewise. + (threads_set_current_threadobject): Likewise. + + * src/threads/native/threads.c (threadlistlock): Removed. + (threads_impl_preinit): Removed main-thread initialization code. + (threads_impl_table_init): New function. (threads_table_lock): New + function. (threads_table_unlock): Likewise. (threads_init): Get + main-thread from threads-table and removed thread-list code. + (threads_attach_current_thread): Likewise. + (threads_detach_thread): Removed thread-list code. + (threads_find_non_daemon_thread): Removed. + (threads_join_all_threads): Use threads_table_get_non_daemons. + ........ r7851 | twisti | 2007-05-02 21:57:07 +0200 (Wed, 02 May + 2007) | 3 lines + + * src/vmcore/class.c (class_load_attributes): Disable annotation + loading for the release. ........ r7852 | tbfg | 2007-05-02 + 22:36:07 +0200 (Wed, 02 May 2007) | 3 lines + + * java_lang_Double.c (Java_java_lang_Double_doubleToLongBits): + Added missing JNIEnv* argument to signature. ........ r7853 | + twisti | 2007-05-02 22:40:11 +0200 (Wed, 02 May 2007) | 8 lines + + * src/threads/threads-common.c (threads_table_get_threads): New + function. + + * src/threads/threads-common.h (threads_table_get_threads): Added. + + * src/threads/native/threads.c (threads_cast_sendsignals): + Rewritten. (threads_cast_stopworld): Likewise. ........ r7854 | + twisti | 2007-05-02 22:44:59 +0200 (Wed, 02 May 2007) | 4 lines + + * src/native/vm/cldc1.1/java_lang_Double.c + (native/include/java_lang_Double.h): Added. (longBitsToDouble): + Fixed return type. ........ r7855 | twisti | 2007-05-02 22:46:56 + +0200 (Wed, 02 May 2007) | 3 lines + + * src/native/vm/cldc1.1/java_lang_Float.c (native/native.h): + Removed. (native/include/java_lang_Float.h): Added. ........ + r7856 | tbfg | 2007-05-03 00:28:04 +0200 (Thu, 03 May 2007) | 7 + lines + + * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Fixed. (ICMD_IREM): + Fixed. (ICMD_LASTORE): Use M_LST. (ICMD_DASTORE): Use M_LST. + (ICMD_LALOAD): Use M_LLD. (ICMD_DALOAD): Use M_LLD. ........ + r7857 | tbfg | 2007-05-03 02:33:48 +0200 (Thu, 03 May 2007) | 6 + lines + + * src/vm/jit/m68k/codegen.c (ICMD_CALOAD): Fixed. + + * src/vm/jit/m68k/patcher.c (*): Removed patching back of old + opcodes from patcher_wrapper, moved into each patcher. + (patcher_patch_back): Added. ........ r7858 | twisti | 2007-05-03 + 10:16:14 +0200 (Thu, 03 May 2007) | 3 lines + + * contrib/check_dangerous_printf.pl: Removed this file in favor of + pscan. ........ r7859 | twisti | 2007-05-03 10:29:16 +0200 (Thu, + 03 May 2007) | 7 lines + + * src/toolbox/avl.h (avl_tree): Renamed to avl_tree_t. + (avl_node): Renamed to avl_node_t. + + * src/toolbox/avl.c: Likewise. + * src/threads/critical.c: Likewise. + * src/vm/jit/codegen-common.c: Likewise. ........ r7860 | twisti | + 2007-05-03 14:30:05 +0200 (Thu, 03 May 2007) | 9 lines + + * src/toolbox/avl.c (avl_insert_intern): Changed order of + comparator-arguments. (avl_find): Likewise. + + * src/toolbox/avl.h (avl_comparator): Renamed arguments, to + reflect the change. + + * src/vm/jit/codegen-common.c (methodtree_comparator): Likewise. + ........ r7861 | twisti | 2007-05-03 15:49:35 +0200 (Thu, 03 May + 2007) | 4 lines + + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [ENABLE_JAVASE]: This has to be ENABLE_JNI. + (codegen_finish_native_call): Likewise. ........ r7862 | twisti | + 2007-05-03 16:53:39 +0200 (Thu, 03 May 2007) | 7 lines + + * src/toolbox/avl.c (toolbox/logging.h): Added. (vm/global.h): + Likewise. (vm/vm.h): Likewise. (avl_insert_intern): Use vm_abort + instead of assert. (avl_insert): Removed debug code. (avl_dump): + Use logging functions. ........ r7863 | twisti | 2007-05-03 + 22:58:54 +0200 (Thu, 03 May 2007) | 3 lines + + * src/mm/boehm-gc/include/gc.h (GC_HAVE_BUILTIN_BACKTRACE): + Commented, we don't need it and uClibc doesn't have it. ........ + r7864 | twisti | 2007-05-03 23:17:26 +0200 (Thu, 03 May 2007) | 47 + lines + + * src/threads/critical.c (critical_compare): Renamed to + critical_comparator. (critical_find): Removed. + (critical_register_critical_section): Renamed to + critical_section_register. (critical_find_restart_point): Call + avl_find. (critical_register_asm_critical_sections): Call + critical_section_register. + + * src/threads/critical.h (critical_section_node_t): Renamed + members. (thread_restartcriticalsection): Renamed to + md_critical_section_restart. + + * src/threads/native/threads.c (threads_cast_darwinstop): Call + md_critical_section_restart. (threads_sigsuspend_handler): + Likewise. + + * src/vmcore/linker.c (linker_compute_subclasses): Call + threads_cast_{start,stop}world, removed LOCK_MONITOR_{ENTER,EXIT}. + + * src/cacaoh/dummy.c (threads_cast_stopworld): Added. + (threads_cast_startworld): Likewise. + + * src/vm/jit/codegen-common.c (codegen_setup): Setup listcritical. + (codegen_reset): Likewise. (codegen_critical_section_new): New + function. (codegen_critical_section_start): Likewise. + (codegen_critical_section_end): Likwise. + (codegen_critical_section_finish): Likewise. (codegen_finish): + Call codegen_critical_section_finish. (codegen_threadcritrestart): + Removed. (codegen_threadcritstart): Likewise. + (codegen_threadcritstop): Likewise. + + * src/vm/jit/codegen-common.h (codegen_critical_section_t): + Renamed to critical_section_ref_t. (codegendata): Added + listcritical, removed threadcrit, threadcritcurrent and + threadcritcount. (CODEGEN_CRITICAL_SECTION_NEW, + CODEGEN_CRITICAL_SECTION_START) (CODEGEN_CRITICAL_SECTION_END): + Defined. + + * src/vm/jit/powerpc/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/powerpc/linux/md-os.c + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. ........ r7865 | twisti | 2007-05-03 + 23:29:40 +0200 (Thu, 03 May 2007) | 6 lines + + * src/vm/jit/i386/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/i386/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. ........ r7866 | twisti | + 2007-05-04 00:32:11 +0200 (Fri, 04 May 2007) | 6 lines + + * src/vm/jit/x86_64/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. ........ r7867 | tbfg | + 2007-05-04 01:31:01 +0200 (Fri, 04 May 2007) | 7 lines + + * src/vm/jit/m68k/md.c (md_stacktrace_get_returnaddress): Removed + braindead address check and fixed the real bug. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Added float + argument handling. (asm_call_jit_compiler): Fixed stack offset + bug. ........ r7868 | tbfg | 2007-05-04 12:13:20 +0200 (Fri, 04 + May 2007) | 4 lines + + * linker.c (linker_compute_subclasses): Only call + threads_cast_[start|stop]world when ENABLE_THREADS. ........ r7869 + | pm | 2007-05-05 10:08:49 +0200 (Sat, 05 May 2007) | 3 lines + + * contrib/vmlog/Makefile.am (AM_CPPFLAGS): Add include + directories for vmlog. + * src/vm/Makefile.am: Likewise. ........ r7870 | tbfg | 2007-05-05 + 15:46:11 +0200 (Sat, 05 May 2007) | 3 lines + + * linker.c (linker_compute_subclasses): + threads_cast_[start|stop]world only available when using GC. + ........ r7871 | tbfg | 2007-05-05 15:48:39 +0200 (Sat, 05 May + 2007) | 8 lines + + * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Add thread + support. (emit_exception_check_areg): Removed dead code. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Add thread support. + + * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Likewise. + ........ r7872 | ajordan | 2007-05-06 15:32:49 +0200 (Sun, 06 May + 2007) | 5 lines + + * src/vm/jit/sparc64/codegen.c: Implemented threads support. + * src/vm/jit/sparc64/machine-instr.h: Likewise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. ........ r7873 | tbfg + | 2007-05-07 00:20:13 +0200 (Mon, 07 May 2007) | 16 lines + + * src/vm/jit/m68k/codegen.c (codegen_emit): Allocate 2 additional + words in stackframe for long to double conversion. + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Copy exception + object into correct register. + + * src/vm/jit/m68k/codegen.h (M_FLD): Implemented. (M_DLD): + Likewise. (M_FST): Likewise. (M_DST): Likewise. (M_FLTMOVE): + Likewise. (M_INT2FLTMOVE): Likewise. (M_DBLMOVE): Likewise. + (FCONST): Likewise. ........ r7874 | ajordan | 2007-05-07 03:44:47 + +0200 (Mon, 07 May 2007) | 7 lines + + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed + fp arg passing. + * src/vm/jit/sparc64/md-abi.h: Likewise. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Likewise, but + the other way around. + * src/vm/jit/sparc64/md-asm.h: Likewise. ........ r7875 | twisti | + 2007-05-07 13:35:30 +0200 (Mon, 07 May 2007) | 10 lines + + * src/threads/threads-common.c (threads_table_get): Made static + and removed table lock. (threads_dump): Lock threads table. + + * src/threads/threads-common.h (threads_table_get): Removed. + + * src/threads/native/threads.c (threads_cast_stopworld): Lock + threads table. (threads_cast_startworld): Likewise. ........ + r7876 | twisti | 2007-05-07 13:37:00 +0200 (Mon, 07 May 2007) | 2 + lines + + * src/threads/threads-common.c (threads_dump): Typo. ........ + r7877 | tbfg | 2007-05-07 15:02:55 +0200 (Mon, 07 May 2007) | 38 + lines + + * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Enabled. + (SUPPORT_FLOAT_CMP): Enabled. (SUPPORT_DOUBLE): Enabled. + (SUPPORT_DOUBLE_CMP): Enabled. + + * src/vm/jit/m68k/codegen.c (ICMD_FCMPL): Implemented. + (ICMD_DCMPL): Likewise. (ICMD_FCMPG): Likewise. (ICMD_DCMPG): + Likewise. (ICMD_FMUL): Likewise. (ICMD_DMUL): Likewise. + (ICMD_FDIV): Likewise. (ICMD_DDIV): Likewise. (ICMD_FADD): + Likewise. (ICMD_DADD): Likewise. (ICMD_FSUB): Likewise. + (ICMD_DSUB): Likewise. (ICMD_F2D): Likewise. (ICMD_D2F): + Likewise. (ICMD_BUILTIN): Handle float return values. + (codegen_emit_stub_native): Handle float values. + + * src/vm/jit/m68k/codegen.h (M_FCMP): Added. (M_BFEQ): Added. + (M_BFLT): Added. (M_BFGT): Added. (M_BFUN): Added. (M_FADD): + Added. (M_DADD): Added. (M_FSUB): Added. (M_DSUB): Added. + (M_FMUL): Added. (M_DMUL): Added. (M_FDIV): Added. (M_DDIV): + Added. (M_D2F): Added. (M_F2D): Added. ........ r7878 | twisti + | 2007-05-07 15:31:18 +0200 (Mon, 07 May 2007) | 3 lines + + * src/native/vm/java_lang_Thread.h (threads/native/threads.h): + Removed. ........ r7879 | twisti | 2007-05-07 15:45:19 +0200 (Mon, + 07 May 2007) | 8 lines + + * configure.ac (AC_CHECK_HEADERS): Added sys/mman.h, + sys/resource.h. (AC_CHECK_FUNCS): Added getrusage, mprotect. + + * src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include + conditionally. [HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise. + (getcputime) [!HAVE_GETRUSAGE]: Return 0. ........ r7880 | twisti + | 2007-05-07 16:13:45 +0200 (Mon, 07 May 2007) | 6 lines + + * src/vm/jit/mips/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/mips/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. ........ r7881 | twisti | + 2007-05-07 16:16:54 +0200 (Mon, 07 May 2007) | 7 lines + + * configure.ac (AC_CONFIG_FILES): Added + src/vm/jit/mips/uclinux/Makefile. + + * src/vm/jit/mips/uclinux: New directory. + * src/vm/jit/mips/uclinux/md-os.c: New file. + * src/vm/jit/mips/uclinux/Makefile.am: Likewise. ........ r7882 | + tbfg | 2007-05-07 16:23:32 +0200 (Mon, 07 May 2007) | 8 lines + + * tests/exception_restore_registers.java: New test, tests if + variables get restored in case of exceptions. + + * tests/exception_restore_registers.output: New file, expected + output. + + * tests/Makefile.am: Added exception_restore_registers target. + ........ r7883 | tbfg | 2007-05-07 16:26:41 +0200 (Mon, 07 May + 2007) | 11 lines + + * src/vm/jit/m68k/codegen.c (ICMD_FNEG): Implemented. + (ICMD_DNEG): Implemented. + + * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): Store + volatile floatregisters. (asm_patcher_wrapper): Likewise. + (asm_handle_exception): Restore float registers. + + * src/vm/jit/m68k/codegen.h (M_FNEG): Added. (M_DNEG): Added. + ........ r7884 | ajordan | 2007-05-07 17:07:03 +0200 (Mon, 07 May + 2007) | 4 lines + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Adapted to critical + section renames. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. ........ r7885 | + twisti | 2007-05-07 23:29:55 +0200 (Mon, 07 May 2007) | 7 lines + + * src/threads/native/threads.c (mainthreadobj): Removed. + * src/threads/native/threads.h (mainthreadobj): Likewise. + + * src/vm/jit/optimizing/profile.c (threads/native/threads.h): + Likewise. (profile_thread): Rewritten thread iteration. ........ + r7886 | twisti | 2007-05-07 23:34:01 +0200 (Mon, 07 May 2007) | 6 + lines + + * src/vm/jit/alpha/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/alpha/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. ........ r7887 | twisti | + 2007-05-08 15:03:07 +0200 (Tue, 08 May 2007) | 6 lines + + * src/configure.ac (AC_CHECK_HEADERS): Added string.h. + (AC_CHECK_FUNCS): Added strdup. + + * src/src/vmcore/options.c [HAVE_STRING_H] (string.h): Added + #ifdef. (options_get) HAVE_STRDUP]: Added. ........ r7888 | tbfg + | 2007-05-09 10:36:16 +0200 (Wed, 09 May 2007) | 7 lines + + * src/vm/jit/powerpc64/linux/md-os.c + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. + + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. ........ r7889 | tbfg | + 2007-05-09 10:52:11 +0200 (Wed, 09 May 2007) | 36 lines + + * src/vm/jit/m68k/linux/md-abi.h (LA_SIZE_IN_POINTERS): Defined 0. + (PA_SIZE_IN_POINTERS): Removed. (PA_SIZE): Removed. + (LA_LR_OFFSET): Removed. (LA_SIZE_ALIGNED): Removed. + + * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Removed + linking instructions, save only used registers. + + (emit_verbosecall_exit): Likewise. + + * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Depends on configure + option ENABLE_SOFTFLOAT. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Use M_FSTORE/M_FLOAT + to save/restore float registers without converting any values. + Fixed offset of IsSync. + + (codegen_emit_stub_native): Move floating point return values + into floating point registers. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Save/restore + floating point registers. + + (asm_call_jit_compiler): Save/restore volatile floating point + registers. + + (asm_patcher_wrapper): Likewise. + + (asm_handle_exception): Use fmovemd instructions to restore + floatng point registers without converting. + + * src/vm/jit/m68k/codegen.h (M_FSTORE): Added. (M_FLOAT): Added. + ........ r7890 | twisti | 2007-05-09 18:05:58 +0200 (Wed, 09 May + 2007) | 7 lines + + * src/lib/Makefile.am (VM_JAVA_FILES): Renamed vm/reference/ to + gnu/. + + * src/lib/vm: Removed. + * src/lib/gnu: Added. + * src/lib/gnu/java: Likewise. + * src/lib/gnu/gnu: Likewise. ........ r7891 | tbfg | 2007-05-09 + 18:37:20 +0200 (Wed, 09 May 2007) | 5 lines + + * src/vm/jit/powerpc64/codegen.c (ICMD_CHECKCAST): Use + branch_label_* instead of harcoded jump offsets. + + (ICMD_INSTANCEOF): Likewise. ........ r7892 | tbfg | 2007-05-10 + 14:50:45 +0200 (Thu, 10 May 2007) | 3 lines + + * src/vm/jit/powerpc64/patcher.c (patcher_checkcast_interface): + Fixed not flushing all bytes written. ........ r7893 | twisti | + 2007-05-10 15:27:29 +0200 (Thu, 10 May 2007) | 7 lines + + * src/threads/threads-common.c (threads_thread_start_internal): + Set thread-flags. (threads_thread_start): Likewise. + + * src/threads/native/threads.c (threads_startup_thread): Don't set + thread-flags. ........ r7894 | twisti | 2007-05-10 16:04:05 +0200 + (Thu, 10 May 2007) | 19 lines + + * src/vmcore/options.c (opt_verbosethreads): Added. + * src/vmcore/options.h (opt_verbosethreads): Likewise. + + * src/vm/vm.c (XXusage): Added -verbose:threads. (vm_create): + Likewise. + + * src/threads/threads-common.c (threads_create_thread): Renamed + variable thread to t. (threads_thread_print_info): New function. + (threads_dump): Use threads_thread_print_info. + + * src/threads/threads-common.h (threads_thread_print_info): Added. + + * src/threads/native/threads.c (threads_init) [!NDEBUG]: Added + -verbose:threads debug-output. (threads_startup_thread): Likewise. + (threads_attach_current_thread): Likewise. + (threads_detach_thread): Likewise. ........ r7895 | tbfg | + 2007-05-10 16:34:05 +0200 (Thu, 10 May 2007) | 9 lines + + * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Make SOFTFLOAT + clean. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Mark comment + about gcc abi wiredness. + + * src/vm/jit/m68k/codegen.h (M_D2F): Fixed. (M_F2D): Fixed. + ........ r7896 | tbfg | 2007-05-11 19:15:08 +0200 (Fri, 11 May + 2007) | 9 lines + + * src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize + allocation in not synchronized methods which call a builtin + returning a double. Merged with ENABLE_THREADS case. Added code + to copy interface registers. + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Save + temporary registers, dunno if really needed, but its a slow path + anyways. ........ r7897 | twisti | 2007-05-11 20:23:27 +0200 (Fri, + 11 May 2007) | 2 lines + + * src/threads/native/threads.h (threadobject): Removed next and + prev. ........ r7898 | tbfg | 2007-05-11 20:58:24 +0200 (Fri, 11 + May 2007) | 12 lines + + * src/vm/jit/m68k/linux/md-abi.h (ADR_SAV_CNT): Increased by one + (%fp). (ADR_RES_CNT): Decreased by one (%fp). + + * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Declared %fp a + REG_SAV. + + * src/vm/jit/m68k/arch.h (SUPPORT_DIVISION): Defined. + + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Additional logic + to restore %fp when unwinding the stack. ........ r7899 | twisti | + 2007-05-11 21:31:04 +0200 (Fri, 11 May 2007) | 37 lines + + * src/threads/threads-common.c (threads_create_thread): Removed + lock_init_execution_env. + + * src/threads/lock-common.h (lock_init_execution_env): Removed. + (lock_record_free_pools): Likewise. + + * src/threads/native/threads.h (threadobject): Removed ee. + + * src/threads/native/lock.c (vm/finalizer.h): Added. + [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): Likewise. + (lock_global_pool): Removed. (lock_global_pool_lock): Likewise. + (lock_init): Don't initialize lock_global_pool_lock. + (lock_record_init): Removed. (lock_init_execution_env): Likewise. + (lock_record_alloc_new_pool): Likewise. (lock_record_alloc_pool): + Likewise. (lock_record_free_pools): Likewise. + (lock_record_alloc): Likewise. (lock_record_recycle): Likewise. + (lock_hashtable_get_lock_record): Renamed to lock_hashtable_get. + (lock_record_new): New function. (lock_record_free): Likewise. + (lock_hashtable_remove): Likewise. [ENABLE_GC_BOEHM] + (lock_record_finalizer): Likewise. + + * src/threads/native/lock.h (lock_execution_env_t): Removed. + (lock_record_pool_header_t): Likewise. (lock_record_pool_t): + Likewise. (lock_record_t): Renamed obj to object, removed + nextfree. [ENABLE_JVMTI] (lock_global_pool_lock, + lock_global_pool): Removed. + + * src/vmcore/statistics.c (size_lock_record_pool): Renamed to + size_lock_record. (statistics_print_memory_usage): Likewise. + * src/vmcore/statistics.h: Likewise. ........ r7900 | twisti | + 2007-05-11 22:35:16 +0200 (Fri, 11 May 2007) | 6 lines + + * src/vm/jit/arm/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/arm/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. ........ r7901 | twisti | + 2007-05-11 23:18:51 +0200 (Fri, 11 May 2007) | 3 lines + + * src/vmcore/statistics.c (statistics_print_memory_usage): Use + log_println instead of printf. ........ r7902 | twisti | + 2007-05-12 00:33:15 +0200 (Sat, 12 May 2007) | 10 lines + + * configure.ac (AC_CHECK_HEADERS): Added time.h. + (AC_CHECK_FUNCS): Added localtime, localtime_r, time. + + * src/vmcore/statistics.c [HAVE_TIME_H] (time.h): Added. + (statistics_print_date): New function. + * src/vmcore/statistics.h (statistics_print_date): Added. + + * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: Call + statistics_print_date. ........ r7903 | tbfg | 2007-05-14 13:15:33 + +0200 (Mon, 14 May 2007) | 15 lines + + * src/vm/jit/dseg.h (dseg_adddata): Removed warning due to typo. + + * src/vm/jit/m68k/arch.h (SUPPORT_LONG) Defined. + (SUPPORT_LONG_ADD): Defined. (SUPPORT_CONST_LOGICAL): Defined. + + * src/vm/jit/m68k/codegen.c (ICMD_LADD): Implemented. + (ICMD_LADDCONST): Implemented. (ICMD_LSUB): Implemented. + (ICMD_LSUBCONST): Implemented. (ICMD_LNEG): Implemented. + + * src/vm/jit/m68k/codegen.h (M_ISUBX): Added. (M_INEGX): Added. + ........ r7904 | twisti | 2007-05-14 15:29:32 +0200 (Mon, 14 May + 2007) | 26 lines + + * src/threads/threads-common.c (threads_create_thread): Renamed to + threads_thread_new. (threads_thread_free): New function. + (threads_preinit): Renamed threads_create_thread to + threads_thread_new. (threads_thread_start_internal): Likewise. + (threads_thread_start): Likewise. + + * src/threads/threads-common.h (threads_create_thread): Renamed to + threads_thread_new. (threads_thread_free): Added. + (threads_init_threadobject): Renamed to threads_impl_thread_new. + (threads_impl_thread_free): Added. + + * src/threads/native/threads.c (toolbox/avl.h): Removed. + (threadattr): Likewise. (threads_init_threadobject): Renamed to + threads_impl_thread_new. (threads_impl_thread_free): New function. + (threads_init): Use local pthread_attr_t. + (threads_impl_thread_start): Use pthread_attr_setdetachstate (fixes + memory leak), check more return values of pthread-calls. + (threads_attach_current_thread): Renamed threads_create_thread to + threads_thread_new. (threads_detach_thread): Removed lock-record + pools comment, call threads_thread_free. ........ r7905 | twisti + | 2007-05-14 16:11:33 +0200 (Mon, 14 May 2007) | 4 lines + + * src/toolbox/list.c (list_add_first): Call + list_add_first_unsynced. (list_add_first_unsynced): New function. + * src/toolbox/list.h (list_add_first_unsynced): Added. ........ + r7906 | twisti | 2007-05-14 19:25:33 +0200 (Mon, 14 May 2007) | 2 + lines + + * src/native/native.c (native_class_getdeclaredannotations): + Removed. ........ r7907 | tbfg | 2007-05-15 11:25:27 +0200 (Tue, + 15 May 2007) | 2 lines + + * builtin.c (builtin_ldiv): Needed when DISABLE_GC. ........ + r7908 | christian | 2007-05-15 11:55:17 +0200 (Tue, 15 May 2007) | + 37 lines + + * src/vm/jit/codegen-common.c: (codegen_emit_phi_moves): Added. + (Former codegen_insert_phi_moves from codegen.c) + + * src/vm/jit/codegen-common.h: Function prototype for + codegen_emit_phi_moves added. + + * src/vm/jit/optimizing/lsra.c: Adapted to new instruction format + and unified variables. + + * src/vm/jit/optimizing/lsra.h: Likewise. + + * src/vm/jit/optimizing/ssa.c: Likewise. + + * src/vm/jit/optimizing/ssa.h: Likewise. + + * src/vm/jit/optimizing/graph.c: Likewise. + + * src/vm/jit/optimizing/graph.h: Likewise. + + * src/vm/jit/optimizing/dominators.c: Likewise. + + * src/vm/jit/optimizing/lifetimes.c: Likewise and changed lifetime + anaylsis to a worklist algorithmus. + + * src/vm/jit/optimizing/lifetimes.h: Likewise. + + * src/vm/jit/i386/codegen.c: (codegen_insert_phi_moves): Moved to + src/vm/jit/codegen-common.c codegen_emit_phi_moves (codegen_emit): + Necessary Adaptions for SSA. + + * src/toolbox/worklist.c: (wl_reset): Added. + + * src/toolbox/worklist.h: Function Prototype for wl_reset added. + + * src/vm/jit/stack.c: Removed old SSA specific code. ........ + r7909 | tbfg | 2007-05-15 12:32:16 +0200 (Tue, 15 May 2007) | 12 + lines + + * src/vm/jit/powerpc64/patcher.c + (patcher_resolve_classref_to_classinfo): Patch back original code. + + (patcher_resolve_classref_to_vftbl): Likewise. + (patcher_resolve_classref_to_flags): Likewise. + + * src/vm/jit/powerpc64/asmpart.S (DARWIN): Removed all darwin + ifdefed code for readability. Needs to be ported carefully anyways. + + (asm_vm_call_method): When handling arguments treat address type + as long. ........ r7910 | twisti | 2007-05-16 10:02:52 +0200 + (Wed, 16 May 2007) | 59 lines + + * src/native/native.c: Removed all native-includes. + (dummynativetable): Removed. (mainhandle): Likewise. + (native_init): Don't dlopen libjvm, initialize the native-methods + tree. (native_tree_native_methods_comparator): New function. + (native_method_symbol): Likewise. (native_method_find): Likewise. + (native_resolve_function): Use native-methods tree for internal + native methods. + + * src/native/native.h (native/jni.h): Added. + (NATIVE_METHODS_COUNT): Defined. (native_methods_node_t): New + structure. (native_method_register): Added. + + * src/native/vm/nativevm.c: New file. + * src/native/vm/nativevm.h: Likewise. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + nativevm.[ch]. + + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/java_lang_Math.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/v + m/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/sun_misc_Unsafe.c: Added methods table and init + function to register the native methods. ........ r7911 | twisti | + 2007-05-16 11:01:10 +0200 (Wed, 16 May 2007) | 8 lines + + * src/native/native.c (native_library_open): New function. + (native_hashtable_library_add): Renamed to native_library_add. + (native_hashtable_library_find): Renamed to native_library_find. + * src/native/native.h: Likewise. + + * src/native/vm/java_lang_Runtime.c (loadLibrary): Use + native_library_open. ........ r7912 | twisti | 2007-05-18 15:12:09 + +0200 (Fri, 18 May 2007) | 14 lines + + * src/native/native.c (native_tree_native_methods_comparator): + Compare classname, name and descriptor. + (native_method_register): Set all structure members. + (native_method_find): Changed argument-type to methodinfo. + (native_resolve_function): Likewise. + + * src/native/native.h (native_methods_node_t): Added classname and + descriptor, renamed method to function. + + * src/native/vm/gnu/java_lang_VMClass.c: Updated wrong signatures. + * src/native/vm/gnu/java_lang_VMObject.c: Likewise. + * src/native/vm/gnu/java_lang_VMThread.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. + ........ r7913 | twisti | 2007-05-18 15:45:54 +0200 (Fri, 18 May + 2007) | 6 lines + + * src/native/vm/cldc1.1/java_lang_String.c (methods): Removed + quick-hack. + + * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace): + Fixed signature. ........ r7914 | twisti | 2007-05-18 16:17:34 + +0200 (Fri, 18 May 2007) | 4 lines + + * src/threads/threads-common.c (threads_thread_get_state): Fixed + compiler warning. (threads_thread_is_alive): Likewise. ........ + r7915 | twisti | 2007-05-18 16:22:19 +0200 (Fri, 18 May 2007) | 2 + lines + + * src/toolbox/list.c (list_create): Use LOCK_INIT_OBJECT_LOCK- + macro. ........ r7916 | twisti | 2007-05-18 16:24:21 +0200 (Fri, + 18 May 2007) | 10 lines + + * src/vmcore/statistics.c (count_nstub_len): Renamed to + size_stub_native. (statistics_print_memory_usage): Likewise. + + * src/vmcore/statistics.h: Likewise. + + * src/vm/jit/codegen-common.c (codegen_generate_stub_native): + Likewise, moved statistics-calculation after codegen_finish(), so + actually something is counted. ........ r7917 | twisti | + 2007-05-18 17:05:32 +0200 (Fri, 18 May 2007) | 3 lines + + * src/native/vm/cldc1.1/java_lang_Object.c (getClass): Fixed + signature. ........ + [4af05b527810] + +2007-05-18 twisti + + * src/native/vm/cldc1.1/java_lang_Object.c: + * src/native/vm/cldc1.1/java_lang_Object.c (getClass): Fixed + signature. + [54484f15560e] + + * src/vm/jit/codegen-common.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vmcore/statistics.c (count_nstub_len): Renamed to + size_stub_native. (statistics_print_memory_usage): Likewise. + + * src/vmcore/statistics.h: Likewise. + + * src/vm/jit/codegen-common.c (codegen_generate_stub_native): + Likewise, moved statistics-calculation after codegen_finish(), so + actually something is counted. + [63567965122d] + + * src/toolbox/list.c: + * src/toolbox/list.c (list_create): Use LOCK_INIT_OBJECT_LOCK-macro. + [8de6c89e9bf9] + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_thread_get_state): Fixed + compiler warning. (threads_thread_is_alive): Likewise. + [8d74bfb4fb5c] + + * src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_Throwable.c: + * src/native/vm/cldc1.1/java_lang_String.c (methods): Removed quick- + hack. + + * src/native/vm/cldc1.1/java_lang_Throwable.c (fillInStackTrace): + Fixed signature. + [322b8d3496f1] + + * src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c: + * src/native/native.c (native_tree_native_methods_comparator): + Compare classname, name and descriptor. (native_method_register): + Set all structure members. (native_method_find): Changed argument- + type to methodinfo. (native_resolve_function): Likewise. + + * src/native/native.h (native_methods_node_t): Added classname and + descriptor, renamed method to function. + + * src/native/vm/gnu/java_lang_VMClass.c: Updated wrong signatures. + * src/native/vm/gnu/java_lang_VMObject.c: Likewise. + * src/native/vm/gnu/java_lang_VMThread.c: Likewise. + * src/native/vm/gnu/java_lang_reflect_Constructor.c: Likewise. + [f36dae832c9a] + +2007-05-16 twisti + + * src/native/native.c, src/native/native.h, + src/native/vm/java_lang_Runtime.c: + * src/native/native.c (native_library_open): New function. + (native_hashtable_library_add): Renamed to native_library_add. + (native_hashtable_library_find): Renamed to native_library_find. + * src/native/native.h: Likewise. + + * src/native/vm/java_lang_Runtime.c (loadLibrary): Use + native_library_open. + [187f8d8411ff] + + * src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/java_lang_Math.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/ + gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/sun_misc_Unsafe.c, src/native/vm/nativevm.c, + src/native/vm/nativevm.h: + * src/native/native.c: Removed all native-includes. + (dummynativetable): Removed. (mainhandle): Likewise. (native_init): + Don't dlopen libjvm, initialize the native-methods tree. + (native_tree_native_methods_comparator): New function. + (native_method_symbol): Likewise. (native_method_find): Likewise. + (native_resolve_function): Use native-methods tree for internal + native methods. + + * src/native/native.h (native/jni.h): Added. (NATIVE_METHODS_COUNT): + Defined. (native_methods_node_t): New structure. + (native_method_register): Added. + + * src/native/vm/nativevm.c: New file. + * src/native/vm/nativevm.h: Likewise. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + nativevm.[ch]. + + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/java_lang_Math.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/ + gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMObject.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMString.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_lang_reflect_VMProxy.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/gnu/sun_misc_Unsafe.c: Added methods table and init + function to register the native methods. + [64c69300da3b] + +2007-05-15 tbfg + + * src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/patcher.c: + * src/vm/jit/powerpc64/patcher.c + (patcher_resolve_classref_to_classinfo): Patch back original code. + + (patcher_resolve_classref_to_vftbl): Likewise. + (patcher_resolve_classref_to_flags): Likewise. + + * src/vm/jit/powerpc64/asmpart.S (DARWIN): Removed all darwin + ifdefed code for readability. Needs to be ported carefully anyways. + + (asm_vm_call_method): When handling arguments treat address type as + long. + [8b2523c8fe2b] + +2007-05-15 christian + + * src/toolbox/worklist.c, src/toolbox/worklist.h, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/i386/codegen.c, + src/vm/jit/optimizing/dominators.c, src/vm/jit/optimizing/graph.c, + src/vm/jit/optimizing/graph.h, src/vm/jit/optimizing/lifetimes.c, + src/vm/jit/optimizing/lifetimes.h, src/vm/jit/optimizing/lsra.c, + src/vm/jit/optimizing/lsra.h, src/vm/jit/optimizing/ssa.c, + src/vm/jit/optimizing/ssa.h, src/vm/jit/stack.c: + * src/vm/jit/codegen-common.c: (codegen_emit_phi_moves): Added. + (Former codegen_insert_phi_moves from codegen.c) + + * src/vm/jit/codegen-common.h: Function prototype for + codegen_emit_phi_moves added. + + * src/vm/jit/optimizing/lsra.c: Adapted to new instruction format + and unified variables. + + * src/vm/jit/optimizing/lsra.h: Likewise. + + * src/vm/jit/optimizing/ssa.c: Likewise. + + * src/vm/jit/optimizing/ssa.h: Likewise. + + * src/vm/jit/optimizing/graph.c: Likewise. + + * src/vm/jit/optimizing/graph.h: Likewise. + + * src/vm/jit/optimizing/dominators.c: Likewise. + + * src/vm/jit/optimizing/lifetimes.c: Likewise and changed lifetime + anaylsis to a worklist algorithmus. + + * src/vm/jit/optimizing/lifetimes.h: Likewise. + + * src/vm/jit/i386/codegen.c: (codegen_insert_phi_moves): Moved to + src/vm/jit/codegen-common.c codegen_emit_phi_moves (codegen_emit): + Necessary Adaptions for SSA. + + * src/toolbox/worklist.c: (wl_reset): Added. + + * src/toolbox/worklist.h: Function Prototype for wl_reset added. + + * src/vm/jit/stack.c: Removed old SSA specific code. + [6270ebe435fa] + +2007-05-15 tbfg + + * src/vm/builtin.c: + * builtin.c (builtin_ldiv): Needed when DISABLE_GC. + [cec8c00d844a] + +2007-05-14 twisti + + * src/native/native.c: + * src/native/native.c (native_class_getdeclaredannotations): + Removed. + [1fcaff874000] + + * src/toolbox/list.c, src/toolbox/list.h: + * src/toolbox/list.c (list_add_first): Call list_add_first_unsynced. + (list_add_first_unsynced): New function. + * src/toolbox/list.h (list_add_first_unsynced): Added. + [c982fd6285f2] + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h: + * src/threads/threads-common.c (threads_create_thread): Renamed to + threads_thread_new. (threads_thread_free): New function. + (threads_preinit): Renamed threads_create_thread to + threads_thread_new. (threads_thread_start_internal): Likewise. + (threads_thread_start): Likewise. + + * src/threads/threads-common.h (threads_create_thread): Renamed to + threads_thread_new. (threads_thread_free): Added. + (threads_init_threadobject): Renamed to threads_impl_thread_new. + (threads_impl_thread_free): Added. + + * src/threads/native/threads.c (toolbox/avl.h): Removed. + (threadattr): Likewise. (threads_init_threadobject): Renamed to + threads_impl_thread_new. (threads_impl_thread_free): New function. + (threads_init): Use local pthread_attr_t. + (threads_impl_thread_start): Use pthread_attr_setdetachstate (fixes + memory leak), check more return values of pthread-calls. + (threads_attach_current_thread): Renamed threads_create_thread to + threads_thread_new. (threads_detach_thread): Removed lock-record + pools comment, call threads_thread_free. + [f922505053e3] + +2007-05-14 tbfg + + * src/vm/jit/dseg.h, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h: + * src/vm/jit/dseg.h (dseg_adddata): Removed warning due to typo. + + * src/vm/jit/m68k/arch.h (SUPPORT_LONG) Defined. (SUPPORT_LONG_ADD): + Defined. (SUPPORT_CONST_LOGICAL): Defined. + + * src/vm/jit/m68k/codegen.c (ICMD_LADD): Implemented. + (ICMD_LADDCONST): Implemented. (ICMD_LSUB): Implemented. + (ICMD_LSUBCONST): Implemented. (ICMD_LNEG): Implemented. + + * src/vm/jit/m68k/codegen.h (M_ISUBX): Added. (M_INEGX): Added. + [09becbd98429] + +2007-05-11 twisti + + * configure.ac, src/mm/memory.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * configure.ac (AC_CHECK_HEADERS): Added time.h. (AC_CHECK_FUNCS): + Added localtime, localtime_r, time. + + * src/vmcore/statistics.c [HAVE_TIME_H] (time.h): Added. + (statistics_print_date): New function. + * src/vmcore/statistics.h (statistics_print_date): Added. + + * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: Call + statistics_print_date. + [25ead7bd5f52] + + * src/vmcore/statistics.c: + * src/vmcore/statistics.c (statistics_print_memory_usage): Use + log_println instead of printf. + [061cff927754] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/arm/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [d18fe002c94f] + + * src/threads/lock-common.h, src/threads/native/lock.c, + src/threads/native/lock.h, src/threads/native/threads.h, src/threads + /threads-common.c, src/vmcore/statistics.c, src/vmcore/statistics.h: + * src/threads/threads-common.c (threads_create_thread): Removed + lock_init_execution_env. + + * src/threads/lock-common.h (lock_init_execution_env): Removed. + (lock_record_free_pools): Likewise. + + * src/threads/native/threads.h (threadobject): Removed ee. + + * src/threads/native/lock.c (vm/finalizer.h): Added. + [ENABLE_GC_BOEHM] (mm/boehm-gc/include/gc.h): Likewise. + (lock_global_pool): Removed. (lock_global_pool_lock): Likewise. + (lock_init): Don't initialize lock_global_pool_lock. + (lock_record_init): Removed. (lock_init_execution_env): Likewise. + (lock_record_alloc_new_pool): Likewise. (lock_record_alloc_pool): + Likewise. (lock_record_free_pools): Likewise. (lock_record_alloc): + Likewise. (lock_record_recycle): Likewise. + (lock_hashtable_get_lock_record): Renamed to lock_hashtable_get. + (lock_record_new): New function. (lock_record_free): Likewise. + (lock_hashtable_remove): Likewise. [ENABLE_GC_BOEHM] + (lock_record_finalizer): Likewise. + + * src/threads/native/lock.h (lock_execution_env_t): Removed. + (lock_record_pool_header_t): Likewise. (lock_record_pool_t): + Likewise. (lock_record_t): Renamed obj to object, removed nextfree. + [ENABLE_JVMTI] (lock_global_pool_lock, lock_global_pool): Removed. + + * src/vmcore/statistics.c (size_lock_record_pool): Renamed to + size_lock_record. (statistics_print_memory_usage): Likewise. + * src/vmcore/statistics.h: Likewise. + [6c9eb67b735c] + +2007-05-11 tbfg + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h: + * src/vm/jit/m68k/linux/md-abi.h (ADR_SAV_CNT): Increased by one + (%fp). (ADR_RES_CNT): Decreased by one (%fp). + + * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Declared %fp a + REG_SAV. + + * src/vm/jit/m68k/arch.h (SUPPORT_DIVISION): Defined. + + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Additional logic + to restore %fp when unwinding the stack. + [2c693aa2e5a2] + +2007-05-11 twisti + + * src/threads/native/threads.h: + * src/threads/native/threads.h (threadobject): Removed next and + prev. + [f855349a44d5] + +2007-05-11 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c: + * src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize + allocation in not synchronized methods which call a builtin + returning a double. Merged with ENABLE_THREADS case. Added code to + copy interface registers. + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Save temporary + registers, dunno if really needed, but its a slow path anyways. + [90d247b28159] + +2007-05-10 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Make SOFTFLOAT + clean. (emit_verbosecall_exit): Likewise. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Mark comment about + gcc abi wiredness. + + * src/vm/jit/m68k/codegen.h (M_D2F): Fixed. (M_F2D): Fixed. + [1fce7d6e6eed] + +2007-05-10 twisti + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vmcore/options.c (opt_verbosethreads): Added. + * src/vmcore/options.h (opt_verbosethreads): Likewise. + + * src/vm/vm.c (XXusage): Added -verbose:threads. (vm_create): + Likewise. + + * src/threads/threads-common.c (threads_create_thread): Renamed + variable thread to t. (threads_thread_print_info): New function. + (threads_dump): Use threads_thread_print_info. + + * src/threads/threads-common.h (threads_thread_print_info): Added. + + * src/threads/native/threads.c (threads_init) [!NDEBUG]: Added + -verbose:threads debug-output. (threads_startup_thread): Likewise. + (threads_attach_current_thread): Likewise. (threads_detach_thread): + Likewise. + [837d882ff4d7] + + * src/threads/native/threads.c, src/threads/threads-common.c: + * src/threads/threads-common.c (threads_thread_start_internal): Set + thread-flags. (threads_thread_start): Likewise. + + * src/threads/native/threads.c (threads_startup_thread): Don't set + thread-flags. + [473c74e3b3f8] + +2007-05-10 tbfg + + * src/vm/jit/powerpc64/patcher.c: + * src/vm/jit/powerpc64/patcher.c (patcher_checkcast_interface): + Fixed not flushing all bytes written. + [c68a841961bd] + +2007-05-09 tbfg + + * src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (ICMD_CHECKCAST): Use + branch_label_* instead of harcoded jump offsets. + + (ICMD_INSTANCEOF): Likewise. + [42c458c7fbeb] + +2007-05-09 twisti + + * src/lib/Makefile.am, src/lib/gnu/gnu/classpath/VMStackWalker.java, + src/lib/gnu/gnu/classpath/VMSystemProperties.java, + src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java, + src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/gnu/java/lang/VMClassLoader.java, + src/lib/gnu/java/lang/VMString.java, + src/lib/gnu/java/lang/VMThread.java, + src/lib/gnu/java/lang/VMThrowable.java, + src/lib/gnu/java/security/VMAccessController.java, + src/lib/vm/reference/gnu/classpath/VMStackWalker.java, + src/lib/vm/reference/gnu/classpath/VMSystemProperties.java, src/lib/ + vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java, src/l + ib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java, + src/lib/vm/reference/java/lang/VMClassLoader.java, + src/lib/vm/reference/java/lang/VMString.java, + src/lib/vm/reference/java/lang/VMThread.java, + src/lib/vm/reference/java/lang/VMThrowable.java, + src/lib/vm/reference/java/security/VMAccessController.java: + * src/lib/Makefile.am (VM_JAVA_FILES): Renamed vm/reference/ to + gnu/. + + * src/lib/vm: Removed. + * src/lib/gnu: Added. + * src/lib/gnu/java: Likewise. + * src/lib/gnu/gnu: Likewise. + [b01c51c68bf2] + +2007-05-09 tbfg + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.h: + * src/vm/jit/m68k/linux/md-abi.h (LA_SIZE_IN_POINTERS): Defined 0. + (PA_SIZE_IN_POINTERS): Removed. (PA_SIZE): Removed. (LA_LR_OFFSET): + Removed. (LA_SIZE_ALIGNED): Removed. + + * src/vm/jit/m68k/emit.c (emit_verbosecall_enter): Removed linking + instructions, save only used registers. + + (emit_verbosecall_exit): Likewise. + + * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Depends on configure + option ENABLE_SOFTFLOAT. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Use M_FSTORE/M_FLOAT to + save/restore float registers without converting any values. Fixed + offset of IsSync. + + (codegen_emit_stub_native): Move floating point return values into + floating point registers. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Save/restore + floating point registers. + + (asm_call_jit_compiler): Save/restore volatile floating point + registers. + + (asm_patcher_wrapper): Likewise. + + (asm_handle_exception): Use fmovemd instructions to restore floatng + point registers without converting. + + * src/vm/jit/m68k/codegen.h (M_FSTORE): Added. (M_FLOAT): Added. + [223653956636] + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-os.c: + * src/vm/jit/powerpc64/linux/md-os.c + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. + + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + [7e17b57deda1] + +2007-05-08 twisti + + * configure.ac, src/vmcore/options.c: + * src/configure.ac (AC_CHECK_HEADERS): Added string.h. + (AC_CHECK_FUNCS): Added strdup. + + * src/src/vmcore/options.c [HAVE_STRING_H] (string.h): Added #ifdef. + (options_get) HAVE_STRDUP]: Added. + [ecf613150ffd] + +2007-05-07 twisti + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/alpha/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [8bb1aeffa059] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/jit/optimizing/profile.c: + * src/threads/native/threads.c (mainthreadobj): Removed. + * src/threads/native/threads.h (mainthreadobj): Likewise. + + * src/vm/jit/optimizing/profile.c (threads/native/threads.h): + Likewise. (profile_thread): Rewritten thread iteration. + [ae773419190f] + +2007-05-07 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/linux/md-os.c: + * src/vm/jit/sparc64/codegen.c (codegen_emit): Adapted to critical + section renames. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + [7440f5ffe4e0] + +2007-05-07 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h: + * src/vm/jit/m68k/codegen.c (ICMD_FNEG): Implemented. (ICMD_DNEG): + Implemented. + + * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): Store volatile + floatregisters. (asm_patcher_wrapper): Likewise. + (asm_handle_exception): Restore float registers. + + * src/vm/jit/m68k/codegen.h (M_FNEG): Added. (M_DNEG): Added. + [3c46ebb18bc6] + + * tests/Makefile.am, tests/exception_restore_registers.java, + tests/exception_restore_registers.output: + * tests/exception_restore_registers.java: New test, tests if + variables get restored in case of exceptions. + + * tests/exception_restore_registers.output: New file, expected + output. + + * tests/Makefile.am: Added exception_restore_registers target. + [4903c88ec794] + +2007-05-07 twisti + + * configure.ac, src/vm/jit/mips/uclinux/Makefile.am, + src/vm/jit/mips/uclinux/md-os.c: + * configure.ac (AC_CONFIG_FILES): Added + src/vm/jit/mips/uclinux/Makefile. + + * src/vm/jit/mips/uclinux: New directory. + * src/vm/jit/mips/uclinux/md-os.c: New file. + * src/vm/jit/mips/uclinux/Makefile.am: Likewise. + [a2f9e9b4c127] + + * src/vm/jit/mips/codegen.c, src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/mips/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [98af0627c6d6] + + * configure.ac, src/vmcore/statistics.c: + * configure.ac (AC_CHECK_HEADERS): Added sys/mman.h, sys/resource.h. + (AC_CHECK_FUNCS): Added getrusage, mprotect. + + * src/vmcore/statistics.c [HAVE_SYS_TIME_H] (sys/time.h): Include + conditionally. [HAVE_SYS_RESOURCE_H] (sys/resource.h): Likewise. + (getcputime) [!HAVE_GETRUSAGE]: Return 0. + [eb6879201b23] + + * src/native/vm/java_lang_Thread.h: + * src/native/vm/java_lang_Thread.h (threads/native/threads.h): + Removed. + [81608585fa81] + +2007-05-07 tbfg + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h: + * src/vm/jit/m68k/arch.h (SUPPORT_FLOAT): Enabled. + (SUPPORT_FLOAT_CMP): Enabled. (SUPPORT_DOUBLE): Enabled. + (SUPPORT_DOUBLE_CMP): Enabled. + + * src/vm/jit/m68k/codegen.c (ICMD_FCMPL): Implemented. (ICMD_DCMPL): + Likewise. (ICMD_FCMPG): Likewise. (ICMD_DCMPG): Likewise. + (ICMD_FMUL): Likewise. (ICMD_DMUL): Likewise. (ICMD_FDIV): Likewise. + (ICMD_DDIV): Likewise. (ICMD_FADD): Likewise. (ICMD_DADD): Likewise. + (ICMD_FSUB): Likewise. (ICMD_DSUB): Likewise. (ICMD_F2D): Likewise. + (ICMD_D2F): Likewise. (ICMD_BUILTIN): Handle float return values. + (codegen_emit_stub_native): Handle float values. + + * src/vm/jit/m68k/codegen.h (M_FCMP): Added. (M_BFEQ): Added. + (M_BFLT): Added. (M_BFGT): Added. (M_BFUN): Added. (M_FADD): Added. + (M_DADD): Added. (M_FSUB): Added. (M_DSUB): Added. (M_FMUL): Added. + (M_DMUL): Added. (M_FDIV): Added. (M_DDIV): Added. (M_D2F): Added. + (M_F2D): Added. + [b351752b3490] + +2007-05-07 twisti + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_dump): Typo. + [3bc0b63b21b8] + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h: + * src/threads/threads-common.c (threads_table_get): Made static and + removed table lock. (threads_dump): Lock threads table. + + * src/threads/threads-common.h (threads_table_get): Removed. + + * src/threads/native/threads.c (threads_cast_stopworld): Lock + threads table. (threads_cast_startworld): Likewise. + [0087aafbce90] + +2007-05-07 ajordan + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md-asm.h: + * src/vm/jit/sparc64/codegen.c (codegen_emit_stub_native): Fixed fp + arg passing. + * src/vm/jit/sparc64/md-abi.h: Likewise. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call_method): Likewise, but + the other way around. + * src/vm/jit/sparc64/md-asm.h: Likewise. + [fd7ab22fe3d1] + +2007-05-06 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/codegen.c (codegen_emit): Allocate 2 additional + words in stackframe for long to double conversion. + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Copy exception + object into correct register. + + * src/vm/jit/m68k/codegen.h (M_FLD): Implemented. (M_DLD): Likewise. + (M_FST): Likewise. (M_DST): Likewise. (M_FLTMOVE): Likewise. + (M_INT2FLTMOVE): Likewise. (M_DBLMOVE): Likewise. (FCONST): + Likewise. + [0a407cecd8df] + +2007-05-06 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/machine-instr.h: + * src/vm/jit/sparc64/codegen.c: Implemented threads support. + * src/vm/jit/sparc64/machine-instr.h: Likewise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + [962f3ac2f269] + +2007-05-05 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Add thread support. + (emit_exception_check_areg): Removed dead code. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Add thread support. + + * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Likewise. + [2f26a013bf14] + + * src/vmcore/linker.c: + * linker.c (linker_compute_subclasses): + threads_cast_[start|stop]world only available when using GC. + [ddaa473162cc] + +2007-05-05 pm + + * contrib/vmlog/Makefile.am, src/vm/Makefile.am: + * contrib/vmlog/Makefile.am (AM_CPPFLAGS): Add include directories + for vmlog. + * src/vm/Makefile.am: Likewise. + [0200182415ca] + +2007-05-04 tbfg + + * src/vmcore/linker.c: + * linker.c (linker_compute_subclasses): Only call + threads_cast_[start|stop]world when ENABLE_THREADS. + [8a12809e3939] + +2007-05-03 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/md.c: + * src/vm/jit/m68k/md.c (md_stacktrace_get_returnaddress): Removed + braindead address check and fixed the real bug. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method): Added float + argument handling. (asm_call_jit_compiler): Fixed stack offset bug. + [4d450bf43726] + +2007-05-03 twisti + + * src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/x86_64/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [58f763abf182] + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/i386/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [1ea512b3aa7e] + + * src/cacaoh/dummy.c, src/threads/critical.c, src/threads/critical.h, + src/threads/native/threads.c, src/vm/jit/codegen-common.c, + src/vm/jit/codegen-common.h, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/linux/md-os.c, src/vmcore/linker.c: + * src/threads/critical.c (critical_compare): Renamed to + critical_comparator. (critical_find): Removed. + (critical_register_critical_section): Renamed to + critical_section_register. (critical_find_restart_point): Call + avl_find. (critical_register_asm_critical_sections): Call + critical_section_register. + + * src/threads/critical.h (critical_section_node_t): Renamed members. + (thread_restartcriticalsection): Renamed to + md_critical_section_restart. + + * src/threads/native/threads.c (threads_cast_darwinstop): Call + md_critical_section_restart. (threads_sigsuspend_handler): Likewise. + + * src/vmcore/linker.c (linker_compute_subclasses): Call + threads_cast_{start,stop}world, removed LOCK_MONITOR_{ENTER,EXIT}. + + * src/cacaoh/dummy.c (threads_cast_stopworld): Added. + (threads_cast_startworld): Likewise. + + * src/vm/jit/codegen-common.c (codegen_setup): Setup listcritical. + (codegen_reset): Likewise. (codegen_critical_section_new): New + function. (codegen_critical_section_start): Likewise. + (codegen_critical_section_end): Likwise. + (codegen_critical_section_finish): Likewise. (codegen_finish): Call + codegen_critical_section_finish. (codegen_threadcritrestart): + Removed. (codegen_threadcritstart): Likewise. + (codegen_threadcritstop): Likewise. + + * src/vm/jit/codegen-common.h (codegen_critical_section_t): Renamed + to critical_section_ref_t. (codegendata): Added listcritical, + removed threadcrit, threadcritcurrent and threadcritcount. + (CODEGEN_CRITICAL_SECTION_NEW, CODEGEN_CRITICAL_SECTION_START) + (CODEGEN_CRITICAL_SECTION_END): Defined. + + * src/vm/jit/powerpc/codegen.c (codegen_emit): Use + CODEGEN_CRITICAL_SECTION_* macros. + + * src/vm/jit/powerpc/linux/md-os.c (thread_restartcriticalsection): + Renamed to md_critical_section_restart. + [7f54f774046b] + + * src/mm/boehm-gc/include/gc.h: + * src/mm/boehm-gc/include/gc.h (GC_HAVE_BUILTIN_BACKTRACE): + Commented, we don't need it and uClibc doesn't have it. + [52f7bbb43963] + + * src/toolbox/avl.c: + * src/toolbox/avl.c (toolbox/logging.h): Added. (vm/global.h): + Likewise. (vm/vm.h): Likewise. (avl_insert_intern): Use vm_abort + instead of assert. (avl_insert): Removed debug code. (avl_dump): Use + logging functions. + [6c16dd030e43] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_start_native_call) + [ENABLE_JAVASE]: This has to be ENABLE_JNI. + (codegen_finish_native_call): Likewise. + [3953e7c5db17] + + * src/toolbox/avl.c, src/toolbox/avl.h, src/vm/jit/codegen-common.c: + * src/toolbox/avl.c (avl_insert_intern): Changed order of + comparator-arguments. (avl_find): Likewise. + + * src/toolbox/avl.h (avl_comparator): Renamed arguments, to reflect + the change. + + * src/vm/jit/codegen-common.c (methodtree_comparator): Likewise. + [d7c021bc6103] + + * src/threads/critical.c, src/toolbox/avl.c, src/toolbox/avl.h, + src/vm/jit/codegen-common.c: + * src/toolbox/avl.h (avl_tree): Renamed to avl_tree_t. (avl_node): + Renamed to avl_node_t. + + * src/toolbox/avl.c: Likewise. + * src/threads/critical.c: Likewise. + * src/vm/jit/codegen-common.c: Likewise. + [78a3161d59f0] + + * contrib/check_dangerous_printf.pl: + * contrib/check_dangerous_printf.pl: Removed this file in favor of + pscan. + [01c3063dac5a] + +2007-05-03 tbfg + + * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/codegen.c (ICMD_CALOAD): Fixed. + + * src/vm/jit/m68k/patcher.c (*): Removed patching back of old + opcodes from patcher_wrapper, moved into each patcher. + (patcher_patch_back): Added. + [b5bd8907ff04] + +2007-05-02 tbfg + + * src/vm/jit/m68k/codegen.c: + * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Fixed. (ICMD_IREM): + Fixed. (ICMD_LASTORE): Use M_LST. (ICMD_DASTORE): Use M_LST. + (ICMD_LALOAD): Use M_LLD. (ICMD_DALOAD): Use M_LLD. + [e53aa985f343] + +2007-05-02 twisti + + * src/native/vm/cldc1.1/java_lang_Float.c: + * src/native/vm/cldc1.1/java_lang_Float.c (native/native.h): + Removed. (native/include/java_lang_Float.h): Added. + [54ab8fef4a97] + + * src/native/vm/cldc1.1/java_lang_Double.c: + * src/native/vm/cldc1.1/java_lang_Double.c + (native/include/java_lang_Double.h): Added. (longBitsToDouble): + Fixed return type. + [c178e4019030] + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h: + * src/threads/threads-common.c (threads_table_get_threads): New + function. + + * src/threads/threads-common.h (threads_table_get_threads): Added. + + * src/threads/native/threads.c (threads_cast_sendsignals): + Rewritten. (threads_cast_stopworld): Likewise. + [eb798e490771] + +2007-05-02 tbfg + + * src/native/vm/cldc1.1/java_lang_Double.c: + * java_lang_Double.c (Java_java_lang_Double_doubleToLongBits): Added + missing JNIEnv* argument to signature. + [f3210d71cb99] + +2007-05-02 twisti + + * src/vmcore/class.c: + * src/vmcore/class.c (class_load_attributes): Disable annotation + loading for the release. + [0af4700c23ad] + + * src/threads/native/threads.c, src/threads/threads-common.c, + src/threads/threads-common.h: + * src/threads/threads-common.c (threads_preinit): Create and + initialize the main-thread. (threads_table_init): Changed signature, + insert main-thread and maintain a used list too. + (threads_table_add): Use locking and maintain used list. + (threads_table_remove): Likewise. (threads_table_get): New function. + (threads_table_get_non_daemons): Likewise. (threads_table_first): + Likewise. (threads_table_next): Likewise. [!NDEBUG] + (threads_table_dump): Use log_* functions. (threads_dump): Use + threads-table and functions. + + * src/threads/threads-common.h (threads_table_entry_t): Made a + struct and renamed nextfree to next. (threads_table_get): Added + (threads_table_get_non_daemons): Likewise. (threads_table_first): + Likewise. (threads_table_next): Likewise. [!NDEBUG] + (threads_table_dump): Likewise. (threads_impl_table_init): Likewise. + (threads_table_lock): Likewise. (threads_table_unlock): Likewise. + (threads_set_current_threadobject): Likewise. + + * src/threads/native/threads.c (threadlistlock): Removed. + (threads_impl_preinit): Removed main-thread initialization code. + (threads_impl_table_init): New function. (threads_table_lock): New + function. (threads_table_unlock): Likewise. (threads_init): Get + main-thread from threads-table and removed thread-list code. + (threads_attach_current_thread): Likewise. (threads_detach_thread): + Removed thread-list code. (threads_find_non_daemon_thread): Removed. + (threads_join_all_threads): Use threads_table_get_non_daemons. + [0700dff8d4c1] + + * src/vm/jit/powerpc/linux/md-os.c: + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Added uClibc support. (md_signal_handler_sigtrap): Likewise. + (md_signal_handler_sigusr2): Likewise. + (thread_restartcriticalsection): Likewise. + [059aa5d19855] + +2007-05-01 pm + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/disass.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md.c, + src/vm/jit/s390/tests/dacapo.status: + * src/vm/jit/s390/md.c (md_dump_context): Added. Fatal signals now + print the context and a stacktrace. + * src/vm/jit/s390/emit.h (emit_restore_pv): Added. Fixes bug where + REG_PV recalculation uses dseg value to recalculate REG_PV. + * src/vm/jit/s390/emit.c: Likewise. + * src/vm/jit/s390/codegen.h (N_RI, N_RI2): Test immediate operand for + correct signedness. + * src/vm/jit/s390/codegen.c (codegen_emit): Use emit_restore_pv for + REG_PV recalculation/ + * src/vm/jit/s390/disass.c (disass_pseudo_instr): Fix formating. + * src/vm/jit/s390/tests/dacapo.status: Added. + [ff3277613b53] + +2007-05-01 ajordan + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h: + * src/vm/jit/sparc64/codegen.h: Removed unused var_to_reg_int + define. + + * src/vm/jit/sparc64/codegen.c: Fixed JIT float argument passing via + stack. + + * src/vm/jit/sparc64/asmpart.S (asm_vm_call): Fixed integer argument + passing via stack args. + [e33c45b78466] + +2007-05-01 pm + + * src/vm/jit/s390/codegen.h: + * src/vm/jit/s390/codegen.h (gen_bound_check, + gen_nullptr_check_intern, gen_bound_check, N_LONG_0): Remove because + obsolete. + [d859db890556] + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/disass.c: + * src/vm/jit/s390/codegen.c (codegen_emit): Use new emit_label and + emit_label_* functions. + * src/vm/jit/s390/disass.c (disass_pseudo_instr): Nicer formatting for + ill pseudo instruction. + [cc1ac3e37507] + + * src/vm/jit/emit-common.h: + * src/vm/jit/emit-common.h (BRANCH_LABEL_6): Added. + [b90fe58b8782] + +2007-05-01 tbfg + + * src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-os.c: + * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): Support + EXCEPTION_HARDWARE_ARITHMETIC. + + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Use corret opcode for + word forms. + + * src/vm/jit/m68k/codegen.c (ICMD_IDIVPOW2): Implemented. + (ICMD_IREMPOW2): Implemented. (ICMD_ISHLCONST): Fixed. + (ICMD_ISHRCONST): Fixed. (ICMD_IUSHRCONST): Fixed. (ICMD_SALOAD): + Signextension fix. (ICMD_LALOAD): Implemented. (ICMD_LASTORE): + Fixed. (ICMD_IASTORE): Fixed. (ICMD_MULITANEWARRAY): Fixed. + + * src/vm/jit/m68k/codegen.h (M_IADDX): Added. (M_IXOR): Fixed. + (M_BCS): Fixed. + [89edfe323c24] + +2007-04-30 tbfg + + * src/vm/jit/m68k/asmpart.S: + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Restore + registers correctly. + [967120c3cdb9] + +2007-04-30 twisti + + * src/vm/jit/inline/Makefile.am: + * src/vm/jit/inline/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + [e8368e38b6ec] + +2007-04-30 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/stacktrace.c: + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed. + (emit_arithmetic_check): Implemented. + + * src/vm/jit/m68k/md.c (md_get_method_patch_address): Changed + invoking register. (md_stacktrace_get_returnaddress): Fix for + linking words on stack. + + * src/vm/jit/m68k/codegen.c (IUSHRCONST): Fix. (ICMD_IOR): + Implemented. (ICMD_IORCONST): Likewise. (ICMD_IXOR): Likewise. + (ICMD_IXORCONST): Likewise. (ICMD_INVOKEVIRTUAL): Changed invoking + register. (ICMD_INVOKEINTERFACE): Likewise. + + * src/vm/jit/m68k/patcher.c (patcher_invokevirtual): Changed + invoking register. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method_exception_handler): + Proper stack restauration. (L_asm_call_jit_compiler_exception): + Implemented. (asm_patcher_wrapper): Fixses. + (L_asm_patcher_wrapper_exception): Implemented. + + * src/vm/jit/m68k/codegen.h (M_IXOR): Added. (M_IOR_IMM): Added. + (M_IXOR_IMM): Added. + + * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): + Comment and further m68k stuff. + [2ac9ff4e6c4d] + +2007-04-29 pm + + * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/disass.c, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/machine-instr.h, + src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390 + /md-asm.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/machine-instr.h, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h, src/vm/jit/s390 + /md-asm.h, src/vm/jit/s390/disass.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-abi.c: Adapted S390 + port to changes from branches/twisti (hardware exceptions, + emit_branch, abi_registers_*), jctest works again. Cleaned up almost + all dead x86_64 code. + [2ec074267d97] + +2007-04-28 ajordan + + * src/vm/jit/sparc64/asmpart.S: + * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Fixed stack + alignement in first save. + [65770b01fe81] + +2007-04-27 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h, + src/vm/jit/m68k/machine-instr.h, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/emit.c (emit_arrayindexoutofbounds_check): Fixed. + * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigill): AIOOB + fixed. Editor boiler plate added. + + * src/vm/jit/m68k/linux/md-os.h: Editor boiler plate. + + * src/vm/jit/m68k/linux/md-abi.c: Likewise. + + * src/vm/jit/m68k/md.c: Likewise. + + * src/vm/jit/m68k/machine-instr.h: Likewise. + + * src/vm/jit/m68k/patcher.c: Editor boiler plate. + (patcher_invokeinterface): Implemented. (patcher_get_putfield): + Implemented. (patcher_resolve_class): Implemented. + (patcher_get_putstatic): Implemented. + + * src/vm/jit/m68k/codegen.c: Editor boiler plate. (ICMD_GETSTATIC): + Added patcher. (ICMD_AASTORE): Fixed. + + * src/vm/jit/m68k/asmpart.S: Editor boiler plate. + (asm_vm_call_method_exception_handler): Fixed used register. Return + values in %d0 and %a0 as gcc sometimes expects pointers in %a0. + [5b6400d328af] + +2007-04-27 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/solaris/md-os.c: + * src/vm/jit/sparc64/emit.c: Keeping stack 16-byte aligned when + calling C/native functions from the stack. (Solaris requires this) + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/sparc64/codegen.h: Likewise. + + * src/vm/jit/sparc64/md-abi.c: Removed zero sized abi_register_* + arrays. (not allowed in ISO C) + + * src/vm/jit/sparc64/solaris/md-os.c: Preliminary hardware exception + handling. (untested) + [e70daa591465] + +2007-04-26 twisti + + * src/vm/jit/inline/inline.h, src/vm/jit/jit.c: + * src/vm/jit/inline/inline.h (config.h): Added. (inline_inline): + Likewise. + + * src/vm/jit/jit.c (threads/threads-common.h): Added. + [ENABLE_INLINING] (vm/jit/inline/inline.h): Likewise. + [ENABLE_THREADS] (threads/native/threads.h): Removed. + [9544b7246cc7] + + * src/vm/vm.c: + * src/vm/vm.c [ENABLE_THREADS] (threads/native/threads.h): Removed. + (threads/threads-common.h): Added. + [13c16140a43d] + + * src/native/vm/java_lang_Thread.c: + * src/native/vm/java_lang_Thread.c: Set Id keyword. + [a0083a667694] + + * src/native/vm/java_lang_Thread.c: + * src/native/vm/java_lang_Thread.c (start): Renamed + threads_start_javathread to threads_thread_start. + [e25c3f63b5f1] + + * src/mm/memory.c, src/threads/native/threads.c, src/threads/threads- + common.c, src/threads/threads-common.h, src/vm/finalizer.c, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/signal.c: + * src/threads/threads-common.c (threads_thread_create_internal): + Renamed to threads_thread_start_internal and start the thread. + (threads_start_javathread): Renamed to threads_thread_start. + * src/threads/threads-common.h: Likewise. + + * src/threads/native/threads.c (threads_start_thread): Renamed to + threads_impl_thread_start. + + * src/mm/memory.c (thread_memory): Removed. (memory_start_thread): + Call threads_thread_start_internal. + + * src/vm/finalizer.c (thread_finalizer): Removed. + (finalizer_start_thread): Call threads_thread_start_internal. + + * src/vm/signal.c (thread_signal): Removed. (signal_start_thread): + Call threads_thread_start_internal. + + * src/vm/jit/optimizing/profile.c (thread_profile): Removed. + (profile_start_thread): Call threads_thread_start_internal. + + * src/vm/jit/optimizing/recompile.c (thread_recompile): Removed. + (recompile_start_thread): Call threads_thread_start_internal. + [cf0ec721a423] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.c (threads/critical.h): Added. + (threads/native/threads.h): Removed. (threads_table): Added. + (threads_preinit): New function. (threads_table_init): Moved from + implementation file. (threads_table_add): Likewise. + (threads_table_remove): Likewise. (threads_table_dump): Likewise. + + * src/threads/threads-common.h (threads_table_entry_t) + (threads_table_t): Added. (threads_preinit): Likewise. + (threads_table_add): Likewise. (threads_table_remove): Likewise. + (threads_impl_preinit): Likewise. (threads_init_threadobject): + Likewise. + + * src/threads/native/threads.c (threads_table): Removed. + (threads_preinit): Renamed to threads_impl_preinit. + (threads_table_init): Removed. (threads_table_add): Likewise. + (threads_table_remove): Likewise. (threads_table_dump): Likewise. + + * src/threads/native/threads.h (threads_table_entry_t) + (threads_table_t): Removed. (threads_preinit): Likewise. + [98b0208c933b] + +2007-04-25 stefan + + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c: added threads/threads-common.h, + removed vm/jit/i386/md-abi.h + [b40b6e3adec2] + + * src/vm/jit/i386/darwin/md-os.c: + * src/vm/jit/i386/darwin/md-os.c: attempt at porting the exception + changes (see r7596 & r7648). + [e46dd5485bb0] + +2007-04-25 twisti + + * src/threads/lock-common.h, src/threads/threads-common.c, src/threads + /threads-common.h: + * src/threads/lock-common.h (threads/threads-common.h): Removed that + header again and added a comment about not including thread headers. + + * src/threads/threads-common.c (threads_start_javathread): Reverted. + * src/threads/threads-common.h (threads_start_javathread): Likewise. + [823fb8fdda16] + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_dump) [!SIZEOF_VOID_P == 8]: + Fixed warning. + [b96d90a7e7d5] + + * src/threads/lock-common.h, src/threads/threads-common.c, src/threads + /threads-common.h: + * src/threads/threads-common.c (threads_start_javathread): Changed + signature. + + * src/threads/lock-common.h (threads/threads-common.h): Added. + [ENABLE_THREADS]: Only define functions when threads are enabled. + + * src/threads/threads-common.h (native/include/java_lang_Thread.h): + Removed. [ENABLE_THREADS]: Only define functions when threads are + enabled. (threads_start_javathread): Changed signature. + [744b5d438408] + + * src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c: + * src/vm/jit/mips/codegen.c: Changed lock includes. + * src/vm/jit/mips/emit.c: Likewise. + [901b6ff89903] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c: + * src/vm/jit/arm/codegen.c: Changed lock include. + * src/vm/jit/arm/emit.c: Likewise. + [9fc8e573ad28] + + * src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_load): Use switch-case instead of if- + else contruct. (emit_store): Likewise. (emit_copy): Likewise. + [a191766f4557] + + * src/vm/jit/alpha/emit.c: + * src/vm/jit/alpha/emit.c: Set Id keyword. + [b4b601dd0a67] + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c: + * src/vm/jit/alpha/codegen.c: Changed lock include. + * src/vm/jit/alpha/emit.c: Likewise. + [06bc88907312] + + * src/vm/jit/alpha/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit_stub_native): Use + md->params to save and restore argument registers. + [1cf56ebf1324] + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c: + * src/vm/jit/i386/codegen.c: Changed lock include. + * src/vm/jit/i386/emit.c: Likewise. + [3d8268805f33] + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c: + * src/vm/jit/powerpc64/codegen.c: Changed lock includes. + * src/vm/jit/powerpc64/emit.c: Likewise. + [829ba893ab30] + + * src/vm/jit/powerpc/emit.c: + * src/vm/jit/powerpc/emit.c: Set Id keyword. + [3970210193ef] + + * src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c: + * src/vm/jit/powerpc/codegen.c: Fixed lock include. + * src/vm/jit/powerpc/emit.c: Likewise. + [6d8fd28976c5] + + * src/vm/jit/powerpc/linux/md-abi.c: + * src/vm/jit/powerpc/linux/md-abi.c (abi_registers_float_temporary): + Fixed number of registers. + [43002ce63f4b] + + * src/mm/memory.c, src/native/jni.c, src/native/native.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c, + src/threads/Makefile.am, src/threads/lock-common.h, + src/threads/native/lock.h, src/threads/native/threads.c, + src/threads/none/lock.h, src/threads/threads-common.c, + src/toolbox/avl.c, src/toolbox/hashtable.c, src/toolbox/list.c, + src/vm/builtin.c, src/vm/finalizer.c, src/vm/initialize.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c, + src/vm/jit/patcher.h, src/vm/jit/show.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/string.c, src/vmcore/class.c, src/vmcore/classcache.c, + src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/suck.c, + src/vmcore/utf8.c: + * src/threads/lock-common.h: New file. + + * src/threads/native/lock.h: Removed function prototypes. + * src/threads/none/lock.h (LOCK_INIT_OBJECT_LOCK): Added. + + * src/mm/memory.c, src/native/jni.c, src/native/native.c, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c, + src/threads/Makefile.am, src/threads/native/threads.c, src/threads + /threads-common.c, src/toolbox/avl.c, src/toolbox/hashtable.c, + src/toolbox/list.c, src/vm/builtin.c, src/vm/finalizer.c, + src/vm/initialize.c, src/vm/jit/inline/inline.c, src/vm/jit/jit.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c, + src/vm/jit/patcher.h, src/vm/jit/show.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/string.c, src/vmcore/class.c, src/vmcore/classcache.c, + src/vmcore/linker.c, src/vmcore/loader.c, src/vmcore/suck.c, + src/vmcore/utf8.c: Updated headers. + [70b6420148e2] + + * src/mm/memory.h: + * src/mm/memory.h: Updated copyright header. + [c16a6646ceb2] + + * src/mm/memory.c, src/threads/native/threads.c, src/threads/threads- + common.c, src/threads/threads-common.h, src/vm/finalizer.c, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/signal.c: + * src/threads/threads-common.c (threads_create_thread): Renamed to + threads_thread_create_internal and a new function. + (threads_start_javathread): Use threads_create_thread. + + * src/threads/threads-common.h (threads_create_thread): Changed + signature. (threads_thread_create_internal): Added. + + * src/threads/native/threads.c (threads_set_current_threadobject): + Made non-static. (threads_init_threadobject): Likewise, use + threads_create_thread. (threads_init): Cleanup. + (threads_startup_thread): Likewise. (threads_attach_current_thread): + Use threads_create_thread. + + * src/vm/jit/optimizing/profile.c (profile_start_thread): Replaced + threads_create_thread with threads_thread_create_internal. + * src/vm/jit/optimizing/recompile.c (recompile_start_thread): + Likewise. + * src/vm/signal.c (signal_start_thread): Likewise. + * src/vm/finalizer.c (finalizer_start_thread): Likewise. + * src/mm/memory.c (memory_start_thread): Likewise. + [052522c1db52] + +2007-04-25 stefan + + * src/vmcore/linker.c: + * src/vmcore/linker.c (linker_init): added missing + lock_init_object_lock. + [191964287e88] + +2007-04-25 twisti + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_preinit): We always need + variable t. + [b88c5990edf2] + + * src/native/native.c: + * src/native/native.c (native/include/java_lang_Object.h): Include + always. [ENABLE_JAVAME_CLDC1_1] + (native/include/com_sun_cldc_io_ResourceInputStream.h) + (native/include/com_sun_cldc_io_j2me_socket_Protocol.h): Added. + [f994e6222404] + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_init): Use variable t + instead of mainthreadobj->object, makes code simpler. + [a0a835dd24fe] + + * src/threads/native/threads.c, src/threads/threads-common.c: + * src/threads/threads-common.c (threads_create_thread) + [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE. + (threads_start_javathread) [ENABLE_GC_BOEHM]: Likewise. + + * src/threads/native/threads.c (threads_preinit) [ENABLE_GC_BOEHM]: + Likewise. (threads_init): Removed resizing-of-threadobject code, we + don't need it anymore. (threads_attach_current_thread) + [ENABLE_GC_BOEHM]: Use GCNEW_UNCOLLECTABLE. (threads_detach_thread) + [ENABLE_GC_BOEHM]: Use GCFREE. + [af7e5b77a250] + +2007-04-24 twisti + + * src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.c: Set Id keyword. + * src/threads/threads-common.h: Likewise. + [ae9e95a7b28d] + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_dump): Also print integer + thread id, so it's easier to compare with the ones from gdb. + [249c326e0a4b] + +2007-04-24 tbfg + + * m4/threads.m4: + * threads.m4: Fixed a typo + [7a9720e29965] + +2007-04-23 twisti + + * contrib/.cvsignore, doc/.cvsignore, doc/handbook/.cvsignore, + man/.cvsignore, src/.cvsignore, src/cacao/.cvsignore, + src/cacaoh/.cvsignore, src/fdlibm/.cvsignore, src/lib/.cvsignore, + src/mm/.cvsignore, src/mm/boehm-gc/.cvsignore, src/mm/boehm- + gc/doc/.cvsignore, src/mm/boehm-gc/include/.cvsignore, src/mm/cacao- + gc/.cvsignore, src/native/.cvsignore, src/native/include/.cvsignore, + src/native/jvmti/.cvsignore, src/native/tools/.cvsignore, + src/native/vm/.cvsignore, src/native/vm/cldc1.1/.cvsignore, + src/native/vm/gnu/.cvsignore, src/scripts/.cvsignore, + src/threads/.cvsignore, src/threads/native/.cvsignore, + src/threads/none/.cvsignore, src/toolbox/.cvsignore, + src/vm/.cvsignore, src/vm/jit/.cvsignore, + src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore, + src/vm/jit/alpha/freebsd/.cvsignore, + src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/arm/.cvsignore, + src/vm/jit/arm/linux/.cvsignore, src/vm/jit/i386/.cvsignore, + src/vm/jit/i386/darwin/.cvsignore, + src/vm/jit/i386/freebsd/.cvsignore, + src/vm/jit/i386/linux/.cvsignore, src/vm/jit/inline/.cvsignore, + src/vm/jit/intrp/.cvsignore, src/vm/jit/loop/.cvsignore, + src/vm/jit/m68k/.cvsignore, src/vm/jit/m68k/linux/.cvsignore, + src/vm/jit/mips/.cvsignore, src/vm/jit/mips/irix/.cvsignore, + src/vm/jit/mips/linux/.cvsignore, src/vm/jit/optimizing/.cvsignore, + src/vm/jit/parisc/.cvsignore, src/vm/jit/parisc/linux/.cvsignore, + src/vm/jit/powerpc/.cvsignore, src/vm/jit/powerpc/darwin/.cvsignore, + src/vm/jit/powerpc/linux/.cvsignore, + src/vm/jit/powerpc/netbsd/.cvsignore, + src/vm/jit/powerpc64/.cvsignore, + src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/s390/.cvsignore, + src/vm/jit/schedule/.cvsignore, src/vm/jit/sparc64/.cvsignore, + src/vm/jit/sparc64/linux/.cvsignore, + src/vm/jit/sparc64/solaris/.cvsignore, src/vm/jit/tools/.cvsignore, + src/vm/jit/verify/.cvsignore, src/vm/jit/x86_64/.cvsignore, + src/vm/jit/x86_64/freebsd/.cvsignore, + src/vm/jit/x86_64/linux/.cvsignore, src/vmcore/.cvsignore, + tests/.cvsignore, tests/regression/.cvsignore, + tests/regression/codepatching/.cvsignore, + tests/regression/native/.cvsignore, tests/stack/.cvsignore: + * contrib/.cvsignore, doc/.cvsignore, doc/handbook/.cvsignore, + man/.cvsignore, src/.cvsignore, src/cacao/.cvsignore, + src/cacaoh/.cvsignore, src/fdlibm/.cvsignore, src/lib/.cvsignore, + src/mm/.cvsignore, src/mm/boehm-gc/.cvsignore, src/mm/boehm- + gc/doc/.cvsignore, src/mm/boehm-gc/include/.cvsignore, src/mm/cacao- + gc/.cvsignore, src/native/.cvsignore, src/native/include/.cvsignore, + src/native/jvmti/.cvsignore, src/native/tools/.cvsignore, + src/native/vm/.cvsignore, src/native/vm/cldc1.1/.cvsignore, + src/native/vm/gnu/.cvsignore, src/scripts/.cvsignore, + src/threads/.cvsignore, src/threads/none/.cvsignore, + src/threads/posix/.cvsignore, src/toolbox/.cvsignore, + src/vm/.cvsignore, src/vm/jit/.cvsignore, + src/vm/jit/allocator/.cvsignore, src/vm/jit/alpha/.cvsignore, + src/vm/jit/alpha/freebsd/.cvsignore, + src/vm/jit/alpha/linux/.cvsignore, src/vm/jit/arm/.cvsignore, + src/vm/jit/arm/linux/.cvsignore, src/vm/jit/i386/.cvsignore, + src/vm/jit/i386/cygwin/.cvsignore, + src/vm/jit/i386/darwin/.cvsignore, + src/vm/jit/i386/freebsd/.cvsignore, + src/vm/jit/i386/linux/.cvsignore, src/vm/jit/inline/.cvsignore, + src/vm/jit/intrp/.cvsignore, src/vm/jit/loop/.cvsignore, + src/vm/jit/m68k/.cvsignore, src/vm/jit/m68k/linux/.cvsignore, + src/vm/jit/mips/.cvsignore, src/vm/jit/mips/irix/.cvsignore, + src/vm/jit/mips/linux/.cvsignore, src/vm/jit/optimizing/.cvsignore, + src/vm/jit/parisc/.cvsignore, src/vm/jit/parisc/linux/.cvsignore, + src/vm/jit/powerpc/.cvsignore, src/vm/jit/powerpc/darwin/.cvsignore, + src/vm/jit/powerpc/linux/.cvsignore, + src/vm/jit/powerpc/netbsd/.cvsignore, + src/vm/jit/powerpc64/.cvsignore, + src/vm/jit/powerpc64/linux/.cvsignore, src/vm/jit/s390/.cvsignore, + src/vm/jit/schedule/.cvsignore, src/vm/jit/sparc64/.cvsignore, + src/vm/jit/sparc64/linux/.cvsignore, + src/vm/jit/sparc64/solaris/.cvsignore, src/vm/jit/tools/.cvsignore, + src/vm/jit/verify/.cvsignore, src/vm/jit/x86_64/.cvsignore, + src/vm/jit/x86_64/freebsd/.cvsignore, + src/vm/jit/x86_64/linux/.cvsignore, src/vmcore/.cvsignore, + tests/.cvsignore, tests/regression/.cvsignore, + tests/regression/codepatching/.cvsignore, + tests/regression/jasmin/.cvsignore, + tests/regression/native/.cvsignore, tests/stack/.cvsignore: Removed. + [9cfa2b402d78] + + * .cvsignore: + * .cvsignore: Removed. + [de2254a5a0f4] + + * configure.ac, m4/threads.m4: + * configure.ac: Removed --enable-threads checks and call instead + AC_CHECK_ENABLE_THREADS. + * m4/threads.m4: New file. + [fd1ace174105] + +2007-04-23 michi + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_find_replacement_point_for_pc): + Added assertion. (replace_recover_source_state) [ENABLE_GC_CACAO]: + Now recovers native frames. + [353654378d75] + + * configure.ac, contrib/Makefile.am, contrib/vmlog/Makefile, + contrib/vmlog/README, contrib/vmlog/vmlog_cacao.patch, + src/cacaoh/dummy.c, src/mm/cacao-gc/final.c, src/mm/cacao- + gc/final.h, src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/threads/native/Makefile.am, src/threads/native/lock.c, + src/threads/threads-common.h, src/toolbox/list.c, + src/toolbox/list.h, src/vm/Makefile.am, src/vm/builtin.c, + src/vm/builtin.h, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/jit/Makefile.am, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/emit-common.c, + src/vm/jit/intrp/asmpart.c, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/jit/optimizing/recompile.h, src/vm/jit/powerpc/darwin/md- + abi.c, src/vm/jit/powerpc/darwin/md-abi.h, src/vm/jit/powerpc/darwin + /md-os.c, src/vm/jit/replace.c, src/vm/jit/sparc64/arch.h, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md.c, src/vm/jit/stacktrace.c, + src/vm/properties.c, src/vm/signal.c, src/vm/vm.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c, + src/vmcore/suck.h, tests/regression/resolving/Makefile.am: + Merged revisions 7766-7796 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7769 | tbfg | 2007-04-19 17:01:49 +0200 (Thu, 19 Apr + 2007) | 16 lines + + * src/vm/jit/m68k/linux/md-abi.c (abi_registers_integer_saved): + Fixed. (abi_registers_float_saved): Fixed. + + * src/vm/jit/m68k/emit.c (emit_classcast_check): Fixed. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Temporary hacked a + field for saved adr registers until real patch will be done. + (ICMD_INSTANCEOF): Fixed. (ICMD_CHECKCAST): Fixed. + (codegen_emit_stub_compiler): Removed useless code. + + * src/vm/jit/m68k/asmpart.S (L_asm_handle_exception_not_catched): + Implemented. + + * src/vm/jit/m68k/codegen.h (M_BLS): Added. ........ r7770 | + twisti | 2007-04-19 21:39:06 +0200 (Thu, 19 Apr 2007) | 20 lines + + * src/vm/jit/powerpc/darwin/md-abi.h (REG_FA0, REG_FA1): Added. + (REG_A0_A1_PACKED, REG_A2_A3_PACKED): Likewise. + + * src/vm/jit/powerpc/darwin/md-os.c [ENABLE_THREADS] + (threads/native/threads.h): Added. (md_signal_handler_sigsegv): + Changed for hardware-exceptions. (md_signal_handler_sigtrap): New + function. + + * src/vm/jit/powerpc/darwin/md-abi.c (vm/descriptor.h): Changed to + vmcore/descriptor.h. (regs): Renamed to + abi_registers_integer_name. (abi_registers_integer_argument): + Added. (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. + (abi_registers_float_argument): Likewise. + (abi_registers_float_saved): Likewise. + (abi_registers_float_temporary): Likewise. (md_param_alloc): Use + new register arrays. (md_param_alloc_native): New function. + ........ r7771 | twisti | 2007-04-19 21:41:08 +0200 (Thu, 19 Apr + 2007) | 5 lines + + * src/cacaoh/dummy.c (exceptions_print_current_exception): Added + abort. (exceptions_throw_outofmemoryerror): Removed. + (exceptions_throw_illegalaccessexception): Likewise. ........ + r7772 | twisti | 2007-04-19 21:43:39 +0200 (Thu, 19 Apr 2007) | 5 + lines + + * src/vm/signal.c (assert.h): Added. (vm/exceptions.h): + Likewise. [ENABLE_STATISTICS] (vmcore/statistics.h): Likewise. + (signal_init): Added hardware-exception assert. ........ r7773 | + twisti | 2007-04-19 21:44:54 +0200 (Thu, 19 Apr 2007) | 3 lines + + * src/vm/exceptions.h: Added a comment about the hardware- + exception assert in signal_init. ........ r7774 | twisti | + 2007-04-19 21:58:08 +0200 (Thu, 19 Apr 2007) | 2 lines + + * configure.ac (AC_INIT): Changed version to 0.98rc. ........ + r7775 | twisti | 2007-04-19 21:59:17 +0200 (Thu, 19 Apr 2007) | 3 + lines + + * tests/regression/resolving/Makefile.am (check): Added missing + JAVAFLAGS. ........ r7776 | twisti | 2007-04-19 23:31:47 +0200 + (Thu, 19 Apr 2007) | 3 lines + + * src/vm/signal.c (signal_thread): Check return value of sig* + functions. ........ r7777 | twisti | 2007-04-20 13:21:38 +0200 + (Fri, 20 Apr 2007) | 2 lines + + * src/threads/threads-common.h (native/jni.h): Added. ........ + r7778 | twisti | 2007-04-20 14:40:05 +0200 (Fri, 20 Apr 2007) | 3 + lines + + * src/vm/jit/codegen-common.c (codegen_finish_native_call): #ifdef + lrt and plrt. Don't set lrt, we don't need it. ........ r7779 | + twisti | 2007-04-20 14:48:55 +0200 (Fri, 20 Apr 2007) | 2 lines + + * src/vm/vm.c (vm_create): Print unknown -verbose option. ........ + r7780 | twisti | 2007-04-20 14:53:45 +0200 (Fri, 20 Apr 2007) | 2 + lines + + * src/vm/vm.c (version): Print libjvm.so path. ........ r7781 | + twisti | 2007-04-20 15:06:45 +0200 (Fri, 20 Apr 2007) | 4 lines + + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (loadLibrary): + Fixed string-internal warnings. + * src/native/vm/cldc1.1/java_lang_System.c (getProperty0): Likewise. + ........ r7782 | twisti | 2007-04-20 15:09:36 +0200 (Fri, 20 Apr + 2007) | 2 lines + + * src/vm/vm.c: Changed header order to prevent a warning. ........ + r7783 | twisti | 2007-04-20 15:28:27 +0200 (Fri, 20 Apr 2007) | 16 + lines + + * src/toolbox/list.h (listnode): Renamed to listnode_t. (list): + Renamed to list_t. + + * src/toolbox/list.c, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/emit-common.c, + src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, + src/vm/jit/optimizing/recompile.h, src/vm/properties.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c, + src/vmcore/suck.h: Likewise. ........ r7784 | twisti | 2007-04-20 + 15:51:41 +0200 (Fri, 20 Apr 2007) | 9 lines + + * src/toolbox/list.h (list_t): Added size. + + * src/toolbox/list.c (list_create): Initialize size. + (list_create_dump): Likewise. (list_add_first): Increase size. + (list_add_last_unsynced): Likewise. (list_add_before): Likewise. + (list_remove_unsynced): Decrease size. ........ r7785 | edwin | + 2007-04-21 12:55:30 +0200 (Sat, 21 Apr 2007) | 6 lines + + * src/vm/jit/replace.c, src/vm/jit/intrp/asmpart.c, src/vm/jit + /codegen-common.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/vm.c, src/threads/native/lock.c (ENABLE_VMLOG): Applied the + vmlog patch and wrapped all inserted code with #if + defined(ENABLE_VMLOG). ........ r7786 | edwin | 2007-04-21 + 14:37:47 +0200 (Sat, 21 Apr 2007) | 6 lines + + * configure.ac (--enable-vmlog): New configure option. + + * src/vm/jit/Makefile.am, src/vm/Makefile.am, + src/threads/native/Makefile.am (AM_CPPFLAGS): Added -I for vmlog + includes. ........ r7787 | edwin | 2007-04-21 14:48:14 +0200 (Sat, + 21 Apr 2007) | 3 lines + + * contrib/vmlog/vmlog_cacao.patch: Removed. It is no longer + needed. + * contrib/vmlog/README: Updated for CACAO's --enable-vmlog. ........ + r7788 | edwin | 2007-04-21 18:26:34 +0200 (Sat, 21 Apr 2007) | 2 + lines + + * contrib/vmlog/Makefile: Renamed to maintain.mk. ........ r7789 + | edwin | 2007-04-21 18:42:52 +0200 (Sat, 21 Apr 2007) | 4 lines + + * configure.ac: Generate vmlog Makefiles. + * contrib/Makefile.am: Added vmlog to SUBDIRS. + * contrib/vmlog/Makefile.am, contrib/vmlog/t/Makefile.am: New files. + ........ r7790 | edwin | 2007-04-21 20:56:43 +0200 (Sat, 21 Apr + 2007) | 3 lines + + * tests/regression/resolving/Makefile.am: Added "-classpath ." to + javac options so the tests work with ecj out-of-the-box. ........ + r7791 | ajordan | 2007-04-22 17:55:51 +0200 (Sun, 22 Apr 2007) | 13 + lines + + * src/vm/jit/sparc64/arch.h: Properly activated all FP features + SPARC64 supports in hardware. + + * src/vm/jit/sparc64/asmpart.S: Added functions to read/write the + FP state register. + * src/vm/jit/sparc64/md.c: Added prototypes here. + + * src/vm/jit/sparc64/codegen.h: Added 'branch on FP condition + codes' macros. + + * src/vm/jit/sparc64/emit.c (emit_verbosecall_enter): Fixed FP + argument passing. + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed FP conversion + functions to (a) use unique slots in the data segment (doh!), (b) + catch the case where NaN is converted to an integer value. (JVMS and + SPARC do not inherently agree here). ........ r7792 | tbfg | + 2007-04-22 22:02:05 +0200 (Sun, 22 Apr 2007) | 31 lines + + * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigsegv): + Implemented. (md_signal_handler_sigill): More exceptions handled. + Some fixes. + + * src/vm/jit/m68k/linux/md-os.h + (M68K_EXCEPTION_HARDWARE_NULLPOINTER): Used instead of + EXCEPTION_HARDWARE_NULLPOINTER, because a trap with value #0 will + not be taken. + + * src/vm/jit/m68k/emit.c (emit_load_[low|high]): Fixed assertion. + (emit_arrayindexoutofbounds_check): Implemented. + (emit_nullpointer_check): Implemented. + (emit_exception_check_ireg): Renamed emit_exception_check. + (emit_exception_check_areg): Disabled code. + (emit_exception_check): Implemented. + + * src/vm/jit/m68k/codegen.c (ICMD_LALOAD): Implemented. + (ICMD_FALOAD): Implemented. (ICMD_DALOAD): Implemented. + (ICMD_LASTORE): Implemented. (ICMD_FASTORE): Implemented. + (ICMD_DASTORE): Implemented. (ICMD_BUILTIN): Exception check + enabled. (ICMD_MULTIANEWARRAY): Implemented. + (codegen_emit_stub_native): Exception check implemented. + + * src/vm/jit/m68k/asmpart.S (asm_handle_nat_exception): Symbol + exported and implemented. + + * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): + More m68k fixes. ........ r7793 | twisti | 2007-04-23 16:29:48 + +0200 (Mon, 23 Apr 2007) | 3 lines + + * src/vm/signal.c (signal_thread): Don't check for an error on + sigwait (revisit this patch with the exact-GC). ........ r7795 | + twisti | 2007-04-23 22:03:38 +0200 (Mon, 23 Apr 2007) | 2 lines + + * src/vm/builtin.h (md-abi.h): Added. ........ r7796 | twisti | + 2007-04-23 22:04:44 +0200 (Mon, 23 Apr 2007) | 4 lines + + * configure.ac: Removed all classpath related checks and made + functions for them. + * m4/classpath.m4: New file. ........ + [260c33906953] + +2007-04-23 twisti + + * configure.ac, m4/classpath.m4: + * configure.ac: Removed all classpath related checks and made + functions for them. + * m4/classpath.m4: New file. + [a6ecb4be61c9] + + * src/vm/builtin.h: + * src/vm/builtin.h (md-abi.h): Added. + [27f5944a2194] + +2007-04-23 michi + + * configure.ac, contrib/vmlog/Makefile, contrib/vmlog/README, + contrib/vmlog/vmlog_cacao.patch, src/toolbox/list.c, + src/toolbox/list.h, src/vm/Makefile.am, src/vm/exceptions.c, + src/vm/jit/i386/codegen.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.h, src/vm/jit/powerpc/darwin/md-os.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit): Builtin stubs are + called for ICMD_BUILTIN if available. + + * src/vm/jit/i386/codegen.c (codegen_emit): Likewise. + (codegen_emit_stub_builtin): Adapted to new signature and a bugfix. + [f8c80a7d7861] + +2007-04-23 twisti + + * src/vm/signal.c: + * src/vm/signal.c (signal_thread): Don't check for an error on + sigwait (revisit this patch with the exact-GC). + [316672080a9f] + +2007-04-22 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h, + src/vm/jit/stacktrace.c: + * src/vm/jit/m68k/linux/md-os.c (md_signal_handler_sigsegv): + Implemented. (md_signal_handler_sigill): More exceptions handled. + Some fixes. + + * src/vm/jit/m68k/linux/md-os.h + (M68K_EXCEPTION_HARDWARE_NULLPOINTER): Used instead of + EXCEPTION_HARDWARE_NULLPOINTER, because a trap with value #0 will + not be taken. + + * src/vm/jit/m68k/emit.c (emit_load_[low|high]): Fixed assertion. + (emit_arrayindexoutofbounds_check): Implemented. + (emit_nullpointer_check): Implemented. (emit_exception_check_ireg): + Renamed emit_exception_check. (emit_exception_check_areg): Disabled + code. (emit_exception_check): Implemented. + + * src/vm/jit/m68k/codegen.c (ICMD_LALOAD): Implemented. + (ICMD_FALOAD): Implemented. (ICMD_DALOAD): Implemented. + (ICMD_LASTORE): Implemented. (ICMD_FASTORE): Implemented. + (ICMD_DASTORE): Implemented. (ICMD_BUILTIN): Exception check + enabled. (ICMD_MULTIANEWARRAY): Implemented. + (codegen_emit_stub_native): Exception check implemented. + + * src/vm/jit/m68k/asmpart.S (asm_handle_nat_exception): Symbol + exported and implemented. + + * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframe): + More m68k fixes. + [f5b35b44de35] + +2007-04-22 ajordan + + * src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c: + * src/vm/jit/sparc64/arch.h: Properly activated all FP features + SPARC64 supports in hardware. + + * src/vm/jit/sparc64/asmpart.S: Added functions to read/write the FP + state register. + * src/vm/jit/sparc64/md.c: Added prototypes here. + + * src/vm/jit/sparc64/codegen.h: Added 'branch on FP condition codes' + macros. + + * src/vm/jit/sparc64/emit.c (emit_verbosecall_enter): Fixed FP + argument passing. + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed FP conversion + functions to (a) use unique slots in the data segment (doh!), (b) + catch the case where NaN is converted to an integer value. (JVMS and + SPARC do not inherently agree here). + [2871672fa702] + +2007-04-21 edwin + + * tests/regression/resolving/Makefile.am: + * tests/regression/resolving/Makefile.am: Added "-classpath ." to + javac options so the tests work with ecj out-of-the-box. + [7854d14c2197] + + * configure.ac, contrib/Makefile.am, contrib/vmlog/Makefile.am, + contrib/vmlog/t/Makefile.am: + * configure.ac: Generate vmlog Makefiles. + * contrib/Makefile.am: Added vmlog to SUBDIRS. + * contrib/vmlog/Makefile.am, contrib/vmlog/t/Makefile.am: New files. + [c695e40c9ca0] + + * contrib/vmlog/Makefile, contrib/vmlog/maintain.mk: + * contrib/vmlog/Makefile: Renamed to maintain.mk. + [cf73c926d5a8] + + * contrib/vmlog/README, contrib/vmlog/vmlog_cacao.patch: + * contrib/vmlog/vmlog_cacao.patch: Removed. It is no longer needed. + * contrib/vmlog/README: Updated for CACAO's --enable-vmlog. + [550f98d25763] + + * configure.ac, src/threads/native/Makefile.am, src/vm/Makefile.am, + src/vm/jit/Makefile.am: + * configure.ac (--enable-vmlog): New configure option. + + * src/vm/jit/Makefile.am, src/vm/Makefile.am, + src/threads/native/Makefile.am (AM_CPPFLAGS): Added -I for vmlog + includes. + [686e27b2c775] + + * src/threads/native/lock.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/jit/codegen-common.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/replace.c, src/vm/vm.c: + * src/vm/jit/replace.c, src/vm/jit/intrp/asmpart.c, src/vm/jit + /codegen-common.c, src/vm/builtin.c, src/vm/exceptions.c, + src/vm/vm.c, src/threads/native/lock.c (ENABLE_VMLOG): Applied the + vmlog patch and wrapped all inserted code with #if + defined(ENABLE_VMLOG). + [79cd1ec1bdfe] + +2007-04-20 twisti + + * src/toolbox/list.c, src/toolbox/list.h: + * src/toolbox/list.h (list_t): Added size. + + * src/toolbox/list.c (list_create): Initialize size. + (list_create_dump): Likewise. (list_add_first): Increase size. + (list_add_last_unsynced): Likewise. (list_add_before): Likewise. + (list_remove_unsynced): Decrease size. + [a3b9de93ae36] + + * src/toolbox/list.c, src/toolbox/list.h, src/vm/jit/codegen-common.c, + src/vm/jit/codegen-common.h, src/vm/jit/emit-common.c, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/jit/optimizing/recompile.h, src/vm/properties.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c, + src/vmcore/suck.h: + * src/toolbox/list.h (listnode): Renamed to listnode_t. (list): + Renamed to list_t. + + * src/toolbox/list.c, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/emit-common.c, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/jit/optimizing/recompile.h, src/vm/properties.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/suck.c, + src/vmcore/suck.h: Likewise. + [d364c8e90caf] + + * src/vm/vm.c: + * src/vm/vm.c: Changed header order to prevent a warning. + [e2130afe6ce2] + + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/cldc1.1/java_lang_System.c: + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (loadLibrary): + Fixed string-internal warnings. + * src/native/vm/cldc1.1/java_lang_System.c (getProperty0): Likewise. + [3392e29dc096] + + * src/vm/vm.c: + * src/vm/vm.c (version): Print libjvm.so path. + [cf8bfa7aacd0] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Print unknown -verbose option. + [1e0587f7990c] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_finish_native_call): #ifdef + lrt and plrt. Don't set lrt, we don't need it. + [4adb6a2ff2e2] + + * src/threads/threads-common.h: + * src/threads/threads-common.h (native/jni.h): Added. + [46a14c79e619] + +2007-04-19 twisti + + * src/vm/signal.c: + * src/vm/signal.c (signal_thread): Check return value of sig* + functions. + [c9b703e40679] + + * tests/regression/resolving/Makefile.am: + * tests/regression/resolving/Makefile.am (check): Added missing + JAVAFLAGS. + [ef74f05c14af] + + * configure.ac: + * configure.ac (AC_INIT): Changed version to 0.98rc. + [54cbdd59db94] + + * src/vm/exceptions.h: + * src/vm/exceptions.h: Added a comment about the hardware-exception + assert in signal_init. + [577088fbe91e] + + * src/vm/signal.c: + * src/vm/signal.c (assert.h): Added. (vm/exceptions.h): Likewise. + [ENABLE_STATISTICS] (vmcore/statistics.h): Likewise. (signal_init): + Added hardware-exception assert. + [f7ec08f8ba16] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (exceptions_print_current_exception): Added + abort. (exceptions_throw_outofmemoryerror): Removed. + (exceptions_throw_illegalaccessexception): Likewise. + [975230caffb6] + + * src/vm/jit/powerpc/darwin/md-abi.c, src/vm/jit/powerpc/darwin/md- + abi.h, src/vm/jit/powerpc/darwin/md-os.c: + * src/vm/jit/powerpc/darwin/md-abi.h (REG_FA0, REG_FA1): Added. + (REG_A0_A1_PACKED, REG_A2_A3_PACKED): Likewise. + + * src/vm/jit/powerpc/darwin/md-os.c [ENABLE_THREADS] + (threads/native/threads.h): Added. (md_signal_handler_sigsegv): + Changed for hardware-exceptions. (md_signal_handler_sigtrap): New + function. + + * src/vm/jit/powerpc/darwin/md-abi.c (vm/descriptor.h): Changed to + vmcore/descriptor.h. (regs): Renamed to abi_registers_integer_name. + (abi_registers_integer_argument): Added. + (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. + (abi_registers_float_argument): Likewise. + (abi_registers_float_saved): Likewise. + (abi_registers_float_temporary): Likewise. (md_param_alloc): Use new + register arrays. (md_param_alloc_native): New function. + [c7ade92ec34b] + +2007-04-19 tbfg + + * src/vm/jit/allocator/simplereg.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/mips/codegen.c, + src/vm/jit/parse.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/linux/Makefile.am, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/emit.c, src/vm/jit/stack.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/emit.c: + * src/vm/jit/m68k/linux/md-abi.c (abi_registers_integer_saved): + Fixed. (abi_registers_float_saved): Fixed. + + * src/vm/jit/m68k/emit.c (emit_classcast_check): Fixed. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Temporary hacked a field + for saved adr registers until real patch will be done. + (ICMD_INSTANCEOF): Fixed. (ICMD_CHECKCAST): Fixed. + (codegen_emit_stub_compiler): Removed useless code. + + * src/vm/jit/m68k/asmpart.S (L_asm_handle_exception_not_catched): + Implemented. + + * src/vm/jit/m68k/codegen.h (M_BLS): Added. + [84e697c2d473] + +2007-04-19 michi + + * src/mm/cacao-gc/final.c, src/mm/cacao-gc/gc.c, src/mm/cacao- + gc/mark.c: + * src/mm/cacao-gc/final.c: Cleaned up debug code. + * src/mm/cacao-gc/gc.c: Likewise. + * src/mm/cacao-gc/mark.c: Likewise. + [9f8ef49fa79b] + + * src/mm/cacao-gc/heap.c, src/mm/cacao-gc/heap.h: + * src/mm/cacao-gc/heap.h: Removed finalizer header flag. + + * src/mm/cacao-gc/heap.c (heap_alloc): Adapted to above changes. + (heap_print_object): Handle invalid heap references correctly. + [f2937900eaac] + + * src/native/vm/java_lang_ClassLoader.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/builtintable.inc, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/codegen- + common.c, src/vm/jit/emit-common.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/emit.c, src/vm/jit/inline/inline.c, + src/vm/jit/jit.h, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/parse.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/emit.c, src/vm/jit/powerpc64/linux/Makefile.am, + src/vm/jit/replace.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/emit.c, src/vm/jit/show.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/stack.c, src/vm/jit/verify + /typecheck-common.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, tests/regression/jasmin/Makefile.am, + tests/regression/resolving/Makefile.am: + Merged revisions 7732-7765 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7733 | twisti | 2007-04-17 00:56:37 +0200 (Tue, 17 Apr + 2007) | 3 lines + + * src/vm/jit/x86_64/codegen.c (codegen_emit): Made argument + passing cleaner. ........ r7734 | twisti | 2007-04-17 13:15:15 + +0200 (Tue, 17 Apr 2007) | 3 lines + + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Use + simpler code to save and restore argument registers. ........ + r7735 | edwin | 2007-04-17 20:47:50 +0200 (Tue, 17 Apr 2007) | 3 + lines + + * src/vm/jit/parse.c (parse): Small cleanup of local variable + renaming. (No code changes.) ........ r7736 | edwin | 2007-04-17 + 21:24:05 +0200 (Tue, 17 Apr 2007) | 5 lines + + * src/vm/jit/stack.c (stack_analyse): The javalocals array can + have negative values != UNUSED (these values < UNUSED represent + returnAddresses of local subroutines). Thus >= 0 must be used to + check for normal indices. ........ r7737 | edwin | 2007-04-17 + 21:57:55 +0200 (Tue, 17 Apr 2007) | 2 lines + + * src/vm/jit/stack.c (stack_javalocals_store): Added an assert. + ........ r7738 | edwin | 2007-04-17 22:06:44 +0200 (Tue, 17 Apr + 2007) | 2 lines + + * src/vm/jit/jit.h (jitdata): Cleaned up comments for local_map. + ........ r7739 | twisti | 2007-04-17 22:17:01 +0200 (Tue, 17 Apr + 2007) | 10 lines + + * src/threads/threads-common.c (threads_print_stacktrace): Renamed + to threads_thread_print_stacktrace. (threads_print_stacktrace): + New function. (threads_dump): Use threads_thread_print_stacktrace. + + * src/threads/threads-common.h: Likewise. + + * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Use new + threads_print_stacktrace. ........ r7740 | twisti | 2007-04-17 + 22:25:55 +0200 (Tue, 17 Apr 2007) | 4 lines + + * src/threads/native/threads.c (threads_init): Fixed string- + internal warnings. (threads_attach_current_thread): Likewise. + ........ r7741 | edwin | 2007-04-17 22:30:09 +0200 (Tue, 17 Apr + 2007) | 4 lines + + * src/vm/jit/jit.h (basicblock): Document the javalocal array. + (JAVALOCAL_FROM_RETADDR): New macro. (RETADDR_FROM_JAVALOCAL): + Likewise. ........ r7742 | edwin | 2007-04-17 22:37:36 +0200 (Tue, + 17 Apr 2007) | 4 lines + + * src/vm/jit/stack.c, src/vm/jit/show.c, + src/vm/jit/inline/inline.c, src/vm/jit/replace.c, + src/vm/jit/jit.h: Fix and use the new macros for calculating + javalocals values representing returnAddresses. ........ r7743 | + edwin | 2007-04-17 22:53:41 +0200 (Tue, 17 Apr 2007) | 6 lines + + * src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/inline/inline.c, + src/vm/jit/allocator/simplereg.c: Clarification: Renamed variables + that are indices into jd->var to "varindex". Renamed variables that + are bytecode variable indices to "javaindex". ........ r7744 | + twisti | 2007-04-17 22:54:04 +0200 (Tue, 17 Apr 2007) | 2 lines + + * tests/regression/jasmin/Makefile.am (check): Set + LD_LIBRARY_PATH. ........ r7745 | twisti | 2007-04-17 22:59:52 + +0200 (Tue, 17 Apr 2007) | 3 lines + + * src/vm/builtintable.inc (builtintable_function) [ENABLE_JIT]: We + need the entries only for JIT. ........ r7746 | edwin | 2007-04-17 + 23:01:15 +0200 (Tue, 17 Apr 2007) | 2 lines + + * src/vm/jit/verify/typecheck.c: More variable renaming for + clarity. ........ r7747 | edwin | 2007-04-17 23:11:20 +0200 (Tue, + 17 Apr 2007) | 3 lines + + * src/vm/jit/stack.c (stack_reanalyse_block, stack_analyse): + Renamed variable "j" to a more obvious "varindex". ........ + r7748 | edwin | 2007-04-17 23:25:55 +0200 (Tue, 17 Apr 2007) | 3 + lines + + * src/vm/jit/stack.c (stack_analyse): Do not abuse poor "i" for + types, use a separate variable for that. ........ r7749 | edwin + | 2007-04-17 23:30:20 +0200 (Tue, 17 Apr 2007) | 4 lines + + * src/vm/jit/stack.c (stack_init_javalocals): Use "type" as + variable for the type. (stack_analyse): Likewise. ........ + r7750 | twisti | 2007-04-17 23:37:12 +0200 (Tue, 17 Apr 2007) | 3 + lines + + * tests/regression/resolving/Makefile.am (check): Use + LD_LIBRARY_PATH for JAVA. ........ r7751 | twisti | 2007-04-18 + 00:06:01 +0200 (Wed, 18 Apr 2007) | 3 lines + + * src/vm/jit/alpha/codegen.c (codegen_emit): Fixed bug in float- + argument passing. ........ r7752 | twisti | 2007-04-18 00:50:49 + +0200 (Wed, 18 Apr 2007) | 2 lines + + * src/vm/jit/m68k/codegen.c: Boilerplate added. ........ r7753 | + twisti | 2007-04-18 00:55:21 +0200 (Wed, 18 Apr 2007) | 2 lines + + * src/vm/jit/m68k/emit.c: boilerplate added. ........ r7754 | + twisti | 2007-04-18 01:18:15 +0200 (Wed, 18 Apr 2007) | 23 lines + + * src/vm/jit/emit-common.h (emit_copy): Changed signature. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c: Likewise. + ........ r7755 | twisti | 2007-04-18 11:59:58 +0200 (Wed, 18 Apr + 2007) | 3 lines + + * src/native/vm/java_lang_ClassLoader.c [ENABLE_STATISTICS] + (vmcore/statistics.h): Added. ........ r7756 | twisti | 2007-04-18 + 16:11:56 +0200 (Wed, 18 Apr 2007) | 12 lines + + * src/threads/native/threads.c (mutex_join, cond_join): Added. + (threads_init_threadobject): Don't initalize join-mutex and cond. + (threads_preinit): Initialize mutex_join and cond_join. + (threads_startup_thread): Added vm_abort. (threads_detach_thread): + Don't reset thread id and use global mutex and condition. + (threads_find_non_daemon_thread): Lock thread list. + (threads_join_all_threads): Use global mutex and condition. + + * src/threads/native/threads.h (threadobject): Removed joinmutex + and joincond. ........ r7757 | tbfg | 2007-04-18 16:49:18 +0200 + (Wed, 18 Apr 2007) | 6 lines + + * src/vm/jit/powerpc64/codegen.c (sign_ext): Removed from + ICMD_INEG, ICMD_IDIV, ICMD_IREM, ICMD_IMUL, ICMD_IAND and ICMD_IOR + to save the if runtime costs. + + (ICMD_IUSHR): Needs sign extension for 0 bit shift case. ........ + r7758 | michi | 2007-04-18 17:31:07 +0200 (Wed, 18 Apr 2007) | 3 + lines + + * src/vm/jit/powerpc64/linux/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. ........ r7759 | ajordan | 2007-04-18 + 23:04:01 +0200 (Wed, 18 Apr 2007) | 5 lines + + * src/vm/jit/sparc64/emit.c: Migrated to + abi_registers_{integer,float}_argument. + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/sparc64/md-abi.c: Likewise. ........ r7761 | twisti | + 2007-04-19 11:18:20 +0200 (Thu, 19 Apr 2007) | 13 lines + + * src/threads/native/threads.c (threads_start_javathread): + Removed. (threads_detach_thread): Added some comments. + + * src/threads/native/threads.h (threads_start_javathread): + Removed. + + * src/threads/threads-common.c (assert.h): Added. + [ENABLE_STATISTICS] (vmcore/options.h, vmcore/statistics.h): Added. + (threads_start_javathread): Added. + + * src/threads/threads-common.h (vm/global.h): Added. + (native/include/java_lang_Thread.h): Likewise. + (threads_start_javathread): Likewise. ........ r7762 | twisti | + 2007-04-19 11:19:33 +0200 (Thu, 19 Apr 2007) | 3 lines + + * src/threads/threads-common.c (threads_start_javathread) + [ENABLE_JAVASE]: Check for daemon thread and set the flag. ........ + r7763 | michi | 2007-04-19 14:19:19 +0200 (Thu, 19 Apr 2007) | 4 + lines + + * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Use long branch + construct for exception handling here. This fixes a crash in the + following jasmin regression testcase: + jasmin/test_verify_fail_areturn_wrong_reftype. ........ + [d1f4bb13f44d] + +2007-04-19 twisti + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Changed + signature and use register number directly to save registers. + [5e24d4db20dd] + + * src/vm/builtin.c, src/vm/jit/arm/asmpart.S, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h: + * src/vm/jit/codegen-common.c (vm/builtin.h): Added. + (codegen_generate_stub_builtin): New function. + (codegen_generate_stub_native): Moved codegen_finish before + statistics generation, otherwise the numbers are wrong. + (codegen_stub_builtin_enter): New function. + (codegen_stub_builtin_exit): Likewise. + + * src/vm/jit/codegen-common.h (vm/builtin.h): Added. + (codegen_generate_stub_builtin): Likewise. + (codegen_emit_stub_builtin): Likewise. (codegen_stub_builtin_enter): + Likewise. (codegen_stub_builtin_exit): Likewise. + + * src/vm/builtin.c (builtintable_init): Call + codegen_generate_stub_builtin when required. + [117933a6743e] + +2007-04-19 michi + + * src/vm/jit/arm/asmpart.S: + * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Use long branch + construct for exception handling here. This fixes a crash in the + following jasmin regression testcase: + jasmin/test_verify_fail_areturn_wrong_reftype. + [8aa425921124] + +2007-04-19 twisti + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_start_javathread) + [ENABLE_JAVASE]: Check for daemon thread and set the flag. + [8306a271a6c1] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/native/threads.c (threads_start_javathread): Removed. + (threads_detach_thread): Added some comments. + + * src/threads/native/threads.h (threads_start_javathread): Removed. + + * src/threads/threads-common.c (assert.h): Added. + [ENABLE_STATISTICS] (vmcore/options.h, vmcore/statistics.h): Added. + (threads_start_javathread): Added. + + * src/threads/threads-common.h (vm/global.h): Added. + (native/include/java_lang_Thread.h): Likewise. + (threads_start_javathread): Likewise. + [c4a3107b7978] + +2007-04-19 michi + + * src/mm/cacao-gc/rootset.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/arm/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.h, + src/vm/jit/mips/codegen.c, src/vm/jit/parse.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/stack.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/emit.c: + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Add javastack + references to the rootset as well. + [baaa57d14785] + +2007-04-18 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.c: + * src/vm/jit/sparc64/emit.c: Migrated to + abi_registers_{integer,float}_argument. + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/sparc64/md-abi.c: Likewise. + [d958a61d6165] + +2007-04-18 michi + + * src/vm/jit/powerpc64/linux/Makefile.am: + * src/vm/jit/powerpc64/linux/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + [16714b42b207] + +2007-04-18 tbfg + + * src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (sign_ext): Removed from ICMD_INEG, + ICMD_IDIV, ICMD_IREM, ICMD_IMUL, ICMD_IAND and ICMD_IOR to save the + if runtime costs. + + (ICMD_IUSHR): Needs sign extension for 0 bit shift case. + [14d9b6039acb] + +2007-04-18 twisti + + * src/threads/native/threads.c, src/threads/native/threads.h: + * src/threads/native/threads.c (mutex_join, cond_join): Added. + (threads_init_threadobject): Don't initalize join-mutex and cond. + (threads_preinit): Initialize mutex_join and cond_join. + (threads_startup_thread): Added vm_abort. (threads_detach_thread): + Don't reset thread id and use global mutex and condition. + (threads_find_non_daemon_thread): Lock thread list. + (threads_join_all_threads): Use global mutex and condition. + + * src/threads/native/threads.h (threadobject): Removed joinmutex and + joincond. + [9ebf23aa7207] + + * src/native/vm/java_lang_ClassLoader.c: + * src/native/vm/java_lang_ClassLoader.c [ENABLE_STATISTICS] + (vmcore/statistics.h): Added. + [a79842fdacee] + +2007-04-17 twisti + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/emit- + common.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c: + * src/vm/jit/emit-common.h (emit_copy): Changed signature. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/emit.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c: Likewise. + [76e94dbd7a3a] + + * src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/emit.c: boilerplate added. + [1ff409db43be] + + * src/vm/jit/m68k/codegen.c: + * src/vm/jit/m68k/codegen.c: Boilerplate added. + [760d14d37bcb] + + * src/vm/jit/alpha/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit): Fixed bug in float- + argument passing. + [b29395e453c9] + + * tests/regression/resolving/Makefile.am: + * tests/regression/resolving/Makefile.am (check): Use + LD_LIBRARY_PATH for JAVA. + [3d01fe59eafc] + +2007-04-17 edwin + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_init_javalocals): Use "type" as variable + for the type. (stack_analyse): Likewise. + [d41dd80098e8] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): Do not abuse poor "i" for + types, use a separate variable for that. + [159f24ccdc9c] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_reanalyse_block, stack_analyse): Renamed + variable "j" to a more obvious "varindex". + [27c7f7048652] + + * src/vm/jit/verify/typecheck.c: + * src/vm/jit/verify/typecheck.c: More variable renaming for clarity. + [3ed0eebead11] + +2007-04-17 twisti + + * src/vm/builtintable.inc: + * src/vm/builtintable.inc (builtintable_function) [ENABLE_JIT]: We + need the entries only for JIT. + [720be9b2f3e9] + + * tests/regression/jasmin/Makefile.am: + * tests/regression/jasmin/Makefile.am (check): Set LD_LIBRARY_PATH. + [0f69c60c1908] + +2007-04-17 edwin + + * src/vm/jit/allocator/simplereg.c, src/vm/jit/inline/inline.c, + src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c, + src/vm/jit/verify/typeinfo.c: + * src/vm/jit/stack.c, src/vm/jit/verify/typecheck-common.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/inline/inline.c, + src/vm/jit/allocator/simplereg.c: Clarification: Renamed variables + that are indices into jd->var to "varindex". Renamed variables that + are bytecode variable indices to "javaindex". + [620f945a729d] + + * src/vm/jit/inline/inline.c, src/vm/jit/jit.h, src/vm/jit/replace.c, + src/vm/jit/show.c, src/vm/jit/stack.c: + * src/vm/jit/stack.c, src/vm/jit/show.c, src/vm/jit/inline/inline.c, + src/vm/jit/replace.c, src/vm/jit/jit.h: Fix and use the new macros + for calculating javalocals values representing returnAddresses. + [1c7d8fa48924] + + * src/vm/jit/jit.h: + * src/vm/jit/jit.h (basicblock): Document the javalocal array. + (JAVALOCAL_FROM_RETADDR): New macro. (RETADDR_FROM_JAVALOCAL): + Likewise. + [75abe41b937a] + +2007-04-17 twisti + + * src/threads/native/threads.c: + * src/threads/native/threads.c (threads_init): Fixed string-internal + warnings. (threads_attach_current_thread): Likewise. + [e043ec7c3f97] + + * src/threads/threads-common.c, src/threads/threads-common.h, + src/vm/jit/codegen-common.c: + * src/threads/threads-common.c (threads_print_stacktrace): Renamed + to threads_thread_print_stacktrace. (threads_print_stacktrace): New + function. (threads_dump): Use threads_thread_print_stacktrace. + + * src/threads/threads-common.h: Likewise. + + * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Use new + threads_print_stacktrace. + [c3afb76242b9] + +2007-04-17 edwin + + * src/vm/jit/jit.h: + * src/vm/jit/jit.h (jitdata): Cleaned up comments for local_map. + [4a6ac5bcba92] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_javalocals_store): Added an assert. + [447e21183701] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): The javalocals array can have + negative values != UNUSED (these values < UNUSED represent + returnAddresses of local subroutines). Thus >= 0 must be used to + check for normal indices. + [7ac59dbc963c] + + * src/vm/jit/parse.c: + * src/vm/jit/parse.c (parse): Small cleanup of local variable + renaming. (No code changes.) + [bcddd3d2a4e6] + +2007-04-17 twisti + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_native): Use + simpler code to save and restore argument registers. + [7d8cd9be641b] + +2007-04-16 twisti + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit): Made argument passing + cleaner. + [7943e3406a26] + +2007-04-16 michi + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/inline/inline.c: + Merged revisions 7727-7731 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7731 | twisti | 2007-04-17 00:24:30 +0200 (Tue, 17 Apr + 2007) | 7 lines + + * src/vm/jit/codegen-common.c (codegen_setup): Removed maxstack + stuff. + * src/vm/jit/codegen-common.h (codegendata): Likewise. + + * src/vm/jit/inline/inline.c: Fixed includes. + (inline_jit_compile): Removed maxstack stuff. (inline_transform): + Removed basicblockindex. ........ + [33abc694205d] + +2007-04-16 twisti + + * src/vm/jit/Makefile.am, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/inline/inline.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c: + * src/vm/jit/codegen-common.c (codegen_setup): Removed maxstack + stuff. + * src/vm/jit/codegen-common.h (codegendata): Likewise. + + * src/vm/jit/inline/inline.c: Fixed includes. (inline_jit_compile): + Removed maxstack stuff. (inline_transform): Removed basicblockindex. + [e472140655af] + +2007-04-16 michi + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h: + * src/mm/cacao-gc/gc.h [!ENABLE_STATISTICS]: Added dummy defines. + + * src/mm/cacao-gc/gc.c [ENABLE_STATISTICS]: Added gcstat_collections + and gcstat_collections_forced. + [ad29c1300cb4] + +2007-04-16 twisti + + * src/mm/cacao-gc/Makefile.am: + * src/mm/cacao-gc/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + [669b0ff5327d] + +2007-04-16 michi + + * src/mm/cacao-gc/compact.c: + * src/mm/cacao-gc/compact.c (compact_move): Fixed ifdef. + [466da41ce969] + + * src/mm/cacao-gc/Makefile.am, src/vm/jit/Makefile.am, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c: + Merged revisions 7723-7726 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7724 | twisti | 2007-04-16 23:07:10 +0200 (Mon, 16 Apr + 2007) | 5 lines + + * src/vm/jit/powerpc64/linux/md-abi.c: Argument register changes + ported (rev7713). + * src/vm/jit/powerpc64/emit.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. ........ r7725 | twisti + | 2007-04-16 23:09:39 +0200 (Mon, 16 Apr 2007) | 3 lines + + * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added m68k. + * src/mm/cacao-gc/Makefile.am (libgc_la_SOURCES): Removed heap.c. + ........ + [0f5d540918d1] + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c, + tests/gc/ClassInit.java: + * tests/gc/ClassInit.java: Added testcase (static initializer + calling gc). + [3a0594ed3067] + +2007-04-16 twisti + + * src/mm/cacao-gc/Makefile.am, src/vm/jit/Makefile.am: + * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added m68k. + * src/mm/cacao-gc/Makefile.am (libgc_la_SOURCES): Removed heap.c. + [daa4ed3c8940] + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c: + * src/vm/jit/powerpc64/linux/md-abi.c: Argument register changes + ported (rev7713). + * src/vm/jit/powerpc64/emit.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + [e454c133c9aa] + +2007-04-16 michi + + * src/native/jni.c, src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Runtime.c, src/threads/threads-common.c, + src/vm/builtin.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, src/vm/jit/arm/md- + abi.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md- + abi.h, src/vm/jit/reg.c, src/vm/jit/reg.h, src/vm/jit/stack.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c, src/vmcore/utf8.c: + Merged revisions 7707-7722 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7712 | twisti | 2007-04-15 23:13:03 +0200 (Sun, 15 Apr + 2007) | 4 lines + + * src/vm/jit/mips/emit.c (emit_load): Bugfix: Added missing float + instruction. (emit_store): Likewise. ........ r7713 | twisti | + 2007-04-15 23:49:48 +0200 (Sun, 15 Apr 2007) | 29 lines + + * src/vm/jit/reg.c (reg_setup): Removed arg{int,flt}regs stuff. + * src/vm/jit/reg.h (registerdata): Removed arg{int,flt}regs. + + * src/vm/jit/stack.c (stack_analyse): regoff now contains the + register number instead of an offset. + + * src/vm/jit/allocator/simplereg.c: Use + abi_registers_{integer,float}_argument instead of arg{int,flt}regs. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, src/vm/jit/arm + /md-abi.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c: A lot of + changes like the ones above. ........ r7714 | twisti | 2007-04-16 + 16:11:14 +0200 (Mon, 16 Apr 2007) | 4 lines + + * src/vm/builtin.c (builtin_print_argument): Removed + java_lang_String until we know what we do with strings internally + (more patches to come). ........ r7715 | twisti | 2007-04-16 + 16:28:30 +0200 (Mon, 16 Apr 2007) | 5 lines + + * src/threads/threads-common.c + (native/include/java_lang_String.h): Added. + (threads_create_thread): Fixed string-internal warnings. + (threads_dump): Likewise. ........ r7716 | twisti | 2007-04-16 + 16:29:53 +0200 (Mon, 16 Apr 2007) | 2 lines + + * src/vmcore/utf8.c (utf_get_number_of_u2s): Return 0 instead of + NULL. ........ r7717 | twisti | 2007-04-16 17:23:32 +0200 (Mon, 16 + Apr 2007) | 5 lines + + * src/native/vm/gnu/java_lang_VMClassLoader.c (loadClass): Fixed + string-internal warnings. (nativeGetResources): Likewise. + (findLoadedClass): Likewise. ........ r7718 | twisti | 2007-04-16 + 17:26:01 +0200 (Mon, 16 Apr 2007) | 3 lines + + * src/native/vm/gnu/java_lang_VMRuntime.c (mapLibraryName): Fixed + string-internal warnings. ........ r7719 | twisti | 2007-04-16 + 17:29:29 +0200 (Mon, 16 Apr 2007) | 3 lines + + * src/native/vm/gnu/java_lang_reflect_Method.c (getSignature): + Fixed string-internal warnings. ........ r7720 | twisti | + 2007-04-16 17:49:09 +0200 (Mon, 16 Apr 2007) | 13 lines + + * src/native/vm/java_lang_ClassLoader.c (defineClass): Fixed + string-internal warnings. + + * src/native/vm/java_lang_Runtime.c (loadLibrary): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Field.c (getSignature): + Likewise. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (getSignature): Likewise. + + * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): + Likewise. ........ r7721 | twisti | 2007-04-16 17:53:53 +0200 + (Mon, 16 Apr 2007) | 7 lines + + * src/native/vm/java_lang_Class.c (forName): Fixed string-internal + warnings. (getDeclaredFields): Likewise. (getDeclaredMethods): + Likewise. (getEnclosingMethod): Likewise. (getClassSignature): + Likewise. ........ r7722 | twisti | 2007-04-16 17:57:21 +0200 + (Mon, 16 Apr 2007) | 5 lines + + * src/native/jni.c (_Jv_JNI_DefineClass): Fixed string-internal + warnings. (_Jv_JNI_NewStringUTF): Likewise. + (_Jv_JNI_GetStringUTFChars): Likewise. ........ + [24a7a762a076] + +2007-04-16 twisti + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_DefineClass): Fixed string-internal + warnings. (_Jv_JNI_NewStringUTF): Likewise. + (_Jv_JNI_GetStringUTFChars): Likewise. + [a37bf09a362e] + + * src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c (forName): Fixed string-internal + warnings. (getDeclaredFields): Likewise. (getDeclaredMethods): + Likewise. (getEnclosingMethod): Likewise. (getClassSignature): + Likewise. + [07c0a68486d0] + + * src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_Runtime.c: + * src/native/vm/java_lang_ClassLoader.c (defineClass): Fixed string- + internal warnings. + + * src/native/vm/java_lang_Runtime.c (loadLibrary): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Field.c (getSignature): + Likewise. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c (getSignature): + Likewise. + + * src/native/vm/gnu/java_lang_VMThrowable.c (getStackTrace): + Likewise. + [c8536d3e324b] + + * src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/vm/gnu/java_lang_reflect_Method.c (getSignature): Fixed + string-internal warnings. + [5e143a12f2f0] + + * src/native/vm/gnu/java_lang_VMRuntime.c: + * src/native/vm/gnu/java_lang_VMRuntime.c (mapLibraryName): Fixed + string-internal warnings. + [ce5133d6a085] + + * src/native/vm/gnu/java_lang_VMClassLoader.c: + * src/native/vm/gnu/java_lang_VMClassLoader.c (loadClass): Fixed + string-internal warnings. (nativeGetResources): Likewise. + (findLoadedClass): Likewise. + [bf7462d48bc1] + + * src/vmcore/utf8.c: + * src/vmcore/utf8.c (utf_get_number_of_u2s): Return 0 instead of + NULL. + [c6d33c63976b] + + * src/threads/threads-common.c: + * src/threads/threads-common.c (native/include/java_lang_String.h): + Added. (threads_create_thread): Fixed string-internal warnings. + (threads_dump): Likewise. + [9dffdfeeb62e] + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_print_argument): Removed + java_lang_String until we know what we do with strings internally + (more patches to come). + [99f554aec90e] + +2007-04-15 twisti + + * src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, src/vm/jit/arm/md- + abi.c, src/vm/jit/arm/md-abi.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/md-abi.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/md-abi.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md- + abi.h, src/vm/jit/reg.c, src/vm/jit/reg.h, src/vm/jit/stack.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c: + * src/vm/jit/reg.c (reg_setup): Removed arg{int,flt}regs stuff. + * src/vm/jit/reg.h (registerdata): Removed arg{int,flt}regs. + + * src/vm/jit/stack.c (stack_analyse): regoff now contains the + register number instead of an offset. + + * src/vm/jit/allocator/simplereg.c: Use + abi_registers_{integer,float}_argument instead of arg{int,flt}regs. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, src/vm/jit/arm/md- + abi.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/powerpc/linux/md- + abi.h, src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c: A lot of changes like the ones above. + [a3fefe287703] + + * src/vm/jit/mips/emit.c: + * src/vm/jit/mips/emit.c (emit_load): Bugfix: Added missing float + instruction. (emit_store): Likewise. + [9851f06e8ca3] + +2007-04-15 michi + + * src/vm/builtintable.inc: + * src/vm/builtintable.inc: Fixed flags for builtin_new and + builtin_fast_new. + [7308c5bf0f60] + + * src/vm/builtin.h, src/vm/builtintable.inc: + * src/vm/builtin.h (builtintable_entry): Added stub pointer. + * src/vm/builtintable.inc: Adapted to above changes. Added vim boiler + plate. + [22c4d550cf29] + + * src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): Different + function signature. Fixed argument passing. Saving return value. + + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Different + function signature. + [1d72eeb5cb8e] + + * src/vm/jit/i386/codegen.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_builtin): + Implemented. (codegen_emit_stub_native): Now uses + abi_registers_integer_saved. + [66d503d68d4a] + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/md-abi.c, + tests/regression/resolving/Makefile.am, + tests/regression/resolving/classes1/Makefile.am, + tests/regression/resolving/classes2/Makefile.am, + tests/regression/resolving/classes3/Makefile.am: + Merged revisions 7701-7706 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7703 | twisti | 2007-04-15 13:37:55 +0200 (Sun, 15 Apr + 2007) | 6 lines + + * tests/regression/resolving/Makefile.am: Added GNU header and + fixed srcdir != builddir. + * tests/regression/resolving/classes1/Makefile.am: Likewise. + * tests/regression/resolving/classes2/Makefile.am: Likewise. + * tests/regression/resolving/classes3/Makefile.am: Likewise. ........ + r7704 | michi | 2007-04-15 13:55:25 +0200 (Sun, 15 Apr 2007) | 3 + lines + + * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Fixed + calculation of stackframesize. ........ r7705 | michi | 2007-04-15 + 14:15:01 +0200 (Sun, 15 Apr 2007) | 4 lines + + * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): + Added. (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. ........ r7706 | + michi | 2007-04-15 14:17:02 +0200 (Sun, 15 Apr 2007) | 2 lines + + * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): + Fixed. ........ + [84a0c74bbb13] + + * src/vm/jit/i386/md-abi.c: + * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Fixed. + [7105b50d6de2] + + * src/vm/jit/i386/md-abi.c: + * src/vm/jit/i386/md-abi.c (abi_registers_integer_argument): Added. + (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. + [fb1cc05ded0e] + + * src/vm/jit/i386/codegen.c: + * src/vm/jit/i386/codegen.c (codegen_emit_stub_native): Fixed + calculation of stackframesize. + [ad58732e3821] + +2007-04-15 twisti + + * tests/regression/resolving/Makefile.am, + tests/regression/resolving/classes1/Makefile.am, + tests/regression/resolving/classes2/Makefile.am, + tests/regression/resolving/classes3/Makefile.am: + * tests/regression/resolving/Makefile.am: Added GNU header and fixed + srcdir != builddir. + * tests/regression/resolving/classes1/Makefile.am: Likewise. + * tests/regression/resolving/classes2/Makefile.am: Likewise. + * tests/regression/resolving/classes3/Makefile.am: Likewise. + [9fa46231f8d7] + +2007-04-15 michi + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): Removed + call of codegen_finish. + [e47ffd6fee4f] + + * src/cacao/cacao.c, src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h, + src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h, + src/vm/jit/mips/arch.h, src/vm/jit/mips/codegen.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/arch.h, + src/vm/jit/sparc64/arch.h, src/vm/jit/stack.c, + src/vm/jit/x86_64/arch.h: + Merged revisions 7693-7700 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7694 | tbfg | 2007-04-12 17:35:13 +0200 (Thu, 12 Apr + 2007) | 8 lines + + * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed dead + code. + + * src/vm/jit/powerpc64/codegen.c (ICMD_ISUB): Fixed evil bug. + (ICMD_LSHR): Fixed a bug. (createnativestub): Use + emit_patcher_stub. + + * src/vm/jit/powerpc64/patcher.c (patcher_resolve_native): Fixed. + ........ r7695 | twisti | 2007-04-12 21:49:34 +0200 (Thu, 12 Apr + 2007) | 14 lines + + * src/vm/jit/stack.c (stack_analyse): Removed USEBUILTINTABLE, + always check for automatic-builtins (compile this is not + affected). + + * src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h, + src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h, + src/vm/jit/mips/arch.h, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc64/arch.h, src/vm/jit/s390/arch.h, + src/vm/jit/sparc64/arch.h, src/vm/jit/x86_64/arch.h + (USEBUILTINTABLE): Removed. ........ r7698 | twisti | 2007-04-13 + 12:12:04 +0200 (Fri, 13 Apr 2007) | 5 lines + + * src/cacao/cacao.c (main): Save the error message of the first + lt_dlopenext and print it too when the second fails (thanks + Dalibor). Although there's still a problem, when the first fails + for some reason and the second picks up and old installed one + silently. ........ r7699 | twisti | 2007-04-13 12:42:05 +0200 + (Fri, 13 Apr 2007) | 2 lines + + * src/vm/jit/mips/md-abi.c (md_param_alloc): Code beautified. + ........ r7700 | twisti | 2007-04-13 13:48:48 +0200 (Fri, 13 Apr + 2007) | 3 lines + + * src/vm/jit/mips/codegen.c (codegen_emit): ICMD_LDIV, ICMD_LREM: + Use REG_Ax_Ax_PACKED defines. ........ + [cdaa70dc40b0] + +2007-04-13 twisti + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit): ICMD_LDIV, ICMD_LREM: + Use REG_Ax_Ax_PACKED defines. + [11e93792d728] + + * src/vm/jit/mips/md-abi.c: + * src/vm/jit/mips/md-abi.c (md_param_alloc): Code beautified. + [63916a5952b0] + + * src/cacao/cacao.c: + * src/cacao/cacao.c (main): Save the error message of the first + lt_dlopenext and print it too when the second fails (thanks + Dalibor). Although there's still a problem, when the first fails for + some reason and the second picks up and old installed one silently. + [7486bf60943a] + +2007-04-12 twisti + + * src/vm/jit/x86_64/codegen.c: + * src/vm/jit/x86_64/codegen.c (codegen_emit_stub_builtin): New + function. + [05a68242fab2] + + * src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc, + src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h, + src/vm/jit/i386/arch.h, src/vm/jit/mips/arch.h, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/arch.h, src/vm/jit/stack.c, + src/vm/jit/x86_64/arch.h: + * src/vm/builtin.c (builtintable_replace_function): Replaced + checkexception with flags and check for exception flag. + + * src/vm/builtin.h (builtintable_entry): Removed checkexception, + added flags. (BUILTINTABLE_FLAG_STUB): Defined. + (BUILTINTABLE_FLAG_EXCEPTION): Likewise. + + * src/vm/builtintable.inc (builtintable_internal): Moved position of + flags. (builtintable_automatic): Likewise. (builtintable_function): + Likewise. + [b63c7f9b5333] + + * src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h, + src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h, + src/vm/jit/mips/arch.h, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc64/arch.h, src/vm/jit/s390/arch.h, + src/vm/jit/sparc64/arch.h, src/vm/jit/stack.c, + src/vm/jit/x86_64/arch.h: + * src/vm/jit/stack.c (stack_analyse): Removed USEBUILTINTABLE, + always check for automatic-builtins (compile this is not affected). + + * src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h, + src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h, + src/vm/jit/mips/arch.h, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc64/arch.h, src/vm/jit/s390/arch.h, + src/vm/jit/sparc64/arch.h, src/vm/jit/x86_64/arch.h + (USEBUILTINTABLE): Removed. + [9112dbd911db] + +2007-04-12 tbfg + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/patcher.c: + * src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed dead + code. + + * src/vm/jit/powerpc64/codegen.c (ICMD_ISUB): Fixed evil bug. + (ICMD_LSHR): Fixed a bug. (createnativestub): Use emit_patcher_stub. + + * src/vm/jit/powerpc64/patcher.c (patcher_resolve_native): Fixed. + [2f53b0ece37e] + +2007-04-12 michi + + * src/cacaoh/dummy.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/linux/md-os.c, src/vm/jit + /codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/jit.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit_interface.h, + src/vmcore/linker.c, src/vmcore/loader.c: + Merged revisions 7688-7692 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7690 | twisti | 2007-04-12 13:56:05 +0200 (Thu, 12 Apr + 2007) | 3 lines + + * src/vm/jit/arm/linux/md-os.c (mm/memory.h): Removed. + [ENABLE_THREADS] (threads/native/threads.h): Added. ........ r7691 + | twisti | 2007-04-12 14:45:10 +0200 (Thu, 12 Apr 2007) | 36 lines + + * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): + New function. + + * src/vm/jit/codegen-common.h (createcompilerstub): Removed. + (codegen_generate_stub_compiler): Added. + * src/vm/jit_interface.h: Likewise. + * src/cacaoh/dummy.c: Likewise. + + * src/vmcore/linker.c (link_class_intern): Replaced + createcompilerstub with codegen_generate_stub_compiler. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c + (COMPILERSTUB_DATASIZE) (COMPILERSTUB_SIZE): Removed. + (createcompilerstub): Renamed to codegen_emit_stub_compiler and + changed signature. + + * src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.h, + src/vm/jit/i386/codegen.h, src/vm/jit/m68k/codegen.h, + src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.h, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.h, + src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.h + (COMPILERSTUB_CODESIZE): Added. ........ r7692 | twisti | + 2007-04-12 16:47:24 +0200 (Thu, 12 Apr 2007) | 26 lines + + * src/vm/jit/codegen-common.c (codegen_createnativestub): Renamed + to codegen_generate_stub_native and call codegen_finish. + + * src/vm/jit/codegen-common.h (codegen_createnativestub): Removed. + (codegen_generate_stub_native): Added. + * src/vm/jit_interface.h: Likewise. + * src/cacaoh/dummy.c: Likewise. + + * src/vmcore/loader.c (load_newly_created_array): Renamed + codegen_createnativestub to codegen_generate_stub_native and changed + signature. + * src/vm/jit/jit.c (jit_compile_intern): Likewise. + + * src/vm/jit/arm/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/s390/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c + (createnativestub): Renamed to codegen_emit_stub_native and + changed signature, don't call codegen_finish. ........ + [c9aa605344f9] + +2007-04-12 twisti + + * src/cacaoh/dummy.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/arm/codegen.c, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/i386/codegen.c, src/vm/jit/jit.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/s390/codegen.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit_interface.h, + src/vmcore/loader.c: + * src/vm/jit/codegen-common.c (codegen_createnativestub): Renamed to + codegen_generate_stub_native and call codegen_finish. + + * src/vm/jit/codegen-common.h (codegen_createnativestub): Removed. + (codegen_generate_stub_native): Added. + * src/vm/jit_interface.h: Likewise. + * src/cacaoh/dummy.c: Likewise. + + * src/vmcore/loader.c (load_newly_created_array): Renamed + codegen_createnativestub to codegen_generate_stub_native and changed + signature. + * src/vm/jit/jit.c (jit_compile_intern): Likewise. + + * src/vm/jit/arm/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/s390/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/m68k/codegen.c, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/x86_64/codegen.c + (createnativestub): Renamed to codegen_emit_stub_native and changed + signature, don't call codegen_finish. + [bdea958b9063] + + * src/cacaoh/dummy.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/codegen-common.c, src/vm/jit + /codegen-common.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/codegen.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit_interface.h, + src/vmcore/linker.c: + * src/vm/jit/codegen-common.c (codegen_generate_stub_compiler): New + function. + + * src/vm/jit/codegen-common.h (createcompilerstub): Removed. + (codegen_generate_stub_compiler): Added. + * src/vm/jit_interface.h: Likewise. + * src/cacaoh/dummy.c: Likewise. + + * src/vmcore/linker.c (link_class_intern): Replaced + createcompilerstub with codegen_generate_stub_compiler. + + * src/vm/jit/alpha/codegen.c, src/vm/jit/arm/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/m68k/codegen.c, + src/vm/jit/mips/codegen.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/s390/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/x86_64/codegen.c + (COMPILERSTUB_DATASIZE) (COMPILERSTUB_SIZE): Removed. + (createcompilerstub): Renamed to codegen_emit_stub_compiler and + changed signature. + + * src/vm/jit/alpha/codegen.h, src/vm/jit/arm/codegen.h, + src/vm/jit/i386/codegen.h, src/vm/jit/m68k/codegen.h, + src/vm/jit/mips/codegen.h, src/vm/jit/powerpc/codegen.h, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/codegen.h, + src/vm/jit/sparc64/codegen.h, src/vm/jit/x86_64/codegen.h + (COMPILERSTUB_CODESIZE): Added. + [604ac021c387] + + * src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/linux/md-os.c (mm/memory.h): Removed. + [ENABLE_THREADS] (threads/native/threads.h): Added. + [d360d51a6405] + +2007-04-12 michi + + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/mark.c: + * src/mm/cacao-gc/gc.h (gc_collect): Added prototype. + * src/mm/cacao-gc/heap.c: Fixed includes. + * src/mm/cacao-gc/mark.c: Fixed includes. + [aad7ee5bcc5b] + + * src/cacaoh/dummy.c, src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/threads/native/threads.c, src/toolbox/logging.c, + src/vm/global.h, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/emit.c, src/vm/jit/arm/asmpart.S, src/vm/jit + /codegen-common.c, src/vm/jit/i386/asmpart.S, + src/vm/jit/intrp/asmpart.c, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h, + src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/tests/tests.java.pp, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/x86_64/asmpart.S, + src/vmcore/linker.c, src/vmcore/linker.h: + Merged revisions 7674-7687 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7675 | michi | 2007-04-05 16:23:04 +0200 (Thu, 05 Apr + 2007) | 10 lines + + * src/vm/global.h (compiler_lock, compiler_unlock): Removed. + * src/cacaoh/dummy.c (compiler_lock, compiler_unlock): Removed. + * src/threads/native/threads.c (compiler_lock, compiler_unlock): + Removed. + + * src/vmcore/linker.h (linker_classrenumber_lock): Added. + * src/vmcore/linker.c (linker_classrenumber_lock): Added. + (linker_compute_subclasses): Uses above lock object instead of + compiler_lock. + + * src/vm/jit/intrp/asmpart.c (intrp_asm_getclassvalues_atomic): + Likewise. ........ r7676 | twisti | 2007-04-08 23:14:40 +0200 + (Sun, 08 Apr 2007) | 3 lines + + * src/native/vm/cldc1.1/java_lang_Object.c (notifyAll): + Implemented. + * src/native/vm/cldc1.1/java_lang_String.c (lastIndexOf__I): Likewise. + ........ r7677 | twisti | 2007-04-09 13:51:25 +0200 (Mon, 09 Apr + 2007) | 8 lines + + * src/vm/jit/mips/codegen.h (BRANCH_NOPS): Added long-branches + case. + + * src/vm/jit/mips/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + (emit_branch): Implemented conditional long-branches. ........ + r7678 | twisti | 2007-04-09 19:23:55 +0200 (Mon, 09 Apr 2007) | 11 + lines + + * src/vm/jit/alpha/asmpart.S: Use % instead of @ for progbits as + ARM's assembler uses @ as comment character. + * src/vm/jit/arm/asmpart.S: Likewise. + * src/vm/jit/i386/asmpart.S: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/powerpc/asmpart.S: Likewise. + * src/vm/jit/powerpc64/asmpart.S: Likewise. + * src/vm/jit/s390/asmpart.S: Likewise. + * src/vm/jit/sparc64/asmpart.S: Likewise. + * src/vm/jit/x86_64/asmpart.S: Likewise. ........ r7679 | twisti | + 2007-04-09 23:17:36 +0200 (Mon, 09 Apr 2007) | 2 lines + + * src/vm/jit/alpha/emit.c (emit_copy): Check src-type, not dst- + type. ........ r7680 | pm | 2007-04-10 07:02:20 +0200 (Tue, 10 Apr + 2007) | 8 lines + + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/tests/tests.java.pp: Changed very much. ........ + r7681 | twisti | 2007-04-10 14:22:16 +0200 (Tue, 10 Apr 2007) | 3 + lines + + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Set + val accordingly. ........ r7682 | twisti | 2007-04-10 23:24:14 + +0200 (Tue, 10 Apr 2007) | 3 lines + + * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_IF_Lxx + instructions for 64-bit. ........ r7683 | twisti | 2007-04-10 + 23:37:03 +0200 (Tue, 10 Apr 2007) | 3 lines + + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): We + only need to check the cause for pre glibc-2.5. ........ r7684 | + twisti | 2007-04-11 10:11:49 +0200 (Wed, 11 Apr 2007) | 3 lines + + * src/vm/jit/codegen-common.c (codegen_generate): Added re- + generating debug message. ........ r7685 | twisti | 2007-04-11 + 10:21:06 +0200 (Wed, 11 Apr 2007) | 2 lines + + * src/toolbox/logging.c (log_finish): Also print a \n in the log- + file. ........ r7687 | tbfg | 2007-04-11 18:39:22 +0200 (Wed, 11 + Apr 2007) | 19 lines + + * src/vm/jit/powerpc64/arch.h (SUPPORT_LONG_SHIFT): Enabled. + + * src/vm/jit/powerpc64/codegen.c (ICMD_LSHLCONST): Implemented. + (ICMD_LSHRCONST): Likewise. (ICMD_LUSHRCONST): Likewise. + (ICMD_LSHL): Likewise. (ICMD_LSHR): Likewise. (ICMD_LUSHR): + Likewise. (ICMD_IUSHR): Fixed. (ICMD_IUSHRCONST): Fixed. + + * src/vm/jit/powerpc64/codegen.h (M_SRL): Use 64bit opcode. + (M_SRA): Likewise. (M_SRA_IMM): Likewise. (M_SRL_IMM): Likewise. + (M_SSL_IMM): Likewise. (M_SSL): Likewise. (M_CLR_HIGH): Added. + ........ + [7a123c32db11] + +2007-04-11 tbfg + + * src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h: + * src/vm/jit/powerpc64/arch.h (SUPPORT_LONG_SHIFT): Enabled. + + * src/vm/jit/powerpc64/codegen.c (ICMD_LSHLCONST): Implemented. + (ICMD_LSHRCONST): Likewise. (ICMD_LUSHRCONST): Likewise. + (ICMD_LSHL): Likewise. (ICMD_LSHR): Likewise. (ICMD_LUSHR): + Likewise. (ICMD_IUSHR): Fixed. (ICMD_IUSHRCONST): Fixed. + + * src/vm/jit/powerpc64/codegen.h (M_SRL): Use 64bit opcode. (M_SRA): + Likewise. (M_SRA_IMM): Likewise. (M_SRL_IMM): Likewise. (M_SSL_IMM): + Likewise. (M_SSL): Likewise. (M_CLR_HIGH): Added. + [8b91afea2648] + +2007-04-11 twisti + + * src/vm/builtin.h, src/vm/builtintable.inc, + src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/tests/tests.java.pp, + src/vm/jit/x86_64/asmpart.S, src/vmcore/linker.c: + * src/vm/builtin.h (builtin_fast_new): Added. (BUILTIN_FAST_new): + Likewise. + + * src/vm/builtintable.inc (builtintable_internal): Added + BUILTIN_FAST_new. + [2c1970a9e98f] + + * src/toolbox/logging.c: + * src/toolbox/logging.c (log_finish): Also print a \n in the log- + file. + [45a5bb68dac8] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_generate): Added re- + generating debug message. + [5d40e61513e2] + +2007-04-10 twisti + + * src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): We only + need to check the cause for pre glibc-2.5. + [ba356d7fb5f0] + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit): Fixed ICMD_IF_Lxx + instructions for 64-bit. + [c6d5b478aef0] + + * src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Set val + accordingly. + [3e43374d7974] + +2007-04-10 pm + + * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/tests/tests.java.pp: + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/tests/tests.java.pp: Changed very much. + [8991ec608963] + +2007-04-09 twisti + + * src/vm/jit/alpha/emit.c: + * src/vm/jit/alpha/emit.c (emit_copy): Check src-type, not dst-type. + [1d86f11b4c3a] + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/mips/asmpart.S, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/s390/asmpart.S, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/alpha/asmpart.S: Use % instead of @ for progbits as + ARM's assembler uses @ as comment character. + * src/vm/jit/arm/asmpart.S: Likewise. + * src/vm/jit/i386/asmpart.S: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/powerpc/asmpart.S: Likewise. + * src/vm/jit/powerpc64/asmpart.S: Likewise. + * src/vm/jit/s390/asmpart.S: Likewise. + * src/vm/jit/sparc64/asmpart.S: Likewise. + * src/vm/jit/x86_64/asmpart.S: Likewise. + [8e4b092d8838] + + * src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c: + * src/vm/jit/mips/codegen.h (BRANCH_NOPS): Added long-branches case. + + * src/vm/jit/mips/emit.c (emit_load): Use switch-case instead of if- + else contruct. (emit_store): Likewise. (emit_copy): Likewise. + (emit_branch): Implemented conditional long-branches. + [2b31d3ab64e9] + +2007-04-08 twisti + + * src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c: + * src/native/vm/cldc1.1/java_lang_Object.c (notifyAll): Implemented. + * src/native/vm/cldc1.1/java_lang_String.c (lastIndexOf__I): Likewise. + [020417ffe9f4] + +2007-04-05 michi + + * src/cacaoh/dummy.c, src/threads/native/threads.c, src/vm/global.h, + src/vm/jit/intrp/asmpart.c, src/vmcore/linker.c, + src/vmcore/linker.h: + * src/vm/global.h (compiler_lock, compiler_unlock): Removed. + * src/cacaoh/dummy.c (compiler_lock, compiler_unlock): Removed. + * src/threads/native/threads.c (compiler_lock, compiler_unlock): + Removed. + + * src/vmcore/linker.h (linker_classrenumber_lock): Added. + * src/vmcore/linker.c (linker_classrenumber_lock): Added. + (linker_compute_subclasses): Uses above lock object instead of + compiler_lock. + + * src/vm/jit/intrp/asmpart.c (intrp_asm_getclassvalues_atomic): + Likewise. + [b6b122d1b5da] + + * src/native/native.c, src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h, + src/vm/exceptions.c, src/vm/jit/codegen-common.c: + Merged revisions 7665-7673 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7666 | twisti | 2007-04-05 02:14:57 +0200 (Thu, 05 Apr + 2007) | 4 lines + + * src/threads/threads-common.c (threads_print_stacktrace): Removed + !ENABLE_THREADS code, since this file is only compiled with + ENABLE_THREADS. ........ r7669 | twisti | 2007-04-05 13:39:58 + +0200 (Thu, 05 Apr 2007) | 27 lines + + * src/native/vm/java_lang_Thread.c [ENABLE_THREADS] + (threads/native/threads.h): Removed. (threads/threads-common.h): + Added. (vm/stringlocal.h): Likewise. (vm/vm.h): Removed. + (getState): Implemented. + + * src/threads/threads-common.c (vm/vm.h): Added. + (threads_get_state): New function. (threads_dump): Print thread + state. + + * src/threads/threads-common.h (THREAD_STATE_NEW) + (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING) + (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Defined. + (threads_get_state): Added. + + * src/threads/native/threads.c (threads_init): Set thread-state. + (threads_startup_thread): Likewise. + (threads_attach_current_thread): Likewise. + (threads_detach_thread): Likewise. (threads_wait_with_timeout): + Likewise. + + * src/threads/native/threads.h (threadobject): Added state field. + + * src/native/native.c (dummynativetable) [ENABLE_JAVASE]: Added + Java_java_lang_VMThread_getState. ........ r7670 | twisti | + 2007-04-05 13:57:59 +0200 (Thu, 05 Apr 2007) | 13 lines + + * src/threads/threads-common.c (threads_get_state): Renamed to + threads_thread_get_state. (threads_thread_is_alive): New function. + + * src/threads/threads-common.h: Likewise. + + * src/native/vm/java_lang_Thread.c (isAlive): New function. + (getState): Renamed threads_get_state to threads_thread_get_state. + + * src/native/vm/java_lang_Thread.h (isAlive): Added. + + * src/native/vm/cldc1.1/java_lang_Thread.c (isAlive): New + function. ........ r7671 | twisti | 2007-04-05 14:06:28 +0200 + (Thu, 05 Apr 2007) | 3 lines + + * src/vm/exceptions.c (exceptions_throw_nosuchmethoderror) + [!ENABLE_JAVASE]: Throw an error. ........ r7673 | michi | + 2007-04-05 15:22:37 +0200 (Thu, 05 Apr 2007) | 3 lines + + * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Inserted + ifdef to fix compiler error with disabled threads. ........ + [c1e618e7a27b] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_get_pv_from_pc): Inserted + ifdef to fix compiler error with disabled threads. + [bab8588a9998] + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.c, src/mm/cacao- + gc/heap.c, src/vm/exceptions.c: + * src/mm/cacao-gc/heap.c: Added include to fix compile warning. + + * src/mm/cacao-gc/compact.c: Made most functions static. + + * src/mm/cacao-gc/gc.c (gc_collect): Fixed debug output for current + stacktrace. + [f0c3b9c0ed44] + +2007-04-05 twisti + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_throw_nosuchmethoderror) + [!ENABLE_JAVASE]: Throw an error. + [bc502afcb318] + + * src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/java_lang_Thread.c, src/native/vm/java_lang_Thread.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/threads/threads-common.c (threads_get_state): Renamed to + threads_thread_get_state. (threads_thread_is_alive): New function. + + * src/threads/threads-common.h: Likewise. + + * src/native/vm/java_lang_Thread.c (isAlive): New function. + (getState): Renamed threads_get_state to threads_thread_get_state. + + * src/native/vm/java_lang_Thread.h (isAlive): Added. + + * src/native/vm/cldc1.1/java_lang_Thread.c (isAlive): New function. + [60d709c07fc6] + + * src/native/native.c, src/native/vm/java_lang_Thread.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h: + * src/native/vm/java_lang_Thread.c [ENABLE_THREADS] + (threads/native/threads.h): Removed. (threads/threads-common.h): + Added. (vm/stringlocal.h): Likewise. (vm/vm.h): Removed. (getState): + Implemented. + + * src/threads/threads-common.c (vm/vm.h): Added. + (threads_get_state): New function. (threads_dump): Print thread + state. + + * src/threads/threads-common.h (THREAD_STATE_NEW) + (THREAD_STATE_RUNNABLE, THREAD_STATE_BLOCKED, THREAD_STATE_WAITING) + (THREAD_STATE_TIMED_WAITING, THREAD_STATE_TERMINATED): Defined. + (threads_get_state): Added. + + * src/threads/native/threads.c (threads_init): Set thread-state. + (threads_startup_thread): Likewise. (threads_attach_current_thread): + Likewise. (threads_detach_thread): Likewise. + (threads_wait_with_timeout): Likewise. + + * src/threads/native/threads.h (threadobject): Added state field. + + * src/native/native.c (dummynativetable) [ENABLE_JAVASE]: Added + Java_java_lang_VMThread_getState. + [2ef27aeb36c1] + +2007-04-05 michi + + * src/mm/cacao-gc/gc.c: + * src/mm/cacao-gc/gc.c (gc_collect) [!ENABLE_THREADS]: Temporarly + defined away printing of current stacktrace. + [7a3f09dfa9ab] + + * configure.ac, src/mm/cacao-gc/gc.c, src/native/native.c, + src/native/vm/gnu/sun_misc_Unsafe.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h, + src/vm/exceptions.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/arm/md.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S, src/vm/jit/mips/md- + abi.h, src/vm/jit/parse.c, src/vm/jit/parse.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/replace.c, src/vm/jit/replace.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/show.c, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/stack.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-stackbased- + gen.inc, src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/linux/md-os.c, src/vmcore/statistics.c: + Merged revisions 7642-7664 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7643 | twisti | 2007-04-03 13:35:40 +0200 (Tue, 03 Apr + 2007) | 3 lines + + * src/vmcore/statistics.c (statistics_print_memory_usage): Prevent + compiler warning on 64-bit machines. ........ r7644 | twisti | + 2007-04-03 13:37:30 +0200 (Tue, 03 Apr 2007) | 3 lines + + * src/vm/jit/x86_64/emit.c (emit_replacement_stubs): Removed + unused variable disp. ........ r7645 | twisti | 2007-04-03 + 13:46:50 +0200 (Tue, 03 Apr 2007) | 3 lines + + * src/vm/jit/allocator/simplereg.c (simplereg_make_statistics): + Fixed compiler warning. ........ r7646 | twisti | 2007-04-03 + 13:56:21 +0200 (Tue, 03 Apr 2007) | 3 lines + + * src/vm/jit/replace.c (native/include/java_lang_String.h): + Removed. (java_value_print): Don't cast to java_lang_String. + ........ r7647 | twisti | 2007-04-03 14:10:22 +0200 (Tue, 03 Apr + 2007) | 2 lines + + * src/vm/jit/jit.h: Includes alpha-sorted. ........ r7648 | + twisti | 2007-04-03 15:14:09 +0200 (Tue, 03 Apr 2007) | 3 lines + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigfpe): Use + exceptions_new_hardware_exception. ........ r7649 | twisti | + 2007-04-03 15:47:39 +0200 (Tue, 03 Apr 2007) | 4 lines + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use + exceptions_new_hardware_exception. [ENABLE_THREADS] + (md_signal_handler_sigusr2): New function. ........ r7650 | twisti + | 2007-04-03 15:48:10 +0200 (Tue, 03 Apr 2007) | 2 lines + + * configure.ac: Added armv4 architecture. ........ r7651 | + twisti | 2007-04-03 16:00:32 +0200 (Tue, 03 Apr 2007) | 13 lines + + * src/vm/jit/stacktrace.c + (stacktrace_create_inline_stackframeinfo): Removed. + (stacktrace_inline_arithmeticexception): Likewise. + (stacktrace_inline_arrayindexoutofboundsexception): Likewise. + (stacktrace_inline_arraystoreexception): Likewise. + (stacktrace_inline_classcastexception): Likewise. + (stacktrace_inline_nullpointerexception): Likewise. + (stacktrace_inline_fillInStackTrace): Likewise. + (stacktrace_hardware_arithmeticexception): Likewise. + (stacktrace_hardware_nullpointerexception): Likewise. + + * src/vm/jit/stacktrace.h: Likewise. ........ r7652 | twisti | + 2007-04-03 16:23:16 +0200 (Tue, 03 Apr 2007) | 15 lines + + * src/threads/native/threads.h (STACKFRAMEINFO): Return + stackframeinfo instead of a pointer to it. + * src/threads/none/threads.h (STACKFRAMEINFO): Likewise. + + * src/vm/jit/codegen-common.c (codegen_finish_native_call): + STACKFRAMEINFO changes. + + * src/vm/jit/replace.c (replace_recover_source_state): Likewise. + + * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo): + Likewise. (stacktrace_create_extern_stackframeinfo): Likewise. + (stacktrace_create_native_stackframeinfo): Likewise. + (stacktrace_remove_stackframeinfo): Likewise. ........ r7653 | + twisti | 2007-04-03 16:34:23 +0200 (Tue, 03 Apr 2007) | 5 lines + + * src/vm/jit/arm/emit.c (emit_exception_stubs): Removed. + + * src/vm/jit/arm/md.c (md_codegen_patch_branch): Likewise. + (md_stacktrace_get_returnaddress): Removed debug code. ........ + r7654 | twisti | 2007-04-03 17:22:21 +0200 (Tue, 03 Apr 2007) | 4 + lines + + * src/vm/exceptions.c (exceptions_fillinstacktrace) + [ENABLE_JAVAME_CLDC1_1]: fillInStackTrace has another signature in + CLDC-1.1. ........ r7655 | twisti | 2007-04-03 17:22:57 +0200 + (Tue, 03 Apr 2007) | 3 lines + + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigfpe): Use + exceptions_new_hardware_exception. ........ r7656 | twisti | + 2007-04-03 17:29:26 +0200 (Tue, 03 Apr 2007) | 5 lines + + * src/vm/jit/replace.c (threads/threads-common.h): Added. + + * src/vm/jit/replace.h: Moved empty defines to the top of the file + to see what's happening when !defined(ENABLE_REPLACEMENT). + ........ r7657 | twisti | 2007-04-03 17:51:52 +0200 (Tue, 03 Apr + 2007) | 24 lines + + * src/vm/jit/stacktrace.c (stacktrace_create): Changed signature. + + (stacktrace_fillInStackTrace): Pass stackframeinfo to + stacktrace_create. (stacktrace_getClassContext): Likewise. + (stacktrace_getCurrentClass): Likewise. (stacktrace_getStack): + Likewise. (stacktrace_dump_trace): Removed. + + * src/vm/jit/stacktrace.h (threads/native/threads.h) + (threads/none/threads.h): Removed. (stacktrace_create): Added. + (stacktrace_dump_trace): Removed. + + * src/threads/native/threads.c (threads_dump): Removed. + * src/threads/native/threads.h (threads_dump): Likewise. + + * src/threads/threads-common.c (vm/jit/stacktrace.h): Added. + (threads_dump): Added. (threads_print_stacktrace): Likewise. + + * src/threads/threads-common.h (threads_dump): Added. + (threads_print_stacktrace): Likewise. ........ r7658 | twisti | + 2007-04-03 18:06:30 +0200 (Tue, 03 Apr 2007) | 10 lines + + * src/threads/threads-common.c (threads_print_stacktrace): Pass + stackframeinfo to stacktrace_create. + + * src/vm/jit/codegen-common.c (threads/native/threads.h): Removed. + (threads/threads-common.h): Added. (codegen_get_pv_from_pc): + Replaced stacktrace_dump_trace with threads_print_stacktrace. + + * src/vm/jit/stacktrace.h (stacktrace_print_trace_from_buffer): + Added. ........ r7659 | twisti | 2007-04-03 20:02:48 +0200 (Tue, + 03 Apr 2007) | 2 lines + + * src/vm/jit/mips/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Defined. + ........ r7660 | twisti | 2007-04-03 23:30:13 +0200 (Tue, 03 Apr + 2007) | 2 lines + + * src/vm/jit/i386/linux/md-os.c (threads/threads-common.h): Added. + ........ r7661 | twisti | 2007-04-04 00:29:59 +0200 (Wed, 04 Apr + 2007) | 11 lines + + * src/vm/jit/alpha/asmpart.S: Replaced __GNU__ with __linux__ for + exec-stacks. + * src/vm/jit/arm/asmpart.S: Likewise. + * src/vm/jit/i386/asmpart.S: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/powerpc/asmpart.S: Likewise. + * src/vm/jit/powerpc64/asmpart.S: Likewise. + * src/vm/jit/s390/asmpart.S: Likewise. + * src/vm/jit/sparc64/asmpart.S: Likewise. + * src/vm/jit/x86_64/asmpart.S: Likewise. ........ r7662 | twisti | + 2007-04-04 16:16:37 +0200 (Wed, 04 Apr 2007) | 8 lines + + * src/native/vm/gnu/sun_misc_Unsafe.c: Header changes. + + * src/native/native.c [ENABLE_JAVASE] + (native/include/sun_misc_Unsafe.h): Added. [ENABLE_JAVASE] + (dummynativetable): Added Java_sun_misc_Unsafe_objectFieldOffset + and Java_sun_misc_Unsafe_compareAndSwapInt. ........ r7663 | + twisti | 2007-04-05 00:14:42 +0200 (Thu, 05 Apr 2007) | 24 lines + + * src/vm/jit/parse.c (BYTECODEINDEX_TO_BASICBLOCK): Added. + (parsedata_t): Removed instructionstart, added bytecodestart, + basicblockstart, bytecodemap, instructionmap. (parse_setup): + Allocate new arrays. (parse_bytecodeindex_to_basicblock): New + function. (parse_mark_exception_boundaries): Pass parsedata_t. + (parse_resolve_exception_table): Likewise. (parse): Completely + rewritten so we are able to have basic block boundaries on IR + instruction level. We now also resolve basic block pointers in + this pass. + + * src/vm/jit/parse.h (MARK_BASICBLOCK): Pass parsedata_t. + (BLOCK_OF): Removed. + + * src/vm/jit/jit.h (jitdata): Removed basicblockindex. + + * src/vm/jit/show.c (SHOW_TARGET): Print block instead of + insindex. (show_icmd): Likewise. + + * src/vm/jit/stack.c (BRANCH_TARGET): Directly use block. + (stack_analyse): Likewise. + * src/vm/jit/verify/icmds.c: Likewise. + * src/vm/jit/verify/typecheck-stackbased.c: Likewise. ........ r7664 + | twisti | 2007-04-05 00:29:36 +0200 (Thu, 05 Apr 2007) | 4 lines + + * src/vm/jit/verify/typecheck-stackbased.c: Use block directly + instead of insindex. + * src/vm/jit/verify/typecheck-stackbased-gen.inc: Newly generated. + ........ + [9d86f2708920] + +2007-04-05 twisti + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_print_stacktrace): Removed + !ENABLE_THREADS code, since this file is only compiled with + ENABLE_THREADS. + [502ecbd2fba0] + +2007-04-05 michi + + * configure.ac, src/mm/cacao-gc/rootset.h, src/vm/exceptions.c, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/asmpart.S, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/md.c, + src/vm/jit/i386/asmpart.S, src/vm/jit/jit.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/parse.c, src/vm/jit/parse.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/s390/asmpart.S, src/vm/jit/stack.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/emit.c, src/vmcore/statistics.c: + * src/mm/cacao-gc/rootset.h [!ENABLE_THREADS]: Added missing + include. + [604173540cca] + +2007-04-04 twisti + + * src/vm/jit/verify/typecheck-stackbased-gen.inc, src/vm/jit/verify + /typecheck-stackbased.c: + * src/vm/jit/verify/typecheck-stackbased.c: Use block directly + instead of insindex. + * src/vm/jit/verify/typecheck-stackbased-gen.inc: Newly generated. + [9c43f6bf257b] + + * src/vm/jit/jit.h, src/vm/jit/parse.c, src/vm/jit/parse.h, + src/vm/jit/show.c, src/vm/jit/stack.c, src/vm/jit/verify/icmds.c, + src/vm/jit/verify/typecheck-stackbased.c: + * src/vm/jit/parse.c (BYTECODEINDEX_TO_BASICBLOCK): Added. + (parsedata_t): Removed instructionstart, added bytecodestart, + basicblockstart, bytecodemap, instructionmap. (parse_setup): + Allocate new arrays. (parse_bytecodeindex_to_basicblock): New + function. (parse_mark_exception_boundaries): Pass parsedata_t. + (parse_resolve_exception_table): Likewise. (parse): Completely + rewritten so we are able to have basic block boundaries on IR + instruction level. We now also resolve basic block pointers in this + pass. + + * src/vm/jit/parse.h (MARK_BASICBLOCK): Pass parsedata_t. + (BLOCK_OF): Removed. + + * src/vm/jit/jit.h (jitdata): Removed basicblockindex. + + * src/vm/jit/show.c (SHOW_TARGET): Print block instead of insindex. + (show_icmd): Likewise. + + * src/vm/jit/stack.c (BRANCH_TARGET): Directly use block. + (stack_analyse): Likewise. + * src/vm/jit/verify/icmds.c: Likewise. + * src/vm/jit/verify/typecheck-stackbased.c: Likewise. + [1c98fd306ae9] + + * src/native/native.c, src/native/vm/gnu/sun_misc_Unsafe.c: + * src/native/vm/gnu/sun_misc_Unsafe.c: Header changes. + + * src/native/native.c [ENABLE_JAVASE] + (native/include/sun_misc_Unsafe.h): Added. [ENABLE_JAVASE] + (dummynativetable): Added Java_sun_misc_Unsafe_objectFieldOffset and + Java_sun_misc_Unsafe_compareAndSwapInt. + [567b543c09f0] + +2007-04-03 twisti + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/i386/asmpart.S, src/vm/jit/mips/asmpart.S, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/s390/asmpart.S, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/alpha/asmpart.S: Replaced __GNU__ with __linux__ for + exec-stacks. + * src/vm/jit/arm/asmpart.S: Likewise. + * src/vm/jit/i386/asmpart.S: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/powerpc/asmpart.S: Likewise. + * src/vm/jit/powerpc64/asmpart.S: Likewise. + * src/vm/jit/s390/asmpart.S: Likewise. + * src/vm/jit/sparc64/asmpart.S: Likewise. + * src/vm/jit/x86_64/asmpart.S: Likewise. + [444cc6a0252c] + + * src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/linux/md-os.c (threads/threads-common.h): Added. + [eb056f855d16] + + * src/vm/jit/mips/md-abi.h: + * src/vm/jit/mips/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Defined. + [68805417d49c] + + * src/threads/threads-common.c, src/vm/jit/codegen-common.c, + src/vm/jit/stacktrace.h: + * src/threads/threads-common.c (threads_print_stacktrace): Pass + stackframeinfo to stacktrace_create. + + * src/vm/jit/codegen-common.c (threads/native/threads.h): Removed. + (threads/threads-common.h): Added. (codegen_get_pv_from_pc): + Replaced stacktrace_dump_trace with threads_print_stacktrace. + + * src/vm/jit/stacktrace.h (stacktrace_print_trace_from_buffer): + Added. + [92e3e05961c1] + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.c (stacktrace_create): Changed signature. + + (stacktrace_fillInStackTrace): Pass stackframeinfo to + stacktrace_create. (stacktrace_getClassContext): Likewise. + (stacktrace_getCurrentClass): Likewise. (stacktrace_getStack): + Likewise. (stacktrace_dump_trace): Removed. + + * src/vm/jit/stacktrace.h (threads/native/threads.h) + (threads/none/threads.h): Removed. (stacktrace_create): Added. + (stacktrace_dump_trace): Removed. + + * src/threads/native/threads.c (threads_dump): Removed. + * src/threads/native/threads.h (threads_dump): Likewise. + + * src/threads/threads-common.c (vm/jit/stacktrace.h): Added. + (threads_dump): Added. (threads_print_stacktrace): Likewise. + + * src/threads/threads-common.h (threads_dump): Added. + (threads_print_stacktrace): Likewise. + [63bf8943ed5b] + + * src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/replace.c (threads/threads-common.h): Added. + + * src/vm/jit/replace.h: Moved empty defines to the top of the file + to see what's happening when !defined(ENABLE_REPLACEMENT). + [9bff9dceafb9] + + * src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/x86_64/linux/md-os.c (md_signal_handler_sigfpe): Use + exceptions_new_hardware_exception. + [76a092e62a17] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_fillinstacktrace) + [ENABLE_JAVAME_CLDC1_1]: fillInStackTrace has another signature in + CLDC-1.1. + [86cf630e9ed0] + + * src/vm/jit/arm/emit.c, src/vm/jit/arm/md.c: + * src/vm/jit/arm/emit.c (emit_exception_stubs): Removed. + + * src/vm/jit/arm/md.c (md_codegen_patch_branch): Likewise. + (md_stacktrace_get_returnaddress): Removed debug code. + [c10040663367] + + * src/threads/native/threads.h, src/threads/none/threads.h, src/vm/jit + /codegen-common.c, src/vm/jit/replace.c, src/vm/jit/stacktrace.c: + * src/threads/native/threads.h (STACKFRAMEINFO): Return + stackframeinfo instead of a pointer to it. + * src/threads/none/threads.h (STACKFRAMEINFO): Likewise. + + * src/vm/jit/codegen-common.c (codegen_finish_native_call): + STACKFRAMEINFO changes. + + * src/vm/jit/replace.c (replace_recover_source_state): Likewise. + + * src/vm/jit/stacktrace.c (stacktrace_create_stackframeinfo): + Likewise. (stacktrace_create_extern_stackframeinfo): Likewise. + (stacktrace_create_native_stackframeinfo): Likewise. + (stacktrace_remove_stackframeinfo): Likewise. + [a871084ee7e0] + + * src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h: + * src/vm/jit/stacktrace.c (stacktrace_create_inline_stackframeinfo): + Removed. (stacktrace_inline_arithmeticexception): Likewise. + (stacktrace_inline_arrayindexoutofboundsexception): Likewise. + (stacktrace_inline_arraystoreexception): Likewise. + (stacktrace_inline_classcastexception): Likewise. + (stacktrace_inline_nullpointerexception): Likewise. + (stacktrace_inline_fillInStackTrace): Likewise. + (stacktrace_hardware_arithmeticexception): Likewise. + (stacktrace_hardware_nullpointerexception): Likewise. + + * src/vm/jit/stacktrace.h: Likewise. + [af68330ce7c0] + + * configure.ac: + * configure.ac: Added armv4 architecture. + [c937cb3cea57] + + * src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use + exceptions_new_hardware_exception. [ENABLE_THREADS] + (md_signal_handler_sigusr2): New function. + [e9e777a56623] + + * src/vm/jit/i386/linux/md-os.c: + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigfpe): Use + exceptions_new_hardware_exception. + [a97e8e6dc1e0] + + * src/vm/jit/jit.h: + * src/vm/jit/jit.h: Includes alpha-sorted. + [3500fd328b80] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c (native/include/java_lang_String.h): Removed. + (java_value_print): Don't cast to java_lang_String. + [ad5d673f7d24] + + * src/vm/jit/allocator/simplereg.c: + * src/vm/jit/allocator/simplereg.c (simplereg_make_statistics): + Fixed compiler warning. + [1055a2f64e7f] + + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_replacement_stubs): Removed unused + variable disp. + [2e50907d43f4] + + * src/vmcore/statistics.c: + * src/vmcore/statistics.c (statistics_print_memory_usage): Prevent + compiler warning on 64-bit machines. + [ab67f899c788] + +2007-04-02 michi + + * src/vm/jit/replace.c: + Merged revisions 7639-7641 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7641 | michi | 2007-04-03 01:13:55 +0200 (Tue, 03 Apr + 2007) | 2 lines + + * src/vm/jit/replace.c: Added include to fix crash on x86_64. + ........ + [4680535245f6] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c: Added include to fix crash on x86_64. + [ebc64b980d76] + +2007-04-02 twisti + + * src/mm/cacao-gc/gc.h, src/vm/jit/alpha/codegen.c: + * src/mm/cacao-gc/gc.h: Enable __ALPHA__. + + * src/vm/jit/alpha/codegen.c (vm/jit/abi.h): Added. + (createnativestub) [ENABLE_GC_CACAO]: Save and restore callee saved + integer registers in the stackframe info for the GC. + [137d30680194] + +2007-04-02 michi + + * src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md-abi.c: + Merged revisions 7632-7638 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7637 | twisti | 2007-04-02 22:58:30 +0200 (Mon, 02 Apr + 2007) | 4 lines + + * src/vm/jit/alpha/md-abi.c (abi_registers_integer_argument): + Added. (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. ........ r7638 | + twisti | 2007-04-02 23:24:59 +0200 (Mon, 02 Apr 2007) | 4 lines + + * src/vm/jit/alpha/linux/md-os.c [ENABLE_THREADS] + (threads/native/threads.h): Added. [ENABLE_THREADS] + (md_signal_handler_sigusr2): Added #ifdef. ........ + [cd78728131f5] + +2007-04-02 twisti + + * src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/linux/md-os.c [ENABLE_THREADS] + (threads/native/threads.h): Added. [ENABLE_THREADS] + (md_signal_handler_sigusr2): Added #ifdef. + [cee6cdea0943] + + * src/vm/jit/alpha/md-abi.c: + * src/vm/jit/alpha/md-abi.c (abi_registers_integer_argument): Added. + (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. + [8acb739340f8] + + * src/mm/cacao-gc/gc.h, src/vm/jit/x86_64/codegen.c: + * src/mm/cacao-gc/gc.h: Enable __X86_64__. + + * src/vm/jit/x86_64/codegen.c (vm/jit/abi.h): Added. + (createnativestub) [ENABLE_GC_CACAO]: Save and restore callee saved + integer registers in the stackframe info for the GC. + [d62d435e5ddf] + +2007-04-02 michi + + * tests/gc/New.java: + * tests/gc/New.java: Added testcase. + [5ee8dcaa0074] + +2007-04-02 twisti + + * src/mm/cacao-gc/gc.h, src/vm/jit/powerpc/codegen.c: + * src/mm/cacao-gc/gc.h: Enable __POWERPC__. + + * src/vm/jit/powerpc/codegen.c (vm/jit/abi.h): Added. + (createnativestub) [ENABLE_GC_CACAO]: Save and restore callee saved + integer registers in the stackframe info for the GC. + [5a0de1a6ba64] + +2007-04-02 michi + + * src/mm/cacao-gc/heap.c: + * src/mm/cacao-gc/heap.c (heap_print_object): Fixed for 64 bit + architectures. + [1ed0f8681b94] + + * src/vm/jit/parse.c, src/vm/jit/stacktrace.c, src/vm/jit/x86_64/md- + abi.c: + Merged revisions 7628-7631 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7629 | twisti | 2007-04-02 21:45:20 +0200 (Mon, 02 Apr + 2007) | 3 lines + + * src/vm/jit/parse.c (parse): JAVA_GOTO_W must be converted to a + ICMD_GOTO. ........ r7630 | twisti | 2007-04-02 21:56:14 +0200 + (Mon, 02 Apr 2007) | 4 lines + + * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_argument): + Added. (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. ........ r7631 | + michi | 2007-04-02 22:04:22 +0200 (Mon, 02 Apr 2007) | 3 lines + + * src/vm/jit/stacktrace.c (stacktrace_create): Returns NULL if + there is no stacktrace available for the given thread. Fixed + comments. ........ + [1e29fb9df8ce] + + * src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_create): Returns NULL if there + is no stacktrace available for the given thread. Fixed comments. + [63577053a131] + +2007-04-02 twisti + + * src/vm/jit/x86_64/md-abi.c: + * src/vm/jit/x86_64/md-abi.c (abi_registers_integer_argument): + Added. (abi_registers_integer_saved): Likewise. + (abi_registers_integer_temporary): Likewise. + [3da24dcecde5] + + * src/vm/jit/parse.c: + * src/vm/jit/parse.c (parse): JAVA_GOTO_W must be converted to a + ICMD_GOTO. + [6261bb84b822] + +2007-04-02 michi + + * THIRDPARTY, src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/jit.h, + src/vm/jit/parse.c, src/vm/jit/parse.h, src/vm/jit/powerpc/darwin + /md-asm.h, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/stack.c: + Merged revisions 7616-7627 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7617 | twisti | 2007-03-30 01:22:07 +0200 (Fri, 30 Mar + 2007) | 3 lines + + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Fixed address check (thanks Michi). ........ r7619 | twisti | + 2007-03-30 13:41:27 +0200 (Fri, 30 Mar 2007) | 9 lines + + * src/vm/jit/parse.c (parse_realloc_instructions): Renamed ipc to + icount. (parse): Renamed ipc to icount, set method variables at + the very end and use local variables before. + + * src/vm/jit/parse.h (INSTRUCTIONS_CHECK): Renamed ipc to icount. + (PINC): Likewise. (OP_PREPARE_FLAGS): Likewise. ........ r7620 | + edwin | 2007-04-01 12:50:39 +0200 (Sun, 01 Apr 2007) | 3 lines + + * contrib/vmlog: Committed vmlog 0.0.5. + * THIRDPARTY: Added copyright notice for vmlog. ........ r7621 | + stefan | 2007-04-01 18:18:16 +0200 (Sun, 01 Apr 2007) | 3 lines + + * src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/i386/darwin/md- + asm.h: added missing symbol asm_vm_call_method_end. ........ r7622 + | ajordan | 2007-04-02 00:53:59 +0200 (Mon, 02 Apr 2007) | 3 lines + + * src/vm/jit/sparc64/codegen.c: Implemented float argument passing + for builtin calls. + * src/vm/jit/sparc64/codegen.h: Likewise. ........ r7623 | twisti | + 2007-04-02 15:45:30 +0200 (Mon, 02 Apr 2007) | 5 lines + + * src/vm/jit/stack.c (stack_mark_reached): Added assert on b. + (stack_mark_reached_from_outvars): Likewise. + (stack_reach_next_block): Use NULL instead of !. (stack_analyse): + Indent. ........ r7624 | twisti | 2007-04-02 18:09:44 +0200 (Mon, + 02 Apr 2007) | 3 lines + + * src/vm/jit/stack.c (stack_reach_next_block): Reformatted + comments. (stack_analyse): Likewise. ........ r7627 | twisti | + 2007-04-02 20:56:59 +0200 (Mon, 02 Apr 2007) | 8 lines + + * src/vm/jit/jit.h (INS_FLAG_BASICBLOCK): Defined. + (INS_FLAG_ID_SHIFT): Changed to 5. + (INSTRUCTION_STARTS_BASICBLOCK): Added. + + * src/vm/jit/parse.c (parse): Changed basic block determination. + Now basic blocks can start at IR instruction level. This is + required for slow-fast path builtins. ........ + [f9d0a4f6327b] + +2007-04-02 twisti + + * src/vm/jit/jit.h, src/vm/jit/parse.c: + * src/vm/jit/jit.h (INS_FLAG_BASICBLOCK): Defined. + (INS_FLAG_ID_SHIFT): Changed to 5. (INSTRUCTION_STARTS_BASICBLOCK): + Added. + + * src/vm/jit/parse.c (parse): Changed basic block determination. Now + basic blocks can start at IR instruction level. This is required for + slow-fast path builtins. + [ef50941ead84] + +2007-04-02 michi + + * tests/gc/ThreadJava.java, tests/gc/ThreadSleep.java: + * tests/gc/ThreadJava.java: Added testcase. + * tests/gc/ThreadSleep.java: Added testcase. + [0a205fe910b4] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/vm/jit/parse.c, + src/vm/jit/parse.h, src/vm/jit/stack.c: + * src/mm/cacao-gc/gc.c (gc_collect): Moved notification of finalizer + thread. + * src/mm/cacao-gc/mark.c (mark_me): Cleaned up and ifdefed finalizer + code. + [0eb8853e9bf6] + +2007-04-02 twisti + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_reach_next_block): Reformatted comments. + (stack_analyse): Likewise. + [3e3bfb01e253] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_mark_reached): Added assert on b. + (stack_mark_reached_from_outvars): Likewise. + (stack_reach_next_block): Use NULL instead of !. (stack_analyse): + Indent. + [72e9bd12289b] + +2007-04-01 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h: + * src/vm/jit/sparc64/codegen.c: Implemented float argument passing + for builtin calls. + * src/vm/jit/sparc64/codegen.h: Likewise. + [90c476ea0a77] + +2007-04-01 stefan + + * src/vm/jit/i386/darwin/md-asm.h, src/vm/jit/powerpc/darwin/md-asm.h: + * src/vm/jit/powerpc/darwin/md-asm.h, src/vm/jit/i386/darwin/md- + asm.h: added missing symbol asm_vm_call_method_end. + [81dbc8f328aa] + +2007-04-01 edwin + + * THIRDPARTY, contrib/vmlog/COPYING, contrib/vmlog/Makefile, + contrib/vmlog/README, contrib/vmlog/t/concat.c, + contrib/vmlog/t/file.c, contrib/vmlog/t/hash.c, + contrib/vmlog/t/log.c, contrib/vmlog/t/memdup.c, + contrib/vmlog/t/opt.c, contrib/vmlog/t/prolog.h, + contrib/vmlog/t/ring.c, contrib/vmlog/t/string.c, + contrib/vmlog/t/tags.c, contrib/vmlog/t/threadhash.c, + contrib/vmlog/vmlog.c, contrib/vmlog/vmlog.h, + contrib/vmlog/vmlog_cacao.c, contrib/vmlog/vmlog_cacao.h, + contrib/vmlog/vmlog_cacao.patch, contrib/vmlog/vmlog_jamvm.c, + contrib/vmlog/vmlog_jamvm.h, contrib/vmlog/vmlog_jamvm.patch, + contrib/vmlog/vmlogdiff.c, contrib/vmlog/vmlogdump.c, + contrib/vmlog/vmlogindex.c: + * contrib/vmlog: Committed vmlog 0.0.5. + * THIRDPARTY: Added copyright notice for vmlog. + [13140b8f0f3d] + +2007-03-30 twisti + + * src/vm/jit/parse.c, src/vm/jit/parse.h: + * src/vm/jit/parse.c (parse_realloc_instructions): Renamed ipc to + icount. (parse): Renamed ipc to icount, set method variables at the + very end and use local variables before. + + * src/vm/jit/parse.h (INSTRUCTIONS_CHECK): Renamed ipc to icount. + (PINC): Likewise. (OP_PREPARE_FLAGS): Likewise. + [5f89b928fab8] + +2007-03-30 michi + + * tests/gc/Makefile, tests/gc/NativeGlobalRef.java, tests/gc/native.c: + * tests/gc/NativeGlobalRef.java: Added testcase for global + references. + * tests/gc/native.c: Added native library for all testcases. + * tests/gc/Makefile: Added for easy handling of native testcases. + [cad98d81e6c1] + +2007-03-29 twisti + + * src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/s390/arch.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h: + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Fixed address check (thanks Michi). + [5d97b9265241] + +2007-03-29 michi + + * src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/s390/arch.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h, src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/md.c: + Merged revisions 7599,7601-7615 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7604 | pm | 2007-03-29 08:52:15 +0200 (Thu, 29 Mar 2007) + | 7 lines + + * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h: Changed a lot. + ........ r7605 | twisti | 2007-03-29 13:04:25 +0200 (Thu, 29 Mar + 2007) | 3 lines + + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Check for addr == NULL in NPE case. ........ r7611 | ajordan | + 2007-03-29 23:37:40 +0200 (Thu, 29 Mar 2007) | 6 lines + + * src/vm/jit/sparc64/md.c (md_get_pv_from_pc): Implemented sethi + hanlding. + + * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed + window/stack handling in case of exception. + * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Likewise. + ........ r7612 | michi | 2007-03-29 23:56:35 +0200 (Thu, 29 Mar + 2007) | 2 lines + + * src/mm/nogc.c: Fixed merging conflict which was commited to that + file. ........ r7614 | ajordan | 2007-03-30 01:01:58 +0200 (Fri, + 30 Mar 2007) | 5 lines + + * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed + ICMD_IREMPOW2. Added ICMD_L2F and ICMD_L2D. Fixed constant + creation in IF_L* compares. ........ + [5fa9158bb902] + + * src/mm/boehm.c, src/mm/cacao-gc/copy.c, src/mm/cacao-gc/heap.c, + src/mm/gc-common.h, src/mm/memory.h, src/mm/nogc.c, + src/vm/builtin.c, src/vm/jit/mips/irix/md-os.c, + src/vm/jit/mips/linux/md-os.c, src/vmcore/class.c: + * src/vm/builtin.c (builtin_fast_new): Added. + + * src/mm/memory.h: Defined away GC macros for cacao gc. + + * src/vm/jit/mips/linux/md-os.c (md_init): Better use macro here. + * src/vm/jit/mips/irix/md-os.c (md_init): See above. + + * src/vmcore/class.c (class_create_classinfo): Do not use GC macro. + + * src/mm/gc-common.h (heap_alloc): Changed signature of old + heap_allocate. + + * src/mm/nogc.c (heap_alloc): Adapted to above changes. + * src/mm/boehm.c (heap_alloc): See above. + * src/mm/cacao-gc/heap.c (heap_alloc): See above. + + * src/mm/cacao-gc/copy.c: Removed wrongly placed comment. + [53d07e4ed5dc] + +2007-03-29 ajordan + + * src/vm/jit/sparc64/codegen.c: + * src/vm/jit/sparc64/codegen.c (codegen_emit): Fixed ICMD_IREMPOW2. + Added ICMD_L2F and ICMD_L2D. Fixed constant creation in IF_L* + compares. + [67e44799d296] + +2007-03-29 michi + + * src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao- + gc/gc.c, src/mm/nogc.c: + * src/mm/cacao-gc/gc.c (gc_finalizer_all): Implemented + * src/mm/cacao-gc/final.c (final_set_all_reclaimable): Added. + * src/mm/cacao-gc/final.h (final_set_all_reclaimable): Added + prototype. + [46e450965b78] + + * src/mm/nogc.c: + * src/mm/nogc.c: Fixed merging conflict which was commited to that + file. + [c0c73c75fa54] + +2007-03-29 ajordan + + * src/vm/exceptions.h, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md.c: + * src/vm/jit/sparc64/md.c (md_get_pv_from_pc): Implemented sethi + hanlding. + + * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed + window/stack handling in case of exception. + * src/vm/jit/sparc64/asmpart.S (asm_call_jit_compiler): Likewise. + [ab2fb8fcf377] + +2007-03-29 michi + + * src/mm/cacao-gc/final.c, tests/gc/Final.java, + tests/gc/FinalExit.java, tests/gc/FinalForce.java: + * src/mm/cacao-gc/final.c (final_register): Uses list_add_first + instead of list_add_last to be more Sun-like. + + * tests/gc/Final.java: Added testcase for finalization testing. + * tests/gc/FinalExit.java: See above. + * tests/gc/FinalForce.java: See above. + [9d2bb56faa1c] + + * src/vm/exceptions.h: + Merged revisions 7600 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7600 | twisti | 2007-03-29 00:59:52 +0200 (Thu, 29 Mar + 2007) | 3 lines + + * src/vm/exceptions.h (exceptionptr): Removed. + (_no_threads_exceptionptr): Likewise. ........ + [099d13dd30cc] + + * src/mm/cacao-gc/gc.c: + * src/mm/cacao-gc/gc.c (gc_collect): Added a global gc lock. + [07040b7c00cc] + + * tests/gc/ThreadStress.java: + * tests/gc/ThreadStress.java: Added stress test for threads. + [1bae1bedc255] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/replace.c, + src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h: + * src/mm/cacao-gc/heap.c (heap_increase_size): Uses vm_abort on + error now. + * src/mm/cacao-gc/gc.c (gc_finalize_all): Added. + * src/vm/jit/replace.c (replace_me) [ENABLE_GC_CACAO]: Fixed ifdef + here. + [2bfff1dfed66] + +2007-03-29 twisti + + * src/vm/jit/powerpc/linux/md-os.c: + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): + Check for addr == NULL in NPE case. + [be47a420f840] + +2007-03-29 pm + + * src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h: + * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h: Changed a lot. + [3c5a76b228f4] + +2007-03-28 michi + + * tests/gc/Chain.java, tests/gc/Hashcode.java, tests/gc/Simple.java: + * test/gc: Added directory to contain Garbage Collector testcases. + + * test/gc/Chain.java: Added. + * tests/gc/Simple.java: Added. + * tests/gc/Hashcode.java: Added. + [53b6c706a55f] + + * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/compact.c, src/mm + /cacao-gc/compact.h, src/mm/cacao-gc/copy.c, src/mm/cacao-gc/copy.h, + src/mm/cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao- + gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/mark.h, src/mm + /cacao-gc/region.c, src/mm/cacao-gc/region.h, src/mm/cacao- + gc/rootset.c, src/mm/cacao-gc/rootset.h: + Removed author and contact from header, sorry for not listing every + file here. + [3791f0859589] + + * AUTHORS, configure.ac, src/Makefile.am, src/cacaoh/dummy.c, src/mm + /boehm-gc/include/private/gc_locks.h, src/mm/nogc.c, + src/native/include/Makefile.am, src/native/jni.c, + src/native/native.c, src/native/native.h, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, src/threads/native/lock.c, + src/threads/native/threads.c, src/toolbox/list.c, + src/toolbox/list.h, src/vm/access.c, src/vm/builtin.c, + src/vm/builtin.h, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/global.h, src/vm/jit/abi.h, src/vm/jit/alpha/arch.h, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/arch.h, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/Makefile.am, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/arm/md.c, src/vm/jit/asmpart.h, src/vm/jit/code.c, + src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/codegen- + common.h, src/vm/jit/disass-common.c, src/vm/jit/disass.h, + src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/emit-common.c, + src/vm/jit/emit-common.h, src/vm/jit/i386/arch.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/codegen.h, src/vm/jit/i386/emit.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md.c, + src/vm/jit/i386/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/m68k/Makefile.am, src/vm/jit/m68k/arch.h, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, src/vm/jit/m68k + /machine-instr.h, src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md- + abi.c, src/vm/jit/m68k/uclinux/md-abi.h, src/vm/jit/m68k/uclinux/md- + asm.h, src/vm/jit/m68k/uclinux/md-os.c, src/vm/jit/mips/arch.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/patcher.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md- + abi.h, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/reg.c, src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/arch.h, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/verify/typecheck-invoke.inc, + src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h, + src/vm/jit/x86_64/linux/md-os.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/signal.c, src/vm/signallocal.h, + src/vm/string.c, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, + src/vmcore/descriptor.h, src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/statistics.c, + src/vmcore/statistics.h, src/vmcore/zip.c, + tests/regression/native/Makefile.am: + Merged revisions 7501-7598 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7503 | twisti | 2007-03-12 11:11:33 +0100 (Mon, 12 Mar + 2007) | 11 lines + + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c + (vm/vm.h): Added. (open): Call vm_abort. + + * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c + (unistd.h): Added. (readByte): New function. (writeBuf): + Likewise. (available0): Likewise. (close0): Likewise. ........ + r7504 | twisti | 2007-03-12 14:17:07 +0100 (Mon, 12 Mar 2007) | 2 + lines + + * src/vm/jit/arm/md.c (vm/jit/codegen-common.h): Added. ........ + r7505 | twisti | 2007-03-12 14:34:37 +0100 (Mon, 12 Mar 2007) | 8 + lines + + * src/vm/jit/codegen.c (codegen): Change the operand direction of + some macros. Started to implement long-compares differently. + + * src/vm/jit/codegen.h (M_AND, M_ORR, M_EOR, M_AND_IMM, M_MOVEQ) + (M_MOVVS_IMM, M_MOVNE_IMM, M_MOVLT_IMM, M_MOVLS_IMM): Changed + operand direction. (M_ORR_S, M_CMPEQ, M_CMPLE): New macro. + ........ r7510 | michi | 2007-03-13 14:19:07 +0100 (Tue, 13 Mar + 2007) | 2 lines + + * src/vm/jit/arm/linux/Makefile.am: Fixed include path to care + about builddir. ........ r7511 | michi | 2007-03-13 17:32:56 +0100 + (Tue, 13 Mar 2007) | 6 lines + + * src/vm/jit/arm/codegen.c (codegen): Long branches are + implemented differently now. + + * src/vm/jit/arm/codegen.h (M_COMPARE): Easier macros without + overjumps. (M_MOVEQ_IMM, M_MOVGT_IMM, M_ADDHI_IMM, M_SUBLO_IMM, + M_CMPEQ_IMM): New macro. ........ r7513 | twisti | 2007-03-13 + 21:31:23 +0100 (Tue, 13 Mar 2007) | 2 lines + + * src/vm/jit/i386/codegen.c (codegen): Fixed compiler warning. + ........ r7514 | twisti | 2007-03-13 21:31:51 +0100 (Tue, 13 Mar + 2007) | 5 lines + + * src/vm/jit/i386/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + ........ r7516 | michi | 2007-03-14 13:00:07 +0100 (Wed, 14 Mar + 2007) | 2 lines + + * src/mm/nogc.c: Fixed includes and exceptions. ........ r7518 | + michi | 2007-03-14 17:44:05 +0100 (Wed, 14 Mar 2007) | 3 lines + + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Fixed bug with + inmemory arguments, which caused some crashes with verbose-calls. + ........ r7519 | michi | 2007-03-14 18:31:05 +0100 (Wed, 14 Mar + 2007) | 3 lines + + * src/vm/jit/arm/codegen.c (codegen): All the long compares have a + different implementation now. ........ r7520 | twisti | + 2007-03-14 22:16:04 +0100 (Wed, 14 Mar 2007) | 2 lines + + * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Added + temporarily. ........ r7521 | twisti | 2007-03-14 22:18:00 +0100 + (Wed, 14 Mar 2007) | 5 lines + + * src/vm/jit/alpha/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + ........ r7522 | twisti | 2007-03-14 22:54:49 +0100 (Wed, 14 Mar + 2007) | 7 lines + + * src/vmcore/statistics.c (size_string): Added. + (statistics_print_memory_usage): Likewise. + * src/vmcore/statistics.h (size_string): Likewise. + + * src/vm/string.c (vmcore/statistics.h): Added. + (literalstring_u2): Added statistics. ........ r7524 | pm | + 2007-03-15 08:07:51 +0100 (Thu, 15 Mar 2007) | 7 lines + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h: Changed + a lot. + * src/vm/jit/s390/tests, src/vm/jit/s390/tests/tests.java.pp, + src/vm/jit/s390/tests/Makefile: Added opcode tests in java. ........ + r7525 | pm | 2007-03-15 09:23:19 +0100 (Thu, 15 Mar 2007) | 2 lines + + * src/vm/jit/s390/tests/tests.java.pp: added INT2CHAR test testing + negative values. ........ r7526 | twisti | 2007-03-15 10:28:56 + +0100 (Thu, 15 Mar 2007) | 3 lines + + * src/native/jni.c (_Jv_jni_invokeNative): Release memory in + exception case. ........ r7534 | pm | 2007-03-17 00:00:18 +0100 + (Sat, 17 Mar 2007) | 11 lines + + * src/vm/exceptions.c (exceptions_handle_exception): 31 bit + address comparison for S390. These address comparison macros need to + be moved to some header. + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/arch.h, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/md-abi.c, src/vm/jit/s390/tests/tests.java.pp, + src/vm/jit/s390/tests/Makefile: Changed a lot. ........ r7535 | + twisti | 2007-03-17 13:57:32 +0100 (Sat, 17 Mar 2007) | 2 lines + + * src/vm/builtin.c (builtin_isanysubclass): Cleanup and comments. + ........ r7536 | twisti | 2007-03-17 14:10:04 +0100 (Sat, 17 Mar + 2007) | 2 lines + + * src/native/vm/gnu/java_lang_reflect_Method.c (vm/resolve.h): + Added. ........ r7537 | twisti | 2007-03-17 14:11:11 +0100 (Sat, + 17 Mar 2007) | 3 lines + + * src/vm/builtin.c (builtin_isanysubclass): Code cleanup. + (builtin_isanysubclass_vftbl): Likewise. ........ r7538 | twisti | + 2007-03-17 14:12:00 +0100 (Sat, 17 Mar 2007) | 3 lines + + * src/vm/builtin.h (builtin_isanysubclass_vftbl): Removed, made + static. ........ r7543 | ajordan | 2007-03-20 01:25:19 +0100 (Tue, + 20 Mar 2007) | 3 lines + + * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): using this + for native param allocation. No need for my own version of this + anymore. + * src/vm/jit/sparc64/codegen.c: Likewise. ........ r7547 | twisti | + 2007-03-21 14:18:20 +0100 (Wed, 21 Mar 2007) | 4 lines + + * src/vmcore/linker.c (link_primitivetype_table): Set super class + explicitly to NULL. (linker_compute_subclasses): Indent. ........ + r7548 | twisti | 2007-03-21 14:19:44 +0100 (Wed, 21 Mar 2007) | 3 + lines + + * src/vmcore/zip.c (zip_get): Don't assign in if-statement, this + makes debugging a bit easier. ........ r7549 | twisti | + 2007-03-21 14:27:14 +0100 (Wed, 21 Mar 2007) | 22 lines + + * src/vmcore/statistics.c (size_threadobject, size_lock_hashtable) + (size_lock_waiter): Added. (statistics_print_memory_usage): Print + new variables. + + * src/vmcore/statistics.h (size_threadobject, size_lock_hashtable) + (size_lock_waiter): Added. + + * src/threads/native/lock.c (vmcore/options.h): Added. + [ENABLE_STATISTICS] (vmcore/statistics.h): Added. + (lock_hashtable_init): Added statistics. (lock_hashtable_grow): + Likewise. (lock_record_add_waiter): Likewise. + (lock_record_remove_waiter): Likewise. + + * src/threads/native/threads.c [ENABLE_STATISTICS] + (vmcore/statistics.h): Added. (threads_preinit): Added statistics. + (threads_init): Likewise. (threads_start_javathread): Likewise. + (threads_attach_current_thread): Likewise. + (threads_detach_thread): Likewise. ........ r7551 | twisti | + 2007-03-21 15:26:09 +0100 (Wed, 21 Mar 2007) | 8 lines + + * src/vmcore/statistics.c (size_lock_record_pool): Added. + (statistics_print_memory_usage): Print new variable. + + * src/vmcore/statistics.h (size_lock_record_pool): Added. + + * src/threads/native/lock.c (lock_record_alloc_new_pool): Added + statistics. ........ r7554 | michi | 2007-03-22 14:55:44 +0100 + (Thu, 22 Mar 2007) | 3 lines + + * src/vm/jit/arm/codegen.c (codegen) [!ENABLE_SOFTFLOAT]: Fixed + position of soft null pointer checks in PUTFIELD and GETFIELD. + ........ r7559 | twisti | 2007-03-23 12:56:31 +0100 (Fri, 23 Mar + 2007) | 5 lines + + * src/vm/jit/powerpc/emit.c (emit_load): Use switch-case instead + of if-else contruct. (emit_store): Likewise. (emit_copy): + Likewise. ........ r7560 | twisti | 2007-03-23 19:51:41 +0100 + (Fri, 23 Mar 2007) | 4 lines + + * src/vmcore/classcache.c (classcache_add_constraint) + [CLASSCACHE_VERBOSE]: Started to use log-functions. + (classcache_debug_dump): Likewise. ........ r7561 | twisti | + 2007-03-23 20:10:35 +0100 (Fri, 23 Mar 2007) | 7 lines + + * src/vm/global.h (ACC_CLASS_PRIMITIVE): Defined. + + * src/vm/builtin.c (builtin_isanysubclass): Check for primitive + classes. + + * src/vmcore/linker.c (link_primitivetype_table): Set primitive + flag. ........ r7562 | twisti | 2007-03-23 21:38:14 +0100 (Fri, 23 + Mar 2007) | 4 lines + + * src/vm/builtin.c (builtin_isanysubclass_vftbl): Removed. + (builtin_descriptorscompatible): Use builtin_isanysubclass instead + of builtin_isanysubclass_vftbl. ........ r7563 | twisti | + 2007-03-23 22:33:53 +0100 (Fri, 23 Mar 2007) | 22 lines + + * src/vm/builtin.c (builtin_isanysubclass): Removed. + (builtin_instanceof): Replaced builtin_isanysubclass with + class_isanysubclass. (builtin_descriptorscompatible): Likewise. + + * src/vm/builtin.h (builtin_isanysubclass): Removed. + + * src/vm/access.c (access_is_accessible_member): Replaced + builtin_isanysubclass with class_isanysubclass. + * src/native/vm/java_lang_Class.c (isAssignableFrom): Likewise. + + * src/vm/jit/asmpart.h (castinfo): Removed. + + * src/vmcore/class.c (vm/jit/asmpart.h): Added. + (class_isanysubclass): New function. + + * src/vmcore/class.h (castinfo): Added. (class_isanysubclass): + Likewise. + + * src/cacaoh/dummy.c (asm_getclassvalues_atomic): New function. + (intrp_asm_getclassvalues_atomic): Likewise. ........ r7573 | + twisti | 2007-03-25 20:55:02 +0200 (Sun, 25 Mar 2007) | 21 lines + + * src/native/native.c (native_get_parametertypes): Removed. + (native_get_exceptiontypes): Likewise. + * src/native/native.h: Likewise. + + * src/vmcore/method.c (vm/builtin.h): Added. (vm/resolve.h): + Likewise. (method_get_parametertypearray): New function. + (method_get_exceptionarray): Likewise. + * src/vmcore/method.h (method_get_parametertypearray): Added. + (method_get_exceptionarray): Likewise. + + * src/cacaoh/dummy.c (builtin_anewarray): Added. + (resolve_class_from_typedesc): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c + (getParameterTypes): Use method function. (getExceptionTypes): + Likewise. + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (getParameterTypes): Likewise. (getExceptionTypes): Likewise. + ........ r7575 | twisti | 2007-03-25 22:30:50 +0200 (Sun, 25 Mar + 2007) | 9 lines + + Reverted patch 7268. + + * src/vm/jit/code.c: Reverted. + * src/vm/jit/code.h: Likewise. + * src/vm/jit/jit.c: Likewise. + * src/vm/jit/jit.h: Likewise. + * src/vmcore/loader.c: Likewise. + * src/vmcore/method.h: Likewise. ........ r7581 | pm | 2007-03-26 + 09:23:16 +0200 (Mon, 26 Mar 2007) | 10 lines + + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/tests/tests.java.pp, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/md-abi.c: Chaned a lot. ........ r7587 | twisti | + 2007-03-28 15:29:09 +0200 (Wed, 28 Mar 2007) | 19 lines + + * src/vm/exceptions.c (throw_exception_exit_intern): Removed. + (throw_exception): Likewise. (throw_exception_exit): Likewise. + (throw_main_exception): Likewise. (throw_main_exception_exit): + Likewise. (throw_cacao_exception_exit): Likewise. + (exceptions_print_stacktrace): New function. + * src/vm/exceptions.h: Likewise. + + * src/vm/vm.c (vm_create): Use vm_abort or + exceptions_print_stacktrace instead of throw_main_exception_exit. + (vm_run): Likewise. (vm_exit): Likewise. + (vm_get_mainclass_from_jar): Likewise. + + * src/threads/native/threads.c (threads_init): Use return instead + of throw_exception_exit. (threads_startup_thread): Use vm_abort. + ........ r7593 | twisti | 2007-03-28 22:22:13 +0200 (Wed, 28 Mar + 2007) | 3 lines + + Initialized merge tracking via "svnmerge" with revisions "1-7592" + from svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/bran + ches/twisti ........ r7594 | twisti | 2007-03-28 22:28:37 +0200 + (Wed, 28 Mar 2007) | 3 lines + + Initialized merge tracking via "svnmerge" with revisions "1-6086" + from svn+ssh://c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/bran + ches/twisti ........ r7595 | twisti | 2007-03-28 22:50:34 +0200 + (Wed, 28 Mar 2007) | 3 lines + + Initialized merge tracking via "svnmerge" with revisions "1-6085" + from file:///ahome/cacao/svn/cacao/branches/twisti ........ + r7596 | twisti | 2007-03-28 23:05:53 +0200 (Wed, 28 Mar 2007) | 2 + lines + + * Merged in twisti-branch. ........ r7597 | michi | 2007-03-29 + 00:25:44 +0200 (Thu, 29 Mar 2007) | 2 lines + + * AUTHORS: Added myself to the list of authors (finally). ........ + r7598 | twisti | 2007-03-29 00:32:13 +0200 (Thu, 29 Mar 2007) | 2 + lines + + * svnmerge uninit. ........ + [2ba675aeac92] + +2007-03-28 twisti + + * m4/cacaoh.m4, src/native/include/Makefile.am, src/native/jni.c, + src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/toolbox/list.c, + src/toolbox/list.h, src/vm/access.c, src/vm/builtin.c, + src/vm/builtin.h, src/vm/exceptions.h, src/vm/global.h, + src/vm/jit/abi.h, src/vm/jit/alpha/arch.h, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/md.c, src/vm/jit/asmpart.h, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/disass-common.c, + src/vm/jit/disass.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h, + src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/m68k/.cvsignore, + src/vm/jit/m68k/disass.c, src/vm/jit/m68k/emit.h, + src/vm/jit/m68k/linux/.cvsignore, src/vm/jit/m68k/linux/Makefile.am, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/m68k/linux/md-asm.h, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.h, src/vm/jit/mips/arch.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/linux/md-os.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/codegen.h, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md- + abi.h, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/reg.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/emit.h, src/vm/jit/stacktrace.c, + src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c, + src/vm/signal.c, src/vm/signallocal.h, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, + src/vmcore/descriptor.h, src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, tests/regression/native/Makefile.am: + * src/vm/exceptions.h (exceptionptr): Removed. + (_no_threads_exceptionptr): Likewise. + [444d6d50b065] + +2007-03-28 michi + + * configure.ac, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm + /cacao-gc/rootset.c, src/vm/builtin.c, src/vm/builtin.h, + src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/patcher.c, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, + src/vm/jit/parse.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/replace.c, + src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/emit.h, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c, + src/vmcore/classcache.c, src/vmcore/linker.c, src/vmcore/method.c, + src/vmcore/method.h, src/vmcore/options.c, src/vmcore/options.h, + src/vmcore/statistics.c: + * src/mm/cacao-gc/gc.h: Added GC_EXECUTIONSTATE and GC_SOURCESTATE + defines. + * src/mm/cacao-gc/gc.c [!ENABLE_THREADS]: Added _no_threads variables + for above defines. + + * src/mm/cacao-gc/rootset.c: Now uses above defines. + * src/vm/jit/replace.c (replace_me, replace_gc_from_native): Same. + [f6b1620d87fe] + + * AUTHORS: + * AUTHORS: Added myself to the list of authors (finally). + [0b44275eac74] + +2007-03-28 twisti + + * AUTHORS, configure.ac, src/Makefile.am, src/cacaoh/dummy.c, src/mm + /boehm-gc/include/private/gc_locks.h, src/mm/nogc.c, + src/native/include/Makefile.am, src/native/jni.c, + src/toolbox/list.c, src/toolbox/list.h, src/vm/builtin.c, + src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/abi.h, + src/vm/jit/alpha/arch.h, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/codegen.h, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/arch.h, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/arm/md.c, src/vm/jit/asmpart.h, src/vm/jit/codegen- + common.c, src/vm/jit/codegen-common.h, src/vm/jit/disass-common.c, + src/vm/jit/disass.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h, + src/vm/jit/emit-common.c, src/vm/jit/emit-common.h, + src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/codegen.h, + src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/m68k/Makefile.am, + src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/machine-instr.h, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md- + abi.c, src/vm/jit/m68k/uclinux/md-abi.h, src/vm/jit/m68k/uclinux/md- + asm.h, src/vm/jit/m68k/uclinux/md-os.c, src/vm/jit/mips/arch.h, + src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/patcher.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/codegen.h, + src/vm/jit/powerpc/darwin/md-os.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/arch.h, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/codegen.h, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/linux/md- + abi.h, src/vm/jit/powerpc64/linux/md-os.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/reg.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit-arch.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/stacktrace.c, + src/vm/jit/verify/typecheck-invoke.inc, src/vm/jit/x86_64/arch.h, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c, + src/vm/signal.c, src/vm/signallocal.h, src/vm/vm.c, + src/vmcore/descriptor.h, src/vmcore/loader.c, src/vmcore/options.c, + src/vmcore/options.h, tests/regression/native/Makefile.am: + * Merged in twisti-branch. + [584c104cdec1] + + * src/vm/jit/powerpc/codegen.h, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-os.c, src/vm/signal.c, + src/vm/signallocal.h: + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigtrap): New + function. + + * src/vm/jit/powerpc/emit.c (emit_arrayindexoutofbounds_check): Use + trap instruction. + + * src/vm/jit/powerpc/codegen.h (M_OP3_GET_A, M_OP3_GET_B): New + macros. (M_TRAPGEU): Likewise. + + * src/vm/signal.c [__POWERPC__] (signal_init): Install SIGTRAP + handler. + + * src/vm/signallocal.h [__POWERPC__] (md_signal_handler_sigtrap): + Added. + [db686946cce5] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/emit.c (emit_branch): Replaced BRANCH_A with + BRANCH_UGT. (emit_arithmetic_check): Use new hardware-exception + defines. (emit_nullpointer_check): Likewise. + (emit_nullpointer_check_force): Likewise. + (emit_arrayindexoutofbounds_check): Likewise. + (emit_classcast_check): Likewise. (emit_exception_check): Likewise. + + * src/vm/jit/arm/codegen.c (codegen_emit): Generate correct NPE- + check, smaller branch changes. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): + Restructured to be more like the other architectures. + [b1866e6f3a4e] + + * src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/emit.h, src/vm/jit/x86_64/linux/md-os.c, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c: + * src/vm/jit/x86_64/emit.c (vm/exceptions.h): Added. (emit_branch): + New function. (emit_arithmetic_check, + emit_arrayindexoutofbounds_check) (emit_classcast_check, + emit_nullpointer_check, emit_exception_check): Use hardware- + exception instruction. (emit_exception_stubs): Removed. + (emit_mov_mem_reg): New function. (emit_alul_imm32_reg): Likewise. + * src/vm/jit/x86_64/emit.h: Likewise. + + * src/vm/jit/x86_64/md.c (md_codegen_patch_branch): Removed. + + + * src/vm/jit/x86_64/codegen.c (codegen): Renamed to codegen_emit and a + zillion changes. + + * src/vm/jit/x86_64/codegen.h (CALCOFFSETBYTES, CALCIMMEDIATEBYTES): + Removed. (ALIGNCODENOP): Implemented correctly. + (BRANCH_UNCONDITIONAL_SIZE, BRANCH_CONDITIONAL_SIZE): Added. + (BRANCH_NOPS): Added one nop. (M_ALD_MEM, M_ALD_MEM_GET_OPC, + M_ALD_MEM_GET_MOD, M_ALD_MEM_GET_REG) (M_ALD_MEM_GET_RM, + M_ALD_MEM_GET_DISP): New macro. (M_ISUB_IMM32): Likewise. + (M_ICMP_IMM32): Likewise. (M_BAE): Renamed to M_BUGE. (M_BA): + Renamed to M_BUGT. (M_BULT, M_BULE): New macros. (M_CMOVEQ_MEMBASE, + M_CMOVNE_MEMBASE, M_CMOVLT_MEMBASE) (M_CMOVLE_MEMBASE, + M_CMOVGE_MEMBASE, M_CMOVGT_MEMBASE): Removed. (M_CMOVB): Renamed to + M_CMOVULT. (M_CMOVA): Renamed to M_CMOVUGT. + + * src/vm/jit/x86_64/linux/md-os.c (vm/types.h): Added. + (vm/jit/x86_64/codegen.h): Likewise. (vm/exceptions.h): Likewise. + (md_signal_handler_sigsegv): Rewritten for hardware-exceptions. + + * src/vm/jit/x86_64/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS) + (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS): Defined. + + * src/vm/jit/x86_64/patcher.c + (patcher_checkcast_instanceof_interface): Renamed to + patcher_checkcast_interface. (patcher_instanceof_interface): New + function. + [9cbaee9cb174] + + * AUTHORS: + * AUTHORS: Keep it alpha-sorted. + [c261d9c6b664] + + * src/threads/native/threads.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/tests.java.pp, src/vm/vm.c: + * Merged with trunk. + [b65b5373c1e3] + + * src/threads/native/threads.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/vm.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vm/exceptions.c (throw_exception_exit_intern): Removed. + (throw_exception): Likewise. (throw_exception_exit): Likewise. + (throw_main_exception): Likewise. (throw_main_exception_exit): + Likewise. (throw_cacao_exception_exit): Likewise. + (exceptions_print_stacktrace): New function. + * src/vm/exceptions.h: Likewise. + + * src/vm/vm.c (vm_create): Use vm_abort or + exceptions_print_stacktrace instead of throw_main_exception_exit. + (vm_run): Likewise. (vm_exit): Likewise. + (vm_get_mainclass_from_jar): Likewise. + + * src/threads/native/threads.c (threads_init): Use return instead of + throw_exception_exit. (threads_startup_thread): Use vm_abort. + [093dd11f1414] + +2007-03-28 tbfg + + * AUTHORS, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/disass.c, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/emit.h, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/linux/md-os.h, + src/vm/jit/m68k/machine-instr.h, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c: + * AUTHORS: Added Roland Lezuo. + + * src/vm/jit/m68k/linux/md-os.c: Added GPL license header. + * src/vm/jit/m68k/linux/md-os.h: Likewise. + * src/vm/jit/m68k/linux/md-abi.c: Likewise. + * src/vm/jit/m68k/emit.c: Likewise. + * src/vm/jit/m68k/md.c: Likewise. + * src/vm/jit/m68k/emit.h: Likewise. + * src/vm/jit/m68k/codegen.c: Likewise. + * src/vm/jit/m68k/disass.c: Likewise. + * src/vm/jit/m68k/machine-instr.h: Likewise. + * src/vm/jit/m68k/patcher.c: Likewise. + * src/vm/jit/m68k/codegen.h: Likewise. + [2f5a7fa77fd0] + +2007-03-28 twisti + + * src/vm/vm.c, src/vmcore/options.c, src/vmcore/options.h: + * src/vmcore/options.c (checknull): Removed. + * src/vmcore/options.h: Likewise. + + * src/vm/vm.c (opts): Removed softnull. (vm_create): Likewise. + [67aae9ed164f] + +2007-03-27 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/m68k/linux/md-os.c, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c, src/vm/jit/stacktrace.c: + * m68k/linux/md-abi.h (REG_ITMP1_XPTR): Renamed REG_ATMP1_XPTR. + (REG_ITMP2_XPC): Renamed REG_ATMP2_XPC. + + * m68k/linux/md-os.c (md_signal_handler_sigill): Use REG_ATMP1_XPTR + and REG_ATMP2_XPC. + + * m68k/md.c (md_stacktrace_get_returnaddress): Removed frame linking + code, adpat offset. + + * m68k/codegen.c (codegen_emit): Removed frame linking code. + (ICMD_ATHROW): Fixed. (createnativestub): Removed frame linking + code. + + * m68k/asmpart.S (asm_vm_call_method_long): Removed frame linking + code. (asm_vm_call_method_exception_handler): Implemented. + (asm_call_jit_compiler): Removed frame linking code. + (asm_patcher_wrapper): Simpler code. (asm_handle_exception): Partial + implementation. + + * stacktrace.c (stacktrace_create): M68k has a return word on stack. + [1df61ce55fe6] + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-os.c, + src/vm/jit/m68k/linux/md-os.h, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c: + * linux/md-os.h (md_init_linux): Prototyp. + (md_signal_handler_sigill): Likewise. + + * linux/md-os.c (actual_ucontext_t): Correct defines for ucontext_t. + (md_init_linux): New function. (md_signal_handler_sigill): + Implemented. + + * linux/Makefile.am (libmd_la_SOURCES): Added md-os.h. to + dependencies. + + * emit.c (emit_load_low): Implemented. (emit_load_high): + Implemented. (emit_classcast_check): Implemented. (emit_branch): + BRANCH_UGT added. + + * md.c (md_init): Call md_init_linux if on linux. + + * arch.h (HAS_4BYTE_STACKSLOT): Defined true. + (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS): Likewise. + + * codegen.c: Various fixes. (ICMD_INEG): Implemented. (ICMD_IDIV): + Implemented. (ICMD_IREM): Implemented. (ICMD_LDIV): Implemented. + (ICMD_LREM): Implemented. (ICMD_ISHL): Implemented. + (ICMD_ISHLCONST): Implemented. (ICMD_ISHR): Implemented. + (ICMD_ISHRCONST): Implemented. (ICMD_IUSHR): Implemented. + (ICMD_IUSHRCONST): Implemented. (ICMD_IAND): Implemented. + (ICMD_IANDCONST): Implemented. (ICMD_AASTORE): Implemented. + (ICMD_INVOKEINTERFACE): Implemented. (ICMD_TABLESWITCH): + Implemented. (ICMD_LOOKUPSWITCH): Implemented. + + * patcher.c (patcher_instanceof_interface): Implemented. + (patcher_checkcast_interface): Implemented. + (patcher_invokeinterface): Added. + + * codegen.h (ENABLE_SOFTFLOAT): Some ifdefs fors floats. (M_LLD): + Implemented. (M_LST): Implemented. (M_ISUB_IMM): Added. (M_IMUL): + Added. (M_IDIV): Added. (M_ISSL): Added. (M_ISSR): Added. (M_IUSR): + Added. (M_IAND): Added. (M_IOR): Added. (M_IREM): Added. (M_INEG): + Added. (OPWORD_ASSERT): Added. (M_ICMPI): Renamed M_ICMP_IMM. + (M_BLE): Fixed. (M_BHI, M_BHI16, M_BHI32): Added. (M_ASUBINT): + Added. (M_ISSL_IMM): Added (M_ISRL_IMM): Added. (M_IUSR_IMM): Added. + (M_TRAP_SETREGISTER): Added. (M_TRAP): Added. + [b6f5f3f696f2] + +2007-03-26 tbfg + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/tests.java.pp: + * src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv): + Use new exceptions_new_hardware_exception. + + * src/vm/jit/powerpc64/emit.c: Use new hardwareexception defines. + + * src/vm/jit/powerpc64/codegen.c: Likewise. + [826c4444d17a] + +2007-03-26 pm + + * src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c, + src/vm/builtin.h, src/vm/global.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/tests.java.pp, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, src/vmcore/linker.c, + src/vmcore/method.c, src/vmcore/method.h: + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/tests/tests.java.pp, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/md-abi.c: Chaned a lot. + [41183fe2f8bb] + +2007-03-25 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c: + * src/vm/jit/sparc64/emit.c: Adapted to changed BRANCH_U defines. + * src/vm/jit/sparc64/codegen.c: Likewise. + [9179df5f161b] + +2007-03-25 twisti + + * src/vm/jit/codegen-common.h, src/vm/jit/emit-common.c, src/vm/jit + /emit-common.h, src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c: + * src/vm/jit/codegen-common.h (BRANCH_LTU): Renamed to BRANCH_ULT, + to be consistent with Alpha compare instructions. (BRANCH_LEU): + Renamed to BRANCH_ULE. (BRANCH_GEU): Renamed to BRANCH_UGE. + (BRANCH_GTU): Renamed to BRANCH_UGT. + + * src/vm/jit/emit-common.c (emit_bltu): Renamed to emit_bult. + (emit_bleu): Renamed to emit_bule. (emit_bgeu): Renamed to + emit_buge. (emit_bgtu): Renamed to emit_bugt. + * src/vm/jit/emit-common.h: Likewise. + + * src/vm/jit/i386/emit.c (emit_branch): Use new function names. + * src/vm/jit/i386/codegen.c (codegen_emit): Likewise. + [6f04f5dea964] + +2007-03-25 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit-arch.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/emit.h: + * src/vm/jit/sparc64/emit-arch.h: Renamed to emit.h. + * src/vm/jit/sparc64/emit.c: Updated include name. + * src/vm/jit/sparc64/codegen.c: Likewise. + [b52ac55e15ff] + +2007-03-25 twisti + + * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_Class.c, src/vm/access.c, src/vm/builtin.c, + src/vm/builtin.h, src/vm/global.h, src/vm/jit/asmpart.h, + src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vm/jit/powerpc/emit.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h: + * Merged with trunk. + [95bff0b38745] + +2007-03-25 ajordan + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit + /emit-common.c, src/vm/jit/emit-common.h, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit-arch.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/patcher.c: + * src/vm/jit/codegen-common.h (codegen_add_branch_ref): Options + added to branchrefs. (codegen_branch_label_add): Likewise. + * src/vm/jit/codegen-common.c: Likewise. + * src/vm/jit/emit-common.h (emit_label_bccz): Added options. + (emit_label_bcc): Likewise. + * src/vm/jit/emit-common.c (emit_label_*): Adapted to options. + + * src/vm/jit/sparc64/emit-arch.h: Added for SPARC specific branch + otpions and emit_b* wrappers. + + * src/vm/jit/sparc64/emit.c: Adapted to outside changes. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + + * src/vm/jit/sparc64/patcher.c: Fixed classcast_interface patcher. + + * src/vm/jit/sparc64/codegen.h: Fixed M_SHFT macro. + * src/vm/jit/sparc64/codegen.c: Fixed 32-bit shifts and various other + bugs. + [5b5ff31f30a0] + +2007-03-25 twisti + + * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vmcore/loader.c, src/vmcore/method.h: + Reverted patch 7268. + + * src/vm/jit/code.c: Reverted. + * src/vm/jit/code.h: Likewise. + * src/vm/jit/jit.c: Likewise. + * src/vm/jit/jit.h: Likewise. + * src/vmcore/loader.c: Likewise. + * src/vmcore/method.h: Likewise. + [2080e200a6d6] + + * src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/jit/codegen- + common.h, src/vm/jit/emit-common.c, src/vm/jit/emit-common.h, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c: + * src/vm/jit/codegen-common.h (BRANCH_B): Renamed to BRANCH_LTU. + (BRANCH_BE): Renamed to BRANCH_LEU. (BRANCH_AE): Renamed to + BRANCH_GEU. (BRANCH_A): Renamed to BRANCH_GTU. + + * src/vm/jit/emit-common.c (emit_bb): Renamed to emit_bltu. + (emit_bbe): Renamed to emit_bleu. (emit_bae): Renamed to emit_bgeu. + (emit_ba): Renamed to emit_bgtu. + * src/vm/jit/emit-common.h: Likewise. + + * src/vm/jit/i386/emit.c (emit_branch): Use new unsigned-branch + defines. + * src/vm/jit/i386/codegen.c (codegen_emit): Use new unsigned-branch + functions. + [0389cd4d3375] + + * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/vm/jit/i386/patcher.c, src/vmcore/method.c, src/vmcore/method.h: + * src/native/native.c (native_get_parametertypes): Removed. + (native_get_exceptiontypes): Likewise. + * src/native/native.h: Likewise. + + * src/vmcore/method.c (vm/builtin.h): Added. (vm/resolve.h): + Likewise. (method_get_parametertypearray): New function. + (method_get_exceptionarray): Likewise. + * src/vmcore/method.h (method_get_parametertypearray): Added. + (method_get_exceptionarray): Likewise. + + * src/cacaoh/dummy.c (builtin_anewarray): Added. + (resolve_class_from_typedesc): Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c (getParameterTypes): + Use method function. (getExceptionTypes): Likewise. + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (getParameterTypes): Likewise. (getExceptionTypes): Likewise. + [491366802e0d] + +2007-03-25 ajordan + + * src/vm/jit/sparc64/codegen.c: + * src/vm/jit/sparc64/codegen.c (emit_codegen): Fixed incoming + argument handling, 'stack arg -> spilled' case. Fixed compares in + ICMD_IF_XX (integer ones) by removing branch on reg optimization + when val == 0. Doesn't work when there is junk in the upper 32-bits. + Fixed lookupswitch. + [7a9636db4b25] + +2007-03-24 twisti + + * src/vm/jit/i386/arch.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/codegen.h, src/vm/jit/i386/emit.c, + src/vm/jit/i386/linux/md-os.c, src/vm/jit/i386/md.c, + src/vm/jit/i386/patcher.c: + * src/vm/jit/i386/emit.c (vm/exceptions.h): Added. (emit_branch): + New function. (emit_arithmetic_check, + emit_arrayindexoutofbounds_check) (emit_classcast_check, + emit_nullpointer_check, emit_exception_check): Use hardware- + exception instructions. (emit_exception_stubs): Removed. + + * src/vm/jit/i386/md.c (md_codegen_patch_branch): Removed. + + * src/vm/jit/i386/codegen.c (codegen): Renamed to codegen_emit and a + zillion changes. + + * src/vm/jit/i386/codegen.h (M_ALD_MEM): Added. (M_ALD_MEM_GET_OPC, + M_ALD_MEM_GET_MOD, M_ALD_MEM_GET_REG) (M_ALD_MEM_GET_RM, + M_ALD_MEM_GET_DISP): Likewise. + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigsegv): + Rewritten for hardware-exceptions. + + * src/vm/jit/i386/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS) + (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS): Defined. + + * src/vm/jit/i386/patcher.c + (patcher_checkcast_instanceof_interface): Renamed to + patcher_checkcast_interface. (patcher_instanceof_interface): New + function. + [0d1bc9f817e7] + + * src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/mips/linux/md-os.c: + * src/vm/jit/mips/linux/md-os.c (md_signal_handler_sigsegv): Use new + exceptions_new_hardware_exception. + + * src/vm/jit/powerpc/emit.c (emit_arithmetic_check) + (emit_arrayindexoutofbounds_check, emit_classcast_check) + (emit_nullpointer_check, emit_exception_check): Use new hardware- + exception defines. + * src/vm/jit/powerpc/codegen.c (codegen_emit): Likewise. + [421de52e290f] + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h: + * src/vm/jit/codegen-common.c (codegen_setup): Don't set + exceptionrefs. (codegen_reset): Likewise. + (codegen_add_exception_ref): Removed. + (codegen_add_arithmeticexception_ref): Likewise. + (codegen_add_arrayindexoutofboundsexception_ref): Likewise. + (codegen_add_arraystoreexception_ref): Likewise. + (codegen_add_classcastexception_ref): Likewise. + (codegen_add_nullpointerexception_ref): Likewise. + (codegen_add_fillinstacktrace_ref): Likewise. + + * src/vm/jit/codegen-common.h (codegendata): Removed exceptionrefs. + (exceptionref): Removed. (codegen_add_arithmeticexception_ref): + Likewise. (codegen_add_arrayindexoutofboundsexception_ref): + Likewise. (codegen_add_arraystoreexception_ref): Likewise. + (codegen_add_classcastexception_ref): Likewise. + (codegen_add_nullpointerexception_ref): Likewise. + (codegen_add_fillinstacktrace_ref): Likewise. + [fd308cb27a30] + +2007-03-24 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/patcher.c: + This is the hello world runs commit. + + * emit.c (emit_branch): Fixed. + + * codegen.c (ICMD_*ASTORE): Fixed. (ICMD_*ALOAD): Fixed. + + * patcher.c (patcher_resolve_classref_to_flags): Implemented. + (patcher_resolve_classref_to_vftbl): Implemented. + + * asmpart.S (asm_patcher_wrapper): Store scratch registers. + (asm_getclassvalues_atomic): Implemented. + + * codegen.h (M_IMOV_IMM32): Added, for use with patchers. + [ad44ea32e5dc] + +2007-03-23 tbfg + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/m68k/patcher.c: + * linux/md-abi.h (ENABLE_SOFTFLOAT): Ifdefed stuff. + + * linux/md-abi.c (ENABLE_SOFTFLOAT): Ifdefed stuff. + + * emit.c (ENABLE_SOFTFLOAT): Ifdefed stuff. + (emit_nullpointer_check): Added. + + * arch.h (SUPPORT_CONST_MUL): Yes. + + * codegen.c (codegen_emit): ENABLE_SOFTFLOAT stuff. (ICMD_*CONST): + Added. (ICMD_INT2*): Added. (ICMD_IMUL*): Added. (ICMD_IADD, + ICMD_ISUB): Fixes. + + * patcher.c (patcher_invokevirtual): Implemented. + + * codegen.h: Lots of new opcodes implemented. + [bc42d1195a58] + +2007-03-23 twisti + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/linux/md-os.c: + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): Use + new exceptions_new_hardware_exception. + + * src/vm/jit/alpha/emit.c (emit_arithmetic_check) + (emit_arrayindexoutofbounds_check, emit_classcast_check) + (emit_nullpointer_check, emit_exception_check): Use new hardware- + exception defines. + * src/vm/jit/alpha/codegen.c (codegen_emit): Likewise. + [2cd307710e39] + + * src/vm/jit/alpha/md.c: + * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Removed. + (md_codegen_patch_branch): Likewise. + [6d2d08670841] + + * src/vm/access.c, src/vm/builtin.h, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/global.h, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-os.c, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/linker.c: + * src/vm/exceptions.c (exceptions_new_hardware_exception): Changed + signature and rewritten. + + * src/vm/exceptions.h (EXCEPTION_LOAD_DISP_*): Renamed to + EXCEPTION_HARDWARE_*. (exceptions_new_hardware_exception): Changed + signature. + + * src/vm/jit/powerpc/linux/md-os.c (md_signal_handler_sigsegv): Use + new exceptions_new_hardware_exception. + + * src/vm/jit/powerpc/emit.c (emit_arithmetic_check) + (emit_arrayindexoutofbounds_check, emit_classcast_check) + (emit_nullpointer_check, emit_exception_check): Use new defines. + * src/vm/jit/powerpc/codegen.c (codegen_emit): Likewise. + [e891bd9a01e9] + + * src/cacaoh/dummy.c, src/native/vm/java_lang_Class.c, + src/vm/access.c, src/vm/builtin.c, src/vm/builtin.h, + src/vm/jit/asmpart.h, src/vmcore/class.c, src/vmcore/class.h: + * src/vm/builtin.c (builtin_isanysubclass): Removed. + (builtin_instanceof): Replaced builtin_isanysubclass with + class_isanysubclass. (builtin_descriptorscompatible): Likewise. + + * src/vm/builtin.h (builtin_isanysubclass): Removed. + + * src/vm/access.c (access_is_accessible_member): Replaced + builtin_isanysubclass with class_isanysubclass. + * src/native/vm/java_lang_Class.c (isAssignableFrom): Likewise. + + * src/vm/jit/asmpart.h (castinfo): Removed. + + * src/vmcore/class.c (vm/jit/asmpart.h): Added. + (class_isanysubclass): New function. + + * src/vmcore/class.h (castinfo): Added. (class_isanysubclass): + Likewise. + + * src/cacaoh/dummy.c (asm_getclassvalues_atomic): New function. + (intrp_asm_getclassvalues_atomic): Likewise. + [f259f2de6309] + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_isanysubclass_vftbl): Removed. + (builtin_descriptorscompatible): Use builtin_isanysubclass instead + of builtin_isanysubclass_vftbl. + [86da5e869cbf] + + * src/vm/builtin.c, src/vm/global.h, src/vmcore/linker.c: + * src/vm/global.h (ACC_CLASS_PRIMITIVE): Defined. + + * src/vm/builtin.c (builtin_isanysubclass): Check for primitive + classes. + + * src/vmcore/linker.c (link_primitivetype_table): Set primitive + flag. + [0ff0eb43786d] + + * src/vmcore/classcache.c: + * src/vmcore/classcache.c (classcache_add_constraint) + [CLASSCACHE_VERBOSE]: Started to use log-functions. + (classcache_debug_dump): Likewise. + [9b93f8cd8dc9] + + * src/vm/jit/powerpc/emit.c: + * src/vm/jit/powerpc/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + [e24ec626da8a] + +2007-03-23 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/emit.c: + * src/vm/jit/m68k/emit.c (emit_verbosecall_exit): Fixed. + + * src/vm/jit/m68k/codegen.c (ICMD_IRETURN): Fixed. + (createnativestub): Fixed. + + * src/vm/jit/m68k/asmpart.S (L_asm_vm_call_method_copy_done): + Removed assertion. + [9fbd34c11819] + +2007-03-22 michi + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_nullpointer_check_force): Added. + * src/vm/jit/arm/codegen.h (gen_nullptr_check_intern): Removed. + * src/vm/jit/arm/codegen.c (codegen_emit): Adapted to above changes. + [6c0669c61b9c] + +2007-03-22 tbfg + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/patcher.c: + * src/vm/jit/codegen-common.h (datareferences): Enabled for m68k. + + * src/vm/jit/dseg.c (dseg_adddata): Enabled for m68k. + (dseg_resolve_datareferences): Enalbed for m68k. + + * src/vm/jit/dseg.h: Likewise. + + * src/vm/jit/m68k/linux/md-abi.h (REG_D0): Added. (REG_D1, REG_A0, + REG_A1, REG_F0, REG_F1): Added. + + + * src/vm/jit/m68k/emit.c (emit_patcher_stubs): Fixed. + + * src/vm/jit/m68k/codegen.c (createnativestub): Implemented. + + * src/vm/jit/m68k/patcher.c (patcher_resolve_native_function): + Added. + + * src/vm/jit/m68k/codegen.h (M_AMOV): Fixed. (M_AADD_IMM): Fixed. + (M_IADD_IMM): Fixed. + + * src/vm/jit/codegen-common.c (codegen_setup): Datareferences + enabled for m68k. + [de445ee3cb19] + +2007-03-22 twisti + + * src/vm/jit/arm/codegen.c: + * Merged with trunk. + [e13a0efc99c5] + +2007-03-22 michi + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen) [!ENABLE_SOFTFLOAT]: Fixed + position of soft null pointer checks in PUTFIELD and GETFIELD. + [0241cda4051a] + +2007-03-21 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/emit.h, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/linux/md-abi.h (REG_FRESULT2): Removed, all float + registers are 64bit. (REG_A0_A1_PACKED): Removed, no argument + registers. + + * src/vm/jit/m68k/linux/md-abi.c (md_return_alloc): Implemented, we + can alway precolor the result register as no argument registers are + used. + + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Fixed. (emit_branch): + Implemented. (emit_classcast_check): Implemented. + (emit_arrayindexoutofbounds_check): Implemented. + + * src/vm/jit/m68k/md.c (md_get_method_patch_address): Implemented + invokevirtual case. (md_return_alloc): Moved to linux/md-abi.c. + + * src/vm/jit/m68k/emit.h (emit_jsr): Removed. (emit_jmp): Removed. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Added branch resolving. + (ICMD_IADD): Implemented. (ICMD_IINC): Implemented. + (ICMD_IADDCONST): Implemented. (ICMD_ASTORE): Implemented. + (ICMD_IF*): Implemented. (ICMD_IF_ICMP*): Implemented. + (ICMD_IF_ACMP*): Implemented. (ICMD_ARRAYLENGTH): Implemented. + (ICMD_*LOAD): Implemented, but not long, float and double. + (ICMD_*STORE): Likewise. (ICMD_INVOKEVIRTUAL): Fixed. + (ICMD_INSTANCEOF): Partially implemented. (ICMD_CHECKCAST): + Likewise. + + * src/vm/jit/m68k/patcher.c (patcher_resolve_classref_to_flags): + Added. (patcher_resolve_classref_to_vftbl): Added. + (patcher_instanceof_interface): Added. + (patcher_checkcast_interface): Added. + + * src/vm/jit/m68k/asmpart.S (asm_call_jit_compiler): Fixed mptr. + + * src/vm/jit/m68k/codegen.h (BRANCH_NOPS): Implemented. (M_MOV_IMM): + Renamed M_IMOV_IMM. (M_IMOV): Added. (M_AMOV): Added. (M_ICLR): + Added. (M_PUSH): Renamed M_IPUSH. (M_POP): Renamed M_IPOP. + (M_PUSH_IMM): Renamed M_IPUSH_IMM. (M_IADD_IMM): Added. (M_ISUB): + Added. (M_IADD): Added. (M_TST): Renamed M_ITST. (M_ICMPI): Added. + (M_ACMPI): Added. (M_ICMP): Added. (M_ACMP): Added. (M_IAND_IMM): + Added. (M_B[R|EQ|NE|LT|GE|GT|LE|NAN]_[16|32]): Added. (M_LBZX): + Added. (M_LHZX): Added. (M_LWZX): Added. (M_LAX): Added. (M_STBX): + Added. (M_STHX): Added. (M_STWX): Added. (M_STAX): Added. (M_BSEXT): + Added. (M_HSEXT): Added. (M_AADDINT): Added. (M_ISSL_IMM): Added. + [c577767cfb92] + +2007-03-21 twisti + + * src/threads/native/lock.c, src/vmcore/statistics.c: + * Merged with trunk. + [66e2171855c4] + + * src/threads/native/lock.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vmcore/statistics.c (size_lock_record_pool): Added. + (statistics_print_memory_usage): Print new variable. + + * src/vmcore/statistics.h (size_lock_record_pool): Added. + + * src/threads/native/lock.c (lock_record_alloc_new_pool): Added + statistics. + [de5df327235c] + + * src/native/jni.c, src/native/vm/gnu/java_lang_reflect_Method.c, + src/threads/native/lock.c, src/threads/native/threads.c, + src/vm/builtin.c, src/vm/builtin.h, src/vm/exceptions.c, + src/vm/jit/s390/arch.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c, + src/vmcore/linker.c, src/vmcore/statistics.c: + * Merged with trunk. + [044d295cad35] + + * src/threads/native/lock.c, src/threads/native/threads.c, + src/vmcore/statistics.c, src/vmcore/statistics.h: + * src/vmcore/statistics.c (size_threadobject, size_lock_hashtable) + (size_lock_waiter): Added. (statistics_print_memory_usage): Print + new variables. + + * src/vmcore/statistics.h (size_threadobject, size_lock_hashtable) + (size_lock_waiter): Added. + + * src/threads/native/lock.c (vmcore/options.h): Added. + [ENABLE_STATISTICS] (vmcore/statistics.h): Added. + (lock_hashtable_init): Added statistics. (lock_hashtable_grow): + Likewise. (lock_record_add_waiter): Likewise. + (lock_record_remove_waiter): Likewise. + + * src/threads/native/threads.c [ENABLE_STATISTICS] + (vmcore/statistics.h): Added. (threads_preinit): Added statistics. + (threads_init): Likewise. (threads_start_javathread): Likewise. + (threads_attach_current_thread): Likewise. (threads_detach_thread): + Likewise. + [0e6bc4048dbd] + + * src/vmcore/zip.c: + * src/vmcore/zip.c (zip_get): Don't assign in if-statement, this + makes debugging a bit easier. + [9f9318ee0bec] + + * src/vmcore/linker.c: + * src/vmcore/linker.c (link_primitivetype_table): Set super class + explicitly to NULL. (linker_compute_subclasses): Indent. + [0179eeef5747] + +2007-03-21 tbfg + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/disass.c, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/linux/md-abi.h (ADR_RES_CNT): Increased, as %fp + should not be used. (TRACE_ARGS_NUM): Removed. + + * src/vm/jit/m68k/linux/md-abi.c (nregdescadr): Reserved %fp. + + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): Generated moveql for + short immideates. (emit_load): Implemented. + (emit_verbosecall_enter): Implemented. (emit_verbosecall_exit): + Implemented. + + * src/vm/jit/m68k/md.c (md_codegen_get_pv_from_pc): Comment fixed. + (md_get_method_patch_address): Fixed. (cacheflush): Method defintion + added. (md_cacheflush): Implemented. (md_dcacheflush): Implemented. + (md_icacheflush): Implemented. (comment): Kernel patch for + sys_cacheflush to work added. + + * src/vm/jit/m68k/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER): Defined. + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER): Undefined. + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Undefined. + + * src/vm/jit/m68k/codegen.c (codegen_emit): Used callee saved + registers are stored. Arguments copied into local map. Function + calls properly linked. Stack freed, calle saved register restored. + (createcompilerstub): Fixed. (ICMD_ICONST): Implemented. + (ICMD_ATHROW): Likewise. (ICMD_GOTO): Likewise. (ICMD_RET): + Likewise. (ICMD_JSR): Likewise. (ICMD_IFNULL): Likewise. + (ICMD_IFNONNULL): Likewise. (ICMD_GETFIELD): Likewise. + (ICMD_PUTFIELD): Likewise. (ICMD_BUILTIN): Fixed argument handling. + (ICMD_IRETURN): Fixed address return type issue. + + * src/vm/jit/m68k/disass.c (disassinstr): Even prettier output. + + * src/vm/jit/m68k/patcher.c (patcher_wrapper): Fixed. + (patcher_get_putfield): Implemented. + + * src/vm/jit/m68k/asmpart.S (asm_handle_exception): Symbol added. + (asm_vm_call_method): Fixed argument passing. + (asm_call_jit_compiler): Removes stackframe. Invoked jitcode without + linking. + + * src/vm/jit/m68k/codegen.h (M_NOP): Added. (ALIGNCODENOP): Added. + (M_BSR): Renamed M_BSR_IMM. (M_JSR_PCREL): Added. (M_PUSHALL): + Likewise. (M_POPALL): Likewise. (M_AADD_IMM): Likewise. + (M_INT2ADRMOVE): Likewise. (M_ADR2INTMOVE): Likewise. (M_TST): + Likewise. (M_ATST): Likewise. + [d0b36959ff46] + +2007-03-20 ajordan + + * src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/md.c: + * src/vm/jit/sparc64/codegen.h: Fixed load/stores with large + displacements (SETHI). + + * src/vm/jit/sparc64/codegen.c: Implemented hardware exceptions. + * src/vm/jit/sparc64/md.c: Likwise. + * src/vm/jit/sparc64/linux/md-os.c: Likewise. + * src/vm/jit/sparc64/arch.h: Likewise. + [63e0d09e3f85] + +2007-03-20 michi + + * src/vm/exceptions.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, + src/vm/jit/arm/linux/md-os.c, src/vm/signal.c, src/vm/signallocal.h: + * src/vm/jit/arm/codegen.c (codegen_emit): No longer emit exception + stubs. + + * src/vm/jit/arm/codegen.h: Trap instructions added. + + * src/vm/jit/arm/emit.c: (emit_arithmetic_check): Use hardware- + exception instructions. (emit_arrayindexoutofbounds_check): + Likewise. (emit_classcast_check): Likewise. + (emit_nullpointer_check): Likewise. (emit_exception_check): + Likewise. + + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigill): Added. + + * src/vm/signal.c (signal_init) [__ARM__]: Catch SIGILL for + hardware-exceptions. + + * src/vm/signallocal.h [__ARM__]: Added prototype for + md_signal_handler_sigill. + + * src/vm/exceptions.c (exceptions_new_hardware_exception) [__ARM__]: + Adapted to ARM since there is no REG_ZERO on this arch. + [2627837d967b] + +2007-03-20 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/md-abi.c: + * src/vm/jit/sparc64/md-abi.c (md_param_alloc_native): using this + for native param allocation. No need for my own version of this + anymore. + * src/vm/jit/sparc64/codegen.c: Likewise. + [a9e82fd0d81d] + +2007-03-20 michi + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_new_hardware_exception): Added + comment and assertion for ARM, since there is no REG_ZERO there. + [066bff2c61cd] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/emit.c: + Lots of the stuff in this commit was done by twisti, I only + completed his work. + + * src/vm/jit/arm/emit.c (emit_branch, emit_arithmetic_check) + (emit_classcast_check, emit_exception_check): Added. + (emit_exception_stubs): Fixed. + + * src/vm/jit/arm/codegen.h (load_var_to_reg, store_reg_to_var_lng): + Removed. (gen_resolvebranch, gen_nullptr_check, gen_div_check, + gen_bound_check): Removed. + + * src/vm/jit/arm/codegen.c (codegen): Renamed to codegen_emit. + Changed to use emit-branch and emit-check functions. + [cf7ed6d495a5] + + * src/vm/jit/arm/arch.h, src/vm/jit/arm/md.c: + * src/vm/jit/arm/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS) + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Added. + + * src/vm/jit/arm/md.c (md_codegen_patch_branch): Added assertion. + [6e95c5f34111] + +2007-03-17 ajordan + + * src/native/vm/gnu/java_lang_reflect_Method.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, src/vm/jit + /codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit/emit- + common.c, src/vm/jit/emit-common.h, src/vm/jit/m68k/emit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/emit.c, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md.c, + src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c: + * src/vm/jit/emit-common.h: Functions which branch on unsigned + conditions can be enabled by defining + SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS to 1 in arch.h. + (emit_branch): Added option argument to machine dependent branch + emitting function, to accomodate special flags some architectures + might allow to set in the branch. (eg. selecting condition codes, + setting prediction) (emit_bccz): Added option argument. (emit_bcc): + Likewise. + * src/vm/jit/codegen-common.h: Added define for empty branch options + argument. + * src/vm/jit/emit-common.c: All branch emitting functions changed to + pass an empty options argument. + + * src/vm/jit/codegen-common.c (codegen_resolve_branchrefs): Call to + emit_b* adapted to new brach emitting signature. + * src/vm/jit/powerpc/emit.c (emit_branch): Likewise. + * src/vm/jit/powerpc/codegen.c (codegen_emit): Likewise. + * src/vm/jit/alpha/emit.c (emit_branch): Likewise. + * src/vm/jit/alpha/codegen.c (codegen_emit): Likewise. + * src/vm/jit/mips/emit.c (emit_branch): Likewise. + * src/vm/jit/mips/codegen.c (codegen_emit): Likewise. + * src/vm/jit/m68k/emit.c (emit_branch): Likewise. + * src/vm/jit/powerpc64/emit.c (emit_branch): Likewise. + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Likewise. + + * src/vm/jit/sparc64/*: Ported code to work with branch and + exception changes. + [082d27818cb9] + +2007-03-17 twisti + + * src/vm/builtin.h: + * src/vm/builtin.h (builtin_isanysubclass_vftbl): Removed, made + static. + [40dbf088ff86] + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_isanysubclass): Code cleanup. + (builtin_isanysubclass_vftbl): Likewise. + [35e3a6da581a] + + * src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/vm/gnu/java_lang_reflect_Method.c (vm/resolve.h): + Added. + [e18a539bc7ef] + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_isanysubclass): Cleanup and comments. + [da83167dc0e7] + +2007-03-16 pm + + * src/vm/exceptions.c, src/vm/jit/s390/arch.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/tests/Makefile, src/vm/jit/s390/tests/tests.java.pp: + * src/vm/exceptions.c (exceptions_handle_exception): 31 bit address + comparison for S390. These address comparison macros need to be + moved to some header. + * src/vm/jit/s390/emit.c, src/vm/jit/s390/md.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/arch.h, src/vm/jit/s390/patcher.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/s390/tests/tests.java.pp, + src/vm/jit/s390/tests/Makefile: Changed a lot. + [b5435a3d596b] + +2007-03-16 tbfg + + * src/vm/jit/powerpc64/asmpart.S: + * src/vm/jit/powerpc64/asmpart.S (libjvm): Fix libjvm build. + [f84ce133c86f] + + * src/vm/jit/emit-common.c, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c: + * powerpc64/emit.c (emit_branch): Removed superflous vm_abort. + + * powerpc64/codegen.c (codegen_emit): Adopt ppc change. + + * powerpc64/asmpart.S (__ASSEMBLY__): Define needed for newer libc. + (global): Fixed things for static build. + + * emit-common.c (emit_bnan): Enabled for __POWERPC64__. + [773024452f4e] + +2007-03-16 twisti + + * src/cacaoh/dummy.c, src/vm/exceptions.c, src/vm/exceptions.h, + src/vmcore/loader.c: + * src/vm/exceptions.c + (exceptions_throw_noclassdeffounderror_wrong_name): New function. + (exceptions_new_hardware_exception): Distinguish pointer-size. + + * src/vm/exceptions.h + (exceptions_throw_noclassdeffounderror_wrong_name): Added. + * src/cacaoh/dummy.c: Likewise. + + * src/vmcore/loader.c (load_class_from_classbuffer): Use + exceptions_throw_noclassdeffounderror_wrong_name. + [10d06f982050] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen_emit): Use label-branches + instead of hardcoded ones (maybe there are some left). + [af55245327e3] + + * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h: + * src/vm/jit/emit-common.c (emit_label_bne, emit_label_blt) + (emit_label_bge, emit_label_bgt, emit_label_ble): New function. + * src/vm/jit/emit-common.h: Likewise. + [edc6c51ac2df] + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/emit.c: + * src/vm/jit/codegen-common.c (codegen_generate): Removed debug + code. + * src/vm/jit/powerpc/emit.c (emit_branch): Likewise. + [532c70a3d6b6] + +2007-03-15 tbfg + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/patcher.c: + * codegen.c (ICMD_CALOAD): Do not use sign extending load for char. + Dacapo antlr now passes. (opt_showdisassemble): Removed from various + places. + + * patcher.c (opt_showdisassemble): Replaced by opt_shownops. cacao + -so works again. + [e31fbfe92629] + +2007-03-15 twisti + + * src/native/jni.c: + * src/native/jni.c (_Jv_jni_invokeNative): Release memory in + exception case. + [8caf33a3260a] + +2007-03-15 pm + + * src/vm/jit/s390/tests/tests.java.pp: + * src/vm/jit/s390/tests/tests.java.pp: added INT2CHAR test testing + negative values. + [aa554a26fc64] + + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/tests/Makefile, src/vm/jit/s390/tests/tests.java.pp: + * src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h: Changed a + lot. + * src/vm/jit/s390/tests, src/vm/jit/s390/tests/tests.java.pp, + src/vm/jit/s390/tests/Makefile: Added opcode tests in java. + [7cf85b556eef] + +2007-03-14 twisti + + * src/mm/nogc.c, src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/emit.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/string.c, + src/vmcore/statistics.c: + * Merged with trunk. + [8305ef91befc] + + * src/vm/string.c, src/vmcore/statistics.c, src/vmcore/statistics.h: + * src/vmcore/statistics.c (size_string): Added. + (statistics_print_memory_usage): Likewise. + * src/vmcore/statistics.h (size_string): Likewise. + + * src/vm/string.c (vmcore/statistics.h): Added. (literalstring_u2): + Added statistics. + [4848e755769f] + + * src/vm/jit/alpha/emit.c: + * src/vm/jit/alpha/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + [1eb3f98f544d] + + * src/vm/jit/alpha/md.c: + * src/vm/jit/alpha/md.c (vm/jit/codegen-common.h): Added + temporarily. + [ce089b68b9b5] + +2007-03-14 michi + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen): All the long compares have a + different implementation now. + [7da8dcbce235] + + * src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Fixed bug with + inmemory arguments, which caused some crashes with verbose-calls. + [1564b2409e4a] + +2007-03-14 tbfg + + * src/vm/jit/powerpc64/asmpart.S: + * asmpart.S (asm_cacheflush): Create correct ppc64 alf abi function + descriptor for gcc-4.1. gcc-3.4 works too. + + (asm_getclassvalues_atomic): Likewise. + [b16c7b5c46c9] + +2007-03-14 michi + + * src/mm/nogc.c: + * src/mm/nogc.c: Fixed includes and exceptions. + [17f4c0aa0bb1] + +2007-03-13 twisti + + * src/vm/jit/i386/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.h: + * src/vm/jit/powerpc64/linux/md-abi.h (REG_A3, REG_FA0, REG_FA1): + Added. + + * src/vm/jit/powerpc64/emit.c (emit_verbosecall_exit): Adopted + signature change of builtin_verbosecall_exit. + [5b5201b65647] + + * src/vm/jit/i386/emit.c: + * src/vm/jit/i386/emit.c (emit_load): Use switch-case instead of if- + else contruct. (emit_store): Likewise. (emit_copy): Likewise. + [bdbfe4ab81d9] + + * src/vm/jit/i386/codegen.c: + * src/vm/jit/i386/codegen.c (codegen): Fixed compiler warning. + [d04aaed44b74] + + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/md.c: + * Merged with trunk. + [e65251d81071] + +2007-03-13 michi + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h: + * src/vm/jit/arm/codegen.c (codegen): Long branches are implemented + differently now. + + * src/vm/jit/arm/codegen.h (M_COMPARE): Easier macros without + overjumps. (M_MOVEQ_IMM, M_MOVGT_IMM, M_ADDHI_IMM, M_SUBLO_IMM, + M_CMPEQ_IMM): New macro. + [baa7f5e2d7d7] + + * src/vm/jit/arm/linux/Makefile.am: + * src/vm/jit/arm/linux/Makefile.am: Fixed include path to care about + builddir. + [25fb1683004a] + +2007-03-12 twisti + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Removed + ifdef. + [1b260c15209b] + + * src/vm/jit/codegen-common.h: + * src/vm/jit/codegen-common.h (BRANCH_B, BRANCH_BE, BRANCH_AE) + (BRANCH_A, BRANCH_NAN): Defined. + [d6a77d9ac5f6] + + * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h: + * src/vm/jit/emit-common.c [__I386__ || __X86_64__] (emit_bb): New + function. (emit_bbe): Likewise. (emit_bae): Likewise. (emit_ba): + Likewise. [__POWERPC__] (emit_bnan): #ifdef'ed. + * src/vm/jit/emit-common.h: Likewise. + [f7a65ebf9dd9] + +2007-03-12 tbfg + + * src/mm/boehm.c, src/mm/gc-common.h, src/mm/memory.c, + src/mm/memory.h, src/native/jni.h, src/native/native.c, + src/native/native.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/global.h, src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/md.c, src/vm/jit/i386/codegen.c, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/stacktrace.h, src/vm/signal.c, src/vm/signallocal.h, + src/vmcore/class.c, src/vmcore/class.h, src/vmcore/loader.c: + * md.c (md_codegen_get_pv_from_pc): Fixed comment. + (md_get_method_patch_address): Added case for invokespecial and + invokestatic. + + * codegen.c (codegen_emit): Fixed invokespecial/static. + (createcompilerstub): Invoke without linking. + * patcher.c (patcher_invokevirtual): Implemented. + + * asmpart.S (asm_call_jit_compiler): Save correct registers. + [90b6edd36d00] + +2007-03-12 twisti + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h: + * src/vm/jit/codegen.c (codegen): Change the operand direction of + some macros. Started to implement long-compares differently. + + * src/vm/jit/codegen.h (M_AND, M_ORR, M_EOR, M_AND_IMM, M_MOVEQ) + (M_MOVVS_IMM, M_MOVNE_IMM, M_MOVLT_IMM, M_MOVLS_IMM): Changed + operand direction. (M_ORR_S, M_CMPEQ, M_CMPLE): New macro. + [2509f70f8505] + + * src/vm/jit/arm/md.c: + * src/vm/jit/arm/md.c (vm/jit/codegen-common.h): Added. + [d11d179c49bd] + + * src/mm/boehm.c, src/mm/gc-common.h, src/mm/memory.c, + src/mm/memory.h, src/native/jni.h, src/native/native.c, + src/native/native.h, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/global.h, src/vm/jit/i386/codegen.c, src/vm/jit/stacktrace.h, + src/vm/signal.c, src/vm/signallocal.h, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/loader.c: + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c + (vm/vm.h): Added. (open): Call vm_abort. + + * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c + (unistd.h): Added. (readByte): New function. (writeBuf): Likewise. + (available0): Likewise. (close0): Likewise. + [00bc809f0d2a] + +2007-03-12 michi + + * src/mm/cacao-gc/heap.c: + * src/mm/cacao-gc/heap.c: Fixed includes. + [575b62e7001e] + + * src/mm/cacao-gc/gc.c: + * src/mm/cacao-gc/gc.c (gc_suspend): Implemented. (gc_collect): Now + properly suspends threads before collecting. + [2c58bad749e7] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c [ENABLE_GC_CACAO] (replace_gc_from_native): + Added. (replace_me) [ENABLE_GC_CACAO]: Different execution path for + the exact GC. (replace_map_source_state_identity): Added. + [d881dd686fb0] + + * src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Local references + are added. + [6749b3d61efa] + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/mark.c: + * src/mm/cacao-gc/compact.c: Class fields are no longer threaded + directly. + * src/mm/cacao-gc/mark.c: Class fields are no longer marked directly. + [3b706ddc3bfd] + + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/rootset.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/jit/i386/linux/md-os.c: + * src/threads/native/threads.h (threadobject): Struct now contains + es and ss. + * src/threads/native/threads.c (threads_suspend_ack): Informs GC about + suspend. + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): Pass SP + as well. + * src/mm/cacao-gc/gc.h (gc_suspend): Adapted prototype. + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Uses ss of + threadobject. + [132ecadd6b9b] + +2007-03-11 michi + + * src/vm/jit/code.c, src/vm/jit/code.h: + * src/vm/jit/code.c (code_find_codeinfo_for_pc_nocheck): Added. + * src/vm/jit/code.h (code_find_codeinfo_for_pc_nocheck): Added + prototype. + [39fc2c9ba668] + + * configure.ac, src/mm/cacao-gc/heap.c, src/mm/cacao-gc/region.c, + src/mm/cacao-gc/region.h, src/vm/builtin.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/x86_64/asmpart.S: + * src/mm/cacao-gc/region.h (regioninfo_t): Added object header for + locking. + * src/mm/cacao-gc/region.c (region_create): Header mentioned above is + initiated. + * src/mm/cacao-gc/heap.c (heap_alloc_intern): Lock regions while + allocating. + [afd084a060d6] + +2007-03-09 twisti + + * src/cacaoh/headers.c, src/mm/boehm.c, src/mm/gc-common.h, + src/mm/memory.c, src/mm/memory.h, src/native/jni.h, + src/native/native.c, src/native/native.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/Makefile.am, src/vm/builtin.h, src/vm/global.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/arm/patcher.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/patcher.c, src/vm/jit/inline/inline.c, + src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/patcher.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c, + src/vm/jit/stack.c, src/vm/jit/stacktrace.h, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c, + src/vm/jit_interface.h, src/vm/resolve.c, src/vm/resolve.h, + src/vm/signal.c, src/vm/signallocal.h, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.c, + src/vmcore/descriptor.c, src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/statistics.c, + tests/regression/Makefile.am: + * tests/regression/resolving (svn:ignore): Added. + * tests/regression/resolving/classes1: Likewise. + * tests/regression/resolving/classes2: Likewise. + * tests/regression/resolving/classes3: Likewise. + [644c9406eb42] + +2007-03-09 tbfg + + * src/vm/jit/codegen-common.c, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/emit.h, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/emit.c (emit_copy): Implemented. (emit_load): + Implemented. (emit_patcher_stubs): Using bsrl instrad of jsr to + easily spot patchers ind assembler output. + + * src/vm/jit/m68k/md.c (md_dcacheflush): Added. + + * src/vm/jit/m68k/codegen.c (ICMD_*LOAD): Implemented. + (ICMD_PUTSTATIC): Implemented. (ICMD_BUILTIN): Implemented. + + * src/vm/jit/m68k/patcher.c (patcher_wrapper): Correctyl patching + back original code. (patcher_invokestatic_special): Implemented. + (patcher_resolve_classref_to_classinfo): Implemented. + (patcher_get_putstatic): Implemented. + + * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Return to jit + code. + + * src/vm/jit/m68k/codegen.h (M_AMOV_IMM): Fixed. (M_JMP_IMM): Added. + (M_BSR): Added. (OPWORD_COND): Added for M_*MOVE opcodes. (M_*MOVE): + Added. + + * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Show + opt_shownops for m68k enabled. + [e2ec759779d3] + +2007-03-08 michi + + * src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/jit/i386/linux/md-os.c: + Added support for thread suspension! + + * src/threads/native/threads.h (threadobject): Needed fields added. + * src/threads/native/threads.c (threads_stopworld, + threads_startworld): Improved. (threads_suspend_thread, + threads_resume_thread, threads_suspend_ack): Added. + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): Adapted + to changes. + [4c8c428f0906] + + * src/mm/cacao-gc/rootset.c, src/vm/jit/replace.c: + * src/vm/jit/replace.c (replace_me): Loads sfi of current thread. + (replace_recover_source_state): No longer bound to current thread. + + * src/mm/cacao-gc/rootset.c (rootset_from_thread): Loads sfi from + passed thread. + [71ccc40f0313] + + * src/cacaoh/headers.c, src/native/vm/gnu/java_lang_reflect_Field.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/Makefile.am, src/vm/builtin.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/arm/patcher.c, + src/vm/jit/codegen-common.c, src/vm/jit/i386/emit.c, + src/vm/jit/i386/patcher.c, src/vm/jit/inline/inline.c, + src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/patcher.c, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c, + src/vm/jit/stack.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h, + src/vm/resolve.c, src/vm/resolve.h, src/vm/vm.c, + src/vmcore/classcache.c, src/vmcore/descriptor.c, + src/vmcore/linker.c, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h, src/vmcore/statistics.c, + tests/regression/Makefile.am: + * src/threads/native/threads.h: Added THREAD_FLAG_IN_NATIVE and + gc_critical. + * src/threads/native/threads.c: Init and dump the above flags. + + * src/vm/vm.c: Change the THREAD_IN_NATIVE_FLAG accordingly. + * src/vm/jit/codegen-common.c: Same as above. + [32d0b0323e17] + +2007-03-08 tbfg + + * src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/patcher.c: + * src/vm/jit/m68k/linux/md-abi.h (REG_FP): Added. (REG_METHODPTR): + Added. (REG_ITMP12_PACKED): Added. (REG_ITMP23_PACKED): Added. + + * src/vm/jit/m68k/emit.c (emit_jsr): Removed. (emit_jmp): Removed. + (emit_store): Implemented. (emit_patcher_stubs): Implemented. + + + * src/vm/jit/m68k/md.c (md_init): Asserting the offsets generated in + build process. + + * src/vm/jit/m68k/codegen.c (INVOKE_VIRTUAL): Generate method + header. (ICMD_*RETURN): Implemented. + + * src/vm/jit/m68k/patcher.c (patcher_wrapper): Implemented. + (patcher_initialize_class): Implemented. (patcher_invokevirtual): + Implemented. (patcher_resolve_class): Implemented. + + * src/vm/jit/m68k/asmpart.S (asm_patcher_wrapper): Implemented. + + * src/vm/jit/m68k/codegen.h (MCODECHECK): Implemented. + (OPWORD_IMM16): Added. (OPWORD_IMM32): Added. (PATCHER_CALL_SIZE): + Defined. (M_TPF):Added. (M_TPFW): Added. (M_TPFL): Added. (M_JMP): + Added. (M_JSR): Added. (M_JSR_IMM): Added. (M_RET): Added. (M_LINK): + Added. (M_UNLK): Added. (M_PUSH_IMM): Added. (M_ILD): Added. + (M_ALD): Added. (M_IST): Added. (M_AST): Added. (M_INTMOVE): Added. + (M_ADRMOVE): Added. + [083ace5e9428] + +2007-03-08 twisti + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen_emit): Use label-branches. + [f2f8fcaa5e5e] + + * configure.ac, src/cacaoh/dummy.c, src/cacaoh/headers.c, + src/native/jni.c, src/native/native.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Thread.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/vm/Makefile.am, src/vm/builtin.c, + src/vm/builtin.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/patcher.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/replace.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/md-asm.h, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stack.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h, + src/vm/resolve.c, src/vm/resolve.h, src/vm/signal.c, src/vm/vm.c, + src/vmcore/Makefile.am, src/vmcore/class.c, src/vmcore/classcache.c, + src/vmcore/descriptor.c, src/vmcore/linker.c, src/vmcore/loader.c, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/resolve.c, src/vmcore/resolve.h, + src/vmcore/statistics.c, tests/regression/Makefile.am, + tests/regression/resolving/Makefile.am, + tests/regression/resolving/TestController.java, + tests/regression/resolving/TestLoader.java, + tests/regression/resolving/classes1/BarPassFoo.java, + tests/regression/resolving/classes1/BarUseFoo.java, + tests/regression/resolving/classes1/Foo.java, + tests/regression/resolving/classes1/Makefile.am, + tests/regression/resolving/classes2/BarPassFoo.java, + tests/regression/resolving/classes2/BarUseFoo.java, + tests/regression/resolving/classes2/DerivedFoo.java, + tests/regression/resolving/classes2/Foo.java, + tests/regression/resolving/classes2/Makefile.am, + tests/regression/resolving/classes3/BarPassFoo.java, + tests/regression/resolving/classes3/BarUseFoo.java, + tests/regression/resolving/classes3/DerivedFoo.java, + tests/regression/resolving/classes3/Foo.java, + tests/regression/resolving/classes3/Makefile.am, + tests/regression/resolving/test_instance_subtype_violated.java, test + s/regression/resolving/test_param_loading_constraint_violated.java, t + ests/regression/resolving/test_param_loading_constraint_violated_der + ived.java, + tests/regression/resolving/test_param_subtype_violated.java, + tests/regression/resolving/test_return_subtype_ok.java, + tests/regression/resolving/test_return_subtype_violated.java, tests/ + regression/resolving/test_retval_loading_constraint_violated.java, + tests/regression/resolving/test_simple_lazy_load.java: + * Merged with trunk. + [ecc23547cf56] + + * src/vm/jit/alpha/codegen.c: + * src/vm/jit/alpha/codegen.c (codegen_emit): Use label-branches. + [760b24bc4183] + + * src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, src/vm/jit + /emit-common.c, src/vm/jit/emit-common.h: + * src/vm/jit/codegen-common.c (codegen_setup): Create brancheslabel + list. (codegen_reset): Likewise. (codegen_branch_label_add): New + function. + + * src/vm/jit/codegen-common.h (codegendata): Added brancheslabel. + (branch_label_ref_t): New structure. (codegen_branch_label_add): + Added. + + * src/vm/jit/emit-common.c (emit_label_bccz): New function. + (emit_label): Likewise. (emit_label_bcc): Likewise. (emit_label_br): + Likewise. (emit_label_beqz): Likewise. (emit_label_beq): Likewise. + + * src/vm/jit/emit-common.h (BRANCH_LABEL_1, BRANCH_LABEL_2) + (BRANCH_LABEL_3, BRANCH_LABEL_4, BRANCH_LABEL_5): Defined. + (emit_label_bccz): Added. (emit_label): Likewise. (emit_label_bcc): + Likewise. (emit_label_br): Likewise. (emit_label_beqz): Likewise. + (emit_label_beq): Likewise. + [8a343a0e70e3] + +2007-03-08 michi + + * src/cacaoh/dummy.c, src/cacaoh/headers.c, src/mm/cacao-gc/rootset.c, + src/native/jni.c, src/native/native.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Thread.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/threads-common.c, src/vm/Makefile.am, src/vm/builtin.c, + src/vm/builtin.h, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/patcher.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/intrp/patcher.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/replace.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/md-asm.h, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stack.c, src/vm/jit/stacktrace.h, src/vm/jit/verify + /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/patcher.c, + src/vm/jit_interface.h, src/vm/resolve.c, src/vm/resolve.h, + src/vm/signal.c, src/vm/vm.c, src/vmcore/Makefile.am, + src/vmcore/class.c, src/vmcore/descriptor.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h, src/vmcore/resolve.c, + src/vmcore/resolve.h, src/vmcore/statistics.c, + tests/regression/resolving/Makefile.am, + tests/regression/resolving/classes2/BarPassFoo.java, + tests/regression/resolving/test_return_subtype_ok.java, + tests/regression/resolving/test_return_subtype_violated.java: + Merged revisions 7441-7480 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7442 | pm | 2007-03-03 00:28:37 +0100 (Sat, 03 Mar 2007) + | 8 lines + + * src/vm/jit/s390/emit.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/patcher.c, src/vm/jit/s390/asmpart.S: Changed a + lot in S390 codegen. ........ r7444 | edwin | 2007-03-04 13:28:37 + +0100 (Sun, 04 Mar 2007) | 5 lines + + * tests/regression/resolving/test_return_subtype_violated.java: + New test. + + * tests/regression/resolving/Makefile.am: Added new test. ........ + r7445 | edwin | 2007-03-04 13:32:59 +0100 (Sun, 04 Mar 2007) | 4 + lines + + * tests/regression/resolving/test_return_subtype_ok.java: New + test. + + * tests/regression/resolving/Makefile.am: Added new test. ........ + r7446 | edwin | 2007-03-04 15:02:49 +0100 (Sun, 04 Mar 2007) | 2 + lines + + * src/vm/jit/inline/inline.c: Committed breadth-first inlining + code. ........ r7447 | edwin | 2007-03-04 15:22:42 +0100 (Sun, 04 + Mar 2007) | 6 lines + + * src/vmcore/method.h (methodinfo): Added hitcountdown field. + (Only if ENABLE_REPLACEMENT). + + * src/vmcore/loader.c (loader_load_method): Initialize + hitcountdown field. ........ r7448 | edwin | 2007-03-04 15:46:21 + +0100 (Sun, 04 Mar 2007) | 5 lines + + * src/vm/jit/i386/codegen.c (codegen): Emit code for countdown + traps. + + * src/vm/jit/i386/emit.c (emit_replacement_stubs): Add jump + reference for countdown traps. ........ r7449 | twisti | + 2007-03-04 19:07:55 +0100 (Sun, 04 Mar 2007) | 5 lines + + * src/vm/jit/x86_64/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + ........ r7450 | edwin | 2007-03-04 20:13:29 +0100 (Sun, 04 Mar + 2007) | 8 lines + + * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c, + src/vmcore/linker.c: Replayed lost parts of commit 7228. + + * src/vm/jit/intrp/intrp.h: Added missing #include to make it + compile. + + * src/vm/jit/inline/inline.c: Fixed names of vmcore/ #include + files. ........ r7451 | edwin | 2007-03-04 21:10:18 +0100 (Sun, 04 + Mar 2007) | 7 lines + + * src/vm/jit/replace.c: Handle countdown traps. Request + optimization of hot methods and their callers. + + * src/vm/jit/jit.c (jit_compile): Set JITDATA_FLAG_COUNTDOWN for + inlining. (jit_recompile): Set JITDATA_FLAG_INLINE for inlining. + ........ r7453 | pm | 2007-03-05 09:38:29 +0100 (Mon, 05 Mar 2007) + | 8 lines + + * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c: Changed a + lot. ........ r7457 | edwin | 2007-03-05 17:53:45 +0100 (Mon, 05 + Mar 2007) | 3 lines + + * src/vmcore/resolve.h, src/vmcore/resolve.c + (resolve_classref_or_classinfo_eager): New function. ........ + r7458 | edwin | 2007-03-05 18:32:38 +0100 (Mon, 05 Mar 2007) | 2 + lines + + * src/vm/jit/code.c (code_get_methodinfo_from_pv): New function. + ........ r7459 | edwin | 2007-03-05 18:34:43 +0100 (Mon, 05 Mar + 2007) | 4 lines + + * src/vm/builtin.h (builtintable_replace_function): Don't use + instruction * to avoid bootstrapping problems. + * src/vm/builtin.c (builtintable_replace_function): Likewise. ........ + r7460 | edwin | 2007-03-05 18:44:20 +0100 (Mon, 05 Mar 2007) | 5 + lines + + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getSuperclass), + (_Jv_java_lang_Class_getDeclaringClass) + (_Jv_java_lang_Class_getDeclaredClasses): Use + resolve_classref_or_classinfo_eager. ........ r7461 | edwin | + 2007-03-06 00:50:33 +0100 (Tue, 06 Mar 2007) | 3 lines + + * src/native/native.c (native_get_exceptiontypes): Use + resolve_classref_or_classinfo_eager. ........ r7462 | edwin | + 2007-03-06 00:56:41 +0100 (Tue, 06 Mar 2007) | 2 lines + + * src/cacaoh/headers.c: Don't include asmpart.h. ........ r7463 + | edwin | 2007-03-06 01:02:04 +0100 (Tue, 06 Mar 2007) | 3 lines + + * src/vmcore/linker.c (link_class_intern): Use + resolve_classref_or_classinfo_eager. ........ r7464 | edwin | + 2007-03-06 01:26:31 +0100 (Tue, 06 Mar 2007) | 30 lines + + * src/vmcore/resolve.c: Moved back to src/vm/resolve.c. + * src/vmcore/resolve.h: Moved back to src/vm/resolve.h. + * src/vm/jit/code.h (codeinfo): Moved typedef to method.h. + (code_get_methodinfo_for_pv): Added prototype. + * src/vmcore/method.h (codeinfo): Moved typedef here. + + * src/vm/jit_interface.h: New file. + + * src/vm/Makefile.am: Added resolve.[ch] and jit_interface.h. + * src/vmcore/Makefile.am: Removed resolve.[ch]. + + * src/vmcore/class.c: Include "arch.h", but don't include + "resolve.h". + + * src/vmcore/method.c (method_vftbl_lookup): Use + code_get_methodinfo_for_pv. + + * src/vmcore/linker.c (resolve_classref_or_classinfo_eager): Added + copy of prototype to avoid bootstrapping issues. + + * src/cacaoh/dummy.c (code_get_methodinfo_for_pv): New dummy. + (resolve_classref_or_classinfo_eager): Simple implementation that + does not use resolve.c code. (typeinfo_init_class): Removed + dummy. (typeinfo_init_classinfo): Likewise. + (typeinfo_is_assignable_to_class): Likewise. (typeinfo_print): + Likewise. + + * many other files: Changed #include "vmcore/resolve.h" to + "vm/resolve.h". ........ r7465 | edwin | 2007-03-06 01:27:12 +0100 + (Tue, 06 Mar 2007) | 2 lines + + * src/vm/jit_interface.h: Added Id keyword. ........ r7468 | + twisti | 2007-03-06 12:12:03 +0100 (Tue, 06 Mar 2007) | 11 lines + + * src/vmcore/statistics.c (vm/jit/code.h): Added for codeinfo. + (vmcore/class.h): Added. (vmcore/field.h): Likewise. + (vmcore/method.h): Likewise. + + * src/vm/jit/optimizing/recompile.c (vm/jit/code.h): Likewise. + (vm/jit/jit.h): Likewise. + + * src/vm/jit/x86_64/md.c (vm/jit/codegen-common.h): Likewise. + * src/vm/jit/x86_64/md-abi.c (vm/jit/jit.h): Likewise. ........ + r7470 | twisti | 2007-03-06 18:01:19 +0100 (Tue, 06 Mar 2007) | 6 + lines + + * src/vm/vm.c (vm_create): Reenabled signal-thread. This only + works on NPTL-threads and NOT with linuxthreads! + + * src/vm/signal.c (signal_init): Reenabled blocking for SIGINT and + SIGQUIT. ........ r7471 | twisti | 2007-03-06 18:01:49 +0100 (Tue, + 06 Mar 2007) | 2 lines + + * src/vm/signal.c (arch.h): Added. ........ r7472 | ajordan | + 2007-03-06 19:55:12 +0100 (Tue, 06 Mar 2007) | 10 lines + + * src/vm/jit/sparc64/emit.c: emit_{load,store,copy} changed to + switch/case for handling different types. + + * src/vm/jit/sparc64/codegen.h: fixed f2d and d2f conversion. + + * src/vm/jit/sparc64/md-abi.c: removed md_native_reg_setup(), not + needed any longer. + + * src/vm/jit/sparc64/codegen.c: implemented ICMD_MULTIANEWARRAY. + fixed FRETURN, DRETURN. repaired native float arg passing. + ........ r7473 | ajordan | 2007-03-07 01:32:35 +0100 (Wed, 07 Mar + 2007) | 6 lines + + * src/vm/jit/sparc64/md-abi.h: increased number of JIT float + argument registers to 5. + * src/vm/jit/sparc64/md-asm.h: likewise. + * src/vm/jit/sparc64/md-abi.c: likewise. + + * src/vm/jit/sparc64/asmpart.S: added floating point argument + handling in asm_vm_call. ........ r7474 | michi | 2007-03-07 + 12:47:45 +0100 (Wed, 07 Mar 2007) | 9 lines + + * src/threads/native/threads.h (threadobject): This structure is + no longer an instance of java.lang.Thread, but contains a + reference to it. + + * src/threads/native/threads.c (threads_start_javathread): Added. + + * src/threads/threads-common.c: Adapted to above changes. + * src/threads/native/threads.c: See above. + * src/native/vm/java_lang_Thread.c: See above. ........ r7475 | + twisti | 2007-03-07 13:37:34 +0100 (Wed, 07 Mar 2007) | 3 lines + + * src/vm/jit/x86_64/asmpart.S (asm_compare_and_swap): New + function. (asm_memory_barrier): Likewise. ........ r7476 | + twisti | 2007-03-07 14:12:01 +0100 (Wed, 07 Mar 2007) | 2 lines + + * src/vm/jit/x86_64/emit.c (emit_call_reg): Call emit_rex with + size 0. ........ r7477 | twisti | 2007-03-07 15:05:04 +0100 (Wed, + 07 Mar 2007) | 2 lines + + * src/vm/jit/mips/md.c (vm/jit/codegen-common.h): Temporarily + added. ........ r7478 | michi | 2007-03-08 03:59:31 +0100 (Thu, 08 + Mar 2007) | 5 lines + + * src/threads/native/threads.c (threads_init) [!ENABLE_GC_CACAO]: + Fixed bug for lost java.lang.Thread object of mainthread with + BoehmGC. + + * src/native/vm/java_lang_Thread.c: Fixed includes to prevend + compiler warnings. ........ + [d775c359cb66] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/vm/jit/i386/linux + /md-os.c: + * src/vm/jit/i386/linux/md-os.c: Cleaned up. + * src/mm/cacao-gc/gc.h: Fixed includes. + * src/mm/cacao-gc/gc.c (gc_pending): Added global variable. + [c1f89c958f8d] + +2007-03-08 twisti + + * src/mm/boehm.c, src/mm/cacao-gc/compact.c, src/mm/gc-common.h, + src/mm/memory.c, src/mm/memory.h, src/native/jni.h, + src/native/native.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/java_lang_ClassLoader.c, src/toolbox/list.c, + src/toolbox/list.h, src/vm/global.h, src/vm/jit/stacktrace.h, + src/vm/signallocal.h, src/vmcore/class.h, src/vmcore/classcache.h, + src/vmcore/loader.h, src/vmcore/rt-timing.c, src/vmcore/rt-timing.h: + * src/toolbox/list.c (list_remove): Call list_remove_unsynced. + (list_remove_unsynced): New function. + + * src/toolbox/list.h (list_remove_unsynced): Added. + [b65a6efba3aa] + +2007-03-08 michi + + * configure.ac, src/cacaoh/headers.c, src/mm/cacao-gc/gc.h, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/vm/Makefile.am, src/vm/builtin.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/codegen-common.c, + src/vm/jit/i386/emit.c, src/vm/jit/i386/linux/md-os.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/intrp/patcher.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/stack.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/x86_64/md.c, src/vm/signal.c, src/vm/signallocal.h, + src/vmcore/classcache.c, src/vmcore/descriptor.c, + src/vmcore/options.c, src/vmcore/options.h, src/vmcore/statistics.c, + tests/regression/Makefile.am: + * src/mm/cacao-gc/gc.h (gc_suspend): Added prototype. + + * src/vm/signale.c (signale_init) [ENABLE_GC_CACAO]: Handler for + SIGUSR1. + * src/vm/signallocal.h: Added prototype for SIGUSR1 handler. + + * src/vm/jit/i386/linux/md-os.c (md_signal_handler_sigusr1): Added. + [186d485732de] + +2007-03-08 twisti + + * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/vm/jit/alpha/arch.h, + src/vm/jit/alpha/codegen.h, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/emit-common.c, src/vm/jit/emit-common.h, src/vm/signal.c: + * src/vm/jit/alpha/codegen.h (M_INSTR_MEM_A): Renamed to + M_MEM_GET_A. (M_INSTR_MEM_B): Renamed to M_MEM_GET_B. + (M_INSTR_MEM_DISP): Renamed to M_MEM_GET_DISP. + + * src/vm/jit/alpha/linux/md-os.c (md_signal_handler_sigsegv): + Likewise. + + * src/vm/jit/alpha/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER): Defined. + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER): Likewise. + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Likewise. + + * src/vm/jit/emit-common.c (arch.h): Added. + * src/vm/jit/emit-common.h (arch.h): Likewise. + [872d8003e23f] + +2007-03-08 michi + + * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c: + * src/threads/native/threads.c (threads_init) [!ENABLE_GC_CACAO]: + Fixed bug for lost java.lang.Thread object of mainthread with + BoehmGC. + + * src/native/vm/java_lang_Thread.c: Fixed includes to prevend + compiler warnings. + [41366642f3af] + +2007-03-07 twisti + + * src/vm/jit/mips/md.c: + * src/vm/jit/mips/md.c (vm/jit/codegen-common.h): Temporarily added. + [58f73c63ef03] + + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_call_reg): Call emit_rex with size + 0. + [f1b6321c7bea] + + * src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/x86_64/asmpart.S (asm_compare_and_swap): New function. + (asm_memory_barrier): Likewise. + [eab404e7f39b] + +2007-03-07 michi + + * src/native/vm/java_lang_Thread.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/threads-common.c: + * src/threads/native/threads.h (threadobject): This structure is no + longer an instance of java.lang.Thread, but contains a reference to + it. + + * src/threads/native/threads.c (threads_start_javathread): Added. + + * src/threads/threads-common.c: Adapted to above changes. + * src/threads/native/threads.c: See above. + * src/native/vm/java_lang_Thread.c: See above. + [e0154f388f07] + +2007-03-07 ajordan + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md-asm.h: + * src/vm/jit/sparc64/md-abi.h: increased number of JIT float + argument registers to 5. + * src/vm/jit/sparc64/md-asm.h: likewise. + * src/vm/jit/sparc64/md-abi.c: likewise. + + * src/vm/jit/sparc64/asmpart.S: added floating point argument + handling in asm_vm_call. + [2ead47c5f866] + +2007-03-06 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.c: + * src/vm/jit/sparc64/emit.c: emit_{load,store,copy} changed to + switch/case for handling different types. + + * src/vm/jit/sparc64/codegen.h: fixed f2d and d2f conversion. + + * src/vm/jit/sparc64/md-abi.c: removed md_native_reg_setup(), not + needed any longer. + + * src/vm/jit/sparc64/codegen.c: implemented ICMD_MULTIANEWARRAY. + fixed FRETURN, DRETURN. repaired native float arg passing. + [9980961f1055] + +2007-03-06 twisti + + * src/vm/signal.c: + * src/vm/signal.c (arch.h): Added. + [3d116d2fe39a] + + * src/vm/signal.c, src/vm/vm.c: + * src/vm/vm.c (vm_create): Reenabled signal-thread. This only works + on NPTL-threads and NOT with linuxthreads! + + * src/vm/signal.c (signal_init): Reenabled blocking for SIGINT and + SIGQUIT. + [be5ff32af719] + +2007-03-06 tbfg + + * src/cacaoh/headers.c, src/native/native.c, + src/native/vm/gnu/java_lang_reflect_Field.c, src/vm/Makefile.am, + src/vm/jit/allocator/simplereg.c, src/vm/jit/intrp/patcher.c, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/md.c, src/vm/jit/stack.c, src/vm/jit/verify + /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/x86_64/md.c, src/vmcore/Makefile.am, src/vmcore/class.c, + src/vmcore/descriptor.c, src/vmcore/statistics.c: + * src/vm/jit/m68k/md.c (md_get_method_patch_address): Implemented. + + * src/vm/jit/m68k/asmpart.S (call_jit_dummy): Dummy memory slot to + fake jit like invocation of asm_call_jit_compiler. + + (asm_vm_call_method): Invoke jit compiler like from jitted code. + (asm_call_jit_compiler): Invoke compiled method. + [5cd56b546f0e] + +2007-03-06 twisti + + * src/vm/jit/optimizing/recompile.c, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/x86_64/md.c, src/vmcore/statistics.c: + * src/vmcore/statistics.c (vm/jit/code.h): Added for codeinfo. + (vmcore/class.h): Added. (vmcore/field.h): Likewise. + (vmcore/method.h): Likewise. + + * src/vm/jit/optimizing/recompile.c (vm/jit/code.h): Likewise. + (vm/jit/jit.h): Likewise. + + * src/vm/jit/x86_64/md.c (vm/jit/codegen-common.h): Likewise. + * src/vm/jit/x86_64/md-abi.c (vm/jit/jit.h): Likewise. + [846bb32a87d2] + +2007-03-06 michi + + * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/copy.c, src/mm/cacao- + gc/copy.h, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.c: + * src/mm/cacao-gc/copy.c: Added file. + * src/mm/cacao-gc/copy.h: Added file. + * src/mm/cacao-gc/Makefile.am: See above. + + * src/mm/cacao-gc/heap.c: Moved copy specific stuff to own file. + + * src/mm/cacao-gc/gc.c: Now tests copy collections. + [57611210cc37] + + * configure.ac, src/mm/cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h, + src/vm/builtin.h, src/vm/jit/codegen-common.c, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/emit.c, + src/vm/jit/x86_64/emit.c, src/vmcore/classcache.c, + tests/regression/Makefile.am: + Static class references are now explicitly added to the rootset. + + * src/mm/cacao-gc/rootset.c (rootset_from_classes): Added. + * src/mm/cacao-gc/rootset.h (REFTYPE_CLASSREF): Added. + [2eb5b5cfca2f] + +2007-03-06 edwin + + * src/vm/jit_interface.h: + * src/vm/jit_interface.h: Added Id keyword. + [920caf1ce50d] + + * src/cacaoh/dummy.c, src/native/jni.c, src/native/native.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/java_lang_Class.c, src/vm/Makefile.am, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/patcher.c, src/vm/jit/code.h, + src/vm/jit/i386/patcher.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/intrp/patcher.c, src/vm/jit/jit.h, + src/vm/jit/mips/patcher.c, src/vm/jit/parse.c, + src/vm/jit/powerpc/patcher.c, src/vm/jit/powerpc64/patcher.c, + src/vm/jit/s390/patcher.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stack.c, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/patcher.c, src/vm/jit_interface.h, + src/vm/resolve.c, src/vm/resolve.h, src/vmcore/Makefile.am, + src/vmcore/class.c, src/vmcore/descriptor.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/resolve.c, src/vmcore/resolve.h: + * src/vmcore/resolve.c: Moved back to src/vm/resolve.c. + * src/vmcore/resolve.h: Moved back to src/vm/resolve.h. + * src/vm/jit/code.h (codeinfo): Moved typedef to method.h. + (code_get_methodinfo_for_pv): Added prototype. + * src/vmcore/method.h (codeinfo): Moved typedef here. + + * src/vm/jit_interface.h: New file. + + * src/vm/Makefile.am: Added resolve.[ch] and jit_interface.h. + * src/vmcore/Makefile.am: Removed resolve.[ch]. + + * src/vmcore/class.c: Include "arch.h", but don't include + "resolve.h". + + * src/vmcore/method.c (method_vftbl_lookup): Use + code_get_methodinfo_for_pv. + + * src/vmcore/linker.c (resolve_classref_or_classinfo_eager): Added + copy of prototype to avoid bootstrapping issues. + + * src/cacaoh/dummy.c (code_get_methodinfo_for_pv): New dummy. + (resolve_classref_or_classinfo_eager): Simple implementation that + does not use resolve.c code. (typeinfo_init_class): Removed dummy. + (typeinfo_init_classinfo): Likewise. + (typeinfo_is_assignable_to_class): Likewise. (typeinfo_print): + Likewise. + + * many other files: Changed #include "vmcore/resolve.h" to + "vm/resolve.h". + [a6ae28360f65] + + * src/vmcore/linker.c: + * src/vmcore/linker.c (link_class_intern): Use + resolve_classref_or_classinfo_eager. + [8b56688900be] + +2007-03-05 edwin + + * src/cacaoh/headers.c: + * src/cacaoh/headers.c: Don't include asmpart.h. + [899764f7a0ce] + + * src/native/native.c: + * src/native/native.c (native_get_exceptiontypes): Use + resolve_classref_or_classinfo_eager. + [f5aff9934af5] + + * src/native/vm/java_lang_Class.c: + * src/native/vm/java_lang_Class.c + (_Jv_java_lang_Class_getSuperclass), + (_Jv_java_lang_Class_getDeclaringClass) + (_Jv_java_lang_Class_getDeclaredClasses): Use + resolve_classref_or_classinfo_eager. + [1390ab8b3bd2] + + * src/vm/builtin.c, src/vm/builtin.h: + * src/vm/builtin.h (builtintable_replace_function): Don't use + instruction * to avoid bootstrapping problems. + * src/vm/builtin.c (builtintable_replace_function): Likewise. + [19a54ed5e016] + + * src/vm/jit/code.c: + * src/vm/jit/code.c (code_get_methodinfo_from_pv): New function. + [e6e6f9540e1e] + + * src/vm/jit/i386/asmpart.S, src/vmcore/resolve.c, + src/vmcore/resolve.h: + * src/vmcore/resolve.h, src/vmcore/resolve.c + (resolve_classref_or_classinfo_eager): New function. + [3ead6ad73d97] + +2007-03-05 tbfg + + * src/vm/jit/abi.h, src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/m68k/linux/md-abi.h, + src/vm/jit/m68k/md.c, src/vm/jit/reg.c, src/vmcore/descriptor.h: + * src/vm/jit/abi.h (HAS_ADDRESS_REGISTER_FILE): Include arch.h + (nregdescadr): Declare extern when HAS_ADDRESS_REGISTER_FILE. + + * src/vm/jit/m68k/linux/md-abi.h (REF_FP): Added. + + * src/vm/jit/m69k/linux/md-abi.c (nregdescadr): Fixed typo. + (md_param_alloc): Implemented. + + * src/vm/jit/m68k/md.c (md_codegen_get_pv_from_pc): Implemented. + (md_stacktrace_get_returnaddress): Implemented. + + * src/vm/jit/m68k/arch.h (HAS_ADDRESS_REGISTER_FILE): Defined. + + * src/vm/jit/m68k/asmpart.S (asm_vm_call_method_end): Added. + (asm_call_jit_compiler): Implemented. + + * src/vm/jit/reg.c (reg_setup): rd->adrreg_argnum is missing. + + * src/vmcore/descriptor.h (arch.h): Included as needed for + HAS_ADDRESS_REGISTER_FILE. + [629a0a1b6da3] + + * src/vm/jit/mips/asmpart.S, src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/mips/asmpart.S (asm_vm_call_method_end): Added. + * src/vm/jit/x86_64/asmpart.S (asm_vm_call_method_end): Added. + [781fb227cc5e] + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/arm/asmpart.S, + src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, + src/vm/jit/i386/asmpart.S, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h, + src/vm/jit/sparc64/asmpart.S: + * asmpart.h (asm_vm_call_method_end): Dummy method to readable mark + end of the asm_vm_call_method which is needed to insert it into avl + tree. + + * codegen-common.c (codegen_init): Use asm_vm_call_method_end. + + * arm/asmpart.S (asm_vm_call_method_end): Added. + * powerpc/asmpart.S (asm_vm_call_method_end): Added. + * sparc64/asmpart.S (asm_vm_call_method_end): Added. + * alpha/asmpart.S (asm_vm_call_method_end): Added. + * s390/asmpart.S (asm_vm_call_method_end): Added. + * powerpc64/asmpart.S (asm_vm_call_method_end): Added. + * i386/asmpart.S (asm_vm_call_method_end): Added. + [aa13999923b1] + +2007-03-05 pm + + * configure.ac, src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, + src/vm/jit/codegen-common.c, src/vm/jit/i386/patcher.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/patcher.c, + src/vmcore/classcache.c, src/vmcore/resolve.c, src/vmcore/resolve.h, + tests/regression/Makefile.am: + * src/vm/jit/s390/md-abi.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/emit.h, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c: Changed a lot. + [cb92a55875c8] + +2007-03-04 twisti + + * src/mm/boehm.c, src/native/vm/gnu/java_lang_reflect_Method.c, + src/vm/access.c, src/vm/access.h, src/vm/jit/i386/codegen.c, + src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/powerpc64/arch.h, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/md-asm.h, src/vm/jit/stack.c, + src/vm/jit/verify/typecheck.c, src/vmcore/linker.c, + src/vmcore/loader.c, src/vmcore/method.c, src/vmcore/method.h, + src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/powerpc64/linux/md-abi.c (regs): Renamed to + abi_registers_integer_name. (md_param_alloc_native): New function. + + * src/vm/jit/powerpc64/emit.c (emit_verbosecall_enter): Replaced + builtin_trace_args with builtin_verbosecall_enter. + (emit_verbosecall_exit): Replaced builtin_displaymethodstop with + builtin_verbosecall_exit + + * src/vm/jit/powerpc64/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER): Defined. + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER): Likewise. + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Likewise. + [8b515435fe56] + +2007-03-04 edwin + + * src/vm/jit/jit.c, src/vm/jit/replace.c: + * src/vm/jit/replace.c: Handle countdown traps. Request optimization + of hot methods and their callers. + + * src/vm/jit/jit.c (jit_compile): Set JITDATA_FLAG_COUNTDOWN for + inlining. (jit_recompile): Set JITDATA_FLAG_INLINE for inlining. + [25d019f7504b] + + * src/vm/jit/inline/inline.c, src/vm/jit/intrp/intrp.h, + src/vmcore/linker.c, src/vmcore/method.c, src/vmcore/options.c, + src/vmcore/options.h: + * src/vmcore/options.h, src/vmcore/options.c, src/vmcore/method.c, + src/vmcore/linker.c: Replayed lost parts of commit 7228. + + * src/vm/jit/intrp/intrp.h: Added missing #include to make it + compile. + + * src/vm/jit/inline/inline.c: Fixed names of vmcore/ #include files. + [b12f334a12da] + +2007-03-04 twisti + + * src/vm/jit/x86_64/emit.c: + * src/vm/jit/x86_64/emit.c (emit_load): Use switch-case instead of + if-else contruct. (emit_store): Likewise. (emit_copy): Likewise. + [262f592df737] + +2007-03-04 edwin + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c: + * src/vm/jit/i386/codegen.c (codegen): Emit code for countdown + traps. + + * src/vm/jit/i386/emit.c (emit_replacement_stubs): Add jump + reference for countdown traps. + [5fd5b2811199] + + * src/vmcore/loader.c, src/vmcore/method.h: + * src/vmcore/method.h (methodinfo): Added hitcountdown field. (Only + if ENABLE_REPLACEMENT). + + * src/vmcore/loader.c (loader_load_method): Initialize hitcountdown + field. + [efeadd853ac8] + + * src/vm/jit/inline/inline.c: + * src/vm/jit/inline/inline.c: Committed breadth-first inlining code. + [38ec32d5f074] + + * tests/regression/resolving/Makefile.am, + tests/regression/resolving/test_return_subtype_ok.java: + * tests/regression/resolving/test_return_subtype_ok.java: New test. + + * tests/regression/resolving/Makefile.am: Added new test. + [7644200c297b] + + * src/mm/boehm.c, tests/regression/resolving/Makefile.am, + tests/regression/resolving/classes2/BarPassFoo.java, + tests/regression/resolving/test_return_subtype_violated.java: + * tests/regression/resolving/test_return_subtype_violated.java: New + test. + + * tests/regression/resolving/Makefile.am: Added new test. + [498b290fa85e] + +2007-03-03 michi + + * src/mm/boehm.c, src/mm/cacao-gc/heap.c, src/vm/jit/s390/emit.c, + src/vmcore/rt-timing.c, src/vmcore/rt-timing.h: + * src/vmcore/rt-timing.c: Added rt-timing for heap allocation time. + * src/vmcore/rt-timing.h: See above. + + * src/mm/boehm.c (heap_allocate): Heap allocation time is measured. + + * src/mm/cacao-gc/heap.c (heap_allocate): Heap allocation time is + measured. + [01335840ae08] + +2007-03-02 pm + + * configure.ac, src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c, + src/vm/access.h, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/patcher.c, src/vm/jit/stack.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/x86_64/patcher.c, + src/vmcore/classcache.c, src/vmcore/resolve.c, src/vmcore/resolve.h, + tests/regression/Makefile.am: + * src/vm/jit/s390/emit.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/patcher.c, src/vm/jit/s390/asmpart.S: Changed a lot + in S390 codegen. + [b5859fd89dd5] + +2007-03-02 michi + + * configure.ac, src/cacaoh/dummy.c, src/native/jni.c, + src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_ClassLoader.h, src/vm/access.c, + src/vm/access.h, src/vm/jit/alpha/patcher.c, + src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/sparc64/solaris/md-os.c, src/vm/jit/stack.c, + src/vm/jit/stacktrace.h, src/vm/jit/verify/typecheck.c, + src/vm/jit/x86_64/patcher.c, src/vm/vm.c, src/vmcore/classcache.c, + src/vmcore/resolve.c, src/vmcore/resolve.h, + tests/regression/Makefile.am, tests/regression/jasmin/Makefile.am, t + ests/regression/jasmin/test_verify_ok_local_as_retaddr_and_reference + .j, tests/regression/resolving/Makefile.am, + tests/regression/resolving/TestController.java, + tests/regression/resolving/TestLoader.java, + tests/regression/resolving/classes1/BarPassFoo.java, + tests/regression/resolving/classes1/BarUseFoo.java, + tests/regression/resolving/classes1/Foo.java, + tests/regression/resolving/classes1/Makefile.am, + tests/regression/resolving/classes2/BarPassFoo.java, + tests/regression/resolving/classes2/BarUseFoo.java, + tests/regression/resolving/classes2/DerivedFoo.java, + tests/regression/resolving/classes2/Foo.java, + tests/regression/resolving/classes2/Makefile.am, + tests/regression/resolving/classes3/BarPassFoo.java, + tests/regression/resolving/classes3/BarUseFoo.java, + tests/regression/resolving/classes3/DerivedFoo.java, + tests/regression/resolving/classes3/Foo.java, + tests/regression/resolving/classes3/Makefile.am, + tests/regression/resolving/test_instance_subtype_violated.java, test + s/regression/resolving/test_param_loading_constraint_violated.java, t + ests/regression/resolving/test_param_loading_constraint_violated_der + ived.java, + tests/regression/resolving/test_param_subtype_violated.java, tests/r + egression/resolving/test_retval_loading_constraint_violated.java, + tests/regression/resolving/test_simple_lazy_load.java: + Merged revisions 7407-7440 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7408 | twisti | 2007-02-26 23:11:38 +0100 (Mon, 26 Feb + 2007) | 15 lines + + * src/native/vm/java_lang_ClassLoader.c: New file. + * src/native/vm/java_lang_ClassLoader.h: Likewise. + + * src/native/vm/gnu/java_lang_VMClassLoader.c + (native/vm/java_lang_ClassLoader.h): Added. (defineClass): Removed + code and call _Jv_java_lang_ClassLoader_defineClass. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + java_lang_ClassLoader.[ch]. + + * src/native/jni.c [ENABLE_JAVASE] + (native/vm/java_lang_ClassLoader.h): Added. (_Jv_JNI_DefineClass): + Removed env and NULL arguments. ........ r7409 | ajordan | + 2007-02-27 03:07:00 +0100 (Tue, 27 Feb 2007) | 8 lines + + * configure.ac: added solaris specific stuff: arch defines, + libintl dependency and solaris subdir makefile. + + * src/vm/jit/stacktrace.h: declared SPARC specific functions. + + * src/vm/jit/sparc64/emit.c: fixed call to + builtin_verbosecall_exit. + + * src/vm/jit/sparc64/solaris/md-os.c: signal handling disabled, + can't test right now. ........ r7412 | twisti | 2007-02-27 + 22:13:26 +0100 (Tue, 27 Feb 2007) | 2 lines + + * src/vm/jit/sparc64/solaris: Set ignore-properties. ........ + r7414 | pm | 2007-02-28 08:22:04 +0100 (Wed, 28 Feb 2007) | 5 lines + + * src/vm/jit/s390/codegen.c (codegen): Added ICMD_AASTORE. + * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Added exception + handler. + * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Likewise. + ........ r7415 | twisti | 2007-02-28 14:23:54 +0100 (Wed, 28 Feb + 2007) | 3 lines + + * src/native/vm/java_lang_ClassLoader.c (defineClass): Added + loader-variable for convenience. ........ r7416 | twisti | + 2007-02-28 14:25:56 +0100 (Wed, 28 Feb 2007) | 2 lines + + * src/native/vm/java_lang_ClassLoader.c (vm/stringlocal.h): Added. + ........ r7418 | twisti | 2007-02-28 21:07:06 +0100 (Wed, 28 Feb + 2007) | 13 lines + + * src/vm/access.c (access_check_caller): Renamed to + access_check_member. Don't call access_is_accessible_class, this is + wrong. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Use access_check_member. + + * src/native/vm/gnu/java_lang_reflect_Field.c (CHECKFIELDACCESS): + Removed. (cacao_get_field_address): Use access_check_member. + + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): + Likewise. ........ r7419 | twisti | 2007-02-28 23:00:50 +0100 + (Wed, 28 Feb 2007) | 3 lines + + * src/vm/access.h (access_check_caller): Renamed to + access_check_member. ........ r7420 | edwin | 2007-02-28 23:30:31 + +0100 (Wed, 28 Feb 2007) | 3 lines + + * src/vm/jit/stack.c (stack_analyse): Fix: reset TYPE_VOID to + TYPE_ADR at the end of stack_analyse. ........ r7421 | twisti | + 2007-02-28 23:31:50 +0100 (Wed, 28 Feb 2007) | 4 lines + + * src/vm/vm.c (vm_create): Changed initialization order. Call + properties_postinit later, since it puts a pointer to + _Jv_bootclasspath into the properties list. ........ r7422 | edwin + | 2007-02-28 23:50:28 +0100 (Wed, 28 Feb 2007) | 4 lines + + * tests/regression/jasmin/test_verify_ok_local_as_retaddr_and_refe + rence.j: New test. + * tests/regression/jasmin/Makefile.am: Added new test. ........ + r7423 | edwin | 2007-03-01 00:20:58 +0100 (Thu, 01 Mar 2007) | 2 + lines + + * src/vm/jit/stack.c (stack_analyse): Minor STACK_VERBOSE + improvements. ........ r7424 | edwin | 2007-03-01 00:27:15 +0100 + (Thu, 01 Mar 2007) | 3 lines + + * src/vm/jit/verify/typecheck.c (handle_basic_block): Move the + printing of the block to a point where jd->var is already valid. + ........ r7425 | twisti | 2007-03-01 00:39:48 +0100 (Thu, 01 Mar + 2007) | 2 lines + + * src/cacaoh/dummy.c (typeinfo_print): Added. ........ r7426 | + twisti | 2007-03-01 00:57:39 +0100 (Thu, 01 Mar 2007) | 5 lines + + * src/vmcore/classcache.c (toolbox/logging.h): Added. + (classcache_merge_class_entries): Replace log_text with log_println. + (classcache_store): Likewise. (classcache_store_defined): + Likewise. ........ r7427 | edwin | 2007-03-01 13:32:10 +0100 (Thu, + 01 Mar 2007) | 3 lines + + * src/vmcore/resolve.c (resolve_classref_or_classinfo): Always use + refmethod->class as the referring class, if it is available. + ........ r7428 | twisti | 2007-03-01 13:39:45 +0100 (Thu, 01 Mar + 2007) | 6 lines + + * src/native/vm/Makefile.am [ENABLE_JAVASE] (CLASSLOADER_SOURCES): + Added. (libnativevm_la_SOURCES): Use CLASSLOADER_SOURCES. + + * src/native/vm/java_lang_ClassLoader.c (native/jni.h): Added. + ........ r7431 | edwin | 2007-03-01 14:49:14 +0100 (Thu, 01 Mar + 2007) | 14 lines + + * src/vmcore/resolve.h, src/vmcore/resolve.c + (resolve_class_eager_no_access_check): New function. + + * src/vm/jit/powerpc/patcher.c: Use + resolve_class_eager_no_access_check. + * src/vm/jit/arm/patcher.c: Likewise. + * src/vm/jit/sparc64/patcher.c: Likewise. + * src/vm/jit/alpha/patcher.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + * src/vm/jit/mips/patcher.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/x86_64/patcher.c: Likewise. ........ r7433 | edwin | + 2007-03-02 20:42:13 +0100 (Fri, 02 Mar 2007) | 3 lines + + * tests/regression/resolving: Added resolving test suite. These + tests check lazy loading, classloader handling, loading & subtype + constraints. ........ r7434 | edwin | 2007-03-02 20:44:53 +0100 + (Fri, 02 Mar 2007) | 2 lines + + * configure.ac: Added Makefiles of resolving test suite. ........ + r7435 | edwin | 2007-03-02 20:45:42 +0100 (Fri, 02 Mar 2007) | 2 + lines + + * src/vmcore/classcache.c: Print debug messages to stdout. + ........ + [16cce40a0a12] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/heap.h, src/vmcore/rt- + timing.c, src/vmcore/rt-timing.h: + * src/vmcore/rt-timing.h: Added gc rt-timing defines. + * src/vmcore/rt-timing.c [ENABLE_GC_CACAO]: Added gc rt-timing + entries. + * src/mm/cacao-gc/gc.c: Added realtime-timing. + + * src/mm/cacao-gc/heap.h: Removed unused global variables. + [3f7144c5e402] + + * src/native/jni.c, src/native/jni.h: + * src/native/jni.h (hashtable_global_ref): Added. + * src/native/jni.c (hashtable_global_ref): Made non-static for the + exact gc. + [369806a4aae8] + + * src/mm/cacao-gc/rootset.c: + * src/mm/cacao-gc/rootset.c [!ENABLE_THREADS]: Now compiles again. + [d942f1db75bc] + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.h, src/mm/cacao- + gc/heap.c, src/mm/cacao-gc/mark.c, src/vm/global.h, + src/vm/jit/arm/patcher.c, src/vm/jit/i386/patcher.c, + src/vm/jit/s390/patcher.c, src/vm/jit/x86_64/patcher.c, + tests/regression/Makefile.am: + * src/vm/global.h (HDRFLAG_REFERENCING): Added. + + * src/mm/cacao-gc/heap.c: Sets above header flag now. + * src/mm/cacao-gc/compact.c: Check for above header flag now. + * src/mm/cacao-gc/mark.c: See above. + + * src/mm/cacao-gc/gc.h: Added configuration define for the above + behavior. + [080b239a5aaa] + +2007-03-02 tbfg + + * configure.ac, src/vm/jit/arm/patcher.c, src/vm/jit/disass-common.c, + src/vm/jit/disass.h, src/vm/jit/i386/patcher.c, + src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/disass.c, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/emit.h, + src/vm/jit/m68k/linux/md-abi.c, src/vm/jit/s390/patcher.c, + src/vm/jit/x86_64/patcher.c, src/vmcore/classcache.c, + src/vmcore/resolve.c, src/vmcore/resolve.h, + tests/regression/Makefile.am: + * src/vm/jit/disass-common.c(disass_buf): Enabled for m68k. + + * src/vm/jit/disass.h(disass_buf): Likewise. + + * src/vm/jit/m68k/linux/md-abi.c(nregdescaddr): Added. + + * src/vm/jit/m68k/emit.c(emit_jsr): Added. (emit_jmp): Added. + (emit_store): Added. (emit_load): Added. (emit_load_low): Added. + (emit_load_high): Added. (emit_branch): Added. + (emit_verbosecall_enter): Added. (emit_verbosecall_exit): Added. + + * src/vm/jit/m68k/emit.h: Like emit.c + + * src/vm/jit/m68k/codegen.c(codegen_emit): Some dummy code added. + (createnativestub): Likewise. + + * src/vm/jit/m68k/disass.c(disassinstr): Implemented and tested. + + * src/vm/jit/m68k/asmpart.S(asm_vm_call_method): Implemented + argument passing. + + * src/vm/jit/m68k/codegen.h(M_ILLEGAL): Added. (M_PUSH): Likewise. + (M_APUSH): Likewise. (M_POP): Likewise. (M_APOP): Likewise. (M_JMP): + Likewise. (M_JSR): Likewise. + + * configure.ac (ENABLE_DISASSEMBLER): Enabled for m68k. + [bac4f948b59c] + +2007-03-02 edwin + + * src/vmcore/classcache.c: + * src/vmcore/classcache.c: Print debug messages to stdout. + [ba6016da118e] + + * configure.ac: + * configure.ac: Added Makefiles of resolving test suite. + [4313663128f6] + + * tests/regression/Makefile.am, + tests/regression/resolving/Makefile.am, + tests/regression/resolving/TestController.java, + tests/regression/resolving/TestLoader.java, + tests/regression/resolving/classes1/BarPassFoo.java, + tests/regression/resolving/classes1/BarUseFoo.java, + tests/regression/resolving/classes1/Foo.java, + tests/regression/resolving/classes1/Makefile.am, + tests/regression/resolving/classes2/BarPassFoo.java, + tests/regression/resolving/classes2/BarUseFoo.java, + tests/regression/resolving/classes2/DerivedFoo.java, + tests/regression/resolving/classes2/Foo.java, + tests/regression/resolving/classes2/Makefile.am, + tests/regression/resolving/classes3/BarPassFoo.java, + tests/regression/resolving/classes3/BarUseFoo.java, + tests/regression/resolving/classes3/DerivedFoo.java, + tests/regression/resolving/classes3/Foo.java, + tests/regression/resolving/classes3/Makefile.am, + tests/regression/resolving/test_instance_subtype_violated.java, test + s/regression/resolving/test_param_loading_constraint_violated.java, t + ests/regression/resolving/test_param_loading_constraint_violated_der + ived.java, + tests/regression/resolving/test_param_subtype_violated.java, tests/r + egression/resolving/test_retval_loading_constraint_violated.java, + tests/regression/resolving/test_simple_lazy_load.java: + * tests/regression/resolving: Added resolving test suite. These + tests check lazy loading, classloader handling, loading & subtype + constraints. + [cdc72aade335] + +2007-03-02 michi + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/rootset.c, src/mm/cacao- + gc/rootset.h: + * src/mm/cacao-gc/gc.c (gc_collect): Moved rootset creation to + rootset_readout. + * src/mm/cacao-gc/rootset.c (rootset_readout): Added + + * src/mm/cacao-gc/rootset.c (rootset_from_globals): Now adds + threadobjects and global references. + + * src/mm/cacao-gc/rootset.h: Added refs_type field to rootset. + [ad0c808325c4] + +2007-03-01 edwin + + * src/vm/jit/alpha/patcher.c, src/vm/jit/arm/patcher.c, src/vm/jit + /codegen-common.c, src/vm/jit/i386/patcher.c, + src/vm/jit/mips/patcher.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/patcher.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/x86_64/patcher.c, + src/vmcore/resolve.c, src/vmcore/resolve.h: + * src/vmcore/resolve.h, src/vmcore/resolve.c + (resolve_class_eager_no_access_check): New function. + + * src/vm/jit/powerpc/patcher.c: Use + resolve_class_eager_no_access_check. + * src/vm/jit/arm/patcher.c: Likewise. + * src/vm/jit/sparc64/patcher.c: Likewise. + * src/vm/jit/alpha/patcher.c: Likewise. + * src/vm/jit/s390/patcher.c: Likewise. + * src/vm/jit/mips/patcher.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/x86_64/patcher.c: Likewise. + [188ce45e94a5] + +2007-03-01 michi + + * src/mm/cacao-gc/mark.c, src/vm/jit/codegen-common.c: + * src/mm/cacao-gc/mark.c (mark_me): Fixed a bug for "outside + pointers". + [00cb4e70477b] + +2007-03-01 twisti + + * src/cacaoh/dummy.c, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c, + src/vm/access.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/stack.c, + src/vm/jit/verify/typecheck.c, src/vm/vm.c, + tests/regression/jasmin/Makefile.am: + * Merged with trunk. + [39040c757ae6] + + * src/native/vm/Makefile.am, src/native/vm/java_lang_ClassLoader.c: + * src/native/vm/Makefile.am [ENABLE_JAVASE] (CLASSLOADER_SOURCES): + Added. (libnativevm_la_SOURCES): Use CLASSLOADER_SOURCES. + + * src/native/vm/java_lang_ClassLoader.c (native/jni.h): Added. + [020ca26f54f1] + +2007-03-01 edwin + + * src/vmcore/resolve.c: + * src/vmcore/resolve.c (resolve_classref_or_classinfo): Always use + refmethod->class as the referring class, if it is available. + [a671bb862433] + +2007-02-28 twisti + + * src/vmcore/classcache.c: + * src/vmcore/classcache.c (toolbox/logging.h): Added. + (classcache_merge_class_entries): Replace log_text with log_println. + (classcache_store): Likewise. (classcache_store_defined): Likewise. + [5c13c1877eaf] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (typeinfo_print): Added. + [269225303ad5] + +2007-02-28 edwin + + * src/vm/jit/verify/typecheck.c: + * src/vm/jit/verify/typecheck.c (handle_basic_block): Move the + printing of the block to a point where jd->var is already valid. + [23c03d745eca] + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): Minor STACK_VERBOSE + improvements. + [1c941917218d] + + * tests/regression/jasmin/Makefile.am, tests/regression/jasmin/test_ve + rify_ok_local_as_retaddr_and_reference.j: + * tests/regression/jasmin/test_verify_ok_local_as_retaddr_and_refere + nce.j: New test. + * tests/regression/jasmin/Makefile.am: Added new test. + [fe03a2bb9cf6] + +2007-02-28 twisti + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Changed initialization order. Call + properties_postinit later, since it puts a pointer to + _Jv_bootclasspath into the properties list. + [61e332c57634] + +2007-02-28 edwin + + * src/vm/jit/stack.c: + * src/vm/jit/stack.c (stack_analyse): Fix: reset TYPE_VOID to + TYPE_ADR at the end of stack_analyse. + [5042bb6ae3af] + +2007-02-28 twisti + + * src/vm/access.h: + * src/vm/access.h (access_check_caller): Renamed to + access_check_member. + [96cd6de1d0b8] + + * src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, src/vm/access.c: + * src/vm/access.c (access_check_caller): Renamed to + access_check_member. Don't call access_is_accessible_class, this is + wrong. + + * src/native/vm/gnu/java_lang_reflect_Constructor.c + (constructNative): Use access_check_member. + + * src/native/vm/gnu/java_lang_reflect_Field.c (CHECKFIELDACCESS): + Removed. (cacao_get_field_address): Use access_check_member. + + * src/native/vm/gnu/java_lang_reflect_Method.c (invokeNative): + Likewise. + [a0b49cb1bccc] + +2007-02-28 michi + + * src/mm/cacao-gc/mark.c, src/vm/jit/codegen-common.c: + * src/mm/cacao-gc/mark.c: Added MARK() as helper macro. + [2994cd00c958] + +2007-02-28 twisti + + * src/native/vm/java_lang_ClassLoader.c: + * src/native/vm/java_lang_ClassLoader.c (vm/stringlocal.h): Added. + [3c44ad680b4b] + + * src/native/vm/java_lang_ClassLoader.c: + * src/native/vm/java_lang_ClassLoader.c (defineClass): Added loader- + variable for convenience. + [de55c5da2485] + +2007-02-28 pm + + * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen): Added ICMD_AASTORE. + * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Added exception + handler. + * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Likewise. + [6e6fd1de31b1] + +2007-02-27 twisti + + * configure.ac, src/native/Makefile.am, src/native/jni.c, + src/native/vm/Makefile.am, src/vm/exceptions.c, src/vm/global.h, + src/vm/jit/codegen-common.c, src/vm/jit/replace.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-asm.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/solaris/md-os.c, + src/vm/jit/stacktrace.h, src/vm/vm.c, src/vmcore/class.h: + * Merged with trunk. + [8277a27cd172] + + * * src/vm/jit/sparc64/solaris: Set ignore-properties. + [89b8897dd615] + +2007-02-27 michi + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.h: + * src/mm/cacao-gc/gc.h: Fixed typo in POINTS_INTO. + * src/mm/cacao-gc/compact.c (compact_move): Fixed typo. + [f17d8ca4a302] + + * src/mm/cacao-gc/gc.c, src/mm/cacao-gc/gc.h: + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/gc.c: Added define + (GCCONF_FINALIZER) to disable finalization. + [e15792241f6f] + +2007-02-27 ajordan + + * configure.ac, src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/solaris + /md-os.c, src/vm/jit/stacktrace.h: + * configure.ac: added solaris specific stuff: arch defines, libintl + dependency and solaris subdir makefile. + + * src/vm/jit/stacktrace.h: declared SPARC specific functions. + + * src/vm/jit/sparc64/emit.c: fixed call to builtin_verbosecall_exit. + + * src/vm/jit/sparc64/solaris/md-os.c: signal handling disabled, + can't test right now. + [9ae2ff45937d] + +2007-02-26 twisti + + * src/native/jni.c, src/native/vm/Makefile.am, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/java_lang_ClassLoader.c, + src/native/vm/java_lang_ClassLoader.h, src/vm/jit/codegen-common.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-asm.h, src/vmcore/zip.c: + * src/native/vm/java_lang_ClassLoader.c: New file. + * src/native/vm/java_lang_ClassLoader.h: Likewise. + + * src/native/vm/gnu/java_lang_VMClassLoader.c + (native/vm/java_lang_ClassLoader.h): Added. (defineClass): Removed + code and call _Jv_java_lang_ClassLoader_defineClass. + + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + java_lang_ClassLoader.[ch]. + + * src/native/jni.c [ENABLE_JAVASE] + (native/vm/java_lang_ClassLoader.h): Added. (_Jv_JNI_DefineClass): + Removed env and NULL arguments. + [f4e073f67460] + +2007-02-26 michi + + * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md-asm.h, + src/vmcore/zip.c: + Merged revisions 7390-7406 via svnmerge from + svn+ssh://michi@c1.complang.tuwien.ac.at/ahome/cacao/svn/cacao/trunk + + ........ r7395 | michi | 2007-02-23 23:57:53 +0100 (Fri, 23 Feb + 2007) | 2 lines + + * src/vm/jit/replace.c: Renamed regs to + abi_registers_integer_name. ........ r7402 | twisti | 2007-02-24 + 15:47:12 +0100 (Sat, 24 Feb 2007) | 4 lines + + * src/vmcore/zip.c (errno.h): Added. (vm/vm.h): Likewise. + (zip_get): Replaced asserts with vm_abort. ........ r7403 | pm | + 2007-02-25 22:31:58 +0100 (Sun, 25 Feb 2007) | 6 lines + + * src/vm/jit/codegen-common.c (methodtree_comparator): Fixed S390 + related comment. + * src/vm/jit/s390/codegen.h: Fixed M_JSR macro, did not store RA. + * src/vm/jit/s390/md-asm.h: Added (LOAD|STORE)_TEMPORARY_REGISTERS and + (LOAD|STORE)_ARGUMENT_REGISTERS macros. + * src/vm/jit/s390/asmpart.S: Implemented asm_handle_exception and + asm_vm_call_method_exception_handler. + * src/vm/jit/s390/md-abi.c (abi_registers_integer_temporary): did not + contain %r0, added. ........ r7404 | pm | 2007-02-25 23:02:16 + +0100 (Sun, 25 Feb 2007) | 2 lines + + * src/vm/jit/s390/asmpart.S (asm_getclassvalues_atomic, + asm_criticalsections): Added. ........ r7405 | pm | 2007-02-25 + 23:34:27 +0100 (Sun, 25 Feb 2007) | 3 lines + + * src/vm/jit/s390/codegen.c (codegen): Fixed ICMD_IF_ACMPNE + * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Handling NULL + return value of jit_asm_compile. ........ + [1b285f944716] + + * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/compact.c, src/mm + /cacao-gc/final.c, src/mm/cacao-gc/final.h, src/mm/cacao-gc/gc.c, + src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/mark.h, src/mm + /cacao-gc/rootset.c, src/mm/cacao-gc/rootset.h, src/vm/jit/s390/md- + asm.h: + * src/mm/cacao-gc/final.h, src/mm/cacao-gc/final.c, src/mm/cacao- + gc/rootset.h, src/mm/cacao-gc/rootset.c: Added. + * src/mm/cacao-gc/Makefile.am: See above. + + * src/mm/cacao-gc/gc.h (gc_notify_finalizer): Added. + * src/mm/cacao-gc/gc.c: Added finalization support. + * src/mm/cacao-gc/mark.c: Same as above. Rootset can contain "non- + marking" references now. + + * src/mm/cacao-gc/heap.h, src/mm/cacao-gc/heap.c: Severe code + cleanup, this applies to almost all files. + [1fcc2ed6373c] + +2007-02-25 pm + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen): Fixed ICMD_IF_ACMPNE + * src/vm/jit/s390/asmpart.S (asm_call_jit_compiler): Handling NULL + return value of jit_asm_compile. + [4d4b8ff67e86] + + * src/vm/jit/s390/asmpart.S: + * src/vm/jit/s390/asmpart.S (asm_getclassvalues_atomic, + asm_criticalsections): Added. + [081c95d4a439] + + * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390 + /md-asm.h: + * src/vm/jit/codegen-common.c (methodtree_comparator): Fixed S390 + related comment. + * src/vm/jit/s390/codegen.h: Fixed M_JSR macro, did not store RA. + * src/vm/jit/s390/md-asm.h: Added (LOAD|STORE)_TEMPORARY_REGISTERS and + (LOAD|STORE)_ARGUMENT_REGISTERS macros. + * src/vm/jit/s390/asmpart.S: Implemented asm_handle_exception and + asm_vm_call_method_exception_handler. + * src/vm/jit/s390/md-abi.c (abi_registers_integer_temporary): did not + contain %r0, added. + [ac2af54a65da] + +2007-02-24 twisti + + * src/vmcore/class.h, src/vmcore/zip.c: + * src/vmcore/zip.c (errno.h): Added. (vm/vm.h): Likewise. (zip_get): + Replaced asserts with vm_abort. + [4921b203cfdc] + +2007-02-24 michi + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/gc.c, src/mm/cacao- + gc/gc.h, src/mm/cacao-gc/heap.c, src/mm/cacao-gc/mark.c, src/mm + /cacao-gc/region.h: + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/compact.c, src/mm/cacao- + gc/region.h, src/mm/cacao-gc/gc.c, src/mm/cacao-gc/mark.c, src/mm + /cacao-gc/heap.c: Severe code cleanup. + [a8c4d7afe6d8] + + * src/mm/cacao-gc/compact.c, src/mm/cacao-gc/heap.c, src/mm/cacao- + gc/heap.h, src/vm/global.h: + * src/vm/global.h: Added defines HDRFLAG_HASH_TAKEN and + HDRFLAG_HASH_ATTACHED. + + * src/mm/cacao-gc/compact.c (compact_move): Hashcode gets attached + to objects while moving if previously taken. + + * src/mm/cacao-gc/heap.c (get_object_size): Attached hashcode might + increase object size. + [c436d5e47cfa] + +2007-02-23 michi + + * src/native/native.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMSystem.c, + src/native/vm/java_lang_Class.c, src/vm/vm.c, src/vmcore/class.c, + src/vmcore/class.h, src/vmcore/classcache.h, src/vmcore/loader.c, + src/vmcore/loader.h: + * src/vm/vm.c [ENABLE_GC_CACAO]: Added assertion for JVMTI. + + * src/vmcore/loader.h (classloader): Added this typedef, use it to + represent the indirection cell for a classloader. + + * src/vmcore/class.h (classinfo): Classloaders are now represendet + as indirection cells. + + * src/vmcore/loader.c, src/vmcore/class.c, src/vmcore/classcache.h, + src/native/native.c, src/native/vm/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/java_lang_VMSystem.c: Adapted to above changes. + [de2f4c3ac2f3] + + * src/mm/cacao-gc/Makefile.am, src/mm/cacao-gc/compact.c, src/mm + /cacao-gc/gc.c, src/mm/cacao-gc/gc.h, src/mm/cacao-gc/heap.c, src/mm + /cacao-gc/heap.h, src/mm/cacao-gc/mark.c, src/mm/cacao-gc/mark.h, + src/mm/cacao-gc/region.c, src/mm/cacao-gc/region.h: + * src/mm/cacao-gc/mark.h, src/mm/cacao-gc/heap.h, src/mm/cacao- + gc/heap.c, src/mm/cacao-gc/region.h, src/mm/cacao-gc/region.c: + Added. + + * src/mm/cacao-gc/Makefile.am: See above. + + * src/mm/cacao-gc/gc.h, src/mm/cacao-gc/gc.c: Moved development + breaks. (gc_collect): Added. + + * src/mm/cacao-gc/compact.c: Classloaders are threaded in now. + (compact_move): Fixed a severe typo. + [749fb93803aa] + + * src/vm/global.h: + * src/vm/global.h: Added defines for HDRFLAG_MARK1, HDRFLAG_MARK2 + and HDRFLAG_UNCOLLECTABLE. + [3f9744e458be] + + * src/vm/jit/i386/codegen.c, src/vm/jit/replace.c, + src/vm/jit/stacktrace.h: + * src/vm/jit/i386/codegen.c (createnativestub) [ENABLE_GC_CACAO]: + Saved registers are now stored/recovered into/from the + stackframeinfo struct. + + * src/vm/jit/replace.c (replace_pop_native_frame, + replace_push_native_frame) [ENABLE_GC_CACAO]: Handle saved registers + in the stackframeinfo struct now. + + * src/vm/jit/stacktrace.h [ENABLE_GC_CACAO]: Modified stackframeinfo + struct accordingly. + [4ab276d7b9bb] + + * src/vm/jit/replace.c: + * src/vm/jit/replace.c: Renamed regs to abi_registers_integer_name. + [6fe203d50ca4] + + * src/mm/memory.c, src/mm/memory.h: + * src/mm/memory.c, src/mm/memory.h: Moved defines for memcheck into + header file. + [0d3eb975b96c] + + * src/cacaoh/dummy.c, src/native/native.c, src/native/native.h, + src/vmcore/loader.c, src/vmcore/loader.h: + * src/native/native.h (hashtable_library_loader_entry): Uses + indirection cells. + * src/native/native.c (native_hashtable_library_add): Uses indirection + cells. (native_hashtable_library_find): Uses indirection cells. + + * src/vmcore/loader.h (hashtable_classloader_entry): Added to + represent indirection cells. + * src/vmcore/loader.c (hashtable_classloader): Added to hold + indirection cells. (loader_hashtable_classloader_add, + loader_hashtable_classloader_find): Added. + + * src/cacaoh/dummy.c (heap_get_hashcode): Added. + [3ed9616c49da] + + * src/native/jni.c: + * src/native/jni.c (jni_free_localref_table): Added. + * src/native/jni.c [ENABLE_GC_CACAO]: The localref_table is no longer + put onto the heap, but managed explicitly. + [e4b9c076da31] + + * src/mm/gc-common.h, src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/gnu/java_lang_VMSystem.c: + * src/mm/gc-common.h [ENABLE_GC_CACAO]: Added prototype for + heap_get_hashcode(). + * src/native/vm/gnu/java_lang_VMSystem.c [ENABLE_GC_CACAO]: Uses new + method to get hashcodes for objects. + * src/native/vm/cldc1.1/java_lang_Object.c [ENABLE_GC_CACAO]: Don't + know if we can use this here. + [d82b09b9957d] + +2007-02-21 twisti + + * src/vm/global.h, src/vmcore/class.c, src/vmcore/loader.c, + src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vm/global.h (ACC_CLASS_SOFT_REFERENCE, + ACC_CLASS_WEAK_REFERENCE) (ACC_CLASS_PHANTOM_REFERENCE): Added. + + * src/vmcore/class.c (class_create_classinfo) [ENABLE_JAVASE]: Check + if the class is a reference class and flag it. + + * src/vmcore/loader.c (load_class_from_classbuffer): OR the flags + loaded. + + * src/vmcore/utf8.c (utf_java_lang_ref_SoftReference) + (utf_java_lang_ref_WeakReference, + utf_java_lang_ref_PhantomReference): Added. (utf8_init): Initialize + added variables. + * src/vmcore/utf8.h: Likewise. + [417471e88036] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_throw_noclassdeffounderror): Abort + when VM is initializing. + [b40a83ba8073] + +2007-02-21 pm + + * src/vm/jit/s390/codegen.c: + * src/vm/jit/s390/codegen.c (codegen): allocate register save area + required by C abi for builtin calls + * src/vm/jit/s390/codegen.c (createnativestub): fix errornous code + generated for return, fix datasp argument to + codegen_finish_native_call + [9f5b283b0aac] + +2007-02-21 twisti + + * m4/jni.m4, src/native/Makefile.am, src/native/jni.c, src/vm/vm.c: + * m4/jni.m4: Added ENABLE_JNI AM_CONDITIONAL. + + * src/vm/vm.c (vm_createjvm): Replaced some ENABLE_JAVASE with + ENABLE_JNI. (vm_create): Likewise. + + * src/native/Makefile.am: Likewise. + + * src/native/jni.c (jni_init) [ENABLE_JAVASE]: ifdef'ed Java SE + stuff. (_Jv_JNI_DefineClass) [!ENABLE_JAVASE]: Abort. + (_Jv_JNI_FindClass): Likewise. (_Jv_JNI_FromReflectedMethod): + Likewise. (_Jv_JNI_FromReflectedField): Likewise. + (_Jv_JNI_NewDirectByteBuffer): Likewise. + (_Jv_JNI_GetDirectBufferAddress): Likewise. + (_Jv_JNI_GetDirectBufferCapacity): Likewise. + (_Jv_JNI_IsAssignableFrom): Call + _Jv_java_lang_Class_isAssignableFrom. (_Jv_JNI_IsInstanceOf): Call + _Jv_java_lang_Class_isInstance. (_Jv_JNI_EnsureLocalCapacity): + Removed debug output. + [6a87404455be] + + * configure.ac, src/native/include/Makefile.am, + src/native/vm/cldc1.1/Makefile.am, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/vm/jit/Makefile.am, + src/vm/jit/abi-asm.h, src/vm/jit/disass-common.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/patcher.c, + src/vm/jit/x86_64/md-abi.c: + * Merged with trunk. + [0f801edae0f9] + + * src/vm/jit/Makefile.am, src/vm/jit/disass-common.c: + * src/vm/jit/Makefile.am [!WITH_BINUTILS_DISASSEMBLER] + (DISASS_SOURCES): Removed. + + * src/vm/jit/disass-common.c: Removed WITH_BINUTILS_DISASSEMBLER + ifdefs, since it's compiled conditionally. + [68009c60134a] + + * src/vm/jit/x86_64/md-abi.c: + * src/vm/jit/x86_64/md-abi.c (regs): Renamed to + abi_registers_integer_name. (md_param_alloc): Made code more clear. + (md_param_alloc_native): New function. + [cebe1d53aed3] + + * src/vm/jit/abi-asm.h: + * src/vm/jit/abi-asm.h: Cosmetic changes. + [8abf46e074a3] + +2007-02-20 tbfg + + * src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, + src/vm/jit/m68k/codegen.h, src/vm/jit/m68k/emit.c, + src/vm/jit/m68k/emit.h, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/machine-instr.h, + src/vm/jit/m68k/md.c: + * src/vm/jit/m68k/emit.c (emit_mov_imm_reg): New function. + (emit_mov_imm_areg): Likewise. + + * src/vm/jit/m68k/linux/md-abi.h: Lots of defines. + + * src/vm/jit/m68k/linux/md-abi.c: Register allocator data structure + created, some stubs added. + + * src/vm/jit/m68k/md.c (md_param_alloc): Removed. + * src/vm/jit/m68k/arch.h (REG_ZERO): Added a dummy REG_ZERO, needs to + be resolved. + + * src/vm/jit/m68k/emit.h: New file. + + * src/vm/jit/m68k/codegen.c (createcompilerstub): Implemented. + + * src/vm/jit/m68k/machine-instr.h (*BARRIER*): Implemented. + (compare_and_swap): Implemented, but not atomically, there is no way + to do soo on coldfire. + + * src/vm/jit/m68k/codegen.h (M_MOV_IMM): Added. (M_AMOV_IMM): Added. + (M_JMP): Added. (OPWORD): Added. + [2e818486fcf6] + + * src/cacao/Makefile.am, src/mm/memory.h, src/mm/nogc.c, + src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/threads/native/Makefile.am, src/threads/native/threads.c, + src/threads/native/threads.h, src/toolbox/logging.c, + src/vm/finalizer.c, src/vm/jit/abi.h, src/vm/jit/alpha/disass.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/disass.c, src/vm/jit/arm + /md-abi.c, src/vm/jit/asmpart.h, src/vm/jit/disass.h, + src/vm/jit/i386/md-abi.c, src/vm/jit/mips/disass.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/patcher.c, + src/vm/jit/stacktrace.c, src/vm/signal.c, src/vmcore/descriptor.c, + src/vmcore/descriptor.h, src/vmcore/options.c, src/vmcore/options.h: + * src/mm/nogc.c (heap_allocate): Renamed + exceptions_throw_outofmemory_exit to + exceptions_throw_outofmemoryerror. (gc_init): Liekwise. + + * src/vmcore/descriptor.h (methoddesc): Added argaddrreguse when + HAS_ADDRESS_REGISTER_FILE. + [4bc1020616ed] + +2007-02-20 twisti + + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c (vm/exceptions.h): + Added. (vm/stringlocal.h): Likewise. (loadLibrary): Throw error in + case. + [f5960974827d] + + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h: + * src/native/vm/java_lang_Runtime.c (loadLibrary): Different + signature for _Jv_java_lang_Runtime_loadLibrary depending on + ENABLE_JNI. + * src/native/vm/java_lang_Runtime.h: Likewise. + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: Likewise. + * src/native/vm/gnu/java_lang_VMRuntime.c: Likewise. + [89ae09836c68] + + * configure.ac, m4/java.m4, m4/jit.m4, m4/jni.m4: + * configure.ac (AC_CHECK_ENABLE_JAVA): Added. (AC_CHECK_ENABLE_JIT): + Likewise. (AC_CHECK_ENABLE_JNI): Likewise. + + * m4/jni.m4: New file. + * m4/java.m4: Likewise. + * m4/jit.m4: Likewise. + [1c39fd610b52] + +2007-02-19 twisti + + * src/native/include/Makefile.am, src/native/vm/cldc1.1/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h: + * src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c: New file. + + * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES): + Added com_sun_cldchi_jvm_JVM.c. + + * src/native/vm/java_lang_Runtime.c [!WITH_STATIC_CLASSPATH] + (ltdl.h): Added. (native/jni.h): Likewise. (native/native.h): + Likewise. (native/include/java_lang_String.h): Likewise. + (toolbox/logging.h): Likewise. (vm/exceptions.h): Likewise. + (vm/stringlocal.h): Likewise. (vmcore/options.h): Likewise. + (loadLibrary): New function. + + * src/native/vm/java_lang_Runtime.h (native/jni.h): Added. + (native/include/java_lang_String.h): Likewise. + + * src/native/vm/gnu/java_lang_VMRuntime.c [!WITH_STATIC_CLASSPATH] + (ltdl.h): Removed. (native/native.h): Likewise. (toolbox/logging.h): + Likewise. (vmcore/options.h): Likewise. (nativeLoad): Call + _Jv_java_lang_Runtime_loadLibrary. + + * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES): + Added com_sun_cldchi_jvm_JVM.h. + [f1fc106c9495] + +2007-02-18 pm + + * src/cacao/Makefile.am, src/mm/memory.h, src/native/native.c, + src/native/native.h, src/native/vm/gnu/java_lang_reflect_Method.c, + src/threads/native/Makefile.am, src/threads/native/threads.c, + src/threads/native/threads.h, src/toolbox/logging.c, + src/vm/finalizer.c, src/vm/jit/abi.h, src/vm/jit/alpha/disass.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/disass.c, src/vm/jit/arm + /md-abi.c, src/vm/jit/asmpart.h, src/vm/jit/disass.h, + src/vm/jit/i386/md-abi.c, src/vm/jit/mips/disass.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/s390/asmpart.S, src/vm/jit/s390/patcher.c, + src/vm/jit/stacktrace.c, src/vm/signal.c, src/vmcore/descriptor.c, + src/vmcore/descriptor.h, src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/s390/patcher.c (patcher_wrapper): Formatting changes. + * src/vm/jit/s390/asmpart.S (asm_patcher_wrapper): Did not remove + stack frame created by patcher stubs. + [02d0605e27d4] + +2007-02-18 michi + + * src/mm/cacao-gc/compact.c: + * src/mm/cacao-gc/compact.c: Fixed a typo in compact_move(). + Classloaders are now threaded in compact_thread_classes() as well. + [d5545512c055] + + * src/cacaoh/Makefile.am, src/mm/boehm.c, src/native/native.c, + src/native/native.h, src/native/vm/gnu/java_lang_VMRuntime.c, + src/vm/builtin.h, src/vm/jit/Makefile.am, + src/vm/jit/alpha/freebsd/Makefile.am, + src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md-abi.h, + src/vm/jit/alpha/md.c, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/emit.c, src/vm/jit/i386/freebsd/Makefile.am, + src/vm/jit/i386/linux/Makefile.am, src/vm/jit/mips/irix/Makefile.am, + src/vm/jit/mips/linux/Makefile.am, + src/vm/jit/powerpc/darwin/Makefile.am, + src/vm/jit/powerpc/linux/Makefile.am, src/vm/jit/powerpc/linux/md- + abi.h, src/vm/jit/s390/arch.h, src/vm/jit/s390/emit.c, + src/vm/jit/s390/md-asm.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.h, src/vmcore/class.h: + * src/native/native.c, src/native/native.h: The hashtable_library + now uses the hashcode of the classloader instead of its memory + address. + [333581df59af] + +2007-02-16 twisti + + * src/cacaoh/dummy.c, src/mm/memory.c: + * Merged with trunk. + [80d87d7ebe2c] + + * src/cacaoh/dummy.c, src/mm/memory.c, src/vmcore/statistics.c, + src/vmcore/statistics.h: + * src/vmcore/statistics.c (mm/gc-common.h): Added. + (statistics_print_gc_memory_usage): New function. + * src/vmcore/statistics.h (statistics_print_gc_memory_usage): + Likewise. + + * src/cacaoh/dummy.c (gc_get_heap_size): New stub. + (gc_get_free_bytes): Likewise. (gc_get_total_bytes): Likewise. + (gc_get_max_heap_size): Likewise. + + * src/mm/memory.c (memory_thread): Call + statistics_print_gc_memory_usage. + [1a5524ae4db5] + + * src/Makefile.am, src/cacaoh/dummy.c, src/threads/Makefile.am, + src/threads/threads-common.c, src/vm/jit/intrp/asmpart.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/dynamic-super.c, + src/vm/jit/intrp/engine.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/intrp/java.vmg, src/vm/jit/intrp/patcher.c, + src/vm/jit/intrp/peephole.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c: + * Merged with trunk. + [1e3bbf505d88] + +2007-02-16 pm + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md-abi.c, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c: + * src/vm/jit/s390/md.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/md-abi.c: Changed a lot. + Mostly adapted to changes in the tree. + [7e252ec103cb] + +2007-02-15 twisti + + * src/cacaoh/dummy.c, src/vm/jit/intrp/dynamic-super.c, + src/vm/jit/intrp/engine.c: + * src/cacaoh/dummy.c (intrp_asm_abstractmethoderror): New stub. + (print_dynamic_super_statistics): Likewise. + + * src/vm/jit/intrp/engine.c (mm/memory.h): Added. + * src/vm/jit/intrp/dynamic-super.c [!ENABLE_THREADS] + (threads/none/lock.h): Likewise. + [aeb00f812c30] + + * src/Makefile.am, src/threads/Makefile.am, src/threads/threads- + common.c: + * src/Makefile.am [ENABLE_THREADS] (THREADS_DIR): Added. (SUBDIRS): + Added THREADS_DIR. + + * src/threads/Makefile.am (SUBDIRS): Set always to native. + + * src/threads/threads-common.c (threads/none/threads.h): Removed. + [ENABLE_THREADS] (threads_create_thread): Removed ifdef. + (threads_get_current_tid) [ENABLE_THREADS]: Removed. + [9cc012c8781c] + + * src/vm/jit/powerpc/arch.h: + * src/vm/jit/powerpc/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Defined. + [1fa126b89842] + + * src/vm/jit/emit-common.c, src/vm/jit/emit-common.h, + src/vm/jit/mips/arch.h, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/patcher.c: + * src/vm/jit/emit-common.c + [SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER] (emit_beqz) + (emit_bnez, emit_bltz, emit_bgez, emit_bgtz, emit_blez): #ifdef'ed. + [SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS] (emit_beq) + (emit_bne): New functions. + [SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER] (emit_beq, emit_bne) + (emit_blt, emit_bge, emit_bgt, emit_ble): #ifdef'ed. + * src/vm/jit/emit-common.h: Likewise. + + * src/vm/jit/mips/emit.c (emit_branch): Fixed. + (emit_arithmetic_check): Use hardware-exception instructions. + (emit_arrayindexoutofbounds_check): Likewise. + (emit_classcast_check): Likewise. (emit_nullpointer_check): + Likewise. (emit_exception_check): Likewise. (emit_arraystore_check): + Removed. (emit_exception_stubs): Likewise. + + * src/vm/jit/mips/md.c (md_codegen_patch_branch): Removed. + + * src/vm/jit/mips/codegen.c (codegen): Renamed to codegen_emit and + changed to use emit-branch functions. + + * src/vm/jit/mips/codegen.h (M_ITYPE_GET_RS, M_ITYPE_GET_RT) + (M_ITYPE_GET_IMM): Added. + + * src/vm/jit/mips/linux/md-os.c (vm/jit/mips/codegen.h): Added. + (md_signal_handler_sigsegv): Use exceptions_new_hardware_exception. + + * src/vm/jit/mips/arch.h + (SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER) + (SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS): Defined. + + * src/vm/jit/mips/patcher.c (patcher_checkcast_interface): Fixed + patching offsets. + [fad4133a1392] + +2007-02-15 pm + + * src/cacaoh/Makefile.am, src/native/include/Makefile.am, src/threads + /threads-common.c: + * src/threads/threads-common.c (threads_get_current_tid): Return 0 + if compiled with --enable-threads=none + [c76426752793] + +2007-02-14 twisti + + * configure.ac, m4/cacaoh.m4, src/Makefile.am, + src/native/include/Makefile.am: + * configure.ac (--with-cacaoh): Removed code and call + AC_CHECK_WITH_CACAOH. + * m4/cacaoh.m4: New file. + * src/Makefile.am [ENABLE_CACAOH] (CACAOH_DIR): Added. (SUBDIRS): + Added CACAOH_DIR. + * src/native/include/Makefile.am (CACAOH): Don't set it, configure + does that. + [0310673feb39] + +2007-02-14 tbfg + + * src/Makefile.am, src/cacaoh/Makefile.am, + tests/regression/native/Makefile.am: + * src/Makefile.am: Do not recurse into cacaoh when not enabled. + * src/cacaoh/Makefile.am: Removed conditional builds. + * tests/regression/native/Makefile.am: Used hardcoded cacaoh. + [f4ae950cc199] + + * configure.ac, src/cacaoh/Makefile.am, + src/native/include/Makefile.am: + * configure.ac (--with-cacaoh): Added --with-cacaoh for easier + crossbuilds. + + * src/cacaoh/Makefile.am: Use configure provided cacaoh. + + * src/native/include/Makefile.am: Only build cacaoh when no + --with-cacaoh given. + [d3ac14a1eef5] + +2007-02-14 twisti + + * src/vm/jit/intrp/codegen.c, src/vm/jit/intrp/intrp.h, + src/vm/jit/mips/emit.c: + * src/vm/jit/mips/emit.c (emit_branch): New function. + [b9f3457e62b7] + + * src/cacao/Makefile.am, src/mm/boehm.c, src/mm/memory.c, + src/mm/memory.h, src/native/include/Makefile.am, + src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/threads/Makefile.am, src/threads/native/Makefile.am, + src/threads/native/threads.c, src/threads/native/threads.h, + src/toolbox/logging.c, src/vm/builtin.h, src/vm/finalizer.c, + src/vm/jit/abi.h, src/vm/jit/alpha/disass.c, + src/vm/jit/alpha/freebsd/Makefile.am, + src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md-abi.c, + src/vm/jit/alpha/md-abi.h, src/vm/jit/alpha/md.c, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/disass.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/asmpart.h, src/vm/jit/disass.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/emit.c, + src/vm/jit/i386/freebsd/Makefile.am, + src/vm/jit/i386/linux/Makefile.am, src/vm/jit/i386/md-abi.c, + src/vm/jit/intrp/asmpart.c, src/vm/jit/intrp/codegen.c, + src/vm/jit/intrp/dynamic-super.c, src/vm/jit/intrp/engine.c, + src/vm/jit/intrp/intrp.h, src/vm/jit/intrp/java.vmg, + src/vm/jit/intrp/patcher.c, src/vm/jit/intrp/peephole.c, + src/vm/jit/mips/disass.c, src/vm/jit/mips/irix/Makefile.am, + src/vm/jit/mips/linux/Makefile.am, src/vm/jit/mips/md-abi.c, + src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/darwin/Makefile.am, + src/vm/jit/powerpc/linux/Makefile.am, src/vm/jit/powerpc/linux/md- + abi.c, src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-asm.h, src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/stacktrace.c, src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64 + /md-abi.h, src/vm/signal.c, src/vmcore/class.h, + src/vmcore/descriptor.c, src/vmcore/descriptor.h, + src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/intrp/peephole.c: Updated to current codebase. + * src/vm/jit/intrp/intrp.h: Likewise. + * src/vm/jit/intrp/codegen.c: Likewise. + * src/vm/jit/intrp/engine.c: Likewise. + * src/vm/jit/intrp/asmpart.c: Likewise. + * src/vm/jit/intrp/dynamic-super.c: Likewise. + * src/vm/jit/intrp/patcher.c: Likewise. + * src/vm/jit/intrp/java.vmg: Likewise. + [cc5c117f777d] + + * configure.ac, src/cacao/Makefile.am, src/cacaoh/dummy.c, + src/mm/memory.c, src/mm/memory.h, src/native/jni.c, + src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/threads/.cvsignore, src/threads/Makefile.am, + src/threads/critical.c, src/threads/critical.h, + src/threads/native/Makefile.am, src/threads/native/critical.c, + src/threads/native/critical.h, src/threads/native/lock.c, + src/threads/native/lock.h, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/threads.h, + src/threads/threads-common.c, src/threads/threads-common.h, + src/toolbox/logging.c, src/vm/builtin.c, src/vm/builtin.h, + src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/abi.h, + src/vm/jit/alpha/disass.c, src/vm/jit/alpha/emit.c, src/vm/jit/alpha + /md-abi.c, src/vm/jit/alpha/md-abi.h, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/disass.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, + src/vm/jit/disass.h, src/vm/jit/emit-common.h, + src/vm/jit/i386/emit.c, src/vm/jit/i386/md-abi.c, + src/vm/jit/mips/disass.c, src/vm/jit/mips/emit.c, + src/vm/jit/mips/irix/Makefile.am, src/vm/jit/mips/linux/Makefile.am, + src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-abi.h, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/jit/powerpc/linux/md-abi.h, src/vm/jit/replace.c, + src/vm/jit/replace.h, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c, src/vm/jit/show.c, + src/vm/jit/sparc64/Makefile.am, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/solaris/.cvsignore, + src/vm/jit/sparc64/solaris/Makefile.am, src/vm/jit/sparc64/solaris + /md-os.c, src/vm/jit/stacktrace.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.h, src/vm/signal.c, src/vm/vm.c, + src/vmcore/annotation.c, src/vmcore/descriptor.c, + src/vmcore/descriptor.h, src/vmcore/options.c, src/vmcore/options.h: + * Merged with trunk. + [7b6a202c6bfd] + + * src/mm/boehm.c, src/native/include/Makefile.am, src/native/native.c, + src/native/vm/Makefile.am, src/native/vm/cldc1.1/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_Object.h, src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/vm/exceptions.c, + src/vm/jit/alpha/freebsd/Makefile.am, + src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md.c, + src/vm/jit/codegen-common.c, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h, + src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/ucontext.c, + src/vm/jit/i386/cygwin/ucontext.h, + src/vm/jit/i386/freebsd/Makefile.am, + src/vm/jit/i386/linux/Makefile.am, + src/vm/jit/powerpc/darwin/Makefile.am, + src/vm/jit/powerpc/linux/Makefile.am, + src/vm/jit/powerpc/netbsd/Makefile.am, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/patcher.c, src/vm/vm.c, src/vmcore/class.h: + * Merged with trunk. + [e39f030e886d] + +2007-02-14 tbfg + + * src/cacao/Makefile.am, src/cacaoh/dummy.c, src/mm/memory.c, + src/mm/memory.h, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/threads/native/Makefile.am, src/threads/native/threads.c, + src/threads/native/threads.h, src/toolbox/logging.c, + src/vm/finalizer.c, src/vm/jit/Makefile.am, src/vm/jit/abi.h, + src/vm/jit/alpha/disass.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/disass.c, src/vm/jit/arm/md-abi.c, + src/vm/jit/asmpart.h, src/vm/jit/codegen-common.c, + src/vm/jit/disass.h, src/vm/jit/i386/md-abi.c, + src/vm/jit/m68k/disass.c, src/vm/jit/mips/disass.c, src/vm/jit/mips + /md-abi.c, src/vm/jit/powerpc/linux/md-abi.c, src/vm/jit/s390/md.c, + src/vm/jit/stacktrace.c, src/vm/signal.c, src/vmcore/annotation.c, + src/vmcore/descriptor.c, src/vmcore/descriptor.h, + src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/m68k/disass.c: New file. + * src/vm/jit/codegen-common.c: Include vmcore/statistics.h + unconditionally. + [2e1c214eadcf] + +2007-02-13 twisti + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/md-abi.c: + * src/vm/jit/arm/codegen.c (createnativestub) [!__ARM_EABI__]: + #ifdef'ed split-stuff. + * src/vm/jit/arm/md-abi.c (md_param_alloc_native) [!__ARM_EABI__]: + Added GNU EABI stuff. + [af78bca75913] + +2007-02-13 ajordan + + * configure.ac, src/vm/jit/sparc64/Makefile.am, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/solaris/.cvsignore, + src/vm/jit/sparc64/solaris/Makefile.am, src/vm/jit/sparc64/solaris + /md-os.c: + * configure.ac: Added support for compiling on Solaris. + + * src/vm/jit/sparc64/*: Added os subdir, changes for compiling on + Solaris. + [157ae470d534] + +2007-02-13 twisti + + * src/vm/jit/mips/disass.c, src/vm/jit/mips/md-abi.c: + * src/vm/jit/mips/md-abi.c (regs): Renamed to + abi_registers_integer_name. (md_param_alloc_native): New function. + * src/vm/jit/mips/disass.c (disassinstr): Replaced regs with + abi_registers_integer_name. + [3db406d10cfa] + + * src/vm/jit/mips/emit.c, src/vm/jit/mips/md-abi.h: + * src/vm/jit/mips/emit.c (emit_verbosecall_exit): Fixed argument + passing, but I think there's still something left to fix. + * src/vm/jit/mips/md-abi.h (REG_A2_A3_PACKED): Added. + [f55f5d4d9ef6] + + * src/threads/native/lock.c, src/threads/native/lock.h: + * src/threads/native/lock.c (vm/vm.h): Added. + (lock_record_add_waiter): New function. (lock_record_remove_waiter): + Free the waiter data structure. (lock_record_wait): Use + lock_record_add_waiter. + * src/threads/native/lock.h: Cosmetic changes. + [d1d527064209] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (mem_alloc): Arghhhh, fixed arguments. + [a9db026b311f] + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (mem_alloc): Use calloc instead of malloc. + [6faeec3ab2c6] + + * src/threads/threads-common.c: + * src/threads/threads-common.c (threads_get_current_tid): Check if + thread is NULL and return 0. + [8f9daba23327] + + * src/cacaoh/dummy.c, src/threads/threads-common.c, src/threads + /threads-common.h, src/toolbox/logging.c: + * src/threads/threads-common.c (threads_get_current_tid): New + function. + * src/threads/threads-common.h (threads_get_current_tid): Added. + + * src/toolbox/logging.c (log_start): Use threads_get_current_tid. + + * src/cacaoh/dummy.c (threads_get_current_threadobject): Removed. + (threads_get_current_tid): Added. + [3a124f6f4c56] + +2007-02-13 ajordan + + * src/vm/jit/Makefile.am, src/vm/signal.c: + * src/vm/jit/Makefile.am: Reverted duplicate changes. + + * src/vm/signal.c: Reverted one duplicate header include. + [2fbdec7bf486] + + * src/native/jni.c, src/threads/critical.c, + src/threads/none/threads.h, src/threads/threads-common.c, + src/vm/exceptions.c, src/vm/finalizer.c, src/vm/jit/Makefile.am, + src/vm/jit/codegen-common.c, src/vm/jit/stacktrace.c, + src/vm/signal.c: + * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo): + SPARC specific retrieval of the PV. (stacktrace_create): SPARC + specific stack walking. + + * src/vm/jit/Makefile.am: Not compiling verifier source when + disabled. + + * src/vm/jit/codegen-common.c (codegen_add_patch_ref): Included + __SPARC_64__ in ifdef to add patcher NOPs from here. + + * src/vm/signal.c: Added include statements and/or ifdefs to fix + compiling without threads. + * src/vm/exceptions.c: Likewise. + * src/vm/finalizer.c: Likewise. + * src/native/jni.c: Likewise. + * src/threads/none/threads.h: Likewise. + * src/threads/threads-common.c: Likewise. + * src/threads/critical.c: Likewise. + [c51c053fbfbf] + + * src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md-abi.h: + * src/vm/jit/sparc64/md-abi.h: set TRACE_ARGS_NUM to 6. + * src/vm/jit/sparc64/emit.c: using the 6 available integer argument + regs for call tracing. + + * src/vm/jit/sparc64/md-abi.c: added abi register names. Added + md_param_alloc_native(), but still using the existing workaround. + [9a19cd374635] + +2007-02-13 twisti + + * src/mm/memory.c: + * src/mm/memory.c (memory_thread) [ENABLE_STATISTICS]: #ifdef'ed + statistics_print_memory_usage call. + [cd26a2966c4b] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create) [ENABLE_STATISTICS]: #ifdef opt_stat. + [08f3909ddc6a] + + * src/mm/memory.c, src/vm/vm.c: + * src/vm/vm.c (vm_create): Set opt_stat also true for + -verbose:memory. + * src/mm/memory.c [ENABLE_THREADS] (threads/threads-common.h): Added. + (memory_thread): Call statistics_print_memory_usage. + [b512ae21162a] + + * src/cacao/Makefile.am, src/mm/memory.c, src/mm/memory.h, + src/threads/.cvsignore, src/threads/Makefile.am, + src/threads/critical.c, src/threads/critical.h, + src/threads/native/Makefile.am, src/threads/native/critical.c, + src/threads/native/critical.h, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/threads-common.c, + src/threads/threads-common.h, src/vm/finalizer.c, + src/vm/jit/asmpart.h, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, src/vm/signal.c, src/vm/vm.c, + src/vmcore/options.c, src/vmcore/options.h: + * src/vm/jit/optimizing/profile.c (native/jni.h): Removed. + (native/include/java_lang_Thread.h): Likewise. + (native/include/java_lang_VMThread.h): Likewise. (threads/threads- + common.h): Added. (thread_profile): Changed type to threadobject. + (profile_start_thread): Use threads_create_thread. + * src/vm/jit/optimizing/recompile.c: Likewise. + * src/vm/signal.c: Likewise. + * src/vm/finalizer.c: Likewise. + + * src/vm/jit/asmpart.h (threads/native/critical.h): Removed. + (threads/critical.h): Added. + + * src/vmcore/options.c (opt_verbosememory): Added. + * src/vmcore/options.h: Likewise. + + * src/vm/vm.c (XXusage): Added -verbose:memory. (vm_create): + Likewise. Start memory thread. + + * src/cacao/Makefile.am (THREAD_LIB): Changed to + $(top_builddir)/src/threads/libthreads.la. + + * src/mm/memory.c [ENABLE_THREADS] (thread_memory): Added. + [ENABLE_THREADS] (memory_thread): New function. [ENABLE_THREADS] + (memory_start_thread): Likewise. + * src/mm/memory.h [ENABLE_THREADS] (memory_start_thread): Added. + + * src/threads/native/critical.c: Removed. + * src/threads/native/critical.h: Likewise. + * src/threads/critical.c: Added. + * src/threads/critical.h: Likewise. + + * src/threads/threads-common.c: New file. + * src/threads/threads-common.h: Likewise. + * src/threads/Makefile.am (AM_CPPFLAGS): Added. (LIB): Likewise. + [ENABLE_THREADS] (THREAD_LIB): Likewise. (noinst_LTLIBRARIES): + Likewise. (libthreads_la_SOURCES): Likewise. (libthreads_la_LIBADD): + Likewise. + + * src/threads/.cvsignore: New file. + + * src/threads/native/threads.c (include "threads/threads-common.h): + Added. + * src/threads/native/threads.h (MIN_PRIORITY, NORM_PRIORITY) + (MAX_PRIORITY): Removed. + + * src/threads/native/Makefile.am (noinst_LTLIBRARIES): Changed to + libthreadsposix.la. + [57682a5aba23] + + * src/vmcore/annotation.c: + * src/vmcore/annotation.c + (annotation_load_attribute_runtimevisibleannotations): Renamed aa to + annotations. + [1c792673fcbd] + +2007-02-12 twisti + + * src/vm/jit/emit-common.h: + * src/vm/jit/emit-common.h (_EMIT_H): Renamed to _EMIT_COMMON_H. + (config.h): Added. (vm/jit/codegen-common.h): Likewise. + [SIZEOF_VOID_P == 4] (IS_IMM16): Added. + [b19814ba89ab] + + * src/vm/jit/alpha/disass.c, src/vm/jit/alpha/md-abi.c: + * src/vm/jit/alpha/md-abi.c (regs): Renamed to + abi_registers_integer_name. (md_param_alloc_native): New function. + + * src/vm/jit/alpha/disass.c (vm/jit/abi.h): Added. (disassinstr): + Replaced regs with abi_registers_integer_name. + [23febdef7237] + + * src/vm/jit/i386/md-abi.c: + * src/vm/jit/i386/md-abi.c (regs): Renamed to + abi_registers_integer_name. (md_param_alloc_native): New function. + [cc5eeff0cb09] + +2007-02-11 twisti + + * src/vm/jit/arm/disass.c, src/vm/jit/arm/md-abi.c: + * src/vm/jit/arm/disass.c (stdio.h): Added. (regs): Removed. + * src/vm/jit/arm/md-abi.c (abi_registers_integer_name): Added. + (md_param_alloc_native): Likewise. + [29ed076c2ed8] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (vm/jit/abi.h): Added. + [3edfd0bfe9e7] + + * src/vm/jit/disass.h, src/vm/jit/show.c: + * src/vm/jit/disass.h (regs): Removed. + + * src/vm/jit/show.c (vm/jit/abi.h): Added. (show_allocation): + Renamed regs to abi_registers_integer_name. + [f0edc37030d7] + + * src/vm/jit/codegen-common.c, src/vm/jit/powerpc/linux/md-abi.c: + * src/vm/jit/codegen-common.c (codegen_createnativestub): Call + md_param_alloc_native instead of md_param_alloc. + + * src/vm/jit/powerpc/linux/md-abi.c (assert.h): Added. (regs): + Renamed to abi_registers_integer_name. + (abi_registers_integer_argument, abi_registers_integer_saved) + (abi_registers_integer_temporary, abi_registers_float_name) + (abi_registers_float_argument, abi_registers_float_saved) + (abi_registers_float_temporary): Added. (md_param_alloc): + Reformatted. (md_param_alloc_native): New function. + [4736770b86de] + + * src/vm/jit/abi.h, src/vmcore/descriptor.c, src/vmcore/descriptor.h: + * src/vmcore/descriptor.c (vm/jit/abi.h): Added. + * src/vmcore/descriptor.h (md_param_alloc): Removed. + + * src/vm/jit/abi.h (abi_registers_integer_name) + (abi_registers_integer_argument, abi_registers_integer_saved) + (abi_registers_integer_temporary, abi_registers_float_name) + (abi_registers_float_argument, abi_registers_float_saved) + (abi_registers_float_temporary): Added. (md_param_alloc): Likewise. + (md_param_alloc_native): Likewise. + [a16f365547ee] + + * src/native/native.c, src/native/native.h, + src/native/vm/gnu/java_lang_reflect_Method.c: + * src/native/native.c (native_get_returntype): Removed. + * src/native/native.h: Likewise. + + * src/native/vm/gnu/java_lang_reflect_Method.c (getReturnType): + Moved code from native_get_returntype. + [63cc7b056dbb] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (vm/jit/md.h): Added. + [d03242be27f2] + +2007-02-11 michi + + * src/mm/cacao-gc/region.c, src/mm/cacao-gc/region.h, src/mm/memory.c, + src/mm/memory.h: + * src/mm/cacao-gc/region.h, src/mm/cacao-gc/region.c: Added. + * src/mm/memory.c, src/mm/memory.h: Moved defines for memcheck into + header file. + [12fda0ee1c7c] + +2007-02-11 twisti + + * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Keep stack 8-byte + aligned. (emit_verbosecall_exit): Added comment. + * src/vm/jit/arm/asmpart.S (asm_call_jit_compiler): Keep stack 8-byte + aligned. + [d97c9610df75] + +2007-02-11 michi + + * src/vm/jit/i386/codegen.c, src/vm/jit/stacktrace.h: + * src/vm/jit/i386/codegen.c (createnativestub): Saved registers are + now stored/recovered into/from the stackframeinfo structure. + * src/vm/jit/stacktrace.h: Modified stackframeinfo structure + accordingly. + [663e32714291] + +2007-02-11 pm + + * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/patcher.c, + src/vm/jit/stacktrace.c: + * src/vm/jit/stacktrace.c (stacktrace_create_extern_stackframeinfo): + On s390 get return address from stack also in leaf methods. + * src/vm/jit/codegen-common.c (methodtree_comparator): On s390 compare + addresses as 31 bit integers. + * src/vm/jit/s390/md.c, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/asmpart.S: Changed a lot, working on s390 port. + [c749d9c3aaf1] + +2007-02-11 tbfg + + * src/vm/builtin.h, src/vm/jit/arm/emit.c, src/vm/jit/i386/emit.c, + src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/x86_64/emit.c: + * src/vm/jit/powerpc64/codegen.c (CHECKCAST): Longbranches are only + an issue when using SOFTEX. + + * src/vm/jit/powerpc64/patcher.c + (patcher_resolve_classref_to_classinfo): Added. + (patcher_resolve_classref_to_classinfo): Added. + (patcher_resolve_classref_to_vftbl): Added. + (patcher_resolve_classref_to_flags): Added. + [448a35abd40f] + +2007-02-11 michi + + * src/vm/jit/replace.c, src/vm/jit/replace.h: + * src/vm/jit/replace.c: Fixed includes for options.h and + classcache.h headers. + * src/vm/jit/replace.h: Added forward typedef for rplalloc. + [666823923812] + + * src/vm/jit/replace.h: + * src/vm/jit/replace.h: Fixed include for method.h header. + [0ed77d0cbca4] + + * src/mm/gc-common.h, src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/gnu/java_lang_VMSystem.c: + * src/mm/gc-common.h [ENABLE_GC_CACAO]: Added prototype for + heap_get_hashcode(). + * src/native/vm/gnu/java_lang_VMSystem.c [ENABLE_GC_CACAO]: Uses new + method to get hashcodes for objects. + * src/native/vm/cldc1.1/java_lang_Object.c [ENABLE_GC_CACAO]: Don't + know if we can use this here. + [985cf627996d] + +2007-02-11 twisti + + * src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.h: + * src/vm/jit/x86_64/emit.c (emit_verbosecall_enter): Renamed + builtin_trace_args to builtin_verbosecall_enter. + (builtin_verbosecall_exit): Renamed builtin_displaymethodstop to + builtin_verbosecall_exit and changed signature. + + * src/vm/jit/x86_64/md-abi.h (REG_FA0, REG_FA1): Added. + [c6b6afe62556] + +2007-02-10 twisti + + * src/vm/builtin.c, src/vm/builtin.h, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/md-abi.h, src/vm/jit/arm/emit.c, + src/vm/jit/i386/emit.c, src/vm/jit/mips/emit.c, + src/vm/jit/mips/irix/Makefile.am, src/vm/jit/mips/linux/Makefile.am, + src/vm/jit/mips/md-abi.h, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/linux/md-abi.h: + * src/vm/builtin.c (builtin_trace_args): Renamed to + builtin_verbosecall_enter. (builtin_trace_args): Renamed to + builtin_verbosecall_enter. (builtin_displaymethodstop): Renamed to + builtin_verbosecall_exit and changed signature. + * src/vm/builtin.h: Likewise. + + * src/vm/jit/arm/emit.c (emit_verbosecall_enter): Likewise. + (builtin_verbosecall_exit): Likewise. + * src/vm/jit/alpha/emit.c: Likewise. + * src/vm/jit/i386/emit.c: Likewise. + * src/vm/jit/mips/emit.c: Likewise. + * src/vm/jit/powerpc/emit.c: Likewise. + + * src/vm/jit/alpha/md-abi.h (REG_FA0, REG_FA1, REG_FA2): Added. + * src/vm/jit/mips/md-abi.h: Removed multiple defines. + * src/vm/jit/powerpc/linux/md-abi.h (REG_FA0, REG_FA1): Added. + (REG_A0_A1_PACKED): Likewise. + + * src/vm/jit/mips/linux/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + * src/vm/jit/mips/irix/Makefile.am: Likewise. + [07b4af4a23e6] + +2007-02-10 tbfg + + * src/mm/boehm.c, src/native/include/Makefile.am, src/native/native.c, + src/native/vm/cldc1.1/Makefile.am, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_Object.h, src/vm/exceptions.c, + src/vm/jit/alpha/md.c, src/vm/jit/i386/asmpart.S, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/powerpc64/patcher.c, src/vm/jit/s390/arch.h, + src/vmcore/class.h: + * src/vm/jit/powerpc64/linux/md-abi.c: Adopt changes include files. + + * src/vm/jit/powerpc64/emit.c: Likewise. + + * src/vm/jit/powerpc64/md.c: Likewise. + + * src/vm/jit/powerpc64/codegen.c: Likewise. Moved block closing + bracket. + + * src/vm/jit/powerpc64/patcher.c: Likewise. + + * src/vm/exceptions.c: new_arithmeticexception and + new_arrayindexoutofboundsexception prefixed by exceptions_. + [1cdc902a5ccf] + +2007-02-10 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md-abi.c, + src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c: + * src/vm/jit/sparc64/codegen.c (createnativestub): Fixed stack + argument passing. + + * src/vm/jit/sparc64/*: Adapted includes to new cacao structure. + [39f035e16f77] + +2007-02-10 pm + + * src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h: + * s390/codegen.c: fix: ICMD_FCMPL generated wrong branch offset + * s390/codegen.h: likewise + * s390/asmpart.S: fix: asm_call_jit_compiler did not remove stack + frame + [3937893d7ada] + + * src/vm/jit/s390/arch.h, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/patcher.c: + Continued work on S390 codegen. Affected files: + + * s390/codegen.c + * s390/codegen.h + * s390/arch.h + * s390/patcher.c + * s390/asmpart.S + [baf322e0ebc6] + +2007-02-09 twisti + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/linux/md-abi.c, + src/vm/jit/powerpc64/linux/md-os.c, src/vm/jit/powerpc64/md.c, + src/vm/jit/powerpc64/patcher.c: + * src/vm/jit/powerpc64/linux/md-os.c: Fixed includes. + * src/vm/jit/powerpc64/linux/md-abi.c: Likewise. + * src/vm/jit/powerpc64/md.c: Likewise. + * src/vm/jit/powerpc64/codegen.c: Likewise. + * src/vm/jit/powerpc64/patcher.c: Likewise. + [66efde2212b2] + + * src/vm/jit/i386/asmpart.S: + * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): Added ; after + lock, Darwin's assembler requires that. (asm_compare_and_swap): + Likewise. + [29838e9abba1] + + * src/mm/boehm.c: + * src/mm/boehm.c [ENABLE_THREADS] (threads/native/threads.h): + Removed. + [7d3d2244cd52] + + * src/vm/jit/powerpc/darwin/Makefile.am, + src/vm/jit/powerpc/linux/Makefile.am, + src/vm/jit/powerpc/netbsd/Makefile.am: + * src/vm/jit/powerpc/linux/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + * src/vm/jit/powerpc/darwin/Makefile.am: Likewise. + * src/vm/jit/powerpc/netbsd/Makefile.am: Likewise. + [27b01b1e3b7e] + + * src/vm/vm.c, src/vmcore/class.h: + * src/vmcore/class.h (dummy_java_lang_Class): Added. (classinfo): + Use dummy_java_lang_Class. + * src/vm/vm.c (vm_create): Check dummy_java_lang_Class size. + [646f1b3bd20a] + + * src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h: + * src/native/vm/java_lang_Runtime.c [ENABLE_JAVASE] + (runFinalizersOnExit): Added. + * src/native/vm/java_lang_Runtime.h: Likewise. + + * src/native/vm/gnu/java_lang_VMRuntime.c (exit): Renamed argument + par1 to status. (runFinalizersOnExit): Call + _Jv_java_lang_Runtime_runFinalizersOnExit. + [f35f918c49c4] + + * src/native/include/Makefile.am, src/native/native.c, + src/native/vm/Makefile.am, src/native/vm/cldc1.1/Makefile.am, + src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c, + src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Class.h, + src/native/vm/java_lang_Object.h, src/native/vm/java_lang_Runtime.c, + src/native/vm/java_lang_Runtime.h, src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_throw_unsatisfiedlinkerror) + [!ENABLE_JAVASE]: Generate a java.lang.Error. + + * src/native/vm/cldc1.1/java_lang_Class.c (isInstance): Added. + (isAssignableFrom): Likewise. (isInterface): Likewise. (isArray): + Likewise. + + * src/native/vm/cldc1.1/java_lang_Object.c (hashCode): Likewise. + (notify): Likewise. (wait): Likewise. + + * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Smaller + implementation changes. (indexOf__II): Likewise. (lastIndexOf__II): + Likewise. (indexOf__I): Added. + + * src/native/vm/cldc1.1/java_lang_Thread.c: Header updated. + + * src/native/vm/cldc1.1/java_lang_Runtime.c (exitInternal): Fixed + signature. (freeMemory): Added. (totalMemory): Likewise. (gc): + Likewise. + + * src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c: New + file. + * src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c: + Likewise. + * src/native/vm/cldc1.1/Makefile.am (libnativevmcore_la_SOURCES): + Added com_sun_cldc_io_ResourceInputStream.c and + com_sun_cldc_io_j2me_socket_Protocol.c. + + * src/native/vm/java_lang_Runtime.c: New file. + * src/native/vm/java_lang_Runtime.h: Likewise. + * src/native/vm/Makefile.am (libnativevm_la_SOURCES): Added + java_lang_Runtime.c and java_lang_Runtime.h. + + + * src/native/vm/java_lang_Class.c: Un-ifdef some functions for CLDC. + * src/native/vm/java_lang_Class.h: Likewise. + + * src/native/vm/gnu/java_lang_VMRuntime.c + (native/vm/java_lang_Runtime.h): Added. (exit): Call + _Jv_java_lang_Runtime function. (freeMemory): Likewise. + (totalMemory): Likewise. (gc): Likewise. + + * src/native/vm/java_lang_Object.h [ENABLE_JAVASE] + (native/include/java_lang_Cloneable.h): Only available for JavaSE + configurations. + + * src/native/include/Makefile.am (JAVAME_CLDC1_1_HEADER_FILES): + Added com_sun_cldc_io_ResourceInputStream.h and + com_sun_cldc_io_j2me_socket_Protocol.h. + + * src/native/native.c (dummynativetable) [ENABLE_JAVAME_CLDC1_1]: + Added new functions. + [fbdb38a96c9f] + + * src/vm/jit/alpha/freebsd/Makefile.am, + src/vm/jit/alpha/linux/Makefile.am, src/vm/jit/alpha/md.c: + * src/vm/jit/alpha/md.c (vm/options.h): Changed to vmcore/options.h. + + * src/vm/jit/alpha/linux/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + * src/vm/jit/alpha/freebsd/Makefile.am: Likewise. + [693b7e76e960] + +2007-02-08 tbfg + + * src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h, + src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/ucontext.c, + src/vm/jit/i386/cygwin/ucontext.h, src/vm/jit/m68k/.cvsignore, + src/vm/jit/m68k/linux/.cvsignore, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/patcher.c: + * m68k/linux/.cvsignore: Added. + * m68k/.cvsignore: Added. + [cdf1b5289488] + +2007-02-08 michi + + * src/vm/jit/i386/cygwin/Makefile.am, src/vm/jit/i386/cygwin/md-asm.h, + src/vm/jit/i386/cygwin/md-os.c, src/vm/jit/i386/cygwin/ucontext.c, + src/vm/jit/i386/cygwin/ucontext.h: + * src/vm/jit/i386/cygwin/Makefile.am: Changed to unix fileformat. + * src/vm/jit/i386/cygwin/ucontext.h, + src/vm/jit/i386/cygwin/ucontext.c, src/vm/jit/i386/cygwin/md-os.c, + src/vm/jit/i386/cygwin/md-asm.h: Likewise. + [45fafa8afbb4] + +2007-02-08 twisti + + * src/vm/jit/i386/cygwin/Makefile.am, + src/vm/jit/i386/freebsd/Makefile.am, + src/vm/jit/i386/linux/Makefile.am: + * src/vm/jit/i386/linux/Makefile.am (AM_CPPFLAGS) Added + -I$(top_builddir)/src. + * src/vm/jit/i386/cygwin/Makefile.am: Likewise. + * src/vm/jit/i386/freebsd/Makefile.am: Likewise. + [466a8912874b] + +2007-02-07 pm + + * src/vm/jit/codegen-common.c, src/vm/jit/s390/asmpart.S, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/codegen.h, + src/vm/jit/s390/emit.c, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/patcher.c: + Continued work on S390 port. + java.lang.ClassLoader.getSystemClassLoader is now compiled, patched, + called and the patcher trigger compilation of another method. + + * jit/s390/emit.c: Likiwise. + * jit/s390/codegen.c: Likewise. + * jit/s390/codegen.h: Likewise. + * jit/s390/md-asm.h: Likewise. + * jit/s390/patcher.c: Likewise. + * jit/s390/asmpart.S: Likewise. + * jit/codegen-common.c: Likewise. + [592440195369] + +2007-02-07 tbfg + + * src/vm/jit/m68k/Makefile.am: + * src/vm/jit/m68k/Makefile.am (DIST_SUBDIRS): Removed uclinux, added + linux. + [f967fb516920] + + * configure.ac, src/mm/boehm-gc/include/private/gc_locks.h, + src/vm/jit/m68k/linux/Makefile.am, src/vm/jit/m68k/linux/md-abi.c, + src/vm/jit/m68k/linux/md-abi.h, src/vm/jit/m68k/linux/md-asm.h, + src/vm/jit/m68k/linux/md-os.c: + * src/vm/jit/m68k/linux/md-abi.c: Added. + * src/vm/jit/m68k/uclinux: Removed. + * src/mm/boehm-gc/include/private/gc_locks.h (GC_test_and_set): + Disabled, assembly does not work on coldfire. + * configure.ac: Enabled m68k builds. + [76b92aaedb38] + +2007-02-07 twisti + + * configure.ac, src/Makefile.am, src/cacao/Makefile.am, + src/cacao/cacao.c, src/cacaoh/Makefile.am, src/cacaoh/cacaoh.c, + src/cacaoh/headers.c, src/cacaoh/headers.h, src/lib/Makefile.am, + src/mm/Makefile.am, src/mm/boehm.c, src/mm/gc-common.h, + src/mm/memory.c, src/native/include/.cvsignore, + src/native/include/Makefile.am, + src/native/include/java_lang_Class.h, + src/native/include/java_lang_ClassLoader.h, + src/native/include/java_lang_Cloneable.h, + src/native/include/java_lang_Object.h, + src/native/include/java_lang_String.h, + src/native/include/java_lang_Thread.h, + src/native/include/java_lang_ThreadGroup.h, + src/native/include/java_lang_Throwable.h, + src/native/include/java_lang_VMThread.h, + src/native/include/java_lang_VMThrowable.h, + src/native/include/java_util_Properties.h, src/native/jni.c, + src/native/jni.h, src/native/native.c, src/native/native.h, + src/native/vm/Makefile.am, src/threads/native/Makefile.am, + src/threads/native/lock.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/threads/none/lock.h, + src/threads/none/threads.h, src/toolbox/Makefile.am, + src/toolbox/avl.c, src/toolbox/list.c, src/toolbox/logging.c, + src/toolbox/logging.h, src/vm/Makefile.am, src/vm/access.c, + src/vm/access.h, src/vm/annotation.c, src/vm/annotation.h, + src/vm/builtin.c, src/vm/builtin.h, src/vm/builtintable.inc, + src/vm/class.c, src/vm/class.h, src/vm/classcache.c, + src/vm/classcache.h, src/vm/descriptor.c, src/vm/descriptor.h, + src/vm/exceptions.c, src/vm/exceptions.h, src/vm/field.c, + src/vm/field.h, src/vm/finalizer.c, src/vm/hashtable.c, + src/vm/hashtable.h, src/vm/initialize.c, src/vm/initialize.h, + src/vm/jit/Makefile.am, src/vm/jit/abi.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/arch.h, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/codegen.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/linux/md-os.c, + src/vm/jit/alpha/md-abi.c, src/vm/jit/alpha/patcher.c, + src/vm/jit/asmpart.h, src/vm/jit/code.c, src/vm/jit/code.h, + src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/dseg.c, src/vm/jit/dseg.h, src/vm/jit/emit-common.c, + src/vm/jit/i386/arch.h, src/vm/jit/i386/asmpart.S, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/jit/i386 + /md-abi.c, src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/loop/graph.h, src/vm/jit/loop/loop.h, + src/vm/jit/mips/arch.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/disass.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-asm.h, + src/vm/jit/mips/md.c, src/vm/jit/mips/patcher.c, + src/vm/jit/optimizing/Makefile.am, src/vm/jit/optimizing/ifconv.c, + src/vm/jit/optimizing/ifconv.h, src/vm/jit/optimizing/profile.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/parisc/arch.h, + src/vm/jit/parse.c, src/vm/jit/powerpc/arch.h, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/powerpc64/arch.h, src/vm/jit/show.c, + src/vm/jit/sparc64/arch.h, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/stack.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/tools/Makefile.am, src/vm/jit/tools/genoffsets.c, + src/vm/jit/verify/typecheck-stackbased.c, + src/vm/jit/verify/typecheck.c, src/vm/jit/verify/typeinfo.c, + src/vm/jit/verify/typeinfo.h, src/vm/jit/x86_64/Makefile.am, + src/vm/jit/x86_64/arch.h, src/vm/jit/x86_64/codegen.c, + src/vm/jit/x86_64/codegen.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/md.c, + src/vm/jit/x86_64/patcher.c, src/vm/linker.c, src/vm/linker.h, + src/vm/loader.c, src/vm/loader.h, src/vm/method.c, src/vm/method.h, + src/vm/options.c, src/vm/options.h, src/vm/properties.c, + src/vm/properties.h, src/vm/references.h, src/vm/resolve.c, + src/vm/resolve.h, src/vm/rt-timing.c, src/vm/rt-timing.h, + src/vm/signal.c, src/vm/signallocal.h, src/vm/statistics.c, + src/vm/statistics.h, src/vm/string.c, src/vm/stringlocal.h, + src/vm/suck.c, src/vm/suck.h, src/vm/utf8.c, src/vm/utf8.h, + src/vm/vm.c, src/vm/zip.c, src/vm/zip.h: + * Merged with trunk. + [e840d73af6a9] + +2007-02-06 twisti + + * src/native/vm/cldc1.1/Makefile.am: + * src/native/vm/cldc1.1/Makefile.am: Updated header. + [ab6eb7c14e9b] + + * src/native/vm/cldc1.1/java_lang_String.c: + * src/native/vm/cldc1.1/java_lang_String.c (hashCode): Implemented. + (indexOf__II): Likewise. (lastIndexOf__II): Likewise. + [b527bef0a2f2] + + * src/threads/native/Makefile.am, src/vm/jit/x86_64/Makefile.am, + src/vm/jit/x86_64/freebsd/Makefile.am, + src/vm/jit/x86_64/linux/Makefile.am: + * src/threads/native/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + * src/vm/jit/x86_64/Makefile.am: Likewise. + * src/vm/jit/x86_64/linux/Makefile.am: Likewise. + * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise. + [e93ab8483e6b] + + * src/vm/jit/powerpc/codegen.c: + * src/vm/jit/powerpc/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef + profiling code. + [3f09fe8f17ae] + + * src/native/vm/Makefile.am: + * src/native/vm/Makefile.am (DIST_SUBDIRS): Added missing \. + [f9a03ea56104] + + * src/vm/jit/tools/genoffsets.c: + * src/vm/jit/tools/genoffsets.c (vm/jit/stacktrace.h): Not required, + removed. + [4c950490c9bb] + + * src/vm/jit/tools/Makefile.am: + * src/vm/jit/tools/Makefile.am: Cosmetic changes. + [28ac1f93fda5] + + * src/mm/Makefile.am, src/vm/Makefile.am, src/vm/jit/Makefile.am, + src/vm/jit/optimizing/Makefile.am: + * src/vm/jit/optimizing/Makefile.am (AM_CPPFLAGS): Added + -I$(top_builddir)/src. + * src/vm/jit/Makefile.am: Likewise. + * src/vm/Makefile.am: Likewise. + * src/mm/Makefile.am: Likewise. + [b769e2013034] + + * src/vm/jit/x86_64/freebsd/md-os.c, src/vm/jit/x86_64/linux/md-os.c: + * src/vm/jit/linux/md-os.c (thread_restartcriticalsection): Added + missing cast and pass pc to critical_find_restart_point. + * src/vm/jit/freebsd/md-os.c (thread_restartcriticalsection): + Likewise. + [304f206f98a4] + +2007-02-05 twisti + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (builtin_clone, builtin_isanysubclass) + (builtin_new): Keep compiler happy and return a value. + [7b6ed76f17e1] + + * src/vm/signallocal.h: + * src/vm/signallocal.h (vm/types.h): Added. (vm/global.h): Likewise. + [284179c96249] + + * configure.ac, src/vm/jit/x86_64/Makefile.am, + src/vm/jit/x86_64/freebsd/.cvsignore, + src/vm/jit/x86_64/freebsd/Makefile.am, src/vm/jit/x86_64/freebsd/md- + os.c: + * configure.ac (AC_CONFIG_FILES): Added + src/vm/jit/x86_64/freebsd/Makefile. + + * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added freebsd. + + * src/vm/jit/x86_64/freebsd/md-os.c: New file. + * src/vm/jit/x86_64/freebsd/Makefile.am: Likewise. + * src/vm/jit/x86_64/freebsd/.cvsignore: Likewise. + [f06962a27a47] + + * configure.ac, src/vm/jit/x86_64/Makefile.am, + src/vm/jit/x86_64/linux/.cvsignore, + src/vm/jit/x86_64/linux/Makefile.am, src/vm/jit/x86_64/linux/md- + os.c, src/vm/jit/x86_64/md.c: + * configure.ac (AC_CONFIG_FILES): Added + src/vm/jit/x86_64/linux/Makefile. + + * src/vm/jit/x86_64/Makefile.am (DIST_SUBDIRS): Added. (SUBDIRS): + Likewise. (libarch_la_LIBADD): Likewise. + + * src/vm/jit/x86_64/md.c (md_signal_handler_sigsegv) + (md_signal_handler_sigfpe, md_signal_handler_sigusr2) + (thread_restartcriticalsection): Removed. + + * src/vm/jit/x86_64/linux/md-os.c: New file. + * src/vm/jit/x86_64/linux/Makefile.am: Likewise. + * src/vm/jit/x86_64/linux/.cvsignore: Likewise. + [50fd3baf26ce] + +2007-02-04 pm + + * src/vm/jit/codegen-common.h, src/vm/jit/dseg.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/emit.c, src/vm/jit/s390 + /md-abi.c, src/vm/jit/s390/md-abi.h, src/vm/jit/s390/md-asm.h, + src/vm/jit/s390/md.c: + * jit/codegen-common.h: Enabled dseg_adddata for s390. + * jit/dseg.c: Likewise. + * jit/s390/md-abi.h: Continued work on s390 port. + * jit/s390/emit.c: Likewise. + * jit/s390/md.c: Likewise. + * jit/s390/codegen.c: Likewise. + * jit/s390/codegen.h: Likewise. + * jit/s390/md-asm.h: Likewise. + * jit/s390/asmpart.S: Likewise. + * jit/s390/md-abi.c: Likewise. + [39030922ab4c] + +2007-02-04 twisti + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_ExceptionDescribe): Fixed typo. + [ad6e18d9a2c9] + +2007-02-03 twisti + + * src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/codegen.h: + * src/vm/jit/x86_64/codegen.c (codegen) [ENABLE_PROFILING]: #ifdef + instrumentation code. (createnativestub) [ENABLE_PROFILING]: + Likewise. + + * src/vm/jit/x86_64/codegen.h [ENABLE_PROFILING] + (PROFILE_CYCLE_START) (PROFILE_CYCLE_STOP): Added #ifdef. + [222c9620051f] + + * src/native/jni.c, src/vm/builtin.c, src/vm/finalizer.c, + src/vm/signal.c: + * src/vm/builtin.c [ENABLE_THREADS] (threads/native/threads.h): + Removed. [ENABLE_THREADS] (threads/native/lock.h): Added. + (builtin_throw_exception): Use exceptions_set_exception. + + * src/vm/finalizer.c (finalizer_run): Likewise. + + * src/vm/signal.c (signal_start_thread): Use #warning instead of + #error (temporarily). + + * src/native/jni.c (_Jv_jni_invokeNative): Use + exceptions_get_exception, and exceptions_clear_exception. + (_Jv_JNI_ExceptionDescribe): Likewise. (_Jv_JNI_IsAssignableFrom): + Use exceptions_set_exception. (_Jv_JNI_ExceptionOccurred): Use + exceptions_get_exception. (_Jv_JNI_ExceptionCheck): Likewise. + (_Jv_JNI_ExceptionClear): Use exceptions_clear_exception. + [fed9851c2331] + +2007-02-02 twisti + + * src/vm/jit/i386/codegen.c: + * src/vm/jit/i386/codegen.c (codegen) [ENABLE_PROFILING]: Profiling + code. (createnativestub): Likewise. + [7a50687ad4fa] + + * src/native/vm/java_lang_Object.c: + * src/native/vm/java_lang_Object.c [ENABLE_JAVAME_CLDC1_1] + (native/include/java_lang_String.h): Added. + [fd01a1f6bbed] + + * src/native/vm/java_lang_Class.h: + * src/native/vm/java_lang_Class.h + (native/include/java_lang_String.h): Required by java_lang_Class.h + for Java ME. + [f4ce4816ce07] + +2007-02-02 michi + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.h: + * src/vm/jit/arm/md-abi.h: Renamed REG_IP to REG_PV (special favor + for twisti). + * src/vm/jit/arm/emit.c, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h: Adapted to the above change. + [09cb587627a5] + +2007-02-02 twisti + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_compile_intern) [ENABLE_PROFILING]: Call + reorder only when profiling. + [b82b4ffef10b] + + * src/vm/jit/code.h, src/vm/jit/jit.c: + * src/vm/jit/code.h (codeinfo) [ENABLE_PROFILING]: Made frequency, + bbfrequency, and cycles conditional. + + * src/vm/jit/jit.c (jit_compile) [ENABLE_PROFILING]: Likewise. + (jit_compile_intern) [ENABLE_PROFILING]: Likewise. + [aefa55d03b45] + + * src/vm/jit/optimizing/Makefile.am: + * src/vm/jit/optimizing/Makefile.am [ENABLE_PROFILING] + (REORDER_SOURCES): Moved here till we have something better. + [0d4c94194c02] + +2007-02-01 twisti + + * src/vmcore/suck.c: + * src/vmcore/suck.c (assert.h): Added. (suck_float): Use assert + instead of an exception. (suck_double): Likewise. + [307597c08f3e] + + * src/vmcore/linker.c: + * src/vmcore/linker.c (link_class_intern): Also align double and s8 + fields to 4-bytes for ARM. + [bd695dd70df6] + + * src/vm/exceptions.c, src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vmcore/utf8.c (utf_java_lang_InvocationTargetException): Is + actually called utf_java_lang_reflect_InvocationTargetException. + (utf8_init): Likewise. + + * src/vmcore/utf8.h (utf_java_lang_InvocationTargetException): + Likewise. + + * src/vm/exceptions.c (exceptions_throw_invocationtargetexception): + Likewise. + [27db8a25b0c5] + + * src/vm/jit/code.c: + * src/vm/jit/code.c [ENABLE_THREADS] (threads/native/lock.h): Added. + [5c7f3502d8dc] + + * src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/jit.c, + src/vm/jit/jit.h, src/vmcore/loader.c, src/vmcore/method.h: + * src/vmcore/method.h (methodinfo): Removed member object. + * src/vm/jit/code.h (codeinfo): Added member object. + + * src/vmcore/loader.c (loader_load_method): Removed + lock_init_object_lock. (load_newly_created_array): Likewise. + * src/vm/jit/code.c (code_codeinfo_new): Added lock_init_object_lock. + + * src/vm/jit/jit.c (jit_jitdata_new): Changed signature. + (jit_compile): Use codeinfo lock object instead of methodinfo. + (jit_recompile): Changed signature. + * src/vm/jit/jit.h (jit_jitdata_new): Likewise. + [b10236223add] + +2007-01-31 twisti + + * src/cacaoh/dummy.c: + * src/cacaoh/dummy.c (pthread.h): Added. + [9e9bd911a22a] + + * src/cacaoh/dummy.c, src/toolbox/logging.c: + * src/toolbox/logging.c (log_start): Uncommented thread pointer + stuff. + * src/cacaoh/dummy.c (threads_get_current_threadobject): Added. + [edfa159dd432] + + * src/native/jni.c: + * src/native/jni.c (_Jv_JNI_ThrowNew): Fixed warnings. + [2e98f9533278] + + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: Updated + year. + [5972b844a2f3] + + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (string.h): + Added. (mm/memory.h): Likewise. + [932a77fd8583] + + * src/vmcore/loader.c: + * src/vmcore/loader.c (load_newly_created_array) [ENABLE_JAVASE]: + Fixed interfacescount. + [2e8984fe366c] + + * src/vm/exceptions.c, src/vm/exceptions.h: + * src/vm/exceptions.c [ENABLE_JAVAME_CLDC1_1](exceptions_new_error): + New function. (exceptions_asm_new_abstractmethoderror) + [!ENABLE_JAVASE]: Use exceptions_new_error. + (exceptions_throw_virtualmachineerror): Removed. + * src/vm/exceptions.h (exceptions_throw_virtualmachineerror): + Likewise. + [5b39ee72f613] + + * src/vm/jit/Makefile.am: + * src/vm/jit/Makefile.am: Fixed !ENABLE_VERIFER build. + [f7b45962f8d0] + +2007-01-30 twisti + + * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/emit.c, src/vm/jit/arm/md- + abi.c, src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md.c, + src/vm/jit/arm/patcher.c: + * src/vm/jit/arm/emit.c (mm/memory.h): Added. (vm/global.h): + Likewise. (emit_patcher_stubs): Align stack to 8-byte. + (emit_verbosecall_exit): Smaller optimizations. + + * src/vm/jit/arm/md-abi.h (config.h): Added. (REG_A1_A2_PACKED): + Defined. + + * src/vm/jit/arm/md.c: Fixed includes. (md_codegen_get_pv_from_pc): + Use vm_abort. + + * src/vm/jit/arm/codegen.c: Fixed includes. (codegen): Align stack + to 8-byte. (createnativestub): Likewise. + + * src/vm/jit/arm/codegen.h (M_ADD_IMM_EXT_MUL4): Added do-while. + (M_SUB_IMM_EXT_MUL4): Likewise. + + * src/vm/jit/arm/patcher.c: Fixed includes. (patcher_wrapper): Align + stack to 8-byte. + * src/vm/jit/arm/asmpart.S (asm_patcher_wrapper): Likewise. + + * src/vm/jit/arm/md-abi.c: Fixed includes. + [0a30c3d70337] + + * src/vm/signal.c, src/vm/vm.c: + * src/vm/signal.c (signal_init): Disable signal-thread handling + temporarily. + * src/vm/vm.c (vm_create): Likewise. + [7f75f5c44e54] + +2007-01-29 twisti + + * src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/java_lang_Class.c, src/vm/properties.c, + src/vm/string.c, src/vmcore/class.c, src/vmcore/resolve.c, + src/vmcore/utf8.c, src/vmcore/utf8.h: + * src/vm/string.c (native/jni.h): Added. + * src/vm/properties.c (native/jni.h): Likewise. + + * src/native/vm/cldc1.1/java_lang_Runtime.c: Includes fixed for + cacaoh-changes. + * src/native/vm/cldc1.1/java_lang_Class.c: Likewise. + + * src/native/vm/java_lang_Class.c [ENABLE_JAVAME_CLDC1_1] + (native/include/java_lang_String.h): Added. (forName): #ifdef'd + loader variable. + + * src/vmcore/class.c (class_resolveclassmethod): Removed Java ME + exception handling, we do that in the exception function itself. + (class_resolveinterfacemethod): Likewise. + * src/vmcore/resolve.c (resolve_method_invokespecial): Likewise. + + * src/vmcore/utf8.c [ENABLE_JAVASE] + (utf_java_lang_AbstractMethodError, utf_java_lang_NoSuchFieldError) + (utf_java_lang_NoSuchMethodError): Removed ifdef. + * src/vmcore/utf8.h: Likewise. + [882a47a8b48a] + +2007-01-29 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c: + * src/vm/jit/sparc64/codegen.h: Fixed double register number packing + and fp compare instruction macros. + * src/vm/jit/sparc64/codegen.c: Fixed fp compares. Fixed INT2CHAR. + Fixed fp argument saving in createnativestub(). + + * src/vm/jit/sparc64/patcher.c: Implemented get/put field patcher. + + * src/vm/jit/sparc64/md.c: Removed printf. + [402167948fee] + +2007-01-29 twisti + + * src/vm/jit/i386/codegen.c, src/vm/jit/i386/emit.c, src/vm/jit/i386 + /md-abi.c, src/vm/jit/i386/md.c, src/vm/jit/i386/patcher.c: + * src/vm/jit/i386/emit.c: Includes fixed for cacaoh-changes. + * src/vm/jit/i386/md.c: Likewise. + * src/vm/jit/i386/codegen.c: Likewise. + * src/vm/jit/i386/patcher.c: Likewise. + * src/vm/jit/i386/md-abi.c: Likewise. + [0b43a2caf86d] + + * src/vm/jit/i386/asmpart.S: + * src/vm/jit/i386/asmpart.S (asm_compare_and_swap): New function. + (asm_memory_barrier): Likewise. + [4baa01211589] + + * src/vm/jit/alpha/asmpart.S: + * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): Changed + comment. + [edf7afa4a623] + + * src/vm/jit/mips/codegen.c, src/vm/jit/mips/disass.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/patcher.c: + * src/vm/jit/mips/emit.c: Include fixes for cacaoh-changes. + * src/vm/jit/mips/md.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise + * src/vm/jit/mips/linux/md-os.c: Likewise + * src/vm/jit/mips/disass.c: Likewise + * src/vm/jit/mips/patcher.c: Likewise + * src/vm/jit/mips/md-abi.c: Likewise + [5075d26aabb8] + + * src/vm/jit/alpha/codegen.c, src/vm/jit/alpha/emit.c, + src/vm/jit/alpha/linux/md-os.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/alpha/patcher.c: + * src/vm/jit/alpha/emit.c: Fixed includes for cacaoh-changes. + * src/vm/jit/alpha/codegen.c: Likewise. + * src/vm/jit/alpha/linux/md-os.c: Likewise. + * src/vm/jit/alpha/patcher.c: Likewise. + * src/vm/jit/alpha/md-abi.c: Likewise. + [65984e7b13d1] + + * src/native/include/.cvsignore: + * src/native/include/.cvsignore: Ignore all *.h files. + [afcbe578518b] + + * src/vm/jit/x86_64/md.c: + * src/vm/jit/x86_64/md.c: Fixed includes for cacaoh-changes. + [900dc7622fe5] + + * src/vm/jit/x86_64/codegen.c, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md-abi.c, src/vm/jit/x86_64/patcher.c: + * src/vm/jit/x86_64/emit.c: Fixed includes for cacaoh-changes. + * src/vm/jit/x86_64/codegen.c: Likewise. + * src/vm/jit/x86_64/patcher.c: Likewise. + * src/vm/jit/x86_64/md-abi.c: Likewise. + [16d9eafe63cc] + + * src/vm/jit/emit-common.c, src/vm/jit/jit.c, src/vmcore/stackmap.c: + * src/vmcore/stackmap.c [ENABLE_STATISTICS] (vmcore/statistics.h): + Removed ifdef. + * src/vm/jit/jit.c: Likewise. + * src/vm/jit/emit-common.c: Likewise. + [d184eba61575] + + * configure.ac, src/Makefile.am, src/cacao/Makefile.am, + src/cacaoh/Makefile.am, src/cacaoh/cacaoh.c, src/cacaoh/dummy.c, + src/cacaoh/headers.c, src/cacaoh/headers.h, src/mm/Makefile.am, + src/mm/boehm.c, src/mm/gc-common.h, src/mm/memory.c, + src/native/include/Makefile.am, + src/native/include/java_lang_Class.h, + src/native/include/java_lang_ClassLoader.h, + src/native/include/java_lang_Cloneable.h, + src/native/include/java_lang_Object.h, + src/native/include/java_lang_String.h, + src/native/include/java_lang_Thread.h, + src/native/include/java_lang_ThreadGroup.h, + src/native/include/java_lang_Throwable.h, + src/native/include/java_lang_VMThread.h, + src/native/include/java_lang_VMThrowable.h, + src/native/include/java_util_Properties.h, src/native/jni.c, + src/native/jni.h, src/native/native.c, src/native/native.h, + src/native/vm/gnu/gnu_classpath_VMStackWalker.c, + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, src/native/vm/ + gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c, + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c, + src/native/vm/gnu/java_lang_VMClass.c, + src/native/vm/gnu/java_lang_VMClassLoader.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMThrowable.c, + src/native/vm/gnu/java_lang_management_VMManagementFactory.c, + src/native/vm/gnu/java_lang_reflect_Constructor.c, + src/native/vm/gnu/java_lang_reflect_Field.c, + src/native/vm/gnu/java_lang_reflect_Method.c, + src/native/vm/gnu/java_security_VMAccessController.c, + src/native/vm/java_lang_Class.c, src/native/vm/java_lang_Object.c, + src/native/vm/java_lang_Thread.c, src/threads/native/lock.c, + src/threads/native/threads.c, src/threads/native/threads.h, + src/threads/none/lock.h, src/threads/none/threads.h, + src/toolbox/Makefile.am, src/toolbox/avl.c, src/toolbox/hashtable.c, + src/toolbox/hashtable.h, src/toolbox/list.c, src/toolbox/logging.c, + src/toolbox/logging.h, src/vm/Makefile.am, src/vm/access.c, + src/vm/access.h, src/vm/annotation.c, src/vm/annotation.h, + src/vm/builtin.c, src/vm/builtin.h, src/vm/class.c, src/vm/class.h, + src/vm/classcache.c, src/vm/classcache.h, src/vm/descriptor.c, + src/vm/descriptor.h, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/field.c, src/vm/field.h, src/vm/finalizer.c, + src/vm/hashtable.c, src/vm/hashtable.h, src/vm/initialize.c, + src/vm/initialize.h, src/vm/jit/abi.h, + src/vm/jit/allocator/simplereg.c, src/vm/jit/asmpart.h, + src/vm/jit/code.c, src/vm/jit/code.h, src/vm/jit/codegen-common.c, + src/vm/jit/codegen-common.h, src/vm/jit/dseg.c, src/vm/jit/dseg.h, + src/vm/jit/emit-common.c, src/vm/jit/jit.c, src/vm/jit/jit.h, + src/vm/jit/loop/graph.h, src/vm/jit/loop/loop.h, + src/vm/jit/optimizing/ifconv.c, src/vm/jit/optimizing/ifconv.h, + src/vm/jit/optimizing/profile.c, src/vm/jit/optimizing/recompile.c, + src/vm/jit/parse.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/linux/md-abi.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc/patcher.c, + src/vm/jit/show.c, src/vm/jit/stack.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vm/jit/tools/genoffsets.c, + src/vm/jit/verify/typecheck-stackbased.c, src/vm/jit/verify + /typecheck-typeinferer.c, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typeinfo.c, src/vm/jit/verify/typeinfo.h, + src/vm/linker.c, src/vm/linker.h, src/vm/loader.c, src/vm/loader.h, + src/vm/method.c, src/vm/method.h, src/vm/options.c, + src/vm/options.h, src/vm/properties.c, src/vm/properties.h, + src/vm/references.h, src/vm/resolve.c, src/vm/resolve.h, src/vm/rt- + timing.c, src/vm/rt-timing.h, src/vm/signal.c, src/vm/signallocal.h, + src/vm/stackmap.c, src/vm/stackmap.h, src/vm/statistics.c, + src/vm/statistics.h, src/vm/string.c, src/vm/stringlocal.h, + src/vm/suck.c, src/vm/suck.h, src/vm/utf8.c, src/vm/utf8.h, + src/vm/vm.c, src/vm/zip.c, src/vm/zip.h, src/vmcore/.cvsignore, + src/vmcore/Makefile.am, src/vmcore/annotation.c, + src/vmcore/annotation.h, src/vmcore/class.c, src/vmcore/class.h, + src/vmcore/classcache.c, src/vmcore/classcache.h, + src/vmcore/descriptor.c, src/vmcore/descriptor.h, + src/vmcore/field.c, src/vmcore/field.h, src/vmcore/linker.c, + src/vmcore/linker.h, src/vmcore/loader.c, src/vmcore/loader.h, + src/vmcore/method.c, src/vmcore/method.h, src/vmcore/options.c, + src/vmcore/options.h, src/vmcore/references.h, src/vmcore/resolve.c, + src/vmcore/resolve.h, src/vmcore/rt-timing.c, src/vmcore/rt- + timing.h, src/vmcore/stackmap.c, src/vmcore/stackmap.h, + src/vmcore/statistics.c, src/vmcore/statistics.h, src/vmcore/suck.c, + src/vmcore/suck.h, src/vmcore/utf8.c, src/vmcore/utf8.h, + src/vmcore/zip.c, src/vmcore/zip.h: + * This is a rather huge commit, which changes the build order of + various parts to be able to bootstrap cacaoh without any + dependencies on a generated header file. I include the file list + from SVN, so we can see what happened to the files. + + Here we go (D-files were mostly moved to src/vmcore): + + D src/vm/hashtable.h D src/vm/options.h M + src/vm/properties.h D src/vm/zip.c D src/vm/class.c D + src/vm/suck.c D src/vm/loader.c M src/vm/builtin.c M + src/vm/string.c D src/vm/zip.h D src/vm/class.h D src/vm + /rt-timing.c D src/vm/suck.h D src/vm/annotation.c M + src/vm/builtin.h D src/vm/loader.h D src/vm/descriptor.c D + src/vm/annotation.h D src/vm/rt-timing.h D src/vm/resolve.c D + src/vm/method.c D src/vm/descriptor.h M src/vm/finalizer.c D + src/vm/resolve.h D src/vm/method.h D src/vm/references.h D + src/vm/classcache.c D src/vm/statistics.c D + src/vm/classcache.h D src/vm/statistics.h M + src/vm/initialize.c M src/vm/access.c D src/vm/stackmap.c M + src/vm/jit/powerpc/linux/md-abi.c M src/vm/jit/powerpc/emit.c M + src/vm/jit/powerpc/md.c M src/vm/jit/powerpc/codegen.c M + src/vm/jit/powerpc/patcher.c M src/vm/jit/codegen-common.h M + src/vm/jit/abi.h M src/vm/jit/stack.c M + src/vm/jit/optimizing/profile.c M + src/vm/jit/optimizing/recompile.c M + src/vm/jit/optimizing/ifconv.c M src/vm/jit/optimizing/ifconv.h M + src/vm/jit/code.c M src/vm/jit/tools/genoffsets.c M + src/vm/jit/code.h M src/vm/jit/show.c M src/vm/jit/dseg.c M + src/vm/jit/verify/typeinfo.h M src/vm/jit/verify/typecheck- + typeinferer.c M src/vm/jit/verify/typecheck.c M + src/vm/jit/verify/typecheck-stackbased.c M + src/vm/jit/verify/typeinfo.c M src/vm/jit/dseg.h M + src/vm/jit/loop/loop.h M src/vm/jit/loop/graph.h M + src/vm/jit/allocator/simplereg.c M src/vm/jit/parse.c M + src/vm/jit/asmpart.h M src/vm/jit/stacktrace.c M src/vm/jit + /emit-common.c M src/vm/jit/jit.c M src/vm/jit/stacktrace.h M + src/vm/jit/codegen-common.c M src/vm/jit/jit.h M + src/vm/initialize.h M src/vm/access.h D src/vm/stackmap.h M + src/vm/signal.c M src/vm/exceptions.c M src/vm/vm.c D + src/vm/field.c D src/vm/linker.c M src/vm/exceptions.h M + src/vm/stringlocal.h D src/vm/utf8.c D src/vm/field.h M + src/vm/Makefile.am D src/vm/linker.h D src/vm/hashtable.c D + src/vm/options.c D src/vm/utf8.h M src/vm/properties.c M + src/vm/signallocal.h M src/cacao/Makefile.am M + src/native/jni.c M src/native/vm/java_lang_Class.c M + src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c M + src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c M + src/native/vm/gnu/java_security_VMAccessController.c M + src/native/vm/gnu/java_lang_VMClassLoader.c M + src/native/vm/gnu/java_lang_management_VMManagementFactory.c M + src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c M + src/native/vm/gnu/java_lang_VMClass.c M + src/native/vm/gnu/java_lang_VMThread.c M + src/native/vm/gnu/gnu_classpath_VMSystemProperties.c M + src/native/vm/gnu/java_lang_reflect_Method.c M + src/native/vm/gnu/java_lang_VMRuntime.c M + src/native/vm/gnu/java_lang_reflect_Field.c M + src/native/vm/gnu/gnu_classpath_VMStackWalker.c M src/native/vm/g + nu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c M + src/native/vm/gnu/java_lang_reflect_Constructor.c M + src/native/vm/gnu/java_lang_VMThrowable.c M + src/native/vm/java_lang_Object.c M + src/native/vm/java_lang_Thread.c D + src/native/include/java_lang_Thread.h D + src/native/include/java_lang_Throwable.h D + src/native/include/java_util_Properties.h D + src/native/include/java_lang_VMThread.h D + src/native/include/java_lang_VMThrowable.h D + src/native/include/java_lang_ClassLoader.h M + src/native/include/Makefile.am D + src/native/include/java_lang_Cloneable.h D + src/native/include/java_lang_ThreadGroup.h D + src/native/include/java_lang_Class.h D + src/native/include/java_lang_Object.h D + src/native/include/java_lang_String.h M src/native/jni.h M + src/native/native.c M src/native/native.h A + src/toolbox/hashtable.h M src/toolbox/list.c M + src/toolbox/avl.c M src/toolbox/logging.c M + src/toolbox/Makefile.am M src/toolbox/logging.h A + src/toolbox/hashtable.c M src/mm/gc-common.h M + src/mm/Makefile.am M src/mm/memory.c M src/mm/boehm.c M + src/Makefile.am M src/threads/none/threads.h M + src/threads/none/lock.h M src/threads/native/threads.h M + src/threads/native/lock.c M src/threads/native/threads.c AM + src/vmcore A src/vmcore/options.h A src/vmcore/zip.c A + src/vmcore/suck.c A src/vmcore/class.c A src/vmcore/loader.c A + src/vmcore/zip.h A src/vmcore/annotation.c A src/vmcore/suck.h + A src/vmcore/class.h A src/vmcore/rt-timing.c A + src/vmcore/loader.h A src/vmcore/descriptor.c A + src/vmcore/resolve.c A src/vmcore/annotation.h A src/vmcore + /rt-timing.h A src/vmcore/method.c A src/vmcore/descriptor.h A + src/vmcore/resolve.h A src/vmcore/method.h A + src/vmcore/references.h A src/vmcore/classcache.c A + src/vmcore/statistics.c A src/vmcore/.cvsignore A + src/vmcore/classcache.h A src/vmcore/statistics.h A + src/vmcore/stackmap.c A src/vmcore/stackmap.h A + src/vmcore/field.c A src/vmcore/linker.c A src/vmcore/utf8.c A + src/vmcore/field.h A src/vmcore/Makefile.am A + src/vmcore/linker.h A src/vmcore/options.c A src/vmcore/utf8.h + M src/cacaoh/cacaoh.c M src/cacaoh/headers.h M + src/cacaoh/Makefile.am M src/cacaoh/headers.c A + src/cacaoh/dummy.c M configure.ac + [0fc2b6dcc07b] + + * src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c [ENABLE_SOFTFLOAT] (emit_load): Implemented. + (emit_store): Changed implementation to be more clear. (emit_copy): + Likewise. + [fe8afee04ad9] + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (codegen): ICMD_DASTORE: bugfix for + softfloat. + [91314a82783b] + +2007-01-28 twisti + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (createcompilerstub): Don't generate a + codeinfo. + [2fde0f1e0334] + + * src/vm/jit/arm/codegen.c: + * src/vm/jit/arm/codegen.c (createcompilerstub): Don't generate a + codeinfo. + [e3b34887588a] + +2007-01-27 twisti + + * configure.ac, m4/soft.m4, src/vm/builtin.c, src/vm/builtintable.inc, + src/vm/jit/alpha/arch.h, src/vm/jit/arm/arch.h, + src/vm/jit/i386/arch.h, src/vm/jit/m68k/arch.h, + src/vm/jit/mips/arch.h, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/patcher.c, src/vm/jit/parisc/arch.h, + src/vm/jit/powerpc/arch.h, src/vm/jit/powerpc64/arch.h, + src/vm/jit/s390/arch.h, src/vm/jit/sparc64/arch.h, + src/vm/jit/x86_64/arch.h: + * configure.ac: Use AC_CHECK_SOFTFLOAT, AC_CHECK_SOFT_FLOAT_CMP and + AC_CHECK_SOFT_DOUBLE_CMP. + * m4/soft.m4: New file. + + * src/vm/builtin.c [!SUPPORT_FLOAT_CMP] (builtin_fcmpl): Added + conditional. [!SUPPORT_DOUBLE_CMP] (builtin_dcmpl): Likewise. + + * src/vm/builtintable.inc (builtintable_automatic): + [!SUPPORT_FLOAT_CMP] (BUILTIN_fcmpl): Added. [!SUPPORT_DOUBLE_CMP] + (BUILTIN_dcmpl): Likewise. (builtintable_function): [__MIPS__ && + SIZEOF_VOID_P != 4] (BUILTIN_arraycopy): Added. + + * src/vm/jit/mips/codegen.c (codegen): Added SUPPORT_FLOAT_CMP for + ICMD_FCMPx, and SUPPORT_DOUBLE_CMP for ICMD_DCMPx. + + * src/vm/jit/arm/arch.h (SUPPORT_FLOAT_CMP, SUPPORT_DOUBLE_CMP): + Added. + * src/vm/jit/powerpc/arch.h: Likewise. + * src/vm/jit/sparc64/arch.h: Likewise. + * src/vm/jit/alpha/arch.h: Likewise. + * src/vm/jit/s390/arch.h: Likewise. + * src/vm/jit/mips/arch.h: Likewise. + * src/vm/jit/parisc/arch.h: Likewise. + * src/vm/jit/m68k/arch.h: Likewise. + * src/vm/jit/i386/arch.h: Likewise. + * src/vm/jit/powerpc64/arch.h: Likewise. + * src/vm/jit/x86_64/arch.h: Likewise. + + * src/vm/jit/mips/patcher.c (vm/jit/md.h): Added. + [0030ae40a5f0] + + * src/vm/loader.c: + * src/vm/loader.c (load_newly_created_array): c->interfacescount was + always set to 0, fixed. + [c583dcb762a3] + +2007-01-27 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/linux/md-os.c, + src/vm/jit/sparc64/md.c: + * src/vm/jit/sparc64/emit.c: Moved exception check generation to + emit functions. + * src/vm/jit/sparc64/codegen.h: Likewise. + * src/vm/jit/sparc64/codegen.c: Likewise. + + * src/vm/jit/sparc64/md.c: Added SPARC specific functions for + getting JIT information from the stack frame. + + * src/vm/jit/sparc64/linux/md-os.c: Fixed icache flushing when start + address is not doubleword aligned. + [2bd4d44bd3c0] + +2007-01-23 twisti + + * src/vm/jit/mips/emit.c: + * src/vm/jit/mips/emit.c (emit_patcher_stubs): Use + dseg_add_functionptr instead of dseg_add_address. + [0d1711cc34aa] + +2007-01-22 twisti + + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c: + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit): + Added missing file://. + [cd2249587a11] + + * src/cacao/cacao.c: + * src/cacao/cacao.c (main): Fixed typo. + [543a7a5860cb] + + * src/lib/Makefile.am, + src/lib/vm/reference/gnu/classpath/VMSystemProperties.java, + src/native/include/Makefile.am: + * src/lib/vm/reference/gnu/classpath/VMSystemProperties.java: New + file. + + * src/lib/Makefile.am (VM_JAVA_FILES): Added + gnu/classpath/VMSystemProperties.java. (VM_CLASS_FILES): Likewise. + + * src/native/include/Makefile.am (VM_ZIP): Added. (DO_HEADER_FILES): + Depend on VM_ZIP. + [cd1a96682531] + + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c, + src/vm/properties.c, src/vm/properties.h: + * src/vm/properties.c (properties_get): Search list forward, as we + don't have duplicate entries anymore. (properties_system_add): New + function. + * src/vm/properties.h (properties_system_add): Added. + + * src/native/vm/gnu/gnu_classpath_VMSystemProperties.c (postInit): + New function. + [67978ad263eb] + + * src/vm/jit/mips/md.c: + * src/vm/jit/mips/md.c (md_get_method_patch_address): Fixed compiler + warning. + [3091559d5e74] + + * src/cacao/cacao.c: + * src/cacao/cacao.c (main): Fixed compiler warning. + [d5e2cb977df7] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/patcher.c: + * src/vm/jit/arm/codegen.c (vm/jit/md.h): Added. + * src/vm/jit/arm/patcher.c (vm/jit/md.h): Likewise. + [0b8f6c2eab9d] + +2007-01-22 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h: + * src/vm/jit/sparc64/codegen.h: Fixed big disp handling. + * src/vm/jit/sparc64/codegen.c: Likewise. + [a635998681c3] + +2007-01-22 twisti + + * src/vm/jit/Makefile.am, src/vm/jit/codegen-common.c, + src/vm/jit/jit.c, src/vm/jit/jit.h, src/vm/jit/md.h, src/vm/vm.c: + * src/vm/jit/jit.h (md_init, md_get_method_patch_address,) + (md_cacheflush, md_icacheflush, md_dcacheflush, intrp_md_init): + Removed. + + * src/vm/jit/md.h: New file. + * src/vm/jit/Makefile.am (noinst_HEADERS): Added md.h. + + * src/vm/jit/jit.c (vm/jit/md.h): Added. + * src/vm/jit/codegen-common.c (vm/jit/md.h): Likewise. + * src/vm/vm.c (vm/jit/md.h): Likewise. + [d390734ef98c] + +2007-01-19 edwin + + * configure.ac, src/cacaoh/headers.c, src/vm/exceptions.c, + src/vm/jit/inline/inline.c, src/vm/jit/jit.c, src/vm/linker.c, + src/vm/method.c, src/vm/options.c, src/vm/options.h, src/vm/vm.c: + * src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c, + src/vm/jit/jit.c, src/vm/vm.c, src/vm/linker.c, src/vm/options.c, + src/cacaoh/headers.c: Cleaned up inlining options. + + * src/vm/exceptions.c: Removed a left-over use of "useinlining". + + * configure.ac: New configure flag --enable-inlining-debug. + [566f6e517a77] + +2007-01-18 twisti + + * src/vm/jit/arm/asmpart.S, src/vm/jit/arm/md-asm.h: + * src/vm/jit/arm/md-asm.h: Renamed argument defines to start with 0. + * src/vm/jit/arm/asmpart.S: Likewise. + [2b341e5bb601] + + * src/vm/vm.c: + * src/vm/vm.c (usage): Removed CACAO options. (XXusage): New + function. (vm_create): Handle OPT_XX. + [28b7b97ae806] + + * src/vm/jit/powerpc/asmpart.S: + * src/vm/jit/powerpc/asmpart.S (asm_compare_and_swap): New function. + (asm_memory_barrier): Likewise. + [50cb34084654] + + * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/md-asm.h: + * src/vm/jit/mips/md-asm.h (RESTORE_ARGUMENT_REGISTERS) + (RESTORE_ARGUMENT_REGISTERS, SAVE_TEMPORARY_REGISTERS) + (RESTORE_TEMPORARY_REGISTERS): Added missing float registers. + + * src/vm/jit/mips/asmpart.S (asm_patcher_wrapper): Changed stack + size for float registers. + [a5ec1ec75994] + +2007-01-17 tbfg + + * src/vm/jit/powerpc64/codegen.c, src/vm/jit/powerpc64/emit.c, + src/vm/jit/powerpc64/linux/md-abi.h: + * src/vm/jit/powerpc64/linux/md-abi.h (REG_ZERO): Added. + + * src/vm/jit/powerpc64/emit.c (emit_replacement_stubs): + Conditionally compiled on ENABLE_REPLACEMENT. + + * src/vm/jit/powerpc64/codegen.c (codegen_emit): Replaced + emit_replacement_stubs with REPLACEMENT_EMIT_STUBS. + [e6ee875d25a7] + +2007-01-17 twisti + + * src/vm/exceptions.c: + * src/vm/exceptions.c (md-abi.h): Added. + [4bec4df1aab1] + + * src/vm/jit/codegen-common.c: + * src/vm/jit/codegen-common.c (codegen_reset): #ifdef replacement + stuff. + [1ecfc6ea6c0e] + + * configure.ac, src/cacaoh/headers.c, src/vm/jit/Makefile.am, + src/vm/jit/alpha/asmpart.S, src/vm/jit/asmpart.h, src/vm/jit/disass- + common.c, src/vm/jit/disass.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/x86_64/asmpart.S: + Merged with trunk rev7219. + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/disass-common.c, + src/vm/jit/s390, src/vm/jit/s390/emit.c, src/vm/jit/s390/md-abi.h, + src/vm/jit/s390/md.c, src/vm/jit/s390/emit.h, + src/vm/jit/s390/codegen.c, src/vm/jit/s390/machine-instr.h, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/arch.h, src/vm/jit/s390 + /md-asm.h, src/vm/jit/s390/disass.c, src/vm/jit/s390/patcher.c, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/Makefile.am, + src/vm/jit/s390/md-abi.c, src/vm/jit/s390/.cvsignore, + src/vm/jit/disass.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/asmpart.h, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/Makefile.am, src/cacaoh/headers.c, configure.ac: Merged. + [15381fe4a67f] + +2007-01-16 pm + + * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/disass-common.c, + src/vm/jit/disass.h, src/vm/jit/s390/.cvsignore, + src/vm/jit/s390/Makefile.am, src/vm/jit/s390/arch.h, + src/vm/jit/s390/asmpart.S, src/vm/jit/s390/codegen.c, + src/vm/jit/s390/codegen.h, src/vm/jit/s390/disass.c, + src/vm/jit/s390/emit.c, src/vm/jit/s390/emit.h, src/vm/jit/s390 + /machine-instr.h, src/vm/jit/s390/md-abi.c, src/vm/jit/s390/md- + abi.h, src/vm/jit/s390/md-asm.h, src/vm/jit/s390/md.c, + src/vm/jit/s390/patcher.c: + Initial import of s390 codegen, codebase is copyed from x86_64. + [c5d44fda5516] + +2007-01-16 twisti + + * src/cacaoh/headers.c: + * src/cacaoh/headers.c (asm_compare_and_swap): Added. + (asm_memory_barrier): Likewise. + [ced478ee11d0] + + * src/vm/jit/x86_64/asmpart.S: + * src/vm/jit/x86_64/asmpart.S (asm_patcher_wrapper): Removed unused + sizestackframeinfo. + [6aaa22b2b309] + + * src/vm/jit/alpha/asmpart.S, src/vm/jit/asmpart.h: + * src/vm/jit/asmpart.h (asm_compare_and_swap): Added. + (asm_memory_barrier): Likewise. + + * src/vm/jit/alpha/asmpart.S (asm_compare_and_swap): New function. + (asm_memory_barrier): Likewise. + [8a11edfc6695] + +2007-01-15 twisti + + * src/vm/jit/powerpc64/codegen.c: + * src/vm/jit/powerpc64/codegen.c (codegen): Ported replacement. + [1b31182b8fdf] + + * configure.ac, src/cacaoh/cacaoh.c, src/cacaoh/headers.c, + src/mm/boehm.c, src/mm/memory.c, src/native/native.c, + src/vm/builtin.c, src/vm/classcache.c, src/vm/descriptor.c, + src/vm/exceptions.c, src/vm/exceptions.h, src/vm/jit/Makefile.am, + src/vm/jit/allocator/liveness.c, src/vm/jit/allocator/lsra.c, + src/vm/jit/allocator/simplereg.c, src/vm/jit/alpha/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/inline/inline.c, + src/vm/jit/inline/inline_debug.inc, src/vm/jit/intrp/codegen.c, + src/vm/jit/jit.c, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h, + src/vm/jit/mips/emit.c, src/vm/jit/mips/linux/md-os.c, + src/vm/jit/mips/md-abi.c, src/vm/jit/mips/md-abi.h, + src/vm/jit/mips/md.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md-abi.h, + src/vm/jit/sparc64/md.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/stack.c, src/vm/jit/tools/genoffsets.c, + src/vm/jit/verify/generate.pl, src/vm/jit/verify/typecheck- + builtins.inc, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/codegen.c, src/vm/loader.c, src/vm/rt-timing.c, + src/vm/rt-timing.h, src/vm/suck.c, src/vm/utf8.c, src/vm/vm.c: + Merged with trunk rev7206. + + * src/vm/suck.c, src/vm/loader.c, src/vm/builtin.c, src/vm/rt- + timing.c, src/vm/descriptor.c, src/vm/rt-timing.h, + src/vm/classcache.c, src/vm/jit/powerpc/codegen.c, src/vm/jit/arm, + src/vm/jit/arm/emit.c, src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md.c, + src/vm/jit/arm/codegen.c, src/vm/jit/arm/machine-instr.h, + src/vm/jit/arm/codegen.h src/vm/jit/arm/linux, src/vm/jit/arm/linux + /md-os.c, src/vm/jit/arm/linux/Makefile.am, + src/vm/jit/arm/linux/.cvsignore, src/vm/jit/arm/arch.h, + src/vm/jit/arm/md-asm.h, src/vm/jit/arm/disass.c, + src/vm/jit/arm/patcher.c, src/vm/jit/arm/asmpart.S, + src/vm/jit/arm/Makefile.am, src/vm/jit/arm/md-abi.c, + src/vm/jit/arm/.cvsignore, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/patcher.c, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/alpha/codegen.c, src/vm/jit/stack.c, + src/vm/jit/tools/genoffsets.c, src/vm/jit/verify/typecheck- + typeinferer-gen.inc, src/vm/jit/verify/typecheck-typeinferer.c, + src/vm/jit/verify/generate.pl, src/vm/jit/verify/typeinfo.c, + src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/mips/md-abi.h, + src/vm/jit/mips/emit.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/codegen.c, src/vm/jit/mips/codegen.h, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/md-abi.c, src/vm/jit/inline/inline.c, + src/vm/jit/inline/inline_debug.inc, src/vm/jit/allocator/lsra.c, + src/vm/jit/allocator/simplereg.c, src/vm/jit/allocator/liveness.c, + src/vm/jit/parisc/linux/Makefile.am, src/vm/jit/m68k, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/md.c, + src/vm/jit/m68k/arch.h, src/vm/jit/m68k/codegen.c, src/vm/jit/m68k + /machine-instr.h, src/vm/jit/m68k/patcher.c, + src/vm/jit/m68k/uclinux, src/vm/jit/m68k/uclinux/md-abi.h, + src/vm/jit/m68k/uclinux/md-os.c, src/vm/jit/m68k/uclinux/md-asm.h, + src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md- + abi.c, src/vm/jit/m68k/asmpart.S, src/vm/jit/m68k/Makefile.am, + src/vm/jit/m68k/codegen.h, src/vm/jit/powerpc64/codegen.c, + src/vm/jit/i386/codegen.c, src/vm/jit/intrp/codegen.c, + src/vm/jit/x86_64/codegen.c, src/vm/jit/jit.c, + src/vm/jit/Makefile.am, src/vm/exceptions.c, src/vm/vm.c, + src/vm/exceptions.h, src/vm/utf8.c, src/native/native.c, + src/mm/memory.c, src/mm/boehm.c, src/cacaoh/cacaoh.c, + src/cacaoh/headers.c, configure.ac: Merged. + [263e061c0f8d] + +2007-01-13 edwin + + * src/vm/jit/verify/typecheck-typeinferer.c: + * src/vm/jit/verify/typecheck-typeinferer.c: Check basic types in + debug mode. + [bc6ac49a2576] + + * src/vm/jit/verify/generate.pl, src/vm/jit/verify/typecheck- + typeinferer-gen.inc: + * src/vm/jit/verify/generate.pl: Further changes for the type + inferer. + + * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Regenerated. + [58d274e03303] + + * src/vm/rt-timing.c, src/vm/rt-timing.h: + * src/vm/rt-timing.h: Fixed position of #include "config.h". + (rt_timing_diff_usec): Export. + + * src/vm/rt-timing.c (rt_timing_diff_usec): Export. + [17a57a236451] + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_compile_intern): Removed unused code and + fixed instrumentation. + [d32067dc461e] + + * src/vm/jit/inline/inline.c, src/vm/jit/inline/inline_debug.inc: + * src/vm/jit/inline/inline.c: Better inlining decisions. Implemented + knapsack heuristics. More statistics. Refactoring and fixes. + + * src/vm/jit/inline/inline_debug.inc: Fixed to make it compile. + [2675b8465cc8] + +2007-01-13 ajordan + + * src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/codegen.h, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md-abi.h, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c: + * src/vm/jit/sparc64/md-abi.h: The JIT stackframes now also includes + the 6 parameter slots required when doing a ABI compliant C call. + * src/vm/jit/sparc64/emit.c: Likewise. + * src/vm/jit/sparc64/codegen.c: Likewise. + * src/vm/jit/sparc64/patcher.c: Likewise. + * src/vm/jit/sparc64/asmpart.S: Likewise. + + * src/vm/jit/sparc64/codegen.h: Added include. + + * src/vm/jit/sparc64/md.c: Added method, to get framepointer from + saved register window. (for temporary fix in JIT stack walking) + [8723d252337d] + +2007-01-12 twisti + + * src/vm/jit/arm/linux/md-os.c: + * src/vm/jit/arm/linux/md-os.c (md_signal_handler_sigsegv): Use + codegen_get_pv_from_pc. + [b14675eb67a8] + +2007-01-11 twisti + + * src/vm/jit/mips/asmpart.S, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/codegen.h, src/vm/jit/mips/emit.c, + src/vm/jit/mips/linux/md-os.c, src/vm/jit/mips/md-abi.c, + src/vm/jit/mips/md-abi.h: + * src/vm/jit/mips/md-abi.h: Merged MIPS32 code. + * src/vm/jit/mips/emit.c: Likewise. + * src/vm/jit/mips/codegen.c: Likewise. + * src/vm/jit/mips/codegen.h: Likewise. + * src/vm/jit/mips/linux/md-os.c: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/mips/md-abi.c: Likewise. + [87baf39e945a] + + * src/mm/memory.c, src/vm/jit/m68k/Makefile.am, + src/vm/jit/m68k/arch.h, src/vm/jit/m68k/asmpart.S, + src/vm/jit/m68k/codegen.c, src/vm/jit/m68k/codegen.h, + src/vm/jit/m68k/emit.c, src/vm/jit/m68k/machine-instr.h, + src/vm/jit/m68k/md.c, src/vm/jit/m68k/patcher.c, + src/vm/jit/m68k/uclinux/Makefile.am, src/vm/jit/m68k/uclinux/md- + abi.c, src/vm/jit/m68k/uclinux/md-abi.h, src/vm/jit/m68k/uclinux/md- + asm.h, src/vm/jit/m68k/uclinux/md-os.c: + * src/mm/memory.c (mem_realloc): Fixed compiler warning. + [2758baba10d2] + + * src/vm/exceptions.c: + * src/vm/exceptions.c (exceptions_throw_internalerror): Don't return + a value. (exceptions_throw_outofmemoryerror): Likewise. + [bd9464eafaa4] + + * src/vm/jit/arm/codegen.c, src/vm/jit/arm/codegen.h, + src/vm/jit/arm/emit.c: + * src/vm/jit/arm/emit.c (emit_exception_stubs): Renamed eref to er, + use md_codegen_patch_branch. + + * src/vm/jit/arm/codegen.c (codegen): Use + codegen_resolve_branchrefs, use exceptions_throw_internalerror. + + * src/vm/jit/arm/codegen.h (M_STACK_LOAD_FLT_TYPED): Removed. + (M_STACK_STORE_FLT_TYPED): Likewise. + [6b1b1aad7475] + + * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/arm/.cvsignore, + src/vm/jit/arm/Makefile.am, src/vm/jit/arm/arch.h, + src/vm/jit/arm/asmpart.S, src/vm/jit/arm/codegen.c, + src/vm/jit/arm/codegen.h, src/vm/jit/arm/disass.c, + src/vm/jit/arm/emit.c, src/vm/jit/arm/linux/.cvsignore, + src/vm/jit/arm/linux/Makefile.am, src/vm/jit/arm/linux/md-os.c, + src/vm/jit/arm/machine-instr.h, src/vm/jit/arm/md-abi.c, + src/vm/jit/arm/md-abi.h, src/vm/jit/arm/md-asm.h, + src/vm/jit/arm/md.c, src/vm/jit/arm/patcher.c: + * configure.ac [ENABLE_STATICVM] (AC_CHECK_LIB(dl)): Only perform + the check if we want a static VM. (AC_CONFIG_FILES): Added + src/vm/jit/arm/Makefile and src/vm/jit/arm/linux/Makefile. + * src/vm/jit/Makefile.am (DIST_SUBDIRS): Added arm. + [93c25d89aa7a] + +2007-01-10 twisti + + * src/vm/builtin.c: + * src/vm/builtin.c (builtin_newarray): Removed debug output. + [ca1161ec4cc1] + + * src/cacaoh/cacaoh.c, src/cacaoh/headers.c, src/mm/boehm.c, + src/mm/memory.c, src/native/native.c, src/vm/builtin.c, + src/vm/classcache.c, src/vm/descriptor.c, src/vm/exceptions.c, + src/vm/exceptions.h, src/vm/jit/allocator/liveness.c, + src/vm/jit/allocator/lsra.c, src/vm/jit/allocator/simplereg.c, + src/vm/jit/alpha/codegen.c, src/vm/jit/i386/codegen.c, + src/vm/jit/intrp/codegen.c, src/vm/jit/mips/codegen.c, + src/vm/jit/mips/md.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/powerpc64/codegen.c, src/vm/jit/sparc64/codegen.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/stack.c, + src/vm/jit/tools/genoffsets.c, src/vm/jit/verify/typecheck- + builtins.inc, src/vm/jit/verify/typeinfo.c, + src/vm/jit/x86_64/codegen.c, src/vm/loader.c, src/vm/suck.c, + src/vm/utf8.c, src/vm/vm.c: + * src/vm/suck.c (suck_add): Use vm_abort instead of + throw_cacao_exception_exit. (suck_float, suck_double): Use + exceptions_throw_internalerror. + + * src/vm/loader.c (load_class_bootstrap): Use vm_abort instead of + throw_cacao_exception_exit. + * src/vm/jit/sparc64/emit.c (emit_patcher_stubs): Likewise. + * src/vm/jit/mips/md.c (md_patch_replacement_point): Likewise. + * src/vm/vm.c (vm_create): Likewise. + + * src/vm/builtin.c (builtin_newarray): Use + exceptions_throw_outofmemoryerror. + + * src/vm/descriptor.c (descriptor_pool_lookup_classref): Use + exceptions_throw_internalerror. + * src/vm/classcache.c (classcache_store_unique): Likewise. + * src/vm/jit/powerpc/codegen.c (codegen): Likewise. + * src/vm/jit/sparc64/codegen.c (codegen): Likewise. + * src/vm/jit/alpha/codegen.c (codegen): Likewise. + * src/vm/jit/mips/codegen.c (codegen): Likewise. + * src/vm/jit/i386/codegen.c (codegen): Likewise. + * src/vm/jit/powerpc64/codegen.c (codegen): Likewise. + * src/vm/jit/intrp/codegen.c (codegen): Likewise. + * src/vm/jit/x86_64/codegen.c (codegen): Likewise. + * src/vm/jit/stack.c (stack_reanalyse_block): Likewise. + (stack_analyse): Likewise. + * src/vm/jit/verify/typeinfo.c (typeinfos_init_from_methoddesc): + Likewise. (typeinfo_init_component): Likewise. + * src/vm/jit/verify/typecheck-builtins.inc: Likewise. + * src/vm/jit/allocator/lsra.c (lsra_scan_registers_canditates): + Likewise. + * src/vm/jit/allocator/simplereg.c (simplereg_allocate_temporaries): + Likewise. + * src/vm/jit/allocator/liveness.c + (liveness_scan_registers_canditates): Likewise. + + * src/vm/exceptions.c (exceptions_throw_outofmemory_exit): Removed. + (new_internalerror): Removed. (exceptions_throw_internalerror): + Rewritten. (exceptions_throw_outofmemoryerror): Added. + + * src/vm/exceptions.h: Likewise. + + * src/vm/utf8.c (utf_get_number_of_u2s): Use + exceptions_throw_internalerror instead of + throw_cacao_exception_exit. + + * src/native/native.c (native_init): Changed debug output. + + * src/mm/memory.c (memory_checked_alloc): Use vm_abort instead of + exceptions_throw_outofmemory_exit. (mem_realloc): Changed debug + output. + * src/mm/boehm.c (gc_out_of_memory): Use vm_abort and + exceptions_throw_outofmemoryerror. + + * src/cacaoh/cacaoh.c (cacaoh_abort): Added. (main): Use + cacaoh_abort. + + * src/cacaoh/headers.c (throw_cacao_exception_exit): Removed. + (exceptions_throw_outofmemory_exit): Likewise. (new_internalerror): + Renamed to exceptions_throw_internalerror. + (exceptions_throw_outofmemoryerror): Added. + + * src/vm/jit/tools/genoffsets.c (main): Don't print + sizestackframeinfo. + [eaa7c4b43388] + + * src/vm/jit/parisc/linux/Makefile.am: + * src/vm/jit/parisc/linux/Makefile.am (libmd_la_SOURCES): Commented. + [b51cf064818d] + +2007-01-08 twisti + + * configure.ac, src/cacao/cacao.c, src/mm/memory.c, src/vm/jit/emit- + common.h, src/vm/jit/inline/inline.c, src/vm/jit/jit.c, + src/vm/jit/mips/codegen.c, src/vm/jit/parisc/Makefile.am, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c, src/vm/jit/verify/Makefile.am, + src/vm/jit/verify/generate.pl, src/vm/jit/verify/icmds.c, + src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify + /typecheck-common.c, src/vm/jit/verify/typecheck-common.h, + src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck- + invoke.inc, src/vm/jit/verify/typecheck-stackbased-gen.inc, + src/vm/jit/verify/typecheck-variablesbased-gen.inc, + src/vm/jit/verify/typecheck.c, src/vm/method.c, src/vm/method.h, + src/vm/vm.c: + Merged with trunk rev6283. + + * src/vm/method.c, src/vm/method.h, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/patcher.c, + src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-invoke.inc, + src/vm/jit/verify/typecheck-common.c, src/vm/jit/verify/typecheck- + typeinferer-gen.inc, src/vm/jit/verify/typecheck-multianewarray.inc, + src/vm/jit/verify/typecheck-typeinferer.c, src/vm/jit/verify + /typecheck-common.h, src/vm/jit/verify/typecheck-fields.inc, + src/vm/jit/verify/typecheck-typeinferer.h, src/vm/jit/verify + /typecheck-stackbased-gen.inc, src/vm/jit/verify/typecheck.c, + src/vm/jit/verify/typecheck-variablesbased-gen.inc, + src/vm/jit/verify/generate.pl, src/vm/jit/verify/Makefile.am, + src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/mips/codegen.c, + src/vm/jit/inline/inline.c, src/vm/jit/parisc/linux/Makefile.am, + src/vm/jit/parisc/Makefile.am, src/vm/jit/jit.c, src/vm/jit/emit- + common.h, src/vm/vm.c, src/cacao/cacao.c, src/mm/memory.c, + configure.ac: Merged. + [8e237a4d5523] + + * configure.ac: + * configure.ac: Added GPL header. + [c3f5ae9d7eb2] + + * src/vm/vm.c: + * src/vm/vm.c (vm_create): Fixed off-by-one bug. + [f5e5e63ff2db] + +2007-01-08 ajordan + + * src/vm/jit/sparc64/codegen.c: + * src/vm/jit/sparc64/codegen.c: Fixed argument passing via the stack + (for JIT methods). + [77115a8e9e95] + +2007-01-07 ajordan + + * src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/codegen.h, + src/vm/jit/sparc64/linux/md-os.c, src/vm/jit/sparc64/md.c, + src/vm/jit/sparc64/patcher.c: + * src/vm/jit/sparc64/codegen.c: Implemented INSTANCEOF and CHECKCAST + ICMDs + * src/vm/jit/sparc64/patcher.c: and their respective patchers. + + * src/vm/jit/sparc64/codegen.h: Added comparison instructions. + + * src/vm/jit/sparc64/linux/md-os.c: Implemented instruction cache + flush for linux. + * src/vm/jit/sparc64/md.c: Likewise. + [2d476dbfb2c2] + +2007-01-06 twisti + + * configure.ac: + * configure.ac: Check for libdl. + [6decb9c44f6f] + + * src/cacao/cacao.c: + * src/cacao/cacao.c (main): Print function name in error output. + [941930b2845d] + +2007-01-06 edwin + + * src/vm/jit/inline/inline.c: + * src/vm/jit/inline/inline.c: Many refactorings and comments. + [a4fdb4ceef75] + +2007-01-04 twisti + + * src/mm/memory.c: + * src/mm/memory.c (mem_realloc): Use vm_abort. + [e6f0eee2c2cf] + +2007-01-03 edwin + + * src/vm/jit/verify/Makefile.am, src/vm/jit/verify/icmds.c, + src/vm/jit/verify/typecheck-builtins.inc, src/vm/jit/verify + /typecheck-common.c, src/vm/jit/verify/typecheck-common.h, + src/vm/jit/verify/typecheck-fields.inc, src/vm/jit/verify/typecheck- + invoke.inc, src/vm/jit/verify/typecheck-multianewarray.inc, + src/vm/jit/verify/typecheck-stackbased-gen.inc, src/vm/jit/verify + /typecheck-typeinferer-gen.inc, src/vm/jit/verify/typecheck- + typeinferer.c, src/vm/jit/verify/typecheck-typeinferer.h, + src/vm/jit/verify/typecheck-variablesbased-gen.inc, + src/vm/jit/verify/typecheck.c: + * src/vm/jit/verify/typecheck-typeinferer.c: New type inference + pass. + * src/vm/jit/verify/typecheck-typeinferer.h: Likewise. + + * src/vm/jit/verify/typecheck-common.c: Moved code from typecheck.c + that can be shared between the variables-based verifier and the type + inference pass to this file. + * src/vm/jit/verify/typecheck-common.h: Likewise. + + * src/vm/jit/verify/typecheck-multianewarray.inc: Moved code for + type checking/infering MULTIANEWARRAY to this file. + + * src/vm/jit/verify/icmds.c: Adapted for generating the type + infererence pass. + * src/vm/jit/verify/typecheck-invoke.inc: Likewise. + * src/vm/jit/verify/typecheck-fields.inc: Likewise. + * src/vm/jit/verify/typecheck.c: Likewise. + * src/vm/jit/verify/Makefile.am: Likewise. + * src/vm/jit/verify/typecheck-builtins.inc: Likewise. + + * src/vm/jit/verify/typecheck-typeinferer-gen.inc: Generated. + + * src/vm/jit/verify/typecheck-stackbased-gen.inc: Regenerated. + * src/vm/jit/verify/typecheck-variablesbased-gen.inc: Regenerated. + [6d875bc53835] + + * src/vm/jit/verify/icmds.c, src/vm/jit/verify/typecheck-stackbased- + gen.inc, src/vm/jit/verify/typecheck-variablesbased-gen.inc: + * src/vm/jit/verify/icmds.c: Added comments. + + * src/vm/jit/verify/typecheck-stackbased-gen.inc, src/vm/jit/verify + /typecheck-variablesbased-gen.inc: Regenerated. + [81dcffbbd1b3] + + * src/vm/method.c, src/vm/method.h: + * src/vm/method.c, src/vm/method.h (method_count_implementations): + New function. + [58228f481c93] + + * src/vm/jit/verify/generate.pl: + * src/vm/jit/verify/generate.pl: Added options --typeinferer and + --debug. Prepared for generating the type inference pass. + [07e04a8efbb4] + +2007-01-02 twisti + + * configure.ac, src/vm/jit/parisc/Makefile.am, + src/vm/jit/parisc/linux/Makefile.am: + * configure.ac (AC_CONFIG_FILES): Added + src/vm/jit/parisc/linux/Makefile. + * src/vm/jit/parisc/Makefile.am (SUBDIRS): Set to $(OS_DIR). + * src/vm/jit/parisc/linux/Makefile.am: New file. + [d193cb85b31c] + +2007-01-02 edwin + + * src/vm/jit/emit-common.h: + * src/vm/jit/emit-common.h (emit_replacement_stubs): Only declare + prototype if ENABLE_REPLACEMENT. + [60115f167ec8] + + * src/vm/jit/mips/codegen.c: + * src/vm/jit/mips/codegen.c (codegen): Use REPLACEMENT_ macros. + [5e4385a84e1e] + +2007-01-02 twisti + + * configure.ac, src/native/include/.cvsignore, + src/native/include/Makefile.am, + src/native/include/java_lang_VMObject.h, src/vm/jit/Makefile.am, + src/vm/jit/alpha/asmpart.S, src/vm/jit/alpha/disass.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md-abi.c, + src/vm/jit/alpha/md.c, src/vm/jit/asmpart.h, src/vm/jit/code.c, + src/vm/jit/code.h, src/vm/jit/codegen-common.c, src/vm/jit/codegen- + common.h, src/vm/jit/i386/asmpart.S, src/vm/jit/i386/codegen.c, + src/vm/jit/i386/disass.c, src/vm/jit/i386/emit.c, src/vm/jit/i386 + /md-abi.c, src/vm/jit/i386/md.c, src/vm/jit/inline/inline.c, + src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S, src/vm/jit/mips/emit.c, + src/vm/jit/mips/md.c, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/md.c, + src/vm/jit/replace.h, src/vm/jit/show.c, src/vm/jit/sparc64/emit.c, + src/vm/jit/sparc64/md.c, src/vm/jit/tools/genoffsets.c, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/disass.c, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/x86_64/md.c, tests/regression/jctest.java, + tests/regression/jctest.output: + Merged with trunk rev6266. + + * src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/md.c, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/codegen-common.h, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md.c, + src/vm/jit/alpha/disass.c, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/md-abi.c, src/vm/jit/code.c, + src/vm/jit/tools/genoffsets.c, src/vm/jit/code.h, src/vm/jit/show.c, + src/vm/jit/mips/emit.c, src/vm/jit/mips/md.c, + src/vm/jit/mips/asmpart.S, src/vm/jit/inline/inline.c, + src/vm/jit/powerpc64/md.c, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/i386/emit.c, src/vm/jit/i386/md.c, + src/vm/jit/i386/codegen.c, src/vm/jit/i386/disass.c, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/md-abi.c, + src/vm/jit/asmpart.h, src/vm/jit/x86_64/emit.c, + src/vm/jit/x86_64/md.c, src/vm/jit/x86_64/disass.c, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/md-abi.c, + src/vm/jit/replace.h, src/vm/jit/Makefile.am, src/vm/jit/codegen- + common.c, src/vm/jit/jit.h, src/native/include, + src/native/include/java_lang_VMObject.h, + src/native/include/Makefile.am, src/native/include/.cvsignore, + tests/regression/jctest.output, tests/regression/jctest.java, + configure.ac: Merged. + [191085398868] + +2007-01-02 edwin + + * src/vm/jit/jit.c: + * src/vm/jit/jit.c (jit_invalidate_code): Require + ENABLE_REPLACEMENT. + [66966741fd27] + +2007-01-02 twisti + + * configure.ac, contrib/setenvinstalled.in, contrib/setenvsource.in, + m4/ac_prog_javac.m4, src/Makefile.am, src/cacaoh/cacaoh.c, + src/cacaoh/headers.c, src/fdlibm/Makefile.am, src/fdlibm/e_fmod.c, + src/fdlibm/fdlibm.h, src/fdlibm/ieeefp.h, src/fdlibm/mprec.h, + src/fdlibm/s_copysign.c, src/fdlibm/s_finite.c, src/fdlibm/w_fmod.c, + src/lib/vm/reference/java/lang/VMThread.java, src/mm/memory.c, + src/native/Makefile.am, src/native/include/.cvsignore, + src/native/include/Makefile.am, + src/native/include/java_lang_Thread.h, + src/native/include/java_lang_VMThread.h, src/native/jni.c, + src/native/native.c, src/native/native.h, src/native/vm/Makefile.am, + src/threads/native/lock.c, src/threads/native/threads.c, + src/threads/native/threads.h, src/vm/annotation.c, src/vm/class.c, + src/vm/class.h, src/vm/exceptions.c, src/vm/exceptions.h, + src/vm/finalizer.c, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/md.c, src/vm/jit/asmpart.h, src/vm/jit/codegen- + common.c, src/vm/jit/i386/asmpart.S, src/vm/jit/i386/md.c, + src/vm/jit/inline/inline.c, src/vm/jit/mips/md.c, + src/vm/jit/optimizing/recompile.c, src/vm/jit/powerpc/asmpart.S, + src/vm/jit/powerpc/codegen.c, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc64/asmpart.S, src/vm/jit/powerpc64/md.c, + src/vm/jit/sparc64/asmpart.S, src/vm/jit/sparc64/codegen.c, + src/vm/jit/stacktrace.c, src/vm/jit/stacktrace.h, + src/vm/jit/x86_64/asmpart.S, src/vm/jit/x86_64/md.c, + src/vm/linker.c, src/vm/loader.c, src/vm/properties.c, + src/vm/properties.h, src/vm/resolve.c, src/vm/resolve.h, + src/vm/signal.c, src/vm/utf8.c, src/vm/utf8.h, src/vm/vm.c, + tests/regression/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/jasmin/Makefile.am, + tests/regression/native/Makefile.am: + Merged with trunk rev6223. + + * m4/ac_prog_javac.m4, src/vm/properties.h, src/vm/class.c, + src/vm/loader.c, src/vm/annotation.c, src/vm/class.h, + src/vm/resolve.c, src/vm/finalizer.c, src/vm/resolve.h, + src/vm/jit/powerpc/emit.c, src/vm/jit/powerpc/codegen.c, + src/vm/jit/sparc64/codegen.c, src/vm/jit/sparc64/asmpart.S, + src/vm/jit/optimizing/recompile.c, src/vm/jit/stacktrace.c, + src/vm/jit/stacktrace.h, src/vm/jit/codegen-common.c, + src/vm/signal.c, src/vm/exceptions.c, src/vm/vm.c, src/vm/linker.c, + src/vm/exceptions.h, src/vm/utf8.c, src/vm/utf8.h, + src/vm/properties.c, src/lib/vm/reference/java/lang/VMThread.java, + src/native/jni.c, src/native/vm/java_lang_Thread.h, + src/native/vm/cldc1.1, + src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c, + src/native/vm/cldc1.1/java_lang_Runtime.c, + src/native/vm/cldc1.1/java_lang_System.c, + src/native/vm/cldc1.1/java_lang_Class.c, + src/native/vm/cldc1.1/java_lang_Float.c, + src/native/vm/cldc1.1/Makefile.am, + src/native/vm/cldc1.1/java_lang_Object.c, + src/native/vm/cldc1.1/java_lang_String.c, + src/native/vm/cldc1.1/java_lang_Thread.c, + src/native/vm/cldc1.1/java_lang_Throwable.c, + src/native/vm/cldc1.1/java_lang_Math.c, + src/native/vm/cldc1.1/.cvsignore, + src/native/vm/cldc1.1/java_lang_Double.c, + src/native/vm/java_lang_Class.c, + src/native/vm/gnu/java_lang_VMThread.c, + src/native/vm/gnu/java_lang_VMRuntime.c, + src/native/vm/gnu/Makefile.am, src/native/vm/Makefile.am, + src/native/vm/java_lang_Object.c, src/native/vm/java_lang_Thread.c, + src/native/vm/java_lang_Class.h, src/native/vm/java_lang_Object.h, + src/native/include, src/native/include/java_lang_Thread.h, + src/native/include/java_lang_VMThread.h, + src/native/include/Makefile.am, src/native/include/.cvsignore, + src/native/native.c, src/native/Makefile.am, src/native/native.h, + src/mm/memory.c, src/Makefile.am, src/threads/native/threads.h, + src/threads/native/lock.c, src/threads/native/threads.c, + src/fdlibm/k_cos.c, src/fdlibm/s_ceil.c, src/fdlibm/s_finite.c, + src/fdlibm/ieeefp.h, src/fdlibm/fdlibm.h, src/fdlibm/s_floor.c, + src/fdlibm/k_sin.c, src/fdlibm/s_tan.c, src/fdlibm/s_cos.c, + src/fdlibm/w_fmod.c, src/fdlibm/mprec.h, src/fdlibm/s_sin.c, + src/fdlibm/s_copysign.c, src/fdlibm/w_sqrt.c, + src/fdlibm/e_rem_pio2.c, src/fdlibm/k_rem_pio2.c, + src/fdlibm/Makefile.am, src/fdlibm/e_fmod.c, src/fdlibm/k_tan.c, + src/fdlibm/e_sqrt.c, src/cacaoh/cacaoh.c, src/cacaoh/headers.c, + contrib/setenvinstalled.in, contrib/setenvsource.in, + tests/regression/jasmin/Makefile.am, + tests/regression/native/Makefile.am, + tests/regression/codepatching/Makefile.am, + tests/regression/Makefile.am, configure.ac: Merged. + [693ea6b397f5] + +2007-01-02 edwin + + * configure.ac, src/vm/jit/Makefile.am, src/vm/jit/alpha/asmpart.S, + src/vm/jit/alpha/emit.c, src/vm/jit/alpha/md.c, + src/vm/jit/asmpart.h, src/vm/jit/code.c, src/vm/jit/code.h, + src/vm/jit/codegen-common.c, src/vm/jit/codegen-common.h, + src/vm/jit/i386/asmpart.S, src/vm/jit/i386/emit.c, + src/vm/jit/i386/md.c, src/vm/jit/jit.h, src/vm/jit/mips/asmpart.S, + src/vm/jit/mips/emit.c, src/vm/jit/mips/md.c, + src/vm/jit/powerpc/asmpart.S, src/vm/jit/powerpc/emit.c, + src/vm/jit/powerpc/md.c, src/vm/jit/powerpc64/asmpart.S, + src/vm/jit/powerpc64/md.c, src/vm/jit/replace.h, src/vm/jit/show.c, + src/vm/jit/sparc64/emit.c, src/vm/jit/sparc64/md.c, + src/vm/jit/tools/genoffsets.c, src/vm/jit/x86_64/asmpart.S, + src/vm/jit/x86_64/emit.c, src/vm/jit/x86_64/md.c: + * configure.ac: Added option --enable-replacement. + + * src/vm/jit/Makefile.am: Compile replace.c only for + ENABLE_REPLACEMENT. + + * src/vm/jit/replace.h: Define empty macros unless + ENABLE_REPLACEMENT. + + * src/vm/jit/powerpc/emit.c: Enclosed replacement-specific code in + #if ENABLE_REPLACEMENT. + * src/vm/jit/powerpc/md.c: Likewise. + * src/vm/jit/powerpc/asmpart.S: Likewise. + * src/vm/jit/codegen-common.h: Likewise. + * src/vm/jit/sparc64/emit.c: Likewise. + * src/vm/jit/sparc64/md.c: Likewise. + * src/vm/jit/alpha/emit.c: Likewise. + * src/vm/jit/alpha/md.c: Likewise. + * src/vm/jit/alpha/asmpart.S: Likewise. + * src/vm/jit/code.c: Likewise. + * src/vm/jit/code.h: Likewise. + * src/vm/jit/tools/genoffsets.c: Likewise. + * src/vm/jit/show.c: Likewise. + * src/vm/jit/mips/emit.c: Likewise. + * src/vm/jit/mips/md.c: Likewise. + * src/vm/jit/mips/asmpart.S: Likewise. + * src/vm/jit/powerpc64/md.c: Likewise. + * src/vm/jit/powerpc64/asmpart.S: Likewise. + * src/vm/jit/i386/emit.c: Likewise. + * src/vm/jit/i386/md.c: Likewise. + * src/vm/jit/i386/asmpart.S: Likewise. + * src/vm/jit/asmpart.h: Likewise. + * src/vm/jit/x86_64/emit.c: Likewise. + * src/vm/jit/x86_64/md.c: Likewise. + * src/vm/jit/x86_64/asmpart.S: Likewise. + * src/vm/jit/codegen-common.c: Likewise. + * src/vm/jit/jit.h: Likewise. + [d57bc9b264e8] + + * src/vm/jit/i386/codegen.c: + * src/vm/jit/i386/codegen.c (codegen): Cleaned up to use + REPLACEMENT_ macros. + [262f09f41eaf] + +2007-01-02 twisti + + * tests/regression/jctest.java, tests/regression/jctest.output: + * tests/regression/jctest.java: Print hex numbers too. + * tests/regression/jctest.output: Updated. + [bead5d6be07a] + diff --git a/Makefile.am b/Makefile.am index e451bb5a5..069cd4fe1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,12 @@ ACLOCAL_AMFLAGS = -I m4 MAINTAINERCLEANFILES = Makefile.in configure -SUBDIRS = contrib doc man src tests +SUBDIRS = \ + contrib \ + doc \ + man \ + src \ + tests EXTRA_DIST = \ ChangeLog-1998 \ @@ -36,6 +41,8 @@ EXTRA_DIST = \ ChangeLog-2003 \ ChangeLog-2004 \ ChangeLog-2005 \ + ChangeLog-2006 \ + ChangeLog-2007 \ THIRDPARTY diff --git a/NEWS b/NEWS index 973a7bd67..e2ce1c6ab 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,20 @@ -New in release 0.99 (March x, 2008) +New in release 0.99.1 (June 17, 2008) + + * Fixed compilation of OpenJDK code (libltdl related). + * Imported new gnu/java/lang/CPStringBuilder.java to fix OOMEs. + * Fixed abort with OpenJDK's java binary when exiting. + +New in release 0.99 (June 14, 2008) * Initial support to use OpenJDK as Java core library. * Fixed memory leak in Boehm-GC. + * Boehm-GC updated to version 7.1. + * Removed libltdl dependency. + * Renamed --with-classpath configure options to + --with-java-runtime-library. + * Renamed --with-jre-layout to --enable-layout. + * Replaced --with-classpath-includedir with --with-jni_h and + --with-jni_md_h to better support OpenJDK/IcedTea builds. * Use 8-byte stack-slots on all architectures. * Faster C-to-Java calls. * Removed genoffsets, cross-compilation is now much easier. @@ -11,8 +24,6 @@ New in release 0.99 (March x, 2008) * Assertion support. * Linenumber table code rewritten. * Exception table code rewritten. - * Replaced --with-classpath-includedir with --with-jni_h and - --with-jni_md_h to better support OpenJDK/IcedTea build.s New in release 0.98 (June 6, 2007) diff --git a/THIRDPARTY b/THIRDPARTY index ec1766123..72405f576 100644 --- a/THIRDPARTY +++ b/THIRDPARTY @@ -70,7 +70,7 @@ The upstream for fdlibm is libgcj (http://gcc.gnu.org/java/), they sync again with the 'real' upstream (http://www.netlib.org/fdlibm/readme). -* src/lib/gnu/* +* src/classes/gnuclasspath/* GNU Classpath is licensed under the terms of the GNU General Public License with the following clarification and special exception: @@ -169,36 +169,6 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. -* contrib/svn2cl.xsl - - Copyright (C) 2004, 2005, 2006 Arthur de Jong. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - 3. The name of the author may not be used to endorse or promote - products derived from this software without specific prior - written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - * contrib/vmlog Copyright (C) 2006 Edwin Steiner @@ -212,14 +182,14 @@ See contrib/vmlog/COPYING for the full text of the license. * contrib/mapfile-vers-product, - src/lib/gnu/sun/misc/Unsafe.java, - src/lib/gnu/sun/reflect/ConstantPool.java, - src/lib/gnu/sun/reflect/annotation/AnnotationParser.java, - src/lib/gnu/sun/reflect/annotation/AnnotationType.java, - src/lib/gnu/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, - src/lib/gnu/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java, - src/lib/gnu/sun/reflect/annotation/ExceptionProxy.java, - src/lib/gnu/sun/reflect/annotation/TypeNotPresentExceptionProxy.java + src/classes/gnuclasspath/sun/misc/Unsafe.java, + src/classes/gnuclasspath/sun/reflect/ConstantPool.java, + src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java, + src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java, + src/classes/gnuclasspath/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java, + src/classes/gnuclasspath/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java, + src/classes/gnuclasspath/sun/reflect/annotation/ExceptionProxy.java, + src/classes/gnuclasspath/sun/reflect/annotation/TypeNotPresentExceptionProxy.java Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff --git a/autogen.sh b/autogen.sh index 1c6c633c8..e3fc293e9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,139 +1,150 @@ #!/bin/sh -# test for a libtoolize +# Test for a autoconf commands. -CACAO_HAVE_LIBTOOLIZE=false +# Test for a autoconf. -for CACAO_LIBTOOLIZE in libtoolize libtoolize15 glibtoolize; do - if ${CACAO_LIBTOOLIZE} --version > /dev/null 2>&1; then - CACAO_LIBTOOLIZE_VERSION=`${CACAO_LIBTOOLIZE} --version | sed 's/^.*[^0-9.]\([0-9]\{1,\}\.[0-9.]\{1,\}\).*/\1/'` -# echo ${CACAO_LIBTOOLIZE_VERSION} - case ${CACAO_LIBTOOLIZE_VERSION} in - 1.5* | 2.* ) - CACAO_HAVE_LIBTOOLIZE=true +HAVE_AUTOCONF=false + +for AUTOCONF in autoconf autoconf259; do + if ${AUTOCONF} --version > /dev/null 2>&1; then + AUTOCONF_VERSION=`${AUTOCONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTOCONF_VERSION} + case ${AUTOCONF_VERSION} in + 2.59* | 2.6[0-9]* ) + HAVE_AUTOCONF=true break; ;; esac fi done -if test ${CACAO_HAVE_LIBTOOLIZE} = false; then - echo "No proper libtoolize was found." - echo "You must have libtool 1.5 or later installed." - exit 1 -fi +# Test for a autoheader. +HAVE_AUTOHEADER=false -# test for a aclocal - -CACAO_HAVE_ACLOCAL=false - -for CACAO_ACLOCAL in aclocal aclocal-1.9 aclocal19; do - if ${CACAO_ACLOCAL} --version > /dev/null 2>&1; then - CACAO_ACLOCAL_VERSION=`${CACAO_ACLOCAL} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` -# echo ${CACAO_ACLOCAL_VERSION} - case ${CACAO_ACLOCAL_VERSION} in - 1.9* | 1.1[0-9]* ) - CACAO_HAVE_ACLOCAL=true +for AUTOHEADER in autoheader autoheader259; do + if ${AUTOHEADER} --version > /dev/null 2>&1; then + AUTOHEADER_VERSION=`${AUTOHEADER} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTOHEADER_VERSION} + case ${AUTOHEADER_VERSION} in + 2.59* | 2.6[0-9]* ) + HAVE_AUTOHEADER=true break; ;; esac fi done -if test ${CACAO_HAVE_ACLOCAL} = false; then - echo "No proper aclocal was found." - echo "You must have automake 1.9 or later installed." - exit 1 -fi - +# Test for a autoreconf. -# test for a autoheader +HAVE_AUTORECONF=false -CACAO_HAVE_AUTOHEADER=false - -for CACAO_AUTOHEADER in autoheader autoheader259; do - if ${CACAO_AUTOHEADER} --version > /dev/null 2>&1; then - CACAO_AUTOHEADER_VERSION=`${CACAO_AUTOHEADER} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` -# echo ${CACAO_AUTOHEADER_VERSION} - case ${CACAO_AUTOHEADER_VERSION} in +for AUTORECONF in autoreconf; do + if ${AUTORECONF} --version > /dev/null 2>&1; then + AUTORECONF_VERSION=`${AUTORECONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTORECONF_VERSION} + case ${AUTORECONF_VERSION} in 2.59* | 2.6[0-9]* ) - CACAO_HAVE_AUTOHEADER=true + HAVE_AUTORECONF=true break; ;; esac fi done -if test ${CACAO_HAVE_AUTOHEADER} = false; then +if test ${HAVE_AUTOCONF} = false; then + echo "No proper autoconf was found." + echo "You must have autoconf 2.59 or later installed." + exit 1 +fi + +if test ${HAVE_AUTOHEADER} = false; then echo "No proper autoheader was found." echo "You must have autoconf 2.59 or later installed." exit 1 fi +if test ${HAVE_AUTORECONF} = false; then + echo "No proper autoreconf was found." + echo "You must have autoconf 2.59 or later installed." + exit 1 +fi -# test for a automake -CACAO_HAVE_AUTOMAKE=false +# Test for a automake commands. -for CACAO_AUTOMAKE in automake automake-1.9 automake19; do - if ${CACAO_AUTOMAKE} --version > /dev/null 2>&1; then - CACAO_AUTOMAKE_VERSION=`${CACAO_AUTOMAKE} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` -# echo ${CACAO_AUTOMAKE_VERSION} - case ${CACAO_AUTOMAKE_VERSION} in +# Test for a aclocal. + +HAVE_ACLOCAL=false + +for ACLOCAL in aclocal aclocal-1.10 aclocal-1.9 aclocal19; do + if ${ACLOCAL} --version > /dev/null 2>&1; then + ACLOCAL_VERSION=`${ACLOCAL} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${ACLOCAL_VERSION} + case ${ACLOCAL_VERSION} in + 1.9* | 1.1[0-9]* ) + HAVE_ACLOCAL=true + break; + ;; + esac + fi +done + +# Test for a automake. + +HAVE_AUTOMAKE=false + +for AUTOMAKE in automake automake-1.10 automake-1.9 automake19; do + if ${AUTOMAKE} --version > /dev/null 2>&1; then + AUTOMAKE_VERSION=`${AUTOMAKE} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` +# echo ${AUTOMAKE_VERSION} + case ${AUTOMAKE_VERSION} in 1.9* | 1.1[0-9]* ) - CACAO_HAVE_AUTOMAKE=true + HAVE_AUTOMAKE=true break; ;; esac fi done -if test ${CACAO_HAVE_AUTOMAKE} = false; then +if test ${HAVE_ACLOCAL} = false; then + echo "No proper aclocal was found." + echo "You must have automake 1.9 or later installed." + exit 1 +fi + +if test ${HAVE_AUTOMAKE} = false; then echo "No proper automake was found." echo "You must have automake 1.9 or later installed." exit 1 fi -# test for a autoconf +# Test for a libtoolize. -CACAO_HAVE_AUTOCONF=false +HAVE_LIBTOOLIZE=false -for CACAO_AUTOCONF in autoconf autoconf259; do - if ${CACAO_AUTOCONF} --version > /dev/null 2>&1; then - CACAO_AUTOCONF_VERSION=`${CACAO_AUTOCONF} --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'` -# echo ${CACAO_AUTOCONF_VERSION} - case ${CACAO_AUTOCONF_VERSION} in - 2.59* | 2.6[0-9]* ) - CACAO_HAVE_AUTOCONF=true +for LIBTOOLIZE in libtoolize libtoolize15 glibtoolize; do + if ${LIBTOOLIZE} --version > /dev/null 2>&1; then + LIBTOOLIZE_VERSION=`${LIBTOOLIZE} --version | sed 's/^.*[^0-9.]\([0-9]\{1,\}\.[0-9.]\{1,\}\).*/\1/'` +# echo ${LIBTOOLIZE_VERSION} + case ${LIBTOOLIZE_VERSION} in + 1.5* | 2.* ) + HAVE_LIBTOOLIZE=true break; ;; esac fi done -if test ${CACAO_HAVE_AUTOCONF} = false; then - echo "No proper autoconf was found." - echo "You must have autoconf 2.59 or later installed." +if test ${HAVE_LIBTOOLIZE} = false; then + echo "No proper libtoolize was found." + echo "You must have libtool 1.5 or later installed." exit 1 fi -${CACAO_LIBTOOLIZE} --automake -if test `uname` = 'FreeBSD'; then - ${CACAO_ACLOCAL} -I m4 -I /usr/local/share/aclocal -I /usr/local/share/aclocal19 -else - ${CACAO_ACLOCAL} -I m4 -fi -${CACAO_AUTOHEADER} -${CACAO_AUTOMAKE} --add-missing -${CACAO_AUTOCONF} - -export CACAO_LIBTOOLIZE -export CACAO_ACLOCAL -export CACAO_AUTOHEADER -export CACAO_AUTOMAKE -export CACAO_AUTOCONF +export ACLOCAL AUTOCONF AUTOHEADER AUTOMAKE LIBTOOLIZE -cd src/mm/boehm-gc && ./autogen.sh && cd ../.. +${AUTORECONF} --install --symlink diff --git a/configure.ac b/configure.ac index f42699841..9f76066eb 100644 --- a/configure.ac +++ b/configure.ac @@ -23,11 +23,11 @@ dnl 02110-1301, USA. dnl Process this file with autoconf to produce a configure script. -AC_INIT(cacao, 0.99rc6, cacao@cacaojvm.org) -AC_CONFIG_SRCDIR(src/cacao/cacao.c) +AC_INIT(cacao, 1.1.0pre, cacao@cacaojvm.org) +AC_CONFIG_SRCDIR(src/cacao/cacao.cpp) AC_CANONICAL_HOST AC_PREREQ(2.59) -AM_INIT_AUTOMAKE([1.9.0 dist-bzip2]) +AM_INIT_AUTOMAKE([1.9.0 dist-bzip2 tar-ustar]) AM_MAINTAINER_MODE AM_CONFIG_HEADER([config.h]) @@ -35,87 +35,93 @@ AM_CONFIG_HEADER([config.h]) AC_PREFIX_DEFAULT(/usr/local/cacao) -dnl set optimization and debugging for all architectures and systems +dnl Set optimization and debugging for all architectures and systems. if test x"$CFLAGS" = "x"; then - OPT_CFLAGS="-O0 -g3" + OPT_CFLAGS="-g -O0" else OPT_CFLAGS=$CFLAGS fi +if test x"$CXXFLAGS" = "x"; then + OPT_CXXFLAGS="-g -O0" +else + OPT_CXXFLAGS=$CXXFLAGS +fi + dnl system type case "$host_cpu" in alpha | alphaev56 | alphapca56 ) ARCH_DIR="alpha" - ARCH_CFLAGS="-mieee -D__ALPHA__" + ARCH_FLAGS="-mieee -D__ALPHA__" JAVA_ARCH="alpha" ;; -arm | armv4 | armv4tl | armv5b | armv5l ) +arm | armv4 | armv4tl | armv5b | armv5l | armv5tel | armv5tejl ) ARCH_DIR="arm" - ARCH_CFLAGS="-D__ARM__" + ARCH_FLAGS="-D__ARM__" JAVA_ARCH="arm" ;; hppa2.0 ) ARCH_DIR="parisc" - ARCH_CFLAGS="-D__PARISC__" + ARCH_FLAGS="-D__PARISC__" JAVA_ARCH="hppa" ;; i386 | i486 | i586 | i686 ) ARCH_DIR="i386" - ARCH_CFLAGS="-D__I386__" + ARCH_FLAGS="-m32 -D__I386__" JAVA_ARCH="i386" ;; m68k ) ARCH_DIR="m68k" - ARCH_CFLAGS="-D__M68K__" + ARCH_FLAGS="-D__M68K__" JAVA_ARCH="m68k" ;; mips | mipsel ) ARCH_DIR="mips" - ARCH_CFLAGS="-D__MIPS__" + ARCH_FLAGS="-D__MIPS__" dnl Is this correct for mipsel? JAVA_ARCH="mips" ;; powerpc ) ARCH_DIR="powerpc" - ARCH_CFLAGS="-D__POWERPC__" + ARCH_FLAGS="-m32 -D__POWERPC__" JAVA_ARCH="ppc" ;; powerpc64 ) ARCH_DIR="powerpc64" - ARCH_CFLAGS="-D__POWERPC64__" + ARCH_FLAGS="-m64 -D__POWERPC64__" JAVA_ARCH="ppc64" ;; s390 ) ARCH_DIR="s390" - ARCH_CFLAGS="-D__S390__" + ARCH_FLAGS="-D__S390__" JAVA_ARCH="s390" ;; sparc | sparc64 ) ARCH_DIR="sparc64" - ARCH_CFLAGS="-mcpu=v9 -m64 -D__SPARC_64__" + ARCH_FLAGS="-mcpu=v9 -m64 -D__SPARC_64__" dnl Is this correct for 64-bits? JAVA_ARCH="sparc" ;; x86_64 ) ARCH_DIR="x86_64" - ARCH_CFLAGS="-D__X86_64__" + ARCH_FLAGS="-m64 -D__X86_64__" JAVA_ARCH="amd64" ;; xdspcore ) ARCH_DIR="xdspcore" ENABLE_STATICVM="yes" - ARCH_CFLAGS="-D__XDSPCORE__" + ARCH_FLAGS="-D__XDSPCORE__" USE_SCHEDULER="1" ;; @@ -128,59 +134,79 @@ dnl host type case "$host_os" in *cygwin* ) OS_DIR="cygwin" - INTRP_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -Wall -Wno-long-long" - ARCH_CFLAGS="$ARCH_CFLAGS -D__WINDOWS__ -D__CYGWIN__ -ansi -pedantic -Wall -Wno-long-long" + OS_FLAGS="-D__WINDOWS__ -D__CYGWIN__" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; *darwin* ) OS_DIR="darwin" - INTRP_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -Wall -Wno-long-long" - ARCH_CFLAGS="$ARCH_CFLAGS -D__DARWIN__ -ansi -pedantic -Wall -Wno-long-long" + OS_FLAGS="-D__DARWIN__" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" + ;; + +dnl Must be BEFORE *freebsd*. +*kfreebsd*-gnu) + OS_DIR="freebsd" + OS_FLAGS="-D__FREEBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; *freebsd* ) OS_DIR="freebsd" - INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED" - ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE_EXTENDED" + OS_FLAGS="-D__FREEBSD__ -D_XOPEN_SOURCE_EXTENDED" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; *irix* ) OS_DIR="irix" - INTRP_CFLAGS="$ARCH_CFLAGS -D__IRIX__" - ARCH_CFLAGS="$ARCH_CFLAGS -D__IRIX__" + OS_FLAGS="-D__IRIX__" + CC_FLAGS="" + CXX_FLAGS="" + INTRP_CFLAGS="$ARCH_FLAGS $OS_FLAGS" ;; -*kfreebsd*-gnu) - OS_DIR="freebsd" - INTRP_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" - ARCH_CFLAGS="$ARCH_CFLAGS -D__FREEBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" - ;; - -dnl must be before *linux* +dnl Must be BEFORE *linux*. *uclinux | *elf ) OS_DIR="uclinux" - INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" - ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; *linux* | *Linux* ) OS_DIR="linux" - INTRP_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" - ARCH_CFLAGS="$ARCH_CFLAGS -D__LINUX__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + OS_FLAGS="-D__LINUX__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; *netbsd* ) OS_DIR="netbsd" - INTRP_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" - ARCH_CFLAGS="$ARCH_CFLAGS -D__NETBSD__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + OS_FLAGS="-D__NETBSD__ -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; *solaris* ) OS_DIR="solaris" - dnl on solaris the architecture defines 'sparc','sun','unix' are not set when cpp is called with -ansi - dnl therefore we add them here - INTRP_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix" - ARCH_CFLAGS="$ARCH_CFLAGS -D__SOLARIS__ -ansi -pedantic -Wall -Wno-long-long -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ -D_BSD_SOURCE -Dsparc -Dsun -Dunix" + dnl On solaris the architecture defines 'sparc', 'sun', 'unix' are + dnl not set when cpp is called with -std=c99, therefore we add them + dnl here. + OS_FLAGS="-D__SOLARIS__ -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_BSD_SOURCE" + CC_FLAGS="-std=c99 -pedantic -Wall -Wno-long-long -D_XOPEN_SOURCE=600" + CXX_FLAGS="-std=c++98 -pedantic -Wall -Wno-long-long" + INTRP_CFLAGS="-Wall -Wno-long-long $ARCH_FLAGS $OS_FLAGS" ;; * ) @@ -190,7 +216,8 @@ esac dnl temporary set the CFLAGS for configure tests (e.g. inline keyword) dnl we set it properly at the end of this file -CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS" +CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS" +CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS" dnl set interpreter flags AC_SUBST(INTRP_CFLAGS) @@ -199,30 +226,40 @@ dnl define and substitute some architecture specific variables AC_DEFINE_UNQUOTED([ARCH_DIR], "${ARCH_DIR}", [architecture directory]) AC_DEFINE_UNQUOTED([JAVA_ARCH], "${JAVA_ARCH}", [Java architecture name]) AC_SUBST(ARCH_DIR) +AC_SUBST(JAVA_ARCH) AC_SUBST(OS_DIR) AC_SUBST(USE_SCHEDULER) dnl Checks for programs. AC_PROG_CC +AC_PROG_CXX AM_PROG_AS AC_PROG_LD AC_PROG_LD_GNU -AC_PROG_RANLIB AC_PROG_LN_S AC_PROG_MAKE_SET AM_PROG_MKDIR_P +AM_CONDITIONAL([WITH_GNU_LD], [test x"$with_gnu_ld" = "xyes"]) + dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC +dnl Crucial header files. +AC_CHECK_HEADERS([stdbool.h],, [AC_MSG_ERROR(cannot find stdbool.h)]) +AC_CHECK_HEADERS([stdint.h],, [AC_MSG_ERROR(cannot find stdint.h)]) + dnl keep them alpha-sorted! AC_CHECK_HEADERS([assert.h]) AC_CHECK_HEADERS([errno.h]) +AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_HEADERS([fcntl.h]) AC_CHECK_HEADERS([libgen.h]) AC_CHECK_HEADERS([netdb.h]) +AC_CHECK_HEADERS([signal.h]) +AC_CHECK_HEADERS([stdarg.h]) AC_CHECK_HEADERS([stdint.h]) AC_CHECK_HEADERS([stdio.h]) AC_CHECK_HEADERS([stdlib.h]) @@ -239,15 +276,6 @@ AC_CHECK_HEADERS([sys/stat.h]) AC_CHECK_HEADERS([sys/time.h]) AC_CHECK_HEADERS([sys/types.h]) -dnl this is for fdlibm -AC_CHECK_HEADERS([inttypes.h]) -AC_CHECK_HEADERS([sys/config.h]) -AC_CHECK_HEADERS([sys/types.h]) -AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t])) -AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define to 1 if you have uint32_t])) -AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t])) -AC_EGREP_HEADER(u_int32_t, sys/config.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, [Define to 1 if you have BSD u_int32_t])) - dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE @@ -259,7 +287,12 @@ AC_STRUCT_TM dnl Checks for libraries (NOTE: Should be done before function checks, dnl as some functions may be in libraries we check for). -AC_CHECK_LIB(dl, dlopen,,) + +case "${OS_DIR}" in + solaris ) + AC_CHECK_LIB([socket], [gethostname],, [AC_MSG_ERROR(cannot find libsocket)]) + ;; +esac dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL @@ -273,6 +306,8 @@ AC_CHECK_FUNCS([accept]) AC_CHECK_FUNCS([access]) AC_CHECK_FUNCS([atoi]) AC_CHECK_FUNCS([atol]) +AC_CHECK_FUNCS([backtrace]) +AC_CHECK_FUNCS([backtrace_symbols]) AC_CHECK_FUNCS([calloc]) AC_CHECK_FUNCS([close]) AC_CHECK_FUNCS([confstr]) @@ -288,6 +323,7 @@ AC_CHECK_FUNCS([fstat]) AC_CHECK_FUNCS([fsync]) AC_CHECK_FUNCS([ftruncate]) AC_CHECK_FUNCS([getcwd]) +AC_CHECK_FUNCS([getenv]) AC_CHECK_FUNCS([gethostbyname]) AC_CHECK_FUNCS([gethostname]) AC_CHECK_FUNCS([getpagesize]) @@ -308,6 +344,7 @@ AC_CHECK_FUNCS([memset]) AC_CHECK_FUNCS([mmap]) AC_CHECK_FUNCS([mprotect]) AC_CHECK_FUNCS([open]) +AC_CHECK_FUNCS([printf]) AC_CHECK_FUNCS([read]) AC_CHECK_FUNCS([readlink]) AC_CHECK_FUNCS([realloc]) @@ -319,15 +356,19 @@ AC_CHECK_FUNCS([setsockopt]) AC_CHECK_FUNCS([shutdown]) AC_CHECK_FUNCS([socket]) AC_CHECK_FUNCS([stat]) +AC_CHECK_FUNCS([str2sig]) AC_CHECK_FUNCS([strcat]) AC_CHECK_FUNCS([strchr]) AC_CHECK_FUNCS([strcpy]) +AC_CHECK_FUNCS([strcmp]) AC_CHECK_FUNCS([strdup]) AC_CHECK_FUNCS([strerror]) AC_CHECK_FUNCS([strlen]) AC_CHECK_FUNCS([strncmp]) AC_CHECK_FUNCS([strstr]) AC_CHECK_FUNCS([time]) +AC_CHECK_FUNCS([va_end]) +AC_CHECK_FUNCS([va_start]) AC_CHECK_FUNCS([write]) @@ -359,8 +400,7 @@ AC_DEFINE_UNQUOTED([CACAO_LIBDIR], "${CACAO_LIBDIR}", [library installation pref AC_SUBST(CACAO_LIBDIR) -AC_CHECK_ENABLE_LTDL - +AC_CHECK_ENABLE_DL AC_CHECK_ENABLE_JAVA AC_CHECK_ENABLE_JIT @@ -377,266 +417,20 @@ AC_CHECK_SOFT_DOUBLE_CMP AC_CHECK_ENABLE_GC AC_CHECK_ENABLE_DEBUG AC_CHECK_ENABLE_DUMP - - -dnl check for memcheck support -AC_MSG_CHECKING(whether debugging memory checks should be enabled) -AC_ARG_ENABLE([memcheck], - [AS_HELP_STRING(--enable-memcheck,enable debugging memory checks [[default=no]])], - [case "${enableval}" in - yes) ENABLE_MEMCHECK=yes;; - *) ENABLE_MEMCHECK=no;; - esac], - [ENABLE_MEMCHECK=no]) -AC_MSG_RESULT(${ENABLE_MEMCHECK}) -AM_CONDITIONAL([ENABLE_MEMCHECK], test x"${ENABLE_MEMCHECK}" = "xyes") - -if test x"${ENABLE_MEMCHECK}" = "xyes"; then - AC_DEFINE([ENABLE_MEMCHECK], 1, [perform debugging memory checks]) -fi - - -dnl check for handles (indirection cells) support -AC_MSG_CHECKING(whether handles (indirection cells) should be enabled) -AC_ARG_ENABLE([handles], - [AS_HELP_STRING(--enable-handles,enable handles (indirection cells) [[default=no]])], - [case "${enableval}" in - yes) ENABLE_HANDLES=yes;; - *) ENABLE_HANDLES=no;; - esac], - [ENABLE_HANDLES=no]) -AC_MSG_RESULT(${ENABLE_HANDLES}) -AM_CONDITIONAL([ENABLE_HANDLES], test x"${ENABLE_HANDLES}" = "xyes") - -if test x"${ENABLE_HANDLES}" = "xyes"; then - AC_DEFINE([ENABLE_HANDLES], 1, [enable handles (indirection cells)]) -fi - - -dnl check for vmlog support -AC_MSG_CHECKING(whether vmlog tracing should be enabled) -AC_ARG_ENABLE([vmlog], - [AS_HELP_STRING(--enable-vmlog,enable vmlog tracing [[default=no]])], - [case "${enableval}" in - yes) ENABLE_VMLOG=yes;; - *) ENABLE_VMLOG=no;; - esac], - [ENABLE_VMLOG=no]) -AC_MSG_RESULT(${ENABLE_VMLOG}) -AM_CONDITIONAL([ENABLE_VMLOG], test x"${ENABLE_VMLOG}" = "xyes") - -if test x"${ENABLE_VMLOG}" = "xyes"; then - AC_DEFINE([ENABLE_VMLOG], 1, [enable vmlog tracing code]) -fi - - -dnl check for disassembler support -AC_MSG_CHECKING(whether disassembler should be enabled) -AC_ARG_ENABLE([disassembler], - [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])], - [case "${enableval}" in - yes) ENABLE_DISASSEMBLER=yes;; - *) ENABLE_DISASSEMBLER=no;; - esac], - [ENABLE_DISASSEMBLER=no]) -AC_MSG_RESULT(${ENABLE_DISASSEMBLER}) -AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes") - -if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then - AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler]) - - dnl check for binutils headers and libraries on some architectures for the - dnl disassembler - case "${ARCH_DIR}" in - arm | i386 | powerpc | x86_64 | sparc64 | powerpc64 | s390 | m68k) - AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)]) - AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)]) - AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)]) - AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)]) - - case "${OS_DIR}" in - cygwin | darwin | netbsd | solaris) - AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))]) - ;; - esac - - case "${OS_DIR}" in - solaris) - AC_CHECK_LIB(rt, sem_init,, [AC_MSG_ERROR(cannot find librt)]) - ;; - esac - - - AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))]) - AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))]) - AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))]) - AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler]) - AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true]) - ;; - * ) - AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false]) - ;; - esac -else - AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false]) -fi - - -dnl check for statistics -AC_MSG_CHECKING(whether statistics generation should be enabled) -AC_ARG_ENABLE([statistics], - [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])], - [case "${enableval}" in - yes) ENABLE_STATISTICS=yes;; - *) ENABLE_STATISTICS=no;; - esac], - [ENABLE_STATISTICS=no]) -AC_MSG_RESULT(${ENABLE_STATISTICS}) -AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes") - -if test x"${ENABLE_STATISTICS}" = "xyes"; then - AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics]) -fi - - -dnl check for verifier -AC_MSG_CHECKING(whether classfile verification should be enabled) -AC_ARG_ENABLE([verifier], - [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=enabled]])], - [case "${enableval}" in - no) ENABLE_VERIFIER=no;; - *) ENABLE_VERIFIER=yes;; - esac], - [ENABLE_VERIFIER=yes]) -AC_MSG_RESULT(${ENABLE_VERIFIER}) -AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes") - -if test x"${ENABLE_VERIFIER}" = "xyes"; then - AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification]) -fi - - -dnl check for compiler timing -AC_MSG_CHECKING(whether real-time timing should be enabled) -AC_ARG_ENABLE([rt-timing], - [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])], - [case "${enableval}" in - yes) ENABLE_RT_TIMING=yes;; - *) ENABLE_RT_TIMING=no;; - esac], - [ENABLE_RT_TIMING=no]) -AC_MSG_RESULT(${ENABLE_RT_TIMING}) -AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes") - -if test x"${ENABLE_RT_TIMING}" = "xyes"; then - AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing]) -fi - - -dnl check for cycle count statistics -AC_MSG_CHECKING(whether cycle count statistics should be enabled) -AC_ARG_ENABLE([cycles-stats], - [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])], - [case "${enableval}" in - yes) ENABLE_CYCLES_STATS=yes;; - *) ENABLE_CYCLES_STATS=no;; - esac], - [ENABLE_CYCLES_STATS=no]) -AC_MSG_RESULT(${ENABLE_CYCLES_STATS}) -AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes") - -if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then - AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics]) -fi - - -dnl check for JVMTI -AC_MSG_CHECKING(whether to compile JVMTI support) -AC_ARG_ENABLE([jvmti], - [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])], - [case "${enableval}" in - yes) ENABLE_JVMTI=yes;; - *) ENABLE_JVMTI=no;; - esac], - [ENABLE_JVMTI=no]) -AC_MSG_RESULT(${ENABLE_JVMTI}) -AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes") - -if test x"${ENABLE_JVMTI}" = "xyes"; then - AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI]) -fi - - +AC_CHECK_ENABLE_MEMCHECK +AC_CHECK_ENABLE_HANDLES +AC_CHECK_ENABLE_VMLOG +AC_CHECK_ENABLE_DISASSEMBLER +AC_CHECK_ENABLE_STATISTICS +AC_CHECK_ENABLE_VERIFIER +AC_CHECK_ENABLE_RT_TIMING +AC_CHECK_ENABLE_CYCLE_STATS +AC_CHECK_ENABLE_JVMTI AC_CHECK_ENABLE_THREADS - - -dnl check if if-conversion should be supported -AC_MSG_CHECKING(whether if-conversion should be supported) -AC_ARG_ENABLE([ifconv], - [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=enabled]])], - [case "${enableval}" in - no) ENABLE_IFCONV=no;; - *) ENABLE_IFCONV=yes;; - esac], - [ENABLE_IFCONV=yes]) -AC_MSG_RESULT(${ENABLE_IFCONV}) -AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes") - -if test x"${ENABLE_IFCONV}" = "xyes"; then - AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion]) -fi - - -dnl check for inlining -AC_MSG_CHECKING(whether method inlining should be supported) -AC_ARG_ENABLE([inlining], - [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])], - [case "${enableval}" in - yes) ENABLE_INLINING=yes;; - *) ENABLE_INLINING=no;; - esac], - [ENABLE_INLINING=no]) -AC_MSG_RESULT(${ENABLE_INLINING}) -AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes") - -if test x"${ENABLE_INLINING}" = "xyes"; then - AC_DEFINE([ENABLE_INLINING], 1, [use method inlining]) -fi - - -dnl check for inlining debug options -AC_MSG_CHECKING(whether method inlining debug options should be enabled) -AC_ARG_ENABLE([inlining-debug], - [AS_HELP_STRING(--enable-inlining-debug,enable method inlining debug options [[default=no]])], - [case "${enableval}" in - yes) ENABLE_INLINING_DEBUG=yes;; - *) ENABLE_INLINING_DEBUG=no;; - esac], - [ENABLE_INLINING_DEBUG=no]) -AC_MSG_RESULT(${ENABLE_INLINING_DEBUG}) -AM_CONDITIONAL([ENABLE_INLINING_DEBUG], test x"${ENABLE_INLINING_DEBUG}" = "xyes") - -if test x"${ENABLE_INLINING_DEBUG}" = "xyes"; then - AC_DEFINE([ENABLE_INLINING_DEBUG], 1, [enable method inlining debug options]) -fi - - -dnl check for replacement -AC_MSG_CHECKING(whether on-stack replacement should be supported) -AC_ARG_ENABLE([replacement], - [AS_HELP_STRING(--enable-replacement,enable on-stack replacement [[default=no]])], - [case "${enableval}" in - yes) ENABLE_REPLACEMENT=yes;; - *) ENABLE_REPLACEMENT=no;; - esac], - [ENABLE_REPLACEMENT=no]) -AC_MSG_RESULT(${ENABLE_REPLACEMENT}) -AM_CONDITIONAL([ENABLE_REPLACEMENT], test x"${ENABLE_REPLACEMENT}" = "xyes") - -if test x"${ENABLE_REPLACEMENT}" = "xyes"; then - AC_DEFINE([ENABLE_REPLACEMENT], 1, [use on-stack replacement]) -fi - +AC_CHECK_ENABLE_IFCONV +AC_CHECK_ENABLE_INLINING +AC_CHECK_ENABLE_INLINING_DEBUG +AC_CHECK_ENABLE_REPLACEMENT dnl check for loop optimization AC_MSG_CHECKING(whether loop optimization should be supported) @@ -668,11 +462,13 @@ AC_MSG_RESULT(${ENABLE_SSA}) AM_CONDITIONAL([ENABLE_SSA], test x"${ENABLE_SSA}" = "xyes") AM_CONDITIONAL([ENABLE_ESCAPE], test x"${ENABLE_SSA}" = "xyes") AM_CONDITIONAL([ENABLE_ESCAPE_CHECK], test x"${ENABLE_SSA}" = "xyes") +AM_CONDITIONAL([ENABLE_TLH], test x"${ENABLE_SSA}" = "xyes") if test x"${ENABLE_SSA}" = "xyes"; then AC_DEFINE([ENABLE_SSA], 1, [enable lsra with ssa]) AC_DEFINE([ENABLE_ESCAPE], 1, [enable escape analysis with ssa]) AC_DEFINE([ENABLE_ESCAPE_CHECK], 1, [enable generating code to validate escape analysis results]) + AC_DEFINE([ENABLE_TLH], 1, [enable thread local heap]) ENABLE_LSRA="no" fi @@ -737,6 +533,7 @@ else AM_CONDITIONAL([USE_SCHEDULER], [false]) fi +AC_CHECK_ENABLE_OPAGENT AC_CHECK_ENABLE_ZLIB @@ -754,19 +551,9 @@ AC_CHECK_ENABLE_STATICVM AC_CHECK_ENABLE_ANNOTATIONS AC_CHECK_ENABLE_ASSERTION +dnl This one depends on AC_CHECK_ENABLE_ZLIB. +AC_CHECK_WITH_VM_ZIP -dnl where is CACAO's vm.zip -AC_MSG_CHECKING(where CACAO's vm.zip is installed) -AC_ARG_WITH([vm-zip], - [AS_HELP_STRING(--with-vm-zip=,path to CACAO's vm.zip (includes the name of the file and may be flat) [[default=/usr/local/cacao/share/cacao/vm.zip]])], - [CACAO_VM_ZIP=${withval}], - [CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/vm.zip]) -AC_MSG_RESULT(${CACAO_VM_ZIP}) -AC_DEFINE_UNQUOTED([CACAO_VM_ZIP], "${CACAO_VM_ZIP}", [CACAO's vm.zip]) -AC_SUBST(CACAO_VM_ZIP) - - -AC_CHECK_WITH_CACAOH AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY dnl Now we check for jre-layout so we can skip some checks that are @@ -775,6 +562,7 @@ AC_CHECK_ENABLE_JRE_LAYOUT AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_PREFIX AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_CLASSES +AC_CHECK_WITH_BUILD_JAVA_RUNTIME_LIBRARY_CLASSES if test x"${ENABLE_JRE_LAYOUT}" = "xno"; then AC_CHECK_WITH_JAVA_RUNTIME_LIBRARY_LIBDIR @@ -808,6 +596,8 @@ case "${WITH_JAVA_RUNTIME_LIBRARY}" in ;; esac +AC_CHECK_WITH_JASMIN_JAR +AC_CHECK_WITH_JUNIT_JAR AC_CHECK_HEADERS( [regex.h], @@ -837,14 +627,21 @@ AZ_PYTHON_LSPEC dnl define some stuff required for --fullversion AC_DEFINE_UNQUOTED(VERSION_CONFIGURE_ARGS, "$ac_configure_args", [configure arguments]) AC_DEFINE_UNQUOTED(VERSION_CC, "$CC", [CC used]) -AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CPPFLAGS", [CFLAGS used]) +AC_DEFINE_UNQUOTED(VERSION_CXX, "$CXX", [CXX used]) +AC_DEFINE_UNQUOTED(VERSION_CFLAGS, "$OPT_CFLAGS $ARCH_CFLAGS $CC_FLAGS $CPPFLAGS", [CFLAGS used]) +AC_DEFINE_UNQUOTED(VERSION_CXXFLAGS, "$OPT_CXXFLAGS $ARCH_CXXFLAGS $CXX_FLAGS $CPPFLAGS", [CXXFLAGS used]) -dnl finally pass CFLAGS to Makefiles via AM_CFLAGS +dnl Finally pass flags to Makefiles. CFLAGS="$OPT_CFLAGS" -AM_CFLAGS=$ARCH_CFLAGS +CXXFLAGS="$OPT_CXXFLAGS" + +AM_CFLAGS="$CC_FLAGS $ARCH_FLAGS $OS_FLAGS" +AM_CXXFLAGS="$CXX_FLAGS $ARCH_FLAGS $OS_FLAGS" AM_CPPFLAGS="$CPPFLAGS" + AC_SUBST(AM_CFLAGS) +AC_SUBST(AM_CXXFLAGS) AC_SUBST(AM_CPPFLAGS) @@ -860,7 +657,6 @@ AC_CONFIG_FILES([Makefile] [man/Makefile] [src/Makefile] [src/cacao/Makefile] - [src/cacaoh/Makefile] [src/classes/Makefile] [src/fdlibm/Makefile] [src/mm/Makefile] @@ -891,6 +687,7 @@ AC_CONFIG_FILES([Makefile] [src/vm/jit/i386/darwin/Makefile] [src/vm/jit/i386/freebsd/Makefile] [src/vm/jit/i386/linux/Makefile] + [src/vm/jit/i386/solaris/Makefile] [src/vm/jit/intrp/Makefile] [src/vm/jit/inline/Makefile] [src/vm/jit/ir/Makefile] @@ -919,13 +716,13 @@ AC_CONFIG_FILES([Makefile] [src/vm/jit/x86_64/Makefile] [src/vm/jit/x86_64/freebsd/Makefile] [src/vm/jit/x86_64/linux/Makefile] - [src/vmcore/Makefile] + [src/vm/jit/x86_64/solaris/Makefile] [tests/Makefile] [tests/regression/Makefile] - [tests/regression/bugzilla/Makefile] [tests/regression/assertion/Makefile] + [tests/regression/base/Makefile] + [tests/regression/bugzilla/Makefile] [tests/regression/jasmin/Makefile] - [tests/regression/junit/Makefile] [tests/regression/native/Makefile] [tests/regression/resolving/Makefile] [tests/regression/resolving/classes1/Makefile] @@ -934,11 +731,8 @@ AC_CONFIG_FILES([Makefile] ) -dnl now configure subpackages with OPT_CFLAGS and ARCH_CFLAGS -export OPT_CFLAGS -export ARCH_CFLAGS dnl We only build the shared library objects but we use it as -dnl noinst_LTLIBRARIES +dnl noinst_LTLIBRARIES. ac_configure_args="$ac_configure_args --disable-static" AC_CONFIG_SUBDIRS(src/mm/boehm-gc) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 57803bd3a..a37279b65 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -23,6 +23,9 @@ SUBDIRS = vmlog +EXTRA_DIST = \ + mapfile-vers-product + noinst_DATA = \ setenvinstalled.in \ setenvsource.in diff --git a/contrib/mapfile-vers-product b/contrib/mapfile-vers-product index 5d23dfa6a..d414e6358 100644 --- a/contrib/mapfile-vers-product +++ b/contrib/mapfile-vers-product @@ -31,7 +31,7 @@ SUNWprivate_1.1 { global: # CACAO - vm_createjvm; + VM_create; vm_run; # JNI diff --git a/contrib/svn2cl.xsl b/contrib/svn2cl.xsl deleted file mode 100644 index 1333b9434..000000000 --- a/contrib/svn2cl.xsl +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - - -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &newl; - - - - - - - - - - - - - - - - - - - - - - - - - - - &newl; - - - - - &space;&space; - - - - &newl;&newl; - - - - - :&space; - - - - - [r - - ]&space; - - - - - - - &newl; - - - - - - - &tab; - - - - - - - - - - - - - - &space; - - - - - - - - - - - - - - - - - - - - - - - - - - ,&space; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - . - - - - - - - - - - - - - - - - - - &tab; - - - - - - - - - - &newl; - - - - - - - - - - - - - - - - - - - &newl;&tab; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/doxygen/Makefile.am b/doc/doxygen/Makefile.am index c75bf12b8..2ea19e9a5 100644 --- a/doc/doxygen/Makefile.am +++ b/doc/doxygen/Makefile.am @@ -25,7 +25,7 @@ dist_noinst_DATA = \ Doxyfile doxygen: - doxygen + doxygen $(srcdir)/Doxyfile clean-local: -rm -rf html latex diff --git a/m4/cacaoh.m4 b/m4/cacaoh.m4 deleted file mode 100644 index 1c19667e8..000000000 --- a/m4/cacaoh.m4 +++ /dev/null @@ -1,34 +0,0 @@ -dnl m4/cacaoh.m4 -dnl -dnl Copyright (C) 2007, 2008 -dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO -dnl -dnl This file is part of CACAO. -dnl -dnl This program is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU General Public License as -dnl published by the Free Software Foundation; either version 2, or (at -dnl your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, but -dnl WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this program; if not, write to the Free Software -dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -dnl 02110-1301, USA. - - -dnl check which cacaoh to use - -AC_DEFUN([AC_CHECK_WITH_CACAOH],[ -AC_MSG_CHECKING(which cacaoh to use (for crosscompilation)) -AC_ARG_WITH([cacaoh], - [AS_HELP_STRING(--with-cacaoh,which cacaoh to use [[default=$(top_builddir)/src/cacaoh/cacaoh]])], - [CACAOH="${withval}"], - [CACAOH=["\$(top_builddir)/src/cacaoh/cacaoh"]]) -AC_MSG_RESULT(${CACAOH}) -AC_SUBST(CACAOH) -]) diff --git a/m4/cycle-stats.m4 b/m4/cycle-stats.m4 new file mode 100644 index 000000000..c474adc83 --- /dev/null +++ b/m4/cycle-stats.m4 @@ -0,0 +1,41 @@ +dnl m4/cycle-stats.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for cycle count statistics + +AC_DEFUN([AC_CHECK_ENABLE_CYCLE_STATS],[ +AC_MSG_CHECKING(whether cycle count statistics should be enabled) +AC_ARG_ENABLE([cycles-stats], + [AS_HELP_STRING(--enable-cycles-stats,enable cycle count statistics [[default=no]])], + [case "${enableval}" in + yes) ENABLE_CYCLES_STATS=yes;; + *) ENABLE_CYCLES_STATS=no;; + esac], + [ENABLE_CYCLES_STATS=no]) +AC_MSG_RESULT(${ENABLE_CYCLES_STATS}) +AM_CONDITIONAL([ENABLE_CYCLES_STATS], test x"${ENABLE_CYCLES_STATS}" = "xyes") + +if test x"${ENABLE_CYCLES_STATS}" = "xyes"; then + AC_DEFINE([ENABLE_CYCLES_STATS], 1, [enable cycle count statistics]) +fi +]) diff --git a/m4/disassembler.m4 b/m4/disassembler.m4 new file mode 100644 index 000000000..b45333c19 --- /dev/null +++ b/m4/disassembler.m4 @@ -0,0 +1,76 @@ +dnl m4/disassembler.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for disassembler support + +AC_DEFUN([AC_CHECK_ENABLE_DISASSEMBLER],[ +AC_MSG_CHECKING(whether disassembler should be enabled) +AC_ARG_ENABLE([disassembler], + [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])], + [case "${enableval}" in + yes) ENABLE_DISASSEMBLER=yes;; + *) ENABLE_DISASSEMBLER=no;; + esac], + [ENABLE_DISASSEMBLER=no]) +AC_MSG_RESULT(${ENABLE_DISASSEMBLER}) +AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes") + +if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then + AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler]) + + dnl check for binutils headers and libraries on some architectures for the + dnl disassembler + case "${ARCH_DIR}" in + arm | i386 | powerpc | x86_64 | sparc64 | powerpc64 | s390 | m68k) + AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)]) + AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)]) + AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)]) + AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)]) + + case "${OS_DIR}" in + cygwin | darwin | netbsd | solaris) + AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))]) + ;; + esac + + case "${OS_DIR}" in + solaris) + AC_CHECK_LIB(rt, sem_init,, [AC_MSG_ERROR(cannot find librt)]) + ;; + esac + + + AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))]) + AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))]) + AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))]) + AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler]) + AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true]) + ;; + * ) + AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false]) + ;; + esac +else + AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false]) +fi +]) diff --git a/m4/dl.m4 b/m4/dl.m4 new file mode 100644 index 000000000..039e8993f --- /dev/null +++ b/m4/dl.m4 @@ -0,0 +1,55 @@ +dnl m4/dl.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check if dynamic library loading should be used + +AC_DEFUN([AC_CHECK_ENABLE_DL],[ +AC_MSG_CHECKING(whether to support dynamic library loading) +AC_ARG_ENABLE([dl], + [AS_HELP_STRING(--disable-dl,disable dynamic library loading (needs libdl) [[default=enabled]])], + [case "${enableval}" in + no) ENABLE_DL=no;; + *) ENABLE_DL=yes;; + esac], + [ENABLE_DL=yes]) +AC_MSG_RESULT(${ENABLE_DL}) + +if test x"${ENABLE_DL}" = "xyes"; then + AC_CHECK_HEADERS([dlfcn.h],, [AC_MSG_ERROR(cannot find dlfcn.h)]) + + case "${OS_DIR}" in + netbsd ) + dnl There is no libdl on NetBSD (see PR96). + ;; + *) + AC_CHECK_LIB([dl], [dlopen],, [AC_MSG_ERROR(cannot find libdl)]) + ;; + esac + + AC_CHECK_FUNCS([dlclose]) + AC_CHECK_FUNCS([dlerror]) + AC_CHECK_FUNCS([dlopen]) + AC_CHECK_FUNCS([dlsym]) + AC_DEFINE([ENABLE_DL], 1, [Enable dynamic library loading.]) +fi +]) diff --git a/m4/handles.m4 b/m4/handles.m4 new file mode 100644 index 000000000..3e1fae12a --- /dev/null +++ b/m4/handles.m4 @@ -0,0 +1,41 @@ +dnl m4/handles.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for handles (indirection cells) support + +AC_DEFUN([AC_CHECK_ENABLE_HANDLES],[ +AC_MSG_CHECKING(whether handles (indirection cells) should be enabled) +AC_ARG_ENABLE([handles], + [AS_HELP_STRING(--enable-handles,enable handles (indirection cells) [[default=no]])], + [case "${enableval}" in + yes) ENABLE_HANDLES=yes;; + *) ENABLE_HANDLES=no;; + esac], + [ENABLE_HANDLES=no]) +AC_MSG_RESULT(${ENABLE_HANDLES}) +AM_CONDITIONAL([ENABLE_HANDLES], test x"${ENABLE_HANDLES}" = "xyes") + +if test x"${ENABLE_HANDLES}" = "xyes"; then + AC_DEFINE([ENABLE_HANDLES], 1, [enable handles (indirection cells)]) +fi +]) diff --git a/m4/ifconv.m4 b/m4/ifconv.m4 new file mode 100644 index 000000000..78bcb4f98 --- /dev/null +++ b/m4/ifconv.m4 @@ -0,0 +1,41 @@ +dnl m4/ifconv.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check if if-conversion should be supported + +AC_DEFUN([AC_CHECK_ENABLE_IFCONV],[ +AC_MSG_CHECKING(whether if-conversion should be supported) +AC_ARG_ENABLE([ifconv], + [AS_HELP_STRING(--disable-ifconv,disable if-conversion [[default=enabled]])], + [case "${enableval}" in + no) ENABLE_IFCONV=no;; + *) ENABLE_IFCONV=yes;; + esac], + [ENABLE_IFCONV=yes]) +AC_MSG_RESULT(${ENABLE_IFCONV}) +AM_CONDITIONAL([ENABLE_IFCONV], test x"${ENABLE_IFCONV}" = "xyes") + +if test x"${ENABLE_IFCONV}" = "xyes"; then + AC_DEFINE([ENABLE_IFCONV], 1, [enable if-conversion]) +fi +]) diff --git a/m4/inlining.m4 b/m4/inlining.m4 new file mode 100644 index 000000000..00a8c161a --- /dev/null +++ b/m4/inlining.m4 @@ -0,0 +1,61 @@ +dnl m4/inlining.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for inlining + +AC_DEFUN([AC_CHECK_ENABLE_INLINING],[ +AC_MSG_CHECKING(whether method inlining should be supported) +AC_ARG_ENABLE([inlining], + [AS_HELP_STRING(--enable-inlining,enable method inlining [[default=no]])], + [case "${enableval}" in + yes) ENABLE_INLINING=yes;; + *) ENABLE_INLINING=no;; + esac], + [ENABLE_INLINING=no]) +AC_MSG_RESULT(${ENABLE_INLINING}) +AM_CONDITIONAL([ENABLE_INLINING], test x"${ENABLE_INLINING}" = "xyes") + +if test x"${ENABLE_INLINING}" = "xyes"; then + AC_DEFINE([ENABLE_INLINING], 1, [use method inlining]) +fi +]) + + +dnl check for inlining debug options + +AC_DEFUN([AC_CHECK_ENABLE_INLINING_DEBUG],[ +AC_MSG_CHECKING(whether method inlining debug options should be enabled) +AC_ARG_ENABLE([inlining-debug], + [AS_HELP_STRING(--enable-inlining-debug,enable method inlining debug options [[default=no]])], + [case "${enableval}" in + yes) ENABLE_INLINING_DEBUG=yes;; + *) ENABLE_INLINING_DEBUG=no;; + esac], + [ENABLE_INLINING_DEBUG=no]) +AC_MSG_RESULT(${ENABLE_INLINING_DEBUG}) +AM_CONDITIONAL([ENABLE_INLINING_DEBUG], test x"${ENABLE_INLINING_DEBUG}" = "xyes") + +if test x"${ENABLE_INLINING_DEBUG}" = "xyes"; then + AC_DEFINE([ENABLE_INLINING_DEBUG], 1, [enable method inlining debug options]) +fi +]) diff --git a/m4/jasmin.m4 b/m4/jasmin.m4 new file mode 100644 index 000000000..14e0cde53 --- /dev/null +++ b/m4/jasmin.m4 @@ -0,0 +1,34 @@ +dnl m4/jasmin.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl Check location of Jasmin jar file. + +AC_DEFUN([AC_CHECK_WITH_JASMIN_JAR],[ +AC_MSG_CHECKING(location of Jasmin jar) +AC_ARG_WITH([jasmin-jar], + [AS_HELP_STRING(--with-jasmin-jar=,location of Jasmin jar file [[default=/usr/share/java/cup.jar:/usr/share/java/jasmin-sable.jar]])], + [JASMIN_JAR="${withval}"], + [JASMIN_JAR="/usr/share/java/cup.jar:/usr/share/java/jasmin-sable.jar"]) +AC_MSG_RESULT(${JASMIN_JAR}) +AC_SUBST(JASMIN_JAR) +]) diff --git a/m4/java-runtime-library.m4 b/m4/java-runtime-library.m4 index d69cf7e07..587ddfaf9 100644 --- a/m4/java-runtime-library.m4 +++ b/m4/java-runtime-library.m4 @@ -92,14 +92,28 @@ AC_ARG_WITH([java-runtime-library-classes], AC_MSG_RESULT(${JAVA_RUNTIME_LIBRARY_CLASSES}) AC_DEFINE_UNQUOTED([JAVA_RUNTIME_LIBRARY_CLASSES], "${JAVA_RUNTIME_LIBRARY_CLASSES}", [Java runtime library classes]) AC_SUBST(JAVA_RUNTIME_LIBRARY_CLASSES) +]) + + +dnl where are Java core library classes located at compilation time + +AC_DEFUN([AC_CHECK_WITH_BUILD_JAVA_RUNTIME_LIBRARY_CLASSES],[ +AC_MSG_CHECKING(where Java core library classes are located at compile time) +AC_ARG_WITH([build-java-runtime-library-classes], + [AS_HELP_STRING(--with-build-java-runtime-library-classes=,path to Java core library classes (includes the name of the file and may be flat) [[default=${JAVA_RUNTIME_LIBRARY_CLASSES}]])], + [BUILD_JAVA_RUNTIME_LIBRARY_CLASSES=${withval}], + [BUILD_JAVA_RUNTIME_LIBRARY_CLASSES=${JAVA_RUNTIME_LIBRARY_CLASSES}]) +AC_MSG_RESULT(${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}) +AC_DEFINE_UNQUOTED([BUILD_JAVA_RUNTIME_LIBRARY_CLASSES], "${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}", [Java core library classes at compile time]) +AC_SUBST(BUILD_JAVA_RUNTIME_LIBRARY_CLASSES) dnl define BOOTCLASSPATH for Makefiles case "${WITH_JAVA_RUNTIME_LIBRARY}" in cldc1.1 | gnuclasspath) - BOOTCLASSPATH="\$(top_builddir)/src/classes/classes:\$(JAVA_RUNTIME_LIBRARY_CLASSES)" + BOOTCLASSPATH="\$(top_builddir)/src/classes/classes:${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}" ;; *) - BOOTCLASSPATH="\$(JAVA_RUNTIME_LIBRARY_CLASSES)" + BOOTCLASSPATH="${BUILD_JAVA_RUNTIME_LIBRARY_CLASSES}" ;; esac AC_SUBST(BOOTCLASSPATH) diff --git a/m4/junit.m4 b/m4/junit.m4 new file mode 100644 index 000000000..1df6db50f --- /dev/null +++ b/m4/junit.m4 @@ -0,0 +1,34 @@ +dnl m4/junit.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl Check location of JUnit jar file. + +AC_DEFUN([AC_CHECK_WITH_JUNIT_JAR],[ +AC_MSG_CHECKING(location of JUnit jar) +AC_ARG_WITH([junit-jar], + [AS_HELP_STRING(--with-junit-jar=,location of JUnit jar file [[default=/usr/share/java/junit4.jar]])], + [JUNIT_JAR="${withval}"], + [JUNIT_JAR="/usr/share/java/junit4.jar"]) +AC_MSG_RESULT(${JUNIT_JAR}) +AC_SUBST(JUNIT_JAR) +]) diff --git a/m4/jvmti.m4 b/m4/jvmti.m4 new file mode 100644 index 000000000..7ee27ad75 --- /dev/null +++ b/m4/jvmti.m4 @@ -0,0 +1,41 @@ +dnl m4/jvmti.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for JVMTI + +AC_DEFUN([AC_CHECK_ENABLE_JVMTI],[ +AC_MSG_CHECKING(whether to compile JVMTI support) +AC_ARG_ENABLE([jvmti], + [AS_HELP_STRING(--enable-jvmti,enable JVMTI [[default=no]])], + [case "${enableval}" in + yes) ENABLE_JVMTI=yes;; + *) ENABLE_JVMTI=no;; + esac], + [ENABLE_JVMTI=no]) +AC_MSG_RESULT(${ENABLE_JVMTI}) +AM_CONDITIONAL([ENABLE_JVMTI], test x"${ENABLE_JVMTI}" = "xyes") + +if test x"${ENABLE_JVMTI}" = "xyes"; then + AC_DEFINE([ENABLE_JVMTI], 1, [use JVMTI]) +fi +]) diff --git a/m4/ltdl.m4 b/m4/ltdl.m4 deleted file mode 100644 index 6a7b174ca..000000000 --- a/m4/ltdl.m4 +++ /dev/null @@ -1,55 +0,0 @@ -dnl m4/ltdl.m4 -dnl -dnl Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, -dnl C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -dnl E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -dnl J. Wenninger, Institut f. Computersprachen - TU Wien -dnl -dnl This file is part of CACAO. -dnl -dnl This program is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU General Public License as -dnl published by the Free Software Foundation; either version 2, or (at -dnl your option) any later version. -dnl -dnl This program is distributed in the hope that it will be useful, but -dnl WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with this program; if not, write to the Free Software -dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -dnl 02110-1301, USA. - - -dnl check if ltdl should be used - -AC_DEFUN([AC_CHECK_ENABLE_LTDL],[ -AC_MSG_CHECKING(whether ltdl should be used) -AC_ARG_ENABLE([ltdl], - [AS_HELP_STRING(--disable-ltdl,disable ltdl support [[default=enabled]])], - [case "${enableval}" in - no) - ENABLE_LTDL=no - ;; - *) - ENABLE_LTDL=yes - ;; - esac], - [ENABLE_LTDL=yes]) -AC_MSG_RESULT(${ENABLE_LTDL}) - -if test x"${ENABLE_LTDL}" = "xyes"; then - dnl we need this check for --enable-staticvm, otherwise ltdl can't find dlopen - if test x"${ENABLE_STATICVM}" = "xyes"; then - AC_CHECK_LIB(dl, dlopen,, [AC_MSG_ERROR(cannot find libdl)]) - fi - - AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)]) - AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)]) - AC_DEFINE([ENABLE_LTDL], 1, [use ltdl]) -fi - -AM_CONDITIONAL([ENABLE_LTDL], test x"${ENABLE_LTDL}" = "xyes") -]) diff --git a/m4/memcheck.m4 b/m4/memcheck.m4 new file mode 100644 index 000000000..008990f3c --- /dev/null +++ b/m4/memcheck.m4 @@ -0,0 +1,41 @@ +dnl m4/memcheck.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for memcheck support + +AC_DEFUN([AC_CHECK_ENABLE_MEMCHECK],[ +AC_MSG_CHECKING(whether debugging memory checks should be enabled) +AC_ARG_ENABLE([memcheck], + [AS_HELP_STRING(--enable-memcheck,enable debugging memory checks [[default=no]])], + [case "${enableval}" in + yes) ENABLE_MEMCHECK=yes;; + *) ENABLE_MEMCHECK=no;; + esac], + [ENABLE_MEMCHECK=no]) +AC_MSG_RESULT(${ENABLE_MEMCHECK}) +AM_CONDITIONAL([ENABLE_MEMCHECK], test x"${ENABLE_MEMCHECK}" = "xyes") + +if test x"${ENABLE_MEMCHECK}" = "xyes"; then + AC_DEFINE([ENABLE_MEMCHECK], 1, [perform debugging memory checks]) +fi +]) diff --git a/m4/opagent.m4 b/m4/opagent.m4 new file mode 100644 index 000000000..5b5596102 --- /dev/null +++ b/m4/opagent.m4 @@ -0,0 +1,58 @@ +dnl m4/opagent.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + +dnl check if opagent library should be used + +AC_DEFUN([AC_CHECK_ENABLE_OPAGENT],[ +AC_ARG_WITH([opagent-includedir], + [AS_HELP_STRING(--with-opagent-includedir=,location of opagent header files [[default=/usr/include]])], + [OPAGENT_CFLAGS=-I"${withval}"], + []) +AC_SUBST(OPAGENT_CFLAGS) + +AC_ARG_WITH([opagent-libdir], + [AS_HELP_STRING(--with-opagent-libdir=,location of opagent library [[default=/usr/lib/oprofile]])], + [OPAGENT_LDFLAGS=-L"${withval}"], + [OPAGENT_LDFLAGS=-L/usr/lib/oprofile]) +AC_SUBST(OPAGENT_LDFLAGS) + +AC_MSG_CHECKING(whether Oprofile opagent support code should be compiled) +AC_ARG_ENABLE([opagent], + [AS_HELP_STRING(--enable-opagent,enable opagent library support [[default=disabled]])], + [case "${enableval}" in + yes) ENABLE_OPAGENT=yes;; + *) ENABLE_OPAGENT=no;; + esac], + [ENABLE_OPAGENT=no]) +AC_MSG_RESULT(${ENABLE_OPAGENT}) + +if test x"${ENABLE_OPAGENT}" = "xyes"; then + CFLAGS="$CFLAGS $OPAGENT_CFLAGS" + CPPFLAGS="$CPPFLAGS $OPAGENT_CFLAGS" + LDFLAGS="$LDFLAGS $OPAGENT_LDFLAGS" + AC_CHECK_HEADERS([opagent.h],, [AC_MSG_ERROR(cannot find opagent.h)]) + AC_CHECK_LIB(opagent, op_open_agent,, [AC_MSG_ERROR(cannot find libopagent)]) + AC_DEFINE([ENABLE_OPAGENT], 1, [use opagent]) +fi +AM_CONDITIONAL([ENABLE_OPAGENT], [test x"${ENABLE_OPAGENT}" = "xyes"]) +]) + diff --git a/m4/replacement.m4 b/m4/replacement.m4 new file mode 100644 index 000000000..0a891be6f --- /dev/null +++ b/m4/replacement.m4 @@ -0,0 +1,41 @@ +dnl m4/replacement.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for replacement + +AC_DEFUN([AC_CHECK_ENABLE_REPLACEMENT],[ +AC_MSG_CHECKING(whether on-stack replacement should be supported) +AC_ARG_ENABLE([replacement], + [AS_HELP_STRING(--enable-replacement,enable on-stack replacement [[default=no]])], + [case "${enableval}" in + yes) ENABLE_REPLACEMENT=yes;; + *) ENABLE_REPLACEMENT=no;; + esac], + [ENABLE_REPLACEMENT=no]) +AC_MSG_RESULT(${ENABLE_REPLACEMENT}) +AM_CONDITIONAL([ENABLE_REPLACEMENT], test x"${ENABLE_REPLACEMENT}" = "xyes") + +if test x"${ENABLE_REPLACEMENT}" = "xyes"; then + AC_DEFINE([ENABLE_REPLACEMENT], 1, [use on-stack replacement]) +fi +]) diff --git a/m4/rt-timing.m4 b/m4/rt-timing.m4 new file mode 100644 index 000000000..c2e85f8c1 --- /dev/null +++ b/m4/rt-timing.m4 @@ -0,0 +1,41 @@ +dnl m4/rt-timing.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for compiler timing + +AC_DEFUN([AC_CHECK_ENABLE_RT_TIMING],[ +AC_MSG_CHECKING(whether real-time timing should be enabled) +AC_ARG_ENABLE([rt-timing], + [AS_HELP_STRING(--enable-rt-timing,enable real-time timing [[default=no]])], + [case "${enableval}" in + yes) ENABLE_RT_TIMING=yes;; + *) ENABLE_RT_TIMING=no;; + esac], + [ENABLE_RT_TIMING=no]) +AC_MSG_RESULT(${ENABLE_RT_TIMING}) +AM_CONDITIONAL([ENABLE_RT_TIMING], test x"${ENABLE_RT_TIMING}" = "xyes") + +if test x"${ENABLE_RT_TIMING}" = "xyes"; then + AC_DEFINE([ENABLE_RT_TIMING], 1, [enable real-time timing]) +fi +]) diff --git a/m4/statistics.m4 b/m4/statistics.m4 new file mode 100644 index 000000000..2ee82c0ed --- /dev/null +++ b/m4/statistics.m4 @@ -0,0 +1,41 @@ +dnl m4/statistics.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for statistics + +AC_DEFUN([AC_CHECK_ENABLE_STATISTICS],[ +AC_MSG_CHECKING(whether statistics generation should be enabled) +AC_ARG_ENABLE([statistics], + [AS_HELP_STRING(--enable-statistics,enable statistics generation [[default=no]])], + [case "${enableval}" in + yes) ENABLE_STATISTICS=yes;; + *) ENABLE_STATISTICS=no;; + esac], + [ENABLE_STATISTICS=no]) +AC_MSG_RESULT(${ENABLE_STATISTICS}) +AM_CONDITIONAL([ENABLE_STATISTICS], test x"${ENABLE_STATISTICS}" = "xyes") + +if test x"${ENABLE_STATISTICS}" = "xyes"; then + AC_DEFINE([ENABLE_STATISTICS], 1, [enable statistics]) +fi +]) diff --git a/m4/threads.m4 b/m4/threads.m4 index 08cc6f8ed..c1acf9bae 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -57,10 +57,11 @@ case "${ENABLE_THREADS}" in AC_DEFINE([ENABLE_THREADS], 1, [enable threads]) AC_CHECK_LIB(pthread, main) - ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT" + OS_FLAGS="$OS_FLAGS -D_REENTRANT" - dnl we changed ARCH_CFLAGS, set CFLAGS again - CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS" + dnl We changed OS_FLAGS, set CFLAGS again. + CFLAGS="$OPT_CFLAGS $ARCH_FLAGS $OS_FLAGS $CC_FLAGS" + CXXFLAGS="$OPT_CXXFLAGS $ARCH_FLAGS $OS_FLAGS $CXX_FLAGS" dnl tell boehm to support threads as well ac_configure_args="$ac_configure_args --enable-boehm-threads=posix" diff --git a/m4/verifier.m4 b/m4/verifier.m4 new file mode 100644 index 000000000..96141e081 --- /dev/null +++ b/m4/verifier.m4 @@ -0,0 +1,41 @@ +dnl m4/verifier.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for verifier + +AC_DEFUN([AC_CHECK_ENABLE_VERIFIER],[ +AC_MSG_CHECKING(whether classfile verification should be enabled) +AC_ARG_ENABLE([verifier], + [AS_HELP_STRING(--disable-verifier,disable classfile verification [[default=enabled]])], + [case "${enableval}" in + no) ENABLE_VERIFIER=no;; + *) ENABLE_VERIFIER=yes;; + esac], + [ENABLE_VERIFIER=yes]) +AC_MSG_RESULT(${ENABLE_VERIFIER}) +AM_CONDITIONAL([ENABLE_VERIFIER], test x"${ENABLE_VERIFIER}" = "xyes") + +if test x"${ENABLE_VERIFIER}" = "xyes"; then + AC_DEFINE([ENABLE_VERIFIER], 1, [enable classfile verification]) +fi +]) diff --git a/m4/vm-zip.m4 b/m4/vm-zip.m4 new file mode 100644 index 000000000..85f2548a5 --- /dev/null +++ b/m4/vm-zip.m4 @@ -0,0 +1,43 @@ +dnl m4/vm-zip.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl where is CACAO's vm.zip + +AC_DEFUN([AC_CHECK_WITH_VM_ZIP],[ +AC_MSG_CHECKING(where CACAO's vm.zip is installed) +AC_ARG_WITH([vm-zip], + [AS_HELP_STRING(--with-vm-zip=,path to CACAO's vm.zip (includes the name of the file and may be flat) [[default=(--enable-zlib:${CACAO_PREFIX}/share/cacao/vm.zip,--disable-zlib:${CACAO_PREFIX}/share/cacao/classes)]])], + [CACAO_VM_ZIP=${withval}], + [case "${ENABLE_ZLIB}" in + no) + CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/classes + ;; + *) + CACAO_VM_ZIP=${CACAO_PREFIX}/share/cacao/vm.zip + ;; + esac + ]) +AC_MSG_RESULT(${CACAO_VM_ZIP}) +AC_DEFINE_UNQUOTED([CACAO_VM_ZIP], "${CACAO_VM_ZIP}", [CACAO's vm.zip]) +AC_SUBST(CACAO_VM_ZIP) +]) diff --git a/m4/vmlog.m4 b/m4/vmlog.m4 new file mode 100644 index 000000000..17d98a271 --- /dev/null +++ b/m4/vmlog.m4 @@ -0,0 +1,41 @@ +dnl m4/vmlog.m4 +dnl +dnl Copyright (C) 2008 +dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +dnl +dnl This file is part of CACAO. +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2, or (at +dnl your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +dnl 02110-1301, USA. + + +dnl check for vmlog support + +AC_DEFUN([AC_CHECK_ENABLE_VMLOG],[ +AC_MSG_CHECKING(whether vmlog tracing should be enabled) +AC_ARG_ENABLE([vmlog], + [AS_HELP_STRING(--enable-vmlog,enable vmlog tracing [[default=no]])], + [case "${enableval}" in + yes) ENABLE_VMLOG=yes;; + *) ENABLE_VMLOG=no;; + esac], + [ENABLE_VMLOG=no]) +AC_MSG_RESULT(${ENABLE_VMLOG}) +AM_CONDITIONAL([ENABLE_VMLOG], test x"${ENABLE_VMLOG}" = "xyes") + +if test x"${ENABLE_VMLOG}" = "xyes"; then + AC_DEFINE([ENABLE_VMLOG], 1, [enable vmlog tracing code]) +fi +]) diff --git a/src/Makefile.am b/src/Makefile.am index b2cb8bf2a..b1bf2b106 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,6 @@ DIST_SUBDIRS = \ cacao \ - cacaoh \ classes \ fdlibm \ mm \ @@ -31,21 +30,18 @@ DIST_SUBDIRS = \ scripts \ threads \ toolbox \ - vm \ - vmcore + vm # DON'T CHANGE THIS ORDER!!! SUBDIRS = \ - toolbox \ - vmcore \ - cacaoh \ classes \ - native \ fdlibm \ + toolbox \ mm \ - threads \ vm \ + threads \ + native \ cacao \ scripts diff --git a/src/cacao/Makefile.am b/src/cacao/Makefile.am index 2a5247afd..0f59f3228 100644 --- a/src/cacao/Makefile.am +++ b/src/cacao/Makefile.am @@ -35,11 +35,17 @@ lib_LTLIBRARIES = \ libjvm.la libjvm_la_LDFLAGS = \ - -version-info 1:0:0 + -avoid-version if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK +if WITH_GNU_LD libjvm_la_LDFLAGS += \ -Xlinker --version-script=$(top_srcdir)/contrib/mapfile-vers-product +else +# This is for the Solaris LD. +libjvm_la_LDFLAGS += \ + -Xlinker -M$(top_srcdir)/contrib/mapfile-vers-product +endif endif cacao_LDFLAGS += \ @@ -68,6 +74,11 @@ endif libjvm_la_SOURCES = +# Dummy C++ source to cause C++ linking. +# http://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries +nodist_EXTRA_libjvm_la_SOURCES = \ + dummy.cxx + libjvm_la_LIBADD = \ $(top_builddir)/src/fdlibm/libfdlibm.la \ $(top_builddir)/src/mm/libmm.la \ @@ -75,14 +86,13 @@ libjvm_la_LIBADD = \ $(top_builddir)/src/threads/libthreads.la \ $(top_builddir)/src/toolbox/libtoolbox.la \ $(top_builddir)/src/vm/libvm.la \ - $(top_builddir)/src/vmcore/libvmcore.la \ $(GC_LIB) bin_PROGRAMS = \ cacao cacao_SOURCES = \ - cacao.c + cacao.cpp cacao_LDADD = \ $(CACAO_LIBS) @@ -91,6 +101,20 @@ cacao_DEPENDENCIES = \ $(cacao_LDADD) +if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK +install-data-local: + $(mkdir_p) $(prefix)/jre/lib/$(JAVA_ARCH)/server + $(LN_S) -f $(libdir)/libjvm.so $(prefix)/jre/lib/$(JAVA_ARCH)/server + $(ECHO) $(ECHO_N) > $(prefix)/jre/lib/$(JAVA_ARCH)/server/Xusage.txt + $(ECHO) $(ECHO_N) > $(prefix)/jre/lib/$(JAVA_ARCH)/server/libjsig.so + +uninstall-local: + rm -f $(prefix)/jre/lib/$(JAVA_ARCH)/server/libjvm.so + rm -f $(prefix)/jre/lib/$(JAVA_ARCH)/server/Xusage.txt + rm -f $(prefix)/jre/lib/$(JAVA_ARCH)/server/libjsig.so +endif + + ## Local variables: ## mode: Makefile ## indent-tabs-mode: t diff --git a/src/cacao/cacao.c b/src/cacao/cacao.c deleted file mode 100644 index 1f1936258..000000000 --- a/src/cacao/cacao.c +++ /dev/null @@ -1,223 +0,0 @@ -/* src/cacao/cacao.c - contains main() of cacao - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#if defined(ENABLE_LIBJVM) -# include -#endif - -#if defined(ENABLE_JRE_LAYOUT) -# include -# include -# include -#endif - -#include -#include - -#include "vm/types.h" - -#include "native/jni.h" - -#if defined(ENABLE_JVMTI) -# include "native/jvmti/jvmti.h" -# include "native/jvmti/cacaodbg.h" -# include "threads/mutex.h" -#endif - -#include "vm/vm.h" - - -/* forward declarations *******************************************************/ - -static JavaVMInitArgs *cacao_options_prepare(int argc, char **argv); - - -/* main ************************************************************************ - - The main program. - -*******************************************************************************/ - -int main(int argc, char **argv) -{ -#if defined(ENABLE_LIBJVM) - char *path; -#endif - -#if defined(ENABLE_LIBJVM) - /* Variables for JNI_CreateJavaVM dlopen call. */ - lt_dlhandle libjvm_handle; - lt_ptr libjvm_vm_createjvm; - lt_ptr libjvm_vm_run; - const char *lterror; - - bool (*vm_createjvm)(JavaVM **, void **, void *); - void (*vm_run)(JavaVM *, JavaVMInitArgs *); -#endif - - JavaVM *vm; /* denotes a Java VM */ - JNIEnv *env; - JavaVMInitArgs *vm_args; - - /* prepare the options */ - - vm_args = cacao_options_prepare(argc, argv); - - /* load and initialize a Java VM, return a JNI interface pointer in env */ - -#if defined(ENABLE_LIBJVM) -# if defined(ENABLE_JRE_LAYOUT) - /* SUN also uses a buffer of 4096-bytes (strace is your friend). */ - - path = malloc(sizeof(char) * 4096); - - if (readlink("/proc/self/exe", path, 4095) == -1) { - fprintf(stderr, "main: readlink failed: %s\n", strerror(errno)); - abort(); - } - - /* get the path of the current executable */ - - path = dirname(path); - - if ((strlen(path) + strlen("/../lib/libjvm") + strlen("0")) > 4096) { - fprintf(stderr, "main: libjvm name to long for buffer\n"); - abort(); - } - - /* concatinate the library name */ - - strcat(path, "/../lib/libjvm"); -# else - path = CACAO_LIBDIR"/libjvm"; -# endif - - if (lt_dlinit()) { - fprintf(stderr, "main: lt_dlinit failed: %s\n", lt_dlerror()); - abort(); - } - - /* First try to open where dlopen searches, e.g. LD_LIBRARY_PATH. - If not found, try the absolute path. */ - - if (!(libjvm_handle = lt_dlopenext("libjvm"))) { - /* save the error message */ - - lterror = strdup(lt_dlerror()); - - if (!(libjvm_handle = lt_dlopenext(path))) { - /* print the first error message too */ - - fprintf(stderr, "main: lt_dlopenext failed: %s\n", lterror); - - /* and now the current one */ - - fprintf(stderr, "main: lt_dlopenext failed: %s\n", lt_dlerror()); - abort(); - } - - /* free the error string */ - - free((void *) lterror); - } - - if (!(libjvm_vm_createjvm = lt_dlsym(libjvm_handle, "vm_createjvm"))) { - fprintf(stderr, "main: lt_dlsym failed: %s\n", lt_dlerror()); - abort(); - } - - vm_createjvm = - (bool (*)(JavaVM **, void **, void *)) (ptrint) libjvm_vm_createjvm; -#endif - - /* create the Java VM */ - - (void) vm_createjvm(&vm, (void *) &env, vm_args); - -#if defined(ENABLE_JVMTI) - mutex_init(&dbgcomlock); - if (jvmti) jvmti_set_phase(JVMTI_PHASE_START); -#endif - -#if defined(ENABLE_LIBJVM) - if (!(libjvm_vm_run = lt_dlsym(libjvm_handle, "vm_run"))) { - fprintf(stderr, "lt_dlsym failed: %s\n", lt_dlerror()); - abort(); - } - - vm_run = (void (*)(JavaVM *, JavaVMInitArgs *)) (ptrint) libjvm_vm_run; -#endif - - /* run the VM */ - - vm_run(vm, vm_args); - - /* keep compiler happy */ - - return 0; -} - - -/* cacao_options_prepare ******************************************************* - - Prepare the JavaVMInitArgs. - -*******************************************************************************/ - -static JavaVMInitArgs *cacao_options_prepare(int argc, char **argv) -{ - JavaVMInitArgs *vm_args; - s4 i; - - vm_args = malloc(sizeof(JavaVMInitArgs)); - - vm_args->version = JNI_VERSION_1_2; - vm_args->nOptions = argc - 1; - vm_args->options = malloc(sizeof(JavaVMOption) * argc); - vm_args->ignoreUnrecognized = JNI_FALSE; - - for (i = 1; i < argc; i++) - vm_args->options[i - 1].optionString = argv[i]; - - return vm_args; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/cacao/cacao.cpp b/src/cacao/cacao.cpp new file mode 100644 index 000000000..08a0ff895 --- /dev/null +++ b/src/cacao/cacao.cpp @@ -0,0 +1,230 @@ +/* src/cacao/cacao.cpp - contains main() of cacao + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#if defined(ENABLE_JRE_LAYOUT) +# include +# include +# include +#endif + +#include +#include + +#include "vm/types.h" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JVMTI) +# include "native/jvmti/jvmti.h" +# include "native/jvmti/cacaodbg.h" +#endif + +#include "vm/os.hpp" +#include "vm/vm.hpp" + + +/* Defines. *******************************************************************/ + +#define LIBJVM_NAME NATIVE_LIBRARY_PREFIX"jvm"NATIVE_LIBRARY_SUFFIX + + +/* forward declarations *******************************************************/ + +static JavaVMInitArgs* prepare_options(int argc, char** argv); + + +/* main ************************************************************************ + + The main program. + +*******************************************************************************/ + +int main(int argc, char **argv) +{ +#if defined(ENABLE_LIBJVM) + char* path; + +# if defined(ENABLE_JRE_LAYOUT) + int len; +# endif +#endif + +#if defined(ENABLE_LIBJVM) + /* Variables for JNI_CreateJavaVM dlopen call. */ + void* libjvm_handle; + void* libjvm_VM_create; + void* libjvm_vm_run; + const char* lterror; + + bool (*VM_create)(JavaVM **, void **, void *); + void (*vm_run)(JavaVM *, JavaVMInitArgs *); +#endif + + JavaVM *vm; /* denotes a Java VM */ + JNIEnv *env; + JavaVMInitArgs *vm_args; + + /* prepare the options */ + + vm_args = prepare_options(argc, argv); + + /* load and initialize a Java VM, return a JNI interface pointer in env */ + +#if defined(ENABLE_LIBJVM) +# if defined(ENABLE_JRE_LAYOUT) + /* SUN also uses a buffer of 4096-bytes (strace is your friend). */ + + path = (char*) os::malloc(sizeof(char) * 4096); + + if (readlink("/proc/self/exe", path, 4095) == -1) { + fprintf(stderr, "main: readlink failed: %s\n", strerror(errno)); + os::abort(); + } + + /* get the path of the current executable */ + + path = os::dirname(path); + len = os::strlen(path) + os::strlen("/../lib/"LIBJVM_NAME) + os::strlen("0"); + + if (len > 4096) { + fprintf(stderr, "main: libjvm name to long for buffer\n"); + os::abort(); + } + + /* concatinate the library name */ + + strcat(path, "/../lib/"LIBJVM_NAME); +# else + path = (char*) CACAO_LIBDIR"/"LIBJVM_NAME; +# endif + + /* First try to open where dlopen searches, e.g. LD_LIBRARY_PATH. + If not found, try the absolute path. */ + + libjvm_handle = os::dlopen(LIBJVM_NAME, RTLD_NOW); + + if (libjvm_handle == NULL) { + /* save the error message */ + + lterror = strdup(os::dlerror()); + + libjvm_handle = os::dlopen(path, RTLD_NOW); + + if (libjvm_handle == NULL) { + /* print the first error message too */ + + fprintf(stderr, "main: os::dlopen failed: %s\n", lterror); + + /* and now the current one */ + + fprintf(stderr, "main: os::dlopen failed: %s\n", os::dlerror()); + os::abort(); + } + + /* free the error string */ + + free((void *) lterror); + } + + libjvm_VM_create = os::dlsym(libjvm_handle, "VM_create"); + + if (libjvm_VM_create == NULL) { + fprintf(stderr, "main: lt_dlsym failed: %s\n", os::dlerror()); + os::abort(); + } + + VM_create = + (bool (*)(JavaVM **, void **, void *)) (ptrint) libjvm_VM_create; +#endif + + /* create the Java VM */ + + (void) VM_create(&vm, (void**) &env, vm_args); + +#if defined(ENABLE_JVMTI) +# error This should be a JVMTI function. + Mutex_init(&dbgcomlock); + if (jvmti) jvmti_set_phase(JVMTI_PHASE_START); +#endif + +#if defined(ENABLE_LIBJVM) + libjvm_vm_run = os::dlsym(libjvm_handle, "vm_run"); + + if (libjvm_vm_run == NULL) { + fprintf(stderr, "main: os::dlsym failed: %s\n", os::dlerror()); + os::abort(); + } + + vm_run = (void (*)(JavaVM *, JavaVMInitArgs *)) (ptrint) libjvm_vm_run; +#endif + + /* run the VM */ + + vm_run(vm, vm_args); + + /* keep compiler happy */ + + return 0; +} + + +/** + * Prepare the JavaVMInitArgs structure. + */ +static JavaVMInitArgs* prepare_options(int argc, char** argv) +{ + JavaVMInitArgs* vm_args; + + vm_args = (JavaVMInitArgs*) malloc(sizeof(JavaVMInitArgs)); + + vm_args->version = JNI_VERSION_1_2; + vm_args->nOptions = argc - 1; + vm_args->options = (JavaVMOption*) malloc(sizeof(JavaVMOption) * argc); + vm_args->ignoreUnrecognized = JNI_FALSE; + + for (int i = 1; i < argc; i++) + vm_args->options[i - 1].optionString = argv[i]; + + return vm_args; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/cacaoh/Makefile.am b/src/cacaoh/Makefile.am deleted file mode 100644 index 7ab1d6405..000000000 --- a/src/cacaoh/Makefile.am +++ /dev/null @@ -1,61 +0,0 @@ -## src/cacaoh/Makefile.am -## -## Copyright (C) 1996-2005, 2006, 2007, 2008 -## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO -## -## This file is part of CACAO. -## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 2, or (at -## your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - - -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) - -if ENABLE_RT_TIMING -cacaoh_LDFLAGS = -lrt -endif - -noinst_LTLIBRARIES = \ - libcacaoh.la - -libcacaoh_la_SOURCES = \ - dummy.c \ - headers.c \ - headers.h - -libcacaoh_la_LIBADD = \ - $(top_builddir)/src/toolbox/libtoolbox.la \ - $(top_builddir)/src/vmcore/libvmcore.la - -noinst_PROGRAMS = \ - cacaoh - -cacaoh_SOURCES = \ - cacaoh.c - -cacaoh_LDADD = \ - libcacaoh.la - -cacaoh_DEPENDENCIES = \ - $(cacaoh_LDADD) - - -## Local variables: -## mode: Makefile -## indent-tabs-mode: t -## c-basic-offset: 4 -## tab-width: 8 -## compile-command: "automake --add-missing" -## End: diff --git a/src/cacaoh/cacaoh.c b/src/cacaoh/cacaoh.c deleted file mode 100644 index 0f1e8edfd..000000000 --- a/src/cacaoh/cacaoh.c +++ /dev/null @@ -1,367 +0,0 @@ -/* src/cacaoh/cacaoh.c - main for header generation (cacaoh) - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "vm/types.h" - -#include "cacaoh/headers.h" - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "toolbox/hashtable.h" -#include "toolbox/logging.h" - -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/classcache.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" -#include "vmcore/suck.h" - - -/* define cacaoh options ******************************************************/ - -enum { - OPT_HELP, - OPT_VERSION, - OPT_VERBOSE, - OPT_DIRECTORY, - OPT_CLASSPATH, - OPT_BOOTCLASSPATH, - - DUMMY -}; - - -opt_struct opts[] = { - { "help", false, OPT_HELP }, - { "version", false, OPT_VERSION }, - { "verbose", false, OPT_VERBOSE }, - { "d", true, OPT_DIRECTORY }, - { "classpath", true, OPT_CLASSPATH }, - { "bootclasspath", true, OPT_BOOTCLASSPATH }, - { NULL, false, 0 } -}; - - -/* usage *********************************************************************** - - Obviously prints usage information of cacaoh. - -*******************************************************************************/ - -void usage(void) -{ - printf("Usage: cacaoh [options] \n" - "\n" - "Options:\n" - " -help Print this message\n" - " -classpath \n" - " -bootclasspath \n" - " -d Output directory\n" - " -version Print version information\n" - " -verbose Enable verbose output\n"); - - /* exit with error code */ - - exit(1); -} - - -/* version ********************************************************************* - - Prints cacaoh version information. - -*******************************************************************************/ - -static void version(void) -{ - printf("cacaoh version "VERSION"\n"); - printf("Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,\n"); - printf("C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,\n"); - printf("E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,\n"); - printf("J. Wenninger, Institut f. Computersprachen - TU Wien\n\n"); - - printf("This program is free software; you can redistribute it and/or\n"); - printf("modify it under the terms of the GNU General Public License as\n"); - printf("published by the Free Software Foundation; either version 2, or (at\n"); - printf("your option) any later version.\n\n"); - - printf("This program is distributed in the hope that it will be useful, but\n"); - printf("WITHOUT ANY WARRANTY; without even the implied warranty of\n"); - printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"); - printf("General Public License for more details.\n"); - - exit(0); -} - - -/* forward declarations *******************************************************/ - -static JavaVMInitArgs *cacaoh_options_prepare(int argc, char **argv); - - -/* main ************************************************************************ - - Main program. - -*******************************************************************************/ - -int main(int argc, char **argv) -{ - JavaVMInitArgs *vm_args; - s4 i, j; - s4 opt; - classinfo *c; - char *opt_directory; - - /********** internal (only used by main) *****************************/ - - char *bootclasspath; - char *classpath; - char *cp; - s4 cplen; - - if (argc < 2) - usage(); - - /* set the bootclasspath */ - - cp = getenv("BOOTCLASSPATH"); - - if (cp) { - bootclasspath = MNEW(char, strlen(cp) + strlen("0")); - strcpy(bootclasspath, cp); - } - else { - cplen = -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - strlen(CACAO_VM_ZIP) + - strlen(":") + -#endif - strlen(JAVA_RUNTIME_LIBRARY_CLASSES) + - strlen("0"); - - bootclasspath = MNEW(char, cplen); -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - strcat(bootclasspath, CACAO_VM_ZIP); - strcat(bootclasspath, ":"); -#endif - strcat(bootclasspath, JAVA_RUNTIME_LIBRARY_CLASSES); - } - - - /* set the classpath */ - - cp = getenv("CLASSPATH"); - - if (cp != NULL) { - classpath = MNEW(char, strlen(cp) + strlen("0")); - strcat(classpath, cp); - } - else { - classpath = MNEW(char, strlen(".") + strlen("0")); - strcpy(classpath, "."); - } - - - /* initialize options with default values */ - - opt_verbose = false; - opt_directory = NULL; - - - /* parse the options ******************************************************/ - - vm_args = cacaoh_options_prepare(argc, argv); - - while ((opt = options_get(opts, vm_args)) != OPT_DONE) { - switch (opt) { - case OPT_IGNORE: - break; - - case OPT_HELP: - usage(); - break; - - case OPT_CLASSPATH: - /* forget old classpath and set the argument as new classpath */ - MFREE(classpath, char, strlen(classpath)); - - classpath = MNEW(char, strlen(opt_arg) + strlen("0")); - strcpy(classpath, opt_arg); - break; - - case OPT_BOOTCLASSPATH: - /* Forget default bootclasspath and set the argument as - new boot classpath. */ - MFREE(bootclasspath, char, strlen(bootclasspath)); - - bootclasspath = MNEW(char, strlen(opt_arg) + strlen("0")); - strcpy(bootclasspath, opt_arg); - break; - - case OPT_DIRECTORY: - opt_directory = MNEW(char, strlen(opt_arg) + strlen("0")); - strcpy(opt_directory, opt_arg); - break; - - case OPT_VERSION: - version(); - break; - - case OPT_VERBOSE: - opt_verbose = true; - loadverbose = true; - break; - - default: - usage(); - } - } - - /**************************** Program start **************************/ - - if (opt_verbose) { - log_init(NULL); - log_println("Java - header-generator started"); - } - - utf8_init(); - - /* initialize the classcache hashtable stuff: lock, hashtable - (must be done _after_ threads_preinit) */ - - if (!classcache_init()) - vm_abort("classcache_init failed\n"); - - /* initialize the loader with bootclasspath (must be done _after_ - thread_preinit) */ - - if (!suck_init()) - vm_abort("suck_init failed\n"); - - suck_add(bootclasspath); - - /* Also add the normal classpath, so the bootstrap class loader - can find the files. */ - - suck_add(classpath); - - /* AFTER: classcache_init */ - - loader_preinit(); - loader_init(); - - - /* load Java classes ******************************************************/ - - for (i = opt_index; i < vm_args->nOptions; i++) { - cp = vm_args->options[i].optionString; - - /* convert classname */ - - for (j = strlen(cp) - 1; j >= 0; j--) { - switch (cp[j]) { - case '.': - cp[j] = '/'; - break; - case '_': - cp[j] = '$'; - break; - } - } - - /* exceptions are catched with new_exception call */ - - if (!(c = load_class_bootstrap(utf_new_char(cp)))) - vm_abort("java.lang.NoClassDefFoundError: %s\n", cp); - - if (!link_class(c)) - vm_abort("java.lang.LinkageError: %s\n", cp); - - headerfile_generate(c, opt_directory); - } - - /************************ Release all resources **********************/ - - loader_close(); - - if (opt_verbose) { - log_println("Java - header-generator stopped"); -#if defined(ENABLE_STATISTICS) - statistics_print_memory_usage(); -#endif - } - - return 0; -} - - -/* cacaoh_options_prepare ****************************************************** - - Prepare the JavaVMInitArgs. - -*******************************************************************************/ - -static JavaVMInitArgs *cacaoh_options_prepare(int argc, char **argv) -{ - JavaVMInitArgs *vm_args; - s4 i; - - vm_args = NEW(JavaVMInitArgs); - - vm_args->nOptions = argc - 1; - vm_args->options = MNEW(JavaVMOption, argc); - - for (i = 1; i < argc; i++) - vm_args->options[i - 1].optionString = argv[i]; - - return vm_args; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/cacaoh/dummy.c b/src/cacaoh/dummy.c deleted file mode 100644 index 6e10e3992..000000000 --- a/src/cacaoh/dummy.c +++ /dev/null @@ -1,854 +0,0 @@ -/* src/cacaoh/dummy.c - dummy functions for cacaoh - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "native/llni.h" - -#include "toolbox/logging.h" - -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/primitive.h" -#include "vm/vm.h" - -#include "vm/jit/code.h" - -#include "vmcore/class.h" -#include "vmcore/classcache.h" -#include "vmcore/field.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/utf8.h" -#include "vmcore/system.h" - - -/* global variables ***********************************************************/ - -bool vm_initializing = true; -char *_Jv_bootclasspath; - - -java_handle_t *javastring_new_slash_to_dot(utf *u) -{ - vm_abort("javastring_new_slash_to_dot"); - - return NULL; -} - - -/* access *********************************************************************/ - -bool access_is_accessible_class(classinfo *referer, classinfo *cls) -{ - return true; -} - -bool access_is_accessible_member(classinfo *referer, classinfo *declarer, - int32_t memberflags) -{ - vm_abort("access_is_accessible_member"); - - return true; -} - - -/* array **********************************************************************/ - -java_handle_t *array_objectarray_element_get(java_handle_objectarray_t *a, int32_t index) -{ - java_handle_t *value; - int32_t size; - - if (a == NULL) { - log_println("array_objectarray_element_get(a=%p, index=%d): NullPointerException", a, index); - return NULL; - } - - size = LLNI_array_size(a); - - if ((index < 0) || (index > size)) { - log_println("array_objectarray_element_get(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index); - return NULL; - } - - value = LLNI_WRAP(LLNI_array_direct(a, index)); - - return value; -} - -void array_objectarray_element_set(java_handle_objectarray_t *a, int32_t index, java_handle_t *value) -{ - int32_t size; - - if (a == NULL) { - log_println("array_objectarray_element_set(a=%p, index=%d): NullPointerException", a, index); - return; - } - - size = LLNI_array_size(a); - - if ((index < 0) || (index > size)) { - log_println("array_objectarray_element_set(a=%p, index=%d): ArrayIndexOutOfBoundsException", a, index); - return; - } - - LLNI_array_direct(a, index) = LLNI_UNWRAP(value); -} - -int32_t array_length_get(java_handle_t *a) -{ - if (a == NULL) { - log_println("array_length_get(a=%p): NullPointerException", a); - return 0; - } - - return LLNI_array_size(a); -} - - -/* asm ************************************************************************/ - -void asm_abstractmethoderror(void) -{ - abort(); -} - -void intrp_asm_abstractmethoderror(void) -{ - abort(); -} - - -/* builtin ********************************************************************/ - -java_handle_t *builtin_clone(void *env, java_handle_t *o) -{ - vm_abort("builtin_clone: Not implemented."); - return NULL; -} - -bool fast_subtype_check(struct _vftbl *s, struct _vftbl *t) -{ - vm_abort("fast_subtype_check: Not implemented."); - return 0; -} - -bool builtin_isanysubclass(classinfo *sub, classinfo *super) -{ - vm_abort("builtin_isanysubclass: Not implemented."); - return 0; -} - -bool builtin_instanceof(java_handle_t *o, classinfo *class) -{ - vm_abort("builtin_instanceof: Not implemented."); - return 0; -} - -java_handle_t *builtin_new(classinfo *c) -{ - vm_abort("builtin_new: Not implemented."); - return NULL; -} - -java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass) -{ - java_objectarray_t *oa = (java_objectarray_t*) mem_alloc( - sizeof(java_array_t) + size * sizeof(java_object_t*)); - java_handle_objectarray_t *h = (java_handle_objectarray_t*) LLNI_WRAP( - (java_object_t*) oa); - - if (h != NULL) { - LLNI_array_size(h) = size; - } - - return h; -} - -java_handle_bytearray_t *builtin_newarray_byte(int32_t size) -{ - java_bytearray_t *ba = (java_bytearray_t*) mem_alloc( - sizeof(java_array_t) + size * sizeof(int8_t)); - java_handle_bytearray_t *h = (java_handle_bytearray_t*) LLNI_WRAP( - (java_object_t*) ba); - - if (h != NULL) { - LLNI_array_size(h) = size; - } - - return h; -} - - -/* code ***********************************************************************/ - -void code_free_code_of_method(methodinfo *m) -{ -} - - -methodinfo *code_get_methodinfo_for_pv(void *pv) -{ - return NULL; -} - - -/* codegen ********************************************************************/ - -u1 *codegen_generate_stub_compiler(methodinfo *m) -{ - return NULL; -} - -codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f) -{ - return NULL; -} - -#if defined(ENABLE_INTRP) -u1 *intrp_createcompilerstub(methodinfo *m) -{ - return NULL; -} -#endif - -void removecompilerstub(u1 *stub) -{ -} - -void removenativestub(u1 *stub) -{ -} - - -/* exceptions *****************************************************************/ - -void exceptions_clear_exception(void) -{ -} - -void exceptions_print_current_exception(void) -{ - abort(); -} - -void exceptions_throw_abstractmethoderror(void) -{ - fprintf(stderr, "java.lang.AbstractMethodError\n"); - - abort(); -} - -void exceptions_throw_classcircularityerror(classinfo *c) -{ - fprintf(stderr, "java.lang.ClassCircularityError: "); - - utf_display_printable_ascii(c->name); - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_classformaterror(classinfo *c, const char *message, ...) -{ - va_list ap; - - fprintf(stderr, "java.lang.ClassFormatError: "); - - utf_display_printable_ascii(c->name); - fprintf(stderr, ": "); - - va_start(ap, message); - vfprintf(stderr, message, ap); - va_end(ap); - - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message) -{ - fprintf(stderr, "java.lang.IncompatibleClassChangeError: "); - - if (c != NULL) - utf_fprint_printable_ascii_classname(stderr, c->name); - - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_internalerror(const char *message, ...) -{ - va_list ap; - - fprintf(stderr, "java.lang.InternalError: "); - - va_start(ap, message); - vfprintf(stderr, message, ap); - va_end(ap); - - abort(); -} - -void exceptions_throw_linkageerror(const char *message, classinfo *c) -{ - fprintf(stderr, "java.lang.LinkageError: %s", message); - - if (c != NULL) - utf_fprint_printable_ascii_classname(stderr, c->name); - - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_noclassdeffounderror(utf *name) -{ - fprintf(stderr, "java.lang.NoClassDefFoundError: "); - utf_fprint_printable_ascii(stderr, name); - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name) -{ - fprintf(stderr, "java.lang.NoClassDefFoundError: "); - utf_fprint_printable_ascii(stderr, c->name); - fprintf(stderr, " (wrong name: "); - utf_fprint_printable_ascii(stderr, name); - fprintf(stderr, ")\n"); - - abort(); -} - -void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...) -{ - fprintf(stderr, "java.lang.VerifyError: "); - utf_fprint_printable_ascii(stderr, m->name); - fprintf(stderr, ": %s", message); - - abort(); -} - -void exceptions_throw_nosuchfielderror(classinfo *c, utf *name) -{ - fprintf(stderr, "java.lang.NoSuchFieldError: "); - utf_fprint_printable_ascii(stderr, c->name); - fprintf(stderr, "."); - utf_fprint_printable_ascii(stderr, name); - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc) -{ - fprintf(stderr, "java.lang.NoSuchMethodError: "); - utf_fprint_printable_ascii(stderr, c->name); - fprintf(stderr, "."); - utf_fprint_printable_ascii(stderr, name); - utf_fprint_printable_ascii(stderr, desc); - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi) -{ - fprintf(stderr, "java.lang.UnsupportedClassVersionError: " ); - utf_display_printable_ascii(c->name); - fprintf(stderr, " (Unsupported major.minor version %d.%d)\n", ma, mi); - - abort(); -} - -void exceptions_throw_classnotfoundexception(utf *name) -{ - fprintf(stderr, "java.lang.ClassNotFoundException: "); - utf_fprint_printable_ascii(stderr, name); - fputc('\n', stderr); - - abort(); -} - -void exceptions_throw_nullpointerexception(void) -{ - fprintf(stderr, "java.lang.NullPointerException\n"); - - abort(); -} - - -/* finalizer ******************************************************************/ - -void finalizer_notify(void) -{ - vm_abort("finalizer_notify"); -} - -void finalizer_run(void *o, void *p) -{ - vm_abort("finalizer_run"); -} - - -/* gc *************************************************************************/ - -void gc_reference_register(java_object_t **ref, int32_t reftype) -{ - vm_abort("gc_reference_register"); -} - -int64_t gc_get_heap_size(void) -{ - return 0; -} - -int64_t gc_get_free_bytes(void) -{ - return 0; -} - -int64_t gc_get_total_bytes(void) -{ - return 0; -} - -int64_t gc_get_max_heap_size(void) -{ - return 0; -} - - -/* heap ***********************************************************************/ - -void *heap_alloc_uncollectable(size_t bytelength) -{ - return calloc(bytelength, 1); -} - -s4 heap_get_hashcode(java_object_t *o) -{ - return 0; -} - - -/* jit ************************************************************************/ - -void jit_invalidate_code(methodinfo *m) -{ - vm_abort("jit_invalidate_code"); -} - - -/* llni ***********************************************************************/ - -void llni_critical_start() -{ -} - -void llni_critical_end() -{ -} - - -/* localref *******************************************************************/ - -java_handle_t *localref_add(java_object_t *o) -{ -#if defined(ENABLE_HANDLES) - java_handle_t *h = (java_handle_t*) mem_alloc(sizeof(java_handle_t)); - - h->heap_object = o; - - return h; -#else - return (java_handle_t*) o; -#endif -} - - -/* lock ***********************************************************************/ - -void lock_init_object_lock(java_object_t *o) -{ -} - -bool lock_monitor_enter(java_handle_t *o) -{ - return true; -} - -bool lock_monitor_exit(java_handle_t *o) -{ - return true; -} - - -/* md *************************************************************************/ - -void md_param_alloc(methoddesc *md) -{ -} - -void md_param_alloc_native(methoddesc *md) -{ -} - - -/* memory *********************************************************************/ - -void *mem_alloc(int32_t size) -{ - /* real implementation in src/mm/memory.c clears memory */ - - return calloc(size, 1); -} - -void *mem_realloc(void *src, int32_t len1, int32_t len2) -{ - return realloc(src, len2); -} - -void mem_free(void *m, int32_t size) -{ - free(m); -} - -void *dumpmemory_get(size_t size) -{ - return malloc(size); -} - -int32_t dumpmemory_marker(void) -{ - return 0; -} - -void dumpmemory_release(int32_t size) -{ -} - - -/* package ********************************************************************/ - -/* void package_add(java_handle_t *packagename) */ -void package_add(utf *packagename) -{ - /* Do nothing. */ -} - - -/* primitive ******************************************************************/ - -classinfo *primitive_arrayclass_get_by_type(int type) -{ - return NULL; -} - -classinfo *primitive_class_get_by_type(int type) -{ - abort(); - return NULL; -} - -classinfo *primitive_class_get_by_char(char ch) -{ - abort(); - return NULL; -} - - -/* properties *****************************************************************/ - -void properties_add(char *key, char *value) -{ -} - -char *properties_get(char *key) -{ - return NULL; -} - - -/* reflect ********************************************************************/ - -java_handle_t *reflect_constructor_new(fieldinfo *f) -{ - vm_abort("reflect_constructor_new: Not implemented."); - return NULL; -} - -java_handle_t *reflect_field_new(fieldinfo *f) -{ - vm_abort("reflect_field_new: Not implemented."); - return NULL; -} - -java_handle_t *reflect_method_new(methodinfo *m) -{ - vm_abort("reflect_method_new: Not implemented."); - return NULL; -} - - -/* resolve ********************************************************************/ - -void resolve_handle_pending_exception(bool throwError) -{ - vm_abort("resolve_handle_pending_exception: Not implemented."); -} - -bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, classinfo **result) -{ - abort(); - - return false; -} - -/* stupid resolving implementation used by resolve_classref_or_classinfo_eager */ -/* This function does eager resolving without any access checks. */ - -static classinfo * dummy_resolve_class_from_name(classinfo *referer, - utf *classname, - bool checkaccess) -{ - classinfo *cls = NULL; - char *utf_ptr; - int len; - - assert(referer); - assert(classname); - - /* lookup if this class has already been loaded */ - - cls = classcache_lookup(referer->classloader, classname); - - if (!cls) { - /* resolve array types */ - - if (classname->text[0] == '[') { - utf_ptr = classname->text + 1; - len = classname->blength - 1; - - /* classname is an array type name */ - - switch (*utf_ptr) { - case 'L': - utf_ptr++; - len -= 2; - /* FALLTHROUGH */ - case '[': - /* the component type is a reference type */ - /* resolve the component type */ - if ((cls = dummy_resolve_class_from_name(referer, - utf_new(utf_ptr,len), - checkaccess)) == NULL) - return NULL; /* exception */ - - /* create the array class */ - cls = class_array_of(cls,false); - if (!cls) - return NULL; /* exception */ - } - } - - /* load the class */ - if (!cls) { - if (!(cls = load_class_from_classloader(classname, - referer->classloader))) - return false; /* exception */ - } - } - - /* the class is now loaded */ - assert(cls); - assert(cls->state & CLASS_LOADED); - - return cls; -} - - -classinfo * resolve_classref_or_classinfo_eager(classref_or_classinfo cls, - bool checkaccess) -{ - classinfo *c; - - assert(cls.any); - - if (IS_CLASSREF(cls)) { - /* we must resolve this reference */ - - if ((c = dummy_resolve_class_from_name(cls.ref->referer, cls.ref->name, - checkaccess)) == NULL) - return NULL; - } - else { - /* cls has already been resolved */ - c = cls.cls; - } - - assert(c); - assert(c->state & CLASS_LOADED); - - /* succeeded */ - return c; -} - - -/* stacktrace *****************************************************************/ - -java_handle_objectarray_t *stacktrace_getClassContext() -{ - return NULL; -} - - -/* threads ********************************************************************/ - -intptr_t threads_get_current_tid(void) -{ - return 0; -} - -void threads_cast_stopworld(void) -{ -} - -void threads_cast_startworld(void) -{ -} - - -/* vm *************************************************************************/ - -void vm_printconfig(void) -{ -} - -void vm_abort(const char *text, ...) -{ - va_list ap; - - va_start(ap, text); - vfprintf(stderr, text, ap); - va_end(ap); - - system_abort(); -} - -void vm_abort_errno(const char *text, ...) -{ - va_list ap; - - va_start(ap, text); - vm_abort_errnum(errno, text, ap); - va_end(ap); -} - -void vm_abort_errnum(int errnum, const char *text, ...) -{ - va_list ap; - - log_start(); - - va_start(ap, text); - log_vprint(text, ap); - va_end(ap); - - log_print(": %s", system_strerror(errnum)); - log_finish(); - - system_abort(); -} - -java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...) -{ - return NULL; -} - - -/* XXX */ - -void stringtable_update(void) -{ - log_println("stringtable_update: REMOVE ME!"); -} - -java_object_t *literalstring_new(utf *u) -{ - log_println("literalstring_new: REMOVE ME!"); - - return NULL; -} - - -void print_dynamic_super_statistics(void) -{ -} - - -#if defined(ENABLE_VMLOG) -void vmlog_cacao_set_prefix(const char *arg) -{ -} - -void vmlog_cacao_set_stringprefix(const char *arg) -{ -} - -void vmlog_cacao_set_ignoreprefix(const char *arg) -{ -} -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/cacaoh/headers.c b/src/cacaoh/headers.c deleted file mode 100644 index 8d9c42fc9..000000000 --- a/src/cacaoh/headers.c +++ /dev/null @@ -1,508 +0,0 @@ -/* src/cacaoh/headers.c - functions for header generation - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#if defined(ENABLE_THREADS) -# if defined(__DARWIN__) -# include -# endif -# include -#endif - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "toolbox/chain.h" -#include "toolbox/logging.h" - -#include "vm/builtin.h" -#include "vm/global.h" -#include "vm/stringlocal.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - - -/************************ global variables **********************/ - -#define ACC_NATIVELY_OVERLOADED 0x10000000 - -#if defined(ENABLE_HANDLES) -# define HEAP_PREFIX "heap_" -#else -# define HEAP_PREFIX "" -#endif - -chain *ident_chain; /* chain with method and field names in current class */ -FILE *file = NULL; -static uint32_t outputsize; -static bool dopadding; - - -static void printIDpart(int c) -{ - if ((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - (c == '_')) - putc(c, file); - else - putc('_', file); -} - - -void printID(utf *u) -{ - char *utf_ptr = u->text; - int i; - - for (i = 0; i < utf_get_number_of_u2s(u); i++) - printIDpart(utf_nextu2(&utf_ptr)); -} - - -static void addoutputsize(int len) -{ - uint32_t newsize; - int32_t i; - - if (!dopadding) - return; - - newsize = MEMORY_ALIGN(outputsize, len); - - for (i = outputsize; i < newsize; i++) - fprintf(file, " uint8_t pad%d\n", (int) i); - - outputsize = newsize; -} - - -void printOverloadPart(utf *desc) -{ - char *utf_ptr=desc->text; - uint16_t c; - - fprintf(file, "__"); - - while ((c = utf_nextu2(&utf_ptr)) != ')') { - switch (c) { - case 'I': - case 'S': - case 'B': - case 'C': - case 'Z': - case 'J': - case 'F': - case 'D': - fprintf(file, "%c", (char) c); - break; - case '[': - fprintf(file, "_3"); - break; - case 'L': - putc('L', file); - while ((c = utf_nextu2(&utf_ptr)) != ';') - printIDpart(c); - fprintf(file, "_2"); - break; - case '(': - break; - default: - log_text("invalid method descriptor"); - assert(0); - } - } -} - -static char *printtype(char *utf_ptr, char *prefix, char *infix) -{ - uint16_t c; - - switch (utf_nextu2(&utf_ptr)) { - case 'V': - fprintf(file, "void"); - break; - case 'I': - case 'S': - case 'B': - case 'C': - case 'Z': - addoutputsize(4); - fprintf(file, "int32_t"); - break; - case 'J': - addoutputsize(8); - fprintf(file, "int64_t"); - break; - case 'F': - addoutputsize(4); - fprintf(file, "float"); - break; - case 'D': - addoutputsize(8); - fprintf(file, "double"); - break; - case '[': - addoutputsize ( sizeof(java_array_t*) ); - switch (utf_nextu2(&utf_ptr)) { - case 'I': fprintf (file, "java%s_intarray_t*", infix); break; - case 'J': fprintf (file, "java%s_longarray_t*", infix); break; - case 'Z': fprintf (file, "java%s_booleanarray_t*", infix); break; - case 'B': fprintf (file, "java%s_bytearray_t*", infix); break; - case 'S': fprintf (file, "java%s_shortarray_t*", infix); break; - case 'C': fprintf (file, "java%s_chararray_t*", infix); break; - case 'F': fprintf (file, "java%s_floatarray_t*", infix); break; - case 'D': fprintf (file, "java%s_doublearray_t*", infix); break; - - case '[': fprintf(file, "java%s_objectarray_t*", infix); - while ((c = utf_nextu2(&utf_ptr)) == '['); - if (c == 'L') - while (utf_nextu2(&utf_ptr) != ';'); - break; - - case 'L': fprintf(file, "java%s_objectarray_t*", infix); - while (utf_nextu2(&utf_ptr) != ';'); - break; - default: - log_text("invalid type descriptor"); - assert(0); - } - break; - - case 'L': - addoutputsize ( sizeof(java_object_t*)); - fprintf (file, "struct %s", prefix); - while ( (c = utf_nextu2(&utf_ptr)) != ';' ) printIDpart (c); - fprintf (file, "*"); - break; - - default: - log_text("Unknown type in field descriptor"); - assert(0); - } - - return utf_ptr; -} - - -/***** determine the number of entries of a utf string in the ident chain *****/ - -static int searchidentchain_utf(utf *ident) -{ - utf *u = chain_first(ident_chain); /* first element of list */ - int count = 0; - - while (u) { - if (u==ident) count++; /* string found */ - u = chain_next(ident_chain); /* next element in list */ - } - - return count; -} - - -/************** print structure for direct access to objects ******************/ - -static void printfields(classinfo *c) -{ - int32_t i; - fieldinfo *f; - int ident_count; - - if (!c) { - addoutputsize(sizeof(java_object_t)); - fprintf(file, " java_object_t header;\n"); - return; - } - - printfields(c->super); - - for (i = 0; i < c->fieldscount; i++) { - f = &(c->fields[i]); - - if (!(f->flags & ACC_STATIC)) { - fprintf(file, " "); - printtype(f->descriptor->text, HEAP_PREFIX, ""); - fprintf(file, " "); - utf_fprint_printable_ascii(file, f->name); - - /* rename multiple fieldnames */ - if ((ident_count = searchidentchain_utf(f->name))) - fprintf(file, "%d", ident_count - 1); - chain_addlast(ident_chain, f->name); - - fprintf(file, ";\n"); - } - } -} - - -/***************** store prototype for native method in file ******************/ - -void printmethod(methodinfo *m) -{ - char *utf_ptr; - int32_t paramnum = 1; - - /* search for return-type in descriptor */ - utf_ptr = m->descriptor->text; - while (utf_nextu2(&utf_ptr) != ')'); - - /* create remarks */ - fprintf(file, "\n/*\n * Class: "); - utf_fprint_printable_ascii(file, m->clazz->name); - fprintf(file, "\n * Method: "); - utf_fprint_printable_ascii(file, m->name); - fprintf(file, "\n * Signature: "); - utf_fprint_printable_ascii(file, m->descriptor); - fprintf(file, "\n */\n"); - - /* create prototype */ - fprintf(file, "JNIEXPORT "); - printtype(utf_ptr, "", "_handle"); - fprintf(file, " JNICALL Java_"); - printID(m->clazz->name); - - chain_addlast(ident_chain, m->name); - - fprintf(file, "_"); - printID(m->name); - - /* ATTENTION: We use a dummy flag here. */ - - if (m->flags & ACC_NATIVELY_OVERLOADED) - printOverloadPart(m->descriptor); - - fprintf(file, "(JNIEnv *env"); - - utf_ptr = m->descriptor->text + 1; - - if (!(m->flags & ACC_STATIC)) { - fprintf(file, ", struct "); - printID(m->clazz->name); - fprintf(file, "* this"); - - } else { - fprintf(file, ", jclass clazz"); - } - - if ((*utf_ptr) != ')') fprintf(file, ", "); - - while ((*utf_ptr) != ')') { - utf_ptr = printtype(utf_ptr, "", "_handle"); - fprintf(file, " par%d", paramnum++); - if ((*utf_ptr)!=')') fprintf(file, ", "); - } - - fprintf(file, ");\n\n"); -} - - -/******* remove package-name in fully-qualified classname *********************/ - -void gen_header_filename(char *buffer, utf *u) -{ - int32_t i; - - for (i = 0; i < utf_get_number_of_u2s(u); i++) { - if ((u->text[i] == '/') || (u->text[i] == '$')) { - buffer[i] = '_'; /* convert '$' and '/' to '_' */ - - } else { - buffer[i] = u->text[i]; - } - } - buffer[utf_get_number_of_u2s(u)] = '\0'; -} - - -/* create headerfile for classes and store native methods in chain ************/ - -void headerfile_generate(classinfo *c, char *opt_directory) -{ - char header_filename[1024] = ""; - char classname[1024]; - char uclassname[1024]; - int32_t i; - methodinfo *m; - int32_t j; - methodinfo *m2; - bool nativelyoverloaded; - - /* prevent compiler warnings */ - - nativelyoverloaded = false; - - /* open headerfile for class */ - gen_header_filename(classname, c->name); - - /* create chain for renaming fields */ - ident_chain = chain_new(); - - if (opt_directory) { - sprintf(header_filename, "%s/%s.h", opt_directory, classname); - - } else { - sprintf(header_filename, "%s.h", classname); - } - - file = fopen(header_filename, "w"); - if (!file) { - log_text("Can not open file to store header information"); - assert(0); - } - - fprintf(file, "/* This file is machine generated, don't edit it! */\n\n"); - - /* convert to uppercase */ - for (i = 0; classname[i]; i++) { - uclassname[i] = toupper(classname[i]); - } - uclassname[i] = '\0'; - - fprintf(file, "#ifndef _%s_H\n#define _%s_H\n\n", uclassname, uclassname); - - /* create structure for direct access to objects */ - fprintf(file, "/* Structure information for class: "); - utf_fprint_printable_ascii(file, c->name); - fprintf(file, " */\n\n"); - fprintf(file, "typedef struct %s", HEAP_PREFIX); - printID(c->name); - fprintf(file, " {\n"); - outputsize = 0; - dopadding = true; - - printfields(c); - - fprintf(file, "} %s", HEAP_PREFIX); - printID(c->name); - fprintf(file, ";\n\n"); - -#if defined(ENABLE_HANDLES) - /* create structure for indirection cell */ - fprintf(file, "typedef struct "); - printID(c->name); - fprintf(file, " {\n"); - fprintf(file, " %s", HEAP_PREFIX); - printID(c->name); - fprintf(file, " *heap_object;\n"); - fprintf(file, "} "); - printID(c->name); - fprintf(file, ";\n\n"); -#endif - - /* create chain for renaming overloaded methods */ - chain_free(ident_chain); - ident_chain = chain_new(); - - /* create method-prototypes */ - - /* find overloaded methods */ - - for (i = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (!(m->flags & ACC_NATIVE)) - continue; - - /* We use a dummy flag here. */ - - if (!(m->flags & ACC_NATIVELY_OVERLOADED)) { - nativelyoverloaded = false; - - for (j = i + 1; j < c->methodscount; j++) { - m2 = &(c->methods[j]); - - if (!(m2->flags & ACC_NATIVE)) - continue; - - if (m->name == m2->name) { - m2->flags |= ACC_NATIVELY_OVERLOADED; - nativelyoverloaded = true; - } - } - } - - if (nativelyoverloaded == true) - m->flags |= ACC_NATIVELY_OVERLOADED; - } - - for (i = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (m->flags & ACC_NATIVE) - printmethod(m); - } - - chain_free(ident_chain); - - fprintf(file, "#endif\n\n"); - - fclose(file); -} - - -/******** print classname, '$' used to seperate inner-class name ***********/ - -void print_classname(classinfo *clazz) -{ - utf *u = clazz->name; - char *endpos = u->text + u->blength; - char *utf_ptr = u->text; - uint16_t c; - - while (utf_ptr < endpos) { - if ((c = utf_nextu2(&utf_ptr)) == '_') - putc('$', file); - else - putc(c, file); - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/cacaoh/headers.h b/src/cacaoh/headers.h deleted file mode 100644 index de8ed7116..000000000 --- a/src/cacaoh/headers.h +++ /dev/null @@ -1,72 +0,0 @@ -/* src/cacaoh/headers.h - export functions for header generation - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -#ifndef _HEADERS_H -#define _HEADERS_H - -#include "config.h" - -#include "toolbox/chain.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/utf8.h" - - -/* export variables ***********************************************************/ - -extern chain *nativemethod_chain; -extern chain *nativeclass_chain; -extern chain *ident_chain; -extern FILE *file; - - -/* function prototypes ********************************************************/ - -void printID(utf *u); -void printOverloadPart(utf *desc); -void printmethod(methodinfo *m); -void gen_header_filename(char *buffer, utf *u); -void headerfile_generate(classinfo *c, char *opt_directory); -void print_classname(classinfo *clazz); - -#endif /* _HEADERS_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/classes/Makefile.am b/src/classes/Makefile.am index 9ddec4970..507eb39d6 100644 --- a/src/classes/Makefile.am +++ b/src/classes/Makefile.am @@ -77,7 +77,7 @@ endif if ENABLE_ZLIB pkgdata_DATA = vm.zip else -pkgdata_DATA = nozip +noinst_DATA = nozip endif endif @@ -88,7 +88,7 @@ VM_JAVA_FILES = \ if ENABLE_ZLIB pkgdata_DATA = vm.zip else -pkgdata_DATA = nozip +noinst_DATA = nozip endif endif @@ -107,6 +107,14 @@ else nozip: $(VM_JAVA_FILES) $(mkdir_p) classes $(JAVAC) -bootclasspath $(BOOTCLASSPATH) -source 1.5 -target 1.5 -d classes $(VM_JAVA_FILES) + +install-data-local: nozip + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + cp -R classes $(DESTDIR)$(pkgdatadir) + +uninstall-local: + rm -rf $(DESTDIR)$(pkgdatadir)/classes + endif clean-local: diff --git a/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java b/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java index 688f36dbc..27e7d2cc7 100644 --- a/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java +++ b/src/classes/gnuclasspath/gnu/java/lang/CPStringBuilder.java @@ -204,8 +204,11 @@ public final class CPStringBuilder int valueLength = value.length; /* Always call ensureCapacity in order to preserve - copy-on-write semantics. */ - ensureCapacity(newLength); + copy-on-write semantics, except when the position + is simply being reset + */ + if (newLength > 0) + ensureCapacity(newLength); if (newLength < valueLength) { @@ -1036,18 +1039,24 @@ public final class CPStringBuilder * Increase the capacity of this StringBuilder. This will * ensure that an expensive growing operation will not occur until either * minimumCapacity is reached or the array has been allocated. - * The buffer is grown to the larger of minimumCapacity and + * The buffer is grown to either minimumCapacity * 2, if + * the array has been allocated or the larger of minimumCapacity and * capacity() * 2 + 2, if it is not already large enough. * * @param minimumCapacity the new capacity - * @see #capacity() + * @see #length() */ public void ensureCapacity(int minimumCapacity) { if (allocated || minimumCapacity > value.length) { - int max = value.length * 2 + 2; - minimumCapacity = (minimumCapacity < max ? max : minimumCapacity); + if (minimumCapacity > value.length) + { + int max = value.length * 2 + 2; + minimumCapacity = (minimumCapacity < max ? max : minimumCapacity); + } + else + minimumCapacity *= 2; allocateArray(minimumCapacity); } } diff --git a/src/classes/gnuclasspath/java/lang/VMThread.java b/src/classes/gnuclasspath/java/lang/VMThread.java index a511f3cf0..e4f2595d3 100644 --- a/src/classes/gnuclasspath/java/lang/VMThread.java +++ b/src/classes/gnuclasspath/java/lang/VMThread.java @@ -376,41 +376,42 @@ final class VMThread * @throws InterruptedException if the Thread is (or was) interrupted; * it's interrupted status will be cleared */ - static void sleep(long ms, int ns) throws InterruptedException - { - // Note: JDK treats a zero length sleep is like Thread.yield(), - // without checking the interrupted status of the thread. - // It's unclear if this is a bug in the implementation or the spec. - // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203 - if (ms == 0 && ns == 0) - { - if (Thread.interrupted()) - throw new InterruptedException(); - return; - } +// static void sleep(long ms, int ns) throws InterruptedException +// { +// // Note: JDK treats a zero length sleep is like Thread.yield(), +// // without checking the interrupted status of the thread. +// // It's unclear if this is a bug in the implementation or the spec. +// // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203 +// if (ms == 0 && ns == 0) +// { +// if (Thread.interrupted()) +// throw new InterruptedException(); +// return; +// } - // Compute end time, but don't overflow - long now = System.currentTimeMillis(); - long end = now + ms; - if (end < now) - end = Long.MAX_VALUE; +// // Compute end time, but don't overflow +// long now = System.currentTimeMillis(); +// long end = now + ms; +// if (end < now) +// end = Long.MAX_VALUE; - // A VM is allowed to return from wait() without notify() having been - // called, so we loop to handle possible spurious wakeups. - VMThread vt = Thread.currentThread().vmThread; - synchronized (vt) - { - while (true) - { - vt.wait(ms, ns); - now = System.currentTimeMillis(); - if (now >= end) - break; - ms = end - now; - ns = 0; - } - } - } +// // A VM is allowed to return from wait() without notify() having been +// // called, so we loop to handle possible spurious wakeups. +// VMThread vt = Thread.currentThread().vmThread; +// synchronized (vt) +// { +// while (true) +// { +// vt.wait(ms, ns); +// now = System.currentTimeMillis(); +// if (now >= end) +// break; +// ms = end - now; +// ns = 0; +// } +// } +// } + static native void sleep(long ms, int ns) throws InterruptedException; /** * Determine whether the current Thread has been interrupted, and clear diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java index 8c5aca365..51ce4729e 100644 --- a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java +++ b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationParser.java @@ -47,7 +47,7 @@ public class AnnotationParser { * Parses the annotations described by the passed byte array, * but returns Annotation[] so I don't have to do this in C. * - * @author Mathias Panzenböck + * @author Mathias Panzenboeck * * @param rawAnnotations are the unparsed annotations * @param constPool is the constant pool of the declaring class @@ -67,7 +67,7 @@ public class AnnotationParser { /** * Parses parameter annotations. * - * @author Mathias Panzenböck + * @author Mathias Panzenboeck * * @param parameterAnnotations are the unparsed parameter annotations * @param constPool is the constant pool of the declaring class @@ -99,7 +99,7 @@ public class AnnotationParser { * This method is basically copied from OpenJDKs * java.lang.reflect.Method.getAnnotationDefault() * - * @author Mathias Panzenböck + * @author Mathias Panzenboeck * * @param method represents the method for which the annotation default value has to be parsed * @param annotationDefault is the unparsed annotation default value diff --git a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java index ea559bbb9..f80fe7f98 100644 --- a/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java +++ b/src/classes/gnuclasspath/sun/reflect/annotation/AnnotationType.java @@ -45,7 +45,7 @@ public class AnnotationType { * sun.misc.SharedSecrets.getJavaLangAccess().setAnnotationType() so * this class can be used with gnu classpath. * - * @author Mathias Panzenböck + * @author Mathias Panzenboeck */ private static Map annotationTypes = new HashMap(); diff --git a/src/fdlibm/ieeefp.h b/src/fdlibm/ieeefp.h index 17ff86bff..fa4313251 100644 --- a/src/fdlibm/ieeefp.h +++ b/src/fdlibm/ieeefp.h @@ -75,7 +75,7 @@ #define __IEEE_BIG_ENDIAN #endif -#ifdef __i386__ +#if defined(__i386__) || defined(__i386) #define __IEEE_LITTLE_ENDIAN #endif diff --git a/src/mm/Makefile.am b/src/mm/Makefile.am index 22c39cec2..78ba758a1 100644 --- a/src/mm/Makefile.am +++ b/src/mm/Makefile.am @@ -31,7 +31,7 @@ DIST_SUBDIRS = \ if DISABLE_GC GC_FILE = \ - nogc.c + gc-none.cpp endif if ENABLE_GC_BOEHM @@ -39,7 +39,7 @@ SUBDIRS = \ boehm-gc GC_FILE = \ - boehm.c + gc-boehm.cpp GC_LIB = \ $(top_builddir)/src/mm/boehm-gc/libgc.la @@ -59,16 +59,21 @@ noinst_LTLIBRARIES = \ libmm_la_SOURCES = \ codememory.c \ codememory.h \ - dumpmemory.c \ - dumpmemory.h \ + dumpmemory.cpp \ + dumpmemory.hpp \ $(GC_FILE) \ - gc-common.h \ + gc.hpp \ memory.c \ memory.h libmm_la_LIBADD = \ $(GC_LIB) +if ENABLE_TLH +libmm_la_SOURCES += \ + tlh.h \ + tlh.c +endif ## Local variables: ## mode: Makefile diff --git a/src/mm/boehm-gc/Makefile.am b/src/mm/boehm-gc/Makefile.am index 57207d792..cf83b2614 100644 --- a/src/mm/boehm-gc/Makefile.am +++ b/src/mm/boehm-gc/Makefile.am @@ -16,6 +16,13 @@ ## Process this file with automake to produce Makefile.in. +ACLOCAL_AMFLAGS = -I m4 + +DISTCLEANFILES = \ + atomic_ops.c \ + atomic_ops_sysdeps.S \ + libatomic_ops + ## FIXME: `make distcheck' in this directory will not currently work. ## This is most likely to the explicit flags passed to submakes. @@ -35,14 +42,16 @@ SUBDIRS = # Initialize variables so that we can declare files locally. EXTRA_DIST = noinst_LTLIBRARIES = -include_HEADERS = -pkginclude_HEADERS = +# Don't install include/gc +#include_HEADERS = +#pkginclude_HEADERS = dist_noinst_HEADERS = check_PROGRAMS = TESTS = -pkgconfigdir = $(libdir)/pkgconfig -dist_pkgconfig_DATA = bdw-gc.pc +# Don't install pkg-config data. +#pkgconfigdir = $(libdir)/pkgconfig +#dist_pkgconfig_DATA = bdw-gc.pc # C Library # --------- @@ -74,7 +83,7 @@ endif if USE_INTERNAL_LIBATOMIC_OPS nodist_libgc_la_SOURCES = ./atomic_ops.c endif - + if NEED_ATOMIC_OPS_ASM nodist_libgc_la_SOURCES = ./atomic_ops_sysdeps.S endif @@ -96,7 +105,7 @@ EXTRA_libgc_la_SOURCES = alpha_mach_dep.S \ if CPLUSPLUS noinst_LTLIBRARIES += libgccpp.la -pkginclude_HEADERS += include/gc_cpp.h include/gc_allocator.h +#pkginclude_HEADERS += include/gc_cpp.h include/gc_allocator.h libgccpp_la_SOURCES = gc_cpp.cc libgccpp_la_LIBADD = ./libgc.la libgccpp_la_LDFLAGS = -version-info 1:3:0 -no-undefined @@ -189,7 +198,7 @@ CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host # :FIXME: why do we distribute this one??? # -EXTRA_DIST += libtool.m4 +#EXTRA_DIST += libtool.m4 # # :GOTCHA: GNU make rule for making .s out of .S is flawed, diff --git a/src/mm/boehm-gc/autogen.sh b/src/mm/boehm-gc/autogen.sh deleted file mode 100755 index fe66cc007..000000000 --- a/src/mm/boehm-gc/autogen.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -${CACAO_LIBTOOLIZE} --automake -if test `uname` = 'FreeBSD'; then - ${CACAO_ACLOCAL} -I . -I /usr/local/share/aclocal -I /usr/local/share/aclocal19 -else - ${CACAO_ACLOCAL} -fi -${CACAO_AUTOHEADER} -${CACAO_AUTOMAKE} --add-missing -${CACAO_AUTOCONF} - -(cd libatomic_ops-1.2; ./autogen.sh) diff --git a/src/mm/boehm-gc/configure.ac b/src/mm/boehm-gc/configure.ac index 7e5d530f7..5ab3d30af 100644 --- a/src/mm/boehm-gc/configure.ac +++ b/src/mm/boehm-gc/configure.ac @@ -35,11 +35,6 @@ AC_SUBST(GC_VERSION) AM_PROG_CC_C_O AC_PROG_CXX -dnl temporary set the CFLAGS for configure tests (e.g. inline keyword) -dnl we set it properly later in this file -CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS" -AC_C_INLINE - AM_PROG_AS ## FIXME: really needed? (AC_LIBTOOL already provides this) AC_CHECK_TOOL(AR, ar) @@ -500,15 +495,6 @@ case "$host" in *) AC_MSG_RESULT(no) ;; esac -dnl We need to override the top-level CFLAGS. This is how we do it. -dnl MY_CFLAGS="$CFLAGS" -dnl AC_SUBST(MY_CFLAGS) - -dnl pass CFLAGS to Makefiles via AM_CFLAGS -CFLAGS=$OPT_CFLAGS -AM_CFLAGS=$ARCH_CFLAGS -AC_SUBST(AM_CFLAGS) - dnl Include defines that have become de facto standard. dnl ALL_INTERIOR_POINTERS can be overridden in startup code. AC_DEFINE([NO_EXECUTE_PERMISSION], 1, [no exceute permission]) diff --git a/src/mm/boehm-gc/include/gc.h b/src/mm/boehm-gc/include/gc.h index 1dab4c214..19a657105 100644 --- a/src/mm/boehm-gc/include/gc.h +++ b/src/mm/boehm-gc/include/gc.h @@ -242,11 +242,6 @@ GC_API unsigned long GC_time_limit; */ GC_API void GC_init(void); -/* Added for cacao */ -int GC_signum1(); -int GC_signum2(); -/* cacao END */ - /* * general purpose allocation routines, with roughly malloc calling conv. * The atomic versions promise that no relevant pointers are contained diff --git a/src/mm/boehm-gc/include/include.am b/src/mm/boehm-gc/include/include.am index 991a07990..a27aab074 100644 --- a/src/mm/boehm-gc/include/include.am +++ b/src/mm/boehm-gc/include/include.am @@ -55,6 +55,7 @@ dist_noinst_HEADERS += \ include/javaxfc.h # unprefixed header -include_HEADERS += \ +#include_HEADERS += \ +dist_noinst_HEADERS += \ include/extra/gc.h \ include/extra/gc_cpp.h diff --git a/src/mm/boehm-gc/include/private/gcconfig.h b/src/mm/boehm-gc/include/private/gcconfig.h index 8e77c48a8..b828759d0 100644 --- a/src/mm/boehm-gc/include/private/gcconfig.h +++ b/src/mm/boehm-gc/include/private/gcconfig.h @@ -141,12 +141,12 @@ # define SEQUENT # define mach_type_known # endif -# if defined(sun) && (defined(i386) || defined(__i386__)) +# if (defined(sun) || defined(__sun)) && (defined(i386) || defined(__i386__)) # define I386 # define SOLARIS # define mach_type_known # endif -# if defined(sun) && defined(__amd64) +# if (defined(sun) || defined(__sun)) && defined(__amd64) # define X86_64 # define SOLARIS # define mach_type_known diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh b/src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh deleted file mode 100755 index 4b785263f..000000000 --- a/src/mm/boehm-gc/libatomic_ops-1.2/autogen.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -if test `uname` = 'FreeBSD'; then - ${CACAO_ACLOCAL} -I . -I /usr/local/share/aclocal -I /usr/local/share/aclocal19 -else - ${CACAO_ACLOCAL} -fi -${CACAO_AUTOHEADER} -${CACAO_AUTOMAKE} --add-missing -${CACAO_AUTOCONF} diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/doc/Makefile.am b/src/mm/boehm-gc/libatomic_ops-1.2/doc/Makefile.am index ce212d08a..09756e71c 100644 --- a/src/mm/boehm-gc/libatomic_ops-1.2/doc/Makefile.am +++ b/src/mm/boehm-gc/libatomic_ops-1.2/doc/Makefile.am @@ -1,3 +1,4 @@ # installed documentation # -dist_pkgdata_DATA=COPYING LICENSING.txt README.txt COPYING README_stack.txt README_malloc.txt README_win32.txt +#dist_pkgdata_DATA=COPYING LICENSING.txt README.txt COPYING README_stack.txt README_malloc.txt README_win32.txt +dist_noinst_DATA=COPYING LICENSING.txt README.txt COPYING README_stack.txt README_malloc.txt README_win32.txt diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/mkinstalldirs b/src/mm/boehm-gc/libatomic_ops-1.2/mkinstalldirs deleted file mode 100755 index 259dbfcd3..000000000 --- a/src/mm/boehm-gc/libatomic_ops-1.2/mkinstalldirs +++ /dev/null @@ -1,158 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy - -scriptversion=2005-06-29.22 - -# Original author: Noah Friedman -# Created: 1993-05-16 -# Public domain. -# -# This file is maintained in Automake, please report -# bugs to or send patches to -# . - -errstatus=0 -dirmode= - -usage="\ -Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... - -Create each directory DIR (with mode MODE, if specified), including all -leading file name components. - -Report bugs to ." - -# process command line arguments -while test $# -gt 0 ; do - case $1 in - -h | --help | --h*) # -h for help - echo "$usage" - exit $? - ;; - -m) # -m PERM arg - shift - test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } - dirmode=$1 - shift - ;; - --version) - echo "$0 $scriptversion" - exit $? - ;; - --) # stop option processing - shift - break - ;; - -*) # unknown option - echo "$usage" 1>&2 - exit 1 - ;; - *) # first non-opt arg - break - ;; - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in - 0) exit 0 ;; -esac - -# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and -# mkdir -p a/c at the same time, both will detect that a is missing, -# one will create a, then the other will try to create a and die with -# a "File exists" error. This is a problem when calling mkinstalldirs -# from a parallel make. We use --version in the probe to restrict -# ourselves to GNU mkdir, which is thread-safe. -case $dirmode in - '') - if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - else - # On NextStep and OpenStep, the `mkdir' command does not - # recognize any option. It will interpret all options as - # directories to create, and then abort because `.' already - # exists. - test -d ./-p && rmdir ./-p - test -d ./--version && rmdir ./--version - fi - ;; - *) - if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && - test ! -d ./--version; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - else - # Clean up after NextStep and OpenStep mkdir. - for d in ./-m ./-p ./--version "./$dirmode"; - do - test -d $d && rmdir $d - done - fi - ;; -esac - -for file -do - case $file in - /*) pathcomp=/ ;; - *) pathcomp= ;; - esac - oIFS=$IFS - IFS=/ - set fnord $file - shift - IFS=$oIFS - - for d - do - test "x$d" = x && continue - - pathcomp=$pathcomp$d - case $pathcomp in - -*) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr= - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp=$pathcomp/ - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-end: "$" -# End: diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/src/Makefile.am b/src/mm/boehm-gc/libatomic_ops-1.2/src/Makefile.am index 7ca41ff11..be1adf9fe 100644 --- a/src/mm/boehm-gc/libatomic_ops-1.2/src/Makefile.am +++ b/src/mm/boehm-gc/libatomic_ops-1.2/src/Makefile.am @@ -2,8 +2,10 @@ SUBDIRS=atomic_ops AM_CFLAGS=@PICFLAG@ -include_HEADERS=atomic_ops.h atomic_ops_stack.h atomic_ops_malloc.h -lib_LIBRARIES = libatomic_ops.a libatomic_ops_gpl.a +#include_HEADERS=atomic_ops.h atomic_ops_stack.h atomic_ops_malloc.h +noinst_HEADERS=atomic_ops.h atomic_ops_stack.h atomic_ops_malloc.h +#lib_LIBRARIES = libatomic_ops.a libatomic_ops_gpl.a +noinst_LIBRARIES = libatomic_ops.a libatomic_ops_gpl.a if NEED_ASM libatomic_ops_a_SOURCES = atomic_ops.c atomic_ops_sysdeps.S else diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am b/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am index 8000273f2..67148e79e 100644 --- a/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am +++ b/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/Makefile.am @@ -3,7 +3,8 @@ SUBDIRS=sysdeps EXTRA_DIST=generalize-small.template #Private Headers -private_HEADERS=generalize.h generalize-small.h +#private_HEADERS=generalize.h generalize-small.h +noinst_HEADERS=generalize.h generalize-small.h privatedir=${includedir}/atomic_ops/ generalize-small.h: generalize-small.template diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am b/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am index f47f8120c..ceed063ef 100644 --- a/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am +++ b/src/mm/boehm-gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/Makefile.am @@ -1,5 +1,6 @@ #General sysdep utility headers, followed by the arch-specific ones -nobase_sysdep_HEADERS= generic_pthread.h \ +#nobase_sysdep_HEADERS= generic_pthread.h \ +noinst_HEADERS= generic_pthread.h \ atomic_load_store.h \ aligned_atomic_load_store.h \ acquire_release_volatile.h \ diff --git a/src/mm/boehm-gc/libatomic_ops-1.2/tests/test_atomic_include.h b/src/mm/boehm-gc/libatomic_ops-1.2/tests/test_atomic_include.h index bc280ebd2..c9970ab36 100644 --- a/src/mm/boehm-gc/libatomic_ops-1.2/tests/test_atomic_include.h +++ b/src/mm/boehm-gc/libatomic_ops-1.2/tests/test_atomic_include.h @@ -5,15 +5,6 @@ * see doc/COPYING for details. */ -void test_atomic(void); -void test_atomic_release(void); -void test_atomic_acquire(void); -void test_atomic_read(void); -void test_atomic_write(void); -void test_atomic_full(void); -void test_atomic_release_write(void); -void test_atomic_acquire_read(void); - /* Some basic sanity tests. These do not test the barrier semantics. */ #undef TA_assert diff --git a/src/mm/boehm-gc/libtool.m4 b/src/mm/boehm-gc/libtool.m4 deleted file mode 100644 index 0f53cb592..000000000 --- a/src/mm/boehm-gc/libtool.m4 +++ /dev/null @@ -1,6397 +0,0 @@ -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -## Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005 -## Free Software Foundation, Inc. -## Originally by Gordon Matzigkeit , 1996 -## -## This file is free software; the Free Software Foundation gives -## unlimited permission to copy and/or distribute it, with or without -## modifications, as long as this notice is preserved. - -# serial 48 AC_PROG_LIBTOOL - - -# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) -# ----------------------------------------------------------- -# If this macro is not defined by Autoconf, define it here. -m4_ifdef([AC_PROVIDE_IFELSE], - [], - [m4_define([AC_PROVIDE_IFELSE], - [m4_ifdef([AC_PROVIDE_$1], - [$2], [$3])])]) - - -# AC_PROG_LIBTOOL -# --------------- -AC_DEFUN([AC_PROG_LIBTOOL], -[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl -dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX -dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. - AC_PROVIDE_IFELSE([AC_PROG_CXX], - [AC_LIBTOOL_CXX], - [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX - ])]) -dnl And a similar setup for Fortran 77 support - AC_PROVIDE_IFELSE([AC_PROG_F77], - [AC_LIBTOOL_F77], - [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 -])]) - -dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. -dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run -dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. - AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], - [AC_LIBTOOL_GCJ], - [ifdef([AC_PROG_GCJ], - [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([A][M_PROG_GCJ], - [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) - ifdef([LT_AC_PROG_GCJ], - [define([LT_AC_PROG_GCJ], - defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) -])])# AC_PROG_LIBTOOL - - -# _AC_PROG_LIBTOOL -# ---------------- -AC_DEFUN([_AC_PROG_LIBTOOL], -[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl -AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl -AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl -AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -# Prevent multiple expansion -define([AC_PROG_LIBTOOL], []) -])# _AC_PROG_LIBTOOL - - -# AC_LIBTOOL_SETUP -# ---------------- -AC_DEFUN([AC_LIBTOOL_SETUP], -[AC_PREREQ(2.50)dnl -AC_REQUIRE([AC_ENABLE_SHARED])dnl -AC_REQUIRE([AC_ENABLE_STATIC])dnl -AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_PROG_LD])dnl -AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl -AC_REQUIRE([AC_PROG_NM])dnl - -AC_REQUIRE([AC_PROG_LN_S])dnl -AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl -# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! -AC_REQUIRE([AC_OBJEXT])dnl -AC_REQUIRE([AC_EXEEXT])dnl -dnl - -AC_LIBTOOL_SYS_MAX_CMD_LEN -AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -AC_LIBTOOL_OBJDIR - -AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -_LT_AC_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' -[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] - -# Same as above, but do not quote variable references. -[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Constants: -rm="rm -f" - -# Global variables: -default_ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a -ltmain="$ac_aux_dir/ltmain.sh" -ofile="$default_ofile" -with_gnu_ld="$lt_cv_prog_gnu_ld" - -AC_CHECK_TOOL(AR, ar, false) -AC_CHECK_TOOL(RANLIB, ranlib, :) -AC_CHECK_TOOL(STRIP, strip, :) - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -test -z "$AS" && AS=as -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$DLLTOOL" && DLLTOOL=dlltool -test -z "$LD" && LD=ld -test -z "$LN_S" && LN_S="ln -s" -test -z "$MAGIC_CMD" && MAGIC_CMD=file -test -z "$NM" && NM=nm -test -z "$SED" && SED=sed -test -z "$OBJDUMP" && OBJDUMP=objdump -test -z "$RANLIB" && RANLIB=: -test -z "$STRIP" && STRIP=: -test -z "$ac_objext" && ac_objext=o - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - AC_PATH_MAGIC - fi - ;; -esac - -AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -enable_win32_dll=yes, enable_win32_dll=no) - -AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -AC_ARG_WITH([pic], - [AC_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) -test -z "$pic_mode" && pic_mode=default - -# Use C for the default configuration in the libtool script -tagname= -AC_LIBTOOL_LANG_C_CONFIG -_LT_AC_TAGCONFIG -])# AC_LIBTOOL_SETUP - - -# _LT_AC_SYS_COMPILER -# ------------------- -AC_DEFUN([_LT_AC_SYS_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_AC_SYS_COMPILER - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -AC_DEFUN([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -AC_DEFUN([_LT_COMPILER_BOILERPLATE], -[ac_outfile=conftest.$ac_objext -printf "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$rm conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -AC_DEFUN([_LT_LINKER_BOILERPLATE], -[ac_outfile=conftest.$ac_objext -printf "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$rm conftest* -])# _LT_LINKER_BOILERPLATE - - -# _LT_AC_SYS_LIBPATH_AIX -# ---------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], -[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } -}'`; fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_AC_SYS_LIBPATH_AIX - - -# _LT_AC_SHELL_INIT(ARG) -# ---------------------- -AC_DEFUN([_LT_AC_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_AC_SHELL_INIT - - -# _LT_AC_PROG_ECHO_BACKSLASH -# -------------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], -[_LT_AC_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -echo=${ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then - # Yippee, $echo works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat </dev/null 2>&1 && unset CDPATH - -if test -z "$ECHO"; then -if test "X${echo_test_string+set}" != Xset; then -# find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if (echo_test_string=`eval $cmd`) 2>/dev/null && - echo_test_string=`eval $cmd` && - (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null - then - break - fi - done -fi - -if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : -else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$echo" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - echo='print -r' - elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - echo='printf %s\n' - if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - echo="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - echo="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - echo=echo - fi - fi - fi - fi -fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -ECHO=$echo -if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(ECHO) -])])# _LT_AC_PROG_ECHO_BACKSLASH - - -# _LT_AC_LOCK -# ----------- -AC_DEFUN([_LT_AC_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AC_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) LD="${LD-ld} -64" ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], -[*-*-cygwin* | *-*-mingw* | *-*-pw32*) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; - ]) -esac - -need_locks="$enable_libtool_lock" - -])# _LT_AC_LOCK - - -# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], -[AC_REQUIRE([LT_AC_PROG_SED]) -AC_CACHE_CHECK([$1], [$2], - [$2=no - ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $rm conftest* -]) - -if test x"[$]$2" = xyes; then - ifelse([$5], , :, [$5]) -else - ifelse([$6], , :, [$6]) -fi -])# AC_LIBTOOL_COMPILER_OPTION - - -# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ------------------------------------------------------------ -# Check whether the given compiler option works -AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], -[AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - printf "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $rm conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - ifelse([$4], , :, [$4]) -else - ifelse([$5], , :, [$5]) -fi -])# AC_LIBTOOL_LINKER_OPTION - - -# AC_LIBTOOL_SYS_MAX_CMD_LEN -# -------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], -[# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ - = "XX$teststring") >/dev/null 2>&1 && - new_result=`expr "X$teststring" : ".*" 2>&1` && - lt_cv_sys_max_cmd_len=$new_result && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - teststring= - # Add a significant safety factor because C++ compilers can tack on massive - # amounts of additional arguments before passing them to the linker. - # It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -])# AC_LIBTOOL_SYS_MAX_CMD_LEN - - -# _LT_AC_CHECK_DLFCN -# ------------------ -AC_DEFUN([_LT_AC_CHECK_DLFCN], -[AC_CHECK_HEADERS(dlfcn.h)dnl -])# _LT_AC_CHECK_DLFCN - - -# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# --------------------------------------------------------------------- -AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext < -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -#ifdef __cplusplus -extern "C" void exit (int); -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - exit (status); -}] -EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_AC_TRY_DLOPEN_SELF - - -# AC_LIBTOOL_DLOPEN_SELF -# ---------------------- -AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], -[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_AC_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -])# AC_LIBTOOL_DLOPEN_SELF - - -# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) -# --------------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler -AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $rm -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $rm conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files - $rm out/* && rmdir out - cd .. - rmdir conftest - $rm conftest* -]) -])# AC_LIBTOOL_PROG_CC_C_O - - -# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) -# ----------------------------------------- -# Check to see if we can do hard links to lock some files if needed -AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], -[AC_REQUIRE([_LT_AC_LOCK])dnl - -hard_links="nottested" -if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $rm conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS - - -# AC_LIBTOOL_OBJDIR -# ----------------- -AC_DEFUN([AC_LIBTOOL_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -])# AC_LIBTOOL_OBJDIR - - -# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) -# ---------------------------------------------- -# Check hardcoding attributes. -AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_AC_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ - test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ - test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existant directories. - if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_AC_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_AC_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_AC_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH - - -# AC_LIBTOOL_SYS_LIB_STRIP -# ------------------------ -AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], -[striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) -fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -])# AC_LIBTOOL_SYS_LIB_STRIP - - -# AC_LIBTOOL_SYS_DYNAMIC_LINKER -# ----------------------------- -# PORTME Fill in your ld.so characteristics -AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], -[AC_MSG_CHECKING([dynamic linker characteristics]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix4* | aix5*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $rm \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' - # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. - if test "$GCC" = yes; then - sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` - else - sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' - fi - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -kfreebsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[123]]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - freebsd*) # from 4.6 on - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix3*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -knetbsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='GNU ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -nto-qnx*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - export_dynamic_flag_spec='${wl}-Blargedynsym' - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - shlibpath_overrides_runpath=no - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - shlibpath_overrides_runpath=yes - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi -])# AC_LIBTOOL_SYS_DYNAMIC_LINKER - - -# _LT_AC_TAGCONFIG -# ---------------- -AC_DEFUN([_LT_AC_TAGCONFIG], -[AC_ARG_WITH([tags], - [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], - [include additional configurations @<:@automatic@:>@])], - [tagnames="$withval"]) - -if test -f "$ltmain" && test -n "$tagnames"; then - if test ! -f "${ofile}"; then - AC_MSG_WARN([output file `$ofile' does not exist]) - fi - - if test -z "$LTCC"; then - eval "`$SHELL ${ofile} --config | grep '^LTCC='`" - if test -z "$LTCC"; then - AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) - else - AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) - fi - fi - if test -z "$LTCFLAGS"; then - eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`" - fi - - # Extract list of available tagged configurations in $ofile. - # Note that this assumes the entire list is on one line. - available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` - - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for tagname in $tagnames; do - IFS="$lt_save_ifs" - # Check whether tagname contains only valid characters - case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in - "") ;; - *) AC_MSG_ERROR([invalid tag name: $tagname]) - ;; - esac - - if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null - then - AC_MSG_ERROR([tag name \"$tagname\" already exists]) - fi - - # Update the list of available tags. - if test -n "$tagname"; then - echo appending configuration tag \"$tagname\" to $ofile - - case $tagname in - CXX) - if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_LIBTOOL_LANG_CXX_CONFIG - else - tagname="" - fi - ;; - - F77) - if test -n "$F77" && test "X$F77" != "Xno"; then - AC_LIBTOOL_LANG_F77_CONFIG - else - tagname="" - fi - ;; - - GCJ) - if test -n "$GCJ" && test "X$GCJ" != "Xno"; then - AC_LIBTOOL_LANG_GCJ_CONFIG - else - tagname="" - fi - ;; - - RC) - AC_LIBTOOL_LANG_RC_CONFIG - ;; - - *) - AC_MSG_ERROR([Unsupported tag name: $tagname]) - ;; - esac - - # Append the new tag name to the list of available tags. - if test -n "$tagname" ; then - available_tags="$available_tags $tagname" - fi - fi - done - IFS="$lt_save_ifs" - - # Now substitute the updated list of available tags. - if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then - mv "${ofile}T" "$ofile" - chmod +x "$ofile" - else - rm -f "${ofile}T" - AC_MSG_ERROR([unable to update list of available tagged configurations.]) - fi -fi -])# _LT_AC_TAGCONFIG - - -# AC_LIBTOOL_DLOPEN -# ----------------- -# enable checks for dlopen support -AC_DEFUN([AC_LIBTOOL_DLOPEN], - [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_DLOPEN - - -# AC_LIBTOOL_WIN32_DLL -# -------------------- -# declare package support for building win32 DLLs -AC_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) -])# AC_LIBTOOL_WIN32_DLL - - -# AC_ENABLE_SHARED([DEFAULT]) -# --------------------------- -# implement the --enable-shared flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_SHARED], -[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([shared], - [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]AC_ENABLE_SHARED_DEFAULT) -])# AC_ENABLE_SHARED - - -# AC_DISABLE_SHARED -# ----------------- -# set the default shared flag to --disable-shared -AC_DEFUN([AC_DISABLE_SHARED], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_SHARED(no) -])# AC_DISABLE_SHARED - - -# AC_ENABLE_STATIC([DEFAULT]) -# --------------------------- -# implement the --enable-static flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_STATIC], -[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([static], - [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]AC_ENABLE_STATIC_DEFAULT) -])# AC_ENABLE_STATIC - - -# AC_DISABLE_STATIC -# ----------------- -# set the default static flag to --disable-static -AC_DEFUN([AC_DISABLE_STATIC], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_STATIC(no) -])# AC_DISABLE_STATIC - - -# AC_ENABLE_FAST_INSTALL([DEFAULT]) -# --------------------------------- -# implement the --enable-fast-install flag -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -AC_DEFUN([AC_ENABLE_FAST_INSTALL], -[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl -AC_ARG_ENABLE([fast-install], - [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) -])# AC_ENABLE_FAST_INSTALL - - -# AC_DISABLE_FAST_INSTALL -# ----------------------- -# set the default to --disable-fast-install -AC_DEFUN([AC_DISABLE_FAST_INSTALL], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -AC_ENABLE_FAST_INSTALL(no) -])# AC_DISABLE_FAST_INSTALL - - -# AC_LIBTOOL_PICMODE([MODE]) -# -------------------------- -# implement the --with-pic flag -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -AC_DEFUN([AC_LIBTOOL_PICMODE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl -pic_mode=ifelse($#,1,$1,default) -])# AC_LIBTOOL_PICMODE - - -# AC_PROG_EGREP -# ------------- -# This is predefined starting with Autoconf 2.54, so this conditional -# definition can be removed once we require Autoconf 2.54 or later. -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], -[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], - [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 - then ac_cv_prog_egrep='grep -E' - else ac_cv_prog_egrep='egrep' - fi]) - EGREP=$ac_cv_prog_egrep - AC_SUBST([EGREP]) -])]) - - -# AC_PATH_TOOL_PREFIX -# ------------------- -# find a file program which can recognise shared library -AC_DEFUN([AC_PATH_TOOL_PREFIX], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="ifelse([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -])# AC_PATH_TOOL_PREFIX - - -# AC_PATH_MAGIC -# ------------- -# find a file program which can recognise a shared library -AC_DEFUN([AC_PATH_MAGIC], -[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# AC_PATH_MAGIC - - -# AC_PROG_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([AC_PROG_LD], -[AC_ARG_WITH([gnu-ld], - [AC_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no]) -AC_REQUIRE([LT_AC_PROG_SED])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix3*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux*) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -nto-qnx*) - lt_cv_deplibs_check_method=unknown - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown -])# AC_DEPLIBS_CHECK_METHOD - - -# AC_PROG_NM -# ---------- -# find the pathname to a BSD-compatible name lister -AC_DEFUN([AC_PROG_NM], -[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm -fi]) -NM="$lt_cv_path_NM" -])# AC_PROG_NM - - -# AC_CHECK_LIBM -# ------------- -# check for math library -AC_DEFUN([AC_CHECK_LIBM], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -])# AC_CHECK_LIBM - - -# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) -# ----------------------------------- -# sets LIBLTDL to the link flags for the libltdl convenience library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-convenience to the configure arguments. Note that -# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, -# it is assumed to be `libltdl'. LIBLTDL will be prefixed with -# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/' -# (note the single quotes!). If your package is not flat and you're not -# using automake, define top_builddir and top_srcdir appropriately in -# the Makefiles. -AC_DEFUN([AC_LIBLTDL_CONVENIENCE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - case $enable_ltdl_convenience in - no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; - "") enable_ltdl_convenience=yes - ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; - esac - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la - LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - # For backwards non-gettext consistent compatibility... - INCLTDL="$LTDLINCL" -])# AC_LIBLTDL_CONVENIENCE - - -# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) -# ----------------------------------- -# sets LIBLTDL to the link flags for the libltdl installable library and -# LTDLINCL to the include flags for the libltdl header and adds -# --enable-ltdl-install to the configure arguments. Note that -# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided, -# and an installed libltdl is not found, it is assumed to be `libltdl'. -# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with -# '${top_srcdir}/' (note the single quotes!). If your package is not -# flat and you're not using automake, define top_builddir and top_srcdir -# appropriately in the Makefiles. -# In the future, this macro may have to be called after AC_PROG_LIBTOOL. -AC_DEFUN([AC_LIBLTDL_INSTALLABLE], -[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl - AC_CHECK_LIB(ltdl, lt_dlinit, - [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], - [if test x"$enable_ltdl_install" = xno; then - AC_MSG_WARN([libltdl not installed, but installation disabled]) - else - enable_ltdl_install=yes - fi - ]) - if test x"$enable_ltdl_install" = x"yes"; then - ac_configure_args="$ac_configure_args --enable-ltdl-install" - LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la - LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) - else - ac_configure_args="$ac_configure_args --enable-ltdl-install=no" - LIBLTDL="-lltdl" - LTDLINCL= - fi - # For backwards non-gettext consistent compatibility... - INCLTDL="$LTDLINCL" -])# AC_LIBLTDL_INSTALLABLE - - -# AC_LIBTOOL_CXX -# -------------- -# enable support for C++ libraries -AC_DEFUN([AC_LIBTOOL_CXX], -[AC_REQUIRE([_LT_AC_LANG_CXX]) -])# AC_LIBTOOL_CXX - - -# _LT_AC_LANG_CXX -# --------------- -AC_DEFUN([_LT_AC_LANG_CXX], -[AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([_LT_AC_PROG_CXXCPP]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) -])# _LT_AC_LANG_CXX - -# _LT_AC_PROG_CXXCPP -# ------------------ -AC_DEFUN([_LT_AC_PROG_CXXCPP], -[ -AC_REQUIRE([AC_PROG_CXX]) -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -fi -])# _LT_AC_PROG_CXXCPP - -# AC_LIBTOOL_F77 -# -------------- -# enable support for Fortran 77 libraries -AC_DEFUN([AC_LIBTOOL_F77], -[AC_REQUIRE([_LT_AC_LANG_F77]) -])# AC_LIBTOOL_F77 - - -# _LT_AC_LANG_F77 -# --------------- -AC_DEFUN([_LT_AC_LANG_F77], -[AC_REQUIRE([AC_PROG_F77]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) -])# _LT_AC_LANG_F77 - - -# AC_LIBTOOL_GCJ -# -------------- -# enable support for GCJ libraries -AC_DEFUN([AC_LIBTOOL_GCJ], -[AC_REQUIRE([_LT_AC_LANG_GCJ]) -])# AC_LIBTOOL_GCJ - - -# _LT_AC_LANG_GCJ -# --------------- -AC_DEFUN([_LT_AC_LANG_GCJ], -[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], - [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], - [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], - [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], - [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) -])# _LT_AC_LANG_GCJ - - -# AC_LIBTOOL_RC -# ------------- -# enable support for Windows resource files -AC_DEFUN([AC_LIBTOOL_RC], -[AC_REQUIRE([LT_AC_PROG_RC]) -_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) -])# AC_LIBTOOL_RC - - -# AC_LIBTOOL_LANG_C_CONFIG -# ------------------------ -# Ensure that the configuration vars for the C compiler are -# suitably defined. Those variables are subsequently used by -# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) -AC_DEFUN([_LT_AC_LANG_C_CONFIG], -[lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_AC_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}\n' - -_LT_AC_SYS_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) -AC_LIBTOOL_PROG_COMPILER_PIC($1) -AC_LIBTOOL_PROG_CC_C_O($1) -AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -AC_LIBTOOL_PROG_LD_SHLIBS($1) -AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) -AC_LIBTOOL_SYS_LIB_STRIP -AC_LIBTOOL_DLOPEN_SELF - -# Report which library types will actually be built -AC_MSG_CHECKING([if libtool supports shared libraries]) -AC_MSG_RESULT([$can_build_shared]) - -AC_MSG_CHECKING([whether to build shared libraries]) -test "$can_build_shared" = "no" && enable_shared=no - -# On AIX, shared libraries and static libraries use the same namespace, and -# are all built from PIC. -case $host_os in -aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - -aix4* | aix5*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; -esac -AC_MSG_RESULT([$enable_shared]) - -AC_MSG_CHECKING([whether to build static libraries]) -# Make sure either enable_shared or enable_static is yes. -test "$enable_shared" = yes || enable_static=yes -AC_MSG_RESULT([$enable_static]) - -AC_LIBTOOL_CONFIG($1) - -AC_LANG_POP -CC="$lt_save_CC" -])# AC_LIBTOOL_LANG_C_CONFIG - - -# AC_LIBTOOL_LANG_CXX_CONFIG -# -------------------------- -# Ensure that the configuration vars for the C compiler are -# suitably defined. Those variables are subsequently used by -# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. -AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) -AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], -[AC_LANG_PUSH(C++) -AC_REQUIRE([AC_PROG_CXX]) -AC_REQUIRE([_LT_AC_PROG_CXXCPP]) - -_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_AC_TAGVAR(allow_undefined_flag, $1)= -_LT_AC_TAGVAR(always_export_symbols, $1)=no -_LT_AC_TAGVAR(archive_expsym_cmds, $1)= -_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_AC_TAGVAR(hardcode_direct, $1)=no -_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= -_LT_AC_TAGVAR(hardcode_minus_L, $1)=no -_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_AC_TAGVAR(hardcode_automatic, $1)=no -_LT_AC_TAGVAR(module_cmds, $1)= -_LT_AC_TAGVAR(module_expsym_cmds, $1)= -_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown -_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_AC_TAGVAR(no_undefined_flag, $1)= -_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= -_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Dependencies to place before and after the object being linked: -_LT_AC_TAGVAR(predep_objects, $1)= -_LT_AC_TAGVAR(postdep_objects, $1)= -_LT_AC_TAGVAR(predeps, $1)= -_LT_AC_TAGVAR(postdeps, $1)= -_LT_AC_TAGVAR(compiler_lib_search_path, $1)= - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_AC_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;\n" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_AC_SYS_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC=$CC -lt_save_LD=$LD -lt_save_GCC=$GCC -GCC=$GXX -lt_save_with_gnu_ld=$with_gnu_ld -lt_save_path_LD=$lt_cv_path_LD -if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx -else - $as_unset lt_cv_prog_gnu_ld -fi -if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX -else - $as_unset lt_cv_path_LD -fi -test -z "${LDCXX+set}" || LD=$LDCXX -CC=${CXX-"c++"} -compiler=$CC -_LT_AC_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) - -# We don't want -fno-exception wen compiling C++ code, so set the -# no_builtin_flag separately -if test "$GXX" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' -else - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= -fi - -if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - AC_PROG_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ - grep 'no-whole-archive' > /dev/null; then - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - -else - GXX=no - with_gnu_ld=no - wlarc= -fi - -# PORTME: fill in a description of your system's C++ link characteristics -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -_LT_AC_TAGVAR(ld_shlibs, $1)=yes -case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_AC_TAGVAR(archive_cmds, $1)='' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - else - # We have old collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GXX" = yes ; then - lt_int_apple_cc_single_mod=no - output_verbose_link_cmd='echo' - if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then - lt_int_apple_cc_single_mod=yes - fi - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - fi - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - if test "X$lt_int_apple_cc_single_mod" = Xyes ; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - freebsd[[12]]*) - # C++ shared libraries reported to be fairly broken before switch to ELF - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - freebsd-elf*) - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - ;; - gnu*) - ;; - hpux9*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - ;; - *) - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - interix3*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' - fi - fi - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - linux*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc*) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC*) - # Portland Group C++ compiler - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - esac - ;; - lynxos*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - m88k*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - openbsd2*) - # C++ shared libraries are fairly broken - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - openbsd*) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd='echo' - ;; - osf3*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~ - $rm $lib.exp' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - psos*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The C++ compiler is used as linker so we must use $wl - # flag to pass the commands to the underlying system - # linker. We must also pass each convience library through - # to the system linker between allextract/defaultextract. - # The C++ compiler will combine linker options so we - # cannot just pass the convience library names through - # without $wl. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' - ;; - esac - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | grep -v '^2\.7' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" - fi - - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - fi - ;; - esac - ;; - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - # So that behaviour is only enabled if SCOABSPATH is set to a - # non-empty value in the environment. Most likely only useful for - # creating official distributions of packages. - # This is a hack until libtool officially supports absolute path - # names for shared libraries. - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - vxworks*) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; -esac -AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_AC_TAGVAR(GCC, $1)="$GXX" -_LT_AC_TAGVAR(LD, $1)="$LD" - -## CAVEAT EMPTOR: -## There is no encapsulation within the following macros, do not change -## the running order or otherwise move them around unless you know exactly -## what you are doing... -AC_LIBTOOL_POSTDEP_PREDEP($1) -AC_LIBTOOL_PROG_COMPILER_PIC($1) -AC_LIBTOOL_PROG_CC_C_O($1) -AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) -AC_LIBTOOL_PROG_LD_SHLIBS($1) -AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) -AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) - -AC_LIBTOOL_CONFIG($1) - -AC_LANG_POP -CC=$lt_save_CC -LDCXX=$LD -LD=$lt_save_LD -GCC=$lt_save_GCC -with_gnu_ldcxx=$with_gnu_ld -with_gnu_ld=$lt_save_with_gnu_ld -lt_cv_path_LDCXX=$lt_cv_path_LD -lt_cv_path_LD=$lt_save_path_LD -lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld -lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -])# AC_LIBTOOL_LANG_CXX_CONFIG - -# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) -# ------------------------------------ -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" -ifelse([$1], [], -[#! $SHELL - -# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. -# -# This file is part of GNU Libtool: -# Originally by Gordon Matzigkeit , 1996 -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# A sed program that does not truncate output. -SED=$lt_SED - -# Sed that helps us avoid accidentally triggering echo(1) options like -n. -Xsed="$SED -e 1s/^X//" - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -# The names of the tagged configurations supported by this script. -available_tags= - -# ### BEGIN LIBTOOL CONFIG], -[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) - -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: - -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# Whether or not to build shared libraries. -build_libtool_libs=$enable_shared - -# Whether or not to build static libraries. -build_old_libs=$enable_static - -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) - -# Whether or not to disallow shared libs when runtime libs are static -allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) - -# Whether or not to optimize for fast installation. -fast_install=$enable_fast_install - -# The host system. -host_alias=$host_alias -host=$host -host_os=$host_os - -# The build system. -build_alias=$build_alias -build=$build -build_os=$build_os - -# An echo program that does not interpret backslashes. -echo=$lt_echo - -# The archiver. -AR=$lt_AR -AR_FLAGS=$lt_AR_FLAGS - -# A C compiler. -LTCC=$lt_LTCC - -# LTCC compiler flags. -LTCFLAGS=$lt_LTCFLAGS - -# A language-specific compiler. -CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) - -# Is the compiler the GNU C compiler? -with_gcc=$_LT_AC_TAGVAR(GCC, $1) - -# An ERE matcher. -EGREP=$lt_EGREP - -# The linker used to build libraries. -LD=$lt_[]_LT_AC_TAGVAR(LD, $1) - -# Whether we need hard or soft links. -LN_S=$lt_LN_S - -# A BSD-compatible nm program. -NM=$lt_NM - -# A symbol stripping program -STRIP=$lt_STRIP - -# Used to examine libraries when file_magic_cmd begins "file" -MAGIC_CMD=$MAGIC_CMD - -# Used on cygwin: DLL creation program. -DLLTOOL="$DLLTOOL" - -# Used on cygwin: object dumper. -OBJDUMP="$OBJDUMP" - -# Used on cygwin: assembler. -AS="$AS" - -# The name of the directory that contains temporary libtool files. -objdir=$objdir - -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds - -# How to pass a linker flag through the compiler. -wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) - -# Object file suffix (normally "o"). -objext="$ac_objext" - -# Old archive suffix (normally "a"). -libext="$libext" - -# Shared library suffix (normally ".so"). -shrext_cmds='$shrext_cmds' - -# Executable file suffix (normally ""). -exeext="$exeext" - -# Additional compiler flags for building library objects. -pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) -pic_mode=$pic_mode - -# What is the maximum length of a command? -max_cmd_len=$lt_cv_sys_max_cmd_len - -# Does compiler simultaneously support -c and -o options? -compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) - -# Must we lock files when doing compilation? -need_locks=$lt_need_locks - -# Do we need the lib prefix for modules? -need_lib_prefix=$need_lib_prefix - -# Do we need a version for libraries? -need_version=$need_version - -# Whether dlopen is supported. -dlopen_support=$enable_dlopen - -# Whether dlopen of programs is supported. -dlopen_self=$enable_dlopen_self - -# Whether dlopen of statically linked programs is supported. -dlopen_self_static=$enable_dlopen_self_static - -# Compiler flag to prevent dynamic linking. -link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) - -# Compiler flag to turn off builtin functions. -no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) - -# Compiler flag to allow reflexive dlopens. -export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) - -# Compiler flag to generate shared objects directly from archives. -whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) - -# Compiler flag to generate thread-safe objects. -thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) - -# Library versioning type. -version_type=$version_type - -# Format of library name prefix. -libname_spec=$lt_libname_spec - -# List of archive names. First name is the real one, the rest are links. -# The last name is the one that the linker finds with -lNAME. -library_names_spec=$lt_library_names_spec - -# The coded name of the library, if different from the real name. -soname_spec=$lt_soname_spec - -# Commands used to build and install an old-style archive. -RANLIB=$lt_RANLIB -old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) -old_postinstall_cmds=$lt_old_postinstall_cmds -old_postuninstall_cmds=$lt_old_postuninstall_cmds - -# Create an old-style archive from a shared archive. -old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) - -# Create a temporary old-style archive to link instead of a shared archive. -old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) - -# Commands used to build and install a shared archive. -archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) -archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) -postinstall_cmds=$lt_postinstall_cmds -postuninstall_cmds=$lt_postuninstall_cmds - -# Commands used to build a loadable module (assumed same as above if empty) -module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) -module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) - -# Commands to strip libraries. -old_striplib=$lt_old_striplib -striplib=$lt_striplib - -# Dependencies to place before the objects being linked to create a -# shared library. -predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) - -# Dependencies to place after the objects being linked to create a -# shared library. -postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) - -# Dependencies to place before the objects being linked to create a -# shared library. -predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) - -# Dependencies to place after the objects being linked to create a -# shared library. -postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) - -# The library search path used internally by the compiler when linking -# a shared library. -compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) - -# Method to check whether dependent libraries are shared objects. -deplibs_check_method=$lt_deplibs_check_method - -# Command to use when deplibs_check_method == file_magic. -file_magic_cmd=$lt_file_magic_cmd - -# Flag that allows shared libraries with undefined symbols to be built. -allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) - -# Flag that forces no undefined symbols. -no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) - -# Commands used to finish a libtool library installation in a directory. -finish_cmds=$lt_finish_cmds - -# Same as above, but a single script fragment to be evaled but not shown. -finish_eval=$lt_finish_eval - -# Take the output of nm and produce a listing of raw symbols and C names. -global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe - -# Transform the output of nm in a proper C declaration -global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl - -# Transform the output of nm in a C name address pair -global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address - -# This is the shared library runtime path variable. -runpath_var=$runpath_var - -# This is the shared library path variable. -shlibpath_var=$shlibpath_var - -# Is shlibpath searched before the hard-coded library search path? -shlibpath_overrides_runpath=$shlibpath_overrides_runpath - -# How to hardcode a shared library path into an executable. -hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) - -# Whether we should hardcode library paths into libraries. -hardcode_into_libs=$hardcode_into_libs - -# Flag to hardcode \$libdir into a binary during linking. -# This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) - -# If ld is used when linking, flag to hardcode \$libdir into -# a binary during linking. This must work even if \$libdir does -# not exist. -hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) - -# Whether we need a single -rpath flag with a separated argument. -hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) - -# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the -# resulting binary. -hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) - -# Set to yes if using the -LDIR flag during linking hardcodes DIR into the -# resulting binary. -hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) - -# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into -# the resulting binary. -hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) - -# Set to yes if building a shared library automatically hardcodes DIR into the library -# and all subsequent libraries and executables linked against it. -hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) - -# Variables whose values should be saved in libtool wrapper scripts and -# restored at relink time. -variables_saved_for_relink="$variables_saved_for_relink" - -# Whether libtool must link a program against all its dependency libraries. -link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) - -# Compile-time system search path for libraries -sys_lib_search_path_spec=$lt_sys_lib_search_path_spec - -# Run-time system search path for libraries -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec - -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" - -# Set to yes if exported symbols are required. -always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) - -# The commands to list exported symbols. -export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) - -# The commands to extract the exported symbol list from a shared archive. -extract_expsyms_cmds=$lt_extract_expsyms_cmds - -# Symbols that should not be listed in the preloaded symbols. -exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) - -# Symbols that must always be exported. -include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) - -ifelse([$1],[], -[# ### END LIBTOOL CONFIG], -[# ### END LIBTOOL TAG CONFIG: $tagname]) - -__EOF__ - -ifelse([$1],[], [ - case $host_os in - aix3*) - cat <<\EOF >> "$cfgfile" - -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -EOF - ;; - esac - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || \ - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -]) -else - # If there is no Makefile yet, we rely on a make rule to execute - # `config.status --recheck' to rerun these tests and create the - # libtool script then. - ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` - if test -f "$ltmain_in"; then - test -f Makefile && make "$ltmain" - fi -fi -])# AC_LIBTOOL_CONFIG - - -# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------------------- -AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], -[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl - -_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI - - -# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE -# --------------------------------- -AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], -[AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_NM]) -AC_REQUIRE([AC_OBJEXT]) -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Transform an extracted symbol line into a proper C declaration -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) # Its linker distinguishes data from code symbols - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - ;; -linux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDGIRSTW]]' - lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Try without a prefix undercore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if grep ' nm_test_var$' "$nlist" >/dev/null; then - if grep ' nm_test_func$' "$nlist" >/dev/null; then - cat < conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' - - cat <> conftest.$ac_ext -#if defined (__STDC__) && __STDC__ -# define lt_ptr_t void * -#else -# define lt_ptr_t char * -# define const -#endif - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - lt_ptr_t address; -} -lt_preloaded_symbols[[]] = -{ -EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext - cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr_t) 0} -}; - -#ifdef __cplusplus -} -#endif -EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -f conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi -]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE - - -# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) -# --------------------------------------- -AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], -[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) - ifelse([$1],[CXX],[ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | os2* | pw32*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix4* | aix5*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | kfreebsd*-gnu | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux*) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - icpc* | ecpc*) - # Intel C++ - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC*) - # Portland Group C++ compiler. - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - - beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - interix3*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - hpux*) - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - darwin*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - case $cc_basename in - xlc*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - esac - ;; - - mingw* | pw32* | os2*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' - ;; - - hpux9* | hpux10* | hpux11*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - newsos6) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - linux*) - case $cc_basename in - icc* | ecc*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - esac - ;; - - osf3* | osf4* | osf5*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then - AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], - _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), - [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" - ;; -esac - -# -# Check to make sure the static flag actually works. -# -wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\" -AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) -]) - - -# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) -# ------------------------------------ -# See if the linker supports building shared libraries. -AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], -[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -ifelse([$1],[CXX],[ - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix4* | aix5*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - else - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw*) - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' - ;; - *) - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac -],[ - runpath_var= - _LT_AC_TAGVAR(allow_undefined_flag, $1)= - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_AC_TAGVAR(archive_cmds, $1)= - _LT_AC_TAGVAR(archive_expsym_cmds, $1)= - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= - _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_minus_L, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown - _LT_AC_TAGVAR(hardcode_automatic, $1)=no - _LT_AC_TAGVAR(module_cmds, $1)= - _LT_AC_TAGVAR(module_expsym_cmds, $1)= - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_AC_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - extract_expsyms_cmds= - # Just being paranoid about ensuring that cc_basename is set. - _LT_CC_BASENAME([$compiler]) - case $host_os in - cygwin* | mingw* | pw32*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>/dev/null` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix3* | aix4* | aix5*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -EOF - fi - ;; - - amigaos*) - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - - # Samuel A. Falvo II reports - # that the semantics of dynamic libraries on AmigaOS, at least up - # to version 4, is to share data among multiple programs linked - # with the same dynamic library. Since this doesn't match the - # behavior of shared libraries on other platforms, we can't use - # them. - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - beos*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32*) - # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=no - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - interix3*) - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - linux*) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - tmp_addflag= - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - esac - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test $supports_anon_versioning = yes; then - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - $echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -EOF - elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_AC_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix4* | aix5*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | grep 'GNU' > /dev/null; then - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - else - _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_AC_TAGVAR(archive_cmds, $1)='' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - else - # We have old collect2 - _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_AC_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an empty executable. - _LT_AC_SYS_LIBPATH_AIX - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - # see comment about different semantics on the GNU ld section - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - bsdi[[45]]*) - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' - _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - case $host_os in - rhapsody* | darwin1.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' - ;; - *) # Darwin 1.3 on - if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - else - case ${MACOSX_DEPLOYMENT_TARGET} in - 10.[[012]]) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' - ;; - 10.*) - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' - ;; - esac - fi - ;; - esac - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_automatic, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - if test "$GCC" = yes ; then - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - else - case $cc_basename in - xlc*) - output_verbose_link_cmd='echo' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' - _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' - # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' - ;; - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi - ;; - - dgux*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | kfreebsd*-gnu | dragonfly*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - openbsd*) - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - ;; - - os2*) - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ - $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' - else - wlarc='' - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine linker options so we - # cannot just pass the convience library names through - # without $wl, iff we do not link with $LD. - # Luckily, gcc supports the same syntax we need for Sun Studio. - # Supported since Solaris 2.6 (maybe 2.5.1?) - case $wlarc in - '') - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; - *) - _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;; - esac ;; - esac - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes - _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_AC_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_AC_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*) - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' - _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_AC_TAGVAR(link_all_deplibs, $1)=yes - _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_AC_TAGVAR(ld_shlibs, $1)=no - ;; - esac - fi -]) -AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) -test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -# -# Do we need to explicitly link libc? -# -case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_AC_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - $rm conftest* - printf "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) - _LT_AC_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) - then - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $rm conftest* - AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac -])# AC_LIBTOOL_PROG_LD_SHLIBS - - -# _LT_AC_FILE_LTDLL_C -# ------------------- -# Be careful that the start marker always follows a newline. -AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ -# /* ltdll.c starts here */ -# #define WIN32_LEAN_AND_MEAN -# #include -# #undef WIN32_LEAN_AND_MEAN -# #include -# -# #ifndef __CYGWIN__ -# # ifdef __CYGWIN32__ -# # define __CYGWIN__ __CYGWIN32__ -# # endif -# #endif -# -# #ifdef __cplusplus -# extern "C" { -# #endif -# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); -# #ifdef __cplusplus -# } -# #endif -# -# #ifdef __CYGWIN__ -# #include -# DECLARE_CYGWIN_DLL( DllMain ); -# #endif -# HINSTANCE __hDllInstance_base; -# -# BOOL APIENTRY -# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) -# { -# __hDllInstance_base = hInst; -# return TRUE; -# } -# /* ltdll.c ends here */ -])# _LT_AC_FILE_LTDLL_C - - -# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) -# --------------------------------- -AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) - - -# old names -AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) -AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) -AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) -AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) -AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) - -# This is just to silence aclocal about the macro not being used -ifelse([AC_DISABLE_FAST_INSTALL]) - -AC_DEFUN([LT_AC_PROG_GCJ], -[AC_CHECK_TOOL(GCJ, gcj, no) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS) -]) - -AC_DEFUN([LT_AC_PROG_RC], -[AC_CHECK_TOOL(RC, windres, no) -]) - -############################################################ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # -############################################################ -# LT_AC_PROG_SED -# -------------- -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -AC_DEFUN([LT_AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_MSG_RESULT([$SED]) -]) diff --git a/src/mm/boehm-gc/m4/dummy b/src/mm/boehm-gc/m4/dummy new file mode 100644 index 000000000..e69de29bb diff --git a/src/mm/boehm-gc/mkinstalldirs b/src/mm/boehm-gc/mkinstalldirs deleted file mode 100755 index 82a561f43..000000000 --- a/src/mm/boehm-gc/mkinstalldirs +++ /dev/null @@ -1,101 +0,0 @@ -#! /bin/sh -# mkinstalldirs --- make directory hierarchy -# Author: Noah Friedman -# Created: 1993-05-16 -# Public domain - -# $Id: mkinstalldirs,v 1.1.1.1 2005/10/10 22:33:34 hboehm Exp $ - -errstatus=0 -dirmode="" - -usage="\ -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." - -# process command line arguments -while test $# -gt 0 ; do - case "${1}" in - -h | --help | --h* ) # -h for help - echo "${usage}" 1>&2; exit 0 ;; - -m ) # -m PERM arg - shift - test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } - dirmode="${1}" - shift ;; - -- ) shift; break ;; # stop option processing - -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option - * ) break ;; # first non-opt arg - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in -0) exit 0 ;; -esac - -case $dirmode in -'') - if mkdir -p -- . 2>/dev/null; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - fi ;; -*) - if mkdir -m "$dirmode" -p -- . 2>/dev/null; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - fi ;; -esac - -for file -do - set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` - shift - - pathcomp= - for d - do - pathcomp="$pathcomp$d" - case "$pathcomp" in - -* ) pathcomp=./$pathcomp ;; - esac - - if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - - lasterr="" - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi - fi - - pathcomp="$pathcomp/" - done -done - -exit $errstatus - -# Local Variables: -# mode: shell-script -# sh-indentation: 3 -# End: -# mkinstalldirs ends here diff --git a/src/mm/boehm-gc/pthread_stop_world.c b/src/mm/boehm-gc/pthread_stop_world.c index 85fa531cb..30ad9bef5 100644 --- a/src/mm/boehm-gc/pthread_stop_world.c +++ b/src/mm/boehm-gc/pthread_stop_world.c @@ -372,9 +372,6 @@ int GC_suspend_all() return n_live_threads; } -void lock_stopworld(int); -void unlock_stopworld(); - void GC_stop_world() { int i; @@ -561,16 +558,4 @@ void GC_stop_init() { } } -/* Added for cacao */ -int GC_signum1() -{ - return SIG_SUSPEND; -} - -int GC_signum2() -{ - return SIG_THR_RESTART; -} -/* cacao END */ - #endif diff --git a/src/mm/boehm.c b/src/mm/boehm.c deleted file mode 100644 index 411cb6c70..000000000 --- a/src/mm/boehm.c +++ /dev/null @@ -1,274 +0,0 @@ -/* src/mm/boehm.c - interface for boehm gc - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#if defined(ENABLE_THREADS) && defined(__LINUX__) -#define GC_LINUX_THREADS -#endif -#if defined(ENABLE_THREADS) && defined(__IRIX__) -#define GC_IRIX_THREADS -#endif -#if defined(ENABLE_THREADS) && defined(__DARWIN__) -#define GC_DARWIN_THREADS -#endif - -#include "boehm-gc/include/gc.h" -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "toolbox/logging.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/finalizer.h" -#include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/rt-timing.h" - - -/* global variables ***********************************************************/ - -static bool in_gc_out_of_memory = false; /* is GC out of memory? */ - - -/* prototype static functions *************************************************/ - -static void gc_ignore_warnings(char *msg, GC_word arg); - - -/* gc_init ********************************************************************* - - Initializes the boehm garbage collector. - -*******************************************************************************/ - -void gc_init(size_t heapmaxsize, size_t heapstartsize) -{ - size_t heapcurrentsize; - - TRACESUBSYSTEMINITIALIZATION("gc_init"); - - /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */ - - GC_java_finalization = 1; - - /* Ignore pointers that do not point to the start of an object. */ - - GC_all_interior_pointers = 0; - - /* suppress warnings */ - - GC_set_warn_proc(gc_ignore_warnings); - - /* install a GC notifier */ - - GC_finalize_on_demand = 1; - GC_finalizer_notifier = finalizer_notify; - - /* define OOM function */ - - GC_oom_fn = gc_out_of_memory; - - GC_INIT(); - - /* set the maximal heap size */ - - GC_set_max_heap_size(heapmaxsize); - - /* set the initial heap size */ - - heapcurrentsize = GC_get_heap_size(); - - if (heapstartsize > heapcurrentsize) - GC_expand_hp(heapstartsize - heapcurrentsize); -} - - -static void gc_ignore_warnings(char *msg, GC_word arg) -{ -} - - -void *heap_alloc_uncollectable(size_t size) -{ - void *p; - - p = GC_MALLOC_UNCOLLECTABLE(size); - - /* clear allocated memory region */ - - MSET(p, 0, uint8_t, size); - - return p; -} - - -/* heap_alloc ****************************************************************** - - Allocates memory on the Java heap. - -*******************************************************************************/ - -void *heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect) -{ - void *p; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_end; -#endif - - RT_TIMING_GET_TIME(time_start); - - /* We can't use a bool here for references, as it's passed as a - bitmask in builtin_new. Thus we check for != 0. */ - - if (references != 0) - p = GC_MALLOC(size); - else - p = GC_MALLOC_ATOMIC(size); - - if (p == NULL) - return NULL; - - if (finalizer != NULL) - GC_REGISTER_FINALIZER_NO_ORDER(p, finalizer_run, 0, 0, 0); - - /* clear allocated memory region */ - - MSET(p, 0, uint8_t, size); - - RT_TIMING_GET_TIME(time_end); - RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC); - - return p; -} - - -void heap_free(void *p) -{ - GC_FREE(p); -} - -void gc_call(void) -{ - if (opt_verbosegc) - dolog("Garbage Collection: previous/now = %d / %d ", - 0, 0); - - GC_gcollect(); -} - - -int64_t gc_get_heap_size(void) -{ - return GC_get_heap_size(); -} - - -int64_t gc_get_free_bytes(void) -{ - return GC_get_free_bytes(); -} - - -/* gc_get_total_bytes ********************************************************** - - Returns the number of total bytes currently used on the Java heap. - -*******************************************************************************/ - -int64_t gc_get_total_bytes(void) -{ - return GC_get_total_bytes(); -} - - -int64_t gc_get_max_heap_size(void) -{ - return GC_get_max_heap_size(); -} - - -void gc_invoke_finalizers(void) -{ - GC_invoke_finalizers(); -} - - -void gc_finalize_all(void) -{ - GC_finalize_all(); -} - - -/* gc_out_of_memory ************************************************************ - - This function is called when boehm detects that it is OOM. - -*******************************************************************************/ - -void *gc_out_of_memory(size_t bytes_requested) -{ - /* if this happens, we are REALLY out of memory */ - - if (in_gc_out_of_memory) { - /* this is all we can do... */ - vm_abort("gc_out_of_memory: out of memory"); - } - - in_gc_out_of_memory = true; - - /* try to release some memory */ - - gc_call(); - - /* now instantiate the exception */ - - exceptions_throw_outofmemoryerror(); - - in_gc_out_of_memory = false; - - return NULL; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/mm/cacao-gc/final.c b/src/mm/cacao-gc/final.c index fb0d77342..b895797e4 100644 --- a/src/mm/cacao-gc/final.c +++ b/src/mm/cacao-gc/final.c @@ -1,9 +1,7 @@ /* mm/cacao-gc/final.c - GC module for finalization and weak references - Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. diff --git a/src/mm/cacao-gc/final.h b/src/mm/cacao-gc/final.h index 8987073fe..e09309f84 100644 --- a/src/mm/cacao-gc/final.h +++ b/src/mm/cacao-gc/final.h @@ -1,9 +1,7 @@ /* mm/cacao-gc/final.h - GC header for finalization and weak references - Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -28,10 +26,11 @@ #ifndef _FINAL_H #define _FINAL_H +#include "config.h" #include "vm/types.h" #include "toolbox/list.h" -#include "vmcore/method.h" +#include "vm/method.h" /* Global Variables ***********************************************************/ diff --git a/src/mm/cacao-gc/gc.c b/src/mm/cacao-gc/gc.c index 1f8f5db41..4362d85f5 100644 --- a/src/mm/cacao-gc/gc.c +++ b/src/mm/cacao-gc/gc.c @@ -31,7 +31,7 @@ #include "vm/types.h" #include "threads/lock-common.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "compact.h" #include "copy.h" @@ -43,9 +43,10 @@ #include "rootset.h" #include "mm/memory.h" #include "toolbox/logging.h" + #include "vm/finalizer.h" -#include "vm/vm.h" -#include "vmcore/rt-timing.h" +#include "vm/rt-timing.h" +#include "vm/vm.hpp" /* Global Variables ***********************************************************/ diff --git a/src/mm/cacao-gc/gc.h b/src/mm/cacao-gc/gc.h index 31060381d..d4a300946 100644 --- a/src/mm/cacao-gc/gc.h +++ b/src/mm/cacao-gc/gc.h @@ -35,10 +35,10 @@ #include "config.h" #include "vm/types.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "toolbox/list.h" -#include "vm/jit/replace.h" +#include "vm/jit/replace.hpp" /* Configuration Switches *****************************************************/ @@ -54,7 +54,7 @@ #if !defined(NDEBUG) && defined(GC_DEBUGGING) # include -# include "vmcore/options.h" +# include "vm/options.h" # define GC_LOG(code) if (opt_verbosegc) { code; } # define GC_ASSERT(assertion) assert(assertion) #else diff --git a/src/mm/cacao-gc/heap.c b/src/mm/cacao-gc/heap.c index 425b0dfc3..f3630c7a3 100644 --- a/src/mm/cacao-gc/heap.c +++ b/src/mm/cacao-gc/heap.c @@ -1,9 +1,7 @@ /* mm/cacao-gc/heap.c - GC module for heap management - Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -39,11 +37,12 @@ #include "native/include/java_lang_String.h" #include "native/llni.h" #include "toolbox/logging.h" + #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" -#include "vmcore/options.h" -#include "vmcore/rt-timing.h" +#include "vm/options.h" +#include "vm/rt-timing.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" /* Global Variables ***********************************************************/ diff --git a/src/mm/cacao-gc/mark.c b/src/mm/cacao-gc/mark.c index c2c8a5c9b..1a64e8626 100644 --- a/src/mm/cacao-gc/mark.c +++ b/src/mm/cacao-gc/mark.c @@ -32,9 +32,10 @@ #include "rootset.h" #include "mm/memory.h" #include "toolbox/logging.h" + #include "vm/global.h" -#include "vm/vm.h" -#include "vmcore/linker.h" +#include "vm/linker.h" +#include "vm/vm.hpp" /* Helper Macros **************************************************************/ diff --git a/src/mm/cacao-gc/rootset.c b/src/mm/cacao-gc/rootset.c index 89ac2c201..7761fa808 100644 --- a/src/mm/cacao-gc/rootset.c +++ b/src/mm/cacao-gc/rootset.c @@ -33,13 +33,13 @@ #include "mm/memory.h" #include "threads/threadlist.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "toolbox/logging.h" #include "vm/global.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" rootset_t *rootset_create(void) diff --git a/src/mm/cacao-gc/rootset.h b/src/mm/cacao-gc/rootset.h index e61315f55..9267d7fdb 100644 --- a/src/mm/cacao-gc/rootset.h +++ b/src/mm/cacao-gc/rootset.h @@ -31,10 +31,11 @@ typedef struct rootset_t rootset_t; #include "config.h" #include "vm/types.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/jit/replace.h" -#include "vmcore/method.h" +#include "vm/method.h" + +#include "vm/jit/replace.hpp" /* Structures *****************************************************************/ diff --git a/src/mm/codememory.c b/src/mm/codememory.c index 7d2fd89c8..b56179221 100644 --- a/src/mm/codememory.c +++ b/src/mm/codememory.c @@ -29,33 +29,31 @@ #include #include /* REMOVEME */ -#include "threads/lock-common.h" -#include "threads/thread.h" +#include "threads/mutex.hpp" +#include "threads/thread.hpp" #include "mm/codememory.h" #include "mm/memory.h" -#include "vmcore/options.h" +#include "vm/global.h" +#include "vm/options.h" +#include "vm/os.hpp" #if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" +# include "vm/statistics.h" #endif -#include "vmcore/system.h" - -#include "vm/global.h" - /* global code memory variables ***********************************************/ #define DEFAULT_CODE_MEMORY_SIZE 128 * 1024 /* defaulting to 128kB */ #if defined(ENABLE_THREADS) -static java_object_t *lock_code_memory = NULL; +static Mutex *code_memory_mutex = NULL; #endif -static void *code_memory = NULL; -static int code_memory_size = 0; -static int pagesize = 0; +static void *code_memory = NULL; +static int code_memory_size = 0; +static int pagesize = 0; /* codememory_init ************************************************************* @@ -69,16 +67,14 @@ void codememory_init(void) TRACESUBSYSTEMINITIALIZATION("codememory_init"); #if defined(ENABLE_THREADS) - /* create lock for code memory */ - - lock_code_memory = NEW(java_object_t); + /* create mutex for code memory */ - lock_init_object_lock(lock_code_memory); + code_memory_mutex = Mutex_new(); #endif /* Get the pagesize of this architecture. */ - pagesize = system_getpagesize(); + pagesize = os_getpagesize(); } @@ -93,7 +89,7 @@ void *codememory_get(size_t size) { void *p; - LOCK_MONITOR_ENTER(lock_code_memory); + Mutex_lock(code_memory_mutex); size = MEMORY_ALIGN(size, ALIGNSIZE); @@ -124,9 +120,9 @@ void *codememory_get(size_t size) /* allocate the memory */ - p = system_mmap_anonymous(NULL, code_memory_size, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE); + p = os_mmap_anonymous(NULL, code_memory_size, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_PRIVATE); /* set global code memory pointer */ @@ -140,7 +136,7 @@ void *codememory_get(size_t size) code_memory = (void *) ((ptrint) code_memory + size); code_memory_size -= size; - LOCK_MONITOR_EXIT(lock_code_memory); + Mutex_unlock(code_memory_mutex); return p; } diff --git a/src/mm/codememory.h b/src/mm/codememory.h index c9dd38393..3fe3a18cb 100644 --- a/src/mm/codememory.h +++ b/src/mm/codememory.h @@ -29,6 +29,11 @@ #include "config.h" #include + +#ifdef __cplusplus +extern "C" { +#endif + #include @@ -45,6 +50,10 @@ void codememory_init(void); void *codememory_get(size_t size); void codememory_release(void *p, size_t size); +#ifdef __cplusplus +} +#endif + #endif /* _CODEMEMORY_H */ diff --git a/src/mm/dumpmemory.c b/src/mm/dumpmemory.c deleted file mode 100644 index 0dc191515..000000000 --- a/src/mm/dumpmemory.c +++ /dev/null @@ -1,482 +0,0 @@ -/* src/mm/dumpmemory.c - dump memory management - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "mm/dumpmemory.h" -#include "mm/memory.h" - -#include "threads/thread.h" - -#include "vmcore/options.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#include "vmcore/system.h" - -#include "vm/vm.h" - - -/******************************************************************************* - - This structure is used for dump memory allocation if cacao - runs without threads. - -*******************************************************************************/ - -#if !defined(ENABLE_THREADS) -static dumpinfo_t _no_threads_dumpinfo; -#endif - -#if defined(ENABLE_THREADS) -#define DUMPINFO &((threadobject *) THREADOBJECT)->dumpinfo -#else -#define DUMPINFO &_no_threads_dumpinfo -#endif - - -/* dump_check_canaries ********************************************************* - - Check canaries in dump memory. - - IN: - di...........dumpinfo_t * of the dump area to check - bottomsize...dump size down to which the dump area should be checked - (specify 0 to check the whole dump area) - - ERROR HANDLING: - If any canary has been changed, this function aborts the VM with - an error message. - -*******************************************************************************/ - -#if defined(ENABLE_MEMCHECK) -static void dump_check_canaries(dumpinfo_t *di, s4 bottomsize) -{ - dump_allocation_t *da; - uint8_t *pm; - int i, j; - - /* iterate over all dump memory allocations above bottomsize */ - - da = di->allocations; - - while (da && da->used >= bottomsize) { - /* check canaries */ - - pm = ((uint8_t *) da->mem) - MEMORY_CANARY_SIZE; - - for (i = 0; i < MEMORY_CANARY_SIZE; ++i) { - if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) { - fprintf(stderr, "canary bytes:"); - - for (j = 0; j < MEMORY_CANARY_SIZE; ++j) - fprintf(stderr, " %02x", pm[j]); - - fprintf(stderr,"\n"); - - vm_abort("error: dump memory bottom canary killed: " - "%p (%d bytes allocated at %p)\n", - pm + i, da->size, da->mem); - } - } - - pm = ((uint8_t *) da->mem) + da->size; - - for (i = 0; i < MEMORY_CANARY_SIZE; ++i) { - if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) { - fprintf(stderr, "canary bytes:"); - - for (j = 0; j < MEMORY_CANARY_SIZE; ++j) - fprintf(stderr, " %02x", pm[j]); - - fprintf(stderr, "\n"); - - vm_abort("error: dump memory top canary killed: " - "%p (%d bytes allocated at %p)\n", - pm + i, da->size, da->mem); - } - } - - da = da->next; - } -} -#endif /* defined(ENABLE_MEMCHECK) */ - - -/* dumpmemory_alloc ************************************************************ - - ATTENTION: This function must only be called from dumpmemory_get! - - Allocate a new dump memory block. - - IN: - di ..... dumpinfo_t of the current thread - size ... required memory size - -*******************************************************************************/ - -void dumpmemory_alloc(dumpinfo_t *di, size_t size) -{ - dumpblock_t *db; - size_t newblocksize; - - /* Allocate a new dumpblock_t structure. */ - - db = memory_checked_alloc(sizeof(dumpblock_t)); - - /* If requested size is greater than the default, make the new - dump block as big as the size requested. Else use the default - size. */ - - if (size > DUMPBLOCKSIZE) { - newblocksize = size; - } - else { - newblocksize = DUMPBLOCKSIZE; - } - - /* allocate dumpblock memory */ - - db->dumpmem = memory_checked_alloc(newblocksize); - - db->size = newblocksize; - db->prev = di->block; - di->block = db; - - /* Used dump size is previously allocated dump size, because the - remaining free memory of the previous dump block cannot be - used. */ - - di->used = di->allocated; - - /* Increase the allocated dump size by the size of the new dump - block. */ - - di->allocated += newblocksize; - -#if defined(ENABLE_STATISTICS) - /* The amount of globally allocated dump memory (thread save). */ - - if (opt_stat) - globalallocateddumpsize += newblocksize; -#endif -} - - -/* dumpmemory_get ************************************************************** - - Allocate memory in the dump area. - - IN: - size.........size of block to allocate, in bytes - may be zero, in which case NULL is returned - - RETURN VALUE: - pointer to allocated memory, or - NULL iff `size` was zero - - ERROR HANDLING: - XXX This function uses `memory_checked_alloc`, which *exits* if - no memory could be allocated. - - THREADS: - dumpmemory_get is thread safe. Each thread has its own dump - memory area. - - This function is a fast allocator suitable for scratch memory that - can be collectively freed when the current activity (eg. compiling) - is done. - - You cannot selectively free dump memory. Before you start - allocating it, you remember the current size returned by - `dumpmemory_marker`. Later, when you no longer need the memory, - call `dumpmemory_release` with the remembered size and all dump - memory allocated since the call to `dumpmemory_marker` will be - freed. - -*******************************************************************************/ - -void *dumpmemory_get(size_t size) -{ -#if defined(DISABLE_DUMP) - - /* use malloc memory for dump memory (for debugging only!) */ - - return mem_alloc(size); - -#else /* !defined(DISABLE_DUMP) */ - - void *p; - dumpinfo_t *di; -#if defined(ENABLE_MEMCHECK) - s4 origsize = size; /* needed for the canary system */ -#endif - - di = DUMPINFO; - - if (size == 0) - return NULL; - -#if defined(ENABLE_MEMCHECK) - size += 2 * MEMORY_CANARY_SIZE; -#endif - - size = MEMORY_ALIGN(size, ALIGNSIZE); - - /* Check if we have enough memory in the current memory block. */ - - if (di->used + size > di->allocated) { - /* If not, allocate a new one. */ - - dumpmemory_alloc(di, size); - } - - /* current dump block base address + the size of the current dump - block - the size of the unused memory = new start address */ - - p = ((uint8_t *) di->block->dumpmem) + di->block->size - - (di->allocated - di->used); - -#if defined(ENABLE_MEMCHECK) - { - dump_allocation_t *da = NEW(dump_allocation_t); - uint8_t *pm; - int i; - - /* add the allocation to our linked list of allocations */ - - da->next = di->allocations; - da->mem = ((uint8_t *) p) + MEMORY_CANARY_SIZE; - da->size = origsize; - da->used = di->used; - - di->allocations = da; - - /* write the canaries */ - - pm = (uint8_t *) p; - - for (i = 0; i < MEMORY_CANARY_SIZE; ++i) - pm[i] = i + MEMORY_CANARY_FIRST_BYTE; - - pm = ((uint8_t *) da->mem) + da->size; - - for (i = 0; i < MEMORY_CANARY_SIZE; ++i) - pm[i] = i + MEMORY_CANARY_FIRST_BYTE; - - /* make m point after the bottom canary */ - - p = ((uint8_t *) p) + MEMORY_CANARY_SIZE; - - /* clear the memory */ - - (void) system_memset(p, MEMORY_CLEAR_BYTE, da->size); - } -#endif /* defined(ENABLE_MEMCHECK) */ - - /* Increase used dump size by the allocated memory size. */ - - di->used += size; - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - if (di->used > maxdumpsize) - maxdumpsize = di->used; -#endif - - return p; - -#endif /* defined(DISABLE_DUMP) */ -} - - -/* dumpmemory_realloc ********************************************************** - - Stupid realloc implementation for dump memory. Avoid, if possible. - -*******************************************************************************/ - -void *dumpmemory_realloc(void *src, s4 len1, s4 len2) -{ -#if defined(DISABLE_DUMP) - /* use malloc memory for dump memory (for debugging only!) */ - - return mem_realloc(src, len1, len2); -#else - void *dst; - - dst = dumpmemory_get(len2); - - (void) system_memcpy(dst, src, len1); - -#if defined(ENABLE_MEMCHECK) - /* destroy the source */ - - (void) system_memset(src, MEMORY_CLEAR_BYTE, len1); -#endif - - return dst; -#endif -} - - -/* dumpmemory_release ********************************************************** - - Release dump memory above the given size. - - IN: - size........All dump memory above this mark will be freed. Usually - `size` will be the return value of a `dumpmemory_marker` - call made earlier. - - ERROR HANDLING: - XXX If the given size is invalid, this function *exits* with an - error message. - - See `dump_alloc`. - -*******************************************************************************/ - -void dumpmemory_release(s4 size) -{ -#if defined(DISABLE_DUMP) - - /* use malloc memory for dump memory (for debugging only!) */ - - /* do nothing */ - -#else /* !defined(DISABLE_DUMP) */ - - dumpinfo_t *di; - - di = DUMPINFO; - - if ((size < 0) || (size > di->used)) - vm_abort("dump_release: Illegal dump release size: %d", size); - -#if defined(ENABLE_MEMCHECK) - { - dump_allocation_t *da, *next; - - /* check canaries */ - - dump_check_canaries(di, size); - - /* iterate over all dump memory allocations about to be released */ - - da = di->allocations; - - while ((da != NULL) && (da->used >= size)) { - next = da->next; - - /* invalidate the freed memory */ - - (void) system_memset(da->mem, MEMORY_CLEAR_BYTE, da->size); - - FREE(da, dump_allocation_t); - - da = next; - } - di->allocations = da; - } -#endif /* defined(ENABLE_MEMCHECK) */ - - /* Reset the used dump size to the size specified. */ - - di->used = size; - - while ((di->block != NULL) && di->allocated - di->block->size >= di->used) { - dumpblock_t *tmp = di->block; - - di->allocated -= tmp->size; - di->block = tmp->prev; - -#if defined(ENABLE_STATISTICS) - /* the amount of globally allocated dump memory (thread save) */ - - if (opt_stat) - globalallocateddumpsize -= tmp->size; -#endif - - /* Release the dump memory and the dumpinfo structure. */ - - system_free(tmp->dumpmem); - system_free(tmp); - } - -#endif /* defined(DISABLE_DUMP) */ -} - - -/* dumpmemory_marker *********************************************************** - - Returns a marker of the dump memory area. This marker is actually - the used size of the dump memory area. - - RETURN VALUE: - marker of the current dump memory status - -*******************************************************************************/ - -int32_t dumpmemory_marker(void) -{ -#if defined(DISABLE_DUMP) - /* use malloc memory for dump memory (for debugging only!) */ - - return 0; - -#else /* !defined(DISABLE_DUMP) */ - - dumpinfo_t *di; - - di = DUMPINFO; - - if (di == NULL) - return 0; - - return di->used; - -#endif /* defined(DISABLE_DUMP) */ -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/mm/dumpmemory.cpp b/src/mm/dumpmemory.cpp new file mode 100644 index 000000000..b63056330 --- /dev/null +++ b/src/mm/dumpmemory.cpp @@ -0,0 +1,343 @@ +/* src/mm/dumpmemory.cpp - dump memory management + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "mm/dumpmemory.hpp" +#include "mm/memory.h" + +#include "threads/thread.hpp" + +#include "vm/options.h" +#include "vm/os.hpp" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/vm.hpp" + + +/******************************************************************************* + + This structure is used for dump memory allocation if cacao + runs without threads. + +*******************************************************************************/ + +#if !defined(ENABLE_THREADS) +static dumpinfo_t _no_threads_dumpinfo; +#endif + + +/* dump_check_canaries ********************************************************* + + Check canaries in dump memory. + + IN: + di...........dumpinfo_t * of the dump area to check + bottomsize...dump size down to which the dump area should be checked + (specify 0 to check the whole dump area) + + ERROR HANDLING: + If any canary has been changed, this function aborts the VM with + an error message. + +*******************************************************************************/ + +#if defined(ENABLE_MEMCHECK) +static void dump_check_canaries(dumpinfo_t *di, s4 bottomsize) +{ + dump_allocation_t *da; + uint8_t *pm; + int i, j; + + /* iterate over all dump memory allocations above bottomsize */ + + da = di->allocations; + + while (da && da->used >= bottomsize) { + /* check canaries */ + + pm = ((uint8_t *) da->mem) - MEMORY_CANARY_SIZE; + + for (i = 0; i < MEMORY_CANARY_SIZE; ++i) { + if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) { + fprintf(stderr, "canary bytes:"); + + for (j = 0; j < MEMORY_CANARY_SIZE; ++j) + fprintf(stderr, " %02x", pm[j]); + + fprintf(stderr,"\n"); + + vm_abort("error: dump memory bottom canary killed: " + "%p (%d bytes allocated at %p)\n", + pm + i, da->size, da->mem); + } + } + + pm = ((uint8_t *) da->mem) + da->size; + + for (i = 0; i < MEMORY_CANARY_SIZE; ++i) { + if (pm[i] != i + MEMORY_CANARY_FIRST_BYTE) { + fprintf(stderr, "canary bytes:"); + + for (j = 0; j < MEMORY_CANARY_SIZE; ++j) + fprintf(stderr, " %02x", pm[j]); + + fprintf(stderr, "\n"); + + vm_abort("error: dump memory top canary killed: " + "%p (%d bytes allocated at %p)\n", + pm + i, da->size, da->mem); + } + } + + da = da->next; + } +} +#endif /* defined(ENABLE_MEMCHECK) */ + + +/** + * Allocate a new thread-local dump memory structure. + */ +DumpMemory::DumpMemory() : _size(0), _used(0) +{ +} + + +/** + * Stupid realloc implementation for dump memory. Avoid, if possible. + */ +void* DumpMemory::reallocate(void* src, size_t len1, size_t len2) +{ + void* dst = allocate(len2); + + (void) os::memcpy(dst, src, len1); + +#if defined(ENABLE_MEMCHECK) + // Destroy the source. + (void) os::memset(src, MEMORY_CLEAR_BYTE, len1); +#endif + + return dst; +} + + +/** + * Add the given dump area to the area list. + * + * @param dm Pointer to dump area. + */ +void DumpMemory::add_area(DumpMemoryArea* dma) +{ + _areas.push_back(dma); + + // Increase the size count of the dump memory. + _size += dma->get_size(); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + if (_size > (size_t) maxdumpsize) + maxdumpsize = _size; + } +#endif +} + + +/** + * Remove the given dump area from the area list. + * + * @param dm Pointer to dump area. + */ +void DumpMemory::remove_area(DumpMemoryArea* dma) +{ + // Sanity check. + assert(_areas.back() == dma); + + // Remove the last area from the list. The check above guarantees + // we are removing the correct area. + _areas.pop_back(); + + // Decrease the size and used count. + _size -= dma->get_size(); + _used -= dma->get_used(); +} + + +/** + * Allocate a new dump memory area. + * + * @ param size Required memory size. + */ +DumpMemoryArea::DumpMemoryArea(size_t size) : _size(0), _used(0) +{ + // Get the DumpMemory object of the current thread. + DumpMemory* dm = DumpMemory::get_current(); + + // Add this area to the areas list. + dm->add_area(this); +} + + +/** + * Release all dump memory blocks in the current dump area. + */ +DumpMemoryArea::~DumpMemoryArea() +{ + // Get the DumpMemory object of the current thread. + DumpMemory* dm = DumpMemory::get_current(); + +#if defined(ENABLE_MEMCHECK) + { + dump_allocation_t *da, *next; + + /* check canaries */ + + dump_check_canaries(di, size); + + /* iterate over all dump memory allocations about to be released */ + + da = di->allocations; + + while ((da != NULL) && (da->used >= size)) { + next = da->next; + + /* invalidate the freed memory */ + + (void) os_memset(da->mem, MEMORY_CLEAR_BYTE, da->size); + + FREE(da, dump_allocation_t); + + da = next; + } + di->allocations = da; + } +#endif /* defined(ENABLE_MEMCHECK) */ + + + // Free all memory blocks. + for (std::vector::iterator it = _blocks.begin(); it != _blocks.end(); it++) { + // Call the destructor of the current block. + delete *it; + } + + // Remove this area for the area list. + dm->remove_area(this); +} + + +/** + * Allocate a dump memory block for the current dump memory area. + * + * @param size Required memory size. + * + * @return Pointer to the newly allocated block. + */ +DumpMemoryBlock* DumpMemoryArea::allocate_new_block(size_t size) +{ + DumpMemoryBlock* dmb = new DumpMemoryBlock(size); + _blocks.push_back(dmb); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + DumpMemory* dm = DumpMemory::get_current(); + dm->add_size(dmb->get_size()); + + if (dm->get_size() > (size_t) maxdumpsize) + maxdumpsize = dm->get_size(); + } +#endif + + return dmb; +} + + +/** + * Allocate a memory block for the current dump memory block. + * + * @param size Required memory size. + */ +DumpMemoryBlock::DumpMemoryBlock(size_t size) : _size(0), _used(0), _block(0) +{ + // If requested size is greater than the default, make the new + // memory block as big as the requested size. Otherwise use the + // default size. + _size = (size > DEFAULT_SIZE) ? size : DEFAULT_SIZE; + + // Allocate a memory block. + _block = memory_checked_alloc(_size); + +#if defined(ENABLE_STATISTICS) + // The amount of globally allocated dump memory (thread safe). + if (opt_stat) + globalallocateddumpsize += _size; +#endif +} + + +/** + * Release the memory block for the dump memory block. + * + * @param size Required memory size. + */ +DumpMemoryBlock::~DumpMemoryBlock() +{ + // Release the memory block. + mem_free(_block, /* XXX */ 1); + +#if defined(ENABLE_STATISTICS) + // The amount of globally allocated dump memory (thread safe). + if (opt_stat) + globalallocateddumpsize -= _size; +#endif +} + + +// Legacy C interface. + +extern "C" { + void* DumpMemory_allocate(size_t size) { return DumpMemory::allocate(size); } + void* DumpMemory_reallocate(void* src, size_t len1, size_t len2) { return DumpMemory::reallocate(src, len1, len2); } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/mm/dumpmemory.h b/src/mm/dumpmemory.h deleted file mode 100644 index f51977799..000000000 --- a/src/mm/dumpmemory.h +++ /dev/null @@ -1,118 +0,0 @@ -/* src/mm/dumpmemory.h - dump memory management - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _DUMPMEMORY_H -#define _DUMPMEMORY_H - -/* forward typedefs ***********************************************************/ - -typedef struct dumpblock_t dumpblock_t; -typedef struct dumpinfo_t dumpinfo_t; - -#include "config.h" - -#include -#include - - -/* ATTENTION: We need to define dumpblock_t and dumpinfo_t before - internal includes, as we need dumpinfo_t as nested structure in - threadobject. */ - -/* dumpblock ******************************************************************/ - -#define DUMPBLOCKSIZE 2 << 13 /* 2 * 8192 bytes */ -#define ALIGNSIZE 8 - -struct dumpblock_t { - dumpblock_t *prev; - void *dumpmem; - int32_t size; -}; - - -/* dump_allocation ************************************************************* - - This struct is used to record dump memory allocations for ENABLE_MEMCHECK. - -*******************************************************************************/ - -#if defined(ENABLE_MEMCHECK) -typedef struct dump_allocation_t dump_allocation_t; - -struct dump_allocation_t { - dump_allocation_t *next; - void *mem; - int32_t used; - int32_t size; -}; -#endif - - -/* dumpinfo *******************************************************************/ - -struct dumpinfo_t { - dumpblock_t *block; /* the current top-most block */ - int32_t allocated; /* allocated bytes in this area */ - int32_t used; /* used bytes in this dump area */ -#if defined(ENABLE_MEMCHECK) - dump_allocation_t *allocations; /* list of allocations in this area */ -#endif -}; - - -/* convenience macros *********************************************************/ - -#define DMARKER dumpmarker = dumpmemory_marker() -#define DRELEASE dumpmemory_release(dumpmarker) - -#define DNEW(type) ((type *) dumpmemory_get(sizeof(type))) -#define DMNEW(type,num) ((type *) dumpmemory_get(sizeof(type) * (num))) -#define DMREALLOC(ptr,type,num1,num2) dumpmemory_realloc((ptr), sizeof(type) * (num1), \ - sizeof(type) * (num2)) - -/* function prototypes ********************************************************/ - -void *dumpmemory_get(size_t size); -void *dumpmemory_realloc(void *src, int32_t len1, int32_t len2); -int32_t dumpmemory_marker(void); -void dumpmemory_release(int32_t size); - -#endif /* _DUMPMEMORY_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/mm/dumpmemory.hpp b/src/mm/dumpmemory.hpp new file mode 100644 index 000000000..1621eaba9 --- /dev/null +++ b/src/mm/dumpmemory.hpp @@ -0,0 +1,395 @@ +/* src/mm/dumpmemory.hpp - dump memory management + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _DUMPMEMORY_HPP +#define _DUMPMEMORY_HPP + +#include "config.h" + +#include +#include +#include + +#ifdef __cplusplus + +#include +#include +#include +#include // REMOVEME + + +// Forward declaration. +class DumpMemoryArea; +class DumpMemoryBlock; + + +/** + * Thread-local dump memory structure. + */ +class DumpMemory { +private: + size_t _size; ///< Size of the dump areas in this dump memory. + size_t _used; ///< Used memory in this dump memory. + std::list _areas; ///< Pointer to the current dump area. + +#if 0 +#if defined(ENABLE_MEMCHECK) + dump_allocation_t *allocations; /* list of allocations in this area */ +#endif +#endif + +public: + DumpMemory(); + ~DumpMemory(); + + static inline DumpMemory* get_current(); + static inline void* allocate(size_t size); + + inline void add_size(size_t size) { _size += size; } + + inline size_t get_size() const { return _size; } + inline size_t get_used() const { return _used; } + + inline DumpMemoryArea* get_current_area() const; + + static void* reallocate(void* src, size_t len1, size_t len2); + + void add_area(DumpMemoryArea* dma); + void remove_area(DumpMemoryArea* dma); +}; + + +/** + * Dump memory area. + */ +class DumpMemoryArea { +private: + size_t _size; ///< Size of the current memory block. + size_t _used; ///< Used memory in the current memory block. + std::vector _blocks; ///< List of memory blocks in this area. + +public: + DumpMemoryArea(size_t size = 0); + ~DumpMemoryArea(); + + inline size_t get_size() const { return _size; } + inline size_t get_used() const { return _used; } + + // Inline functions. + inline void* allocate(size_t size); + inline DumpMemoryBlock* get_current_block() const; + + DumpMemoryBlock* allocate_new_block(size_t size); +}; + + +/** + * Dump memory block. + */ +class DumpMemoryBlock { +private: + static const size_t DEFAULT_SIZE = 2 << 13; // 2 * 8192 bytes + + size_t _size; ///< Size of the current memory block. + size_t _used; ///< Used memory in the current memory block. + void* _block; ///< List of memory blocks in this area. + +public: + DumpMemoryBlock(size_t size = 0); + ~DumpMemoryBlock(); + + inline size_t get_size() const { return _size; } + inline size_t get_used() const { return _used; } + inline size_t get_free() const { return _size - _used; } + + // Inline functions. + inline void* allocate(size_t size); +}; + + +/** + * Allocator for the dump memory. + */ +template class DumpMemoryAllocator { +public: + // Type definitions. + typedef T value_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + // Rebind allocator to type U. + template struct rebind { + typedef DumpMemoryAllocator other; + }; + + /* constructors and destructor + * - nothing to do because the allocator has no state + */ + DumpMemoryAllocator() throw() { + } + + DumpMemoryAllocator(const DumpMemoryAllocator&) throw() { + } + + template DumpMemoryAllocator(const DumpMemoryAllocator&) throw() { + } + + ~DumpMemoryAllocator() throw() { + } + + pointer allocate(size_type n, void* = 0) { + printf("allocate: n=%d * %d\n", n, sizeof(T)); + return static_cast(DumpMemory::allocate(n * sizeof(T))); + } + + // Initialize elements of allocated storage p with value value. + void construct(pointer p, const T& value) { + printf("construct: p=%p, value=%p\n", p, value); + // Initialize memory with placement new. + new ((void*) p) T(value); + } + + // Destroy elements of initialized storage p. + void destroy(pointer p) { + printf("destroy: p=%p\n", p); + // Destroy objects by calling their destructor. + p->~T(); + } + + void deallocate(pointer p, size_type n) { + printf("deallocate: p=%p, n=%d\n", p, n); + // We don't need to deallocate on dump memory. + } +}; + + +/* dump_allocation ************************************************************* + + This struct is used to record dump memory allocations for ENABLE_MEMCHECK. + +*******************************************************************************/ + +#if 0 +#if defined(ENABLE_MEMCHECK) +typedef struct dump_allocation_t dump_allocation_t; + +struct dump_allocation_t { + dump_allocation_t *next; + void *mem; + int32_t used; + int32_t size; +}; +#endif +#endif + + +// Includes. +#include "mm/memory.h" + +#include "threads/thread.hpp" + +#include "vm/options.h" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + + +// Inline functions. + +inline DumpMemory* DumpMemory::get_current() +{ + // Get the DumpMemory object of the current thread. + threadobject* t = thread_get_current(); + DumpMemory* dm = t->_dumpmemory; + return dm; +} + +inline DumpMemoryArea* DumpMemory::get_current_area() const +{ + return _areas.back(); +} + +inline void* DumpMemory::allocate(size_t size) +{ + DumpMemory* dm = get_current(); + DumpMemoryArea* dma = dm->get_current_area(); + + size_t alignedsize = size; + +#if defined(ENABLE_MEMCHECK) + alignedsize += 2 * MEMORY_CANARY_SIZE; +#endif + + // Align the allocation size. + alignedsize = MEMORY_ALIGN(alignedsize, ALIGNSIZE); + + void* p = dma->allocate(alignedsize); + + // Increase the used count of the dump memory. + dm->_used += alignedsize; + + return p; +} + +inline DumpMemoryBlock* DumpMemoryArea::get_current_block() const +{ + return _blocks.empty() ? NULL : _blocks.back(); +} + +inline void* DumpMemoryArea::allocate(size_t size) +{ + DumpMemoryBlock* dmb = get_current_block(); + + // Check if we have a memory block or have enough memory in the + // current memory block. + if (dmb == NULL || size > dmb->get_free()) { + // No, allocate a new one. + dmb = allocate_new_block(size); + + // Increase the size of the memory area. We use get_size() + // here because the default size is very likely to be bigger + // than size. + _size += dmb->get_size(); + } + + void* p = dmb->allocate(size); + + // Increase the used size of the memory area. + _used += size; + + return p; +} + +/** + * Allocate memory in the current dump memory area. + * + * This function is a fast allocator suitable for scratch memory that + * can be collectively freed when the current activity (eg. compiling) + * is done. + * + * You cannot selectively free dump memory. Before you start + * allocating it, you remember the current size returned by + * `dumpmemory_marker`. Later, when you no longer need the memory, + * call `dumpmemory_release` with the remembered size and all dump + * memory allocated since the call to `dumpmemory_marker` will be + * freed. + * + * @parm size Size of block to allocate in bytes. May be zero, in which case NULL is returned + * + * @return Pointer to allocated memory, or NULL iff size was zero. + */ +void* DumpMemoryBlock::allocate(size_t size) +{ +#if defined(ENABLE_MEMCHECK) + size_t origsize = size; /* needed for the canary system */ +#endif + + if (size == 0) + return NULL; + + // Sanity check. + assert(size <= (_size - _used)); + + // Calculate the memory address of the newly allocated memory. + void* p = (void*) (((uint8_t*) _block) + _used); + +#if defined(ENABLE_MEMCHECK) + { + dump_allocation_t *da = NEW(dump_allocation_t); + uint8_t *pm; + int i; + + /* add the allocation to our linked list of allocations */ + + da->next = di->allocations; + da->mem = ((uint8_t *) p) + MEMORY_CANARY_SIZE; + da->size = origsize; + da->used = di->used; + + di->allocations = da; + + /* write the canaries */ + + pm = (uint8_t *) p; + + for (i = 0; i < MEMORY_CANARY_SIZE; ++i) + pm[i] = i + MEMORY_CANARY_FIRST_BYTE; + + pm = ((uint8_t *) da->mem) + da->size; + + for (i = 0; i < MEMORY_CANARY_SIZE; ++i) + pm[i] = i + MEMORY_CANARY_FIRST_BYTE; + + /* make m point after the bottom canary */ + + p = ((uint8_t *) p) + MEMORY_CANARY_SIZE; + + /* clear the memory */ + + (void) os_memset(p, MEMORY_CLEAR_BYTE, da->size); + } +#endif /* defined(ENABLE_MEMCHECK) */ + + // Increase used memory block size by the allocated memory size. + _used += size; + + return p; +} + +#else + +// Legacy C interface. + +void* DumpMemory_allocate(size_t size); +void* DumpMemory_reallocate(void* src, size_t len1, size_t len2); + +#define DNEW(type) ((type*) DumpMemory_allocate(sizeof(type))) +#define DMNEW(type,num) ((type*) DumpMemory_allocate(sizeof(type) * (num))) +#define DMREALLOC(ptr,type,num1,num2) ((type*) DumpMemory_reallocate((ptr), sizeof(type) * (num1), sizeof(type) * (num2))) + +#endif + +#endif // _DUMPMEMORY_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/mm/gc-boehm.cpp b/src/mm/gc-boehm.cpp new file mode 100644 index 000000000..55a820f05 --- /dev/null +++ b/src/mm/gc-boehm.cpp @@ -0,0 +1,273 @@ +/* src/mm/gc-boehm.cpp - interface for boehm gc + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#if defined(ENABLE_THREADS) && defined(__LINUX__) +#define GC_LINUX_THREADS +#endif +#if defined(ENABLE_THREADS) && defined(__IRIX__) +#define GC_IRIX_THREADS +#endif +#if defined(ENABLE_THREADS) && defined(__DARWIN__) +#define GC_DARWIN_THREADS +#endif + +#include "boehm-gc/include/gc.h" +#include "mm/gc.hpp" +#include "mm/memory.h" + +#include "toolbox/logging.h" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/finalizer.h" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/rt-timing.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" + + +/* global variables ***********************************************************/ + +static bool in_gc_out_of_memory = false; /* is GC out of memory? */ + + +/* prototype static functions *************************************************/ + +static void gc_ignore_warnings(char *msg, GC_word arg); + + +/* gc_init ********************************************************************* + + Initializes the boehm garbage collector. + +*******************************************************************************/ + +void gc_init(size_t heapmaxsize, size_t heapstartsize) +{ + size_t heapcurrentsize; + + TRACESUBSYSTEMINITIALIZATION("gc_init"); + + /* just to be sure (should be set to 1 by JAVA_FINALIZATION macro) */ + + GC_java_finalization = 1; + + /* Ignore pointers that do not point to the start of an object. */ + + GC_all_interior_pointers = 0; + + /* suppress warnings */ + + GC_set_warn_proc(gc_ignore_warnings); + + /* install a GC notifier */ + + GC_finalize_on_demand = 1; + GC_finalizer_notifier = finalizer_notify; + + /* define OOM function */ + + GC_oom_fn = gc_out_of_memory; + + GC_INIT(); + + /* set the maximal heap size */ + + GC_set_max_heap_size(heapmaxsize); + + /* set the initial heap size */ + + heapcurrentsize = GC_get_heap_size(); + + if (heapstartsize > heapcurrentsize) + GC_expand_hp(heapstartsize - heapcurrentsize); +} + + +static void gc_ignore_warnings(char *msg, GC_word arg) +{ +} + + +void *heap_alloc_uncollectable(size_t size) +{ + void *p; + + p = GC_MALLOC_UNCOLLECTABLE(size); + + /* clear allocated memory region */ + + MSET(p, 0, uint8_t, size); + + return p; +} + + +/* heap_alloc ****************************************************************** + + Allocates memory on the Java heap. + +*******************************************************************************/ + +void *heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect) +{ + void *p; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +#endif + + RT_TIMING_GET_TIME(time_start); + + /* We can't use a bool here for references, as it's passed as a + bitmask in builtin_new. Thus we check for != 0. */ + + if (references != 0) + p = GC_MALLOC(size); + else + p = GC_MALLOC_ATOMIC(size); + + if (p == NULL) + return NULL; + + if (finalizer != NULL) + GC_REGISTER_FINALIZER_NO_ORDER(p, finalizer_run, 0, 0, 0); + + /* clear allocated memory region */ + + MSET(p, 0, uint8_t, size); + + RT_TIMING_GET_TIME(time_end); + RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_GC_ALLOC); + + return p; +} + + +void heap_free(void *p) +{ + GC_FREE(p); +} + +void gc_call(void) +{ + if (opt_verbosegc) + dolog("Garbage Collection: previous/now = %d / %d ", + 0, 0); + + GC_gcollect(); +} + + +int64_t gc_get_heap_size(void) +{ + return GC_get_heap_size(); +} + + +int64_t gc_get_free_bytes(void) +{ + return GC_get_free_bytes(); +} + + +/* gc_get_total_bytes ********************************************************** + + Returns the number of total bytes currently used on the Java heap. + +*******************************************************************************/ + +int64_t gc_get_total_bytes(void) +{ + return GC_get_total_bytes(); +} + + +int64_t gc_get_max_heap_size(void) +{ + return GC_get_max_heap_size(); +} + + +void gc_invoke_finalizers(void) +{ + GC_invoke_finalizers(); +} + + +void gc_finalize_all(void) +{ + GC_finalize_all(); +} + + +/* gc_out_of_memory ************************************************************ + + This function is called when boehm detects that it is OOM. + +*******************************************************************************/ + +void *gc_out_of_memory(size_t bytes_requested) +{ + /* if this happens, we are REALLY out of memory */ + + if (in_gc_out_of_memory) { + /* this is all we can do... */ + VM::get_current()->abort("gc_out_of_memory: out of memory"); + } + + in_gc_out_of_memory = true; + + /* try to release some memory */ + + gc_call(); + + /* now instantiate the exception */ + + exceptions_throw_outofmemoryerror(); + + in_gc_out_of_memory = false; + + return NULL; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/mm/gc-common.h b/src/mm/gc-common.h deleted file mode 100644 index 12454e86e..000000000 --- a/src/mm/gc-common.h +++ /dev/null @@ -1,106 +0,0 @@ -/* src/mm/gc-common.h - gc independant interface for heap managment - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _GC_COMMON_H -#define _GC_COMMON_H - -#include "config.h" - -#include - -#include "vm/global.h" - -#include "vmcore/method.h" - - -/* reference types ************************************************************/ - -enum { - GC_REFTYPE_THREADOBJECT, - GC_REFTYPE_CLASSLOADER, - GC_REFTYPE_JNI_GLOBALREF, - GC_REFTYPE_FINALIZER, - GC_REFTYPE_LOCALREF, - GC_REFTYPE_STACK, - GC_REFTYPE_CLASSREF, - GC_REFTYPE_LOCKRECORD -}; - - -/* function prototypes ********************************************************/ - -void gc_init(size_t heapmaxsize, size_t heapstartsize); - -void* heap_alloc_uncollectable(size_t size); -void* heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect); -void heap_free(void *p); - -#if defined(ENABLE_GC_CACAO) -void heap_init_objectheader(java_object_t *o, uint32_t size); -int32_t heap_get_hashcode(java_object_t *o); - -void gc_reference_register(java_object_t **ref, int32_t reftype); -void gc_reference_unregister(java_object_t **ref); - -void gc_weakreference_register(java_object_t **ref, int32_t reftype); -void gc_weakreference_unregister(java_object_t **ref); -#endif - -void gc_call(void); -int64_t gc_get_heap_size(void); -int64_t gc_get_free_bytes(void); -int64_t gc_get_total_bytes(void); -int64_t gc_get_max_heap_size(void); -void gc_invoke_finalizers(void); -void gc_finalize_all(void); -void* gc_out_of_memory(size_t bytes_requested); - - -/* inlined functions **********************************************************/ - -static inline int32_t heap_hashcode(java_object_t *obj) -{ -#if defined(ENABLE_GC_CACAO) - return heap_get_hashcode(obj); -#else - return (int32_t)(intptr_t) obj; -#endif -} - -#endif /* _GC_COMMON_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/mm/gc-none.cpp b/src/mm/gc-none.cpp new file mode 100644 index 000000000..d0a488d2a --- /dev/null +++ b/src/mm/gc-none.cpp @@ -0,0 +1,178 @@ +/* src/mm/gc-none.cpp - allocates memory through malloc (no GC) + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#if defined(HAVE_SYS_MMAN_H) +# include +#endif + +#include "vm/types.h" + +#include "boehm-gc/include/gc.h" + +#include "mm/gc.hpp" +#include "mm/memory.h" + +#include "toolbox/logging.h" + +#include "vm/jit/builtin.hpp" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" + + +/* global stuff ***************************************************************/ + +#define MMAP_HEAPADDRESS 0x10000000 /* try to map the heap to this addr. */ +#define ALIGNSIZE 8 + +static void *mmapptr = NULL; +static int mmapsize = 0; +static void *mmaptop = NULL; + + +void* heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect) +{ + void *m; + + mmapptr = (void *) MEMORY_ALIGN((ptrint) mmapptr, ALIGNSIZE); + + m = mmapptr; + mmapptr = (void *) ((ptrint) mmapptr + size); + + if (mmapptr > mmaptop) + vm_abort("heap_alloc: out of memory"); + + MSET(m, 0, u1, size); + + return m; +} + + +void* heap_alloc_uncollectable(size_t size) +{ + return heap_alloc(size, false, NULL, false); +} + + +void heap_free(void* p) +{ + /* nop */ +} + + + +void gc_init(size_t heapmaxsize, size_t heapstartsize) +{ + heapmaxsize = MEMORY_ALIGN(heapmaxsize, ALIGNSIZE); + +#if defined(HAVE_MMAP) + mmapptr = mmap((void *) MMAP_HEAPADDRESS, + (size_t) heapmaxsize, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | +# if defined(MAP_ANONYMOUS) + MAP_ANONYMOUS, +# elif defined(MAP_ANON) + MAP_ANON, +# else + 0, +# endif + -1, + (off_t) 0); + + if (mmapptr == MAP_FAILED) + vm_abort("gc_init: out of memory"); +#else + mmapptr = malloc(heapmaxsize); + + if (mmapptr == NULL) + vm_abort("gc_init: out of memory"); +#endif + + mmapsize = heapmaxsize; + mmaptop = (void *) ((ptrint) mmapptr + mmapsize); +} + + +void gc_call(void) +{ + log_text("GC call: nothing done..."); + /* nop */ +} + + +s8 gc_get_heap_size(void) +{ + return 0; +} + + +s8 gc_get_free_bytes(void) +{ + return 0; +} + + +s8 gc_get_total_bytes(void) +{ + return 0; +} + + +s8 gc_get_max_heap_size(void) +{ + return 0; +} + + +void gc_invoke_finalizers(void) +{ + /* nop */ +} + + +void gc_finalize_all(void) +{ + /* nop */ +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/mm/gc.hpp b/src/mm/gc.hpp new file mode 100644 index 000000000..7e130458e --- /dev/null +++ b/src/mm/gc.hpp @@ -0,0 +1,162 @@ +/* src/mm/gc.hpp - gc independant interface for heap managment + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _GC_HPP +#define _GC_HPP + +#include "config.h" + +#include +#include + +#if defined(ENABLE_GC_CACAO) +# include "threads/thread.hpp" +#endif + +#include "vm/global.h" +#include "vm/method.h" + + +#ifdef __cplusplus + +class GC { +public: + // Critical section functions. + static void critical_enter(void); + static void critical_leave(void); +}; + +extern "C" { +#endif + + +/* reference types ************************************************************/ + +enum { + GC_REFTYPE_THREADOBJECT, + GC_REFTYPE_CLASSLOADER, + GC_REFTYPE_JNI_GLOBALREF, + GC_REFTYPE_FINALIZER, + GC_REFTYPE_LOCALREF, + GC_REFTYPE_STACK, + GC_REFTYPE_CLASSREF, + GC_REFTYPE_LOCKRECORD +}; + + +/* function prototypes ********************************************************/ + +void gc_init(size_t heapmaxsize, size_t heapstartsize); + +void* heap_alloc_uncollectable(size_t size); +void* heap_alloc(size_t size, int references, methodinfo *finalizer, bool collect); +void heap_free(void *p); + +#if defined(ENABLE_GC_CACAO) +void heap_init_objectheader(java_object_t *o, uint32_t size); +int32_t heap_get_hashcode(java_object_t *o); + +void gc_reference_register(java_object_t **ref, int32_t reftype); +void gc_reference_unregister(java_object_t **ref); + +void gc_weakreference_register(java_object_t **ref, int32_t reftype); +void gc_weakreference_unregister(java_object_t **ref); +#endif + +void gc_call(void); +int64_t gc_get_heap_size(void); +int64_t gc_get_free_bytes(void); +int64_t gc_get_total_bytes(void); +int64_t gc_get_max_heap_size(void); +void gc_invoke_finalizers(void); +void gc_finalize_all(void); +void* gc_out_of_memory(size_t bytes_requested); + + +/* inlined functions **********************************************************/ + +static inline int32_t heap_hashcode(java_object_t *obj) +{ +#if defined(ENABLE_GC_CACAO) + return heap_get_hashcode(obj); +#else + return (int32_t)(intptr_t) obj; +#endif +} + +#ifdef __cplusplus +} + +/** + * Enters a LLNI critical section which prevents the GC from moving + * objects around on the collected heap. + * + * There are no race conditions possible while entering such a critical + * section, because each thread only modifies its own thread local flag + * and the GC reads the flags while the world is stopped. + */ +inline void GC::critical_enter() +{ +#if defined(ENABLE_GC_CACAO) + threadobject *t; + + t = THREADOBJECT; + assert(!t->gc_critical); + t->gc_critical = true; +#endif +} + +/** + * Leaves a LLNI critical section and allows the GC to move objects + * around on the collected heap again. + */ +inline void GC::critical_leave() +{ +#if defined(ENABLE_GC_CACAO) + threadobject *t; + + t = THREADOBJECT; + assert(t->gc_critical); + t->gc_critical = false; +#endif +} + +#endif + +#endif /* _GC_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/mm/memory.c b/src/mm/memory.c index 0b74e5351..ccaa8ec4d 100644 --- a/src/mm/memory.c +++ b/src/mm/memory.c @@ -26,11 +26,7 @@ #include "config.h" #include -#include -#include -#include -#include -#include +#include #if defined(__DARWIN__) /* If we compile with -ansi on darwin, is not @@ -47,23 +43,21 @@ #include "native/native.h" #include "threads/lock-common.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "toolbox/logging.h" -#include "vm/exceptions.h" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" -#include "vmcore/options.h" +#include "vm/options.h" +#include "vm/os.hpp" #if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" +# include "vm/statistics.h" #endif -#include "vmcore/system.h" - /* memory_mprotect ************************************************************* @@ -74,9 +68,8 @@ void memory_mprotect(void *addr, size_t len, int prot) { - if (system_mprotect(addr, len, prot) != 0) - vm_abort("memory_mprotect: system_mprotect failed: %s", - strerror(errno)); + if (os_mprotect(addr, len, prot) != 0) + vm_abort_errno("memory_mprotect: os_mprotect failed"); } @@ -93,7 +86,7 @@ void *memory_checked_alloc(size_t size) { /* always allocate memory zeroed out */ - void *p = calloc(size, 1); + void *p = os_calloc(size, 1); if (p == NULL) vm_abort("memory_checked_alloc: calloc failed: out of memory"); @@ -149,7 +142,7 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2) #if defined(ENABLE_MEMCHECK) if (len2 < len1) - memset((u1*)dst + len2, MEMORY_CLEAR_BYTE, len1 - len2); + os_memset((u1*)dst + len2, MEMORY_CLEAR_BYTE, len1 - len2); #endif dst = realloc(src, len2); @@ -159,7 +152,7 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2) #if defined(ENABLE_MEMCHECK) if (len2 > len1) - memset((u1*)dst + len1, MEMORY_CLEAR_BYTE, len2 - len1); + os_memset((u1*)dst + len1, MEMORY_CLEAR_BYTE, len2 - len1); #endif return dst; @@ -183,10 +176,10 @@ void mem_free(void *m, int32_t size) #if defined(ENABLE_MEMCHECK) /* destroy the contents */ - memset(m, MEMORY_CLEAR_BYTE, size); + os_memset(m, MEMORY_CLEAR_BYTE, size); #endif - free(m); + os_free(m); } diff --git a/src/mm/memory.h b/src/mm/memory.h index 0d2c74b29..ec6393f19 100644 --- a/src/mm/memory.h +++ b/src/mm/memory.h @@ -26,29 +26,29 @@ #ifndef _MEMORY_H #define _MEMORY_H - #include "config.h" -#include +#include -#include "vm/types.h" -#include "mm/codememory.h" -#include "mm/dumpmemory.h" +// Align the size of memory allocations to this size. +#define ALIGNSIZE 8 +#define MEMORY_ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size)) -/* constants for ENABLE_MEMCHECK **********************************************/ +// Constants for ENABLE_MEMCHECK. #if defined(ENABLE_MEMCHECK) #define MEMORY_CANARY_SIZE 16 #define MEMORY_CANARY_FIRST_BYTE 0xca #define MEMORY_CLEAR_BYTE 0xa5 -#endif /* defined(ENABLE_MEMCHECK) */ - +#endif -/* internal includes **********************************************************/ -#include "mm/gc-common.h" +// Includes. +#include "mm/codememory.h" +#include "mm/dumpmemory.hpp" +#include "mm/gc.hpp" /* @@ -88,7 +88,6 @@ Some more macros: */ -#define MEMORY_ALIGN(pos,size) ((((pos) + (size) - 1) / (size)) * (size)) #define PADDING(pos,size) (MEMORY_ALIGN((pos),(size)) - (pos)) #define OFFSET(s,el) ((int32_t) ((ptrint) &(((s*) 0)->el))) @@ -127,6 +126,10 @@ Some more macros: /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool memory_init(void); void memory_mprotect(void *addr, size_t len, int prot); @@ -144,6 +147,10 @@ void *mem_realloc(void *src, int32_t len1, int32_t len2); bool memory_start_thread(void); #endif +#ifdef __cplusplus +} +#endif + #endif /* _MEMORY_H */ diff --git a/src/mm/nogc.c b/src/mm/nogc.c deleted file mode 100644 index c84deb46d..000000000 --- a/src/mm/nogc.c +++ /dev/null @@ -1,183 +0,0 @@ -/* src/mm/nogc.c - allocates memory through malloc (no GC) - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#if defined(HAVE_SYS_MMAN_H) -# include -#endif - -#include "vm/types.h" - -#include "boehm-gc/include/gc.h" - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "toolbox/logging.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" - - -/* global stuff ***************************************************************/ - -#define MMAP_HEAPADDRESS 0x10000000 /* try to map the heap to this addr. */ -#define ALIGNSIZE 8 - -static void *mmapptr = NULL; -static int mmapsize = 0; -static void *mmaptop = NULL; - - -void *heap_alloc(u4 size, u4 references, methodinfo *finalizer, bool collect) -{ - void *m; - - mmapptr = (void *) MEMORY_ALIGN((ptrint) mmapptr, ALIGNSIZE); - - m = mmapptr; - mmapptr = (void *) ((ptrint) mmapptr + size); - - if (mmapptr > mmaptop) - vm_abort("heap_alloc: out of memory"); - - MSET(m, 0, u1, size); - - return m; -} - - -void *heap_alloc_uncollectable(u4 size) -{ - return heap_alloc(size, false, NULL, false); -} - - -void heap_free(void *p) -{ - /* nop */ -} - - - -void gc_init(u4 heapmaxsize, u4 heapstartsize) -{ - heapmaxsize = MEMORY_ALIGN(heapmaxsize, ALIGNSIZE); - -#if defined(HAVE_MMAP) - mmapptr = mmap((void *) MMAP_HEAPADDRESS, - (size_t) heapmaxsize, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | -# if defined(MAP_ANONYMOUS) - MAP_ANONYMOUS, -# elif defined(MAP_ANON) - MAP_ANON, -# else - 0, -# endif - -1, - (off_t) 0); - - if (mmapptr == MAP_FAILED) - vm_abort("gc_init: out of memory"); -#else - mmapptr = malloc(heapmaxsize); - - if (mmapptr == NULL) - vm_abort("gc_init: out of memory"); -#endif - - mmapsize = heapmaxsize; - mmaptop = (void *) ((ptrint) mmapptr + mmapsize); -} - - -void gc_call(void) -{ - log_text("GC call: nothing done..."); - /* nop */ -} - - -s8 gc_get_heap_size(void) -{ - return 0; -} - - -s8 gc_get_free_bytes(void) -{ - return 0; -} - - -s8 gc_get_total_bytes(void) -{ - return 0; -} - - -s8 gc_get_max_heap_size(void) -{ - return 0; -} - - -void gc_invoke_finalizers(void) -{ - /* nop */ -} - - -void gc_finalize_all(void) -{ - /* nop */ -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/mm/tlh.c b/src/mm/tlh.c new file mode 100644 index 000000000..e46cf8760 --- /dev/null +++ b/src/mm/tlh.c @@ -0,0 +1,128 @@ +/* src/mm/tlh.c + + Copyright (C) 2008 + CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#include "config.h" + +#include "mm/memory.h" +#include "mm/tlh.h" + +#include "vm/global.h" + +#include +#include + +static const int TLH_MAX_SIZE = (20 * 1024 * 1024); + +static inline bool tlh_avail(tlh_t *tlh, unsigned n) { + /* + --- --- --- --- + ^ end + ^ top + ^ top + 2 + */ + return (tlh->top + n) <= tlh->end; +} + +void tlh_init(tlh_t *tlh) { + + void *heap = mmap( + NULL, + TLH_MAX_SIZE, + PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_PRIVATE, + -1, + 0 + ); + + if (heap == MAP_FAILED) { + /* The top pointer points to end, so all allocations will fail. */ + tlh->start = NULL; + tlh->end = NULL; + tlh->top = NULL; + tlh->base = NULL; + } else { + tlh->start = (uint8_t *)heap; + tlh->top = tlh->start; + tlh->base = tlh->start; + tlh->end = tlh->start + TLH_MAX_SIZE; + } + + tlh->overflows = 0; +} + +void tlh_destroy(tlh_t *tlh) { + int res = munmap(tlh->start, TLH_MAX_SIZE); + if (res == -1) { + /* TODO */ + assert(0); + } + tlh->start = NULL; + tlh->end = NULL; + tlh->top = NULL; + tlh->base = NULL; +} + +void tlh_add_frame(tlh_t *tlh) { + if (tlh_avail(tlh, SIZEOF_VOID_P)) { + *(uint8_t **)tlh->top = tlh->base; + tlh->base = tlh->top; + tlh->top += SIZEOF_VOID_P; + } else { + tlh->overflows += 1; + } +} + +void tlh_remove_frame(tlh_t *tlh) { + if (tlh->overflows > 0) { + tlh->overflows -= 1; + } else { + tlh->top = tlh->base; + tlh->base = *(uint8_t **)tlh->top; + } +} + +void *tlh_alloc(tlh_t *tlh, size_t size) { + void *ret; + if (tlh_avail(tlh, size)) { + ret = tlh->top; + tlh->top += size; + MZERO(ret, char, size); + } else { + ret = NULL; + } + return ret; +} + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/mm/tlh.h b/src/mm/tlh.h new file mode 100644 index 000000000..6a6eab8af --- /dev/null +++ b/src/mm/tlh.h @@ -0,0 +1,74 @@ +/* src/mm/tlh.h + + Copyright (C) 2008 + CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MM_TLH_H +#define _MM_TLH_H + +#include "config.h" + +#include +#include + +typedef struct { + uint8_t *start; + uint8_t *end; + uint8_t *top; + uint8_t *base; + unsigned overflows; +} tlh_t; + +#ifdef __cplusplus +extern "C" { +#endif + +void tlh_init(tlh_t *tlh); + +void tlh_destroy(tlh_t *tlh); + +void tlh_add_frame(tlh_t *tlh); + +void tlh_remove_frame(tlh_t *tlh); + +void *tlh_alloc(tlh_t *tlh, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/Makefile.am b/src/native/Makefile.am index 8cb17b562..f18f9c2d4 100644 --- a/src/native/Makefile.am +++ b/src/native/Makefile.am @@ -1,9 +1,7 @@ ## src/native/Makefile.am ## -## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, -## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -## J. Wenninger, Institut f. Computersprachen - TU Wien +## Copyright (C) 1996-2005, 2006, 2007, 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO ## ## This file is part of CACAO. ## @@ -28,7 +26,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top LIBS = SUBDIRS = \ - include \ vm if ENABLE_JVMTI @@ -40,8 +37,8 @@ noinst_LTLIBRARIES = libnative.la if ENABLE_JNI JNI_SOURCES = \ - jni.c \ - jni.h \ + jni.cpp \ + jni.hpp \ localref.c \ localref.h endif diff --git a/src/native/include/Makefile.am b/src/native/include/Makefile.am index bdecd1eef..28a29873c 100644 --- a/src/native/include/Makefile.am +++ b/src/native/include/Makefile.am @@ -21,142 +21,85 @@ ## 02110-1301, USA. -JAVAH = $(CACAOH) -JAVAHCMD = $(JAVAH) -bootclasspath $(BOOTCLASSPATH) +JAVAH = javah +JAVAHCMD = $(JAVAH) -jni -bootclasspath $(BOOTCLASSPATH) -COMMON_HEADER_FILES = \ - java_lang_Class.h \ - java_lang_Object.h \ - java_lang_String.h \ - java_lang_Thread.h \ - java_lang_Throwable.h \ - \ - java_io_InputStream.h \ - java_io_PrintStream.h \ - \ - java_lang_Boolean.h \ - java_lang_Byte.h \ - java_lang_Character.h \ - java_lang_Double.h \ - java_lang_Float.h \ - java_lang_Integer.h \ - java_lang_Long.h \ - java_lang_Short.h \ - java_util_Vector.h - -JAVASE_HEADER_FILES = \ - java_lang_ClassLoader.h \ - java_lang_Cloneable.h \ - java_lang_ThreadGroup.h \ - java_util_Properties.h \ - \ - java_io_File.h \ - java_lang_Process.h \ - java_lang_StackTraceElement.h \ - java_lang_reflect_Constructor.h \ - java_lang_reflect_Field.h \ - java_lang_reflect_Method.h \ - java_nio_Buffer.h \ - java_security_ProtectionDomain.h \ - java_util_HashMap.h \ - java_util_Map.h \ - java_util_concurrent_atomic_AtomicLong.h \ - sun_misc_Unsafe.h - -if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH -JAVASE_HEADER_FILES += \ - java_lang_VMThread.h \ - java_lang_VMThrowable.h \ - \ - gnu_classpath_Pointer.h \ - gnu_classpath_Pointer32.h \ - gnu_classpath_Pointer64.h \ - gnu_java_lang_VMCPStringBuilder.h \ - java_lang_VMObject.h \ - java_lang_reflect_VMConstructor.h \ - java_lang_reflect_VMField.h \ - java_lang_reflect_VMMethod.h \ - java_nio_DirectByteBufferImpl.h - -if ENABLE_ANNOTATIONS -JAVASE_HEADER_FILES += \ - sun_reflect_ConstantPool.h -endif -endif - -if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK -JAVASE_HEADER_FILES += \ - java_lang_AssertionStatusDirectives.h \ - java_nio_ByteBuffer.h \ - sun_reflect_ConstantPool.h -endif - -JAVAME_CLDC1_1_HEADER_FILES = \ +if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1 +IMPLEMENTED_VM_CLASSES_HEADER_FILES = \ com_sun_cldc_io_ResourceInputStream.h \ com_sun_cldc_io_j2me_socket_Protocol.h \ com_sun_cldchi_io_ConsoleOutputStream.h \ com_sun_cldchi_jvm_FileDescriptor.h \ com_sun_cldchi_jvm_JVM.h \ + java_lang_Class.h \ java_lang_Math.h \ java_lang_Runtime.h \ java_lang_System.h - -JVMTI_HEADER_FILES = \ - gnu_classpath_jdwp_VMFrame.h \ - gnu_classpath_jdwp_VMMethod.h \ - gnu_classpath_jdwp_VMVirtualMachine.h \ - gnu_classpath_jdwp_event_EventRequest.h \ - gnu_classpath_jdwp_util_VariableTable.h +endif if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH -ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES = \ +IMPLEMENTED_VM_CLASSES_HEADER_FILES = \ gnu_classpath_VMStackWalker.h \ gnu_classpath_VMSystemProperties.h \ + gnu_java_lang_VMCPStringBuilder.h \ gnu_java_lang_management_VMClassLoadingMXBeanImpl.h \ gnu_java_lang_management_VMMemoryMXBeanImpl.h \ gnu_java_lang_management_VMRuntimeMXBeanImpl.h \ gnu_java_lang_management_VMThreadMXBeanImpl.h \ java_lang_VMClass.h \ java_lang_VMClassLoader.h \ + java_lang_VMObject.h \ java_lang_VMRuntime.h \ java_lang_VMString.h \ java_lang_VMSystem.h \ - java_lang_management_MemoryUsage.h \ - java_lang_management_ThreadInfo.h \ + java_lang_VMThread.h \ + java_lang_VMThrowable.h \ java_lang_management_VMManagementFactory.h \ + java_lang_reflect_VMConstructor.h \ + java_lang_reflect_VMField.h \ + java_lang_reflect_VMMethod.h \ java_lang_reflect_VMProxy.h \ - java_security_VMAccessController.h -endif - -CLEANFILES = \ - *.h - -DO_HEADER_FILES = \ - $(COMMON_HEADER_FILES) + java_security_VMAccessController.h \ + java_util_concurrent_atomic_AtomicLong.h \ + sun_misc_Unsafe.h -if ENABLE_JAVASE -DO_HEADER_FILES += \ - $(JAVASE_HEADER_FILES) \ - $(ADDITIONAL_IMPLEMENTED_VM_CLASSES_HEADER_FILES) +if ENABLE_ANNOTATIONS +IMPLEMENTED_VM_CLASSES_HEADER_FILES += \ + sun_reflect_ConstantPool.h +endif endif -if ENABLE_JAVAME_CLDC1_1 -DO_HEADER_FILES += \ - $(JAVAME_CLDC1_1_HEADER_FILES) +if WITH_JAVA_RUNTIME_LIBRARY_OPENJDK +IMPLEMENTED_VM_CLASSES_HEADER_FILES = \ + sun_misc_Unsafe.h endif if ENABLE_JVMTI -DO_HEADER_FILES += \ - $(GEN_JVMTI_HEADER_FILES) +JVMTI_HEADER_FILES = \ + gnu_classpath_jdwp_VMFrame.h \ + gnu_classpath_jdwp_VMMethod.h \ + gnu_classpath_jdwp_VMVirtualMachine.h \ + gnu_classpath_jdwp_event_EventRequest.h \ + gnu_classpath_jdwp_util_VariableTable.h endif +CLEANFILES = \ + *.h + +DO_HEADER_FILES = \ + $(IMPLEMENTED_VM_CLASSES_HEADER_FILES) + if WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH +if ENABLE_ZLIB VM_ZIP = $(top_builddir)/src/classes/vm.zip endif +endif if WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1 +if ENABLE_ZLIB VM_ZIP = $(top_builddir)/src/classes/vm.zip endif +endif noinst_DATA = $(DO_HEADER_FILES) diff --git a/src/native/jni.c b/src/native/jni.c deleted file mode 100644 index 392126e17..000000000 --- a/src/native/jni.c +++ /dev/null @@ -1,4390 +0,0 @@ -/* src/native/jni.c - implementation of the Java Native Interface functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "vm/types.h" - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/localref.h" -#include "native/native.h" - -#if defined(ENABLE_JAVASE) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/gnu_classpath_Pointer.h" - -# if SIZEOF_VOID_P == 8 -# include "native/include/gnu_classpath_Pointer64.h" -# else -# include "native/include/gnu_classpath_Pointer32.h" -# endif -# endif -#endif - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Throwable.h" - -#if defined(ENABLE_JAVASE) - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -# endif - -/* java_lang_ClassLoader is used in java_lang_Class and vice versa, so - we pre-define it here to prevent a compiler warning for Sun - configurations. */ - -struct java_lang_ClassLoader; - -# include "native/include/java_lang_Class.h" -# include "native/include/java_lang_ClassLoader.h" - -# include "native/include/java_lang_reflect_Constructor.h" -# include "native/include/java_lang_reflect_Field.h" -# include "native/include/java_lang_reflect_Method.h" - -# include "native/include/java_nio_Buffer.h" - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/java_lang_reflect_VMConstructor.h" -# include "native/include/java_lang_reflect_VMField.h" -# include "native/include/java_lang_reflect_VMMethod.h" - -# include "native/include/java_nio_DirectByteBufferImpl.h" -# endif -#elif defined(ENABLE_JAVAME_CLDC1_1) -# include "native/include/java_lang_Class.h" -#endif - -#if defined(ENABLE_JVMTI) -# include "native/jvmti/cacaodbg.h" -#endif - -#if defined(ENABLE_JAVASE) -# include "native/vm/reflect.h" -#endif - -#include "threads/lock-common.h" -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/initialize.h" -#include "vm/primitive.h" -#include "vm/resolve.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/argument.h" -#include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" - - -/* debug **********************************************************************/ - -#if !defined(NDEBUG) -# define TRACEJNICALLS(text) \ - do { \ - if (opt_TraceJNICalls) { \ - log_println text; \ - } \ - } while (0) -#else -# define TRACEJNICALLS(text) -#endif - - -/* global variables ***********************************************************/ - -/* global reference table *****************************************************/ - -/* hashsize must be power of 2 */ - -#define HASHTABLE_GLOBAL_REF_SIZE 64 /* initial size of globalref-hash */ - -static hashtable *hashtable_global_ref; /* hashtable for globalrefs */ - - -/* direct buffer stuff ********************************************************/ - -#if defined(ENABLE_JAVASE) -static classinfo *class_java_nio_Buffer; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - -static classinfo *class_java_nio_DirectByteBufferImpl; -static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite; - -# if SIZEOF_VOID_P == 8 -static classinfo *class_gnu_classpath_Pointer64; -# else -static classinfo *class_gnu_classpath_Pointer32; -# endif - -static methodinfo *dbbirw_init; - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - -static classinfo *class_sun_nio_ch_DirectBuffer; -static classinfo *class_java_nio_DirectByteBuffer; - -static methodinfo *dbb_init; - -# endif -#endif - - -/* some forward declarations **************************************************/ - -jobject jni_NewLocalRef(JNIEnv *env, jobject ref); - - -/* jni_init ******************************************************************** - - Initialize the JNI subsystem. - -*******************************************************************************/ - -bool jni_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("jni_init"); - - /* create global ref hashtable */ - - hashtable_global_ref = NEW(hashtable); - - hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE); - - -#if defined(ENABLE_JAVASE) - /* Direct buffer stuff. */ - - if (!(class_java_nio_Buffer = - load_class_bootstrap(utf_new_char("java/nio/Buffer"))) || - !link_class(class_java_nio_Buffer)) - return false; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - if (!(class_java_nio_DirectByteBufferImpl = - load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) || - !link_class(class_java_nio_DirectByteBufferImpl)) - return false; - - if (!(class_java_nio_DirectByteBufferImpl_ReadWrite = - load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) || - !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite)) - return false; - - if (!(dbbirw_init = - class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite, - utf_init, - utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V")))) - return false; - -# if SIZEOF_VOID_P == 8 - if (!(class_gnu_classpath_Pointer64 = - load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) || - !link_class(class_gnu_classpath_Pointer64)) - return false; -# else - if (!(class_gnu_classpath_Pointer32 = - load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) || - !link_class(class_gnu_classpath_Pointer32)) - return false; -# endif - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - if (!(class_sun_nio_ch_DirectBuffer = - load_class_bootstrap(utf_new_char("sun/nio/ch/DirectBuffer")))) - vm_abort("jni_init: loading sun/nio/ch/DirectBuffer failed"); - - if (!link_class(class_sun_nio_ch_DirectBuffer)) - vm_abort("jni_init: linking sun/nio/ch/DirectBuffer failed"); - - if (!(class_java_nio_DirectByteBuffer = - load_class_bootstrap(utf_new_char("java/nio/DirectByteBuffer")))) - vm_abort("jni_init: loading java/nio/DirectByteBuffer failed"); - - if (!link_class(class_java_nio_DirectByteBuffer)) - vm_abort("jni_init: linking java/nio/DirectByteBuffer failed"); - - if (!(dbb_init = - class_resolvemethod(class_java_nio_DirectByteBuffer, - utf_init, - utf_new_char("(JI)V")))) - vm_abort("jni_init: resolving java/nio/DirectByteBuffer.init(JI)V failed"); - -# endif - -#endif /* defined(ENABLE_JAVASE) */ - - return true; -} - - -/* jni_version_check *********************************************************** - - Check if the given JNI version is supported. - - IN: - version....JNI version to check - - RETURN VALUE: - true.......supported - false......not supported - -*******************************************************************************/ - -bool jni_version_check(int version) -{ - switch (version) { - case JNI_VERSION_1_1: - case JNI_VERSION_1_2: - case JNI_VERSION_1_4: - case JNI_VERSION_1_6: - return true; - default: - return false; - } -} - - -/* _Jv_jni_CallObjectMethod **************************************************** - - Internal function to call Java Object methods. - -*******************************************************************************/ - -static java_handle_t *_Jv_jni_CallObjectMethod(java_handle_t *o, - vftbl_t *vftbl, - methodinfo *m, va_list ap) -{ - methodinfo *resm; - java_handle_t *ro; - - STATISTICS(jniinvokation()); - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - ro = vm_call_method_valist(resm, o, ap); - - return ro; -} - - -/* _Jv_jni_CallObjectMethodA *************************************************** - - Internal function to call Java Object methods. - -*******************************************************************************/ - -static java_handle_t *_Jv_jni_CallObjectMethodA(java_handle_t *o, - vftbl_t *vftbl, - methodinfo *m, - const jvalue *args) -{ - methodinfo *resm; - java_handle_t *ro; - - STATISTICS(jniinvokation()); - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - ro = vm_call_method_jvalue(resm, o, args); - - return ro; -} - - -/* _Jv_jni_CallIntMethod ******************************************************* - - Internal function to call Java integer class methods (boolean, - byte, char, short, int). - -*******************************************************************************/ - -static jint _Jv_jni_CallIntMethod(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, va_list ap) -{ - methodinfo *resm; - jint i; - - STATISTICS(jniinvokation()); - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - i = vm_call_method_int_valist(resm, o, ap); - - return i; -} - - -/* _Jv_jni_CallIntMethodA ****************************************************** - - Internal function to call Java integer class methods (boolean, - byte, char, short, int). - -*******************************************************************************/ - -static jint _Jv_jni_CallIntMethodA(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, const jvalue *args) -{ - methodinfo *resm; - jint i; - - STATISTICS(jniinvokation()); - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - i = vm_call_method_int_jvalue(resm, o, args); - - return i; -} - - -/* _Jv_jni_CallLongMethod ****************************************************** - - Internal function to call Java long methods. - -*******************************************************************************/ - -static jlong _Jv_jni_CallLongMethod(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, va_list ap) -{ - methodinfo *resm; - jlong l; - - STATISTICS(jniinvokation()); - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - l = vm_call_method_long_valist(resm, o, ap); - - return l; -} - - -/* _Jv_jni_CallLongMethodA ***************************************************** - - Internal function to call Java long methods. - -*******************************************************************************/ - -static jlong _Jv_jni_CallLongMethodA(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, const jvalue *args) -{ - methodinfo *resm; - jlong l; - - STATISTICS(jniinvokation()); - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - } - else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - l = vm_call_method_long_jvalue(resm, o, args); - - return l; -} - - -/* _Jv_jni_CallFloatMethod ***************************************************** - - Internal function to call Java float methods. - -*******************************************************************************/ - -static jfloat _Jv_jni_CallFloatMethod(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, va_list ap) -{ - methodinfo *resm; - jfloat f; - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - f = vm_call_method_float_valist(resm, o, ap); - - return f; -} - - -/* _Jv_jni_CallFloatMethodA **************************************************** - - Internal function to call Java float methods. - -*******************************************************************************/ - -static jfloat _Jv_jni_CallFloatMethodA(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, const jvalue *args) -{ - methodinfo *resm; - jfloat f; - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - } - else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - f = vm_call_method_float_jvalue(resm, o, args); - - return f; -} - - -/* _Jv_jni_CallDoubleMethod **************************************************** - - Internal function to call Java double methods. - -*******************************************************************************/ - -static jdouble _Jv_jni_CallDoubleMethod(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, va_list ap) -{ - methodinfo *resm; - jdouble d; - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - d = vm_call_method_double_valist(resm, o, ap); - - return d; -} - - -/* _Jv_jni_CallDoubleMethodA *************************************************** - - Internal function to call Java double methods. - -*******************************************************************************/ - -static jdouble _Jv_jni_CallDoubleMethodA(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, const jvalue *args) -{ - methodinfo *resm; - jdouble d; - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - } - else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - d = vm_call_method_double_jvalue(resm, o, args); - - return d; -} - - -/* _Jv_jni_CallVoidMethod ****************************************************** - - Internal function to call Java void methods. - -*******************************************************************************/ - -static void _Jv_jni_CallVoidMethod(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, va_list ap) -{ - methodinfo *resm; - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - (void) vm_call_method_valist(resm, o, ap); -} - - -/* _Jv_jni_CallVoidMethodA ***************************************************** - - Internal function to call Java void methods. - -*******************************************************************************/ - -static void _Jv_jni_CallVoidMethodA(java_handle_t *o, vftbl_t *vftbl, - methodinfo *m, const jvalue *args) -{ - methodinfo *resm; - - if (m == NULL) { - exceptions_throw_nullpointerexception(); - return; - } - - /* Class initialization is done by the JIT compiler. This is ok - since a static method always belongs to the declaring class. */ - - if (m->flags & ACC_STATIC) { - /* For static methods we reset the object. */ - - if (o != NULL) - o = NULL; - - /* for convenience */ - - resm = m; - - } else { - /* For instance methods we make a virtual function table lookup. */ - - resm = method_vftbl_lookup(vftbl, m); - } - - STATISTICS(jnicallXmethodnvokation()); - - (void) vm_call_method_jvalue(resm, o, args); -} - - -/* GetVersion ****************************************************************** - - Returns the major version number in the higher 16 bits and the - minor version number in the lower 16 bits. - -*******************************************************************************/ - -jint _Jv_JNI_GetVersion(JNIEnv *env) -{ - TRACEJNICALLS(("_Jv_JNI_GetVersion(env=%p)", env)); - - /* We support JNI 1.6. */ - - return JNI_VERSION_1_6; -} - - -/* Class Operations ***********************************************************/ - -/* DefineClass ***************************************************************** - - Loads a class from a buffer of raw class data. The buffer - containing the raw class data is not referenced by the VM after the - DefineClass call returns, and it may be discarded if desired. - -*******************************************************************************/ - -jclass _Jv_JNI_DefineClass(JNIEnv *env, const char *name, jobject loader, - const jbyte *buf, jsize bufLen) -{ -#if defined(ENABLE_JAVASE) - utf *u; - classloader_t *cl; - classinfo *c; - java_lang_Class *co; - - TRACEJNICALLS(("_Jv_JNI_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d)", env, name, loader, buf, bufLen)); - - u = utf_new_char(name); - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - c = class_define(u, cl, bufLen, (uint8_t *) buf, NULL); - - co = LLNI_classinfo_wrap(c); - - return (jclass) jni_NewLocalRef(env, (jobject) co); -#else - vm_abort("_Jv_JNI_DefineClass: not implemented in this configuration"); - - /* keep compiler happy */ - - return 0; -#endif -} - - -/* FindClass ******************************************************************* - - This function loads a locally-defined class. It searches the - directories and zip files specified by the CLASSPATH environment - variable for the class with the specified name. - -*******************************************************************************/ - -jclass jni_FindClass(JNIEnv *env, const char *name) -{ -#if defined(ENABLE_JAVASE) - - utf *u; - classinfo *cc; - classinfo *c; - java_lang_Class *co; - - TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name)); - - /* FIXME If name is NULL we have a problem here. */ - - u = utf_new_char_classname((char *) name); - - if ((u == NULL) /*|| (int)strlen(name) > symbolOopDesc::max_length() */) { - exceptions_throw_noclassdeffounderror(u); - return NULL; - } - - /* Check stacktrace for classloader, if one found use it, - otherwise use the system classloader. */ - - /* Quote from the JNI documentation: - - In the Java 2 Platform, FindClass locates the class loader - associated with the current native method. If the native code - belongs to a system class, no class loader will be - involved. Otherwise, the proper class loader will be invoked to - load and link the named class. When FindClass is called through - the Invocation Interface, there is no current native method or - its associated class loader. In that case, the result of - ClassLoader.getBaseClassLoader is used." */ - - cc = stacktrace_get_current_class(); - - if (cc == NULL) - c = load_class_from_sysloader(u); - else - c = load_class_from_classloader(u, cc->classloader); - - if (c == NULL) { - resolve_handle_pending_exception(true); - return NULL; - } - - if (!link_class(c)) - return NULL; - - co = LLNI_classinfo_wrap(c); - - return (jclass) jni_NewLocalRef(env, (jobject) co); - -#elif defined(ENABLE_JAVAME_CLDC1_1) - - utf *u; - classinfo *c; - - TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name)); - - u = utf_new_char_classname((char *) name); - c = load_class_bootstrap(u); - - if (c == NULL) { - resolve_handle_pending_exception(true); - return NULL; - } - - if (!link_class(c)) - return NULL; - - return (jclass) jni_NewLocalRef(env, (jobject) c); - -#else - vm_abort("jni_FindClass: not implemented in this configuration"); - - /* keep compiler happy */ - - return NULL; -#endif -} - - -/* GetSuperclass *************************************************************** - - If clazz represents any class other than the class Object, then - this function returns the object that represents the superclass of - the class specified by clazz. - -*******************************************************************************/ - -jclass _Jv_JNI_GetSuperclass(JNIEnv *env, jclass sub) -{ - classinfo *c; - classinfo *super; - java_lang_Class *co; - - TRACEJNICALLS(("_Jv_JNI_GetSuperclass(env=%p, sub=%p)", env, sub)); - - c = LLNI_classinfo_unwrap(sub); - - if (c == NULL) - return NULL; - - super = class_get_superclass(c); - - co = LLNI_classinfo_wrap(super); - - return (jclass) jni_NewLocalRef(env, (jobject) co); -} - - -/* IsAssignableFrom ************************************************************ - - Determines whether an object of sub can be safely cast to sup. - -*******************************************************************************/ - -jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup) -{ - classinfo *to; - classinfo *from; - - TRACEJNICALLS(("_Jv_JNI_IsAssignableFrom(env=%p, sub=%p, sup=%p)", env, sub, sup)); - - to = (classinfo *) sup; - from = (classinfo *) sub; - - return class_is_assignable_from(to, from); -} - - -/* Throw *********************************************************************** - - Causes a java.lang.Throwable object to be thrown. - -*******************************************************************************/ - -jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj) -{ - java_handle_t *o; - - STATISTICS(jniinvokation()); - - o = (java_handle_t *) obj; - - exceptions_set_exception(o); - - return JNI_OK; -} - - -/* ThrowNew ******************************************************************** - - Constructs an exception object from the specified class with the - message specified by message and causes that exception to be - thrown. - -*******************************************************************************/ - -jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg) -{ - classinfo *c; - java_handle_t *o; - java_handle_t *s; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - if (msg == NULL) - msg = ""; - s = javastring_new_from_utf_string(msg); - - /* instantiate exception object */ - - o = native_new_and_init_string(c, s); - - if (o == NULL) - return -1; - - exceptions_set_exception(o); - - return 0; -} - - -/* ExceptionOccurred *********************************************************** - - Determines if an exception is being thrown. The exception stays - being thrown until either the native code calls ExceptionClear(), - or the Java code handles the exception. - -*******************************************************************************/ - -jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env) -{ - java_handle_t *o; - - TRACEJNICALLS(("_Jv_JNI_ExceptionOccurred(env=%p)", env)); - - o = exceptions_get_exception(); - - return jni_NewLocalRef(env, (jthrowable) o); -} - - -/* ExceptionDescribe *********************************************************** - - Prints an exception and a backtrace of the stack to a system - error-reporting channel, such as stderr. This is a convenience - routine provided for debugging. - -*******************************************************************************/ - -void jni_ExceptionDescribe(JNIEnv *env) -{ - TRACEJNICALLS(("jni_ExceptionDescribe(env=%p)", env)); - - exceptions_print_stacktrace(); -} - - -/* ExceptionClear ************************************************************** - - Clears any exception that is currently being thrown. If no - exception is currently being thrown, this routine has no effect. - -*******************************************************************************/ - -void jni_ExceptionClear(JNIEnv *env) -{ - TRACEJNICALLS(("jni_ExceptionClear(env=%p)", env)); - - exceptions_clear_exception(); -} - - -/* FatalError ****************************************************************** - - Raises a fatal error and does not expect the VM to recover. This - function does not return. - -*******************************************************************************/ - -void _Jv_JNI_FatalError(JNIEnv *env, const char *msg) -{ - STATISTICS(jniinvokation()); - - /* this seems to be the best way */ - - vm_abort("JNI Fatal error: %s", msg); -} - - -/* PushLocalFrame ************************************************************** - - Creates a new local reference frame, in which at least a given - number of local references can be created. - -*******************************************************************************/ - -jint jni_PushLocalFrame(JNIEnv* env, jint capacity) -{ - TRACEJNICALLS(("jni_PushLocalFrame(env=%p, capacity=%d)", env, capacity)); - - if (capacity <= 0) - return -1; - - /* add new local reference frame to current table */ - - if (!localref_frame_push(capacity)) - return -1; - - return 0; -} - - -/* PopLocalFrame *************************************************************** - - Pops off the current local reference frame, frees all the local - references, and returns a local reference in the previous local - reference frame for the given result object. - -*******************************************************************************/ - -jobject jni_PopLocalFrame(JNIEnv* env, jobject result) -{ - TRACEJNICALLS(("jni_PopLocalFrame(env=%p, result=%p)", env, result)); - - /* release all current local frames */ - - localref_frame_pop_all(); - - /* add local reference and return the value */ - - return jni_NewLocalRef(env, result); -} - - -/* DeleteLocalRef ************************************************************** - - Deletes the local reference pointed to by localRef. - -*******************************************************************************/ - -void jni_DeleteLocalRef(JNIEnv *env, jobject localRef) -{ - java_handle_t *o; - - TRACEJNICALLS(("jni_DeleteLocalRef(env=%p, ref=%p)", env, localRef)); - - o = (java_handle_t *) localRef; - - if (o == NULL) - return; - - /* delete the reference */ - - localref_del(o); -} - - -/* IsSameObject **************************************************************** - - Tests whether two references refer to the same Java object. - -*******************************************************************************/ - -jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2) -{ - java_handle_t *o1; - java_handle_t *o2; - jboolean result; - - STATISTICS(jniinvokation()); - - o1 = (java_handle_t *) ref1; - o2 = (java_handle_t *) ref2; - - LLNI_CRITICAL_START; - - if (LLNI_UNWRAP(o1) == LLNI_UNWRAP(o2)) - result = JNI_TRUE; - else - result = JNI_FALSE; - - LLNI_CRITICAL_END; - - return result; -} - - -/* NewLocalRef ***************************************************************** - - Creates a new local reference that refers to the same object as ref. - -*******************************************************************************/ - -jobject jni_NewLocalRef(JNIEnv *env, jobject ref) -{ - java_handle_t *o; - java_handle_t *localref; - - TRACEJNICALLS(("jni_NewLocalRef(env=%p, ref=%p)", env, ref)); - - o = (java_handle_t *) ref; - - if (o == NULL) - return NULL; - - /* insert the reference */ - - localref = localref_add(LLNI_DIRECT(o)); - - return (jobject) localref; -} - - -/* EnsureLocalCapacity ********************************************************* - - Ensures that at least a given number of local references can be - created in the current thread - -*******************************************************************************/ - -jint jni_EnsureLocalCapacity(JNIEnv* env, jint capacity) -{ - localref_table *lrt; - - TRACEJNICALLS(("jni_EnsureLocalCapacity(env=%p, capacity=%d)", env, capacity)); - - /* get local reference table (thread specific) */ - - lrt = LOCALREFTABLE; - - /* check if capacity elements are available in the local references table */ - - if ((lrt->used + capacity) > lrt->capacity) - return jni_PushLocalFrame(env, capacity); - - return 0; -} - - -/* AllocObject ***************************************************************** - - Allocates a new Java object without invoking any of the - constructors for the object. Returns a reference to the object. - -*******************************************************************************/ - -jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz) -{ - classinfo *c; - java_handle_t *o; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - - if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) { - exceptions_throw_instantiationexception(c); - return NULL; - } - - o = builtin_new(c); - - return jni_NewLocalRef(env, (jobject) o); -} - - -/* NewObject ******************************************************************* - - Programmers place all arguments that are to be passed to the - constructor immediately following the methodID - argument. NewObject() accepts these arguments and passes them to - the Java method that the programmer wishes to invoke. - -*******************************************************************************/ - -jobject _Jv_JNI_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - va_list ap; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return NULL; - - /* call constructor */ - - va_start(ap, methodID); - _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap); - va_end(ap); - - return jni_NewLocalRef(env, (jobject) o); -} - - -/* NewObjectV ****************************************************************** - - Programmers place all arguments that are to be passed to the - constructor in an args argument of type va_list that immediately - follows the methodID argument. NewObjectV() accepts these - arguments, and, in turn, passes them to the Java method that the - programmer wishes to invoke. - -*******************************************************************************/ - -jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, - va_list args) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return NULL; - - /* call constructor */ - - _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args); - - return jni_NewLocalRef(env, (jobject) o); -} - - -/* NewObjectA ***************************************************************** - - Programmers place all arguments that are to be passed to the - constructor in an args array of jvalues that immediately follows - the methodID argument. NewObjectA() accepts the arguments in this - array, and, in turn, passes them to the Java method that the - programmer wishes to invoke. - -*******************************************************************************/ - -jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, - const jvalue *args) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return NULL; - - /* call constructor */ - - _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args); - - return jni_NewLocalRef(env, (jobject) o); -} - - -/* GetObjectClass ************************************************************** - - Returns the class of an object. - -*******************************************************************************/ - -jclass _Jv_JNI_GetObjectClass(JNIEnv *env, jobject obj) -{ - java_handle_t *o; - classinfo *c; - java_lang_Class *co; - - STATISTICS(jniinvokation()); - - o = (java_handle_t *) obj; - - if ((o == NULL) || (LLNI_vftbl_direct(o) == NULL)) - return NULL; - - LLNI_class_get(o, c); - - co = LLNI_classinfo_wrap(c); - - return (jclass) jni_NewLocalRef(env, (jobject) co); -} - - -/* IsInstanceOf **************************************************************** - - Tests whether an object is an instance of a class. - -*******************************************************************************/ - -jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz) -{ - classinfo *c; - java_handle_t *h; - - TRACEJNICALLS(("_Jv_JNI_IsInstanceOf(env=%p, obj=%p, clazz=%p)", env, obj, clazz)); - - /* XXX Is this correct? */ - c = LLNI_classinfo_unwrap(clazz); - h = (java_handle_t *) obj; - - return class_is_instance(c, h); -} - - -/* Reflection Support *********************************************************/ - -/* FromReflectedMethod ********************************************************* - - Converts java.lang.reflect.Method or java.lang.reflect.Constructor - object to a method ID. - -*******************************************************************************/ - -jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method) -{ -#if defined(ENABLE_JAVASE) - java_handle_t *o; - java_lang_reflect_Method *rm; - java_lang_reflect_Constructor *rc; - classinfo *c; - methodinfo *m; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMMethod *rvmm; - java_lang_reflect_VMConstructor *rvmc; -#endif - - TRACEJNICALLS(("jni_FromReflectedMethod(env=%p, method=%p)", env, method)); - - o = (java_handle_t *) method; - - if (o == NULL) - return NULL; - - if (o->vftbl->clazz == class_java_lang_reflect_Constructor) { - rc = (java_lang_reflect_Constructor *) method; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - LLNI_field_get_ref(rc, cons , rvmc); - LLNI_field_get_cls(rvmc, clazz, c); - LLNI_field_get_val(rvmc, slot , slot); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - LLNI_field_get_cls(rc, clazz, c); - LLNI_field_get_val(rc, slot , slot); - -#else -# error unknown configuration -#endif - } - else { - assert(o->vftbl->clazz == class_java_lang_reflect_Method); - - rm = (java_lang_reflect_Method *) method; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - LLNI_field_get_ref(rm, m , rvmm); - LLNI_field_get_cls(rvmm, clazz, c); - LLNI_field_get_val(rvmm, slot , slot); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - LLNI_field_get_cls(rm, clazz, c); - LLNI_field_get_val(rm, slot , slot); - -#else -# error unknown configuration -#endif - } - - m = &(c->methods[slot]); - - return (jmethodID) m; -#else - vm_abort("jni_FromReflectedMethod: Not implemented in this configuration."); - - /* Keep compiler happy. */ - - return NULL; -#endif -} - - -/* FromReflectedField ********************************************************** - - Converts a java.lang.reflect.Field to a field ID. - -*******************************************************************************/ - -jfieldID jni_FromReflectedField(JNIEnv* env, jobject field) -{ -#if defined(ENABLE_JAVASE) - java_lang_reflect_Field *rf; - classinfo *c; - fieldinfo *f; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMField *rvmf; -#endif - - TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field)); - - rf = (java_lang_reflect_Field *) field; - - if (rf == NULL) - return NULL; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - LLNI_field_get_ref(rf, f, rvmf); - LLNI_field_get_cls(rvmf, clazz, c); - LLNI_field_get_val(rvmf, slot , slot); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - LLNI_field_get_cls(rf, clazz, c); - LLNI_field_get_val(rf, slot , slot); - -#else -# error unknown configuration -#endif - - f = &(c->fields[slot]); - - return (jfieldID) f; -#else - vm_abort("jni_FromReflectedField: Not implemented in this configuration."); - - /* Keep compiler happy. */ - - return NULL; -#endif -} - - -/* ToReflectedMethod *********************************************************** - - Converts a method ID derived from cls to an instance of the - java.lang.reflect.Method class or to an instance of the - java.lang.reflect.Constructor class. - -*******************************************************************************/ - -jobject _Jv_JNI_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, - jboolean isStatic) -{ -#if defined(ENABLE_JAVASE) - methodinfo *m; - java_lang_reflect_Constructor *rc; - java_lang_reflect_Method *rm; - - TRACEJNICALLS(("_Jv_JNI_ToReflectedMethod(env=%p, cls=%p, methodID=%p, isStatic=%d)", env, cls, methodID, isStatic)); - - m = (methodinfo *) methodID; - - /* HotSpot does the same assert. */ - - assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0)); - - if (m->name == utf_init) { - rc = reflect_constructor_new(m); - - return (jobject) rc; - } - else { - rm = reflect_method_new(m); - - return (jobject) rm; - } -#else - vm_abort("_Jv_JNI_ToReflectedMethod: not implemented in this configuration"); - - /* keep compiler happy */ - - return NULL; -#endif -} - - -/* ToReflectedField ************************************************************ - - Converts a field ID derived from cls to an instance of the - java.lang.reflect.Field class. - -*******************************************************************************/ - -jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID, - jboolean isStatic) -{ - STATISTICS(jniinvokation()); - - log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!"); - - return NULL; -} - - -/* Calling Instance Methods ***************************************************/ - -/* GetMethodID ***************************************************************** - - Returns the method ID for an instance (nonstatic) method of a class - or interface. The method may be defined in one of the clazz's - superclasses and inherited by clazz. The method is determined by - its name and signature. - - GetMethodID() causes an uninitialized class to be initialized. - -*******************************************************************************/ - -jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - utf *uname; - utf *udesc; - methodinfo *m; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - - if (c == NULL) - return NULL; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return NULL; - - /* try to get the method of the class or one of it's superclasses */ - - uname = utf_new_char((char *) name); - udesc = utf_new_char((char *) sig); - - m = class_resolvemethod(c, uname, udesc); - - if ((m == NULL) || (m->flags & ACC_STATIC)) { - exceptions_throw_nosuchmethoderror(c, uname, udesc); - - return NULL; - } - - return (jmethodID) m; -} - - -/* JNI-functions for calling instance methods *********************************/ - -#define JNI_CALL_VIRTUAL_METHOD(name, type, intern) \ -type _Jv_JNI_Call##name##Method(JNIEnv *env, jobject obj, \ - jmethodID methodID, ...) \ -{ \ - java_handle_t *o; \ - methodinfo *m; \ - va_list ap; \ - type ret; \ - \ - o = (java_handle_t *) obj; \ - m = (methodinfo *) methodID; \ - \ - va_start(ap, methodID); \ - ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, ap); \ - va_end(ap); \ - \ - return ret; \ -} - -JNI_CALL_VIRTUAL_METHOD(Boolean, jboolean, Int) -JNI_CALL_VIRTUAL_METHOD(Byte, jbyte, Int) -JNI_CALL_VIRTUAL_METHOD(Char, jchar, Int) -JNI_CALL_VIRTUAL_METHOD(Short, jshort, Int) -JNI_CALL_VIRTUAL_METHOD(Int, jint, Int) -JNI_CALL_VIRTUAL_METHOD(Long, jlong, Long) -JNI_CALL_VIRTUAL_METHOD(Float, jfloat, Float) -JNI_CALL_VIRTUAL_METHOD(Double, jdouble, Double) - - -#define JNI_CALL_VIRTUAL_METHOD_V(name, type, intern) \ -type _Jv_JNI_Call##name##MethodV(JNIEnv *env, jobject obj, \ - jmethodID methodID, va_list args) \ -{ \ - java_handle_t *o; \ - methodinfo *m; \ - type ret; \ - \ - o = (java_handle_t *) obj; \ - m = (methodinfo *) methodID; \ - \ - ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, args); \ - \ - return ret; \ -} - -JNI_CALL_VIRTUAL_METHOD_V(Boolean, jboolean, Int) -JNI_CALL_VIRTUAL_METHOD_V(Byte, jbyte, Int) -JNI_CALL_VIRTUAL_METHOD_V(Char, jchar, Int) -JNI_CALL_VIRTUAL_METHOD_V(Short, jshort, Int) -JNI_CALL_VIRTUAL_METHOD_V(Int, jint, Int) -JNI_CALL_VIRTUAL_METHOD_V(Long, jlong, Long) -JNI_CALL_VIRTUAL_METHOD_V(Float, jfloat, Float) -JNI_CALL_VIRTUAL_METHOD_V(Double, jdouble, Double) - - -#define JNI_CALL_VIRTUAL_METHOD_A(name, type, intern) \ -type _Jv_JNI_Call##name##MethodA(JNIEnv *env, jobject obj, \ - jmethodID methodID, \ - const jvalue *args) \ -{ \ - java_handle_t *o; \ - methodinfo *m; \ - type ret; \ - \ - o = (java_handle_t *) obj; \ - m = (methodinfo *) methodID; \ - \ - ret = _Jv_jni_Call##intern##MethodA(o, LLNI_vftbl_direct(o), m, args); \ - \ - return ret; \ -} - -JNI_CALL_VIRTUAL_METHOD_A(Boolean, jboolean, Int) -JNI_CALL_VIRTUAL_METHOD_A(Byte, jbyte, Int) -JNI_CALL_VIRTUAL_METHOD_A(Char, jchar, Int) -JNI_CALL_VIRTUAL_METHOD_A(Short, jshort, Int) -JNI_CALL_VIRTUAL_METHOD_A(Int, jint, Int) -JNI_CALL_VIRTUAL_METHOD_A(Long, jlong, Long) -JNI_CALL_VIRTUAL_METHOD_A(Float, jfloat, Float) -JNI_CALL_VIRTUAL_METHOD_A(Double, jdouble, Double) - - -jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID, - ...) -{ - java_handle_t *o; - methodinfo *m; - java_handle_t *ret; - va_list ap; - - o = (java_handle_t *) obj; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, ap); - va_end(ap); - - return jni_NewLocalRef(env, (jobject) ret); -} - - -jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) -{ - java_handle_t *o; - methodinfo *m; - java_handle_t *ret; - - o = (java_handle_t *) obj; - m = (methodinfo *) methodID; - - ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, args); - - return jni_NewLocalRef(env, (jobject) ret); -} - - -jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) -{ - java_handle_t *o; - methodinfo *m; - java_handle_t *ret; - - o = (java_handle_t *) obj; - m = (methodinfo *) methodID; - - ret = _Jv_jni_CallObjectMethodA(o, LLNI_vftbl_direct(o), m, args); - - return jni_NewLocalRef(env, (jobject) ret); -} - - - -void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) -{ - java_handle_t *o; - methodinfo *m; - va_list ap; - - o = (java_handle_t *) obj; - m = (methodinfo *) methodID; - - va_start(ap, methodID); - _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap); - va_end(ap); -} - - -void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, - va_list args) -{ - java_handle_t *o; - methodinfo *m; - - o = (java_handle_t *) obj; - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args); -} - - -void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, - const jvalue *args) -{ - java_handle_t *o; - methodinfo *m; - - o = (java_handle_t *) obj; - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args); -} - - - -#define JNI_CALL_NONVIRTUAL_METHOD(name, type, intern) \ -type _Jv_JNI_CallNonvirtual##name##Method(JNIEnv *env, jobject obj, \ - jclass clazz, jmethodID methodID, \ - ...) \ -{ \ - java_handle_t *o; \ - classinfo *c; \ - methodinfo *m; \ - va_list ap; \ - type ret; \ - \ - o = (java_handle_t *) obj; \ - c = LLNI_classinfo_unwrap(clazz); \ - m = (methodinfo *) methodID; \ - \ - va_start(ap, methodID); \ - ret = _Jv_jni_Call##intern##Method(o, c->vftbl, m, ap); \ - va_end(ap); \ - \ - return ret; \ -} - -JNI_CALL_NONVIRTUAL_METHOD(Boolean, jboolean, Int) -JNI_CALL_NONVIRTUAL_METHOD(Byte, jbyte, Int) -JNI_CALL_NONVIRTUAL_METHOD(Char, jchar, Int) -JNI_CALL_NONVIRTUAL_METHOD(Short, jshort, Int) -JNI_CALL_NONVIRTUAL_METHOD(Int, jint, Int) -JNI_CALL_NONVIRTUAL_METHOD(Long, jlong, Long) -JNI_CALL_NONVIRTUAL_METHOD(Float, jfloat, Float) -JNI_CALL_NONVIRTUAL_METHOD(Double, jdouble, Double) - - -#define JNI_CALL_NONVIRTUAL_METHOD_V(name, type, intern) \ -type _Jv_JNI_CallNonvirtual##name##MethodV(JNIEnv *env, jobject obj, \ - jclass clazz, jmethodID methodID, \ - va_list args) \ -{ \ - java_handle_t *o; \ - classinfo *c; \ - methodinfo *m; \ - type ret; \ - \ - o = (java_handle_t *) obj; \ - c = LLNI_classinfo_unwrap(clazz); \ - m = (methodinfo *) methodID; \ - \ - ret = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); \ - \ - return ret; \ -} - -JNI_CALL_NONVIRTUAL_METHOD_V(Boolean, jboolean, Int) -JNI_CALL_NONVIRTUAL_METHOD_V(Byte, jbyte, Int) -JNI_CALL_NONVIRTUAL_METHOD_V(Char, jchar, Int) -JNI_CALL_NONVIRTUAL_METHOD_V(Short, jshort, Int) -JNI_CALL_NONVIRTUAL_METHOD_V(Int, jint, Int) -JNI_CALL_NONVIRTUAL_METHOD_V(Long, jlong, Long) -JNI_CALL_NONVIRTUAL_METHOD_V(Float, jfloat, Float) -JNI_CALL_NONVIRTUAL_METHOD_V(Double, jdouble, Double) - - -#define JNI_CALL_NONVIRTUAL_METHOD_A(name, type, intern) \ -type _Jv_JNI_CallNonvirtual##name##MethodA(JNIEnv *env, jobject obj, \ - jclass clazz, jmethodID methodID, \ - const jvalue *args) \ -{ \ - log_text("JNI-Call: CallNonvirtual##name##MethodA: IMPLEMENT ME!"); \ - \ - return 0; \ -} - -JNI_CALL_NONVIRTUAL_METHOD_A(Boolean, jboolean, Int) -JNI_CALL_NONVIRTUAL_METHOD_A(Byte, jbyte, Int) -JNI_CALL_NONVIRTUAL_METHOD_A(Char, jchar, Int) -JNI_CALL_NONVIRTUAL_METHOD_A(Short, jshort, Int) -JNI_CALL_NONVIRTUAL_METHOD_A(Int, jint, Int) -JNI_CALL_NONVIRTUAL_METHOD_A(Long, jlong, Long) -JNI_CALL_NONVIRTUAL_METHOD_A(Float, jfloat, Float) -JNI_CALL_NONVIRTUAL_METHOD_A(Double, jdouble, Double) - -jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - ...) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - java_handle_t *r; - va_list ap; - - o = (java_handle_t *) obj; - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - va_start(ap, methodID); - r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap); - va_end(ap); - - return jni_NewLocalRef(env, (jobject) r); -} - - -jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - va_list args) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - java_handle_t *r; - - o = (java_handle_t *) obj; - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args); - - return jni_NewLocalRef(env, (jobject) r); -} - - -jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj, - jclass clazz, jmethodID methodID, - const jvalue *args) -{ - log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!"); - - return jni_NewLocalRef(env, NULL); -} - - -void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, ...) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - va_list ap; - - o = (java_handle_t *) obj; - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - va_start(ap, methodID); - _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap); - va_end(ap); -} - - -void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, va_list args) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - - o = (java_handle_t *) obj; - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethod(o, c->vftbl, m, args); -} - - -void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz, - jmethodID methodID, const jvalue * args) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - - o = (java_handle_t *) obj; - c = LLNI_classinfo_unwrap(clazz); - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args); -} - - -/* Accessing Fields of Objects ************************************************/ - -/* GetFieldID ****************************************************************** - - Returns the field ID for an instance (nonstatic) field of a - class. The field is specified by its name and signature. The - GetField and SetField families of accessor functions - use field IDs to retrieve object fields. - -*******************************************************************************/ - -jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - fieldinfo *f; - utf *uname; - utf *udesc; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - - /* XXX NPE check? */ - - uname = utf_new_char((char *) name); - udesc = utf_new_char((char *) sig); - - f = class_findfield(c, uname, udesc); - - if (f == NULL) - exceptions_throw_nosuchfielderror(c, uname); - - return (jfieldID) f; -} - - -/* GetField Routines ***************************************************** - - This family of accessor routines returns the value of an instance - (nonstatic) field of an object. The field to access is specified by - a field ID obtained by calling GetFieldID(). - -*******************************************************************************/ - -#define GET_FIELD(o,type,f) \ - *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) - -#define JNI_GET_FIELD(name, type, intern) \ -type _Jv_JNI_Get##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID) \ -{ \ - intern ret; \ - \ - TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "Field(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID)); \ - \ - LLNI_CRITICAL_START; \ - \ - ret = GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID); \ - \ - LLNI_CRITICAL_END; \ - \ - return (type) ret; \ -} - -JNI_GET_FIELD(Boolean, jboolean, s4) -JNI_GET_FIELD(Byte, jbyte, s4) -JNI_GET_FIELD(Char, jchar, s4) -JNI_GET_FIELD(Short, jshort, s4) -JNI_GET_FIELD(Int, jint, s4) -JNI_GET_FIELD(Long, jlong, s8) -JNI_GET_FIELD(Float, jfloat, float) -JNI_GET_FIELD(Double, jdouble, double) - - -jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID) -{ - java_handle_t *o; - - TRACEJNICALLS(("_Jv_JNI_GetObjectField(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID)); - - LLNI_CRITICAL_START; - - o = LLNI_WRAP(GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), java_object_t*, fieldID)); - - LLNI_CRITICAL_END; - - return jni_NewLocalRef(env, (jobject) o); -} - - -/* SetField Routines ***************************************************** - - This family of accessor routines sets the value of an instance - (nonstatic) field of an object. The field to access is specified by - a field ID obtained by calling GetFieldID(). - -*******************************************************************************/ - -#define SET_FIELD(o,type,f,value) \ - *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) = (type) (value) - -#define JNI_SET_FIELD(name, type, intern) \ -void _Jv_JNI_Set##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID, \ - type value) \ -{ \ - TRACEJNICALLS(("_Jv_JNI_Set" STR(name) "Field(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value)); \ - \ - LLNI_CRITICAL_START; \ - \ - SET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID, value); \ - \ - LLNI_CRITICAL_START; \ -} - -JNI_SET_FIELD(Boolean, jboolean, s4) -JNI_SET_FIELD(Byte, jbyte, s4) -JNI_SET_FIELD(Char, jchar, s4) -JNI_SET_FIELD(Short, jshort, s4) -JNI_SET_FIELD(Int, jint, s4) -JNI_SET_FIELD(Long, jlong, s8) -JNI_SET_FIELD(Float, jfloat, float) -JNI_SET_FIELD(Double, jdouble, double) - - -void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, - jobject value) -{ - TRACEJNICALLS(("_Jv_JNI_SetObjectField(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value)); - - LLNI_CRITICAL_START; - - SET_FIELD(obj, java_handle_t*, fieldID, LLNI_UNWRAP((java_handle_t*) value)); - - LLNI_CRITICAL_END; -} - - -/* Calling Static Methods *****************************************************/ - -/* GetStaticMethodID *********************************************************** - - Returns the method ID for a static method of a class. The method is - specified by its name and signature. - - GetStaticMethodID() causes an uninitialized class to be - initialized. - -*******************************************************************************/ - -jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - utf *uname; - utf *udesc; - methodinfo *m; - - TRACEJNICALLS(("_Jv_JNI_GetStaticMethodID(env=%p, clazz=%p, name=%s, sig=%s)", env, clazz, name, sig)); - - c = LLNI_classinfo_unwrap(clazz); - - if (c == NULL) - return NULL; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return NULL; - - /* try to get the static method of the class */ - - uname = utf_new_char((char *) name); - udesc = utf_new_char((char *) sig); - - m = class_resolvemethod(c, uname, udesc); - - if ((m == NULL) || !(m->flags & ACC_STATIC)) { - exceptions_throw_nosuchmethoderror(c, uname, udesc); - - return NULL; - } - - return (jmethodID) m; -} - - -#define JNI_CALL_STATIC_METHOD(name, type, intern) \ -type _Jv_JNI_CallStatic##name##Method(JNIEnv *env, jclass clazz, \ - jmethodID methodID, ...) \ -{ \ - methodinfo *m; \ - va_list ap; \ - type res; \ - \ - m = (methodinfo *) methodID; \ - \ - va_start(ap, methodID); \ - res = _Jv_jni_Call##intern##Method(NULL, NULL, m, ap); \ - va_end(ap); \ - \ - return res; \ -} - -JNI_CALL_STATIC_METHOD(Boolean, jboolean, Int) -JNI_CALL_STATIC_METHOD(Byte, jbyte, Int) -JNI_CALL_STATIC_METHOD(Char, jchar, Int) -JNI_CALL_STATIC_METHOD(Short, jshort, Int) -JNI_CALL_STATIC_METHOD(Int, jint, Int) -JNI_CALL_STATIC_METHOD(Long, jlong, Long) -JNI_CALL_STATIC_METHOD(Float, jfloat, Float) -JNI_CALL_STATIC_METHOD(Double, jdouble, Double) - - -#define JNI_CALL_STATIC_METHOD_V(name, type, intern) \ -type _Jv_JNI_CallStatic##name##MethodV(JNIEnv *env, jclass clazz, \ - jmethodID methodID, va_list args) \ -{ \ - methodinfo *m; \ - type res; \ - \ - m = (methodinfo *) methodID; \ - \ - res = _Jv_jni_Call##intern##Method(NULL, NULL, m, args); \ - \ - return res; \ -} - -JNI_CALL_STATIC_METHOD_V(Boolean, jboolean, Int) -JNI_CALL_STATIC_METHOD_V(Byte, jbyte, Int) -JNI_CALL_STATIC_METHOD_V(Char, jchar, Int) -JNI_CALL_STATIC_METHOD_V(Short, jshort, Int) -JNI_CALL_STATIC_METHOD_V(Int, jint, Int) -JNI_CALL_STATIC_METHOD_V(Long, jlong, Long) -JNI_CALL_STATIC_METHOD_V(Float, jfloat, Float) -JNI_CALL_STATIC_METHOD_V(Double, jdouble, Double) - - -#define JNI_CALL_STATIC_METHOD_A(name, type, intern) \ -type _Jv_JNI_CallStatic##name##MethodA(JNIEnv *env, jclass clazz, \ - jmethodID methodID, const jvalue *args) \ -{ \ - methodinfo *m; \ - type res; \ - \ - m = (methodinfo *) methodID; \ - \ - res = _Jv_jni_Call##intern##MethodA(NULL, NULL, m, args); \ - \ - return res; \ -} - -JNI_CALL_STATIC_METHOD_A(Boolean, jboolean, Int) -JNI_CALL_STATIC_METHOD_A(Byte, jbyte, Int) -JNI_CALL_STATIC_METHOD_A(Char, jchar, Int) -JNI_CALL_STATIC_METHOD_A(Short, jshort, Int) -JNI_CALL_STATIC_METHOD_A(Int, jint, Int) -JNI_CALL_STATIC_METHOD_A(Long, jlong, Long) -JNI_CALL_STATIC_METHOD_A(Float, jfloat, Float) -JNI_CALL_STATIC_METHOD_A(Double, jdouble, Double) - - -jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - java_handle_t *o; - va_list ap; - - TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID)); - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap); - va_end(ap); - - return jni_NewLocalRef(env, (jobject) o); -} - - -jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - java_handle_t *o; - - TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); - - m = (methodinfo *) methodID; - - o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args); - - return jni_NewLocalRef(env, (jobject) o); -} - - -jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue *args) -{ - methodinfo *m; - java_handle_t *o; - - TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); - - m = (methodinfo *) methodID; - - o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args); - - return jni_NewLocalRef(env, (jobject) o); -} - - -void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz, - jmethodID methodID, ...) -{ - methodinfo *m; - va_list ap; - - TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID)); - - m = (methodinfo *) methodID; - - va_start(ap, methodID); - _Jv_jni_CallVoidMethod(NULL, NULL, m, ap); - va_end(ap); -} - - -void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz, - jmethodID methodID, va_list args) -{ - methodinfo *m; - - TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); - - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethod(NULL, NULL, m, args); -} - - -void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz, - jmethodID methodID, const jvalue * args) -{ - methodinfo *m; - - TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); - - m = (methodinfo *) methodID; - - _Jv_jni_CallVoidMethodA(NULL, NULL, m, args); -} - - -/* Accessing Static Fields ****************************************************/ - -/* GetStaticFieldID ************************************************************ - - Returns the field ID for a static field of a class. The field is - specified by its name and signature. The GetStaticField and - SetStaticField families of accessor functions use field IDs - to retrieve static fields. - -*******************************************************************************/ - -jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, - const char *sig) -{ - classinfo *c; - fieldinfo *f; - utf *uname; - utf *usig; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - - uname = utf_new_char((char *) name); - usig = utf_new_char((char *) sig); - - f = class_findfield(c, uname, usig); - - if (f == NULL) - exceptions_throw_nosuchfielderror(c, uname); - - return (jfieldID) f; -} - - -/* GetStaticField ******************************************************** - - This family of accessor routines returns the value of a static - field of an object. - -*******************************************************************************/ - -#define JNI_GET_STATIC_FIELD(name, type, field) \ -type _Jv_JNI_GetStatic##name##Field(JNIEnv *env, jclass clazz, \ - jfieldID fieldID) \ -{ \ - classinfo *c; \ - fieldinfo *f; \ - \ - STATISTICS(jniinvokation()); \ - \ - c = LLNI_classinfo_unwrap(clazz); \ - f = (fieldinfo *) fieldID; \ - \ - if (!(c->state & CLASS_INITIALIZED)) \ - if (!initialize_class(c)) \ - return 0; \ - \ - return f->value->field; \ -} - -JNI_GET_STATIC_FIELD(Boolean, jboolean, i) -JNI_GET_STATIC_FIELD(Byte, jbyte, i) -JNI_GET_STATIC_FIELD(Char, jchar, i) -JNI_GET_STATIC_FIELD(Short, jshort, i) -JNI_GET_STATIC_FIELD(Int, jint, i) -JNI_GET_STATIC_FIELD(Long, jlong, l) -JNI_GET_STATIC_FIELD(Float, jfloat, f) -JNI_GET_STATIC_FIELD(Double, jdouble, d) - - -jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz, - jfieldID fieldID) -{ - classinfo *c; - fieldinfo *f; - java_handle_t *h; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return NULL; - - h = LLNI_WRAP(f->value->a); - - return jni_NewLocalRef(env, (jobject) h); -} - - -/* SetStaticField ******************************************************* - - This family of accessor routines sets the value of a static field - of an object. - -*******************************************************************************/ - -#define JNI_SET_STATIC_FIELD(name, type, field) \ -void _Jv_JNI_SetStatic##name##Field(JNIEnv *env, jclass clazz, \ - jfieldID fieldID, \ - type value) \ -{ \ - classinfo *c; \ - fieldinfo *f; \ - \ - STATISTICS(jniinvokation()); \ - \ - c = LLNI_classinfo_unwrap(clazz); \ - f = (fieldinfo *) fieldID; \ - \ - if (!(c->state & CLASS_INITIALIZED)) \ - if (!initialize_class(c)) \ - return; \ - \ - f->value->field = value; \ -} - -JNI_SET_STATIC_FIELD(Boolean, jboolean, i) -JNI_SET_STATIC_FIELD(Byte, jbyte, i) -JNI_SET_STATIC_FIELD(Char, jchar, i) -JNI_SET_STATIC_FIELD(Short, jshort, i) -JNI_SET_STATIC_FIELD(Int, jint, i) -JNI_SET_STATIC_FIELD(Long, jlong, l) -JNI_SET_STATIC_FIELD(Float, jfloat, f) -JNI_SET_STATIC_FIELD(Double, jdouble, d) - - -void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, - jobject value) -{ - classinfo *c; - fieldinfo *f; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - f = (fieldinfo *) fieldID; - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return; - - f->value->a = LLNI_UNWRAP((java_handle_t *) value); -} - - -/* String Operations **********************************************************/ - -/* NewString ******************************************************************* - - Create new java.lang.String object from an array of Unicode - characters. - -*******************************************************************************/ - -jstring _Jv_JNI_NewString(JNIEnv *env, const jchar *buf, jsize len) -{ - java_lang_String *s; - java_handle_chararray_t *a; - u4 i; - - STATISTICS(jniinvokation()); - - s = (java_lang_String *) builtin_new(class_java_lang_String); - a = builtin_newarray_char(len); - - /* javastring or characterarray could not be created */ - if ((a == NULL) || (s == NULL)) - return NULL; - - /* copy text */ - for (i = 0; i < len; i++) - LLNI_array_direct(a, i) = buf[i]; - - LLNI_field_set_ref(s, value , a); - LLNI_field_set_val(s, offset, 0); - LLNI_field_set_val(s, count , len); - - return (jstring) jni_NewLocalRef(env, (jobject) s); -} - - -static jchar emptyStringJ[]={0,0}; - -/* GetStringLength ************************************************************* - - Returns the length (the count of Unicode characters) of a Java - string. - -*******************************************************************************/ - -jsize _Jv_JNI_GetStringLength(JNIEnv *env, jstring str) -{ - java_lang_String *s; - jsize len; - - TRACEJNICALLS(("_Jv_JNI_GetStringLength(env=%p, str=%p)", env, str)); - - s = (java_lang_String *) str; - - LLNI_field_get_val(s, count, len); - - return len; -} - - -/******************** convertes javastring to u2-array ****************************/ - -u2 *javastring_tou2(jstring so) -{ - java_lang_String *s; - java_handle_chararray_t *a; - u2 *stringbuffer; - u4 i; - int32_t count; - int32_t offset; - - STATISTICS(jniinvokation()); - - s = (java_lang_String *) so; - - if (!s) - return NULL; - - LLNI_field_get_ref(s, value, a); - - if (!a) - return NULL; - - LLNI_field_get_val(s, count, count); - LLNI_field_get_val(s, offset, offset); - - /* allocate memory */ - - stringbuffer = MNEW(u2, count + 1); - - /* copy text */ - - for (i = 0; i < count; i++) - stringbuffer[i] = LLNI_array_direct(a, offset + i); - - /* terminate string */ - - stringbuffer[i] = '\0'; - - return stringbuffer; -} - - -/* GetStringChars ************************************************************** - - Returns a pointer to the array of Unicode characters of the - string. This pointer is valid until ReleaseStringChars() is called. - -*******************************************************************************/ - -const jchar *_Jv_JNI_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy) -{ - jchar *jc; - - STATISTICS(jniinvokation()); - - jc = javastring_tou2(str); - - if (jc) { - if (isCopy) - *isCopy = JNI_TRUE; - - return jc; - } - - if (isCopy) - *isCopy = JNI_TRUE; - - return emptyStringJ; -} - - -/* ReleaseStringChars ********************************************************** - - Informs the VM that the native code no longer needs access to - chars. The chars argument is a pointer obtained from string using - GetStringChars(). - -*******************************************************************************/ - -void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars) -{ - java_lang_String *s; - - STATISTICS(jniinvokation()); - - if (chars == emptyStringJ) - return; - - s = (java_lang_String *) str; - - MFREE(((jchar *) chars), jchar, LLNI_field_direct(s, count) + 1); -} - - -/* NewStringUTF **************************************************************** - - Constructs a new java.lang.String object from an array of UTF-8 - characters. - -*******************************************************************************/ - -jstring _Jv_JNI_NewStringUTF(JNIEnv *env, const char *bytes) -{ - java_lang_String *s; - - TRACEJNICALLS(("_Jv_JNI_NewStringUTF(env=%p, bytes=%s)", env, bytes)); - - s = (java_lang_String *) javastring_safe_new_from_utf8(bytes); - - return (jstring) jni_NewLocalRef(env, (jobject) s); -} - - -/****************** returns the utf8 length in bytes of a string *******************/ - -jsize _Jv_JNI_GetStringUTFLength(JNIEnv *env, jstring string) -{ - java_lang_String *s; - s4 length; - - TRACEJNICALLS(("_Jv_JNI_GetStringUTFLength(env=%p, string=%p)", env, string)); - - s = (java_lang_String *) string; - - length = u2_utflength(LLNI_field_direct(s, value)->data, LLNI_field_direct(s, count)); - - return length; -} - - -/* GetStringUTFChars *********************************************************** - - Returns a pointer to an array of UTF-8 characters of the - string. This array is valid until it is released by - ReleaseStringUTFChars(). - -*******************************************************************************/ - -const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string, - jboolean *isCopy) -{ - utf *u; - - STATISTICS(jniinvokation()); - - if (string == NULL) - return ""; - - if (isCopy) - *isCopy = JNI_TRUE; - - u = javastring_toutf((java_handle_t *) string, false); - - if (u != NULL) - return u->text; - - return ""; -} - - -/* ReleaseStringUTFChars ******************************************************* - - Informs the VM that the native code no longer needs access to - utf. The utf argument is a pointer derived from string using - GetStringUTFChars(). - -*******************************************************************************/ - -void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf) -{ - STATISTICS(jniinvokation()); - - /* XXX we don't release utf chars right now, perhaps that should be done - later. Since there is always one reference the garbage collector will - never get them */ -} - - -/* Array Operations ***********************************************************/ - -/* GetArrayLength ************************************************************** - - Returns the number of elements in the array. - -*******************************************************************************/ - -jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array) -{ - java_handle_t *a; - jsize size; - - TRACEJNICALLS(("_Jv_JNI_GetArrayLength(env=%p, array=%p)", env, array)); - - a = (java_handle_t *) array; - - size = LLNI_array_size(a); - - return size; -} - - -/* NewObjectArray ************************************************************** - - Constructs a new array holding objects in class elementClass. All - elements are initially set to initialElement. - -*******************************************************************************/ - -jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length, - jclass elementClass, jobject initialElement) -{ - classinfo *c; - java_handle_t *o; - java_handle_objectarray_t *oa; - s4 i; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(elementClass); - o = (java_handle_t *) initialElement; - - if (length < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } - - oa = builtin_anewarray(length, c); - - if (oa == NULL) - return NULL; - - /* set all elements to initialElement */ - - for (i = 0; i < length; i++) - array_objectarray_element_set(oa, i, o); - - return (jobjectArray) jni_NewLocalRef(env, (jobject) oa); -} - - -jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array, - jsize index) -{ - java_handle_objectarray_t *oa; - java_handle_t *o; - - STATISTICS(jniinvokation()); - - oa = (java_handle_objectarray_t *) array; - - if (index >= LLNI_array_size(oa)) { - exceptions_throw_arrayindexoutofboundsexception(); - return NULL; - } - - o = array_objectarray_element_get(oa, index); - - return jni_NewLocalRef(env, (jobject) o); -} - - -void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array, - jsize index, jobject val) -{ - java_handle_objectarray_t *oa; - java_handle_t *o; - - STATISTICS(jniinvokation()); - - oa = (java_handle_objectarray_t *) array; - o = (java_handle_t *) val; - - if (index >= LLNI_array_size(oa)) { - exceptions_throw_arrayindexoutofboundsexception(); - return; - } - - /* check if the class of value is a subclass of the element class - of the array */ - - if (!builtin_canstore(oa, o)) - return; - - array_objectarray_element_set(oa, index, o); -} - - -#define JNI_NEW_ARRAY(name, type, intern) \ -type _Jv_JNI_New##name##Array(JNIEnv *env, jsize len) \ -{ \ - java_handle_##intern##array_t *a; \ - \ - STATISTICS(jniinvokation()); \ - \ - if (len < 0) { \ - exceptions_throw_negativearraysizeexception(); \ - return NULL; \ - } \ - \ - a = builtin_newarray_##intern(len); \ - \ - return (type) jni_NewLocalRef(env, (jobject) a); \ -} - -JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean) -JNI_NEW_ARRAY(Byte, jbyteArray, byte) -JNI_NEW_ARRAY(Char, jcharArray, char) -JNI_NEW_ARRAY(Short, jshortArray, short) -JNI_NEW_ARRAY(Int, jintArray, int) -JNI_NEW_ARRAY(Long, jlongArray, long) -JNI_NEW_ARRAY(Float, jfloatArray, float) -JNI_NEW_ARRAY(Double, jdoubleArray, double) - - -/* GetArrayElements ********************************************* - - A family of functions that returns the body of the primitive array. - -*******************************************************************************/ - -#define JNI_GET_ARRAY_ELEMENTS(name, type, intern) \ -type *_Jv_JNI_Get##name##ArrayElements(JNIEnv *env, type##Array array, \ - jboolean *isCopy) \ -{ \ - java_handle_##intern##array_t *a; \ - \ - TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayElements(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); \ - \ - a = (java_handle_##intern##array_t *) array; \ - \ - if (isCopy) \ - *isCopy = JNI_FALSE; \ - \ - return (type *) LLNI_array_data(a); \ -} - -JNI_GET_ARRAY_ELEMENTS(Boolean, jboolean, boolean) -JNI_GET_ARRAY_ELEMENTS(Byte, jbyte, byte) -JNI_GET_ARRAY_ELEMENTS(Char, jchar, char) -JNI_GET_ARRAY_ELEMENTS(Short, jshort, short) -JNI_GET_ARRAY_ELEMENTS(Int, jint, int) -JNI_GET_ARRAY_ELEMENTS(Long, jlong, long) -JNI_GET_ARRAY_ELEMENTS(Float, jfloat, float) -JNI_GET_ARRAY_ELEMENTS(Double, jdouble, double) - - -/* ReleaseArrayElements ***************************************** - - A family of functions that informs the VM that the native code no - longer needs access to elems. The elems argument is a pointer - derived from array using the corresponding - GetArrayElements() function. If necessary, this - function copies back all changes made to elems to the original - array. - -*******************************************************************************/ - -#define JNI_RELEASE_ARRAY_ELEMENTS(name, type, intern, intern2) \ -void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array, \ - type *elems, jint mode) \ -{ \ - java_handle_##intern##array_t *a; \ - \ - STATISTICS(jniinvokation()); \ - \ - a = (java_handle_##intern##array_t *) array; \ - \ - if (elems != (type *) LLNI_array_data(a)) { \ - switch (mode) { \ - case JNI_COMMIT: \ - MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \ - break; \ - case 0: \ - MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \ - /* XXX TWISTI how should it be freed? */ \ - break; \ - case JNI_ABORT: \ - /* XXX TWISTI how should it be freed? */ \ - break; \ - } \ - } \ -} - -JNI_RELEASE_ARRAY_ELEMENTS(Boolean, jboolean, boolean, u1) -JNI_RELEASE_ARRAY_ELEMENTS(Byte, jbyte, byte, s1) -JNI_RELEASE_ARRAY_ELEMENTS(Char, jchar, char, u2) -JNI_RELEASE_ARRAY_ELEMENTS(Short, jshort, short, s2) -JNI_RELEASE_ARRAY_ELEMENTS(Int, jint, int, s4) -JNI_RELEASE_ARRAY_ELEMENTS(Long, jlong, long, s8) -JNI_RELEASE_ARRAY_ELEMENTS(Float, jfloat, float, float) -JNI_RELEASE_ARRAY_ELEMENTS(Double, jdouble, double, double) - - -/* GetArrayRegion ********************************************** - - A family of functions that copies a region of a primitive array - into a buffer. - -*******************************************************************************/ - -#define JNI_GET_ARRAY_REGION(name, type, intern, intern2) \ -void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array, \ - jsize start, jsize len, type *buf) \ -{ \ - java_handle_##intern##array_t *a; \ - \ - TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayRegion(env=%p, array=%p, start=%d, len=%d, buf=%p)", env, array, start, len, buf)); \ - \ - a = (java_handle_##intern##array_t *) array; \ - \ - if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \ - exceptions_throw_arrayindexoutofboundsexception(); \ - else \ - MCOPY(buf, &LLNI_array_direct(a, start), intern2, len); \ -} - -JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1) -JNI_GET_ARRAY_REGION(Byte, jbyte, byte, s1) -JNI_GET_ARRAY_REGION(Char, jchar, char, u2) -JNI_GET_ARRAY_REGION(Short, jshort, short, s2) -JNI_GET_ARRAY_REGION(Int, jint, int, s4) -JNI_GET_ARRAY_REGION(Long, jlong, long, s8) -JNI_GET_ARRAY_REGION(Float, jfloat, float, float) -JNI_GET_ARRAY_REGION(Double, jdouble, double, double) - - -/* SetArrayRegion ********************************************** - - A family of functions that copies back a region of a primitive - array from a buffer. - -*******************************************************************************/ - -#define JNI_SET_ARRAY_REGION(name, type, intern, intern2) \ -void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array, \ - jsize start, jsize len, const type *buf) \ -{ \ - java_handle_##intern##array_t *a; \ - \ - STATISTICS(jniinvokation()); \ - \ - a = (java_handle_##intern##array_t *) array; \ - \ - if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \ - exceptions_throw_arrayindexoutofboundsexception(); \ - else \ - MCOPY(&LLNI_array_direct(a, start), buf, intern2, len); \ -} - -JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1) -JNI_SET_ARRAY_REGION(Byte, jbyte, byte, s1) -JNI_SET_ARRAY_REGION(Char, jchar, char, u2) -JNI_SET_ARRAY_REGION(Short, jshort, short, s2) -JNI_SET_ARRAY_REGION(Int, jint, int, s4) -JNI_SET_ARRAY_REGION(Long, jlong, long, s8) -JNI_SET_ARRAY_REGION(Float, jfloat, float, float) -JNI_SET_ARRAY_REGION(Double, jdouble, double, double) - - -/* Registering Native Methods *************************************************/ - -/* RegisterNatives ************************************************************* - - Registers native methods with the class specified by the clazz - argument. The methods parameter specifies an array of - JNINativeMethod structures that contain the names, signatures, and - function pointers of the native methods. The nMethods parameter - specifies the number of native methods in the array. - -*******************************************************************************/ - -jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz, - const JNINativeMethod *methods, jint nMethods) -{ - classinfo *c; - - STATISTICS(jniinvokation()); - - c = LLNI_classinfo_unwrap(clazz); - - /* XXX: if implemented this needs a call to jvmti_NativeMethodBind - if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr); - */ - - native_method_register(c->name, methods, nMethods); - - return 0; -} - - -/* UnregisterNatives *********************************************************** - - Unregisters native methods of a class. The class goes back to the - state before it was linked or registered with its native method - functions. - - This function should not be used in normal native code. Instead, it - provides special programs a way to reload and relink native - libraries. - -*******************************************************************************/ - -jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz) -{ - STATISTICS(jniinvokation()); - - /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */ - - log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!"); - - return 0; -} - - -/* Monitor Operations *********************************************************/ - -/* MonitorEnter **************************************************************** - - Enters the monitor associated with the underlying Java object - referred to by obj. - -*******************************************************************************/ - -jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj) -{ - STATISTICS(jniinvokation()); - - if (obj == NULL) { - exceptions_throw_nullpointerexception(); - return JNI_ERR; - } - - LOCK_MONITOR_ENTER(obj); - - return JNI_OK; -} - - -/* MonitorExit ***************************************************************** - - The current thread must be the owner of the monitor associated with - the underlying Java object referred to by obj. The thread - decrements the counter indicating the number of times it has - entered this monitor. If the value of the counter becomes zero, the - current thread releases the monitor. - -*******************************************************************************/ - -jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj) -{ - STATISTICS(jniinvokation()); - - if (obj == NULL) { - exceptions_throw_nullpointerexception(); - return JNI_ERR; - } - - LOCK_MONITOR_EXIT(obj); - - return JNI_OK; -} - - -/* JavaVM Interface ***********************************************************/ - -/* GetJavaVM ******************************************************************* - - Returns the Java VM interface (used in the Invocation API) - associated with the current thread. The result is placed at the - location pointed to by the second argument, vm. - -*******************************************************************************/ - -jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **vm) -{ - STATISTICS(jniinvokation()); - - *vm = (JavaVM *) _Jv_jvm; - - return 0; -} - - -/* GetStringRegion ************************************************************* - - Copies len number of Unicode characters beginning at offset start - to the given buffer buf. - - Throws StringIndexOutOfBoundsException on index overflow. - -*******************************************************************************/ - -void _Jv_JNI_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, - jchar *buf) -{ - java_lang_String *s; - java_handle_chararray_t *ca; - - STATISTICS(jniinvokation()); - - s = (java_lang_String *) str; - LLNI_field_get_ref(s, value, ca); - - if ((start < 0) || (len < 0) || (start > LLNI_field_direct(s, count)) || - (start + len > LLNI_field_direct(s, count))) { - exceptions_throw_stringindexoutofboundsexception(); - return; - } - - MCOPY(buf, &LLNI_array_direct(ca, start), u2, len); -} - - -/* GetStringUTFRegion ********************************************************** - - Translates len number of Unicode characters beginning at offset - start into UTF-8 format and place the result in the given buffer - buf. - - Throws StringIndexOutOfBoundsException on index overflow. - -*******************************************************************************/ - -void _Jv_JNI_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start, - jsize len, char *buf) -{ - java_lang_String *s; - java_handle_chararray_t *ca; - s4 i; - int32_t count; - int32_t offset; - - TRACEJNICALLS(("_Jv_JNI_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf)); - - s = (java_lang_String *) str; - LLNI_field_get_ref(s, value, ca); - LLNI_field_get_val(s, count, count); - LLNI_field_get_val(s, offset, offset); - - if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) { - exceptions_throw_stringindexoutofboundsexception(); - return; - } - - for (i = 0; i < len; i++) - buf[i] = LLNI_array_direct(ca, offset + start + i); - - buf[i] = '\0'; -} - - -/* GetPrimitiveArrayCritical *************************************************** - - Obtain a direct pointer to array elements. - - ATTENTION: Critical section keeps open when this function returns! - See ReleasePrimitiveArrayCritical. - -*******************************************************************************/ - -void* jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy) -{ - java_handle_t* h; - java_array_t* a; - arraydescriptor* ad; - void* data; - - TRACEJNICALLS(("jni_GetPrimitiveArrayCritical(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); - - if (isCopy != NULL) { - *isCopy = JNI_FALSE; - } - - LLNI_CRITICAL_START; - - h = (java_handle_t*) array; - a = (java_array_t*) LLNI_UNWRAP(h); - ad = a->objheader.vftbl->arraydesc; - - /* Sanity check. */ - - assert(ad != NULL); - - data = (void*) (((intptr_t) a) + ad->dataoffset); - - return data; -} - - -/* ReleasePrimitiveArrayCritical *********************************************** - - No specific documentation. - - ATTENTION: This function closes the critical section opened in - GetPrimitiveArrayCritical! - -*******************************************************************************/ - -void jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode) -{ - TRACEJNICALLS(("jni_ReleasePrimitiveArrayCritical(env=%p, array=%p, carray=%p, mode=%d)", env, array, carray, mode)); - - LLNI_CRITICAL_END; -} - - -/* GetStringCritical *********************************************************** - - The semantics of these two functions are similar to the existing - Get/ReleaseStringChars functions. - -*******************************************************************************/ - -const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string, - jboolean *isCopy) -{ - STATISTICS(jniinvokation()); - - return _Jv_JNI_GetStringChars(env, string, isCopy); -} - - -void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string, - const jchar *cstring) -{ - STATISTICS(jniinvokation()); - - _Jv_JNI_ReleaseStringChars(env, string, cstring); -} - - -jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj) -{ - TRACEJNICALLS(("_Jv_JNI_NewWeakGlobalRef(env=%p, obj=%p): IMPLEMENT ME!", env, obj)); - - return obj; -} - - -void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref) -{ - TRACEJNICALLS(("_Jv_JNI_DeleteWeakGlobalRef(env=%p, ref=%p): IMPLEMENT ME", env, ref)); -} - - -/* NewGlobalRef **************************************************************** - - Creates a new global reference to the object referred to by the obj - argument. - -*******************************************************************************/ - -jobject _Jv_JNI_NewGlobalRef(JNIEnv* env, jobject obj) -{ - hashtable_global_ref_entry *gre; - u4 key; /* hashkey */ - u4 slot; /* slot in hashtable */ - java_handle_t *o; - - STATISTICS(jniinvokation()); - - o = (java_handle_t *) obj; - - LOCK_MONITOR_ENTER(hashtable_global_ref->header); - - LLNI_CRITICAL_START; - - /* normally addresses are aligned to 4, 8 or 16 bytes */ - - key = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */ - slot = key & (hashtable_global_ref->size - 1); - gre = hashtable_global_ref->ptr[slot]; - - /* search external hash chain for the entry */ - - while (gre) { - if (gre->o == LLNI_DIRECT(o)) { - /* global object found, increment the reference */ - - gre->refs++; - - break; - } - - gre = gre->hashlink; /* next element in external chain */ - } - - LLNI_CRITICAL_END; - - /* global ref not found, create a new one */ - - if (gre == NULL) { - gre = NEW(hashtable_global_ref_entry); - -#if defined(ENABLE_GC_CACAO) - /* register global ref with the GC */ - - gc_reference_register(&(gre->o), GC_REFTYPE_JNI_GLOBALREF); -#endif - - LLNI_CRITICAL_START; - - gre->o = LLNI_DIRECT(o); - gre->refs = 1; - - LLNI_CRITICAL_END; - - /* insert entry into hashtable */ - - gre->hashlink = hashtable_global_ref->ptr[slot]; - - hashtable_global_ref->ptr[slot] = gre; - - /* update number of hashtable-entries */ - - hashtable_global_ref->entries++; - } - - LOCK_MONITOR_EXIT(hashtable_global_ref->header); - -#if defined(ENABLE_HANDLES) - return gre; -#else - return obj; -#endif -} - - -/* DeleteGlobalRef ************************************************************* - - Deletes the global reference pointed to by globalRef. - -*******************************************************************************/ - -void _Jv_JNI_DeleteGlobalRef(JNIEnv* env, jobject globalRef) -{ - hashtable_global_ref_entry *gre; - hashtable_global_ref_entry *prevgre; - u4 key; /* hashkey */ - u4 slot; /* slot in hashtable */ - java_handle_t *o; - - STATISTICS(jniinvokation()); - - o = (java_handle_t *) globalRef; - - LOCK_MONITOR_ENTER(hashtable_global_ref->header); - - LLNI_CRITICAL_START; - - /* normally addresses are aligned to 4, 8 or 16 bytes */ - - key = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */ - slot = key & (hashtable_global_ref->size - 1); - gre = hashtable_global_ref->ptr[slot]; - - /* initialize prevgre */ - - prevgre = NULL; - - /* search external hash chain for the entry */ - - while (gre) { - if (gre->o == LLNI_DIRECT(o)) { - /* global object found, decrement the reference count */ - - gre->refs--; - - /* if reference count is 0, remove the entry */ - - if (gre->refs == 0) { - /* special handling if it's the first in the chain */ - - if (prevgre == NULL) - hashtable_global_ref->ptr[slot] = gre->hashlink; - else - prevgre->hashlink = gre->hashlink; - -#if defined(ENABLE_GC_CACAO) - /* unregister global ref with the GC */ - - gc_reference_unregister(&(gre->o)); -#endif - - FREE(gre, hashtable_global_ref_entry); - } - - LLNI_CRITICAL_END; - - LOCK_MONITOR_EXIT(hashtable_global_ref->header); - - return; - } - - prevgre = gre; /* save current pointer for removal */ - gre = gre->hashlink; /* next element in external chain */ - } - - log_println("JNI-DeleteGlobalRef: global reference not found"); - - LLNI_CRITICAL_END; - - LOCK_MONITOR_EXIT(hashtable_global_ref->header); -} - - -/* ExceptionCheck ************************************************************** - - Returns JNI_TRUE when there is a pending exception; otherwise, - returns JNI_FALSE. - -*******************************************************************************/ - -jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env) -{ - java_handle_t *o; - - STATISTICS(jniinvokation()); - - o = exceptions_get_exception(); - - return (o != NULL) ? JNI_TRUE : JNI_FALSE; -} - - -/* New JNI 1.4 functions ******************************************************/ - -/* NewDirectByteBuffer ********************************************************* - - Allocates and returns a direct java.nio.ByteBuffer referring to the - block of memory starting at the memory address address and - extending capacity bytes. - -*******************************************************************************/ - -jobject _Jv_JNI_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity) -{ -#if defined(ENABLE_JAVASE) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_handle_t *nbuf; - -# if SIZEOF_VOID_P == 8 - gnu_classpath_Pointer64 *paddress; -# else - gnu_classpath_Pointer32 *paddress; -# endif - - TRACEJNICALLS(("_Jv_JNI_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld", env, address, capacity)); - - /* alocate a gnu.classpath.Pointer{32,64} object */ - -# if SIZEOF_VOID_P == 8 - if (!(paddress = (gnu_classpath_Pointer64 *) - builtin_new(class_gnu_classpath_Pointer64))) -# else - if (!(paddress = (gnu_classpath_Pointer32 *) - builtin_new(class_gnu_classpath_Pointer32))) -# endif - return NULL; - - /* fill gnu.classpath.Pointer{32,64} with address */ - - LLNI_field_set_val(paddress, data, (ptrint) address); - - /* create a java.nio.DirectByteBufferImpl$ReadWrite object */ - - nbuf = (*env)->NewObject(env, class_java_nio_DirectByteBufferImpl_ReadWrite, - (jmethodID) dbbirw_init, NULL, paddress, - (jint) capacity, (jint) capacity, (jint) 0); - - /* add local reference and return the value */ - - return jni_NewLocalRef(env, nbuf); - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - jobject o; - int64_t addr; - int32_t cap; - - TRACEJNICALLS(("_Jv_JNI_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld", env, address, capacity)); - - /* Be paranoid about address sign-extension. */ - - addr = (int64_t) ((uintptr_t) address); - cap = (int32_t) capacity; - - o = (*env)->NewObject(env, (jclass) class_java_nio_DirectByteBuffer, - (jmethodID) dbb_init, addr, cap); - - /* Add local reference and return the value. */ - - return jni_NewLocalRef(env, o); - -# else -# error unknown classpath configuration -# endif - -#else - vm_abort("_Jv_JNI_NewDirectByteBuffer: not implemented in this configuration"); - - /* keep compiler happy */ - - return NULL; -#endif -} - - -/* GetDirectBufferAddress ****************************************************** - - Fetches and returns the starting address of the memory region - referenced by the given direct java.nio.Buffer. - -*******************************************************************************/ - -void *_Jv_JNI_GetDirectBufferAddress(JNIEnv *env, jobject buf) -{ -#if defined(ENABLE_JAVASE) - java_handle_t *h; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - java_nio_DirectByteBufferImpl *nbuf; - gnu_classpath_Pointer *po; -# if SIZEOF_VOID_P == 8 - gnu_classpath_Pointer64 *paddress; - int64_t address; -# else - gnu_classpath_Pointer32 *paddress; - int32_t address; -# endif - void *p; - - TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf)); - - /* Prevent compiler warning. */ - - h = (java_handle_t *) buf; - - if ((h != NULL) && !builtin_instanceof(h, class_java_nio_Buffer)) - return NULL; - - nbuf = (java_nio_DirectByteBufferImpl *) buf; - - LLNI_field_get_ref(nbuf, address, po); - -# if SIZEOF_VOID_P == 8 - paddress = (gnu_classpath_Pointer64 *) po; -# else - paddress = (gnu_classpath_Pointer32 *) po; -# endif - - if (paddress == NULL) - return NULL; - - LLNI_field_get_val(paddress, data, address); - - p = (void *) (intptr_t) address; - - return p; - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - java_nio_Buffer *o; - int64_t address; - void *p; - - TRACEJNICALLS(("_Jv_JNI_GetDirectBufferAddress(env=%p, buf=%p)", env, buf)); - - /* Prevent compiler warning. */ - - h = (java_handle_t *) buf; - - if ((h != NULL) && !builtin_instanceof(h, class_sun_nio_ch_DirectBuffer)) - return NULL; - - o = (java_nio_Buffer *) buf; - - LLNI_field_get_val(o, address, address); - - p = (void *) (intptr_t) address; - - return p; - -# else -# error unknown classpath configuration -# endif - -#else - - vm_abort("_Jv_JNI_GetDirectBufferAddress: not implemented in this configuration"); - - /* keep compiler happy */ - - return NULL; - -#endif -} - - -/* GetDirectBufferCapacity ***************************************************** - - Fetches and returns the capacity in bytes of the memory region - referenced by the given direct java.nio.Buffer. - -*******************************************************************************/ - -jlong _Jv_JNI_GetDirectBufferCapacity(JNIEnv* env, jobject buf) -{ -#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_handle_t *o; - java_nio_Buffer *nbuf; - jlong capacity; - - STATISTICS(jniinvokation()); - - o = (java_handle_t *) buf; - - if (!builtin_instanceof(o, class_java_nio_DirectByteBufferImpl)) - return -1; - - nbuf = (java_nio_Buffer *) o; - - LLNI_field_get_val(nbuf, cap, capacity); - - return capacity; -#else - vm_abort("_Jv_JNI_GetDirectBufferCapacity: not implemented in this configuration"); - - /* keep compiler happy */ - - return 0; -#endif -} - - -/* GetObjectRefType ************************************************************ - - Returns the type of the object referred to by the obj argument. The - argument obj can either be a local, global or weak global - reference. - -*******************************************************************************/ - -jobjectRefType jni_GetObjectRefType(JNIEnv *env, jobject obj) -{ - log_println("jni_GetObjectRefType: IMPLEMENT ME!"); - - return -1; -} - - -/* DestroyJavaVM *************************************************************** - - Unloads a Java VM and reclaims its resources. Only the main thread - can unload the VM. The system waits until the main thread is only - remaining user thread before it destroys the VM. - -*******************************************************************************/ - -jint _Jv_JNI_DestroyJavaVM(JavaVM *vm) -{ - int status; - - TRACEJNICALLS(("_Jv_JNI_DestroyJavaVM(vm=%p)", vm)); - - if (vm_created == false) - return JNI_ERR; - - status = vm_destroy(vm); - - return status; -} - - -/* AttachCurrentThread ********************************************************* - - Attaches the current thread to a Java VM. Returns a JNI interface - pointer in the JNIEnv argument. - - Trying to attach a thread that is already attached is a no-op. - - A native thread cannot be attached simultaneously to two Java VMs. - - When a thread is attached to the VM, the context class loader is - the bootstrap loader. - -*******************************************************************************/ - -static int jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon) -{ -#if defined(ENABLE_THREADS) - JavaVMAttachArgs *vm_aargs; - bool result; - - /* If the current thread has already been attached, this operation - is a no-op. */ - - result = thread_current_is_attached(); - - if (result == true) { - *p_env = _Jv_env; - - return JNI_OK; - } - - vm_aargs = (JavaVMAttachArgs *) thr_args; - - if (vm_aargs != NULL) { - if ((vm_aargs->version != JNI_VERSION_1_2) && - (vm_aargs->version != JNI_VERSION_1_4)) - return JNI_EVERSION; - } - - if (!threads_attach_current_thread(vm_aargs, false)) - return JNI_ERR; - - if (!localref_table_init()) - return JNI_ERR; -#endif - - *p_env = _Jv_env; - - return JNI_OK; -} - - -jint _Jv_JNI_AttachCurrentThread(JavaVM *vm, void **p_env, void *thr_args) -{ - int result; - - TRACEJNICALLS(("_Jv_JNI_AttachCurrentThread(vm=%p, p_env=%p, thr_args=%p)", vm, p_env, thr_args)); - - if (vm_created == false) - return JNI_ERR; - - result = jni_attach_current_thread(p_env, thr_args, false); - - return result; -} - - -/* DetachCurrentThread ********************************************************* - - Detaches the current thread from a Java VM. All Java monitors held - by this thread are released. All Java threads waiting for this - thread to die are notified. - - In JDK 1.1, the main thread cannot be detached from the VM. It must - call DestroyJavaVM to unload the entire VM. - - In the JDK, the main thread can be detached from the VM. - - The main thread, which is the thread that created the Java VM, - cannot be detached from the VM. Instead, the main thread must call - JNI_DestroyJavaVM() to unload the entire VM. - -*******************************************************************************/ - -jint _Jv_JNI_DetachCurrentThread(JavaVM *vm) -{ -#if defined(ENABLE_THREADS) - threadobject *t; - bool result; - - TRACEJNICALLS(("_Jv_JNI_DetachCurrentThread(vm=%p)", vm)); - - t = thread_get_current(); - - /* Sanity check. */ - - assert(t != NULL); - - /* If the given thread has already been detached, this operation - is a no-op. */ - - result = thread_is_attached(t); - - if (result == false) - return true; - - /* We need to pop all frames before we can destroy the table. */ - - localref_frame_pop_all(); - - if (!localref_table_destroy()) - return JNI_ERR; - - if (!threads_detach_thread(t)) - return JNI_ERR; -#endif - - return JNI_OK; -} - - -/* GetEnv ********************************************************************** - - If the current thread is not attached to the VM, sets *env to NULL, - and returns JNI_EDETACHED. If the specified version is not - supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise, - sets *env to the appropriate interface, and returns JNI_OK. - -*******************************************************************************/ - -jint jni_GetEnv(JavaVM *vm, void **env, jint version) -{ - TRACEJNICALLS(("jni_GetEnv(vm=%p, env=%p, version=%d)", vm, env, version)); - - if (vm_created == false) { - *env = NULL; - return JNI_EDETACHED; - } - -#if defined(ENABLE_THREADS) - if (thread_get_current() == NULL) { - *env = NULL; - - return JNI_EDETACHED; - } -#endif - - /* Check the JNI version. */ - - if (jni_version_check(version) == true) { - *env = _Jv_env; - return JNI_OK; - } - -#if defined(ENABLE_JVMTI) - if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE) - == JVMTI_VERSION_INTERFACE_JVMTI) { - - *env = (void *) jvmti_new_environment(); - - if (env != NULL) - return JNI_OK; - } -#endif - - *env = NULL; - - return JNI_EVERSION; -} - - -/* AttachCurrentThreadAsDaemon ************************************************* - - Same semantics as AttachCurrentThread, but the newly-created - java.lang.Thread instance is a daemon. - - If the thread has already been attached via either - AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine - simply sets the value pointed to by penv to the JNIEnv of the - current thread. In this case neither AttachCurrentThread nor this - routine have any effect on the daemon status of the thread. - -*******************************************************************************/ - -jint _Jv_JNI_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *args) -{ - int result; - - TRACEJNICALLS(("_Jv_JNI_AttachCurrentThreadAsDaemon(vm=%p, penv=%p, args=%p)", vm, penv, args)); - - if (vm_created == false) - return JNI_ERR; - - result = jni_attach_current_thread(penv, args, true); - - return result; -} - - -/* JNI invocation table *******************************************************/ - -const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = { - NULL, - NULL, - NULL, - - _Jv_JNI_DestroyJavaVM, - _Jv_JNI_AttachCurrentThread, - _Jv_JNI_DetachCurrentThread, - jni_GetEnv, - _Jv_JNI_AttachCurrentThreadAsDaemon -}; - - -/* JNI function table *********************************************************/ - -struct JNINativeInterface_ _Jv_JNINativeInterface = { - NULL, - NULL, - NULL, - NULL, - _Jv_JNI_GetVersion, - - _Jv_JNI_DefineClass, - jni_FindClass, - jni_FromReflectedMethod, - jni_FromReflectedField, - _Jv_JNI_ToReflectedMethod, - _Jv_JNI_GetSuperclass, - _Jv_JNI_IsAssignableFrom, - _Jv_JNI_ToReflectedField, - - _Jv_JNI_Throw, - _Jv_JNI_ThrowNew, - _Jv_JNI_ExceptionOccurred, - jni_ExceptionDescribe, - jni_ExceptionClear, - _Jv_JNI_FatalError, - jni_PushLocalFrame, - jni_PopLocalFrame, - - _Jv_JNI_NewGlobalRef, - _Jv_JNI_DeleteGlobalRef, - jni_DeleteLocalRef, - _Jv_JNI_IsSameObject, - jni_NewLocalRef, - jni_EnsureLocalCapacity, - - _Jv_JNI_AllocObject, - _Jv_JNI_NewObject, - _Jv_JNI_NewObjectV, - _Jv_JNI_NewObjectA, - - _Jv_JNI_GetObjectClass, - _Jv_JNI_IsInstanceOf, - - _Jv_JNI_GetMethodID, - - _Jv_JNI_CallObjectMethod, - _Jv_JNI_CallObjectMethodV, - _Jv_JNI_CallObjectMethodA, - _Jv_JNI_CallBooleanMethod, - _Jv_JNI_CallBooleanMethodV, - _Jv_JNI_CallBooleanMethodA, - _Jv_JNI_CallByteMethod, - _Jv_JNI_CallByteMethodV, - _Jv_JNI_CallByteMethodA, - _Jv_JNI_CallCharMethod, - _Jv_JNI_CallCharMethodV, - _Jv_JNI_CallCharMethodA, - _Jv_JNI_CallShortMethod, - _Jv_JNI_CallShortMethodV, - _Jv_JNI_CallShortMethodA, - _Jv_JNI_CallIntMethod, - _Jv_JNI_CallIntMethodV, - _Jv_JNI_CallIntMethodA, - _Jv_JNI_CallLongMethod, - _Jv_JNI_CallLongMethodV, - _Jv_JNI_CallLongMethodA, - _Jv_JNI_CallFloatMethod, - _Jv_JNI_CallFloatMethodV, - _Jv_JNI_CallFloatMethodA, - _Jv_JNI_CallDoubleMethod, - _Jv_JNI_CallDoubleMethodV, - _Jv_JNI_CallDoubleMethodA, - _Jv_JNI_CallVoidMethod, - _Jv_JNI_CallVoidMethodV, - _Jv_JNI_CallVoidMethodA, - - _Jv_JNI_CallNonvirtualObjectMethod, - _Jv_JNI_CallNonvirtualObjectMethodV, - _Jv_JNI_CallNonvirtualObjectMethodA, - _Jv_JNI_CallNonvirtualBooleanMethod, - _Jv_JNI_CallNonvirtualBooleanMethodV, - _Jv_JNI_CallNonvirtualBooleanMethodA, - _Jv_JNI_CallNonvirtualByteMethod, - _Jv_JNI_CallNonvirtualByteMethodV, - _Jv_JNI_CallNonvirtualByteMethodA, - _Jv_JNI_CallNonvirtualCharMethod, - _Jv_JNI_CallNonvirtualCharMethodV, - _Jv_JNI_CallNonvirtualCharMethodA, - _Jv_JNI_CallNonvirtualShortMethod, - _Jv_JNI_CallNonvirtualShortMethodV, - _Jv_JNI_CallNonvirtualShortMethodA, - _Jv_JNI_CallNonvirtualIntMethod, - _Jv_JNI_CallNonvirtualIntMethodV, - _Jv_JNI_CallNonvirtualIntMethodA, - _Jv_JNI_CallNonvirtualLongMethod, - _Jv_JNI_CallNonvirtualLongMethodV, - _Jv_JNI_CallNonvirtualLongMethodA, - _Jv_JNI_CallNonvirtualFloatMethod, - _Jv_JNI_CallNonvirtualFloatMethodV, - _Jv_JNI_CallNonvirtualFloatMethodA, - _Jv_JNI_CallNonvirtualDoubleMethod, - _Jv_JNI_CallNonvirtualDoubleMethodV, - _Jv_JNI_CallNonvirtualDoubleMethodA, - _Jv_JNI_CallNonvirtualVoidMethod, - _Jv_JNI_CallNonvirtualVoidMethodV, - _Jv_JNI_CallNonvirtualVoidMethodA, - - _Jv_JNI_GetFieldID, - - _Jv_JNI_GetObjectField, - _Jv_JNI_GetBooleanField, - _Jv_JNI_GetByteField, - _Jv_JNI_GetCharField, - _Jv_JNI_GetShortField, - _Jv_JNI_GetIntField, - _Jv_JNI_GetLongField, - _Jv_JNI_GetFloatField, - _Jv_JNI_GetDoubleField, - _Jv_JNI_SetObjectField, - _Jv_JNI_SetBooleanField, - _Jv_JNI_SetByteField, - _Jv_JNI_SetCharField, - _Jv_JNI_SetShortField, - _Jv_JNI_SetIntField, - _Jv_JNI_SetLongField, - _Jv_JNI_SetFloatField, - _Jv_JNI_SetDoubleField, - - _Jv_JNI_GetStaticMethodID, - - _Jv_JNI_CallStaticObjectMethod, - _Jv_JNI_CallStaticObjectMethodV, - _Jv_JNI_CallStaticObjectMethodA, - _Jv_JNI_CallStaticBooleanMethod, - _Jv_JNI_CallStaticBooleanMethodV, - _Jv_JNI_CallStaticBooleanMethodA, - _Jv_JNI_CallStaticByteMethod, - _Jv_JNI_CallStaticByteMethodV, - _Jv_JNI_CallStaticByteMethodA, - _Jv_JNI_CallStaticCharMethod, - _Jv_JNI_CallStaticCharMethodV, - _Jv_JNI_CallStaticCharMethodA, - _Jv_JNI_CallStaticShortMethod, - _Jv_JNI_CallStaticShortMethodV, - _Jv_JNI_CallStaticShortMethodA, - _Jv_JNI_CallStaticIntMethod, - _Jv_JNI_CallStaticIntMethodV, - _Jv_JNI_CallStaticIntMethodA, - _Jv_JNI_CallStaticLongMethod, - _Jv_JNI_CallStaticLongMethodV, - _Jv_JNI_CallStaticLongMethodA, - _Jv_JNI_CallStaticFloatMethod, - _Jv_JNI_CallStaticFloatMethodV, - _Jv_JNI_CallStaticFloatMethodA, - _Jv_JNI_CallStaticDoubleMethod, - _Jv_JNI_CallStaticDoubleMethodV, - _Jv_JNI_CallStaticDoubleMethodA, - _Jv_JNI_CallStaticVoidMethod, - _Jv_JNI_CallStaticVoidMethodV, - _Jv_JNI_CallStaticVoidMethodA, - - _Jv_JNI_GetStaticFieldID, - - _Jv_JNI_GetStaticObjectField, - _Jv_JNI_GetStaticBooleanField, - _Jv_JNI_GetStaticByteField, - _Jv_JNI_GetStaticCharField, - _Jv_JNI_GetStaticShortField, - _Jv_JNI_GetStaticIntField, - _Jv_JNI_GetStaticLongField, - _Jv_JNI_GetStaticFloatField, - _Jv_JNI_GetStaticDoubleField, - _Jv_JNI_SetStaticObjectField, - _Jv_JNI_SetStaticBooleanField, - _Jv_JNI_SetStaticByteField, - _Jv_JNI_SetStaticCharField, - _Jv_JNI_SetStaticShortField, - _Jv_JNI_SetStaticIntField, - _Jv_JNI_SetStaticLongField, - _Jv_JNI_SetStaticFloatField, - _Jv_JNI_SetStaticDoubleField, - - _Jv_JNI_NewString, - _Jv_JNI_GetStringLength, - _Jv_JNI_GetStringChars, - _Jv_JNI_ReleaseStringChars, - - _Jv_JNI_NewStringUTF, - _Jv_JNI_GetStringUTFLength, - _Jv_JNI_GetStringUTFChars, - _Jv_JNI_ReleaseStringUTFChars, - - _Jv_JNI_GetArrayLength, - - _Jv_JNI_NewObjectArray, - _Jv_JNI_GetObjectArrayElement, - _Jv_JNI_SetObjectArrayElement, - - _Jv_JNI_NewBooleanArray, - _Jv_JNI_NewByteArray, - _Jv_JNI_NewCharArray, - _Jv_JNI_NewShortArray, - _Jv_JNI_NewIntArray, - _Jv_JNI_NewLongArray, - _Jv_JNI_NewFloatArray, - _Jv_JNI_NewDoubleArray, - - _Jv_JNI_GetBooleanArrayElements, - _Jv_JNI_GetByteArrayElements, - _Jv_JNI_GetCharArrayElements, - _Jv_JNI_GetShortArrayElements, - _Jv_JNI_GetIntArrayElements, - _Jv_JNI_GetLongArrayElements, - _Jv_JNI_GetFloatArrayElements, - _Jv_JNI_GetDoubleArrayElements, - - _Jv_JNI_ReleaseBooleanArrayElements, - _Jv_JNI_ReleaseByteArrayElements, - _Jv_JNI_ReleaseCharArrayElements, - _Jv_JNI_ReleaseShortArrayElements, - _Jv_JNI_ReleaseIntArrayElements, - _Jv_JNI_ReleaseLongArrayElements, - _Jv_JNI_ReleaseFloatArrayElements, - _Jv_JNI_ReleaseDoubleArrayElements, - - _Jv_JNI_GetBooleanArrayRegion, - _Jv_JNI_GetByteArrayRegion, - _Jv_JNI_GetCharArrayRegion, - _Jv_JNI_GetShortArrayRegion, - _Jv_JNI_GetIntArrayRegion, - _Jv_JNI_GetLongArrayRegion, - _Jv_JNI_GetFloatArrayRegion, - _Jv_JNI_GetDoubleArrayRegion, - _Jv_JNI_SetBooleanArrayRegion, - _Jv_JNI_SetByteArrayRegion, - _Jv_JNI_SetCharArrayRegion, - _Jv_JNI_SetShortArrayRegion, - _Jv_JNI_SetIntArrayRegion, - _Jv_JNI_SetLongArrayRegion, - _Jv_JNI_SetFloatArrayRegion, - _Jv_JNI_SetDoubleArrayRegion, - - _Jv_JNI_RegisterNatives, - _Jv_JNI_UnregisterNatives, - - _Jv_JNI_MonitorEnter, - _Jv_JNI_MonitorExit, - - _Jv_JNI_GetJavaVM, - - /* New JNI 1.2 functions. */ - - _Jv_JNI_GetStringRegion, - _Jv_JNI_GetStringUTFRegion, - - jni_GetPrimitiveArrayCritical, - jni_ReleasePrimitiveArrayCritical, - - _Jv_JNI_GetStringCritical, - _Jv_JNI_ReleaseStringCritical, - - _Jv_JNI_NewWeakGlobalRef, - _Jv_JNI_DeleteWeakGlobalRef, - - _Jv_JNI_ExceptionCheck, - - /* New JNI 1.4 functions. */ - - _Jv_JNI_NewDirectByteBuffer, - _Jv_JNI_GetDirectBufferAddress, - _Jv_JNI_GetDirectBufferCapacity, - - /* New JNI 1.6 functions. */ - - jni_GetObjectRefType -}; - - -/* Invocation API Functions ***************************************************/ - -/* JNI_GetDefaultJavaVMInitArgs ************************************************ - - Returns a default configuration for the Java VM. - -*******************************************************************************/ - -jint JNI_GetDefaultJavaVMInitArgs(void *vm_args) -{ - JavaVMInitArgs *_vm_args; - - _vm_args = (JavaVMInitArgs *) vm_args; - - /* GNU classpath currently supports JNI 1.2 */ - - switch (_vm_args->version) { - case JNI_VERSION_1_1: - _vm_args->version = JNI_VERSION_1_1; - break; - - case JNI_VERSION_1_2: - case JNI_VERSION_1_4: - _vm_args->ignoreUnrecognized = JNI_FALSE; - _vm_args->options = NULL; - _vm_args->nOptions = 0; - break; - - default: - return -1; - } - - return 0; -} - - -/* JNI_GetCreatedJavaVMs ******************************************************* - - Returns all Java VMs that have been created. Pointers to VMs are written in - the buffer vmBuf in the order they are created. At most bufLen number of - entries will be written. The total number of created VMs is returned in - *nVMs. - -*******************************************************************************/ - -jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs) -{ - TRACEJNICALLS(("JNI_GetCreatedJavaVMs(vmBuf=%p, jsize=%d, jsize=%p)", vmBuf, bufLen, nVMs)); - - if (bufLen <= 0) - return JNI_ERR; - - /* We currently only support 1 VM running. */ - - vmBuf[0] = (JavaVM *) _Jv_jvm; - *nVMs = 1; - - return JNI_OK; -} - - -/* JNI_CreateJavaVM ************************************************************ - - Loads and initializes a Java VM. The current thread becomes the main thread. - Sets the env argument to the JNI interface pointer of the main thread. - -*******************************************************************************/ - -jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args) -{ - TRACEJNICALLS(("JNI_CreateJavaVM(p_vm=%p, p_env=%p, vm_args=%p)", p_vm, p_env, vm_args)); - - /* actually create the JVM */ - - if (!vm_createjvm(p_vm, p_env, vm_args)) - return JNI_ERR; - - return JNI_OK; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/jni.cpp b/src/native/jni.cpp new file mode 100644 index 000000000..5969e99a1 --- /dev/null +++ b/src/native/jni.cpp @@ -0,0 +1,4209 @@ +/* src/native/jni.cpp - implementation of the Java Native Interface functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "vm/types.h" + +#include "mm/gc.hpp" +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/localref.h" +#include "native/native.h" + +#if defined(ENABLE_JVMTI) +# include "native/jvmti/cacaodbg.h" +#endif + +#include "threads/lock-common.h" +#include "threads/mutex.hpp" +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/resolve.h" +#include "vm/statistics.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/argument.h" +#include "vm/jit/asmpart.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/stacktrace.hpp" + + +/* debug **********************************************************************/ + +#if !defined(NDEBUG) + +# define TRACEJNICALLS(x) \ + do { \ + if (opt_TraceJNICalls) { \ + log_println x; \ + } \ + } while (0) + +# define TRACEJNICALLSENTER(x) \ + do { \ + if (opt_TraceJNICalls) { \ + log_start(); \ + log_print x; \ + } \ + } while (0) + +# define TRACEJNICALLSEXIT(x) \ + do { \ + if (opt_TraceJNICalls) { \ + log_print x; \ + log_finish(); \ + } \ + } while (0) + +#else + +# define TRACEJNICALLS(x) +# define TRACEJNICALLSENTER(x) +# define TRACEJNICALLSEXIT(x) + +#endif + + +/* global variables ***********************************************************/ + +/* global reference table *****************************************************/ + +/* hashsize must be power of 2 */ + +#define HASHTABLE_GLOBAL_REF_SIZE 64 /* initial size of globalref-hash */ + +static hashtable *hashtable_global_ref; /* hashtable for globalrefs */ + + +/* direct buffer stuff ********************************************************/ + +#if defined(ENABLE_JAVASE) +static classinfo *class_java_nio_Buffer; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + +static classinfo *class_java_nio_DirectByteBufferImpl; +static classinfo *class_java_nio_DirectByteBufferImpl_ReadWrite; + +# if SIZEOF_VOID_P == 8 +static classinfo *class_gnu_classpath_Pointer64; +# else +static classinfo *class_gnu_classpath_Pointer32; +# endif + +static methodinfo *dbbirw_init; + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + +static classinfo *class_sun_nio_ch_DirectBuffer; +static classinfo *class_java_nio_DirectByteBuffer; + +static methodinfo *dbb_init; + +# endif +#endif + + +/* some forward declarations **************************************************/ + +extern "C" { +jobject jni_NewLocalRef(JNIEnv *env, jobject ref); +} + + +/* jni_init ******************************************************************** + + Initialize the JNI subsystem. + +*******************************************************************************/ + +bool jni_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("jni_init"); + + /* create global ref hashtable */ + + hashtable_global_ref = NEW(hashtable); + + hashtable_create(hashtable_global_ref, HASHTABLE_GLOBAL_REF_SIZE); + + +#if defined(ENABLE_JAVASE) + /* Direct buffer stuff. */ + + if (!(class_java_nio_Buffer = + load_class_bootstrap(utf_new_char("java/nio/Buffer"))) || + !link_class(class_java_nio_Buffer)) + return false; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + if (!(class_java_nio_DirectByteBufferImpl = + load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl"))) || + !link_class(class_java_nio_DirectByteBufferImpl)) + return false; + + if (!(class_java_nio_DirectByteBufferImpl_ReadWrite = + load_class_bootstrap(utf_new_char("java/nio/DirectByteBufferImpl$ReadWrite"))) || + !link_class(class_java_nio_DirectByteBufferImpl_ReadWrite)) + return false; + + if (!(dbbirw_init = + class_resolvemethod(class_java_nio_DirectByteBufferImpl_ReadWrite, + utf_init, + utf_new_char("(Ljava/lang/Object;Lgnu/classpath/Pointer;III)V")))) + return false; + +# if SIZEOF_VOID_P == 8 + if (!(class_gnu_classpath_Pointer64 = + load_class_bootstrap(utf_new_char("gnu/classpath/Pointer64"))) || + !link_class(class_gnu_classpath_Pointer64)) + return false; +# else + if (!(class_gnu_classpath_Pointer32 = + load_class_bootstrap(utf_new_char("gnu/classpath/Pointer32"))) || + !link_class(class_gnu_classpath_Pointer32)) + return false; +# endif + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + if (!(class_sun_nio_ch_DirectBuffer = + load_class_bootstrap(utf_new_char("sun/nio/ch/DirectBuffer")))) + vm_abort("jni_init: loading sun/nio/ch/DirectBuffer failed"); + + if (!link_class(class_sun_nio_ch_DirectBuffer)) + vm_abort("jni_init: linking sun/nio/ch/DirectBuffer failed"); + + if (!(class_java_nio_DirectByteBuffer = + load_class_bootstrap(utf_new_char("java/nio/DirectByteBuffer")))) + vm_abort("jni_init: loading java/nio/DirectByteBuffer failed"); + + if (!link_class(class_java_nio_DirectByteBuffer)) + vm_abort("jni_init: linking java/nio/DirectByteBuffer failed"); + + if (!(dbb_init = + class_resolvemethod(class_java_nio_DirectByteBuffer, + utf_init, + utf_new_char("(JI)V")))) + vm_abort("jni_init: resolving java/nio/DirectByteBuffer.init(JI)V failed"); + +# endif + +#endif /* defined(ENABLE_JAVASE) */ + + return true; +} + + +/* jni_version_check *********************************************************** + + Check if the given JNI version is supported. + + IN: + version....JNI version to check + + RETURN VALUE: + true.......supported + false......not supported + +*******************************************************************************/ + +bool jni_version_check(int version) +{ + switch (version) { + case JNI_VERSION_1_1: + case JNI_VERSION_1_2: + case JNI_VERSION_1_4: + case JNI_VERSION_1_6: + return true; + default: + return false; + } +} + + +/* _Jv_jni_CallObjectMethod **************************************************** + + Internal function to call Java Object methods. + +*******************************************************************************/ + +static java_handle_t *_Jv_jni_CallObjectMethod(java_handle_t *o, + vftbl_t *vftbl, + methodinfo *m, va_list ap) +{ + methodinfo *resm; + java_handle_t *ro; + + STATISTICS(jniinvokation()); + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + ro = vm_call_method_valist(resm, o, ap); + + return ro; +} + + +/* _Jv_jni_CallObjectMethodA *************************************************** + + Internal function to call Java Object methods. + +*******************************************************************************/ + +static java_handle_t *_Jv_jni_CallObjectMethodA(java_handle_t *o, + vftbl_t *vftbl, + methodinfo *m, + const jvalue *args) +{ + methodinfo *resm; + java_handle_t *ro; + + STATISTICS(jniinvokation()); + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + ro = vm_call_method_jvalue(resm, o, args); + + return ro; +} + + +/* _Jv_jni_CallIntMethod ******************************************************* + + Internal function to call Java integer class methods (boolean, + byte, char, short, int). + +*******************************************************************************/ + +static jint _Jv_jni_CallIntMethod(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, va_list ap) +{ + methodinfo *resm; + jint i; + + STATISTICS(jniinvokation()); + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + i = vm_call_method_int_valist(resm, o, ap); + + return i; +} + + +/* _Jv_jni_CallIntMethodA ****************************************************** + + Internal function to call Java integer class methods (boolean, + byte, char, short, int). + +*******************************************************************************/ + +static jint _Jv_jni_CallIntMethodA(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, const jvalue *args) +{ + methodinfo *resm; + jint i; + + STATISTICS(jniinvokation()); + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + i = vm_call_method_int_jvalue(resm, o, args); + + return i; +} + + +/* _Jv_jni_CallLongMethod ****************************************************** + + Internal function to call Java long methods. + +*******************************************************************************/ + +static jlong _Jv_jni_CallLongMethod(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, va_list ap) +{ + methodinfo *resm; + jlong l; + + STATISTICS(jniinvokation()); + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + l = vm_call_method_long_valist(resm, o, ap); + + return l; +} + + +/* _Jv_jni_CallLongMethodA ***************************************************** + + Internal function to call Java long methods. + +*******************************************************************************/ + +static jlong _Jv_jni_CallLongMethodA(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, const jvalue *args) +{ + methodinfo *resm; + jlong l; + + STATISTICS(jniinvokation()); + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + } + else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + l = vm_call_method_long_jvalue(resm, o, args); + + return l; +} + + +/* _Jv_jni_CallFloatMethod ***************************************************** + + Internal function to call Java float methods. + +*******************************************************************************/ + +static jfloat _Jv_jni_CallFloatMethod(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, va_list ap) +{ + methodinfo *resm; + jfloat f; + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + f = vm_call_method_float_valist(resm, o, ap); + + return f; +} + + +/* _Jv_jni_CallFloatMethodA **************************************************** + + Internal function to call Java float methods. + +*******************************************************************************/ + +static jfloat _Jv_jni_CallFloatMethodA(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, const jvalue *args) +{ + methodinfo *resm; + jfloat f; + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + } + else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + f = vm_call_method_float_jvalue(resm, o, args); + + return f; +} + + +/* _Jv_jni_CallDoubleMethod **************************************************** + + Internal function to call Java double methods. + +*******************************************************************************/ + +static jdouble _Jv_jni_CallDoubleMethod(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, va_list ap) +{ + methodinfo *resm; + jdouble d; + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + d = vm_call_method_double_valist(resm, o, ap); + + return d; +} + + +/* _Jv_jni_CallDoubleMethodA *************************************************** + + Internal function to call Java double methods. + +*******************************************************************************/ + +static jdouble _Jv_jni_CallDoubleMethodA(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, const jvalue *args) +{ + methodinfo *resm; + jdouble d; + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + } + else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + d = vm_call_method_double_jvalue(resm, o, args); + + return d; +} + + +/* _Jv_jni_CallVoidMethod ****************************************************** + + Internal function to call Java void methods. + +*******************************************************************************/ + +static void _Jv_jni_CallVoidMethod(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, va_list ap) +{ + methodinfo *resm; + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + (void) vm_call_method_valist(resm, o, ap); +} + + +/* _Jv_jni_CallVoidMethodA ***************************************************** + + Internal function to call Java void methods. + +*******************************************************************************/ + +static void _Jv_jni_CallVoidMethodA(java_handle_t *o, vftbl_t *vftbl, + methodinfo *m, const jvalue *args) +{ + methodinfo *resm; + + if (m == NULL) { + exceptions_throw_nullpointerexception(); + return; + } + + /* Class initialization is done by the JIT compiler. This is ok + since a static method always belongs to the declaring class. */ + + if (m->flags & ACC_STATIC) { + /* For static methods we reset the object. */ + + if (o != NULL) + o = NULL; + + /* for convenience */ + + resm = m; + + } else { + /* For instance methods we make a virtual function table lookup. */ + + resm = method_vftbl_lookup(vftbl, m); + } + + STATISTICS(jnicallXmethodnvokation()); + + (void) vm_call_method_jvalue(resm, o, args); +} + + +// JNI functions are exported as C functions. +extern "C" { + +/* GetVersion ****************************************************************** + + Returns the major version number in the higher 16 bits and the + minor version number in the lower 16 bits. + +*******************************************************************************/ + +jint _Jv_JNI_GetVersion(JNIEnv *env) +{ + TRACEJNICALLS(("_Jv_JNI_GetVersion(env=%p)", env)); + + /* We support JNI 1.6. */ + + return JNI_VERSION_1_6; +} + + +/* Class Operations ***********************************************************/ + +/* DefineClass ***************************************************************** + + Loads a class from a buffer of raw class data. The buffer + containing the raw class data is not referenced by the VM after the + DefineClass call returns, and it may be discarded if desired. + +*******************************************************************************/ + +jclass jni_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize bufLen) +{ +#if defined(ENABLE_JAVASE) + utf *u; + classloader_t *cl; + classinfo *c; + java_handle_t* h; + + TRACEJNICALLS(("jni_DefineClass(env=%p, name=%s, loader=%p, buf=%p, bufLen=%d)", env, name, loader, buf, bufLen)); + + u = utf_new_char(name); + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + c = class_define(u, cl, bufLen, (uint8_t *) buf, NULL); + + h = LLNI_classinfo_wrap(c); + + return (jclass) jni_NewLocalRef(env, (jobject) h); +#else + vm_abort("jni_DefineClass: Not implemented in this configuration"); + + // Keep compiler happy. + + return 0; +#endif +} + + +/* FindClass ******************************************************************* + + This function loads a locally-defined class. It searches the + directories and zip files specified by the CLASSPATH environment + variable for the class with the specified name. + +*******************************************************************************/ + +jclass jni_FindClass(JNIEnv *env, const char *name) +{ +#if defined(ENABLE_JAVASE) + + utf* u; + classinfo* cc; + classinfo* c; + java_handle_t* h; + + TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name)); + + /* FIXME If name is NULL we have a problem here. */ + + u = utf_new_char_classname((char *) name); + + if ((u == NULL) /*|| (int)strlen(name) > symbolOopDesc::max_length() */) { + exceptions_throw_noclassdeffounderror(u); + return NULL; + } + + /* Check stacktrace for classloader, if one found use it, + otherwise use the system classloader. */ + + /* Quote from the JNI documentation: + + In the Java 2 Platform, FindClass locates the class loader + associated with the current native method. If the native code + belongs to a system class, no class loader will be + involved. Otherwise, the proper class loader will be invoked to + load and link the named class. When FindClass is called through + the Invocation Interface, there is no current native method or + its associated class loader. In that case, the result of + ClassLoader.getBaseClassLoader is used." */ + + cc = stacktrace_get_current_class(); + + if (cc == NULL) + c = load_class_from_sysloader(u); + else + c = load_class_from_classloader(u, cc->classloader); + + if (c == NULL) { + resolve_handle_pending_exception(true); + return NULL; + } + + if (!link_class(c)) + return NULL; + + h = LLNI_classinfo_wrap(c); + + return (jclass) jni_NewLocalRef(env, (jobject) h); + +#elif defined(ENABLE_JAVAME_CLDC1_1) + + utf *u; + classinfo *c; + + TRACEJNICALLS(("jni_FindClass(env=%p, name=%s)", env, name)); + + u = utf_new_char_classname((char *) name); + c = load_class_bootstrap(u); + + if (c == NULL) { + resolve_handle_pending_exception(true); + return NULL; + } + + if (!link_class(c)) + return NULL; + + return (jclass) jni_NewLocalRef(env, (jobject) c); + +#else + vm_abort("jni_FindClass: not implemented in this configuration"); + + /* keep compiler happy */ + + return NULL; +#endif +} + + +/* GetSuperclass *************************************************************** + + If clazz represents any class other than the class Object, then + this function returns the object that represents the superclass of + the class specified by clazz. + +*******************************************************************************/ + +jclass jni_GetSuperclass(JNIEnv *env, jclass sub) +{ + classinfo* c; + classinfo* super; + + TRACEJNICALLS(("jni_GetSuperclass(env=%p, sub=%p)", env, sub)); + + c = LLNI_classinfo_unwrap(sub); + + if (c == NULL) + return NULL; + + super = class_get_superclass(c); + + java_handle_t* h = LLNI_classinfo_wrap(super); + + return (jclass) jni_NewLocalRef(env, (jobject) h); +} + + +/* IsAssignableFrom ************************************************************ + + Determines whether an object of sub can be safely cast to sup. + +*******************************************************************************/ + +jboolean _Jv_JNI_IsAssignableFrom(JNIEnv *env, jclass sub, jclass sup) +{ + classinfo *to; + classinfo *from; + + TRACEJNICALLS(("_Jv_JNI_IsAssignableFrom(env=%p, sub=%p, sup=%p)", env, sub, sup)); + + to = (classinfo *) sup; + from = (classinfo *) sub; + + return class_is_assignable_from(to, from); +} + + +/* Throw *********************************************************************** + + Causes a java.lang.Throwable object to be thrown. + +*******************************************************************************/ + +jint _Jv_JNI_Throw(JNIEnv *env, jthrowable obj) +{ + java_handle_t *o; + + STATISTICS(jniinvokation()); + + o = (java_handle_t *) obj; + + exceptions_set_exception(o); + + return JNI_OK; +} + + +/* ThrowNew ******************************************************************** + + Constructs an exception object from the specified class with the + message specified by message and causes that exception to be + thrown. + +*******************************************************************************/ + +jint _Jv_JNI_ThrowNew(JNIEnv* env, jclass clazz, const char *msg) +{ + classinfo *c; + java_handle_t *o; + java_handle_t *s; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + if (msg == NULL) + msg = ""; + s = javastring_new_from_utf_string(msg); + + /* instantiate exception object */ + + o = native_new_and_init_string(c, s); + + if (o == NULL) + return -1; + + exceptions_set_exception(o); + + return 0; +} + + +/* ExceptionOccurred *********************************************************** + + Determines if an exception is being thrown. The exception stays + being thrown until either the native code calls ExceptionClear(), + or the Java code handles the exception. + +*******************************************************************************/ + +jthrowable _Jv_JNI_ExceptionOccurred(JNIEnv *env) +{ + java_handle_t *o; + + TRACEJNICALLS(("_Jv_JNI_ExceptionOccurred(env=%p)", env)); + + o = exceptions_get_exception(); + + return (jthrowable) jni_NewLocalRef(env, (jthrowable) o); +} + + +/* ExceptionDescribe *********************************************************** + + Prints an exception and a backtrace of the stack to a system + error-reporting channel, such as stderr. This is a convenience + routine provided for debugging. + +*******************************************************************************/ + +void jni_ExceptionDescribe(JNIEnv *env) +{ + TRACEJNICALLS(("jni_ExceptionDescribe(env=%p)", env)); + + exceptions_print_stacktrace(); +} + + +/* ExceptionClear ************************************************************** + + Clears any exception that is currently being thrown. If no + exception is currently being thrown, this routine has no effect. + +*******************************************************************************/ + +void jni_ExceptionClear(JNIEnv *env) +{ + TRACEJNICALLS(("jni_ExceptionClear(env=%p)", env)); + + exceptions_clear_exception(); +} + + +/* FatalError ****************************************************************** + + Raises a fatal error and does not expect the VM to recover. This + function does not return. + +*******************************************************************************/ + +void _Jv_JNI_FatalError(JNIEnv *env, const char *msg) +{ + STATISTICS(jniinvokation()); + + /* this seems to be the best way */ + + vm_abort("JNI Fatal error: %s", msg); +} + + +/* PushLocalFrame ************************************************************** + + Creates a new local reference frame, in which at least a given + number of local references can be created. + +*******************************************************************************/ + +jint jni_PushLocalFrame(JNIEnv* env, jint capacity) +{ + TRACEJNICALLS(("jni_PushLocalFrame(env=%p, capacity=%d)", env, capacity)); + + if (capacity <= 0) + return -1; + + /* add new local reference frame to current table */ + + if (!localref_frame_push(capacity)) + return -1; + + return 0; +} + + +/* PopLocalFrame *************************************************************** + + Pops off the current local reference frame, frees all the local + references, and returns a local reference in the previous local + reference frame for the given result object. + +*******************************************************************************/ + +jobject jni_PopLocalFrame(JNIEnv* env, jobject result) +{ + TRACEJNICALLS(("jni_PopLocalFrame(env=%p, result=%p)", env, result)); + + /* release all current local frames */ + + localref_frame_pop_all(); + + /* add local reference and return the value */ + + return jni_NewLocalRef(env, result); +} + + +/* DeleteLocalRef ************************************************************** + + Deletes the local reference pointed to by localRef. + +*******************************************************************************/ + +void jni_DeleteLocalRef(JNIEnv *env, jobject localRef) +{ + java_handle_t *o; + + TRACEJNICALLS(("jni_DeleteLocalRef(env=%p, ref=%p)", env, localRef)); + + o = (java_handle_t *) localRef; + + if (o == NULL) + return; + + /* delete the reference */ + + localref_del(o); +} + + +/* IsSameObject **************************************************************** + + Tests whether two references refer to the same Java object. + +*******************************************************************************/ + +jboolean _Jv_JNI_IsSameObject(JNIEnv *env, jobject ref1, jobject ref2) +{ + java_handle_t *o1; + java_handle_t *o2; + jboolean result; + + STATISTICS(jniinvokation()); + + o1 = (java_handle_t *) ref1; + o2 = (java_handle_t *) ref2; + + LLNI_CRITICAL_START; + + if (LLNI_UNWRAP(o1) == LLNI_UNWRAP(o2)) + result = JNI_TRUE; + else + result = JNI_FALSE; + + LLNI_CRITICAL_END; + + return result; +} + + +/* NewLocalRef ***************************************************************** + + Creates a new local reference that refers to the same object as ref. + +*******************************************************************************/ + +jobject jni_NewLocalRef(JNIEnv *env, jobject ref) +{ + java_handle_t *o; + java_handle_t *localref; + + TRACEJNICALLS(("jni_NewLocalRef(env=%p, ref=%p)", env, ref)); + + o = (java_handle_t *) ref; + + if (o == NULL) + return NULL; + + /* insert the reference */ + + localref = localref_add(LLNI_DIRECT(o)); + + return (jobject) localref; +} + + +/* EnsureLocalCapacity ********************************************************* + + Ensures that at least a given number of local references can be + created in the current thread + +*******************************************************************************/ + +jint jni_EnsureLocalCapacity(JNIEnv* env, jint capacity) +{ + localref_table *lrt; + + TRACEJNICALLS(("jni_EnsureLocalCapacity(env=%p, capacity=%d)", env, capacity)); + + /* get local reference table (thread specific) */ + + lrt = LOCALREFTABLE; + + /* check if capacity elements are available in the local references table */ + + if ((lrt->used + capacity) > lrt->capacity) + return jni_PushLocalFrame(env, capacity); + + return 0; +} + + +/* AllocObject ***************************************************************** + + Allocates a new Java object without invoking any of the + constructors for the object. Returns a reference to the object. + +*******************************************************************************/ + +jobject _Jv_JNI_AllocObject(JNIEnv *env, jclass clazz) +{ + classinfo *c; + java_handle_t *o; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + + if ((c->flags & ACC_INTERFACE) || (c->flags & ACC_ABSTRACT)) { + exceptions_throw_instantiationexception(c); + return NULL; + } + + o = builtin_new(c); + + return jni_NewLocalRef(env, (jobject) o); +} + + +/* NewObject ******************************************************************* + + Programmers place all arguments that are to be passed to the + constructor immediately following the methodID + argument. NewObject() accepts these arguments and passes them to + the Java method that the programmer wishes to invoke. + +*******************************************************************************/ + +jobject jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + va_list ap; + + TRACEJNICALLSENTER(("jni_NewObject(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID)); + + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + /* create object */ + + o = builtin_new(c); + + if (o == NULL) + return NULL; + + /* call constructor */ + + va_start(ap, methodID); + _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap); + va_end(ap); + + TRACEJNICALLSEXIT(("->%p", o)); + + return jni_NewLocalRef(env, (jobject) o); +} + + +/* NewObjectV ****************************************************************** + + Programmers place all arguments that are to be passed to the + constructor in an args argument of type va_list that immediately + follows the methodID argument. NewObjectV() accepts these + arguments, and, in turn, passes them to the Java method that the + programmer wishes to invoke. + +*******************************************************************************/ + +jobject _Jv_JNI_NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, + va_list args) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + /* create object */ + + o = builtin_new(c); + + if (o == NULL) + return NULL; + + /* call constructor */ + + _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args); + + return jni_NewLocalRef(env, (jobject) o); +} + + +/* NewObjectA ***************************************************************** + + Programmers place all arguments that are to be passed to the + constructor in an args array of jvalues that immediately follows + the methodID argument. NewObjectA() accepts the arguments in this + array, and, in turn, passes them to the Java method that the + programmer wishes to invoke. + +*******************************************************************************/ + +jobject _Jv_JNI_NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, + const jvalue *args) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + /* create object */ + + o = builtin_new(c); + + if (o == NULL) + return NULL; + + /* call constructor */ + + _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args); + + return jni_NewLocalRef(env, (jobject) o); +} + + +/* GetObjectClass ************************************************************** + + Returns the class of an object. + +*******************************************************************************/ + +jclass jni_GetObjectClass(JNIEnv *env, jobject obj) +{ + java_handle_t* o; + classinfo* c; + + TRACEJNICALLS(("jni_GetObjectClass(env=%p, obj=%p)", env, obj)); + + o = (java_handle_t *) obj; + + if ((o == NULL) || (LLNI_vftbl_direct(o) == NULL)) + return NULL; + + LLNI_class_get(o, c); + + java_handle_t* h = LLNI_classinfo_wrap(c); + + return (jclass) jni_NewLocalRef(env, (jobject) h); +} + + +/* IsInstanceOf **************************************************************** + + Tests whether an object is an instance of a class. + +*******************************************************************************/ + +jboolean _Jv_JNI_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz) +{ + classinfo *c; + java_handle_t *h; + + TRACEJNICALLS(("_Jv_JNI_IsInstanceOf(env=%p, obj=%p, clazz=%p)", env, obj, clazz)); + + /* XXX Is this correct? */ + c = LLNI_classinfo_unwrap(clazz); + h = (java_handle_t *) obj; + + return class_is_instance(c, h); +} + + +/* Reflection Support *********************************************************/ + +/* FromReflectedMethod ********************************************************* + + Converts java.lang.reflect.Method or java.lang.reflect.Constructor + object to a method ID. + +*******************************************************************************/ + +jmethodID jni_FromReflectedMethod(JNIEnv *env, jobject method) +{ +#if defined(ENABLE_JAVASE) + methodinfo* m; + + TRACEJNICALLS(("jni_FromReflectedMethod(env=%p, method=%p)", env, method)); + + java_lang_Object o(method); + + if (o.is_null()) + return NULL; + + if (o.get_Class() == class_java_lang_reflect_Constructor) { + java_lang_reflect_Constructor rc(method); + m = rc.get_method(); + } + else { + assert(o.get_Class() == class_java_lang_reflect_Method); + + java_lang_reflect_Method rm(method); + m = rm.get_method(); + } + + return (jmethodID) m; +#else + vm_abort("jni_FromReflectedMethod: Not implemented in this configuration."); + + // Keep compiler happy. + return NULL; +#endif +} + + +/* FromReflectedField ********************************************************** + + Converts a java.lang.reflect.Field to a field ID. + +*******************************************************************************/ + +jfieldID jni_FromReflectedField(JNIEnv* env, jobject field) +{ +#if defined(ENABLE_JAVASE) + + TRACEJNICALLS(("jni_FromReflectedField(env=%p, field=%p)", env, field)); + + java_lang_reflect_Field rf(field); + + if (rf.is_null()) + return NULL; + + fieldinfo* f = rf.get_field(); + + return (jfieldID) f; +#else + vm_abort("jni_FromReflectedField: Not implemented in this configuration."); + + // Keep compiler happy. + return NULL; +#endif +} + + +/* ToReflectedMethod *********************************************************** + + Converts a method ID derived from cls to an instance of the + java.lang.reflect.Method class or to an instance of the + java.lang.reflect.Constructor class. + +*******************************************************************************/ + +jobject jni_ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic) +{ +#if defined(ENABLE_JAVASE) + TRACEJNICALLS(("jni_ToReflectedMethod(env=%p, cls=%p, methodID=%p, isStatic=%d)", env, cls, methodID, isStatic)); + + methodinfo* m = (methodinfo *) methodID; + + /* HotSpot does the same assert. */ + + assert(((m->flags & ACC_STATIC) != 0) == (isStatic != 0)); + + java_handle_t* h; + + if (m->name == utf_init) { + h = java_lang_reflect_Constructor(m).get_handle(); + } + else { + h = java_lang_reflect_Method(m).get_handle(); + } + + return (jobject) h; +#else + vm_abort("jni_ToReflectedMethod: Not implemented in this configuration."); + + /* keep compiler happy */ + + return NULL; +#endif +} + + +/* ToReflectedField ************************************************************ + + Converts a field ID derived from cls to an instance of the + java.lang.reflect.Field class. + +*******************************************************************************/ + +jobject _Jv_JNI_ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID, + jboolean isStatic) +{ + STATISTICS(jniinvokation()); + + log_text("JNI-Call: ToReflectedField: IMPLEMENT ME!"); + + return NULL; +} + + +/* Calling Instance Methods ***************************************************/ + +/* GetMethodID ***************************************************************** + + Returns the method ID for an instance (nonstatic) method of a class + or interface. The method may be defined in one of the clazz's + superclasses and inherited by clazz. The method is determined by + its name and signature. + + GetMethodID() causes an uninitialized class to be initialized. + +*******************************************************************************/ + +jmethodID _Jv_JNI_GetMethodID(JNIEnv* env, jclass clazz, const char *name, + const char *sig) +{ + classinfo *c; + utf *uname; + utf *udesc; + methodinfo *m; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + + if (c == NULL) + return NULL; + + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return NULL; + + /* try to get the method of the class or one of it's superclasses */ + + uname = utf_new_char((char *) name); + udesc = utf_new_char((char *) sig); + + m = class_resolvemethod(c, uname, udesc); + + if ((m == NULL) || (m->flags & ACC_STATIC)) { + exceptions_throw_nosuchmethoderror(c, uname, udesc); + + return NULL; + } + + return (jmethodID) m; +} + + +/* JNI-functions for calling instance methods *********************************/ + +#define JNI_CALL_VIRTUAL_METHOD(name, type, intern) \ +type _Jv_JNI_Call##name##Method(JNIEnv *env, jobject obj, \ + jmethodID methodID, ...) \ +{ \ + java_handle_t *o; \ + methodinfo *m; \ + va_list ap; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + m = (methodinfo *) methodID; \ + \ + va_start(ap, methodID); \ + ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, ap); \ + va_end(ap); \ + \ + return ret; \ +} + +JNI_CALL_VIRTUAL_METHOD(Boolean, jboolean, Int) +JNI_CALL_VIRTUAL_METHOD(Byte, jbyte, Int) +JNI_CALL_VIRTUAL_METHOD(Char, jchar, Int) +JNI_CALL_VIRTUAL_METHOD(Short, jshort, Int) +JNI_CALL_VIRTUAL_METHOD(Int, jint, Int) +JNI_CALL_VIRTUAL_METHOD(Long, jlong, Long) +JNI_CALL_VIRTUAL_METHOD(Float, jfloat, Float) +JNI_CALL_VIRTUAL_METHOD(Double, jdouble, Double) + + +#define JNI_CALL_VIRTUAL_METHOD_V(name, type, intern) \ +type _Jv_JNI_Call##name##MethodV(JNIEnv *env, jobject obj, \ + jmethodID methodID, va_list args) \ +{ \ + java_handle_t *o; \ + methodinfo *m; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + m = (methodinfo *) methodID; \ + \ + ret = _Jv_jni_Call##intern##Method(o, LLNI_vftbl_direct(o), m, args); \ + \ + return ret; \ +} + +JNI_CALL_VIRTUAL_METHOD_V(Boolean, jboolean, Int) +JNI_CALL_VIRTUAL_METHOD_V(Byte, jbyte, Int) +JNI_CALL_VIRTUAL_METHOD_V(Char, jchar, Int) +JNI_CALL_VIRTUAL_METHOD_V(Short, jshort, Int) +JNI_CALL_VIRTUAL_METHOD_V(Int, jint, Int) +JNI_CALL_VIRTUAL_METHOD_V(Long, jlong, Long) +JNI_CALL_VIRTUAL_METHOD_V(Float, jfloat, Float) +JNI_CALL_VIRTUAL_METHOD_V(Double, jdouble, Double) + + +#define JNI_CALL_VIRTUAL_METHOD_A(name, type, intern) \ +type _Jv_JNI_Call##name##MethodA(JNIEnv *env, jobject obj, \ + jmethodID methodID, \ + const jvalue *args) \ +{ \ + java_handle_t *o; \ + methodinfo *m; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + m = (methodinfo *) methodID; \ + \ + ret = _Jv_jni_Call##intern##MethodA(o, LLNI_vftbl_direct(o), m, args); \ + \ + return ret; \ +} + +JNI_CALL_VIRTUAL_METHOD_A(Boolean, jboolean, Int) +JNI_CALL_VIRTUAL_METHOD_A(Byte, jbyte, Int) +JNI_CALL_VIRTUAL_METHOD_A(Char, jchar, Int) +JNI_CALL_VIRTUAL_METHOD_A(Short, jshort, Int) +JNI_CALL_VIRTUAL_METHOD_A(Int, jint, Int) +JNI_CALL_VIRTUAL_METHOD_A(Long, jlong, Long) +JNI_CALL_VIRTUAL_METHOD_A(Float, jfloat, Float) +JNI_CALL_VIRTUAL_METHOD_A(Double, jdouble, Double) + + +jobject _Jv_JNI_CallObjectMethod(JNIEnv *env, jobject obj, jmethodID methodID, + ...) +{ + java_handle_t *o; + methodinfo *m; + java_handle_t *ret; + va_list ap; + + o = (java_handle_t *) obj; + m = (methodinfo *) methodID; + + va_start(ap, methodID); + ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, ap); + va_end(ap); + + return jni_NewLocalRef(env, (jobject) ret); +} + + +jobject _Jv_JNI_CallObjectMethodV(JNIEnv *env, jobject obj, jmethodID methodID, + va_list args) +{ + java_handle_t *o; + methodinfo *m; + java_handle_t *ret; + + o = (java_handle_t *) obj; + m = (methodinfo *) methodID; + + ret = _Jv_jni_CallObjectMethod(o, LLNI_vftbl_direct(o), m, args); + + return jni_NewLocalRef(env, (jobject) ret); +} + + +jobject _Jv_JNI_CallObjectMethodA(JNIEnv *env, jobject obj, jmethodID methodID, + const jvalue *args) +{ + java_handle_t *o; + methodinfo *m; + java_handle_t *ret; + + o = (java_handle_t *) obj; + m = (methodinfo *) methodID; + + ret = _Jv_jni_CallObjectMethodA(o, LLNI_vftbl_direct(o), m, args); + + return jni_NewLocalRef(env, (jobject) ret); +} + + + +void _Jv_JNI_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...) +{ + java_handle_t *o; + methodinfo *m; + va_list ap; + + o = (java_handle_t *) obj; + m = (methodinfo *) methodID; + + va_start(ap, methodID); + _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, ap); + va_end(ap); +} + + +void _Jv_JNI_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, + va_list args) +{ + java_handle_t *o; + methodinfo *m; + + o = (java_handle_t *) obj; + m = (methodinfo *) methodID; + + _Jv_jni_CallVoidMethod(o, LLNI_vftbl_direct(o), m, args); +} + + +void _Jv_JNI_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, + const jvalue *args) +{ + java_handle_t *o; + methodinfo *m; + + o = (java_handle_t *) obj; + m = (methodinfo *) methodID; + + _Jv_jni_CallVoidMethodA(o, LLNI_vftbl_direct(o), m, args); +} + + + +#define JNI_CALL_NONVIRTUAL_METHOD(name, type, intern) \ +type _Jv_JNI_CallNonvirtual##name##Method(JNIEnv *env, jobject obj, \ + jclass clazz, jmethodID methodID, \ + ...) \ +{ \ + java_handle_t *o; \ + classinfo *c; \ + methodinfo *m; \ + va_list ap; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + c = LLNI_classinfo_unwrap(clazz); \ + m = (methodinfo *) methodID; \ + \ + va_start(ap, methodID); \ + ret = _Jv_jni_Call##intern##Method(o, c->vftbl, m, ap); \ + va_end(ap); \ + \ + return ret; \ +} + +JNI_CALL_NONVIRTUAL_METHOD(Boolean, jboolean, Int) +JNI_CALL_NONVIRTUAL_METHOD(Byte, jbyte, Int) +JNI_CALL_NONVIRTUAL_METHOD(Char, jchar, Int) +JNI_CALL_NONVIRTUAL_METHOD(Short, jshort, Int) +JNI_CALL_NONVIRTUAL_METHOD(Int, jint, Int) +JNI_CALL_NONVIRTUAL_METHOD(Long, jlong, Long) +JNI_CALL_NONVIRTUAL_METHOD(Float, jfloat, Float) +JNI_CALL_NONVIRTUAL_METHOD(Double, jdouble, Double) + + +#define JNI_CALL_NONVIRTUAL_METHOD_V(name, type, intern) \ +type _Jv_JNI_CallNonvirtual##name##MethodV(JNIEnv *env, jobject obj, \ + jclass clazz, jmethodID methodID, \ + va_list args) \ +{ \ + java_handle_t *o; \ + classinfo *c; \ + methodinfo *m; \ + type ret; \ + \ + o = (java_handle_t *) obj; \ + c = LLNI_classinfo_unwrap(clazz); \ + m = (methodinfo *) methodID; \ + \ + ret = _Jv_jni_CallIntMethod(o, c->vftbl, m, args); \ + \ + return ret; \ +} + +JNI_CALL_NONVIRTUAL_METHOD_V(Boolean, jboolean, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Byte, jbyte, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Char, jchar, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Short, jshort, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Int, jint, Int) +JNI_CALL_NONVIRTUAL_METHOD_V(Long, jlong, Long) +JNI_CALL_NONVIRTUAL_METHOD_V(Float, jfloat, Float) +JNI_CALL_NONVIRTUAL_METHOD_V(Double, jdouble, Double) + + +#define JNI_CALL_NONVIRTUAL_METHOD_A(name, type, intern) \ +type _Jv_JNI_CallNonvirtual##name##MethodA(JNIEnv *env, jobject obj, \ + jclass clazz, jmethodID methodID, \ + const jvalue *args) \ +{ \ + log_text("JNI-Call: CallNonvirtual##name##MethodA: IMPLEMENT ME!"); \ + \ + return 0; \ +} + +JNI_CALL_NONVIRTUAL_METHOD_A(Boolean, jboolean, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Byte, jbyte, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Char, jchar, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Short, jshort, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Int, jint, Int) +JNI_CALL_NONVIRTUAL_METHOD_A(Long, jlong, Long) +JNI_CALL_NONVIRTUAL_METHOD_A(Float, jfloat, Float) +JNI_CALL_NONVIRTUAL_METHOD_A(Double, jdouble, Double) + +jobject _Jv_JNI_CallNonvirtualObjectMethod(JNIEnv *env, jobject obj, + jclass clazz, jmethodID methodID, + ...) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + java_handle_t *r; + va_list ap; + + o = (java_handle_t *) obj; + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + va_start(ap, methodID); + r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, ap); + va_end(ap); + + return jni_NewLocalRef(env, (jobject) r); +} + + +jobject _Jv_JNI_CallNonvirtualObjectMethodV(JNIEnv *env, jobject obj, + jclass clazz, jmethodID methodID, + va_list args) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + java_handle_t *r; + + o = (java_handle_t *) obj; + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + r = _Jv_jni_CallObjectMethod(o, c->vftbl, m, args); + + return jni_NewLocalRef(env, (jobject) r); +} + + +jobject _Jv_JNI_CallNonvirtualObjectMethodA(JNIEnv *env, jobject obj, + jclass clazz, jmethodID methodID, + const jvalue *args) +{ + log_text("JNI-Call: CallNonvirtualObjectMethodA: IMPLEMENT ME!"); + + return jni_NewLocalRef(env, NULL); +} + + +void _Jv_JNI_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, ...) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + va_list ap; + + o = (java_handle_t *) obj; + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + va_start(ap, methodID); + _Jv_jni_CallVoidMethod(o, c->vftbl, m, ap); + va_end(ap); +} + + +void _Jv_JNI_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, va_list args) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + + o = (java_handle_t *) obj; + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + _Jv_jni_CallVoidMethod(o, c->vftbl, m, args); +} + + +void _Jv_JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + + o = (java_handle_t *) obj; + c = LLNI_classinfo_unwrap(clazz); + m = (methodinfo *) methodID; + + _Jv_jni_CallVoidMethodA(o, c->vftbl, m, args); +} + + +/* Accessing Fields of Objects ************************************************/ + +/* GetFieldID ****************************************************************** + + Returns the field ID for an instance (nonstatic) field of a + class. The field is specified by its name and signature. The + GetField and SetField families of accessor functions + use field IDs to retrieve object fields. + +*******************************************************************************/ + +jfieldID _Jv_JNI_GetFieldID(JNIEnv *env, jclass clazz, const char *name, + const char *sig) +{ + classinfo *c; + fieldinfo *f; + utf *uname; + utf *udesc; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + + /* XXX NPE check? */ + + uname = utf_new_char((char *) name); + udesc = utf_new_char((char *) sig); + + f = class_findfield(c, uname, udesc); + + if (f == NULL) + exceptions_throw_nosuchfielderror(c, uname); + + return (jfieldID) f; +} + + +/* GetField Routines ***************************************************** + + This family of accessor routines returns the value of an instance + (nonstatic) field of an object. The field to access is specified by + a field ID obtained by calling GetFieldID(). + +*******************************************************************************/ + +#define GET_FIELD(o,type,f) \ + *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) + +#define JNI_GET_FIELD(name, type, intern) \ +type _Jv_JNI_Get##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID) \ +{ \ + intern ret; \ + \ + TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "Field(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID)); \ + \ + LLNI_CRITICAL_START; \ + \ + ret = GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID); \ + \ + LLNI_CRITICAL_END; \ + \ + return (type) ret; \ +} + +JNI_GET_FIELD(Boolean, jboolean, s4) +JNI_GET_FIELD(Byte, jbyte, s4) +JNI_GET_FIELD(Char, jchar, s4) +JNI_GET_FIELD(Short, jshort, s4) +JNI_GET_FIELD(Int, jint, s4) +JNI_GET_FIELD(Long, jlong, s8) +JNI_GET_FIELD(Float, jfloat, float) +JNI_GET_FIELD(Double, jdouble, double) + + +jobject _Jv_JNI_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID) +{ + java_handle_t *o; + + TRACEJNICALLS(("_Jv_JNI_GetObjectField(env=%p, obj=%p, fieldId=%p)", env, obj, fieldID)); + + LLNI_CRITICAL_START; + + o = LLNI_WRAP(GET_FIELD(LLNI_DIRECT((java_handle_t *) obj), java_object_t*, fieldID)); + + LLNI_CRITICAL_END; + + return jni_NewLocalRef(env, (jobject) o); +} + + +/* SetField Routines ***************************************************** + + This family of accessor routines sets the value of an instance + (nonstatic) field of an object. The field to access is specified by + a field ID obtained by calling GetFieldID(). + +*******************************************************************************/ + +#define SET_FIELD(o,type,f,value) \ + *((type *) (((intptr_t) (o)) + ((intptr_t) ((fieldinfo *) (f))->offset))) = (type) (value) + +#define JNI_SET_FIELD(name, type, intern) \ +void _Jv_JNI_Set##name##Field(JNIEnv *env, jobject obj, jfieldID fieldID, \ + type value) \ +{ \ + TRACEJNICALLS(("_Jv_JNI_Set" STR(name) "Field(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value)); \ + \ + LLNI_CRITICAL_START; \ + \ + SET_FIELD(LLNI_DIRECT((java_handle_t *) obj), intern, fieldID, value); \ + \ + LLNI_CRITICAL_START; \ +} + +JNI_SET_FIELD(Boolean, jboolean, s4) +JNI_SET_FIELD(Byte, jbyte, s4) +JNI_SET_FIELD(Char, jchar, s4) +JNI_SET_FIELD(Short, jshort, s4) +JNI_SET_FIELD(Int, jint, s4) +JNI_SET_FIELD(Long, jlong, s8) +JNI_SET_FIELD(Float, jfloat, float) +JNI_SET_FIELD(Double, jdouble, double) + + +void _Jv_JNI_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, + jobject value) +{ + TRACEJNICALLS(("_Jv_JNI_SetObjectField(env=%p, obj=%p, fieldId=%p, value=%p)", env, obj, fieldID, value)); + + LLNI_CRITICAL_START; + + SET_FIELD(obj, java_handle_t*, fieldID, LLNI_UNWRAP((java_handle_t*) value)); + + LLNI_CRITICAL_END; +} + + +/* Calling Static Methods *****************************************************/ + +/* GetStaticMethodID *********************************************************** + + Returns the method ID for a static method of a class. The method is + specified by its name and signature. + + GetStaticMethodID() causes an uninitialized class to be + initialized. + +*******************************************************************************/ + +jmethodID _Jv_JNI_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, + const char *sig) +{ + classinfo *c; + utf *uname; + utf *udesc; + methodinfo *m; + + TRACEJNICALLS(("_Jv_JNI_GetStaticMethodID(env=%p, clazz=%p, name=%s, sig=%s)", env, clazz, name, sig)); + + c = LLNI_classinfo_unwrap(clazz); + + if (c == NULL) + return NULL; + + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return NULL; + + /* try to get the static method of the class */ + + uname = utf_new_char((char *) name); + udesc = utf_new_char((char *) sig); + + m = class_resolvemethod(c, uname, udesc); + + if ((m == NULL) || !(m->flags & ACC_STATIC)) { + exceptions_throw_nosuchmethoderror(c, uname, udesc); + + return NULL; + } + + return (jmethodID) m; +} + + +#define JNI_CALL_STATIC_METHOD(name, type, intern) \ +type _Jv_JNI_CallStatic##name##Method(JNIEnv *env, jclass clazz, \ + jmethodID methodID, ...) \ +{ \ + methodinfo *m; \ + va_list ap; \ + type res; \ + \ + m = (methodinfo *) methodID; \ + \ + va_start(ap, methodID); \ + res = _Jv_jni_Call##intern##Method(NULL, NULL, m, ap); \ + va_end(ap); \ + \ + return res; \ +} + +JNI_CALL_STATIC_METHOD(Boolean, jboolean, Int) +JNI_CALL_STATIC_METHOD(Byte, jbyte, Int) +JNI_CALL_STATIC_METHOD(Char, jchar, Int) +JNI_CALL_STATIC_METHOD(Short, jshort, Int) +JNI_CALL_STATIC_METHOD(Int, jint, Int) +JNI_CALL_STATIC_METHOD(Long, jlong, Long) +JNI_CALL_STATIC_METHOD(Float, jfloat, Float) +JNI_CALL_STATIC_METHOD(Double, jdouble, Double) + + +#define JNI_CALL_STATIC_METHOD_V(name, type, intern) \ +type _Jv_JNI_CallStatic##name##MethodV(JNIEnv *env, jclass clazz, \ + jmethodID methodID, va_list args) \ +{ \ + methodinfo *m; \ + type res; \ + \ + m = (methodinfo *) methodID; \ + \ + res = _Jv_jni_Call##intern##Method(NULL, NULL, m, args); \ + \ + return res; \ +} + +JNI_CALL_STATIC_METHOD_V(Boolean, jboolean, Int) +JNI_CALL_STATIC_METHOD_V(Byte, jbyte, Int) +JNI_CALL_STATIC_METHOD_V(Char, jchar, Int) +JNI_CALL_STATIC_METHOD_V(Short, jshort, Int) +JNI_CALL_STATIC_METHOD_V(Int, jint, Int) +JNI_CALL_STATIC_METHOD_V(Long, jlong, Long) +JNI_CALL_STATIC_METHOD_V(Float, jfloat, Float) +JNI_CALL_STATIC_METHOD_V(Double, jdouble, Double) + + +#define JNI_CALL_STATIC_METHOD_A(name, type, intern) \ +type _Jv_JNI_CallStatic##name##MethodA(JNIEnv *env, jclass clazz, \ + jmethodID methodID, const jvalue *args) \ +{ \ + methodinfo *m; \ + type res; \ + \ + m = (methodinfo *) methodID; \ + \ + res = _Jv_jni_Call##intern##MethodA(NULL, NULL, m, args); \ + \ + return res; \ +} + +JNI_CALL_STATIC_METHOD_A(Boolean, jboolean, Int) +JNI_CALL_STATIC_METHOD_A(Byte, jbyte, Int) +JNI_CALL_STATIC_METHOD_A(Char, jchar, Int) +JNI_CALL_STATIC_METHOD_A(Short, jshort, Int) +JNI_CALL_STATIC_METHOD_A(Int, jint, Int) +JNI_CALL_STATIC_METHOD_A(Long, jlong, Long) +JNI_CALL_STATIC_METHOD_A(Float, jfloat, Float) +JNI_CALL_STATIC_METHOD_A(Double, jdouble, Double) + + +jobject _Jv_JNI_CallStaticObjectMethod(JNIEnv *env, jclass clazz, + jmethodID methodID, ...) +{ + methodinfo *m; + java_handle_t *o; + va_list ap; + + TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID)); + + m = (methodinfo *) methodID; + + va_start(ap, methodID); + o = _Jv_jni_CallObjectMethod(NULL, NULL, m, ap); + va_end(ap); + + return jni_NewLocalRef(env, (jobject) o); +} + + +jobject _Jv_JNI_CallStaticObjectMethodV(JNIEnv *env, jclass clazz, + jmethodID methodID, va_list args) +{ + methodinfo *m; + java_handle_t *o; + + TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); + + m = (methodinfo *) methodID; + + o = _Jv_jni_CallObjectMethod(NULL, NULL, m, args); + + return jni_NewLocalRef(env, (jobject) o); +} + + +jobject _Jv_JNI_CallStaticObjectMethodA(JNIEnv *env, jclass clazz, + jmethodID methodID, const jvalue *args) +{ + methodinfo *m; + java_handle_t *o; + + TRACEJNICALLS(("_Jv_JNI_CallStaticObjectMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); + + m = (methodinfo *) methodID; + + o = _Jv_jni_CallObjectMethodA(NULL, NULL, m, args); + + return jni_NewLocalRef(env, (jobject) o); +} + + +void _Jv_JNI_CallStaticVoidMethod(JNIEnv *env, jclass clazz, + jmethodID methodID, ...) +{ + methodinfo *m; + va_list ap; + + TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethod(env=%p, clazz=%p, methodID=%p, ...)", env, clazz, methodID)); + + m = (methodinfo *) methodID; + + va_start(ap, methodID); + _Jv_jni_CallVoidMethod(NULL, NULL, m, ap); + va_end(ap); +} + + +void _Jv_JNI_CallStaticVoidMethodV(JNIEnv *env, jclass clazz, + jmethodID methodID, va_list args) +{ + methodinfo *m; + + TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodV(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); + + m = (methodinfo *) methodID; + + _Jv_jni_CallVoidMethod(NULL, NULL, m, args); +} + + +void _Jv_JNI_CallStaticVoidMethodA(JNIEnv *env, jclass clazz, + jmethodID methodID, const jvalue * args) +{ + methodinfo *m; + + TRACEJNICALLS(("_Jv_JNI_CallStaticVoidMethodA(env=%p, clazz=%p, methodID=%p, args=%p)", env, clazz, methodID, args)); + + m = (methodinfo *) methodID; + + _Jv_jni_CallVoidMethodA(NULL, NULL, m, args); +} + + +/* Accessing Static Fields ****************************************************/ + +/* GetStaticFieldID ************************************************************ + + Returns the field ID for a static field of a class. The field is + specified by its name and signature. The GetStaticField and + SetStaticField families of accessor functions use field IDs + to retrieve static fields. + +*******************************************************************************/ + +jfieldID _Jv_JNI_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, + const char *sig) +{ + classinfo *c; + fieldinfo *f; + utf *uname; + utf *usig; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + + uname = utf_new_char((char *) name); + usig = utf_new_char((char *) sig); + + f = class_findfield(c, uname, usig); + + if (f == NULL) + exceptions_throw_nosuchfielderror(c, uname); + + return (jfieldID) f; +} + + +/* GetStaticField ******************************************************** + + This family of accessor routines returns the value of a static + field of an object. + +*******************************************************************************/ + +#define JNI_GET_STATIC_FIELD(name, type, field) \ +type _Jv_JNI_GetStatic##name##Field(JNIEnv *env, jclass clazz, \ + jfieldID fieldID) \ +{ \ + classinfo *c; \ + fieldinfo *f; \ + \ + STATISTICS(jniinvokation()); \ + \ + c = LLNI_classinfo_unwrap(clazz); \ + f = (fieldinfo *) fieldID; \ + \ + if (!(c->state & CLASS_INITIALIZED)) \ + if (!initialize_class(c)) \ + return 0; \ + \ + return f->value->field; \ +} + +JNI_GET_STATIC_FIELD(Boolean, jboolean, i) +JNI_GET_STATIC_FIELD(Byte, jbyte, i) +JNI_GET_STATIC_FIELD(Char, jchar, i) +JNI_GET_STATIC_FIELD(Short, jshort, i) +JNI_GET_STATIC_FIELD(Int, jint, i) +JNI_GET_STATIC_FIELD(Long, jlong, l) +JNI_GET_STATIC_FIELD(Float, jfloat, f) +JNI_GET_STATIC_FIELD(Double, jdouble, d) + + +jobject _Jv_JNI_GetStaticObjectField(JNIEnv *env, jclass clazz, + jfieldID fieldID) +{ + classinfo *c; + fieldinfo *f; + java_handle_t *h; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + f = (fieldinfo *) fieldID; + + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return NULL; + + h = (java_handle_t*) LLNI_WRAP(f->value->a); + + return jni_NewLocalRef(env, (jobject) h); +} + + +/* SetStaticField ******************************************************* + + This family of accessor routines sets the value of a static field + of an object. + +*******************************************************************************/ + +#define JNI_SET_STATIC_FIELD(name, type, field) \ +void _Jv_JNI_SetStatic##name##Field(JNIEnv *env, jclass clazz, \ + jfieldID fieldID, \ + type value) \ +{ \ + classinfo *c; \ + fieldinfo *f; \ + \ + STATISTICS(jniinvokation()); \ + \ + c = LLNI_classinfo_unwrap(clazz); \ + f = (fieldinfo *) fieldID; \ + \ + if (!(c->state & CLASS_INITIALIZED)) \ + if (!initialize_class(c)) \ + return; \ + \ + f->value->field = value; \ +} + +JNI_SET_STATIC_FIELD(Boolean, jboolean, i) +JNI_SET_STATIC_FIELD(Byte, jbyte, i) +JNI_SET_STATIC_FIELD(Char, jchar, i) +JNI_SET_STATIC_FIELD(Short, jshort, i) +JNI_SET_STATIC_FIELD(Int, jint, i) +JNI_SET_STATIC_FIELD(Long, jlong, l) +JNI_SET_STATIC_FIELD(Float, jfloat, f) +JNI_SET_STATIC_FIELD(Double, jdouble, d) + + +void _Jv_JNI_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, + jobject value) +{ + classinfo *c; + fieldinfo *f; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + f = (fieldinfo *) fieldID; + + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return; + + f->value->a = LLNI_UNWRAP((java_handle_t *) value); +} + + +/* String Operations **********************************************************/ + +/* NewString ******************************************************************* + + Create new java.lang.String object from an array of Unicode + characters. + +*******************************************************************************/ + +jstring jni_NewString(JNIEnv *env, const jchar *buf, jsize len) +{ + TRACEJNICALLS(("jni_NewString(env=%p, buf=%p, len=%d)", env, buf, len)); + + java_handle_chararray_t* a = builtin_newarray_char(len); + + if (a == NULL) + return NULL; + + /* copy text */ + for (jsize i = 0; i < len; i++) + LLNI_array_direct(a, i) = buf[i]; + + java_handle_t* h = builtin_new(class_java_lang_String); + + if (h == NULL) + return NULL; + + java_lang_String s(h, a, len, 0); + + return (jstring) jni_NewLocalRef(env, (jobject) s.get_handle()); +} + + +static jchar emptyStringJ[]={0,0}; + +/* GetStringLength ************************************************************* + + Returns the length (the count of Unicode characters) of a Java + string. + +*******************************************************************************/ + +jsize jni_GetStringLength(JNIEnv *env, jstring str) +{ + TRACEJNICALLSENTER(("jni_GetStringLength(env=%p, str=%p)", env, str)); + + java_lang_String s(str); + jsize count = s.get_count(); + + TRACEJNICALLSEXIT(("->%d)", count)); + + return count; +} + + +/* GetStringChars ************************************************************** + + Returns a pointer to the array of Unicode characters of the + string. This pointer is valid until ReleaseStringChars() is called. + +*******************************************************************************/ + +const jchar* jni_GetStringChars(JNIEnv *env, jstring str, jboolean *isCopy) +{ + u2 *stringbuffer; + int32_t i; + + TRACEJNICALLS(("jni_GetStringChars(env=%p, str=%p, isCopy=%p)", env, str, isCopy)); + + if (str == NULL) + // FIXME This is really ugly. + return emptyStringJ; + + java_lang_String s(str); + + java_handle_chararray_t* ca = s.get_value(); + int32_t count = s.get_count(); + int32_t offset = s.get_offset(); + + if (ca == NULL) + return NULL; + + /* allocate memory */ + + stringbuffer = MNEW(u2, count + 1); + + /* copy text */ + + for (i = 0; i < count; i++) + stringbuffer[i] = LLNI_array_direct(ca, offset + i); + + /* terminate string */ + + stringbuffer[i] = '\0'; + + if (isCopy) + *isCopy = JNI_TRUE; + + return (jchar*) stringbuffer; +} + + +/* ReleaseStringChars ********************************************************** + + Informs the VM that the native code no longer needs access to + chars. The chars argument is a pointer obtained from string using + GetStringChars(). + +*******************************************************************************/ + +void _Jv_JNI_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars) +{ + TRACEJNICALLS(("jni_ReleaseStringChars(env=%p, str=%p, chars=%p)", env, str, chars)); + + // FIXME + if (chars == emptyStringJ) + return; + + java_lang_String s(str); + int32_t count = s.get_count(); + + MFREE(((jchar*) chars), jchar, count + 1); +} + + +/* NewStringUTF **************************************************************** + + Constructs a new java.lang.String object from an array of UTF-8 + characters. + +*******************************************************************************/ + +jstring jni_NewStringUTF(JNIEnv *env, const char *bytes) +{ + TRACEJNICALLS(("jni_NewStringUTF(env=%p, bytes=%s)", env, bytes)); + + java_handle_t *h = javastring_safe_new_from_utf8(bytes); + + return (jstring) jni_NewLocalRef(env, (jobject) h); +} + + +/****************** returns the utf8 length in bytes of a string *******************/ + +jsize jni_GetStringUTFLength(JNIEnv *env, jstring string) +{ + TRACEJNICALLS(("jni_GetStringUTFLength(env=%p, string=%p)", env, string)); + + java_lang_String s(string); + java_handle_chararray_t* ca = s.get_value(); + int32_t count = s.get_count(); + + // FIXME GC critical section! + int32_t length = u2_utflength(ca->data, count); + + return length; +} + + +/* GetStringUTFChars *********************************************************** + + Returns a pointer to an array of UTF-8 characters of the + string. This array is valid until it is released by + ReleaseStringUTFChars(). + +*******************************************************************************/ + +const char *_Jv_JNI_GetStringUTFChars(JNIEnv *env, jstring string, + jboolean *isCopy) +{ + utf *u; + + STATISTICS(jniinvokation()); + + if (string == NULL) + return ""; + + if (isCopy) + *isCopy = JNI_TRUE; + + u = javastring_toutf((java_handle_t *) string, false); + + if (u != NULL) + return u->text; + + return ""; +} + + +/* ReleaseStringUTFChars ******************************************************* + + Informs the VM that the native code no longer needs access to + utf. The utf argument is a pointer derived from string using + GetStringUTFChars(). + +*******************************************************************************/ + +void _Jv_JNI_ReleaseStringUTFChars(JNIEnv *env, jstring string, const char *utf) +{ + STATISTICS(jniinvokation()); + + /* XXX we don't release utf chars right now, perhaps that should be done + later. Since there is always one reference the garbage collector will + never get them */ +} + + +/* Array Operations ***********************************************************/ + +/* GetArrayLength ************************************************************** + + Returns the number of elements in the array. + +*******************************************************************************/ + +jsize _Jv_JNI_GetArrayLength(JNIEnv *env, jarray array) +{ + java_handle_t *a; + jsize size; + + TRACEJNICALLS(("_Jv_JNI_GetArrayLength(env=%p, array=%p)", env, array)); + + a = (java_handle_t *) array; + + size = LLNI_array_size(a); + + return size; +} + + +/* NewObjectArray ************************************************************** + + Constructs a new array holding objects in class elementClass. All + elements are initially set to initialElement. + +*******************************************************************************/ + +jobjectArray _Jv_JNI_NewObjectArray(JNIEnv *env, jsize length, + jclass elementClass, jobject initialElement) +{ + classinfo *c; + java_handle_t *o; + java_handle_objectarray_t *oa; + s4 i; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(elementClass); + o = (java_handle_t *) initialElement; + + if (length < 0) { + exceptions_throw_negativearraysizeexception(); + return NULL; + } + + oa = builtin_anewarray(length, c); + + if (oa == NULL) + return NULL; + + /* set all elements to initialElement */ + + for (i = 0; i < length; i++) + array_objectarray_element_set(oa, i, o); + + return (jobjectArray) jni_NewLocalRef(env, (jobject) oa); +} + + +jobject _Jv_JNI_GetObjectArrayElement(JNIEnv *env, jobjectArray array, + jsize index) +{ + java_handle_objectarray_t *oa; + java_handle_t *o; + + STATISTICS(jniinvokation()); + + oa = (java_handle_objectarray_t *) array; + + if (index >= LLNI_array_size(oa)) { + exceptions_throw_arrayindexoutofboundsexception(); + return NULL; + } + + o = array_objectarray_element_get(oa, index); + + return jni_NewLocalRef(env, (jobject) o); +} + + +void _Jv_JNI_SetObjectArrayElement(JNIEnv *env, jobjectArray array, + jsize index, jobject val) +{ + java_handle_objectarray_t *oa; + java_handle_t *o; + + STATISTICS(jniinvokation()); + + oa = (java_handle_objectarray_t *) array; + o = (java_handle_t *) val; + + if (index >= LLNI_array_size(oa)) { + exceptions_throw_arrayindexoutofboundsexception(); + return; + } + + /* check if the class of value is a subclass of the element class + of the array */ + + if (!builtin_canstore(oa, o)) + return; + + array_objectarray_element_set(oa, index, o); +} + + +#define JNI_NEW_ARRAY(name, type, intern) \ +type _Jv_JNI_New##name##Array(JNIEnv *env, jsize len) \ +{ \ + java_handle_##intern##array_t *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + if (len < 0) { \ + exceptions_throw_negativearraysizeexception(); \ + return NULL; \ + } \ + \ + a = builtin_newarray_##intern(len); \ + \ + return (type) jni_NewLocalRef(env, (jobject) a); \ +} + +JNI_NEW_ARRAY(Boolean, jbooleanArray, boolean) +JNI_NEW_ARRAY(Byte, jbyteArray, byte) +JNI_NEW_ARRAY(Char, jcharArray, char) +JNI_NEW_ARRAY(Short, jshortArray, short) +JNI_NEW_ARRAY(Int, jintArray, int) +JNI_NEW_ARRAY(Long, jlongArray, long) +JNI_NEW_ARRAY(Float, jfloatArray, float) +JNI_NEW_ARRAY(Double, jdoubleArray, double) + + +/* GetArrayElements ********************************************* + + A family of functions that returns the body of the primitive array. + +*******************************************************************************/ + +#define JNI_GET_ARRAY_ELEMENTS(name, type, intern) \ +type *_Jv_JNI_Get##name##ArrayElements(JNIEnv *env, type##Array array, \ + jboolean *isCopy) \ +{ \ + java_handle_##intern##array_t *a; \ + \ + TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayElements(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); \ + \ + a = (java_handle_##intern##array_t *) array; \ + \ + if (isCopy) \ + *isCopy = JNI_FALSE; \ + \ + return (type *) LLNI_array_data(a); \ +} + +JNI_GET_ARRAY_ELEMENTS(Boolean, jboolean, boolean) +JNI_GET_ARRAY_ELEMENTS(Byte, jbyte, byte) +JNI_GET_ARRAY_ELEMENTS(Char, jchar, char) +JNI_GET_ARRAY_ELEMENTS(Short, jshort, short) +JNI_GET_ARRAY_ELEMENTS(Int, jint, int) +JNI_GET_ARRAY_ELEMENTS(Long, jlong, long) +JNI_GET_ARRAY_ELEMENTS(Float, jfloat, float) +JNI_GET_ARRAY_ELEMENTS(Double, jdouble, double) + + +/* ReleaseArrayElements ***************************************** + + A family of functions that informs the VM that the native code no + longer needs access to elems. The elems argument is a pointer + derived from array using the corresponding + GetArrayElements() function. If necessary, this + function copies back all changes made to elems to the original + array. + +*******************************************************************************/ + +#define JNI_RELEASE_ARRAY_ELEMENTS(name, type, intern, intern2) \ +void _Jv_JNI_Release##name##ArrayElements(JNIEnv *env, type##Array array, \ + type *elems, jint mode) \ +{ \ + java_handle_##intern##array_t *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + a = (java_handle_##intern##array_t *) array; \ + \ + if (elems != (type *) LLNI_array_data(a)) { \ + switch (mode) { \ + case JNI_COMMIT: \ + MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \ + break; \ + case 0: \ + MCOPY(LLNI_array_data(a), elems, intern2, LLNI_array_size(a)); \ + /* XXX TWISTI how should it be freed? */ \ + break; \ + case JNI_ABORT: \ + /* XXX TWISTI how should it be freed? */ \ + break; \ + } \ + } \ +} + +JNI_RELEASE_ARRAY_ELEMENTS(Boolean, jboolean, boolean, u1) +JNI_RELEASE_ARRAY_ELEMENTS(Byte, jbyte, byte, s1) +JNI_RELEASE_ARRAY_ELEMENTS(Char, jchar, char, u2) +JNI_RELEASE_ARRAY_ELEMENTS(Short, jshort, short, s2) +JNI_RELEASE_ARRAY_ELEMENTS(Int, jint, int, s4) +JNI_RELEASE_ARRAY_ELEMENTS(Long, jlong, long, s8) +JNI_RELEASE_ARRAY_ELEMENTS(Float, jfloat, float, float) +JNI_RELEASE_ARRAY_ELEMENTS(Double, jdouble, double, double) + + +/* GetArrayRegion ********************************************** + + A family of functions that copies a region of a primitive array + into a buffer. + +*******************************************************************************/ + +#define JNI_GET_ARRAY_REGION(name, type, intern, intern2) \ +void _Jv_JNI_Get##name##ArrayRegion(JNIEnv *env, type##Array array, \ + jsize start, jsize len, type *buf) \ +{ \ + java_handle_##intern##array_t *a; \ + \ + TRACEJNICALLS(("_Jv_JNI_Get" STR(name) "ArrayRegion(env=%p, array=%p, start=%d, len=%d, buf=%p)", env, array, start, len, buf)); \ + \ + a = (java_handle_##intern##array_t *) array; \ + \ + if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \ + exceptions_throw_arrayindexoutofboundsexception(); \ + else \ + MCOPY(buf, &LLNI_array_direct(a, start), intern2, len); \ +} + +JNI_GET_ARRAY_REGION(Boolean, jboolean, boolean, u1) +JNI_GET_ARRAY_REGION(Byte, jbyte, byte, s1) +JNI_GET_ARRAY_REGION(Char, jchar, char, u2) +JNI_GET_ARRAY_REGION(Short, jshort, short, s2) +JNI_GET_ARRAY_REGION(Int, jint, int, s4) +JNI_GET_ARRAY_REGION(Long, jlong, long, s8) +JNI_GET_ARRAY_REGION(Float, jfloat, float, float) +JNI_GET_ARRAY_REGION(Double, jdouble, double, double) + + +/* SetArrayRegion ********************************************** + + A family of functions that copies back a region of a primitive + array from a buffer. + +*******************************************************************************/ + +#define JNI_SET_ARRAY_REGION(name, type, intern, intern2) \ +void _Jv_JNI_Set##name##ArrayRegion(JNIEnv *env, type##Array array, \ + jsize start, jsize len, const type *buf) \ +{ \ + java_handle_##intern##array_t *a; \ + \ + STATISTICS(jniinvokation()); \ + \ + a = (java_handle_##intern##array_t *) array; \ + \ + if ((start < 0) || (len < 0) || (start + len > LLNI_array_size(a))) \ + exceptions_throw_arrayindexoutofboundsexception(); \ + else \ + MCOPY(&LLNI_array_direct(a, start), buf, intern2, len); \ +} + +JNI_SET_ARRAY_REGION(Boolean, jboolean, boolean, u1) +JNI_SET_ARRAY_REGION(Byte, jbyte, byte, s1) +JNI_SET_ARRAY_REGION(Char, jchar, char, u2) +JNI_SET_ARRAY_REGION(Short, jshort, short, s2) +JNI_SET_ARRAY_REGION(Int, jint, int, s4) +JNI_SET_ARRAY_REGION(Long, jlong, long, s8) +JNI_SET_ARRAY_REGION(Float, jfloat, float, float) +JNI_SET_ARRAY_REGION(Double, jdouble, double, double) + + +/* Registering Native Methods *************************************************/ + +/* RegisterNatives ************************************************************* + + Registers native methods with the class specified by the clazz + argument. The methods parameter specifies an array of + JNINativeMethod structures that contain the names, signatures, and + function pointers of the native methods. The nMethods parameter + specifies the number of native methods in the array. + +*******************************************************************************/ + +jint _Jv_JNI_RegisterNatives(JNIEnv *env, jclass clazz, + const JNINativeMethod *methods, jint nMethods) +{ + classinfo *c; + + STATISTICS(jniinvokation()); + + c = LLNI_classinfo_unwrap(clazz); + + /* XXX: if implemented this needs a call to jvmti_NativeMethodBind + if (jvmti) jvmti_NativeMethodBind(method, address, new_address_ptr); + */ + + native_method_register(c->name, methods, nMethods); + + return 0; +} + + +/* UnregisterNatives *********************************************************** + + Unregisters native methods of a class. The class goes back to the + state before it was linked or registered with its native method + functions. + + This function should not be used in normal native code. Instead, it + provides special programs a way to reload and relink native + libraries. + +*******************************************************************************/ + +jint _Jv_JNI_UnregisterNatives(JNIEnv *env, jclass clazz) +{ + STATISTICS(jniinvokation()); + + /* XXX TWISTI hmm, maybe we should not support that (like kaffe) */ + + log_text("JNI-Call: UnregisterNatives: IMPLEMENT ME!!!"); + + return 0; +} + + +/* Monitor Operations *********************************************************/ + +/* MonitorEnter **************************************************************** + + Enters the monitor associated with the underlying Java object + referred to by obj. + +*******************************************************************************/ + +jint _Jv_JNI_MonitorEnter(JNIEnv *env, jobject obj) +{ + STATISTICS(jniinvokation()); + + if (obj == NULL) { + exceptions_throw_nullpointerexception(); + return JNI_ERR; + } + + LOCK_MONITOR_ENTER(obj); + + return JNI_OK; +} + + +/* MonitorExit ***************************************************************** + + The current thread must be the owner of the monitor associated with + the underlying Java object referred to by obj. The thread + decrements the counter indicating the number of times it has + entered this monitor. If the value of the counter becomes zero, the + current thread releases the monitor. + +*******************************************************************************/ + +jint _Jv_JNI_MonitorExit(JNIEnv *env, jobject obj) +{ + STATISTICS(jniinvokation()); + + if (obj == NULL) { + exceptions_throw_nullpointerexception(); + return JNI_ERR; + } + + LOCK_MONITOR_EXIT(obj); + + return JNI_OK; +} + + +/* JavaVM Interface ***********************************************************/ + +/* GetJavaVM ******************************************************************* + + Returns the Java VM interface (used in the Invocation API) + associated with the current thread. The result is placed at the + location pointed to by the second argument, vm. + +*******************************************************************************/ + +jint _Jv_JNI_GetJavaVM(JNIEnv *env, JavaVM **javavm) +{ + STATISTICS(jniinvokation()); + + *javavm = VM::get_current()->get_javavm(); + + return 0; +} + + +/* GetStringRegion ************************************************************* + + Copies len number of Unicode characters beginning at offset start + to the given buffer buf. + + Throws StringIndexOutOfBoundsException on index overflow. + +*******************************************************************************/ + +void jni_GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, jchar *buf) +{ + java_lang_String s(str); + java_handle_chararray_t* ca = s.get_value(); + int32_t count = s.get_count(); + + if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) { + exceptions_throw_stringindexoutofboundsexception(); + return; + } + + MCOPY(buf, &LLNI_array_direct(ca, start), u2, len); +} + + +/* GetStringUTFRegion ********************************************************** + + Translates len number of Unicode characters beginning at offset + start into UTF-8 format and place the result in the given buffer + buf. + + Throws StringIndexOutOfBoundsException on index overflow. + +*******************************************************************************/ + +void jni_GetStringUTFRegion(JNIEnv* env, jstring str, jsize start, jsize len, char *buf) +{ + TRACEJNICALLS(("jni_GetStringUTFRegion(env=%p, str=%p, start=%d, len=%d, buf=%p)", env, str, start, len, buf)); + + java_lang_String s(str); + java_handle_chararray_t* ca = s.get_value(); + int32_t count = s.get_count(); + int32_t offset = s.get_offset(); + + if ((start < 0) || (len < 0) || (start > count) || (start + len > count)) { + exceptions_throw_stringindexoutofboundsexception(); + return; + } + + int32_t i; + + for (i = 0; i < len; i++) + buf[i] = LLNI_array_direct(ca, offset + start + i); + + buf[i] = '\0'; +} + + +/* GetPrimitiveArrayCritical *************************************************** + + Obtain a direct pointer to array elements. + + ATTENTION: Critical section keeps open when this function returns! + See ReleasePrimitiveArrayCritical. + +*******************************************************************************/ + +void* jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy) +{ + java_handle_t* h; + java_array_t* a; + arraydescriptor* ad; + void* data; + + TRACEJNICALLS(("jni_GetPrimitiveArrayCritical(env=%p, array=%p, isCopy=%d)", env, array, isCopy)); + + if (isCopy != NULL) { + *isCopy = JNI_FALSE; + } + + LLNI_CRITICAL_START; + + h = (java_handle_t*) array; + a = (java_array_t*) LLNI_UNWRAP(h); + ad = a->objheader.vftbl->arraydesc; + + /* Sanity check. */ + + assert(ad != NULL); + + data = (void*) (((intptr_t) a) + ad->dataoffset); + + return data; +} + + +/* ReleasePrimitiveArrayCritical *********************************************** + + No specific documentation. + + ATTENTION: This function closes the critical section opened in + GetPrimitiveArrayCritical! + +*******************************************************************************/ + +void jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode) +{ + TRACEJNICALLS(("jni_ReleasePrimitiveArrayCritical(env=%p, array=%p, carray=%p, mode=%d)", env, array, carray, mode)); + + LLNI_CRITICAL_END; +} + + +/* GetStringCritical *********************************************************** + + The semantics of these two functions are similar to the existing + Get/ReleaseStringChars functions. + +*******************************************************************************/ + +const jchar *_Jv_JNI_GetStringCritical(JNIEnv *env, jstring string, + jboolean *isCopy) +{ + STATISTICS(jniinvokation()); + + return jni_GetStringChars(env, string, isCopy); +} + + +void _Jv_JNI_ReleaseStringCritical(JNIEnv *env, jstring string, + const jchar *cstring) +{ + STATISTICS(jniinvokation()); + + _Jv_JNI_ReleaseStringChars(env, string, cstring); +} + + +jweak _Jv_JNI_NewWeakGlobalRef(JNIEnv* env, jobject obj) +{ + TRACEJNICALLS(("_Jv_JNI_NewWeakGlobalRef(env=%p, obj=%p): IMPLEMENT ME!", env, obj)); + + return (jweak) obj; +} + + +void _Jv_JNI_DeleteWeakGlobalRef(JNIEnv* env, jweak ref) +{ + TRACEJNICALLS(("_Jv_JNI_DeleteWeakGlobalRef(env=%p, ref=%p): IMPLEMENT ME", env, ref)); +} + + +/* NewGlobalRef **************************************************************** + + Creates a new global reference to the object referred to by the obj + argument. + +*******************************************************************************/ + +jobject jni_NewGlobalRef(JNIEnv* env, jobject obj) +{ + hashtable_global_ref_entry *gre; + u4 key; /* hashkey */ + u4 slot; /* slot in hashtable */ + java_handle_t *o; + + TRACEJNICALLS(("jni_NewGlobalRef(env=%p, obj=%p)", env, obj)); + + o = (java_handle_t *) obj; + + hashtable_global_ref->mutex->lock(); + + LLNI_CRITICAL_START; + + /* normally addresses are aligned to 4, 8 or 16 bytes */ + + key = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */ + slot = key & (hashtable_global_ref->size - 1); + gre = (hashtable_global_ref_entry*) hashtable_global_ref->ptr[slot]; + + /* search external hash chain for the entry */ + + while (gre) { + if (gre->o == LLNI_DIRECT(o)) { + /* global object found, increment the reference */ + + gre->refs++; + + break; + } + + gre = gre->hashlink; /* next element in external chain */ + } + + LLNI_CRITICAL_END; + + /* global ref not found, create a new one */ + + if (gre == NULL) { + gre = (hashtable_global_ref_entry*) heap_alloc_uncollectable(sizeof(hashtable_global_ref_entry)); + +#if defined(ENABLE_GC_CACAO) + /* register global ref with the GC */ + + gc_reference_register(&(gre->o), GC_REFTYPE_JNI_GLOBALREF); +#endif + + LLNI_CRITICAL_START; + + gre->o = LLNI_DIRECT(o); + gre->refs = 1; + + LLNI_CRITICAL_END; + + /* insert entry into hashtable */ + + gre->hashlink = (hashtable_global_ref_entry*) hashtable_global_ref->ptr[slot]; + + hashtable_global_ref->ptr[slot] = gre; + + /* update number of hashtable-entries */ + + hashtable_global_ref->entries++; + } + + hashtable_global_ref->mutex->unlock(); + +#if defined(ENABLE_HANDLES) + return gre; +#else + return obj; +#endif +} + + +/* DeleteGlobalRef ************************************************************* + + Deletes the global reference pointed to by globalRef. + +*******************************************************************************/ + +void jni_DeleteGlobalRef(JNIEnv* env, jobject globalRef) +{ + hashtable_global_ref_entry *gre; + hashtable_global_ref_entry *prevgre; + u4 key; /* hashkey */ + u4 slot; /* slot in hashtable */ + java_handle_t *o; + + TRACEJNICALLS(("jni_DeleteGlobalRef(env=%p, globalRef=%p)", env, globalRef)); + + o = (java_handle_t *) globalRef; + + hashtable_global_ref->mutex->lock(); + + LLNI_CRITICAL_START; + + /* normally addresses are aligned to 4, 8 or 16 bytes */ + + key = heap_hashcode(LLNI_DIRECT(o)) >> 4; /* align to 16-byte boundaries */ + slot = key & (hashtable_global_ref->size - 1); + gre = (hashtable_global_ref_entry*) hashtable_global_ref->ptr[slot]; + + /* initialize prevgre */ + + prevgre = NULL; + + /* search external hash chain for the entry */ + + while (gre) { + if (gre->o == LLNI_DIRECT(o)) { + /* global object found, decrement the reference count */ + + gre->refs--; + + /* if reference count is 0, remove the entry */ + + if (gre->refs == 0) { + /* special handling if it's the first in the chain */ + + if (prevgre == NULL) + hashtable_global_ref->ptr[slot] = gre->hashlink; + else + prevgre->hashlink = gre->hashlink; + +#if defined(ENABLE_GC_CACAO) + /* unregister global ref with the GC */ + + gc_reference_unregister(&(gre->o)); +#endif + + heap_free(gre); + } + + LLNI_CRITICAL_END; + + hashtable_global_ref->mutex->unlock(); + + return; + } + + prevgre = gre; /* save current pointer for removal */ + gre = gre->hashlink; /* next element in external chain */ + } + + log_println("jni_DeleteGlobalRef: Global reference not found."); + + LLNI_CRITICAL_END; + + hashtable_global_ref->mutex->unlock(); +} + + +/* ExceptionCheck ************************************************************** + + Returns JNI_TRUE when there is a pending exception; otherwise, + returns JNI_FALSE. + +*******************************************************************************/ + +jboolean _Jv_JNI_ExceptionCheck(JNIEnv *env) +{ + java_handle_t *o; + + STATISTICS(jniinvokation()); + + o = exceptions_get_exception(); + + return (o != NULL) ? JNI_TRUE : JNI_FALSE; +} + + +/* New JNI 1.4 functions ******************************************************/ + +/* NewDirectByteBuffer ********************************************************* + + Allocates and returns a direct java.nio.ByteBuffer referring to the + block of memory starting at the memory address address and + extending capacity bytes. + +*******************************************************************************/ + +jobject jni_NewDirectByteBuffer(JNIEnv *env, void *address, jlong capacity) +{ +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity)); + + // Allocate a gnu.classpath.Pointer{32,64} object. + +# if SIZEOF_VOID_P == 8 + java_handle_t* h = builtin_new(class_gnu_classpath_Pointer64); +# else + java_handle_t* h = builtin_new(class_gnu_classpath_Pointer32); +# endif + + if (h == NULL) + return NULL; + + gnu_classpath_Pointer p(h, address); + + // Create a java.nio.DirectByteBufferImpl$ReadWrite object. + + java_handle_t* nbuf = + (java_handle_t*) jni_NewObject(env, (jclass) class_java_nio_DirectByteBufferImpl_ReadWrite, + (jmethodID) dbbirw_init, NULL, p.get_handle(), + (jint) capacity, (jint) capacity, (jint) 0); + + // Add a local reference and return the value. + + TRACEJNICALLSEXIT(("->%p", nbuf)); + + return jni_NewLocalRef(env, (jobject) nbuf); + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + jobject o; + int64_t addr; + int32_t cap; + + TRACEJNICALLSENTER(("jni_NewDirectByteBuffer(env=%p, address=%p, capacity=%ld)", env, address, capacity)); + + /* Be paranoid about address sign-extension. */ + + addr = (int64_t) ((uintptr_t) address); + cap = (int32_t) capacity; + + o = jni_NewObject(env, (jclass) class_java_nio_DirectByteBuffer, + (jmethodID) dbb_init, addr, cap); + + /* Add local reference and return the value. */ + + TRACEJNICALLSEXIT(("->%p", o)); + + return jni_NewLocalRef(env, o); + +# else +# error unknown classpath configuration +# endif + +#else + vm_abort("jni_NewDirectByteBuffer: Not implemented in this configuration."); + + /* keep compiler happy */ + + return NULL; +#endif +} + + +/* GetDirectBufferAddress ****************************************************** + + Fetches and returns the starting address of the memory region + referenced by the given direct java.nio.Buffer. + +*******************************************************************************/ + +void* jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) +{ +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + TRACEJNICALLSENTER(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf)); + + /* Prevent compiler warning. */ + + java_handle_t* h = (java_handle_t *) buf; + + if ((h != NULL) && !builtin_instanceof(h, class_java_nio_Buffer)) + return NULL; + + java_nio_DirectByteBufferImpl dbb(buf); + java_handle_t* address = dbb.get_address(); + + if (address == NULL) { + TRACEJNICALLSEXIT(("->%p", NULL)); + return NULL; + } + + gnu_classpath_Pointer p(address); + void* data = p.get_data(); + + TRACEJNICALLSEXIT(("->%p", data)); + + return data; + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + TRACEJNICALLS(("jni_GetDirectBufferAddress(env=%p, buf=%p)", env, buf)); + + java_nio_Buffer jnb(buf); + + if (jnb.is_non_null() && !builtin_instanceof(jnb.get_handle(), class_sun_nio_ch_DirectBuffer)) + return NULL; + + void* address = jnb.get_address(); + + return address; + +# else +# error unknown classpath configuration +# endif + +#else + + vm_abort("jni_GetDirectBufferAddress: Not implemented in this configuration."); + + // Keep compiler happy. + return NULL; + +#endif +} + + +/* GetDirectBufferCapacity ***************************************************** + + Fetches and returns the capacity in bytes of the memory region + referenced by the given direct java.nio.Buffer. + +*******************************************************************************/ + +jlong jni_GetDirectBufferCapacity(JNIEnv* env, jobject buf) +{ +#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + TRACEJNICALLS(("jni_GetDirectBufferCapacity(env=%p, buf=%p)", env, buf)); + + java_handle_t* h = (java_handle_t *) buf; + + if (!builtin_instanceof(h, class_java_nio_DirectByteBufferImpl)) + return -1; + + java_nio_Buffer b(h); + jlong capacity = b.get_cap(); + + return capacity; +#else + vm_abort("jni_GetDirectBufferCapacity: not implemented in this configuration"); + + // Keep compiler happy. + + return 0; +#endif +} + + +/* GetObjectRefType ************************************************************ + + Returns the type of the object referred to by the obj argument. The + argument obj can either be a local, global or weak global + reference. + +*******************************************************************************/ + +jobjectRefType jni_GetObjectRefType(JNIEnv *env, jobject obj) +{ + log_println("jni_GetObjectRefType: IMPLEMENT ME!"); + + return (jobjectRefType) NULL; +} + + +/* DestroyJavaVM *************************************************************** + + Unloads a Java VM and reclaims its resources. Only the main thread + can unload the VM. The system waits until the main thread is only + remaining user thread before it destroys the VM. + +*******************************************************************************/ + +jint _Jv_JNI_DestroyJavaVM(JavaVM *javavm) +{ + int status; + + TRACEJNICALLS(("_Jv_JNI_DestroyJavaVM(javavm=%p)", javavm)); + + if (VM::get_current()->is_created() == false) + return JNI_ERR; + + status = vm_destroy(javavm); + + return status; +} + + +/* AttachCurrentThread ********************************************************* + + Attaches the current thread to a Java VM. Returns a JNI interface + pointer in the JNIEnv argument. + + Trying to attach a thread that is already attached is a no-op. + + A native thread cannot be attached simultaneously to two Java VMs. + + When a thread is attached to the VM, the context class loader is + the bootstrap loader. + +*******************************************************************************/ + +static int jni_attach_current_thread(void **p_env, void *thr_args, bool isdaemon) +{ +#if defined(ENABLE_THREADS) + JavaVMAttachArgs *vm_aargs; + bool result; + + /* If the current thread has already been attached, this operation + is a no-op. */ + + result = thread_current_is_attached(); + + if (result == true) { + *p_env = VM::get_current()->get_jnienv(); + return JNI_OK; + } + + vm_aargs = (JavaVMAttachArgs *) thr_args; + + if (vm_aargs != NULL) { + if ((vm_aargs->version != JNI_VERSION_1_2) && + (vm_aargs->version != JNI_VERSION_1_4)) + return JNI_EVERSION; + } + + if (!thread_attach_current_external_thread(vm_aargs, false)) + return JNI_ERR; + + if (!localref_table_init()) + return JNI_ERR; +#endif + + *p_env = VM::get_current()->get_jnienv(); + + return JNI_OK; +} + + +jint jni_AttachCurrentThread(JavaVM *javavm, void **p_env, void *thr_args) +{ + int result; + + TRACEJNICALLS(("jni_AttachCurrentThread(javavm=%p, p_env=%p, thr_args=%p)", javavm, p_env, thr_args)); + + if (VM::get_current()->is_created() == false) + return JNI_ERR; + + result = jni_attach_current_thread(p_env, thr_args, false); + + return result; +} + + +/* DetachCurrentThread ********************************************************* + + Detaches the current thread from a Java VM. All Java monitors held + by this thread are released. All Java threads waiting for this + thread to die are notified. + + In JDK 1.1, the main thread cannot be detached from the VM. It must + call DestroyJavaVM to unload the entire VM. + + In the JDK, the main thread can be detached from the VM. + + The main thread, which is the thread that created the Java VM, + cannot be detached from the VM. Instead, the main thread must call + JNI_DestroyJavaVM() to unload the entire VM. + +*******************************************************************************/ + +jint jni_DetachCurrentThread(JavaVM *vm) +{ +#if defined(ENABLE_THREADS) + bool result; + + TRACEJNICALLS(("jni_DetachCurrentThread(vm=%p)", vm)); + + /* If the current thread has already been detached, this operation + is a no-op. */ + + result = thread_current_is_attached(); + + if (result == false) + return true; + + /* We need to pop all frames before we can destroy the table. */ + + localref_frame_pop_all(); + + if (!localref_table_destroy()) + return JNI_ERR; + + if (!thread_detach_current_external_thread()) + return JNI_ERR; +#endif + + return JNI_OK; +} + + +/* GetEnv ********************************************************************** + + If the current thread is not attached to the VM, sets *env to NULL, + and returns JNI_EDETACHED. If the specified version is not + supported, sets *env to NULL, and returns JNI_EVERSION. Otherwise, + sets *env to the appropriate interface, and returns JNI_OK. + +*******************************************************************************/ + +jint jni_GetEnv(JavaVM *javavm, void **env, jint version) +{ + TRACEJNICALLS(("jni_GetEnv(javavm=%p, env=%p, version=%d)", javavm, env, version)); + + if (VM::get_current()->is_created() == false) { + *env = NULL; + return JNI_EDETACHED; + } + +#if defined(ENABLE_THREADS) + if (thread_get_current() == NULL) { + *env = NULL; + + return JNI_EDETACHED; + } +#endif + + /* Check the JNI version. */ + + if (jni_version_check(version) == true) { + *env = VM::get_current()->get_jnienv(); + return JNI_OK; + } + +#if defined(ENABLE_JVMTI) + if ((version & JVMTI_VERSION_MASK_INTERFACE_TYPE) + == JVMTI_VERSION_INTERFACE_JVMTI) { + + *env = (void *) jvmti_new_environment(); + + if (env != NULL) + return JNI_OK; + } +#endif + + *env = NULL; + + return JNI_EVERSION; +} + + +/* AttachCurrentThreadAsDaemon ************************************************* + + Same semantics as AttachCurrentThread, but the newly-created + java.lang.Thread instance is a daemon. + + If the thread has already been attached via either + AttachCurrentThread or AttachCurrentThreadAsDaemon, this routine + simply sets the value pointed to by penv to the JNIEnv of the + current thread. In this case neither AttachCurrentThread nor this + routine have any effect on the daemon status of the thread. + +*******************************************************************************/ + +jint jni_AttachCurrentThreadAsDaemon(JavaVM *javavm, void **penv, void *args) +{ + int result; + + TRACEJNICALLS(("jni_AttachCurrentThreadAsDaemon(javavm=%p, penv=%p, args=%p)", javavm, penv, args)); + + if (VM::get_current()->is_created() == false) + return JNI_ERR; + + result = jni_attach_current_thread(penv, args, true); + + return result; +} + + +/* JNI invocation table *******************************************************/ + +const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface = { + NULL, + NULL, + NULL, + + _Jv_JNI_DestroyJavaVM, + jni_AttachCurrentThread, + jni_DetachCurrentThread, + jni_GetEnv, + jni_AttachCurrentThreadAsDaemon +}; + + +/* JNI function table *********************************************************/ + +struct JNINativeInterface_ _Jv_JNINativeInterface = { + NULL, + NULL, + NULL, + NULL, + _Jv_JNI_GetVersion, + + jni_DefineClass, + jni_FindClass, + jni_FromReflectedMethod, + jni_FromReflectedField, + jni_ToReflectedMethod, + jni_GetSuperclass, + _Jv_JNI_IsAssignableFrom, + _Jv_JNI_ToReflectedField, + + _Jv_JNI_Throw, + _Jv_JNI_ThrowNew, + _Jv_JNI_ExceptionOccurred, + jni_ExceptionDescribe, + jni_ExceptionClear, + _Jv_JNI_FatalError, + jni_PushLocalFrame, + jni_PopLocalFrame, + + jni_NewGlobalRef, + jni_DeleteGlobalRef, + jni_DeleteLocalRef, + _Jv_JNI_IsSameObject, + jni_NewLocalRef, + jni_EnsureLocalCapacity, + + _Jv_JNI_AllocObject, + jni_NewObject, + _Jv_JNI_NewObjectV, + _Jv_JNI_NewObjectA, + + jni_GetObjectClass, + _Jv_JNI_IsInstanceOf, + + _Jv_JNI_GetMethodID, + + _Jv_JNI_CallObjectMethod, + _Jv_JNI_CallObjectMethodV, + _Jv_JNI_CallObjectMethodA, + _Jv_JNI_CallBooleanMethod, + _Jv_JNI_CallBooleanMethodV, + _Jv_JNI_CallBooleanMethodA, + _Jv_JNI_CallByteMethod, + _Jv_JNI_CallByteMethodV, + _Jv_JNI_CallByteMethodA, + _Jv_JNI_CallCharMethod, + _Jv_JNI_CallCharMethodV, + _Jv_JNI_CallCharMethodA, + _Jv_JNI_CallShortMethod, + _Jv_JNI_CallShortMethodV, + _Jv_JNI_CallShortMethodA, + _Jv_JNI_CallIntMethod, + _Jv_JNI_CallIntMethodV, + _Jv_JNI_CallIntMethodA, + _Jv_JNI_CallLongMethod, + _Jv_JNI_CallLongMethodV, + _Jv_JNI_CallLongMethodA, + _Jv_JNI_CallFloatMethod, + _Jv_JNI_CallFloatMethodV, + _Jv_JNI_CallFloatMethodA, + _Jv_JNI_CallDoubleMethod, + _Jv_JNI_CallDoubleMethodV, + _Jv_JNI_CallDoubleMethodA, + _Jv_JNI_CallVoidMethod, + _Jv_JNI_CallVoidMethodV, + _Jv_JNI_CallVoidMethodA, + + _Jv_JNI_CallNonvirtualObjectMethod, + _Jv_JNI_CallNonvirtualObjectMethodV, + _Jv_JNI_CallNonvirtualObjectMethodA, + _Jv_JNI_CallNonvirtualBooleanMethod, + _Jv_JNI_CallNonvirtualBooleanMethodV, + _Jv_JNI_CallNonvirtualBooleanMethodA, + _Jv_JNI_CallNonvirtualByteMethod, + _Jv_JNI_CallNonvirtualByteMethodV, + _Jv_JNI_CallNonvirtualByteMethodA, + _Jv_JNI_CallNonvirtualCharMethod, + _Jv_JNI_CallNonvirtualCharMethodV, + _Jv_JNI_CallNonvirtualCharMethodA, + _Jv_JNI_CallNonvirtualShortMethod, + _Jv_JNI_CallNonvirtualShortMethodV, + _Jv_JNI_CallNonvirtualShortMethodA, + _Jv_JNI_CallNonvirtualIntMethod, + _Jv_JNI_CallNonvirtualIntMethodV, + _Jv_JNI_CallNonvirtualIntMethodA, + _Jv_JNI_CallNonvirtualLongMethod, + _Jv_JNI_CallNonvirtualLongMethodV, + _Jv_JNI_CallNonvirtualLongMethodA, + _Jv_JNI_CallNonvirtualFloatMethod, + _Jv_JNI_CallNonvirtualFloatMethodV, + _Jv_JNI_CallNonvirtualFloatMethodA, + _Jv_JNI_CallNonvirtualDoubleMethod, + _Jv_JNI_CallNonvirtualDoubleMethodV, + _Jv_JNI_CallNonvirtualDoubleMethodA, + _Jv_JNI_CallNonvirtualVoidMethod, + _Jv_JNI_CallNonvirtualVoidMethodV, + _Jv_JNI_CallNonvirtualVoidMethodA, + + _Jv_JNI_GetFieldID, + + _Jv_JNI_GetObjectField, + _Jv_JNI_GetBooleanField, + _Jv_JNI_GetByteField, + _Jv_JNI_GetCharField, + _Jv_JNI_GetShortField, + _Jv_JNI_GetIntField, + _Jv_JNI_GetLongField, + _Jv_JNI_GetFloatField, + _Jv_JNI_GetDoubleField, + _Jv_JNI_SetObjectField, + _Jv_JNI_SetBooleanField, + _Jv_JNI_SetByteField, + _Jv_JNI_SetCharField, + _Jv_JNI_SetShortField, + _Jv_JNI_SetIntField, + _Jv_JNI_SetLongField, + _Jv_JNI_SetFloatField, + _Jv_JNI_SetDoubleField, + + _Jv_JNI_GetStaticMethodID, + + _Jv_JNI_CallStaticObjectMethod, + _Jv_JNI_CallStaticObjectMethodV, + _Jv_JNI_CallStaticObjectMethodA, + _Jv_JNI_CallStaticBooleanMethod, + _Jv_JNI_CallStaticBooleanMethodV, + _Jv_JNI_CallStaticBooleanMethodA, + _Jv_JNI_CallStaticByteMethod, + _Jv_JNI_CallStaticByteMethodV, + _Jv_JNI_CallStaticByteMethodA, + _Jv_JNI_CallStaticCharMethod, + _Jv_JNI_CallStaticCharMethodV, + _Jv_JNI_CallStaticCharMethodA, + _Jv_JNI_CallStaticShortMethod, + _Jv_JNI_CallStaticShortMethodV, + _Jv_JNI_CallStaticShortMethodA, + _Jv_JNI_CallStaticIntMethod, + _Jv_JNI_CallStaticIntMethodV, + _Jv_JNI_CallStaticIntMethodA, + _Jv_JNI_CallStaticLongMethod, + _Jv_JNI_CallStaticLongMethodV, + _Jv_JNI_CallStaticLongMethodA, + _Jv_JNI_CallStaticFloatMethod, + _Jv_JNI_CallStaticFloatMethodV, + _Jv_JNI_CallStaticFloatMethodA, + _Jv_JNI_CallStaticDoubleMethod, + _Jv_JNI_CallStaticDoubleMethodV, + _Jv_JNI_CallStaticDoubleMethodA, + _Jv_JNI_CallStaticVoidMethod, + _Jv_JNI_CallStaticVoidMethodV, + _Jv_JNI_CallStaticVoidMethodA, + + _Jv_JNI_GetStaticFieldID, + + _Jv_JNI_GetStaticObjectField, + _Jv_JNI_GetStaticBooleanField, + _Jv_JNI_GetStaticByteField, + _Jv_JNI_GetStaticCharField, + _Jv_JNI_GetStaticShortField, + _Jv_JNI_GetStaticIntField, + _Jv_JNI_GetStaticLongField, + _Jv_JNI_GetStaticFloatField, + _Jv_JNI_GetStaticDoubleField, + _Jv_JNI_SetStaticObjectField, + _Jv_JNI_SetStaticBooleanField, + _Jv_JNI_SetStaticByteField, + _Jv_JNI_SetStaticCharField, + _Jv_JNI_SetStaticShortField, + _Jv_JNI_SetStaticIntField, + _Jv_JNI_SetStaticLongField, + _Jv_JNI_SetStaticFloatField, + _Jv_JNI_SetStaticDoubleField, + + jni_NewString, + jni_GetStringLength, + jni_GetStringChars, + _Jv_JNI_ReleaseStringChars, + + jni_NewStringUTF, + jni_GetStringUTFLength, + _Jv_JNI_GetStringUTFChars, + _Jv_JNI_ReleaseStringUTFChars, + + _Jv_JNI_GetArrayLength, + + _Jv_JNI_NewObjectArray, + _Jv_JNI_GetObjectArrayElement, + _Jv_JNI_SetObjectArrayElement, + + _Jv_JNI_NewBooleanArray, + _Jv_JNI_NewByteArray, + _Jv_JNI_NewCharArray, + _Jv_JNI_NewShortArray, + _Jv_JNI_NewIntArray, + _Jv_JNI_NewLongArray, + _Jv_JNI_NewFloatArray, + _Jv_JNI_NewDoubleArray, + + _Jv_JNI_GetBooleanArrayElements, + _Jv_JNI_GetByteArrayElements, + _Jv_JNI_GetCharArrayElements, + _Jv_JNI_GetShortArrayElements, + _Jv_JNI_GetIntArrayElements, + _Jv_JNI_GetLongArrayElements, + _Jv_JNI_GetFloatArrayElements, + _Jv_JNI_GetDoubleArrayElements, + + _Jv_JNI_ReleaseBooleanArrayElements, + _Jv_JNI_ReleaseByteArrayElements, + _Jv_JNI_ReleaseCharArrayElements, + _Jv_JNI_ReleaseShortArrayElements, + _Jv_JNI_ReleaseIntArrayElements, + _Jv_JNI_ReleaseLongArrayElements, + _Jv_JNI_ReleaseFloatArrayElements, + _Jv_JNI_ReleaseDoubleArrayElements, + + _Jv_JNI_GetBooleanArrayRegion, + _Jv_JNI_GetByteArrayRegion, + _Jv_JNI_GetCharArrayRegion, + _Jv_JNI_GetShortArrayRegion, + _Jv_JNI_GetIntArrayRegion, + _Jv_JNI_GetLongArrayRegion, + _Jv_JNI_GetFloatArrayRegion, + _Jv_JNI_GetDoubleArrayRegion, + _Jv_JNI_SetBooleanArrayRegion, + _Jv_JNI_SetByteArrayRegion, + _Jv_JNI_SetCharArrayRegion, + _Jv_JNI_SetShortArrayRegion, + _Jv_JNI_SetIntArrayRegion, + _Jv_JNI_SetLongArrayRegion, + _Jv_JNI_SetFloatArrayRegion, + _Jv_JNI_SetDoubleArrayRegion, + + _Jv_JNI_RegisterNatives, + _Jv_JNI_UnregisterNatives, + + _Jv_JNI_MonitorEnter, + _Jv_JNI_MonitorExit, + + _Jv_JNI_GetJavaVM, + + /* New JNI 1.2 functions. */ + + jni_GetStringRegion, + jni_GetStringUTFRegion, + + jni_GetPrimitiveArrayCritical, + jni_ReleasePrimitiveArrayCritical, + + _Jv_JNI_GetStringCritical, + _Jv_JNI_ReleaseStringCritical, + + _Jv_JNI_NewWeakGlobalRef, + _Jv_JNI_DeleteWeakGlobalRef, + + _Jv_JNI_ExceptionCheck, + + /* New JNI 1.4 functions. */ + + jni_NewDirectByteBuffer, + jni_GetDirectBufferAddress, + jni_GetDirectBufferCapacity, + + /* New JNI 1.6 functions. */ + + jni_GetObjectRefType +}; + + +/* Invocation API Functions ***************************************************/ + +/* JNI_GetDefaultJavaVMInitArgs ************************************************ + + Returns a default configuration for the Java VM. + +*******************************************************************************/ + +jint JNI_GetDefaultJavaVMInitArgs(void *vm_args) +{ + JavaVMInitArgs *_vm_args; + + _vm_args = (JavaVMInitArgs *) vm_args; + + /* GNU classpath currently supports JNI 1.2 */ + + switch (_vm_args->version) { + case JNI_VERSION_1_1: + _vm_args->version = JNI_VERSION_1_1; + break; + + case JNI_VERSION_1_2: + case JNI_VERSION_1_4: + _vm_args->ignoreUnrecognized = JNI_FALSE; + _vm_args->options = NULL; + _vm_args->nOptions = 0; + break; + + default: + return -1; + } + + return 0; +} + + +/* JNI_GetCreatedJavaVMs ******************************************************* + + Returns all Java VMs that have been created. Pointers to VMs are written in + the buffer vmBuf in the order they are created. At most bufLen number of + entries will be written. The total number of created VMs is returned in + *nVMs. + +*******************************************************************************/ + +jint JNI_GetCreatedJavaVMs(JavaVM **vmBuf, jsize bufLen, jsize *nVMs) +{ + TRACEJNICALLS(("JNI_GetCreatedJavaVMs(vmBuf=%p, jsize=%d, jsize=%p)", vmBuf, bufLen, nVMs)); + + if (bufLen <= 0) + return JNI_ERR; + + // We currently only support 1 VM running. + + vmBuf[0] = VM::get_current()->get_javavm(); + *nVMs = 1; + + return JNI_OK; +} + + +/* JNI_CreateJavaVM ************************************************************ + + Loads and initializes a Java VM. The current thread becomes the main thread. + Sets the env argument to the JNI interface pointer of the main thread. + +*******************************************************************************/ + +jint JNI_CreateJavaVM(JavaVM **p_vm, void **p_env, void *vm_args) +{ + TRACEJNICALLS(("JNI_CreateJavaVM(p_vm=%p, p_env=%p, vm_args=%p)", p_vm, p_env, vm_args)); + + /* actually create the JVM */ + + if (!VM_create(p_vm, p_env, vm_args)) + return JNI_ERR; + + return JNI_OK; +} + +} // extern "C" + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/jni.h b/src/native/jni.h deleted file mode 100644 index a74f68688..000000000 --- a/src/native/jni.h +++ /dev/null @@ -1,130 +0,0 @@ -/* src/native/jni.h - JNI types and data structures - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -/* jni.h *********************************************************************** - - ATTENTION: We include this file before we actually define our own - jni.h. We do this because otherwise we can get into unresolvable - circular header dependencies. - - This is OK as GNU Classpath defines: - - #define __CLASSPATH_JNI_MD_H__ - #define _CLASSPATH_JNI_H - - and OpenJDK defines: - - #define _JAVASOFT_JNI_MD_H_ - #define _JAVASOFT_JNI_H_ - - CLASSPATH_JNI_MD_H and CLASSPATH_JNI_H are defined in config.h. - -*******************************************************************************/ - -#include "config.h" - -/* We include both headers with the absolute path so we can be sure - that the preprocessor does not take another header. Furthermore we - include jni_md.h before jni.h as the latter includes the former. */ - -#include INCLUDE_JNI_MD_H -#include INCLUDE_JNI_H - -#ifndef _JNI_H -#define _JNI_H - - -#include "vm/types.h" - -#include "vm/global.h" - -#include "vmcore/method.h" - - -/* _Jv_JNIEnv *****************************************************************/ - -typedef struct _Jv_JNIEnv _Jv_JNIEnv; - -struct _Jv_JNIEnv { - const struct JNINativeInterface_ *env; /* This MUST be the first entry */ -}; - - -/* _Jv_JavaVM *****************************************************************/ - -typedef struct _Jv_JavaVM _Jv_JavaVM; - -struct _Jv_JavaVM { - const struct JNIInvokeInterface_ *functions;/*This MUST be the first entry*/ - - /* JVM instance-specific variables */ - - s8 starttime; /* VM startup time */ - - s4 Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose; - s4 Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose; - s4 java_lang_management_ThreadMXBean_PeakThreadCount; - s4 java_lang_management_ThreadMXBean_ThreadCount; - s8 java_lang_management_ThreadMXBean_TotalStartedThreadCount; -}; - - -/* CACAO related stuff ********************************************************/ - -extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface; -extern struct JNINativeInterface_ _Jv_JNINativeInterface; - - -/* hashtable_global_ref_entry *************************************************/ - -typedef struct hashtable_global_ref_entry hashtable_global_ref_entry; - -struct hashtable_global_ref_entry { - java_object_t *o; /* object pointer of global ref */ - s4 refs; /* references of the current pointer */ - hashtable_global_ref_entry *hashlink; /* link for external chaining */ -}; - - -/* function prototypes ********************************************************/ - -bool jni_init(void); -bool jni_version_check(int version); - -#endif /* _JNI_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/jni.hpp b/src/native/jni.hpp new file mode 100644 index 000000000..616cafd3a --- /dev/null +++ b/src/native/jni.hpp @@ -0,0 +1,117 @@ +/* src/native/jni.hpp - JNI types and data structures + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +/* jni.h *********************************************************************** + + ATTENTION: We include this file before we actually define our own + jni.h. We do this because otherwise we can get into unresolvable + circular header dependencies. + + GNU Classpath's headers define: + + #define __CLASSPATH_JNI_MD_H__ + #define _CLASSPATH_JNI_H + + and jni.h uses: + + _CLASSPATH_VM_JNI_TYPES_DEFINED + + OpenJDK's headers define: + + #define _JAVASOFT_JNI_MD_H_ + #define _JAVASOFT_JNI_H_ + + and jni.h uses: + + JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H + + CLASSPATH_JNI_MD_H and CLASSPATH_JNI_H are defined in config.h. + +*******************************************************************************/ + +#include "config.h" + +/* We include both headers with the absolute path so we can be sure + that the preprocessor does not take another header. Furthermore we + include jni_md.h before jni.h as the latter includes the former. */ + +#include INCLUDE_JNI_MD_H +#include INCLUDE_JNI_H + +#ifndef _JNI_HPP +#define _JNI_HPP + +#include +#include + +#include "vm/global.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* CACAO related stuff ********************************************************/ + +extern const struct JNIInvokeInterface_ _Jv_JNIInvokeInterface; +extern struct JNINativeInterface_ _Jv_JNINativeInterface; + + +/* hashtable_global_ref_entry *************************************************/ + +typedef struct hashtable_global_ref_entry hashtable_global_ref_entry; + +struct hashtable_global_ref_entry { + java_object_t *o; /* object pointer of global ref */ + int32_t refs; /* references of the current pointer */ + hashtable_global_ref_entry *hashlink; /* link for external chaining */ +}; + + +/* function prototypes ********************************************************/ + +bool jni_init(void); +bool jni_version_check(int version); + +#ifdef __cplusplus +} +#endif + +#endif // _JNI_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/jvmti/cacaodbg.c b/src/native/jvmti/cacaodbg.c index 8db874a8f..eb29c6f7b 100644 --- a/src/native/jvmti/cacaodbg.c +++ b/src/native/jvmti/cacaodbg.c @@ -26,15 +26,15 @@ #include "native/jvmti/jvmti.h" #include "native/jvmti/cacaodbg.h" #include "native/jvmti/dbg.h" -#include "vm/vm.h" -#include "vm/loader.h" -#include "vm/exceptions.h" -#include "vm/builtin.h" +#include "vm/vm.hpp" +#include "vm/loader.hpp" +#include "vm/exceptions.hpp" +#include "vm/jit/builtin.hpp" #include "vm/jit/asmpart.h" -#include "vm/stringlocal.h" +#include "vm/string.hpp" #include "toolbox/logging.h" #include "threads/mutex.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include #include diff --git a/src/native/jvmti/cacaodbg.h b/src/native/jvmti/cacaodbg.h index 4b4a219eb..04abbd85c 100644 --- a/src/native/jvmti/cacaodbg.h +++ b/src/native/jvmti/cacaodbg.h @@ -26,7 +26,7 @@ #define _CACAODBG_H #include "threads/mutex.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "native/jvmti/jvmti.h" #include "native/include/java_lang_String.h" #include diff --git a/src/native/jvmti/jvmti.c b/src/native/jvmti/jvmti.c index b80dae48d..8c883e7d0 100644 --- a/src/native/jvmti/jvmti.c +++ b/src/native/jvmti/jvmti.c @@ -36,27 +36,26 @@ #include #include -#include "native/jni.h" +#include "native/jni.hpp" #include "native/native.h" #include "native/jvmti/cacaodbg.h" #include "native/jvmti/jvmti.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" #include "vm/global.h" -#include "vm/loader.h" -#include "vm/builtin.h" +#include "vm/loader.hpp" +#include "vm/jit/builtin.hpp" #include "vm/jit/asmpart.h" #include "vm/class.h" #include "vm/classcache.h" -#include "mm/gc-common.h" +#include "mm/gc.hpp" #include "toolbox/logging.h" #include "vm/options.h" -#include "vm/stringlocal.h" +#include "vm/string.hpp" #include "mm/memory.h" #include "threads/mutex.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "threads/lock-common.h" -#include "vm/exceptions.h" -#include "native/include/java_util_Vector.h" +#include "vm/exceptions.hpp" #include "native/include/java_io_PrintStream.h" #include "native/include/java_io_InputStream.h" #include "native/include/java_lang_Cloneable.h" @@ -64,7 +63,7 @@ #include "native/include/java_lang_VMObject.h" #include "native/include/java_lang_VMSystem.h" #include "native/include/java_lang_VMClass.h" -#include "vm/suck.h" +#include "vm/suck.hpp" #include "boehm-gc/include/gc.h" #if defined(ENABLE_THREADS) @@ -1158,7 +1157,7 @@ GetThreadState (jvmtiEnv * env, jthread thread, jint * thread_state_ptr) if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT; if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_IN_OBJECT_WAIT; if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_PARKED; - if (t->sleeping) *thread_state_ptr |= JVMTI_THREAD_STATE_SLEEPING; + if (false) *thread_state_ptr |= JVMTI_THREAD_STATE_SLEEPING; } #else return JVMTI_ERROR_INTERNAL; diff --git a/src/native/jvmti/jvmti.h b/src/native/jvmti/jvmti.h index b0774abb2..576c7ee2b 100644 --- a/src/native/jvmti/jvmti.h +++ b/src/native/jvmti/jvmti.h @@ -1,10 +1,8 @@ /* src/native/jvmti.c - implementation of the Java Virtual Machine Tool Interface functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -23,19 +21,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Author: Martin Platter - - Changes: +*/ - -*/ #ifndef _JVMTI_H #define _JVMTI_H -#include "native/jni.h" +#include "config.h" + +#include "native/jni.hpp" #define JVMTI_VERSION_INTERFACE_JNI 0x00000000 diff --git a/src/native/llni.c b/src/native/llni.c index e9df0d643..02c171b7b 100644 --- a/src/native/llni.c +++ b/src/native/llni.c @@ -27,7 +27,7 @@ #include -#include "threads/thread.h" +#include "threads/thread.hpp" /* LLNI critical sections ****************************************************** diff --git a/src/native/llni.h b/src/native/llni.h index 65e708685..0301f6800 100644 --- a/src/native/llni.h +++ b/src/native/llni.h @@ -53,45 +53,9 @@ #include "native/localref.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -/* LLNI macros ***************************************************************** - - The following macros should be used whenever a Java Object is - accessed in native code without the use of an JNI function. - - LLNI_field_set_val, LLNI_field_get_val: - Deal with primitive values like integer and float values. Do - not use these macros to access pointers or references! - - LLNI_field_set_ref, LLNI_field_get_ref: - Deal with references to other objects. - - LLNI_field_set_cls, LLNI_field_get_cls: - Deal with references to Java Classes which are internally - represented by classinfo or java_lang_Class. - -*******************************************************************************/ - -#define LLNI_field_set_val(obj, field, value) \ - LLNI_field_direct(obj, field) = (value) - -#define LLNI_field_set_ref(obj, field, reference) \ - LLNI_field_direct(obj, field) = LLNI_UNWRAP(reference) - -#define LLNI_field_set_cls(obj, field, value) \ - LLNI_field_direct(obj, field) = (java_lang_Class *) (value) - -#define LLNI_field_get_val(obj, field, variable) \ - (variable) = LLNI_field_direct(obj, field) - -#define LLNI_field_get_ref(obj, field, variable) \ - (variable) = LLNI_WRAP(LLNI_field_direct(obj, field)) - -#define LLNI_field_get_cls(obj, field, variable) \ - (variable) = (classinfo *) LLNI_field_direct(obj, field) - #define LLNI_class_get(obj, variable) \ (variable) = LLNI_field_direct((java_handle_t *) obj, vftbl->clazz) @@ -143,7 +107,7 @@ *******************************************************************************/ #define LLNI_classinfo_wrap(classinfo) \ - ((java_lang_Class *) LLNI_WRAP(classinfo)) + ((java_handle_t*) LLNI_WRAP(classinfo)) #define LLNI_classinfo_unwrap(clazz) \ ((classinfo *) LLNI_UNWRAP((java_handle_t *) (clazz))) @@ -181,11 +145,18 @@ # define LLNI_CRITICAL_END_THREAD(t) #endif +#ifdef __cplusplus +extern "C" { +#endif + void llni_critical_start(); void llni_critical_end(); void llni_critical_start_thread(threadobject *t); void llni_critical_end_thread(threadobject *t); +#ifdef __cplusplus +} +#endif #endif /* _LLNI_H */ diff --git a/src/native/localref.c b/src/native/localref.c index 8e364b515..f686858c2 100644 --- a/src/native/localref.c +++ b/src/native/localref.c @@ -32,16 +32,15 @@ #include "native/localref.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "toolbox/logging.h" -#include "vm/vm.h" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/argument.h" -#include "vmcore/options.h" - /* debug **********************************************************************/ diff --git a/src/native/localref.h b/src/native/localref.h index f99a56be5..4e0e35e00 100644 --- a/src/native/localref.h +++ b/src/native/localref.h @@ -1,9 +1,7 @@ /* src/native/localref.h - Management of local reference tables - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,11 +31,11 @@ typedef struct localref_table localref_table; #include "config.h" + #include "vm/types.h" #include "vm/global.h" - -#include "vmcore/method.h" +#include "vm/method.h" /* localref_table ************************************************************** @@ -70,6 +68,10 @@ extern localref_table *_no_threads_localref_table; /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool localref_table_init(void); bool localref_table_destroy(void); void localref_table_add(localref_table *lrt); @@ -88,6 +90,9 @@ void localref_native_exit(methodinfo *m, uint64_t *return_regs); void localref_dump(void); #endif +#ifdef __cplusplus +} +#endif #endif /* _LOCALREF_H */ diff --git a/src/native/native.c b/src/native/native.c index 9a4cd343f..4d120918b 100644 --- a/src/native/native.c +++ b/src/native/native.c @@ -1,4 +1,4 @@ -/* src/native/native.c - table of native functions +/* src/native/native.c - native library support Copyright (C) 1996-2005, 2006, 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO @@ -28,39 +28,36 @@ #include #include -#if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H) -# include -#endif - #include #include "vm/types.h" #include "mm/memory.h" -#include "native/jni.h" +#include "native/jni.hpp" #include "native/native.h" #include "native/vm/nativevm.h" -#include "threads/lock-common.h" +#include "threads/mutex.hpp" #include "toolbox/avl.h" #include "toolbox/hashtable.h" #include "toolbox/logging.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/globals.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/resolve.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vm/resolve.h" +#include "vm/jit/jit.hpp" #if defined(ENABLE_JVMTI) #include "native/jvmti/cacaodbg.h" @@ -71,7 +68,7 @@ static avl_tree_t *tree_native_methods; -#if defined(ENABLE_LTDL) +#if defined(ENABLE_DL) static hashtable *hashtable_library; #endif @@ -91,12 +88,7 @@ bool native_init(void) { TRACESUBSYSTEMINITIALIZATION("native_init"); -#if defined(ENABLE_LTDL) - /* initialize libltdl */ - - if (lt_dlinit()) - vm_abort("native_init: lt_dlinit failed: %s\n", lt_dlerror()); - +#if defined(ENABLE_DL) /* initialize library hashtable, 10 entries should be enough */ hashtable_library = NEW(hashtable); @@ -172,11 +164,6 @@ static utf *native_make_overloaded_function(utf *name, utf *descriptor) u2 c; s4 i; utf *u; - int32_t dumpmarker; - - /* mark memory */ - - DMARKER; utf_ptr = descriptor->text; namelen = strlen(name->text) + strlen("__") + strlen("0"); @@ -215,7 +202,7 @@ static utf *native_make_overloaded_function(utf *name, utf *descriptor) i = strlen(name->text); - newname = DMNEW(char, namelen); + newname = MNEW(char, namelen); MCOPY(newname, name->text, char, i); utf_ptr = descriptor->text; @@ -268,7 +255,7 @@ static utf *native_make_overloaded_function(utf *name, utf *descriptor) /* release memory */ - DRELEASE; + MFREE(newname, char, namelen); return u; } @@ -352,11 +339,6 @@ static utf *native_method_symbol(utf *classname, utf *methodname) u2 c; u4 pos; utf *u; - int32_t dumpmarker; - - /* mark memory */ - - DMARKER; /* Calculate length of native function name. We multiply the class and method name length by 6 as this is the maxium @@ -371,7 +353,7 @@ static utf *native_method_symbol(utf *classname, utf *methodname) /* allocate memory */ - name = DMNEW(char, namelen); + name = MNEW(char, namelen); /* generate name of native functions */ @@ -412,7 +394,7 @@ static utf *native_method_symbol(utf *classname, utf *methodname) /* release memory */ - DRELEASE; + MFREE(name, char, namelen); return u; } @@ -507,7 +489,7 @@ functionptr native_method_resolve(methodinfo *m) utf *name; utf *newname; functionptr f; -#if defined(ENABLE_LTDL) +#if defined(ENABLE_DL) classloader_t *cl; hashtable_library_loader_entry *le; hashtable_library_name_entry *ne; @@ -542,7 +524,7 @@ functionptr native_method_resolve(methodinfo *m) f = NULL; -#if defined(ENABLE_LTDL) +#if defined(ENABLE_DL) /* Get the classloader. */ cl = class_get_classloader(m->clazz); @@ -561,10 +543,10 @@ functionptr native_method_resolve(methodinfo *m) ne = le->namelink; while ((ne != NULL) && (f == NULL)) { - f = (functionptr) (ptrint) lt_dlsym(ne->handle, name->text); + f = (functionptr) (ptrint) os_dlsym(ne->handle, name->text); if (f == NULL) - f = (functionptr) (ptrint) lt_dlsym(ne->handle, newname->text); + f = (functionptr) (ptrint) os_dlsym(ne->handle, newname->text); ne = ne->hashlink; } @@ -652,10 +634,10 @@ functionptr native_method_resolve(methodinfo *m) *******************************************************************************/ -#if defined(ENABLE_LTDL) -lt_dlhandle native_library_open(utf *filename) +#if defined(ENABLE_DL) +void* native_library_open(utf *filename) { - lt_dlhandle handle; + void* handle; if (opt_verbosejni) { printf("[Loading native library "); @@ -665,7 +647,7 @@ lt_dlhandle native_library_open(utf *filename) /* try to open the library */ - handle = lt_dlopen(filename->text); + handle = os_dlopen(filename->text, RTLD_LAZY); if (handle == NULL) { if (opt_verbosejni) @@ -673,8 +655,8 @@ lt_dlhandle native_library_open(utf *filename) if (opt_verbose) { log_start(); - log_print("native_library_open: lt_dlopen failed: "); - log_print(lt_dlerror()); + log_print("native_library_open: os_dlopen failed: "); + log_print(dlerror()); log_finish(); } @@ -698,8 +680,8 @@ lt_dlhandle native_library_open(utf *filename) *******************************************************************************/ -#if defined(ENABLE_LTDL) -void native_library_close(lt_dlhandle handle) +#if defined(ENABLE_DL) +void native_library_close(void* handle) { int result; @@ -711,13 +693,13 @@ void native_library_close(lt_dlhandle handle) /* Close the library. */ - result = lt_dlclose(handle); + result = os_dlclose(handle); if (result != 0) { if (opt_verbose) { log_start(); - log_print("native_library_close: lt_dlclose failed: "); - log_print(lt_dlerror()); + log_print("native_library_close: os_dlclose failed: "); + log_print(dlerror()); log_finish(); } } @@ -731,15 +713,15 @@ void native_library_close(lt_dlhandle handle) *******************************************************************************/ -#if defined(ENABLE_LTDL) -void native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle) +#if defined(ENABLE_DL) +void native_library_add(utf *filename, classloader_t *loader, void* handle) { hashtable_library_loader_entry *le; hashtable_library_name_entry *ne; /* library name */ u4 key; /* hashkey */ u4 slot; /* slot in hashtable */ - LOCK_MONITOR_ENTER(hashtable_library->header); + Mutex_lock(hashtable_library->mutex); /* normally addresses are aligned to 4, 8 or 16 bytes */ @@ -782,7 +764,7 @@ void native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle while (ne) { if (ne->name == filename) { - LOCK_MONITOR_EXIT(hashtable_library->header); + Mutex_unlock(hashtable_library->mutex); return; } @@ -802,7 +784,7 @@ void native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle ne->hashlink = le->namelink; le->namelink = ne; - LOCK_MONITOR_EXIT(hashtable_library->header); + Mutex_unlock(hashtable_library->mutex); } #endif @@ -813,7 +795,7 @@ void native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle *******************************************************************************/ -#if defined(ENABLE_LTDL) +#if defined(ENABLE_DL) hashtable_library_name_entry *native_library_find(utf *filename, classloader_t *loader) { @@ -876,11 +858,11 @@ hashtable_library_name_entry *native_library_find(utf *filename, int native_library_load(JNIEnv *env, utf *name, classloader_t *cl) { -#if defined(ENABLE_LTDL) - lt_dlhandle handle; +#if defined(ENABLE_DL) + void* handle; # if defined(ENABLE_JNI) - lt_ptr onload; - int32_t version; + void* onload; + int32_t version; # endif if (name == NULL) { @@ -903,7 +885,7 @@ int native_library_load(JNIEnv *env, utf *name, classloader_t *cl) # if defined(ENABLE_JNI) /* Resolve JNI_OnLoad function. */ - onload = lt_dlsym(handle, "JNI_OnLoad"); + onload = os_dlsym(handle, "JNI_OnLoad"); if (onload != NULL) { JNIEXPORT int32_t (JNICALL *JNI_OnLoad) (JavaVM *, void *); @@ -919,7 +901,7 @@ int native_library_load(JNIEnv *env, utf *name, classloader_t *cl) loaded. */ if ((version != JNI_VERSION_1_2) && (version != JNI_VERSION_1_4)) { - lt_dlclose(handle); + os_dlclose(handle); return 0; } } diff --git a/src/native/native.h b/src/native/native.h index 974a02bc0..d795b28db 100644 --- a/src/native/native.h +++ b/src/native/native.h @@ -1,4 +1,4 @@ -/* src/native/native.h - table of native functions +/* src/native/native.h - native library support Copyright (C) 1996-2005, 2006, 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO @@ -28,20 +28,16 @@ #include "config.h" -#if defined(ENABLE_LTDL) && defined(HAVE_LTDL_H) -# include -#endif - #include -#include "native/jni.h" +#include "native/jni.hpp" +#include "vm/class.h" #include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/utf8.h" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/os.hpp" +#include "vm/utf8.h" /* defines ********************************************************************/ @@ -49,6 +45,15 @@ #define NATIVE_METHODS_COUNT sizeof(methods) / sizeof(JNINativeMethod) +#define NATIVE_LIBRARY_PREFIX "lib" + +#if defined(__DARWIN__) +# define NATIVE_LIBRARY_SUFFIX ".dylib" +#else +# define NATIVE_LIBRARY_SUFFIX ".so" +#endif + + /* native_methods_node_t ******************************************************/ typedef struct native_methods_node_t native_methods_node_t; @@ -63,7 +68,7 @@ struct native_methods_node_t { /* hashtable_library_loader_entry *********************************************/ -#if defined(ENABLE_LTDL) +#if defined(ENABLE_DL) typedef struct hashtable_library_loader_entry hashtable_library_loader_entry; typedef struct hashtable_library_name_entry hashtable_library_name_entry; @@ -77,10 +82,10 @@ struct hashtable_library_loader_entry { /* hashtable_library_name_entry ***********************************************/ -#if defined(ENABLE_LTDL) +#if defined(ENABLE_DL) struct hashtable_library_name_entry { utf *name; /* library name */ - lt_dlhandle handle; /* libtool library handle */ + void* handle; /* libtool library handle */ hashtable_library_name_entry *hashlink; /* link for external chaining */ }; #endif @@ -88,15 +93,19 @@ struct hashtable_library_name_entry { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool native_init(void); void native_method_register(utf *classname, const JNINativeMethod *methods, int32_t count); functionptr native_method_resolve(methodinfo *m); -#if defined(ENABLE_LTDL) -lt_dlhandle native_library_open(utf *filename); -void native_library_close(lt_dlhandle handle); -void native_library_add(utf *filename, classloader_t *loader, lt_dlhandle handle); +#if defined(ENABLE_DL) +void* native_library_open(utf *filename); +void native_library_close(void* handle); +void native_library_add(utf *filename, classloader_t *loader, void *handle); hashtable_library_name_entry *native_library_find(utf *filename, classloader_t *loader); int native_library_load(JNIEnv *env, utf *name, classloader_t *cl); #endif @@ -104,6 +113,10 @@ int native_library_load(JNIEnv *env, utf *name, classloader_t *cl); java_handle_t *native_new_and_init(classinfo *c); java_handle_t *native_new_and_init_string(classinfo *c, java_handle_t *s); +#ifdef __cplusplus +} +#endif + #endif /* _NATIVE_H */ diff --git a/src/native/vm/Makefile.am b/src/native/vm/Makefile.am index 70d401e34..251f8212a 100644 --- a/src/native/vm/Makefile.am +++ b/src/native/vm/Makefile.am @@ -55,12 +55,12 @@ NATIVEVM_LIB = \ endif if ENABLE_JAVASE -REFLECT_SOURCES = \ - reflect.c \ - reflect.h +REFLECTION_SOURCES = \ + reflection.cpp \ + reflection.hpp SUN_MISC_UNSAFE_SOURCES = \ - sun_misc_Unsafe.c + sun_misc_Unsafe.cpp endif noinst_LTLIBRARIES = \ @@ -69,7 +69,7 @@ noinst_LTLIBRARIES = \ libnativevm_la_SOURCES = \ nativevm.c \ nativevm.h \ - $(REFLECT_SOURCES) \ + $(REFLECTION_SOURCES) \ $(SUN_MISC_UNSAFE_SOURCES) libnativevm_la_LIBADD = \ diff --git a/src/native/vm/cldc1.1/Makefile.am b/src/native/vm/cldc1.1/Makefile.am index 625d9acec..3cc987717 100644 --- a/src/native/vm/cldc1.1/Makefile.am +++ b/src/native/vm/cldc1.1/Makefile.am @@ -1,9 +1,7 @@ ## src/native/vm/cldc1.1/Makefile.am ## -## Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, -## R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, -## C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, -## Institut f. Computersprachen - TU Wien +## Copyright (C) 2006, 2007, 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO ## ## This file is part of CACAO. ## @@ -31,20 +29,20 @@ noinst_LTLIBRARIES = \ libnativevmcore.la libnativevmcore_la_SOURCES = \ - com_sun_cldc_io_ResourceInputStream.c \ - com_sun_cldc_io_j2me_socket_Protocol.c \ - com_sun_cldchi_io_ConsoleOutputStream.c \ - com_sun_cldchi_jvm_JVM.c \ - java_lang_Class.c \ - java_lang_Double.c \ - java_lang_Float.c \ - java_lang_Math.c \ - java_lang_Object.c \ - java_lang_Runtime.c \ - java_lang_String.c \ - java_lang_System.c \ - java_lang_Thread.c \ - java_lang_Throwable.c + com_sun_cldc_io_ResourceInputStream.cpp \ + com_sun_cldc_io_j2me_socket_Protocol.cpp \ + com_sun_cldchi_io_ConsoleOutputStream.cpp \ + com_sun_cldchi_jvm_JVM.cpp \ + java_lang_Class.cpp \ + java_lang_Double.cpp \ + java_lang_Float.cpp \ + java_lang_Math.cpp \ + java_lang_Object.cpp \ + java_lang_Runtime.cpp \ + java_lang_String.cpp \ + java_lang_System.cpp \ + java_lang_Thread.cpp \ + java_lang_Throwable.cpp ## Local variables: diff --git a/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c b/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c deleted file mode 100644 index 8395adac0..000000000 --- a/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c +++ /dev/null @@ -1,412 +0,0 @@ -/* src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.c - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -#include -#include -#include -#include -#include - -#include "config.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" -#include "native/include/com_sun_cldc_io_ResourceInputStream.h" -#include "native/include/com_sun_cldchi_jvm_FileDescriptor.h" - -#include "vm/types.h" -#include "vm/builtin.h" -#include "vm/vm.h" /* REMOVE ME: temporarily */ -#include "vm/exceptions.h" -#include "vm/stringlocal.h" - -#include "vmcore/zip.h" - -#include "threads/lock-common.h" - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "open", "(Ljava/lang/String;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_open }, - { "bytesRemain", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain }, - { "readByte", "(Ljava/lang/Object;)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readByte }, - { "readBytes", "(Ljava/lang/Object;[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_readBytes }, - { "clone", "(Ljava/lang/Object;)Ljava/lang/Object;", (void *) (ptrint) &Java_com_sun_cldc_io_ResourceInputStream_clone }, -}; - -/* _Jv_com_sun_cldc_io_ResourceInputStream_init ******************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_com_sun_cldc_io_ResourceInputStream_init(void) -{ - utf *u; - - u = utf_new_char("com/sun/cldc/io/ResourceInputStream"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - -static struct com_sun_cldchi_jvm_FileDescriptor* zip_read_resource(list_classpath_entry *lce, utf *name) -{ - hashtable_zipfile_entry *htzfe; - lfh lfh; - u1 *indata; - u1 *outdata; - z_stream zs; - int err; - - classinfo *ci; - com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL; - - /* try to find the class in the current archive */ - - htzfe = zip_find(lce, name); - - if (htzfe == NULL) - return NULL; - - /* read stuff from local file header */ - - lfh.filenamelength = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH); - lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH); - - indata = htzfe->data + - LFH_HEADER_SIZE + - lfh.filenamelength + - lfh.extrafieldlength; - - /* allocate buffer for uncompressed data */ - - outdata = MNEW(u1, htzfe->uncompressedsize); - - /* how is the file stored? */ - - switch (htzfe->compressionmethod) { - case Z_DEFLATED: - /* fill z_stream structure */ - - zs.next_in = indata; - zs.avail_in = htzfe->compressedsize; - zs.next_out = outdata; - zs.avail_out = htzfe->uncompressedsize; - - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - - /* initialize this inflate run */ - - if (inflateInit2(&zs, -MAX_WBITS) != Z_OK) - vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno)); - - /* decompress the file into buffer */ - - err = inflate(&zs, Z_SYNC_FLUSH); - - if ((err != Z_STREAM_END) && (err != Z_OK)) - vm_abort("zip_get: inflate failed: %s", strerror(errno)); - - /* finish this inflate run */ - - if (inflateEnd(&zs) != Z_OK) - vm_abort("zip_get: inflateEnd failed: %s", strerror(errno)); - break; - - case 0: - /* uncompressed file, just copy the data */ - MCOPY(outdata, indata, u1, htzfe->compressedsize); - break; - - default: - vm_abort("zip_get: unknown compression method %d", - htzfe->compressionmethod); - } - - /* Create a file descriptor object */ - ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor")); - fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci); - LLNI_field_set_val(fileDescriptor, pointer, (int)outdata); - LLNI_field_set_val(fileDescriptor, length, htzfe->uncompressedsize); - LLNI_field_set_val(fileDescriptor, position, 0); - return fileDescriptor; - -} - -static struct com_sun_cldchi_jvm_FileDescriptor* file_read_resource(char *path) -{ - int len; - struct stat statBuffer; - u1 *filep; - com_sun_cldchi_jvm_FileDescriptor *fileDescriptor = NULL; - classinfo *ci; - int fd; - - fd = open(path, O_RDONLY); - - if (fd > 0) { - - if (fstat(fd, &statBuffer) != -1) { - len = statBuffer.st_size; - } else { - return NULL; - } - - /* Map file into the memory */ - filep = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0); - - /* Create a file descriptor object */ - ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor")); - fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci); - LLNI_field_set_val(fileDescriptor, pointer, (int)filep); - LLNI_field_set_val(fileDescriptor, length, len); - LLNI_field_set_val(fileDescriptor, position, 0); - - return fileDescriptor; - - } else { - return NULL; - } - -} - - -/* - * Class: com/sun/cldc/io/ResourceInputStream - * Method: open - * Signature: (Ljava/lang/String;)Ljava/lang/Object; - */ -JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, java_lang_String *name) -{ - - list_classpath_entry *lce; - char *filename; - s4 filenamelen; - char *path; - utf *uname; - com_sun_cldchi_jvm_FileDescriptor* descriptor; - - /* get the classname as char string (do it here for the warning at - the end of the function) */ - - uname = javastring_toutf((java_handle_t *)name, false); - filenamelen = utf_bytes(uname) + strlen("0"); - filename = MNEW(char, filenamelen); - utf_copy(filename, uname); - - /* walk through all classpath entries */ - - for (lce = list_first(list_classpath_entries); lce != NULL; - lce = list_next(list_classpath_entries, lce)) { - -#if defined(ENABLE_ZLIB) - if (lce->type == CLASSPATH_ARCHIVE) { - - /* enter a monitor on zip/jar archives */ - LOCK_MONITOR_ENTER(lce); - - /* try to get the file in current archive */ - descriptor = zip_read_resource(lce, uname); - - /* leave the monitor */ - LOCK_MONITOR_EXIT(lce); - - if (descriptor != NULL) { /* file exists */ - break; - } - - } else { -#endif - - path = MNEW(char, lce->pathlen + filenamelen); - strcpy(path, lce->path); - strcat(path, filename); - - descriptor = file_read_resource(path); - - MFREE(path, char, lce->pathlen + filenamelen); - - if (descriptor != NULL) { /* file exists */ - break; - } - -#if defined(ENABLE_ZLIB) - } -#endif - - } - - MFREE(filename, char, filenamelen); - - return (java_lang_Object*) descriptor; - -} - - -/* - * Class: com_sun_cldc_io_ResourceInputStream - * Method: bytesRemain - * Signature: (Ljava/lang/Object;)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) { - - com_sun_cldchi_jvm_FileDescriptor *fileDescriptor; - int32_t length; - int32_t position; - - fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj; - LLNI_field_get_val(fileDescriptor, position, position); - LLNI_field_get_val(fileDescriptor, length, length); - - return length - position; - -} - -/* - * Class: com_sun_cldc_io_ResourceInputStream - * Method: readByte - * Signature: (Ljava/lang/Object;)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) { - - com_sun_cldchi_jvm_FileDescriptor *fileDescriptor; - u1 byte; - int32_t length; - int32_t position; - int64_t filep; - - fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj; - LLNI_field_get_val(fileDescriptor, position, position); - LLNI_field_get_val(fileDescriptor, length, length); - LLNI_field_get_val(fileDescriptor, pointer, filep); - - if (position < length) { - byte = ((u1*)(int)filep)[position]; - position++; - } else { - return -1; /* EOF */ - } - - /* Update access position */ - LLNI_field_set_val(fileDescriptor, position, position); - - return (byte & 0xFF); - -} - -/* - * Class: com_sun_cldc_io_ResourceInputStream - * Method: readBytes - * Signature: (Ljava/lang/Object;[BII)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj, java_handle_bytearray_t* byteArray, s4 off, s4 len) { - - com_sun_cldchi_jvm_FileDescriptor *fileDescriptor; - s4 readBytes = -1; - int32_t fileLength; - int32_t position; - s4 available; - int64_t filep; - void *buf; - - /* get pointer to the buffer */ - buf = &(LLNI_array_direct(byteArray, off)); - - fileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj; - LLNI_field_get_val(fileDescriptor, position, position); - LLNI_field_get_val(fileDescriptor, length, fileLength); - LLNI_field_get_val(fileDescriptor, pointer, filep); - - if (position < fileLength) { - available = fileLength - position; - if (available < len) { - readBytes = available; - } else { - readBytes = len; - } - memcpy(buf, ((u1*)(int)filep) + position, readBytes * sizeof(u1)); - position += readBytes; - } else { - return -1; /* EOF */ - } - - /* Update access position */ - LLNI_field_set_val(fileDescriptor, position, position); - - return readBytes; -} - -/* - * Class: com_sun_cldc_io_ResourceInputStream - * Method: clone - * Signature: (Ljava/lang/Object;)Ljava/lang/Object; - */ -JNIEXPORT struct java_lang_Object* JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, struct java_lang_Object* jobj) { - - classinfo *ci; - com_sun_cldchi_jvm_FileDescriptor *srcFileDescriptor; - com_sun_cldchi_jvm_FileDescriptor *dstFileDescriptor; - int32_t srcLength; - int32_t srcPosition; - int64_t srcFilePointer; - - srcFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) jobj; - LLNI_field_get_val(srcFileDescriptor, position, srcPosition); - LLNI_field_get_val(srcFileDescriptor, length, srcLength); - LLNI_field_get_val(srcFileDescriptor, pointer, srcFilePointer); - - ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor")); - dstFileDescriptor = (com_sun_cldchi_jvm_FileDescriptor *) native_new_and_init(ci); - LLNI_field_set_val(dstFileDescriptor, position, srcPosition); - LLNI_field_set_val(dstFileDescriptor, length, srcLength); - LLNI_field_set_val(dstFileDescriptor, pointer, srcFilePointer); - - return (java_lang_Object*) dstFileDescriptor; - -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp b/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp new file mode 100644 index 000000000..9aa25a547 --- /dev/null +++ b/src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp @@ -0,0 +1,404 @@ +/* src/native/vm/cldc1.1/com_sun_cldc_io_ResourceInputStream.cpp + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/com_sun_cldc_io_ResourceInputStream.h" +#endif + +#include "threads/mutex.hpp" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/javaobjects.hpp" +#include "vm/string.hpp" +#include "vm/types.h" +#include "vm/vm.hpp" /* REMOVE ME: temporarily */ +#include "vm/zip.h" + + +static java_handle_t* zip_read_resource(list_classpath_entry *lce, utf *name) +{ + hashtable_zipfile_entry *htzfe; + lfh lfh; + u1 *indata; + u1 *outdata; + z_stream zs; + int err; + + classinfo *ci; + + /* try to find the class in the current archive */ + + htzfe = zip_find(lce, name); + + if (htzfe == NULL) + return NULL; + + /* read stuff from local file header */ + + lfh.filenamelength = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH); + lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH); + + indata = htzfe->data + + LFH_HEADER_SIZE + + lfh.filenamelength + + lfh.extrafieldlength; + + /* allocate buffer for uncompressed data */ + + outdata = MNEW(u1, htzfe->uncompressedsize); + + /* how is the file stored? */ + + switch (htzfe->compressionmethod) { + case Z_DEFLATED: + /* fill z_stream structure */ + + zs.next_in = indata; + zs.avail_in = htzfe->compressedsize; + zs.next_out = outdata; + zs.avail_out = htzfe->uncompressedsize; + + zs.zalloc = Z_NULL; + zs.zfree = Z_NULL; + zs.opaque = Z_NULL; + + /* initialize this inflate run */ + + if (inflateInit2(&zs, -MAX_WBITS) != Z_OK) + vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno)); + + /* decompress the file into buffer */ + + err = inflate(&zs, Z_SYNC_FLUSH); + + if ((err != Z_STREAM_END) && (err != Z_OK)) + vm_abort("zip_get: inflate failed: %s", strerror(errno)); + + /* finish this inflate run */ + + if (inflateEnd(&zs) != Z_OK) + vm_abort("zip_get: inflateEnd failed: %s", strerror(errno)); + break; + + case 0: + /* uncompressed file, just copy the data */ + MCOPY(outdata, indata, u1, htzfe->compressedsize); + break; + + default: + vm_abort("zip_get: unknown compression method %d", + htzfe->compressionmethod); + } + + // Create a file descriptor object. + ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor")); + java_handle_t* h = native_new_and_init(ci); + + if (h == NULL) + return NULL; + + com_sun_cldchi_jvm_FileDescriptor fd(h, (int64_t) outdata, 0, htzfe->uncompressedsize); + + return fd.get_handle(); +} + + +static java_handle_t* file_read_resource(char *path) +{ + int len; + struct stat statBuffer; + u1 *filep; + classinfo *ci; + int fd; + + fd = open(path, O_RDONLY); + + if (fd > 0) { + + if (fstat(fd, &statBuffer) != -1) { + len = statBuffer.st_size; + } else { + return NULL; + } + + /* Map file into the memory */ + filep = (u1*) mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0); + + /* Create a file descriptor object */ + ci = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor")); + java_handle_t* h = native_new_and_init(ci); + + if (h == NULL) + return NULL; + + com_sun_cldchi_jvm_FileDescriptor fd(h, (int64_t) filep, 0, len); + + return fd.get_handle(); + } + else { + return NULL; + } +} + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: com/sun/cldc/io/ResourceInputStream + * Method: open + * Signature: (Ljava/lang/String;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_open(JNIEnv *env, jclass clazz, jstring name) +{ + list_classpath_entry *lce; + char *filename; + s4 filenamelen; + char *path; + utf *uname; + java_handle_t* descriptor; + + /* get the classname as char string (do it here for the warning at + the end of the function) */ + + uname = javastring_toutf((java_handle_t *)name, false); + filenamelen = utf_bytes(uname) + strlen("0"); + filename = MNEW(char, filenamelen); + utf_copy(filename, uname); + + /* walk through all classpath entries */ + + for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL; + lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) { + +#if defined(ENABLE_ZLIB) + if (lce->type == CLASSPATH_ARCHIVE) { + + /* enter a monitor on zip/jar archives */ + lce->mutex->lock(); + + /* try to get the file in current archive */ + descriptor = zip_read_resource(lce, uname); + + /* leave the monitor */ + lce->mutex->unlock(); + + if (descriptor != NULL) { /* file exists */ + break; + } + + } else { +#endif + + path = MNEW(char, lce->pathlen + filenamelen); + strcpy(path, lce->path); + strcat(path, filename); + + descriptor = file_read_resource(path); + + MFREE(path, char, lce->pathlen + filenamelen); + + if (descriptor != NULL) { /* file exists */ + break; + } +#if defined(ENABLE_ZLIB) + } +#endif + } + + MFREE(filename, char, filenamelen); + + return (jobject) descriptor; +} + + +/* + * Class: com/sun/cldc/io/ResourceInputStream + * Method: bytesRemain + * Signature: (Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_bytesRemain(JNIEnv *env, jclass clazz, jobject jobj) +{ + com_sun_cldchi_jvm_FileDescriptor fd(jobj); + int32_t length = fd.get_position(); + int32_t position = fd.get_length(); + + return length - position; +} + + +/* + * Class: com/sun/cldc/io/ResourceInputStream + * Method: readByte + * Signature: (Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_readByte(JNIEnv *env, jclass clazz, jobject jobj) +{ + com_sun_cldchi_jvm_FileDescriptor fd(jobj); + + int64_t filep = fd.get_pointer(); + int32_t position = fd.get_position(); + int32_t length = fd.get_length(); + + uint8_t byte; + + if (position < length) { + byte = ((uint8_t*) filep)[position]; + position++; + } + else { + return -1; /* EOF */ + } + + // Update access position. + fd.set_position(position); + + return (byte & 0xFF); +} + + +/* + * Class: com/sun/cldc/io/ResourceInputStream + * Method: readBytes + * Signature: (Ljava/lang/Object;[BII)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_ResourceInputStream_readBytes(JNIEnv *env, jclass clazz, jobject jobj, jbyteArray byteArray, jint off, jint len) +{ + /* get pointer to the buffer */ + // XXX Not GC safe. + void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) byteArray, off)); + + com_sun_cldchi_jvm_FileDescriptor fd(jobj); + + int64_t filep = fd.get_pointer(); + int32_t position = fd.get_position(); + int32_t fileLength = fd.get_length(); + + int32_t readBytes = -1; + + if (position < fileLength) { + int32_t available = fileLength - position; + + if (available < len) { + readBytes = available; + } else { + readBytes = len; + } + + os::memcpy(buf, ((uint8_t*) filep) + position, readBytes * sizeof(uint8_t)); + position += readBytes; + } + else { + return -1; /* EOF */ + } + + // Update access position. + fd.set_position(position); + + return readBytes; +} + + +/* + * Class: com/sun/cldc/io/ResourceInputStream + * Method: clone + * Signature: (Ljava/lang/Object;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_com_sun_cldc_io_ResourceInputStream_clone(JNIEnv *env, jclass clazz, jobject jobj) +{ + com_sun_cldchi_jvm_FileDescriptor fd(jobj); + + classinfo* c = load_class_bootstrap(utf_new_char("com/sun/cldchi/jvm/FileDescriptor")); + java_handle_t* h = native_new_and_init(c); + + if (h == NULL) + return NULL; + + com_sun_cldchi_jvm_FileDescriptor clonefd(h, fd); + + return (jobject) clonefd.get_handle(); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "open", (char*) "(Ljava/lang/String;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_open }, + { (char*) "bytesRemain", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_bytesRemain }, + { (char*) "readByte", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readByte }, + { (char*) "readBytes", (char*) "(Ljava/lang/Object;[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_readBytes }, + { (char*) "clone", (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_com_sun_cldc_io_ResourceInputStream_clone }, +}; + + +/* _Jv_com_sun_cldc_io_ResourceInputStream_init ******************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_com_sun_cldc_io_ResourceInputStream_init(void) +{ + utf *u; + + u = utf_new_char("com/sun/cldc/io/ResourceInputStream"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c deleted file mode 100644 index ee32030c2..000000000 --- a/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c +++ /dev/null @@ -1,282 +0,0 @@ -/* src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.c - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h" - -#include "vm/global.h" -#include "vm/vm.h" /* REMOVE ME: temporarily */ - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "open0", "([BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_open0 }, - { "readBuf", "(I[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf }, - { "readByte", "(I)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_readByte }, - { "writeBuf", "(I[BII)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf }, - { "writeByte", "(II)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte }, - { "available0", "(I)I", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_available0 }, - { "close0", "(I)V", (void *) (ptrint) &Java_com_sun_cldc_io_j2me_socket_Protocol_close0 }, -}; - - -/* _Jv_com_sun_cldc_io_j2me_socket_Protocol_init ******************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init(void) -{ - utf *u; - - u = utf_new_char("com/sun/cldc/io/j2me/socket/Protocol"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: open0 - * Signature: ([BII)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, java_handle_bytearray_t *hostname, s4 port, s4 mode) -{ - struct hostent *phostent; - struct sockaddr_in serv_addr; - char *name; - s4 sockfd; - s4 result; - - /* The hostname byte-array is a NULL terminated C-string. */ - - name = (char *) &(LLNI_array_data(hostname)); - - /* get the host */ - - phostent = gethostbyname(name); - - if (phostent == NULL) - return -1; - - /* fill the sockaddr structure */ - - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(port); - - MCOPY(&serv_addr.sin_addr, phostent->h_addr, u1, phostent->h_length); - - /* create the socket */ - - sockfd = socket(AF_INET, SOCK_STREAM, 0); - - if (sockfd < 0) - return -1; - - /* connect the socket */ - - result = connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)); - - if (result < 0) - return -1; - - return sockfd; -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: readBuf - * Signature: (I[BII)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t *b, s4 off, s4 len) -{ - void *buf; - ssize_t result; - - /* get pointer to the buffer */ - - buf = &(LLNI_array_direct(b, off)); - - /* receive from the socket */ - - result = recv(handle, buf, len, 0); - - if (result == 0) { - /* the peer has performed an orderly shutdown */ - - return -1; - } - else if (result < 0) { - vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed: %s", strerror(errno)); - } - - return result; -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: readByte - * Signature: (I)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv *env, jclass clazz, s4 handle) { - - char byte; - ssize_t result; - - /* receive from the socket */ - - result = recv(handle, &byte, 1, 0); - - if (result == 0) { - /* the peer has performed an orderly shutdown */ - - return -1; - } - else if (result < 0) { - /* should throw an IOException */ - - vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed: %s", strerror(errno)); - } - - return byte; -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: writeBuf - * Signature: (I[BII)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, s4 handle, java_handle_bytearray_t * b, s4 off, s4 len) { - - void *buf; - ssize_t result; - - /* get pointer to the buffer */ - - buf = &(LLNI_array_direct(b, off)); - - /* send the given byte to the socket */ - - result = send(handle, buf, len, 0); - - if (result < 0) - /* should throw an IOException */ - - vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed: %s", strerror(errno)); - - return result; - -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: writeByte - * Signature: (II)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEnv *env, jclass clazz, s4 handle, s4 b) -{ - char byte; - ssize_t result; - - byte = (char) b; - - /* send the given byte to the socket */ - - result = send(handle, &byte, 1, 0); - - if (result < 0) - vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed: %s", strerror(errno)); - - return result; -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: available0 - * Signature: (I)I - */ -JNIEXPORT s4 JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_available0(JNIEnv *env, jclass clazz, s4 handle) -{ - /* NOTE: Sun doesn't have an implementation too */ - - return 0; -} - - -/* - * Class: com/sun/cldc/io/j2me/socket/Protocol - * Method: close0 - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv *env, jclass clazz, s4 handle) -{ - int result; - - /* close the file descriptor */ - - result = close(handle); - - if (result < 0) - vm_abort("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed: %s", strerror(errno)); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp new file mode 100644 index 000000000..9d2058b5a --- /dev/null +++ b/src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp @@ -0,0 +1,266 @@ +/* src/native/vm/cldc1.1/com_sun_cldc_io_j2me_socket_Protocol.cpp + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/com_sun_cldc_io_j2me_socket_Protocol.h" +#endif + +#include "vm/global.h" +#include "vm/vm.hpp" /* REMOVE ME: temporarily */ + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: open0 + * Signature: ([BII)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_open0(JNIEnv *env, jclass clazz, jbyteArray hostname, jint port, jint mode) +{ + struct hostent *phostent; + struct sockaddr_in serv_addr; + + // The hostname byte-array is a NULL terminated C-string. + // XXX Not GC safe. + char* name = (char*) &(LLNI_array_data((java_handle_bytearray_t*) hostname)); + + /* get the host */ + + phostent = gethostbyname(name); + + if (phostent == NULL) + return -1; + + /* fill the sockaddr structure */ + + serv_addr.sin_family = AF_INET; + serv_addr.sin_port = htons(port); + + MCOPY(&serv_addr.sin_addr, phostent->h_addr, u1, phostent->h_length); + + /* create the socket */ + + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + + if (sockfd < 0) + return -1; + + /* connect the socket */ + + int result = connect(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)); + + if (result < 0) + return -1; + + return sockfd; +} + + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: readBuf + * Signature: (I[BII)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf(JNIEnv *env, jclass clazz, jint handle, jbyteArray b, jint off, jint len) +{ + // Get pointer to the buffer. + // XXX Not GC safe. + void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off)); + + // Receive from the socket. + ssize_t result = recv(handle, buf, len, 0); + + if (result == 0) { + // The peer has performed an orderly shutdown. + return -1; + } + else if (result < 0) { + vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf: recv failed"); + } + + return result; +} + + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: readByte + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_readByte(JNIEnv *env, jclass clazz, jint handle) +{ + char byte; + + // Receive from the socket. + ssize_t result = recv(handle, &byte, 1, 0); + + if (result == 0) { + // The peer has performed an orderly shutdown. + return -1; + } + else if (result < 0) { + // TODO Should throw an IOException. + vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_readByte: recv failed"); + } + + return byte; +} + + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: writeBuf + * Signature: (I[BII)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf(JNIEnv *env, jclass clazz, jint handle, jbyteArray b, jint off, jint len) +{ + // Get pointer to the buffer. + // XXX Not GC safe. + void* buf = &(LLNI_array_direct((java_handle_bytearray_t*) b, off)); + + // Send the given byte to the socket. + ssize_t result = send(handle, buf, len, 0); + + if (result < 0) { + // TODO Should throw an IOException. + vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf: send failed"); + } + + return result; +} + + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: writeByte + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte(JNIEnv *env, jclass clazz, jint handle, jint b) +{ + char byte = (char) b; + + // Send the given byte to the socket. + ssize_t result = send(handle, &byte, 1, 0); + + if (result < 0) + vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte: send failed"); + + return result; +} + + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: available0 + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_available0(JNIEnv *env, jclass clazz, jint handle) +{ + // NOTE: Sun doesn't have an implementation too. + return 0; +} + + +/* + * Class: com/sun/cldc/io/j2me/socket/Protocol + * Method: close0 + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_sun_cldc_io_j2me_socket_Protocol_close0(JNIEnv *env, jclass clazz, jint handle) +{ + // Close the file descriptor. + int result = close(handle); + + if (result < 0) + vm_abort_errno("Java_com_sun_cldc_io_j2me_socket_Protocol_close0: close failed"); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "open0", (char*) "([BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_open0 }, + { (char*) "readBuf", (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf }, + { (char*) "readByte", (char*) "(I)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_readByte }, + { (char*) "writeBuf", (char*) "(I[BII)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeBuf }, + { (char*) "writeByte", (char*) "(II)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte }, + { (char*) "available0", (char*) "(I)I", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_available0 }, + { (char*) "close0", (char*) "(I)V", (void*) (uintptr_t) &Java_com_sun_cldc_io_j2me_socket_Protocol_close0 }, +}; + + +/* _Jv_com_sun_cldc_io_j2me_socket_Protocol_init ******************************* + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_com_sun_cldc_io_j2me_socket_Protocol_init(void) +{ + utf *u; + + u = utf_new_char("com/sun/cldc/io/j2me/socket/Protocol"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c b/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c deleted file mode 100644 index fc642a1b2..000000000 --- a/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c +++ /dev/null @@ -1,86 +0,0 @@ -/* src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "write", "(I)V", (void *) (ptrint) &Java_com_sun_cldchi_io_ConsoleOutputStream_write }, -}; - - -/* _Jv_com_sun_cldchi_io_ConsoleOutputStream_init ****************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_com_sun_cldchi_io_ConsoleOutputStream_init(void) -{ - utf *u; - - u = utf_new_char("com/sun/cldchi/io/ConsoleOutputStream"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: com/sun/cldchi/io/ConsoleOutputStream - * Method: write - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, com_sun_cldchi_io_ConsoleOutputStream *this, s4 c) -{ - (void) fputc(c, stdout); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp b/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp new file mode 100644 index 000000000..d3b4b1c2d --- /dev/null +++ b/src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp @@ -0,0 +1,95 @@ +/* src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h" +#endif + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: com/sun/cldchi/io/ConsoleOutputStream + * Method: write + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, jobject _this, jint c) +{ + (void) fputc(c, stdout); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "write", (char*) "(I)V", (void*) (uintptr_t) &Java_com_sun_cldchi_io_ConsoleOutputStream_write }, +}; + + +/* _Jv_com_sun_cldchi_io_ConsoleOutputStream_init ****************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_com_sun_cldchi_io_ConsoleOutputStream_init(void) +{ + utf *u; + + u = utf_new_char("com/sun/cldchi/io/ConsoleOutputStream"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c deleted file mode 100644 index b5b113a90..000000000 --- a/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c +++ /dev/null @@ -1,104 +0,0 @@ -/* src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.c - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" -#include "vm/types.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_String.h" - -#include "native/include/com_sun_cldchi_jvm_JVM.h" - -#include "vm/exceptions.h" -#include "vm/stringlocal.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "loadLibrary", "(Ljava/lang/String;)V", (void *) (ptrint) &Java_com_sun_cldchi_jvm_JVM_loadLibrary }, -}; - - -/* _Jv_com_sun_cldchi_jvm_JVM_init ********************************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_com_sun_cldchi_jvm_JVM_init(void) -{ - utf *u; - - u = utf_new_char("com/sun/cldchi/jvm/JVM"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: com/sun/cldchi/jvm/JVM - * Method: loadLibrary - * Signature: (Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jclass clazz, java_lang_String *libName) -{ - int result; - utf *name; - - /* REMOVEME When we use Java-strings internally. */ - - if (libName == NULL) { - exceptions_throw_nullpointerexception(); - return; - } - - name = javastring_toutf((java_handle_t *) libName, false); - - result = native_library_load(env, name, NULL); - - /* Check for error and throw an exception in case. */ - - if (result == 0) { - exceptions_throw_unsatisfiedlinkerror(name); - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp new file mode 100644 index 000000000..02399192c --- /dev/null +++ b/src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp @@ -0,0 +1,110 @@ +/* src/native/vm/cldc1.1/com_sun_cldchi_jvm_JVM.cpp + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/com_sun_cldchi_jvm_JVM.h" +#endif + +#include "vm/exceptions.hpp" +#include "vm/string.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: com/sun/cldchi/jvm/JVM + * Method: loadLibrary + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_sun_cldchi_jvm_JVM_loadLibrary(JNIEnv *env, jclass clazz, jstring libName) +{ + if (libName == NULL) { + exceptions_throw_nullpointerexception(); + return; + } + + /* REMOVEME When we use Java-strings internally. */ + + utf* name = javastring_toutf((java_handle_t *) libName, false); + + int result = native_library_load(env, name, NULL); + + /* Check for error and throw an exception in case. */ + + if (result == 0) { + exceptions_throw_unsatisfiedlinkerror(name); + } +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "loadLibrary", (char*) "(Ljava/lang/String;)V", (void*) (uintptr_t) &Java_com_sun_cldchi_jvm_JVM_loadLibrary }, +}; + + +/* _Jv_com_sun_cldchi_jvm_JVM_init ********************************************* + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_com_sun_cldchi_jvm_JVM_init(void) +{ + utf *u; + + u = utf_new_char("com/sun/cldchi/jvm/JVM"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Class.c b/src/native/vm/cldc1.1/java_lang_Class.c deleted file mode 100644 index 3d438a719..000000000 --- a/src/native/vm/cldc1.1/java_lang_Class.c +++ /dev/null @@ -1,239 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Class.c - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" -#include "vm/types.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_String.h" /* required by j.l.C */ -#include "native/include/java_lang_Object.h" - -#include "native/include/java_lang_Class.h" - -#include "vm/exceptions.h" -#include "vm/initialize.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "forName", "(Ljava/lang/String;)Ljava/lang/Class;",(void *) (ptrint) &Java_java_lang_Class_forName }, - { "newInstance", "()Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_Class_newInstance }, - { "isInstance", "(Ljava/lang/Object;)Z", (void *) (ptrint) &Java_java_lang_Class_isInstance }, - { "isAssignableFrom", "(Ljava/lang/Class;)Z", (void *) (ptrint) &Java_java_lang_Class_isAssignableFrom }, - { "isInterface", "()Z", (void *) (ptrint) &Java_java_lang_Class_isInterface }, - { "isArray", "()Z", (void *) (ptrint) &Java_java_lang_Class_isArray }, - { "getName", "()Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_Class_getName }, -}; - -/* _Jv_java_lang_Class_init **************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Class_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Class"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Class - * Method: forName - * Signature: (Ljava/lang/String;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Class_forName(JNIEnv *env, jclass clazz, java_lang_String *name) -{ - utf *ufile; - utf *uname; - classinfo *c; - u2 *pos; - s4 i; - - /* illegal argument */ - - if (name == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* create utf string in which '.' is replaced by '/' */ - - ufile = javastring_toutf((java_handle_t *) name, true); - uname = javastring_toutf((java_handle_t *) name, false); - - /* name must not contain '/' (mauve test) */ - - for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) { - if (*pos == '/') { - exceptions_throw_classnotfoundexception(uname); - return NULL; - } - } - - /* try to load, ... */ - - c = load_class_bootstrap(ufile); - - if (c == NULL) - return NULL; - - /* link, ... */ - - if (!link_class(c)) - return NULL; - - /* ...and initialize it. */ - - if (!initialize_class(c)) - return NULL; - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: java/lang/Class - * Method: newInstance - * Signature: ()Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, java_lang_Class* this) -{ - classinfo *c; - java_handle_t *o; - - c = LLNI_classinfo_unwrap(this); - - o = native_new_and_init(c); - - return (java_lang_Object *) o; -} - - -/* - * Class: java/lang/Class - * Method: isInstance - * Signature: (Ljava/lang/Object;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_Class_isInstance(JNIEnv *env, java_lang_Class *this, java_lang_Object *obj) -{ - classinfo *c; - java_handle_t *h; - - c = LLNI_classinfo_unwrap(this); - h = (java_handle_t *) obj; - - return class_is_instance(c, h); -} - - -/* - * Class: java/lang/Class - * Method: isAssignableFrom - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_Class_isAssignableFrom(JNIEnv *env, java_lang_Class *this, java_lang_Class *cls) -{ - classinfo *to; - classinfo *from; - - to = LLNI_classinfo_unwrap(this); - from = LLNI_classinfo_unwrap(cls); - - if (from == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - return class_is_assignable_from(to, from); -} - - -/* - * Class: java/lang/Class - * Method: isInterface - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_Class_isInterface(JNIEnv *env, java_lang_Class *this) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(this); - - return class_is_interface(c); -} - - -/* - * Class: java/lang/Class - * Method: isArray - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_Class_isArray(JNIEnv *env, java_lang_Class *this) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(this); - - return class_is_array(c); -} - - -/* - * Class: java/lang/Class - * Method: getName - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_Class_getName(JNIEnv *env, java_lang_Class *this) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(this); - - return (java_lang_String*) class_get_classname(c); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Class.cpp b/src/native/vm/cldc1.1/java_lang_Class.cpp new file mode 100644 index 000000000..cdfe87c56 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Class.cpp @@ -0,0 +1,248 @@ +/* src/native/vm/cldc1.1/java_lang_Class.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Class.h" +#endif + +#include "vm/exceptions.hpp" +#include "vm/initialize.h" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Class + * Method: forName + * Signature: (Ljava/lang/String;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_Class_forName(JNIEnv *env, jclass clazz, jstring name) +{ + utf *ufile; + utf *uname; + classinfo *c; + char* pos; + int32_t i; + + /* illegal argument */ + + if (name == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* create utf string in which '.' is replaced by '/' */ + + ufile = javastring_toutf((java_handle_t *) name, true); + uname = javastring_toutf((java_handle_t *) name, false); + + /* name must not contain '/' (mauve test) */ + + // FIXME Move this check into a function. + for (i = 0, pos = uname->text; i < uname->blength; i++, pos++) { + if (*pos == '/') { + exceptions_throw_classnotfoundexception(uname); + return NULL; + } + } + + /* try to load, ... */ + + c = load_class_bootstrap(ufile); + + if (c == NULL) + return NULL; + + /* link, ... */ + + if (!link_class(c)) + return NULL; + + /* ...and initialize it. */ + + if (!initialize_class(c)) + return NULL; + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* + * Class: java/lang/Class + * Method: newInstance + * Signature: ()Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_java_lang_Class_newInstance(JNIEnv *env, jclass _this) +{ + classinfo *c; + java_handle_t *o; + + c = LLNI_classinfo_unwrap(_this); + + o = native_new_and_init(c); + + return (jobject) o; +} + + +/* + * Class: java/lang/Class + * Method: isInstance + * Signature: (Ljava/lang/Object;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_Class_isInstance(JNIEnv *env, jclass _this, jobject obj) +{ + classinfo *c; + java_handle_t *h; + + c = LLNI_classinfo_unwrap(_this); + h = (java_handle_t *) obj; + + return class_is_instance(c, h); +} + + +/* + * Class: java/lang/Class + * Method: isAssignableFrom + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_Class_isAssignableFrom(JNIEnv *env, jclass _this, jclass cls) +{ + classinfo *to; + classinfo *from; + + to = LLNI_classinfo_unwrap(_this); + from = LLNI_classinfo_unwrap(cls); + + if (from == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + return class_is_assignable_from(to, from); +} + + +/* + * Class: java/lang/Class + * Method: isInterface + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_Class_isInterface(JNIEnv *env, jclass _this) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(_this); + + return class_is_interface(c); +} + + +/* + * Class: java/lang/Class + * Method: isArray + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_Class_isArray(JNIEnv *env, jclass _this) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(_this); + + return class_is_array(c); +} + + +/* + * Class: java/lang/Class + * Method: getName + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_Class_getName(JNIEnv *env, jclass _this) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(_this); + + return (jstring) class_get_classname(c); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "forName", (char*) "(Ljava/lang/String;)Ljava/lang/Class;",(void*) (uintptr_t) &Java_java_lang_Class_forName }, + { (char*) "newInstance", (char*) "()Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_Class_newInstance }, + { (char*) "isInstance", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_Class_isInstance }, + { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_Class_isAssignableFrom }, + { (char*) "isInterface", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Class_isInterface }, + { (char*) "isArray", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Class_isArray }, + { (char*) "getName", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_Class_getName }, +}; + +/* _Jv_java_lang_Class_init **************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Class_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Class"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Double.c b/src/native/vm/cldc1.1/java_lang_Double.c deleted file mode 100644 index 99f319503..000000000 --- a/src/native/vm/cldc1.1/java_lang_Double.c +++ /dev/null @@ -1,123 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Double.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" -#include "vm/types.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Double.h" - -#include "vm/builtin.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "doubleToLongBits", "(D)J", (void *) (ptrint) &Java_java_lang_Double_doubleToLongBits }, - { "longBitsToDouble", "(J)D", (void *) (ptrint) &Java_java_lang_Double_longBitsToDouble }, -}; - - -/* _Jv_java_lang_Double_init *************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Double_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Double"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Double - * Method: doubleToLongBits - * Signature: (D)J - */ -JNIEXPORT s8 JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, double doubleValue) -{ - jvalue val; - s8 e, f; - val.d = doubleValue; - -#if defined(__IEEE_BYTES_LITTLE_ENDIAN) - /* On little endian ARM processors when using FPA, word order of - doubles is still big endian. So take that into account here. When - using VFP, word order of doubles follows byte order. */ - -#define SWAP_DOUBLE(a) (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff)) - - val.j = SWAP_DOUBLE(val.j); -#endif - - e = val.j & 0x7ff0000000000000LL; - f = val.j & 0x000fffffffffffffLL; - - if (e == DBL_POSINF && f != 0L) - val.j = DBL_NAN; - - return val.j; -} - - -/* - * Class: java/lang/Double - * Method: longBitsToDouble - * Signature: (J)D - */ -JNIEXPORT double JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, s8 longValue) -{ - jvalue val; - val.j = longValue; - -#if defined(__IEEE_BYTES_LITTLE_ENDIAN) - val.j = SWAP_DOUBLE(val.j); -#endif - - return val.d; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Double.cpp b/src/native/vm/cldc1.1/java_lang_Double.cpp new file mode 100644 index 000000000..19146e44c --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Double.cpp @@ -0,0 +1,132 @@ +/* src/native/vm/cldc1.1/java_lang_Double.c + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Double.h" +#endif + +#include "vm/jit/builtin.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Double + * Method: doubleToLongBits + * Signature: (D)J + */ +JNIEXPORT jlong JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, jdouble doubleValue) +{ + jvalue val; + s8 e, f; + val.d = doubleValue; + +#if defined(__IEEE_BYTES_LITTLE_ENDIAN) + /* On little endian ARM processors when using FPA, word order of + doubles is still big endian. So take that into account here. When + using VFP, word order of doubles follows byte order. */ + +#define SWAP_DOUBLE(a) (((a) << 32) | (((a) >> 32) & 0x00000000ffffffff)) + + val.j = SWAP_DOUBLE(val.j); +#endif + + e = val.j & 0x7ff0000000000000LL; + f = val.j & 0x000fffffffffffffLL; + + if (e == DBL_POSINF && f != 0L) + val.j = DBL_NAN; + + return val.j; +} + + +/* + * Class: java/lang/Double + * Method: longBitsToDouble + * Signature: (J)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, jlong longValue) +{ + jvalue val; + val.j = longValue; + +#if defined(__IEEE_BYTES_LITTLE_ENDIAN) + val.j = SWAP_DOUBLE(val.j); +#endif + + return val.d; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "doubleToLongBits", (char*) "(D)J", (void*) (uintptr_t) &Java_java_lang_Double_doubleToLongBits }, + { (char*) "longBitsToDouble", (char*) "(J)D", (void*) (uintptr_t) &Java_java_lang_Double_longBitsToDouble }, +}; + + +/* _Jv_java_lang_Double_init *************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Double_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Double"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Float.c b/src/native/vm/cldc1.1/java_lang_Float.c deleted file mode 100644 index 67cb0046e..000000000 --- a/src/native/vm/cldc1.1/java_lang_Float.c +++ /dev/null @@ -1,94 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Float.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" -#include "vm/types.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Float.h" - -#include "vm/builtin.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "floatToIntBits", "(F)I", (void *) (ptrint) &Java_java_lang_Float_floatToIntBits }, -}; - - -/* _Jv_java_lang_Float_init **************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Float_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Float"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - -/* - * Class: java/lang/Float - * Method: floatToIntBits - * Signature: (F)I - */ -JNIEXPORT s4 JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass clazz, float value) -{ - imm_union val; - int e, f; - - val.f = value; - - e = val.i & 0x7f800000; - f = val.i & 0x007fffff; - - if (e == FLT_POSINF && f != 0) - return FLT_NAN; - - return val.i; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Float.cpp b/src/native/vm/cldc1.1/java_lang_Float.cpp new file mode 100644 index 000000000..0d98b2833 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Float.cpp @@ -0,0 +1,104 @@ +/* src/native/vm/cldc1.1/java_lang_Float.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Float.h" +#endif + +#include "vm/jit/builtin.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Float + * Method: floatToIntBits + * Signature: (F)I + */ +JNIEXPORT jint JNICALL Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass clazz, jfloat value) +{ + imm_union val; + int e, f; + + val.f = value; + + e = val.i & 0x7f800000; + f = val.i & 0x007fffff; + + if (e == FLT_POSINF && f != 0) + return FLT_NAN; + + return val.i; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "floatToIntBits", (char*) "(F)I", (void*) (uintptr_t) &Java_java_lang_Float_floatToIntBits }, +}; + + +/* _Jv_java_lang_Float_init **************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Float_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Float"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Math.c b/src/native/vm/cldc1.1/java_lang_Math.c deleted file mode 100644 index 9d542b7f1..000000000 --- a/src/native/vm/cldc1.1/java_lang_Math.c +++ /dev/null @@ -1,145 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Math.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" -#include "vm/types.h" - -#include "fdlibm/fdlibm.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Math.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "ceil", "(D)D", (void *) (ptrint) &Java_java_lang_Math_ceil }, - { "cos", "(D)D", (void *) (ptrint) &Java_java_lang_Math_cos }, - { "floor", "(D)D", (void *) (ptrint) &Java_java_lang_Math_floor }, - { "sin", "(D)D", (void *) (ptrint) &Java_java_lang_Math_sin }, - { "sqrt", "(D)D", (void *) (ptrint) &Java_java_lang_Math_sqrt }, - { "tan", "(D)D", (void *) (ptrint) &Java_java_lang_Math_tan }, -}; - - -/* _Jv_java_lang_Math_init ***************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Math_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Math"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Math - * Method: ceil - * Signature: (D)D - */ -JNIEXPORT double JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, double a) -{ - return ceil(a); -} - - -/* - * Class: java/lang/Math - * Method: cos - * Signature: (D)D - */ -JNIEXPORT double JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, double a) -{ - return cos(a); -} - - -/* - * Class: java/lang/Math - * Method: floor - * Signature: (D)D - */ -JNIEXPORT double JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, double a) -{ - return floor(a); -} - - -/* - * Class: java/lang/Math - * Method: sin - * Signature: (D)D - */ -JNIEXPORT double JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, double a) -{ - return sin(a); -} - - -/* - * Class: java/lang/Math - * Method: sqrt - * Signature: (D)D - */ -JNIEXPORT double JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, double a) -{ - return sqrt(a); -} - - -/* - * Class: java/lang/Math - * Method: tan - * Signature: (D)D - */ -JNIEXPORT double JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, double a) -{ - return tan(a); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Math.cpp b/src/native/vm/cldc1.1/java_lang_Math.cpp new file mode 100644 index 000000000..8ca741ecb --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Math.cpp @@ -0,0 +1,154 @@ +/* src/native/vm/cldc1.1/java_lang_Math.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "fdlibm/fdlibm.h" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Math.h" +#endif + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Math + * Method: ceil + * Signature: (D)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Math_ceil(JNIEnv *env, jclass clazz, jdouble a) +{ + return ceil(a); +} + + +/* + * Class: java/lang/Math + * Method: cos + * Signature: (D)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Math_cos(JNIEnv *env, jclass clazz, jdouble a) +{ + return cos(a); +} + + +/* + * Class: java/lang/Math + * Method: floor + * Signature: (D)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Math_floor(JNIEnv *env, jclass clazz, jdouble a) +{ + return floor(a); +} + + +/* + * Class: java/lang/Math + * Method: sin + * Signature: (D)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Math_sin(JNIEnv *env, jclass clazz, jdouble a) +{ + return sin(a); +} + + +/* + * Class: java/lang/Math + * Method: sqrt + * Signature: (D)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Math_sqrt(JNIEnv *env, jclass clazz, jdouble a) +{ + return sqrt(a); +} + + +/* + * Class: java/lang/Math + * Method: tan + * Signature: (D)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_Math_tan(JNIEnv *env, jclass clazz, jdouble a) +{ + return tan(a); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "ceil", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_ceil }, + { (char*) "cos", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_cos }, + { (char*) "floor", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_floor }, + { (char*) "sin", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sin }, + { (char*) "sqrt", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_sqrt }, + { (char*) "tan", (char*) "(D)D", (void*) (uintptr_t) &Java_java_lang_Math_tan }, +}; + + +/* _Jv_java_lang_Math_init ***************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Math_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Math"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Object.c b/src/native/vm/cldc1.1/java_lang_Object.c deleted file mode 100644 index 26808ea6e..000000000 --- a/src/native/vm/cldc1.1/java_lang_Object.c +++ /dev/null @@ -1,172 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Object.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_String.h" /* required by j.l.C */ -#include "native/include/java_lang_Class.h" - -#include "native/include/java_lang_Object.h" - -#include "threads/lock-common.h" - -#include "vm/exceptions.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getClass", "()Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_Object_getClass }, - { "hashCode", "()I", (void *) (ptrint) &Java_java_lang_Object_hashCode }, - { "notify", "()V", (void *) (ptrint) &Java_java_lang_Object_notify }, - { "notifyAll", "()V", (void *) (ptrint) &Java_java_lang_Object_notifyAll }, - { "wait", "(J)V", (void *) (ptrint) &Java_java_lang_Object_wait }, -}; - - -/* _Jv_java_lang_Object_init *************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Object_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Object"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Object - * Method: getClass - * Signature: ()Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj) -{ - classinfo *c; - - if (obj == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - LLNI_class_get(obj, c); - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: java/lang/Object - * Method: hashCode - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, java_lang_Object *this) -{ -#if defined(ENABLE_GC_CACAO) - assert(0); -#else - return (int32_t) ((intptr_t) this); -#endif -} - - -/* - * Class: java/lang/Object - * Method: notify - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, java_lang_Object *this) -{ -#if defined(ENABLE_THREADS) - lock_notify_object((java_handle_t *) this); -#endif -} - - -/* - * Class: java/lang/Object - * Method: notifyAll - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, java_lang_Object *this) -{ -#if defined(ENABLE_THREADS) - lock_notify_all_object((java_handle_t *) this); -#endif -} - - -/* - * Class: java/lang/Object - * Method: wait - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, java_lang_Object *this, s8 timeout) -{ -#if defined(ENABLE_JVMTI) - /* Monitor Wait */ - if (jvmti) jvmti_MonitorWaiting(true, this, timeout); -#endif - -#if defined(ENABLE_THREADS) - lock_wait_for_object((java_handle_t *) this, timeout, 0); -#endif - -#if defined(ENABLE_JVMTI) - /* Monitor Waited */ - /* XXX: How do you know if wait timed out ?*/ - if (jvmti) jvmti_MonitorWaiting(false, this, 0); -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Object.cpp b/src/native/vm/cldc1.1/java_lang_Object.cpp new file mode 100644 index 000000000..2f934c6a4 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Object.cpp @@ -0,0 +1,173 @@ +/* src/native/vm/cldc1.1/java_lang_Object.c + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Object.h" +#endif + +#include "threads/lock-common.h" + +#include "vm/exceptions.hpp" +#include "vm/javaobjects.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Object + * Method: getClass + * Signature: ()Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_Object_getClass(JNIEnv *env, jobject obj) +{ + if (obj == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + java_lang_Object o(obj); + + return (jclass) LLNI_classinfo_wrap(o.get_Class()); +} + + +/* + * Class: java/lang/Object + * Method: hashCode + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, jobject _this) +{ + java_lang_Object o(_this); + + return o.get_hashcode(); +} + + +/* + * Class: java/lang/Object + * Method: notify + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + lock_notify_object((java_handle_t *) _this); +#endif +} + + +/* + * Class: java/lang/Object + * Method: notifyAll + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + lock_notify_all_object((java_handle_t *) _this); +#endif +} + + +/* + * Class: java/lang/Object + * Method: wait + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, jobject _this, jlong timeout) +{ +#if defined(ENABLE_JVMTI) + /* Monitor Wait */ + if (jvmti) jvmti_MonitorWaiting(true, _this, timeout); +#endif + +#if defined(ENABLE_THREADS) + lock_wait_for_object((java_handle_t *) _this, timeout, 0); +#endif + +#if defined(ENABLE_JVMTI) + /* Monitor Waited */ + /* XXX: How do you know if wait timed out ?*/ + if (jvmti) jvmti_MonitorWaiting(false, _this, 0); +#endif +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_Object_getClass }, + { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Object_hashCode }, + { (char*) "notify", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notify }, + { (char*) "notifyAll", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Object_notifyAll }, + { (char*) "wait", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Object_wait }, +}; + + +/* _Jv_java_lang_Object_init *************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Object_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Object"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Runtime.c b/src/native/vm/cldc1.1/java_lang_Runtime.c deleted file mode 100644 index 838c68343..000000000 --- a/src/native/vm/cldc1.1/java_lang_Runtime.c +++ /dev/null @@ -1,124 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Runtime.c - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "mm/gc-common.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Runtime.h" - -#include "vm/vm.h" - -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "exitInternal", "(I)V", (void *) (intptr_t) &Java_java_lang_Runtime_exitInternal }, - { "freeMemory", "()J", (void *) (intptr_t) &Java_java_lang_Runtime_freeMemory }, - { "totalMemory", "()J", (void *) (intptr_t) &Java_java_lang_Runtime_totalMemory }, - { "gc", "()V", (void *) (intptr_t) &Java_java_lang_Runtime_gc }, -}; - - -/* _Jv_java_lang_Runtime_init ************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Runtime_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Runtime"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Runtime - * Method: exitInternal - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal(JNIEnv *env, java_lang_Runtime *this, int32_t status) -{ - vm_shutdown(status); -} - - -/* - * Class: java/lang/Runtime - * Method: freeMemory - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_java_lang_Runtime_freeMemory(JNIEnv *env, java_lang_Runtime *this) -{ - return gc_get_free_bytes(); -} - - -/* - * Class: java/lang/Runtime - * Method: totalMemory - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_java_lang_Runtime_totalMemory(JNIEnv *env, java_lang_Runtime *this) -{ - return gc_get_heap_size(); -} - - -/* - * Class: java/lang/Runtime - * Method: gc - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(JNIEnv *env, java_lang_Runtime *this) -{ - gc_call(); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Runtime.cpp b/src/native/vm/cldc1.1/java_lang_Runtime.cpp new file mode 100644 index 000000000..62c6c48fb --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Runtime.cpp @@ -0,0 +1,133 @@ +/* src/native/vm/cldc1.1/java_lang_Runtime.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "mm/gc.hpp" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Runtime.h" +#endif + +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Runtime + * Method: exitInternal + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_java_lang_Runtime_exitInternal(JNIEnv *env, jobject _this, jint status) +{ + vm_shutdown(status); +} + + +/* + * Class: java/lang/Runtime + * Method: freeMemory + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_java_lang_Runtime_freeMemory(JNIEnv *env, jobject _this) +{ + return gc_get_free_bytes(); +} + + +/* + * Class: java/lang/Runtime + * Method: totalMemory + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_java_lang_Runtime_totalMemory(JNIEnv *env, jobject _this) +{ + return gc_get_heap_size(); +} + + +/* + * Class: java/lang/Runtime + * Method: gc + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Runtime_gc(JNIEnv *env, jobject _this) +{ + gc_call(); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "exitInternal", (char*) "(I)V", (void*) (uintptr_t) &Java_java_lang_Runtime_exitInternal }, + { (char*) "freeMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_Runtime_freeMemory }, + { (char*) "totalMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_Runtime_totalMemory }, + { (char*) "gc", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Runtime_gc }, +}; + + +/* _Jv_java_lang_Runtime_init ************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Runtime_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Runtime"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/java_lang_String.c b/src/native/vm/cldc1.1/java_lang_String.c deleted file mode 100644 index c0ba6ad57..000000000 --- a/src/native/vm/cldc1.1/java_lang_String.c +++ /dev/null @@ -1,286 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_String.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" - -#include "native/include/java_lang_String.h" - -#include "vm/stringlocal.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "hashCode", "()I", (void *) (ptrint) &Java_java_lang_String_hashCode }, - { "indexOf", "(I)I", (void *) (ptrint) &Java_java_lang_String_indexOf__I }, - { "indexOf", "(II)I", (void *) (ptrint) &Java_java_lang_String_indexOf__II }, - { "lastIndexOf", "(I)I", (void *) (ptrint) &Java_java_lang_String_lastIndexOf__I }, - { "lastIndexOf", "(II)I", (void *) (ptrint) &Java_java_lang_String_lastIndexOf__II }, -#if 0 - { "equals", "(Ljava/lang/Object;)Z;", (void *) (ptrint) &Java_java_lang_String_equals }, -#endif - { "intern", "()Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_String_intern }, -}; - - -/* _Jv_java_lang_String_init *************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_String_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/String"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/String - * Method: hashCode - * Signature: ()I - */ -JNIEXPORT s4 JNICALL Java_java_lang_String_hashCode(JNIEnv *env, java_lang_String *this) -{ - java_handle_chararray_t *value; - int32_t offset; - int32_t count; - s4 hash; - s4 i; - - /* get values from Java object */ - - LLNI_field_get_val(this, offset, offset); - LLNI_field_get_val(this, count, count); - LLNI_field_get_ref(this, value, value); - - hash = 0; - - for (i = 0; i < count; i++) { - hash = (31 * hash) + LLNI_array_direct(value, offset + i); - } - - return hash; -} - - -/* - * Class: java/lang/String - * Method: indexOf - * Signature: (I)I - */ -JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, java_lang_String *this, s4 ch) -{ - java_handle_chararray_t *value; - int32_t offset; - int32_t count; - s4 i; - - /* get values from Java object */ - - LLNI_field_get_val(this, offset, offset); - LLNI_field_get_val(this, count, count); - LLNI_field_get_ref(this, value, value); - - for (i = 0; i < count; i++) { - if (LLNI_array_direct(value, offset + i) == ch) { - return i; - } - } - - return -1; -} - - -/* - * Class: java/lang/String - * Method: indexOf - * Signature: (II)I - */ -JNIEXPORT s4 JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, java_lang_String *this, s4 ch, s4 fromIndex) -{ - java_handle_chararray_t *value; - int32_t offset; - int32_t count; - s4 i; - - /* get values from Java object */ - - LLNI_field_get_val(this, offset, offset); - LLNI_field_get_val(this, count, count); - LLNI_field_get_ref(this, value, value); - - if (fromIndex < 0) { - fromIndex = 0; - } - else if (fromIndex >= count) { - /* Note: fromIndex might be near -1>>>1. */ - return -1; - } - - for (i = fromIndex ; i < count ; i++) { - if (LLNI_array_direct(value, offset + i) == ch) { - return i; - } - } - - return -1; -} - - -/* - * Class: java/lang/String - * Method: lastIndexOf - * Signature: (I)I - */ -JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, java_lang_String *this, s4 ch) -{ - int32_t count; - - LLNI_field_get_val(this, count, count); - - return Java_java_lang_String_lastIndexOf__II(env, this, ch, count - 1); -} - - -/* - * Class: java/lang/String - * Method: lastIndexOf - * Signature: (II)I - */ -JNIEXPORT s4 JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, java_lang_String *this, s4 ch, s4 fromIndex) -{ - java_handle_chararray_t *value; - int32_t offset; - int32_t count; - s4 start; - s4 i; - - /* get values from Java object */ - - LLNI_field_get_val(this, offset, offset); - LLNI_field_get_val(this, count, count); - LLNI_field_get_ref(this, value, value); - - start = ((fromIndex >= count) ? count - 1 : fromIndex); - - for (i = start; i >= 0; i--) { - if (LLNI_array_direct(value, offset + i) == ch) { - return i; - } - } - - return -1; -} - - -#if 0 -/* - * Class: java/lang/String - * Method: equals - * Signature: (Ljava/lang/Object;)Z; - */ -JNIEXPORT s4 JNICALL Java_java_lang_String_equals(JNIEnv *env, java_lang_String* this, java_lang_Object *o) -{ - java_lang_String* s; - java_handle_chararray_t *value; - int32_t offset; - int32_t count; - java_handle_chararray_t *dvalue; - int32_t doffset; - int32_t dcount; - classinfo *c; - - LLNI_field_get_val(this, offset, offset); - LLNI_field_get_val(this, count, count); - LLNI_field_get_ref(this, value, value); - LLNI_class_get(o, c); - - /* TODO: is this the correct implementation for short-circuiting on object identity? */ - if ((java_lang_Object*)this == o) - return 1; - - if (c != class_java_lang_String) - return 0; - - s = (java_lang_String *) o; - LLNI_field_get_val(this, offset, doffset); - LLNI_field_get_val(this, count, dcount); - LLNI_field_get_ref(this, value, dvalue); - - if (count != dcount) - return 0; - - return ( 0 == memcmp((void*)(LLNI_array_direct(value, offset)), - (void*)(LLNI_array_direct(dvalue, doffset), - count) ); - -} -#endif - - -/* - * Class: java/lang/String - * Method: intern - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_String_intern(JNIEnv *env, java_lang_String *this) -{ - if (this == NULL) - return NULL; - - return (java_lang_String *) javastring_intern((java_handle_t *) this); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/cldc1.1/java_lang_String.cpp b/src/native/vm/cldc1.1/java_lang_String.cpp new file mode 100644 index 000000000..921ae0d70 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_String.cpp @@ -0,0 +1,225 @@ +/* src/native/vm/cldc1.1/java_lang_String.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_String.h" +#endif + +#include "vm/javaobjects.hpp" +#include "vm/string.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/String + * Method: hashCode + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_String_hashCode(JNIEnv *env, jstring _this) +{ + java_lang_String jls(_this); + + java_handle_chararray_t* value = jls.get_value(); + int32_t offset = jls.get_offset(); + int32_t count = jls.get_count(); + + int32_t hash = 0; + + for (int32_t i = 0; i < count; i++) { + hash = (31 * hash) + LLNI_array_direct(value, offset + i); + } + + return hash; +} + + +/* + * Class: java/lang/String + * Method: indexOf + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_java_lang_String_indexOf__I(JNIEnv *env, jstring _this, jint ch) +{ + java_lang_String jls(_this); + + java_handle_chararray_t* value = jls.get_value(); + int32_t offset = jls.get_offset(); + int32_t count = jls.get_count(); + + for (int32_t i = 0; i < count; i++) { + if (LLNI_array_direct(value, offset + i) == ch) { + return i; + } + } + + return -1; +} + + +/* + * Class: java/lang/String + * Method: indexOf + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_java_lang_String_indexOf__II(JNIEnv *env, jstring _this, jint ch, jint fromIndex) +{ + java_lang_String jls(_this); + + java_handle_chararray_t* value = jls.get_value(); + int32_t offset = jls.get_offset(); + int32_t count = jls.get_count(); + + if (fromIndex < 0) { + fromIndex = 0; + } + else if (fromIndex >= count) { + // Note: fromIndex might be near -1>>>1. + return -1; + } + + for (int32_t i = fromIndex ; i < count ; i++) { + if (LLNI_array_direct(value, offset + i) == ch) { + return i; + } + } + + return -1; +} + + +/* + * Class: java/lang/String + * Method: lastIndexOf + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_java_lang_String_lastIndexOf__II(JNIEnv *env, jstring _this, jint ch, jint fromIndex) +{ + java_lang_String jls(_this); + + java_handle_chararray_t* value = jls.get_value(); + int32_t offset = jls.get_offset(); + int32_t count = jls.get_count(); + + int32_t start = ((fromIndex >= count) ? count - 1 : fromIndex); + + for (int32_t i = start; i >= 0; i--) { + if (LLNI_array_direct(value, offset + i) == ch) { + return i; + } + } + + return -1; +} + + +/* + * Class: java/lang/String + * Method: lastIndexOf + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_java_lang_String_lastIndexOf__I(JNIEnv *env, jstring _this, jint ch) +{ + java_lang_String jls(_this); + + return Java_java_lang_String_lastIndexOf__II(env, _this, ch, jls.get_count() - 1); +} + + +/* + * Class: java/lang/String + * Method: intern + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_String_intern(JNIEnv *env, jstring _this) +{ + java_lang_String jls(_this); + + if (jls.is_null()) + return NULL; + + return (jstring) javastring_intern(jls.get_handle()); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "hashCode", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_String_hashCode }, + { (char*) "indexOf", (char*) "(I)I", (void*) (uintptr_t) &Java_java_lang_String_indexOf__I }, + { (char*) "indexOf", (char*) "(II)I", (void*) (uintptr_t) &Java_java_lang_String_indexOf__II }, + { (char*) "lastIndexOf", (char*) "(II)I", (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__II }, + { (char*) "lastIndexOf", (char*) "(I)I", (void*) (uintptr_t) &Java_java_lang_String_lastIndexOf__I }, +#if 0 + { (char*) "equals", (char*) "(Ljava/lang/Object;)Z;", (void*) (uintptr_t) &Java_java_lang_String_equals }, +#endif + { (char*) "intern", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_String_intern }, +}; + + +/* _Jv_java_lang_String_init *************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_String_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/String"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/cldc1.1/java_lang_System.c b/src/native/vm/cldc1.1/java_lang_System.c deleted file mode 100644 index 7a14f9e52..000000000 --- a/src/native/vm/cldc1.1/java_lang_System.c +++ /dev/null @@ -1,132 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_System.c - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" - -#include "native/include/java_lang_System.h" - -#include "vm/builtin.h" -#include "vm/properties.h" -#include "vm/stringlocal.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void *) (ptrint) &Java_java_lang_System_arraycopy }, - { "getProperty0", "(Ljava/lang/String;)Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_System_getProperty0 }, -}; - - -/* _Jv_java_lang_System_init *************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_System_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/System"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/System - * Method: arraycopy - * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V - */ -JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, s4 srcStart, java_lang_Object *dest, s4 destStart, s4 len) -{ - builtin_arraycopy((java_handle_t *) src, srcStart, - (java_handle_t *) dest, destStart, len); -} - - -/* - * Class: java/lang/System - * Method: getProperty0 - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ - -JNIEXPORT java_lang_String* JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, java_lang_String *s) -{ - java_handle_t *so; - char* key; - char* value; - java_handle_t *result; - - so = (java_handle_t *) s; - - /* build an ASCII string out of the java/lang/String passed */ - - key = javastring_tochar(so); - - /* get the property from the internal table */ - - value = properties_get(key); - - /* release the memory allocated in javastring_tochar */ - - MFREE(key, char, 0); - - if (value == NULL) - return NULL; - - result = javastring_new_from_ascii(value); - - return (java_lang_String *) result; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/cldc1.1/java_lang_System.cpp b/src/native/vm/cldc1.1/java_lang_System.cpp new file mode 100644 index 000000000..ec1ce50c7 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_System.cpp @@ -0,0 +1,137 @@ +/* src/native/vm/cldc1.1/java_lang_System.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_System.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/properties.hpp" +#include "vm/string.hpp" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/System + * Method: arraycopy + * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V + */ +JNIEXPORT void JNICALL Java_java_lang_System_arraycopy(JNIEnv *env, jclass clazz, jobject src, jint srcStart, jobject dest, jint destStart, jint len) +{ + builtin_arraycopy((java_handle_t *) src, srcStart, + (java_handle_t *) dest, destStart, len); +} + + +/* + * Class: java/lang/System + * Method: getProperty0 + * Signature: (Ljava/lang/String;)Ljava/lang/String; + */ + +JNIEXPORT jstring JNICALL Java_java_lang_System_getProperty0(JNIEnv *env, jclass clazz, jstring s) +{ + java_handle_t *so; + char* key; + const char* value; + java_handle_t *result; + + so = (java_handle_t *) s; + + /* build an ASCII string out of the java/lang/String passed */ + + key = javastring_tochar(so); + + /* get the property from the internal table */ + + value = VM::get_current()->get_properties().get(key); + + /* release the memory allocated in javastring_tochar */ + + MFREE(key, char, 0); + + if (value == NULL) + return NULL; + + result = javastring_new_from_ascii(value); + + return (jstring) result; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "arraycopy", (char*) "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void*) (uintptr_t) &Java_java_lang_System_arraycopy }, + { (char*) "getProperty0", (char*) "(Ljava/lang/String;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_System_getProperty0 }, +}; + + +/* _Jv_java_lang_System_init *************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_System_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/System"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Thread.c b/src/native/vm/cldc1.1/java_lang_Thread.c deleted file mode 100644 index da9ffd01a..000000000 --- a/src/native/vm/cldc1.1/java_lang_Thread.c +++ /dev/null @@ -1,236 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Thread.c - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Thread.h" - -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/builtin.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "currentThread", "()Ljava/lang/Thread;", (void *) (ptrint) &Java_java_lang_Thread_currentThread }, - { "setPriority0", "(II)V", (void *) (ptrint) &Java_java_lang_Thread_setPriority0 }, - { "sleep", "(J)V", (void *) (ptrint) &Java_java_lang_Thread_sleep }, - { "start0", "()V", (void *) (ptrint) &Java_java_lang_Thread_start0 }, - { "isAlive", "()Z", (void *) (ptrint) &Java_java_lang_Thread_isAlive }, -#if 0 - { "activeCount", "()I", (void *) (ptrint) &Java_java_lang_Thread_activeCount }, - { "setPriority0", "(II)V", (void *) (ptrint) &Java_java_lang_Thread_setPriority0 }, - { "interrupt0", "()V", (void *) (ptrint) &Java_java_lang_Thread_interrupt0 }, - { "internalExit", "()V", (void *) (ptrint) &Java_java_lang_Thread_internalExit }, -#endif - { "yield", "()V", (void *) (ptrint) &Java_java_lang_Thread_yield }, -}; - - -/* _Jv_java_lang_Thread_init *************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Thread_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Thread"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Thread - * Method: currentThread - * Signature: ()Ljava/lang/Thread; - */ -JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz) -{ - java_lang_Thread *to; - - to = (java_lang_Thread *) thread_get_current_object(); - - return to; -} - - -/* - * Class: java/lang/Thread - * Method: setPriority0 - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, java_lang_Thread *this, s4 oldPriority, s4 newPriority) -{ -#if defined(ENABLE_THREADS) - threadobject *t; - - t = (threadobject *) this->vm_thread; - - /* The threadobject is null when a thread is created in Java. The - priority is set later during startup. */ - - if (t == NULL) - return; - - threads_set_thread_priority(t->tid, newPriority); -#endif -} - - -/* - * Class: java/lang/Thread - * Method: sleep - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, s8 millis) -{ -#if defined(ENABLE_THREADS) - threads_sleep(millis, 0); -#endif -} - - -/* - * Class: java/lang/Thread - * Method: start0 - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, java_lang_Thread *this) -{ -#if defined(ENABLE_THREADS) - threads_thread_start((java_handle_t *) this); -#endif -} - - -/* - * Class: java/lang/Thread - * Method: isAlive - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, java_lang_Thread *this) -{ -#if defined(ENABLE_THREADS) - threadobject *t; - bool result; - - t = (threadobject *) this->vm_thread; - - if (t == NULL) - return 0; - - result = threads_thread_is_alive(t); - - return result; -#else - /* If threads are disabled, the only thread running is alive. */ - - return 1; -#endif -} - - -#if 0 -/* - * Class: java/lang/Thread - * Method: activeCount - * Signature: ()I - */ -JNIEXPORT s4 JNICALL Java_java_lang_Thread_activeCount(JNIEnv *env, jclass clazz) -{ -} - - -/* - * Class: java/lang/Thread - * Method: setPriority0 - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, struct java_lang_Thread* this, s4 par1, s4 par2) -{ -} - - -/* - * Class: java/lang/Thread - * Method: interrupt0 - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, struct java_lang_Thread* this) -{ -} - - -/* - * Class: java/lang/Thread - * Method: internalExit - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, struct java_lang_Thread* this) -{ -} -#endif - - -/* - * Class: java/lang/Thread - * Method: yield - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz) -{ -#if defined(ENABLE_THREADS) - threads_yield(); -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Thread.cpp b/src/native/vm/cldc1.1/java_lang_Thread.cpp new file mode 100644 index 000000000..75f8f20d6 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Thread.cpp @@ -0,0 +1,227 @@ +/* src/native/vm/cldc1.1/java_lang_Thread.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Thread.h" +#endif + +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/jit/builtin.hpp" +#include "vm/javaobjects.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Thread + * Method: currentThread + * Signature: ()Ljava/lang/Thread; + */ +JNIEXPORT jobject JNICALL Java_java_lang_Thread_currentThread(JNIEnv *env, jclass clazz) +{ + return (jobject) thread_get_current_object(); +} + + +/* + * Class: java/lang/Thread + * Method: setPriority0 + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_java_lang_Thread_setPriority0(JNIEnv *env, jobject _this, jint oldPriority, jint newPriority) +{ +#if defined(ENABLE_THREADS) + java_lang_Thread jlt(_this); + threadobject* t = jlt.get_vm_thread(); + + // The threadobject is null when a thread is created in Java. The + // priority is set later during startup. + if (t == NULL) + return; + + threads_set_thread_priority(t->tid, newPriority); +#endif +} + + +/* + * Class: java/lang/Thread + * Method: sleep + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_java_lang_Thread_sleep(JNIEnv *env, jclass clazz, jlong millis) +{ +#if defined(ENABLE_THREADS) + threads_sleep(millis, 0); +#endif +} + + +/* + * Class: java/lang/Thread + * Method: start0 + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Thread_start0(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + java_lang_Thread jlt(_this); + threads_thread_start(jlt.get_handle()); +#endif +} + + +/* + * Class: java/lang/Thread + * Method: isAlive + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_Thread_isAlive(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + java_lang_Thread jlt(_this); + threadobject* t = jlt.get_vm_thread(); + + if (t == NULL) + return 0; + + bool result = threads_thread_is_alive(t); + + return result; +#else + // If threads are disabled, the only thread running is alive. + return 1; +#endif +} + + +#if 0 +/* + * Class: java/lang/Thread + * Method: activeCount + * Signature: ()I + */ +JNIEXPORT s4 JNICALL Java_java_lang_Thread_activeCount(JNIEnv *env, jclass clazz) +{ +} + + +/* + * Class: java/lang/Thread + * Method: interrupt0 + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Thread_interrupt0(JNIEnv *env, jobject _this) +{ +} + + +/* + * Class: java/lang/Thread + * Method: internalExit + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Thread_internalExit(JNIEnv *env, jobject _this) +{ +} +#endif + + +/* + * Class: java/lang/Thread + * Method: yield + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Thread_yield(JNIEnv *env, jclass clazz) +{ +#if defined(ENABLE_THREADS) + threads_yield(); +#endif +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "currentThread", (char*) "()Ljava/lang/Thread;", (void*) (uintptr_t) &Java_java_lang_Thread_currentThread }, + { (char*) "setPriority0", (char*) "(II)V", (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0 }, + { (char*) "sleep", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_Thread_sleep }, + { (char*) "start0", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_start0 }, + { (char*) "isAlive", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_Thread_isAlive }, +#if 0 + { (char*) "activeCount", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_Thread_activeCount }, + { (char*) "setPriority0", (char*) "(II)V", (void*) (uintptr_t) &Java_java_lang_Thread_setPriority0 }, + { (char*) "interrupt0", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_interrupt0 }, + { (char*) "internalExit", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_internalExit }, +#endif + { (char*) "yield", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Thread_yield }, +}; + + +/* _Jv_java_lang_Thread_init *************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Thread_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Thread"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/cldc1.1/java_lang_Throwable.c b/src/native/vm/cldc1.1/java_lang_Throwable.c deleted file mode 100644 index 35885d135..000000000 --- a/src/native/vm/cldc1.1/java_lang_Throwable.c +++ /dev/null @@ -1,111 +0,0 @@ -/* src/native/vm/cldc1.1/java_lang_Throwable.c - java/lang/Throwable - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Throwable.h" - -#include "vm/exceptions.h" -#include "vm/jit/stacktrace.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "printStackTrace", "()V", (void *) (uintptr_t) &Java_java_lang_Throwable_printStackTrace }, - { "fillInStackTrace", "()V", (void *) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace }, -}; - - -/* _Jv_java_lang_Throwable_init ************************************************ - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_Throwable_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/Throwable"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/Throwable - * Method: printStackTrace - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, java_lang_Throwable *this) -{ - java_handle_t *o; - - o = (java_handle_t *) this; - - exceptions_print_exception(o); - stacktrace_print_exception(o); -} - - -/* - * Class: java/lang/Throwable - * Method: fillInStackTrace - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, java_lang_Throwable *this) -{ - java_handle_bytearray_t *ba; - - ba = stacktrace_get_current(); - - if (ba == NULL) - return; - - LLNI_field_set_ref(this, backtrace, (java_lang_Object *) ba); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/cldc1.1/java_lang_Throwable.cpp b/src/native/vm/cldc1.1/java_lang_Throwable.cpp new file mode 100644 index 000000000..d839f09c4 --- /dev/null +++ b/src/native/vm/cldc1.1/java_lang_Throwable.cpp @@ -0,0 +1,119 @@ +/* src/native/vm/cldc1.1/java_lang_Throwable.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_lang_Throwable.h" +#endif + +#include "vm/exceptions.hpp" +#include "vm/javaobjects.hpp" + +#include "vm/jit/stacktrace.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/Throwable + * Method: printStackTrace + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, jobject _this) +{ + java_lang_Throwable jlt(_this); + + exceptions_print_exception(jlt.get_handle()); + stacktrace_print_exception(jlt.get_handle()); +} + + +/* + * Class: java/lang/Throwable + * Method: fillInStackTrace + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject _this) +{ + java_handle_bytearray_t* ba = stacktrace_get_current(); + + if (ba == NULL) + return; + + java_lang_Throwable jlt(_this); + jlt.set_backtrace(ba); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "printStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_printStackTrace }, + { (char*) "fillInStackTrace", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_Throwable_fillInStackTrace }, +}; + + +/* _Jv_java_lang_Throwable_init ************************************************ + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_Throwable_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/Throwable"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/Makefile.am b/src/native/vm/gnuclasspath/Makefile.am index 219f88d5e..c592f3077 100644 --- a/src/native/vm/gnuclasspath/Makefile.am +++ b/src/native/vm/gnuclasspath/Makefile.am @@ -1,4 +1,4 @@ -## src/native/vm/gnu/Makefile.am +## src/native/vm/gnuclasspath/Makefile.am ## ## Copyright (C) 1996-2005, 2006, 2008 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO @@ -35,32 +35,32 @@ endif if ENABLE_ANNOTATIONS SUN_REFLECT_SOURCES = \ - sun_reflect_ConstantPool.c + sun_reflect_ConstantPool.cpp endif libnativevmcore_la_SOURCES = \ - gnu_classpath_VMStackWalker.c \ - gnu_classpath_VMSystemProperties.c \ - gnu_java_lang_VMCPStringBuilder.c \ - gnu_java_lang_management_VMClassLoadingMXBeanImpl.c \ - gnu_java_lang_management_VMMemoryMXBeanImpl.c \ - gnu_java_lang_management_VMRuntimeMXBeanImpl.c \ - gnu_java_lang_management_VMThreadMXBeanImpl.c \ - java_lang_VMClass.c \ - java_lang_VMClassLoader.c \ - java_lang_VMObject.c \ - java_lang_VMRuntime.c \ - java_lang_VMString.c \ - java_lang_VMSystem.c \ - java_lang_VMThread.c \ - java_lang_VMThrowable.c \ + gnu_classpath_VMStackWalker.cpp \ + gnu_classpath_VMSystemProperties.cpp \ + gnu_java_lang_VMCPStringBuilder.cpp \ + gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp \ + gnu_java_lang_management_VMMemoryMXBeanImpl.cpp \ + gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp \ + gnu_java_lang_management_VMThreadMXBeanImpl.cpp \ + java_lang_VMClass.cpp \ + java_lang_VMClassLoader.cpp \ + java_lang_VMObject.cpp \ + java_lang_VMRuntime.cpp \ + java_lang_VMString.cpp \ + java_lang_VMSystem.cpp \ + java_lang_VMThread.cpp \ + java_lang_VMThrowable.cpp \ java_lang_management_VMManagementFactory.c \ - java_lang_reflect_VMConstructor.c \ - java_lang_reflect_VMField.c \ - java_lang_reflect_VMMethod.c \ + java_lang_reflect_VMConstructor.cpp \ + java_lang_reflect_VMField.cpp \ + java_lang_reflect_VMMethod.cpp \ java_lang_reflect_VMProxy.c \ - java_security_VMAccessController.c \ - java_util_concurrent_atomic_AtomicLong.c \ + java_security_VMAccessController.cpp \ + java_util_concurrent_atomic_AtomicLong.cpp \ $(SUN_REFLECT_SOURCES) if ENABLE_JVMTI diff --git a/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c b/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c deleted file mode 100644 index eca8f531a..000000000 --- a/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.c +++ /dev/null @@ -1,144 +0,0 @@ -/* src/native/vm/gnu/gnu_classpath_VMStackWalker.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_ClassLoader.h" - -#include "native/include/gnu_classpath_VMStackWalker.h" - -#include "vm/global.h" - -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getClassContext", "()[Ljava/lang/Class;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getClassContext }, - { "getCallingClass", "()Ljava/lang/Class;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClass }, - { "getCallingClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader }, - { "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", (void *) (ptrint) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader }, -}; - - -/* _Jv_gnu_classpath_VMStackWalker_init **************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_classpath_VMStackWalker_init(void) -{ - utf *u; - - u = utf_new_char("gnu/classpath/VMStackWalker"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/classpath/VMStackWalker - * Method: getClassContext - * Signature: ()[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz) -{ - java_handle_objectarray_t *oa; - - oa = stacktrace_getClassContext(); - - return oa; -} - - -/* - * Class: gnu/classpath/VMStackWalker - * Method: getCallingClass - * Signature: ()Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz) -{ - classinfo *c; - - c = stacktrace_get_caller_class(2); - - return (java_lang_Class *) c; -} - - -/* - * Class: gnu/classpath/VMStackWalker - * Method: getCallingClassLoader - * Signature: ()Ljava/lang/ClassLoader; - */ -JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz) -{ - classinfo *c; - classloader_t *cl; - - c = stacktrace_get_caller_class(2); - cl = class_get_classloader(c); - - return (java_lang_ClassLoader *) cl; -} - - -/* - * Class: gnu/classpath/VMStackWalker - * Method: firstNonNullClassLoader - * Signature: ()Ljava/lang/ClassLoader; - */ -JNIEXPORT java_lang_ClassLoader* JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz) -{ - classloader_t *cl; - - cl = stacktrace_first_nonnull_classloader(); - - return (java_lang_ClassLoader *) cl; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp b/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp new file mode 100644 index 000000000..b36eaeea4 --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp @@ -0,0 +1,152 @@ +/* src/native/vm/gnuclasspath/gnu_classpath_VMStackWalker.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/gnu_classpath_VMStackWalker.h" +#endif + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/utf8.h" + +#include "vm/jit/stacktrace.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: gnu/classpath/VMStackWalker + * Method: getClassContext + * Signature: ()[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_gnu_classpath_VMStackWalker_getClassContext(JNIEnv *env, jclass clazz) +{ + java_handle_objectarray_t *oa; + + oa = stacktrace_getClassContext(); + + return (jobjectArray) oa; +} + + +/* + * Class: gnu/classpath/VMStackWalker + * Method: getCallingClass + * Signature: ()Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_gnu_classpath_VMStackWalker_getCallingClass(JNIEnv *env, jclass clazz) +{ + classinfo *c; + + c = stacktrace_get_caller_class(2); + + return (jclass) c; +} + + +/* + * Class: gnu/classpath/VMStackWalker + * Method: getCallingClassLoader + * Signature: ()Ljava/lang/ClassLoader; + */ +JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getCallingClassLoader(JNIEnv *env, jclass clazz) +{ + classinfo *c; + classloader_t *cl; + + c = stacktrace_get_caller_class(2); + cl = class_get_classloader(c); + + return (jobject) cl; +} + + +/* + * Class: gnu/classpath/VMStackWalker + * Method: firstNonNullClassLoader + * Signature: ()Ljava/lang/ClassLoader; + */ +JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader(JNIEnv *env, jclass clazz) +{ + classloader_t *cl; + + cl = stacktrace_first_nonnull_classloader(); + + return (jobject) cl; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getClassContext", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getClassContext }, + { (char*) "getCallingClass", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClass }, + { (char*) "getCallingClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_getCallingClassLoader }, + { (char*) "firstNonNullClassLoader", (char*) "()Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader }, +}; + + +/* _Jv_gnu_classpath_VMStackWalker_init **************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_classpath_VMStackWalker_init(void) +{ + utf *u; + + u = utf_new_char("gnu/classpath/VMStackWalker"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c b/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c deleted file mode 100644 index 5517c6c1a..000000000 --- a/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.c +++ /dev/null @@ -1,154 +0,0 @@ -/* src/native/vm/gnu/gnu_classpath_VMSystemProperties.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_util_Properties.h" - -#include "native/include/gnu_classpath_VMSystemProperties.h" - -#include "vm/exceptions.h" -#include "vm/properties.h" -#include "vm/vm.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "preInit", "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_preInit }, - { "postInit", "(Ljava/util/Properties;)V", (void *) (ptrint) &Java_gnu_classpath_VMSystemProperties_postInit }, -}; - - -/* _Jv_gnu_classpat_VMSystemProperties_init ************************************ - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_classpath_VMSystemProperties_init(void) -{ - utf *u; - - u = utf_new_char("gnu/classpath/VMSystemProperties"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/classpath/VMSystemProperties - * Method: preInit - * Signature: (Ljava/util/Properties;)V - */ -JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, java_util_Properties *properties) -{ - java_handle_t *p; - - p = (java_handle_t *) properties; - - if (p == NULL) { - exceptions_throw_nullpointerexception(); - return; - } - - /* fill the java.util.Properties object */ - - properties_system_add_all(p); -} - - -/* - * Class: gnu/classpath/VMSystemProperties - * Method: postInit - * Signature: (Ljava/util/Properties;)V - */ -JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, java_util_Properties *properties) -{ - java_handle_t *p; -#if defined(ENABLE_JRE_LAYOUT) - char *java_home; - char *path; - s4 len; -#endif - - p = (java_handle_t *) properties; - - if (p == NULL) { - exceptions_throw_nullpointerexception(); - return; - } - - /* post-set some properties */ - -#if defined(ENABLE_JRE_LAYOUT) - /* XXX when we do it that way, we can't set these properties on - commandline */ - - java_home = properties_get("java.home"); - - properties_system_add(p, "gnu.classpath.home", java_home); - - len = - strlen("file://") + - strlen(java_home) + - strlen("/lib") + - strlen("0"); - - path = MNEW(char, len); - - strcpy(path, "file://"); - strcat(path, java_home); - strcat(path, "/lib"); - - properties_system_add(p, "gnu.classpath.home.url", path); - - MFREE(path, char, len); -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp b/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp new file mode 100644 index 000000000..76e766592 --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp @@ -0,0 +1,161 @@ +/* src/native/vm/gnuclasspath/gnu_classpath_VMSystemProperties.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/gnu_classpath_VMSystemProperties.h" +#endif + +#include "vm/exceptions.hpp" +#include "vm/properties.hpp" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: gnu/classpath/VMSystemProperties + * Method: preInit + * Signature: (Ljava/util/Properties;)V + */ +JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_preInit(JNIEnv *env, jclass clazz, jobject properties) +{ + java_handle_t *p; + + p = (java_handle_t *) properties; + + if (p == NULL) { + exceptions_throw_nullpointerexception(); + return; + } + + // Fill the java.util.Properties object. + VM::get_current()->get_properties().fill(p); +} + + +/* + * Class: gnu/classpath/VMSystemProperties + * Method: postInit + * Signature: (Ljava/util/Properties;)V + */ +JNIEXPORT void JNICALL Java_gnu_classpath_VMSystemProperties_postInit(JNIEnv *env, jclass clazz, jobject properties) +{ + java_handle_t *p; +#if defined(ENABLE_JRE_LAYOUT) + const char *java_home; + char *path; + s4 len; +#endif + + p = (java_handle_t *) properties; + + if (p == NULL) { + exceptions_throw_nullpointerexception(); + return; + } + + /* post-set some properties */ + +#if defined(ENABLE_JRE_LAYOUT) + /* XXX when we do it that way, we can't set these properties on + commandline */ + + java_home = VM::get_current()->get_properties().get("java.home"); + + Properties::put(p, "gnu.classpath.home", java_home); + + len = + strlen("file://") + + strlen(java_home) + + strlen("/lib") + + strlen("0"); + + path = MNEW(char, len); + + strcpy(path, "file://"); + strcat(path, java_home); + strcat(path, "/lib"); + + Properties::put(p, "gnu.classpath.home.url", path); + + MFREE(path, char, len); +#endif +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "preInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_preInit }, + { (char*) "postInit", (char*) "(Ljava/util/Properties;)V", (void*) (uintptr_t) &Java_gnu_classpath_VMSystemProperties_postInit }, +}; + + +/* _Jv_gnu_classpat_VMSystemProperties_init ************************************ + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_classpath_VMSystemProperties_init(void) +{ + utf *u; + + u = utf_new_char("gnu/classpath/VMSystemProperties"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c index e647e4d94..9276ebb8f 100644 --- a/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c +++ b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMFrame.c @@ -27,7 +27,7 @@ #include -#include "native/jni.h" +#include "native/jni.hpp" #include "native/include/java_lang_Object.h" #include "native/include/gnu_classpath_jdwp_VMFrame.h" diff --git a/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c index 54ff53478..dec603501 100644 --- a/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c +++ b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMMethod.c @@ -27,7 +27,7 @@ #include -#include "native/jni.h" +#include "native/jni.hpp" #include "native/include/gnu_classpath_jdwp_VMMethod.h" diff --git a/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c index 9e06a6b57..eaf47e630 100644 --- a/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c +++ b/src/native/vm/gnuclasspath/gnu_classpath_jdwp_VMVirtualMachine.c @@ -29,7 +29,7 @@ #include #include "toolbox/logging.h" -#include "native/jni.h" +#include "native/jni.hpp" #include "native/include/java_lang_Thread.h" #include "native/include/java_nio_ByteBuffer.h" #include "native/include/java_lang_Class.h" diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c b/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c deleted file mode 100644 index 0511085db..000000000 --- a/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.c +++ /dev/null @@ -1,129 +0,0 @@ -/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_String.h" - -#include "native/include/gnu_java_lang_VMCPStringBuilder.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "toString", "([CII)Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString }, -}; - - -/* _Jv_gnu_java_lang_VMCPStringBuilder ***************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_java_lang_VMCPStringBuilder_init(void) -{ - utf *u; - - u = utf_new_char("gnu/java/lang/VMCPStringBuilder"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/java/lang/VMCPStringBuilder - * Method: toString - * Signature: ([CII)Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, java_handle_chararray_t *value, int32_t startIndex, int32_t count) -{ - int32_t length; - java_handle_t *o; - java_lang_String *s; - - /* This is a native version of - java.lang.String.([CIIZ)Ljava/lang/String; */ - - if (startIndex < 0) { -/* exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */ - exceptions_throw_stringindexoutofboundsexception(); - return NULL; - } - - if (count < 0) { -/* exceptions_throw_stringindexoutofboundsexception("count: " + count); */ - exceptions_throw_stringindexoutofboundsexception(); - return NULL; - } - - /* equivalent to: offset + count < 0 || offset + count > data.length */ - - LLNI_CRITICAL_START; - length = LLNI_array_size(value); - LLNI_CRITICAL_END; - - if (length - startIndex < count) { -/* exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */ - exceptions_throw_stringindexoutofboundsexception(); - return NULL; - } - - o = builtin_new(class_java_lang_String); - - if (o == NULL) - return NULL; - - s = (java_lang_String *) o; - - LLNI_field_set_ref(s, value, value); - LLNI_field_set_val(s, count, count); - LLNI_field_set_val(s, offset, startIndex); - - return s; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp new file mode 100644 index 000000000..de6aa0e6d --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp @@ -0,0 +1,128 @@ +/* src/native/vm/gnuclasspath/gnu_java_lang_VMCPStringBuilder.cpp + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/gnu_java_lang_VMCPStringBuilder.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" + + +/* + * Class: gnu/java/lang/VMCPStringBuilder + * Method: toString + * Signature: ([CII)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_gnu_java_lang_VMCPStringBuilder_toString(JNIEnv *env, jclass clazz, jcharArray value, jint startIndex, jint count) +{ + /* This is a native version of + java.lang.String.([CIIZ)Ljava/lang/String; */ + + if (startIndex < 0) { +/* exceptions_throw_stringindexoutofboundsexception("offset: " + offset); */ + exceptions_throw_stringindexoutofboundsexception(); + return NULL; + } + + if (count < 0) { +/* exceptions_throw_stringindexoutofboundsexception("count: " + count); */ + exceptions_throw_stringindexoutofboundsexception(); + return NULL; + } + + /* equivalent to: offset + count < 0 || offset + count > data.length */ + + java_handle_chararray_t* ca = (java_handle_chararray_t*) value; + + LLNI_CRITICAL_START; + int32_t length = LLNI_array_size(ca); + LLNI_CRITICAL_END; + + if (length - startIndex < count) { +/* exceptions_throw_stringindexoutofboundsexception("offset + count: " + (offset + count)); */ + exceptions_throw_stringindexoutofboundsexception(); + return NULL; + } + + java_handle_t* h = builtin_new(class_java_lang_String); + + if (h == NULL) + return NULL; + + java_lang_String s(h, ca, (int32_t) count, (int32_t) startIndex); + + return (jstring) s.get_handle(); +} + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "toString", (char*) "([CII)Ljava/lang/String;", (void*) (uintptr_t) &Java_gnu_java_lang_VMCPStringBuilder_toString }, +}; + + +/* _Jv_gnu_java_lang_VMCPStringBuilder ***************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_java_lang_VMCPStringBuilder_init(void) +{ + utf *u; + + u = utf_new_char("gnu/java/lang/VMCPStringBuilder"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c deleted file mode 100644 index ce3b6b4ef..000000000 --- a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c +++ /dev/null @@ -1,135 +0,0 @@ -/* src/native/vm/gnu/gnu_java_lang_management_VMClassLoadingMXBeanImpl.c - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "mm/gc-common.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h" - -#include "toolbox/logging.h" - -#include "vm/vm.h" - -#include "vmcore/classcache.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getLoadedClassCount", "()I", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount }, - { "getUnloadedClassCount", "()J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount }, - { "isVerbose", "()Z", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose }, - { "setVerbose", "(Z)V", (void *) (intptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose }, -}; - - -/* _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init ****************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init(void) -{ - utf *u; - - u = utf_new_char("gnu/java/lang/management/VMClassLoadingMXBeanImpl"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl - * Method: getLoadedClassCount - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz) -{ - int32_t count; - - count = classcache_get_loaded_class_count(); - - return count; -} - - -/* - * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl - * Method: getUnloadedClassCount - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl - * Method: isVerbose - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz) -{ - return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose; -} - - -/* - * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl - * Method: setVerbose - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose) -{ - _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp new file mode 100644 index 000000000..d13cc78d9 --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp @@ -0,0 +1,147 @@ +/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMClassLoadingMXBeanImpl.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "mm/gc.hpp" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h" +#endif + +#include "toolbox/logging.h" + +#include "vm/classcache.h" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl + * Method: getLoadedClassCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount(JNIEnv *env, jclass clazz) +{ + int32_t count; + + count = classcache_get_loaded_class_count(); + + return count; +} + + +/* + * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl + * Method: getUnloadedClassCount + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount: IMPLEMENT ME!"); + + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl + * Method: isVerbose + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz) +{ +/* return _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose: MOVE TO C++!"); + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMClassLoadingMXBeanImpl + * Method: setVerbose + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose) +{ +/* _Jv_jvm->Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_verbose = verbose; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose: MOVE TO C++!"); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getLoadedClassCount", (char*) "()I", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount }, + { (char*) "getUnloadedClassCount", (char*) "()J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount }, + { (char*) "isVerbose", (char*) "()Z", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose }, + { (char*) "setVerbose", (char*) "(Z)V", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose }, +}; + + +/* _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init ****************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_java_lang_management_VMClassLoadingMXBeanImpl_init(void) +{ + utf *u; + + u = utf_new_char("gnu/java/lang/management/VMClassLoadingMXBeanImpl"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c deleted file mode 100644 index 4c05838d9..000000000 --- a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.c +++ /dev/null @@ -1,194 +0,0 @@ -/* src/native/vm/gnu/gnu_java_lang_management_VMMemoryMXBeanImpl.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "mm/gc-common.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_management_MemoryUsage.h" - -#include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h" - -#include "vm/builtin.h" -#include "vm/global.h" -#include "vm/vm.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" /* XXX only for load_class_bootstrap */ -#include "vmcore/options.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getHeapMemoryUsage", "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage }, - { "getNonHeapMemoryUsage", "()Ljava/lang/management/MemoryUsage;", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage }, - { "getObjectPendingFinalizationCount", "()I", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount }, - { "isVerbose", "()Z", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose }, - { "setVerbose", "(Z)V", (void *) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose }, -}; - - -/* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************ - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void) -{ - utf *u; - - u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/java/lang/management/VMMemoryMXBeanImpl - * Method: getHeapMemoryUsage - * Signature: ()Ljava/lang/management/MemoryUsage; - */ -JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz) -{ - classinfo *class_java_lang_management_MemoryUsage; - java_handle_t *o; - java_lang_management_MemoryUsage *mu; - methodinfo *m; - int64_t init; - int64_t used; - int64_t commited; - int64_t maximum; - - /* get the class */ - /* XXX optimize me! sometime... */ - - if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage")))) - return false; - - /* create the object */ - - o = builtin_new(class_java_lang_management_MemoryUsage); - - if (o == NULL) - return NULL; - - /* cast the object to a MemoryUsage object (for debugability) */ - - mu = (java_lang_management_MemoryUsage *) o; - - /* find initializer */ - - m = class_findmethod(class_java_lang_management_MemoryUsage, - utf_init, utf_new_char("(JJJJ)V")); - - /* initializer not found */ - - if (m == NULL) - return NULL; - - /* get values from the VM */ - /* XXX if we ever support more than one VM, change this */ - - init = opt_heapstartsize; - used = gc_get_total_bytes(); - commited = gc_get_heap_size(); - maximum = gc_get_max_heap_size(); - - /* call initializer */ - - (void) vm_call_method(m, o, init, used, commited, maximum); - - return mu; -} - - -/* - * Class: gnu/java/lang/management/VMMemoryMXBeanImpl - * Method: getNonHeapMemoryUsage - * Signature: ()Ljava/lang/management/MemoryUsage; - */ -JNIEXPORT java_lang_management_MemoryUsage* JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!"); - - return NULL; -} - - -/* - * Class: gnu/java/lang/management/VMMemoryMXBeanImpl - * Method: getObjectPendingFinalizationCount - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: gnu/java/lang/management/VMMemoryMXBeanImpl - * Method: isVerbose - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz) -{ - return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose; -} - - -/* - * Class: gnu/java/lang/management/VMMemoryMXBeanImpl - * Method: setVerbose - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, int32_t verbose) -{ - _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp new file mode 100644 index 000000000..30e576a69 --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp @@ -0,0 +1,201 @@ +/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMMemoryMXBeanImpl.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "mm/gc.hpp" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/global.h" +#include "vm/loader.hpp" /* XXX only for load_class_bootstrap */ +#include "vm/options.h" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: gnu/java/lang/management/VMMemoryMXBeanImpl + * Method: getHeapMemoryUsage + * Signature: ()Ljava/lang/management/MemoryUsage; + */ +JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage(JNIEnv *env, jclass clazz) +{ + classinfo *class_java_lang_management_MemoryUsage; + java_handle_t *o; + methodinfo *m; + int64_t init; + int64_t used; + int64_t commited; + int64_t maximum; + + /* get the class */ + /* XXX optimize me! sometime... */ + + if (!(class_java_lang_management_MemoryUsage = load_class_bootstrap(utf_new_char("java/lang/management/MemoryUsage")))) + return false; + + /* create the object */ + + o = builtin_new(class_java_lang_management_MemoryUsage); + + if (o == NULL) + return NULL; + + /* find initializer */ + + m = class_findmethod(class_java_lang_management_MemoryUsage, + utf_init, utf_new_char("(JJJJ)V")); + + /* initializer not found */ + + if (m == NULL) + return NULL; + + /* get values from the VM */ + /* XXX if we ever support more than one VM, change this */ + + init = opt_heapstartsize; + used = gc_get_total_bytes(); + commited = gc_get_heap_size(); + maximum = gc_get_max_heap_size(); + + /* call initializer */ + + (void) vm_call_method(m, o, init, used, commited, maximum); + + return (jobject) o; +} + + +/* + * Class: gnu/java/lang/management/VMMemoryMXBeanImpl + * Method: getNonHeapMemoryUsage + * Signature: ()Ljava/lang/management/MemoryUsage; + */ +JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage: IMPLEMENT ME!"); + + return NULL; +} + + +/* + * Class: gnu/java/lang/management/VMMemoryMXBeanImpl + * Method: getObjectPendingFinalizationCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount: IMPLEMENT ME!"); + + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMMemoryMXBeanImpl + * Method: isVerbose + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose(JNIEnv *env, jclass clazz) +{ +/* return _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose: MOVE TO C++!"); + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMMemoryMXBeanImpl + * Method: setVerbose + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose(JNIEnv *env, jclass clazz, jboolean verbose) +{ +/* _Jv_jvm->Java_gnu_java_lang_management_VMMemoryMXBeanImpl_verbose = verbose; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose: MOVE TO C++!"); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getHeapMemoryUsage", (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage }, + { (char*) "getNonHeapMemoryUsage", (char*) "()Ljava/lang/management/MemoryUsage;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage }, + { (char*) "getObjectPendingFinalizationCount", (char*) "()I", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount }, + { (char*) "isVerbose", (char*) "()Z", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose }, + { (char*) "setVerbose", (char*) "(Z)V", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose }, +}; + + +/* _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init ************************ + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_java_lang_management_VMMemoryMXBeanImpl_init(void) +{ + utf *u; + + u = utf_new_char("gnu/java/lang/management/VMMemoryMXBeanImpl"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c deleted file mode 100644 index cbd1e965d..000000000 --- a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.c +++ /dev/null @@ -1,104 +0,0 @@ -/* src/native/vm/gnu/gnu_java_lang_management_VMRuntimeMXBeanImpl.c - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h" - -#include "vm/builtin.h" -#include "vm/global.h" -#include "vm/vm.h" - -#include "vmcore/class.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getInputArguments", "()[Ljava/lang/String;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments }, - { "getStartTime", "()J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime }, -}; - - -/* _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init *********************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init(void) -{ - utf *u; - - u = utf_new_char("gnu/java/lang/management/VMRuntimeMXBeanImpl"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/java/lang/management/VMRuntimeMXBeanImpl - * Method: getInputArguments - * Signature: ()[Ljava/lang/String; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments: IMPLEMENT ME!"); - - return builtin_anewarray(0, class_java_lang_String); -} - - -/* - * Class: gnu/java/lang/management/VMRuntimeMXBeanImpl - * Method: getStartTime - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime(JNIEnv *env, jclass clazz) -{ - return _Jv_jvm->starttime; -} - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp new file mode 100644 index 000000000..673645eda --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp @@ -0,0 +1,112 @@ +/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMRuntimeMXBeanImpl.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: gnu/java/lang/management/VMRuntimeMXBeanImpl + * Method: getInputArguments + * Signature: ()[Ljava/lang/String; + */ +JNIEXPORT java_handle_objectarray_t* JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments: IMPLEMENT ME!"); + + return builtin_anewarray(0, class_java_lang_String); +} + + +/* + * Class: gnu/java/lang/management/VMRuntimeMXBeanImpl + * Method: getStartTime + * Signature: ()J + */ +JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime(JNIEnv *env, jclass clazz) +{ + return VM::get_current()->get_starttime(); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getInputArguments", (char*) "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments }, + { (char*) "getStartTime", (char*) "()J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime }, +}; + + +/* _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init *********************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_java_lang_management_VMRuntimeMXBeanImpl_init(void) +{ + utf *u; + + u = utf_new_char("gnu/java/lang/management/VMRuntimeMXBeanImpl"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c deleted file mode 100644 index 862ed07ab..000000000 --- a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.c +++ /dev/null @@ -1,205 +0,0 @@ -/* src/native/vm/gnu/gnu_java_lang_management_VMThreadMXBeanImpl.c - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "mm/gc-common.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_Throwable.h" -#include "native/include/java_lang_management_ThreadInfo.h" - -#include "native/include/gnu_java_lang_management_VMThreadMXBeanImpl.h" - -#include "toolbox/logging.h" - -#include "vm/vm.h" - -#include "vmcore/classcache.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "findMonitorDeadlockedThreads", "()[J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads }, - { "getCurrentThreadCpuTime", "()J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime }, - { "getCurrentThreadUserTime", "()J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime }, - { "getPeakThreadCount", "()I", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount }, - { "getThreadCpuTime", "(J)J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime }, - { "getThreadInfoForId", "(JI)Ljava/lang/management/ThreadInfo;", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId }, - { "getThreadUserTime", "(J)J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime }, - { "getTotalStartedThreadCount", "()J", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount }, - { "resetPeakThreadCount", "()V", (void *) (intptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount }, -}; - - -/* _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init ************************ - - Register native functions. - -*******************************************************************************/ - -void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init(void) -{ - utf *u; - - u = utf_new_char("gnu/java/lang/management/VMThreadMXBeanImpl"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: findMonitorDeadlockedThreads - * Signature: ()[J - */ -JNIEXPORT java_handle_longarray_t* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!"); - - return NULL; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getCurrentThreadCpuTime - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getCurrentThreadUserTime - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz) -{ - log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getPeakThreadCount - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz) -{ - return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getThreadCpuTime - * Signature: (J)J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, int64_t id) -{ - log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getThreadInfoForId - * Signature: (JI)Ljava/lang/management/ThreadInfo; - */ -JNIEXPORT java_lang_management_ThreadInfo* JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, int64_t id, int32_t maxDepth) -{ - log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!"); - - return NULL; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getThreadUserTime - * Signature: (J)J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, int64_t par1) -{ - log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: getTotalStartedThreadCount - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz) -{ - return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount; -} - - -/* - * Class: gnu/java/lang/management/VMThreadMXBeanImpl - * Method: resetPeakThreadCount - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount(JNIEnv *env, jclass clazz) -{ - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp new file mode 100644 index 000000000..e8a600899 --- /dev/null +++ b/src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp @@ -0,0 +1,217 @@ +/* src/native/vm/gnuclasspath/gnu_java_lang_management_VMThreadMXBeanImpl.cpp + + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "mm/gc.hpp" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/gnu_java_lang_management_VMThreadMXBeanImpl.h" +#endif + +#include "toolbox/logging.h" + +#include "vm/classcache.h" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: findMonitorDeadlockedThreads + * Signature: ()[J + */ +JNIEXPORT jlongArray JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads: IMPLEMENT ME!"); + + return NULL; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getCurrentThreadCpuTime + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime: IMPLEMENT ME!"); + + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getCurrentThreadUserTime + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime(JNIEnv *env, jclass clazz) +{ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime: IMPLEMENT ME!"); + + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getPeakThreadCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount(JNIEnv *env, jclass clazz) +{ +/* return _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_ThreadMXBean_getPeakThreadCount: MOVE TO C++!"); + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getThreadCpuTime + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime(JNIEnv *env, jclass clazz, jlong id) +{ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime: IMPLEMENT ME!"); + + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getThreadInfoForId + * Signature: (JI)Ljava/lang/management/ThreadInfo; + */ +JNIEXPORT jobject JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId(JNIEnv *env, jclass clazz, jlong id, jint maxDepth) +{ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId: IMPLEMENT ME!"); + + return NULL; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getThreadUserTime + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime(JNIEnv *env, jclass clazz, jlong par1) +{ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime: IMPLEMENT ME!"); + + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: getTotalStartedThreadCount + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount(JNIEnv *env, jclass clazz) +{ +/* return _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_ThreadMXBean_getTotalStartedThreadCount: MOVE TO C++!"); + return 0; +} + + +/* + * Class: gnu/java/lang/management/VMThreadMXBeanImpl + * Method: resetPeakThreadCount + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount(JNIEnv *env, jclass clazz) +{ +/* _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; */ +#warning Move to C++ + log_println("Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount: MOVE TO C++!"); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "findMonitorDeadlockedThreads", (char*) "()[J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads }, + { (char*) "getCurrentThreadCpuTime", (char*) "()J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime }, + { (char*) "getCurrentThreadUserTime", (char*) "()J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime }, + { (char*) "getPeakThreadCount", (char*) "()I", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount }, + { (char*) "getThreadCpuTime", (char*) "(J)J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime }, + { (char*) "getThreadInfoForId", (char*) "(JI)Ljava/lang/management/ThreadInfo;", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId }, + { (char*) "getThreadUserTime", (char*) "(J)J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime }, + { (char*) "getTotalStartedThreadCount", (char*) "()J", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount }, + { (char*) "resetPeakThreadCount", (char*) "()V", (void*) (uintptr_t) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_resetPeakThreadCount }, +}; + + +/* _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init ************************ + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_gnu_java_lang_management_VMThreadMXBeanImpl_init(void) +{ + utf *u; + + u = utf_new_char("gnu/java/lang/management/VMThreadMXBeanImpl"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMClass.c b/src/native/vm/gnuclasspath/java_lang_VMClass.c deleted file mode 100644 index c61e4cc57..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMClass.c +++ /dev/null @@ -1,654 +0,0 @@ -/* src/native/vm/gnuclasspath/java_lang_VMClass.c - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_ClassLoader.h" -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Throwable.h" -#include "native/include/java_lang_reflect_Constructor.h" -#include "native/include/java_lang_reflect_Method.h" - -#include "native/include/java_lang_VMClass.h" - -#include "vm/exceptions.h" -#include "vm/initialize.h" -#include "vm/stringlocal.h" - -#include "vmcore/class.h" - -#if defined(ENABLE_ANNOTATIONS) -#include "native/include/sun_reflect_ConstantPool.h" - -#include "vm/vm.h" - -#include "vmcore/annotation.h" -#endif - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "isInstance", "(Ljava/lang/Class;Ljava/lang/Object;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isInstance }, - { "isAssignableFrom", "(Ljava/lang/Class;Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom }, - { "isInterface", "(Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isInterface }, - { "isPrimitive", "(Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isPrimitive }, - { "getName", "(Ljava/lang/Class;)Ljava/lang/String;", (void *) (uintptr_t) &Java_java_lang_VMClass_getName }, - { "getSuperclass", "(Ljava/lang/Class;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_getSuperclass }, - { "getInterfaces", "(Ljava/lang/Class;)[Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_getInterfaces }, - { "getComponentType", "(Ljava/lang/Class;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_getComponentType }, - { "getModifiers", "(Ljava/lang/Class;Z)I", (void *) (uintptr_t) &Java_java_lang_VMClass_getModifiers }, - { "getDeclaringClass", "(Ljava/lang/Class;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass }, - { "getDeclaredClasses", "(Ljava/lang/Class;Z)[Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses }, - { "getDeclaredFields", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;", (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields }, - { "getDeclaredMethods", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;", (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods }, - { "getDeclaredConstructors", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;", (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors }, - { "getClassLoader", "(Ljava/lang/Class;)Ljava/lang/ClassLoader;", (void *) (uintptr_t) &Java_java_lang_VMClass_getClassLoader }, - { "forName", "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_forName }, - { "isArray", "(Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isArray }, - { "throwException", "(Ljava/lang/Throwable;)V", (void *) (uintptr_t) &Java_java_lang_VMClass_throwException }, -#if defined(ENABLE_ANNOTATIONS) - { "getDeclaredAnnotations", "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;", (void *) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations }, -#endif - { "getEnclosingClass", "(Ljava/lang/Class;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass }, - { "getEnclosingConstructor", "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;", (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor }, - { "getEnclosingMethod", "(Ljava/lang/Class;)Ljava/lang/reflect/Method;", (void *) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod }, - { "getClassSignature", "(Ljava/lang/Class;)Ljava/lang/String;", (void *) (uintptr_t) &Java_java_lang_VMClass_getClassSignature }, - { "isAnonymousClass", "(Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass }, - { "isLocalClass", "(Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isLocalClass }, - { "isMemberClass", "(Ljava/lang/Class;)Z", (void *) (uintptr_t) &Java_java_lang_VMClass_isMemberClass }, -}; - - -/* _Jv_java_lang_VMClass_init ************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMClass_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMClass"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMClass - * Method: isInstance - * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o) -{ - classinfo *c; - java_handle_t *h; - - c = LLNI_classinfo_unwrap(klass); - h = (java_handle_t *) o; - - return class_is_instance(c, h); -} - - -/* - * Class: java/lang/VMClass - * Method: isAssignableFrom - * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c) -{ - classinfo *to; - classinfo *from; - - to = LLNI_classinfo_unwrap(klass); - from = LLNI_classinfo_unwrap(c); - - if (from == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - return class_is_assignable_from(to, from); -} - - -/* - * Class: java/lang/VMClass - * Method: isInterface - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(klass); - - return class_is_interface(c); -} - - -/* - * Class: java/lang/VMClass - * Method: isPrimitive - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(klass); - - return class_is_primitive(c); -} - - -/* - * Class: java/lang/VMClass - * Method: getName - * Signature: (Ljava/lang/Class;)Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo* c; - - c = LLNI_classinfo_unwrap(klass); - - return (java_lang_String*) class_get_classname(c); -} - - -/* - * Class: java/lang/VMClass - * Method: getSuperclass - * Signature: (Ljava/lang/Class;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - classinfo *super; - - c = LLNI_classinfo_unwrap(klass); - - super = class_get_superclass(c); - - return LLNI_classinfo_wrap(super); -} - - -/* - * Class: java/lang/VMClass - * Method: getInterfaces - * Signature: (Ljava/lang/Class;)[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - c = LLNI_classinfo_unwrap(klass); - - oa = class_get_interfaces(c); - - return oa; -} - - -/* - * Class: java/lang/VMClass - * Method: getComponentType - * Signature: (Ljava/lang/Class;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - classinfo *component; - - c = LLNI_classinfo_unwrap(klass); - - component = class_get_componenttype(c); - - return LLNI_classinfo_wrap(component); -} - - -/* - * Class: java/lang/VMClass - * Method: getModifiers - * Signature: (Ljava/lang/Class;Z)I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t ignoreInnerClassesAttrib) -{ - classinfo *c; - int32_t flags; - - c = LLNI_classinfo_unwrap(klass); - - flags = class_get_modifiers(c, ignoreInnerClassesAttrib); - - return flags; -} - - -/* - * Class: java/lang/VMClass - * Method: getDeclaringClass - * Signature: (Ljava/lang/Class;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - classinfo *dc; - - c = LLNI_classinfo_unwrap(klass); - - dc = class_get_declaringclass(c); - - return LLNI_classinfo_wrap(dc); -} - - -/* - * Class: java/lang/VMClass - * Method: getDeclaredClasses - * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - c = LLNI_classinfo_unwrap(klass); - - oa = class_get_declaredclasses(c, publicOnly); - - return oa; -} - - -/* - * Class: java/lang/VMClass - * Method: getDeclaredFields - * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - c = LLNI_classinfo_unwrap(klass); - - oa = class_get_declaredfields(c, publicOnly); - - return oa; -} - - -/* - * Class: java/lang/VMClass - * Method: getDeclaredMethods - * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - c = LLNI_classinfo_unwrap(klass); - - oa = class_get_declaredmethods(c, publicOnly); - - return oa; -} - - -/* - * Class: java/lang/VMClass - * Method: getDeclaredConstructors - * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, int32_t publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - c = LLNI_classinfo_unwrap(klass); - - oa = class_get_declaredconstructors(c, publicOnly); - - return oa; -} - - -/* - * Class: java/lang/VMClass - * Method: getClassLoader - * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader; - */ -JNIEXPORT java_lang_ClassLoader* JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - classloader_t *cl; - - c = LLNI_classinfo_unwrap(klass); - cl = class_get_classloader(c); - - return (java_lang_ClassLoader *) cl; -} - - -/* - * Class: java/lang/VMClass - * Method: forName - * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, java_lang_String *name, int32_t initialize, java_lang_ClassLoader *loader) -{ - classloader_t *cl; - utf *ufile; - utf *uname; - classinfo *c; - u2 *pos; - int32_t i; - - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - /* illegal argument */ - - if (name == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* create utf string in which '.' is replaced by '/' */ - - ufile = javastring_toutf((java_handle_t *) name, true); - uname = javastring_toutf((java_handle_t *) name, false); - - /* name must not contain '/' (mauve test) */ - - for (i = 0, pos = LLNI_field_direct(name, value)->data + LLNI_field_direct(name, offset); i < LLNI_field_direct(name, count); i++, pos++) { - if (*pos == '/') { - exceptions_throw_classnotfoundexception(uname); - return NULL; - } - } - - /* try to load, ... */ - - c = load_class_from_classloader(ufile, cl); - - if (c == NULL) - return NULL; - - /* link, ... */ - - if (!link_class(c)) - return NULL; - - /* ...and initialize it, if required */ - - if (initialize) - if (!initialize_class(c)) - return NULL; - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: java/lang/VMClass - * Method: isArray - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(klass); - - return class_is_array(c); -} - - -/* - * Class: java/lang/VMClass - * Method: throwException - * Signature: (Ljava/lang/Throwable;)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, java_lang_Throwable *t) -{ - java_handle_t *o; - - o = (java_handle_t *) t; - - exceptions_set_exception(o); -} - - -#if defined(ENABLE_ANNOTATIONS) -/* - * Class: java/lang/VMClass - * Method: getDeclaredAnnotations - * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, java_lang_Class* klass) -{ - classinfo *c = NULL; /* classinfo for the java.lang.Class object 'klass' */ - static methodinfo *m_parseAnnotationsIntoArray = NULL; /* parser method (cached, therefore static) */ - utf *utf_parseAnnotationsIntoArray = NULL; /* parser method name */ - utf *utf_desc = NULL; /* parser method descriptor (signature) */ - java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ - sun_reflect_ConstantPool *constantPool = NULL; /* constant pool of klass */ - java_lang_Object *constantPoolOop = (java_lang_Object*)klass; /* constantPoolOop field of */ - /* sun.reflect.ConstantPool */ - - if (klass == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - c = LLNI_classinfo_unwrap(klass); - - /* get annotations: */ - annotations = class_get_annotations(c); - - constantPool = - (sun_reflect_ConstantPool*)native_new_and_init( - class_sun_reflect_ConstantPool); - - if (constantPool == NULL) { - /* out of memory */ - return NULL; - } - - LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop); - - /* only resolve the parser method the first time */ - if (m_parseAnnotationsIntoArray == NULL) { - utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray"); - utf_desc = utf_new_char( - "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)" - "[Ljava/lang/annotation/Annotation;"); - - if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) { - /* out of memory */ - return NULL; - } - - m_parseAnnotationsIntoArray = class_resolveclassmethod( - class_sun_reflect_annotation_AnnotationParser, - utf_parseAnnotationsIntoArray, - utf_desc, - class_java_lang_Class, - true); - - if (m_parseAnnotationsIntoArray == NULL) { - /* method not found */ - return NULL; - } - } - - return (java_handle_objectarray_t*)vm_call_method( - m_parseAnnotationsIntoArray, NULL, - annotations, constantPool, klass); -} -#endif - - -/* - * Class: java/lang/VMClass - * Method: getEnclosingClass - * Signature: (Ljava/lang/Class;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo *c; - classinfo *result; - - c = LLNI_classinfo_unwrap(klass); - - result = class_get_enclosingclass(c); - - return LLNI_classinfo_wrap(result); -} - - -/* - * Class: java/lang/VMClass - * Method: getEnclosingConstructor - * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor; - */ -JNIEXPORT java_lang_reflect_Constructor* JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo* c; - java_handle_t* h; - - c = LLNI_classinfo_unwrap(klass); - h = class_get_enclosingconstructor(c); - - return (java_lang_reflect_Constructor*) h; -} - - -/* - * Class: java/lang/VMClass - * Method: getEnclosingMethod - * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method; - */ -JNIEXPORT java_lang_reflect_Method* JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - classinfo* c; - java_handle_t* h; - - c = LLNI_classinfo_unwrap(klass); - h = class_get_enclosingmethod(c); - - return (java_lang_reflect_Method*) h; -} - - -/* - * Class: java/lang/VMClass - * Method: getClassSignature - * Signature: (Ljava/lang/Class;)Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, java_lang_Class* klass) -{ - classinfo *c; - utf *u; - java_handle_t *s; - - c = LLNI_classinfo_unwrap(klass); - - u = class_get_signature(c); - - if (u == NULL) - return NULL; - - s = javastring_new(u); - - /* in error case s is NULL */ - - return (java_lang_String *) s; -} - - -/* - * Class: java/lang/VMClass - * Method: isAnonymousClass - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - return class_is_anonymousclass(LLNI_classinfo_unwrap(klass)); -} - - -/* - * Class: java/lang/VMClass - * Method: isLocalClass - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - return class_is_localclass(LLNI_classinfo_unwrap(klass)); -} - - -/* - * Class: java/lang/VMClass - * Method: isMemberClass - * Signature: (Ljava/lang/Class;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, java_lang_Class *klass) -{ - return class_is_memberclass(LLNI_classinfo_unwrap(klass)); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMClass.cpp b/src/native/vm/gnuclasspath/java_lang_VMClass.cpp new file mode 100644 index 000000000..9298bbc17 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMClass.cpp @@ -0,0 +1,643 @@ +/* src/native/vm/gnuclasspath/java_lang_VMClass.cpp + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMClass.h" +#endif + +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/string.hpp" + +#if defined(ENABLE_ANNOTATIONS) +#include "vm/annotation.h" +#include "vm/vm.hpp" +#endif + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMClass + * Method: isInstance + * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, jclass klass, jobject o) +{ + classinfo *c; + java_handle_t *h; + + c = LLNI_classinfo_unwrap(klass); + h = (java_handle_t *) o; + + return class_is_instance(c, h); +} + + +/* + * Class: java/lang/VMClass + * Method: isAssignableFrom + * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, jclass klass, jclass c) +{ + classinfo *to; + classinfo *from; + + to = LLNI_classinfo_unwrap(klass); + from = LLNI_classinfo_unwrap(c); + + if (from == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + return class_is_assignable_from(to, from); +} + + +/* + * Class: java/lang/VMClass + * Method: isInterface + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(klass); + + return class_is_interface(c); +} + + +/* + * Class: java/lang/VMClass + * Method: isPrimitive + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(klass); + + return class_is_primitive(c); +} + + +/* + * Class: java/lang/VMClass + * Method: getName + * Signature: (Ljava/lang/Class;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_VMClass_getName(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo* c; + + c = LLNI_classinfo_unwrap(klass); + + return (jstring) class_get_classname(c); +} + + +/* + * Class: java/lang/VMClass + * Method: getSuperclass + * Signature: (Ljava/lang/Class;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + classinfo *super; + + c = LLNI_classinfo_unwrap(klass); + + super = class_get_superclass(c); + + return (jclass) LLNI_classinfo_wrap(super); +} + + +/* + * Class: java/lang/VMClass + * Method: getInterfaces + * Signature: (Ljava/lang/Class;)[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + c = LLNI_classinfo_unwrap(klass); + + oa = class_get_interfaces(c); + + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/VMClass + * Method: getComponentType + * Signature: (Ljava/lang/Class;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getComponentType(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + classinfo *component; + + c = LLNI_classinfo_unwrap(klass); + + component = class_get_componenttype(c); + + return (jclass) LLNI_classinfo_wrap(component); +} + + +/* + * Class: java/lang/VMClass + * Method: getModifiers + * Signature: (Ljava/lang/Class;Z)I + */ +JNIEXPORT jint JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, jclass klass, jboolean ignoreInnerClassesAttrib) +{ + classinfo *c; + int32_t flags; + + c = LLNI_classinfo_unwrap(klass); + + flags = class_get_modifiers(c, ignoreInnerClassesAttrib); + + return flags; +} + + +/* + * Class: java/lang/VMClass + * Method: getDeclaringClass + * Signature: (Ljava/lang/Class;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + classinfo *dc; + + c = LLNI_classinfo_unwrap(klass); + + dc = class_get_declaringclass(c); + + return (jclass) LLNI_classinfo_wrap(dc); +} + + +/* + * Class: java/lang/VMClass + * Method: getDeclaredClasses + * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + c = LLNI_classinfo_unwrap(klass); + + oa = class_get_declaredclasses(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/VMClass + * Method: getDeclaredFields + * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + c = LLNI_classinfo_unwrap(klass); + + oa = class_get_declaredfields(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/VMClass + * Method: getDeclaredMethods + * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + c = LLNI_classinfo_unwrap(klass); + + oa = class_get_declaredmethods(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/VMClass + * Method: getDeclaredConstructors + * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, jclass klass, jboolean publicOnly) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + c = LLNI_classinfo_unwrap(klass); + + oa = class_get_declaredconstructors(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/VMClass + * Method: getClassLoader + * Signature: (Ljava/lang/Class;)Ljava/lang/ClassLoader; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getClassLoader(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + classloader_t *cl; + + c = LLNI_classinfo_unwrap(klass); + cl = class_get_classloader(c); + + return (jobject) cl; +} + + +/* + * Class: java/lang/VMClass + * Method: forName + * Signature: (Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, jclass clazz, jstring name, jboolean initialize, jobject loader) +{ + classloader_t *cl; + utf *ufile; + utf *uname; + classinfo *c; + char* pos; + int32_t i; + + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + /* illegal argument */ + + if (name == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* create utf string in which '.' is replaced by '/' */ + + ufile = javastring_toutf((java_handle_t *) name, true); + uname = javastring_toutf((java_handle_t *) name, false); + + /* name must not contain '/' (mauve test) */ + + // FIXME Move this check into a function. + for (i = 0, pos = uname->text; i < uname->blength; i++, pos++) { + if (*pos == '/') { + exceptions_throw_classnotfoundexception(uname); + return NULL; + } + } + + /* try to load, ... */ + + c = load_class_from_classloader(ufile, cl); + + if (c == NULL) + return NULL; + + /* link, ... */ + + if (!link_class(c)) + return NULL; + + /* ...and initialize it, if required */ + + if (initialize) + if (!initialize_class(c)) + return NULL; + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* + * Class: java/lang/VMClass + * Method: isArray + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(klass); + + return class_is_array(c); +} + + +/* + * Class: java/lang/VMClass + * Method: throwException + * Signature: (Ljava/lang/Throwable;)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMClass_throwException(JNIEnv *env, jclass clazz, jobject t) +{ + java_handle_t *o; + + o = (java_handle_t *) t; + + exceptions_set_exception(o); +} + + +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/VMClass + * Method: getDeclaredAnnotations + * Signature: (Ljava/lang/Class;)[Ljava/lang/annotation/Annotation; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMClass_getDeclaredAnnotations(JNIEnv *env, jclass clazz, jclass klass) +{ + static methodinfo* m_parseAnnotationsIntoArray = NULL; + + if (klass == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + classinfo* c = LLNI_classinfo_unwrap(klass); + + /* get annotations: */ + java_handle_bytearray_t* annotations = class_get_annotations(c); + + java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool); + + if (h == NULL) + return NULL; + + sun_reflect_ConstantPool cp(h); + cp.set_constantPoolOop(klass); + + /* only resolve the parser method the first time */ + if (m_parseAnnotationsIntoArray == NULL) { + utf* utf_parseAnnotationsIntoArray = utf_new_char("parseAnnotationsIntoArray"); + utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;)" + "[Ljava/lang/annotation/Annotation;"); + + if (utf_parseAnnotationsIntoArray == NULL || utf_desc == NULL) { + /* out of memory */ + return NULL; + } + + m_parseAnnotationsIntoArray = class_resolveclassmethod( + class_sun_reflect_annotation_AnnotationParser, + utf_parseAnnotationsIntoArray, + utf_desc, + class_java_lang_Class, + true); + + if (m_parseAnnotationsIntoArray == NULL) { + /* method not found */ + return NULL; + } + } + + java_handle_objectarray_t* oa = (java_handle_objectarray_t*) vm_call_method(m_parseAnnotationsIntoArray, NULL, annotations, cp.get_handle(), klass); + return (jobjectArray) oa; +} +#endif + + +/* + * Class: java/lang/VMClass + * Method: getEnclosingClass + * Signature: (Ljava/lang/Class;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClass_getEnclosingClass(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + classinfo *result; + + c = LLNI_classinfo_unwrap(klass); + + result = class_get_enclosingclass(c); + + return (jclass) LLNI_classinfo_wrap(result); +} + + +/* + * Class: java/lang/VMClass + * Method: getEnclosingConstructor + * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Constructor; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getEnclosingConstructor(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo* c; + java_handle_t* h; + + c = LLNI_classinfo_unwrap(klass); + h = class_get_enclosingconstructor(c); + + return (jobject) h; +} + + +/* + * Class: java/lang/VMClass + * Method: getEnclosingMethod + * Signature: (Ljava/lang/Class;)Ljava/lang/reflect/Method; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMClass_getEnclosingMethod(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo* c; + java_handle_t* h; + + c = LLNI_classinfo_unwrap(klass); + h = class_get_enclosingmethod(c); + + return (jobject) h; +} + + +/* + * Class: java/lang/VMClass + * Method: getClassSignature + * Signature: (Ljava/lang/Class;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_VMClass_getClassSignature(JNIEnv *env, jclass clazz, jclass klass) +{ + classinfo *c; + utf *u; + java_handle_t *s; + + c = LLNI_classinfo_unwrap(klass); + + u = class_get_signature(c); + + if (u == NULL) + return NULL; + + s = javastring_new(u); + + /* in error case s is NULL */ + + return (jstring) s; +} + + +/* + * Class: java/lang/VMClass + * Method: isAnonymousClass + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isAnonymousClass(JNIEnv *env, jclass clazz, jclass klass) +{ + return class_is_anonymousclass(LLNI_classinfo_unwrap(klass)); +} + + +/* + * Class: java/lang/VMClass + * Method: isLocalClass + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isLocalClass(JNIEnv *env, jclass clazz, jclass klass) +{ + return class_is_localclass(LLNI_classinfo_unwrap(klass)); +} + + +/* + * Class: java/lang/VMClass + * Method: isMemberClass + * Signature: (Ljava/lang/Class;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClass_isMemberClass(JNIEnv *env, jclass clazz, jclass klass) +{ + return class_is_memberclass(LLNI_classinfo_unwrap(klass)); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "isInstance", (char*) "(Ljava/lang/Class;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isInstance }, + { (char*) "isAssignableFrom", (char*) "(Ljava/lang/Class;Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isAssignableFrom }, + { (char*) "isInterface", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isInterface }, + { (char*) "isPrimitive", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isPrimitive }, + { (char*) "getName", (char*) "(Ljava/lang/Class;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMClass_getName }, + { (char*) "getSuperclass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getSuperclass }, + { (char*) "getInterfaces", (char*) "(Ljava/lang/Class;)[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getInterfaces }, + { (char*) "getComponentType", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getComponentType }, + { (char*) "getModifiers", (char*) "(Ljava/lang/Class;Z)I", (void*) (uintptr_t) &Java_java_lang_VMClass_getModifiers }, + { (char*) "getDeclaringClass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaringClass }, + { (char*) "getDeclaredClasses", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredClasses }, + { (char*) "getDeclaredFields", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredFields }, + { (char*) "getDeclaredMethods", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredMethods }, + { (char*) "getDeclaredConstructors", (char*) "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredConstructors }, + { (char*) "getClassLoader", (char*) "(Ljava/lang/Class;)Ljava/lang/ClassLoader;", (void*) (uintptr_t) &Java_java_lang_VMClass_getClassLoader }, + { (char*) "forName", (char*) "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_forName }, + { (char*) "isArray", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isArray }, + { (char*) "throwException", (char*) "(Ljava/lang/Throwable;)V", (void*) (uintptr_t) &Java_java_lang_VMClass_throwException }, +#if defined(ENABLE_ANNOTATIONS) + { (char*) "getDeclaredAnnotations", (char*) "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_VMClass_getDeclaredAnnotations }, +#endif + { (char*) "getEnclosingClass", (char*) "(Ljava/lang/Class;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingClass }, + { (char*) "getEnclosingConstructor", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingConstructor }, + { (char*) "getEnclosingMethod", (char*) "(Ljava/lang/Class;)Ljava/lang/reflect/Method;", (void*) (uintptr_t) &Java_java_lang_VMClass_getEnclosingMethod }, + { (char*) "getClassSignature", (char*) "(Ljava/lang/Class;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMClass_getClassSignature }, + { (char*) "isAnonymousClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isAnonymousClass }, + { (char*) "isLocalClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isLocalClass }, + { (char*) "isMemberClass", (char*) "(Ljava/lang/Class;)Z", (void*) (uintptr_t) &Java_java_lang_VMClass_isMemberClass }, +}; + + +/* _Jv_java_lang_VMClass_init ************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMClass_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMClass"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMClassLoader.c b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.c deleted file mode 100644 index 6f6547b91..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMClassLoader.c +++ /dev/null @@ -1,628 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMClassLoader.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_security_ProtectionDomain.h" /* required by... */ -#include "native/include/java_lang_ClassLoader.h" -#include "native/include/java_util_Vector.h" -#include "native/include/java_util_HashMap.h" -#include "native/include/java_util_Map.h" -#include "native/include/java_lang_Boolean.h" - -#include "native/include/java_lang_VMClassLoader.h" - -#include "toolbox/logging.h" -#include "toolbox/list.h" - -#if defined(ENABLE_ASSERTION) -#include "vm/assertion.h" -#endif - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/initialize.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" - -#include "vmcore/class.h" -#include "vmcore/classcache.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" -#include "vmcore/suck.h" -#include "vmcore/zip.h" - -#if defined(ENABLE_JVMTI) -#include "native/jvmti/cacaodbg.h" -#endif - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "defineClass", "(Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defineClass }, - { "getPrimitiveClass", "(C)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_getPrimitiveClass }, - { "resolveClass", "(Ljava/lang/Class;)V", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_resolveClass }, - { "loadClass", "(Ljava/lang/String;Z)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_loadClass }, - { "nativeGetResources", "(Ljava/lang/String;)Ljava/util/Vector;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_nativeGetResources }, - { "defaultAssertionStatus", "()Z", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultAssertionStatus }, - { "defaultUserAssertionStatus", "()Z", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_defaultUserAssertionStatus }, - { "packageAssertionStatus0", "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_packageAssertionStatus0 }, - { "classAssertionStatus0", "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_classAssertionStatus0 }, - { "findLoadedClass", "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_VMClassLoader_findLoadedClass }, -}; - - -/* _Jv_java_lang_VMClassLoader_init ******************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMClassLoader_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMClassLoader"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMClassLoader - * Method: defineClass - * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *cl, java_lang_String *name, java_handle_bytearray_t *data, int32_t offset, int32_t len, java_security_ProtectionDomain *pd) -{ - utf *utfname; - classinfo *c; - classloader_t *loader; - java_lang_Class *o; - -#if defined(ENABLE_JVMTI) - jint new_class_data_len = 0; - unsigned char* new_class_data = NULL; -#endif - - /* check if data was passed */ - - if (data == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* check the indexes passed */ - - if ((offset < 0) || (len < 0) || ((offset + len) > LLNI_array_size(data))) { - exceptions_throw_arrayindexoutofboundsexception(); - return NULL; - } - - /* add classloader to classloader hashtable */ - - loader = loader_hashtable_classloader_add((java_handle_t *) cl); - - if (name != NULL) { - /* convert '.' to '/' in java string */ - - utfname = javastring_toutf((java_handle_t *) name, true); - } - else { - utfname = NULL; - } - -#if defined(ENABLE_JVMTI) - /* XXX again this will not work because of the indirection cell for classloaders */ - assert(0); - /* fire Class File Load Hook JVMTI event */ - - if (jvmti) - jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, - loader, (java_handle_t *) pd, - &new_class_data_len, &new_class_data); -#endif - - /* define the class */ - -#if defined(ENABLE_JVMTI) - /* check if the JVMTI wants to modify the class */ - - if (new_class_data == NULL) - c = class_define(utfname, loader, new_class_data_len, new_class_data, pd); - else -#endif - c = class_define(utfname, loader, len, (uint8_t *) &LLNI_array_direct(data, offset), (java_handle_t *) pd); - - if (c == NULL) - return NULL; - - /* for convenience */ - - o = LLNI_classinfo_wrap(c); - - /* set ProtectionDomain */ - - LLNI_field_set_ref(o, pd, pd); - - return o; -} - - -/* - * Class: java/lang/VMClassLoader - * Method: getPrimitiveClass - * Signature: (C)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, int32_t type) -{ - classinfo *c; - - c = primitive_class_get_by_char(type); - - if (c == NULL) { - exceptions_throw_classnotfoundexception(utf_null); - return NULL; - } - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: java/lang/VMClassLoader - * Method: resolveClass - * Signature: (Ljava/lang/Class;)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, java_lang_Class *c) -{ - classinfo *ci; - - ci = LLNI_classinfo_unwrap(c); - - if (!ci) { - exceptions_throw_nullpointerexception(); - return; - } - - /* link the class */ - - if (!(ci->state & CLASS_LINKED)) - (void) link_class(ci); - - return; -} - - -/* - * Class: java/lang/VMClassLoader - * Method: loadClass - * Signature: (Ljava/lang/String;Z)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, java_lang_String *name, int32_t resolve) -{ - classinfo *c; - utf *u; - - if (name == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* create utf string in which '.' is replaced by '/' */ - - u = javastring_toutf((java_handle_t *) name, true); - - /* load class */ - - c = load_class_bootstrap(u); - - if (c == NULL) - return NULL; - - /* resolve class -- if requested */ - -/* if (resolve) */ - if (!link_class(c)) - return NULL; - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: java/lang/VMClassLoader - * Method: nativeGetResources - * Signature: (Ljava/lang/String;)Ljava/util/Vector; - */ -JNIEXPORT java_util_Vector* JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, java_lang_String *name) -{ - java_handle_t *o; /* vector being created */ - methodinfo *m; /* "add" method of vector */ - java_handle_t *path; /* path to be added */ - list_classpath_entry *lce; /* classpath entry */ - utf *utfname; /* utf to look for */ - char *buffer; /* char buffer */ - char *namestart; /* start of name to use */ - char *tmppath; /* temporary buffer */ - int32_t namelen; /* length of name to use */ - int32_t searchlen; /* length of name to search */ - int32_t bufsize; /* size of buffer allocated */ - int32_t pathlen; /* name of path to assemble */ - struct stat buf; /* buffer for stat */ - jboolean ret; /* return value of "add" */ - - /* get the resource name as utf string */ - - utfname = javastring_toutf((java_handle_t *) name, false); - - if (utfname == NULL) - return NULL; - - /* copy it to a char buffer */ - - namelen = utf_bytes(utfname); - searchlen = namelen; - bufsize = namelen + strlen("0"); - buffer = MNEW(char, bufsize); - - utf_copy(buffer, utfname); - namestart = buffer; - - /* skip leading '/' */ - - if (namestart[0] == '/') { - namestart++; - namelen--; - searchlen--; - } - - /* remove trailing `.class' */ - - if (namelen >= 6 && strcmp(namestart + (namelen - 6), ".class") == 0) { - searchlen -= 6; - } - - /* create a new needle to look for, if necessary */ - - if (searchlen != bufsize-1) { - utfname = utf_new(namestart, searchlen); - if (utfname == NULL) - goto return_NULL; - } - - /* new Vector() */ - - o = native_new_and_init(class_java_util_Vector); - - if (o == NULL) - goto return_NULL; - - /* get Vector.add() method */ - - m = class_resolveclassmethod(class_java_util_Vector, - utf_add, - utf_new_char("(Ljava/lang/Object;)Z"), - NULL, - true); - - if (m == NULL) - goto return_NULL; - - /* iterate over all classpath entries */ - - for (lce = list_first(list_classpath_entries); lce != NULL; - lce = list_next(list_classpath_entries, lce)) { - /* clear path pointer */ - path = NULL; - -#if defined(ENABLE_ZLIB) - if (lce->type == CLASSPATH_ARCHIVE) { - - if (zip_find(lce, utfname)) { - pathlen = strlen("jar:file://") + lce->pathlen + strlen("!/") + - namelen + strlen("0"); - - tmppath = MNEW(char, pathlen); - - sprintf(tmppath, "jar:file://%s!/%s", lce->path, namestart); - path = javastring_new_from_utf_string(tmppath), - - MFREE(tmppath, char, pathlen); - } - - } else { -#endif /* defined(ENABLE_ZLIB) */ - pathlen = strlen("file://") + lce->pathlen + namelen + strlen("0"); - - tmppath = MNEW(char, pathlen); - - sprintf(tmppath, "file://%s%s", lce->path, namestart); - - /* Does this file exist? */ - - if (stat(tmppath + strlen("file://") - 1, &buf) == 0) - if (!S_ISDIR(buf.st_mode)) - path = javastring_new_from_utf_string(tmppath); - - MFREE(tmppath, char, pathlen); -#if defined(ENABLE_ZLIB) - } -#endif - - /* if a resource was found, add it to the vector */ - - if (path != NULL) { - ret = vm_call_method_int(m, o, path); - - if (exceptions_get_exception() != NULL) - goto return_NULL; - - if (ret == 0) - goto return_NULL; - } - } - - MFREE(buffer, char, bufsize); - - return (java_util_Vector *) o; - -return_NULL: - MFREE(buffer, char, bufsize); - - return NULL; -} - - -/* - * Class: java/lang/VMClassLoader - * Method: defaultAssertionStatus - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz) -{ -#if defined(ENABLE_ASSERTION) - return assertion_system_enabled; -#else - return false; -#endif -} - -/* - * Class: java/lang/VMClassLoader - * Method: userAssertionStatus - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz) -{ -#if defined(ENABLE_ASSERTION) - return assertion_user_enabled; -#else - return false; -#endif -} - -/* - * Class: java/lang/VMClassLoader - * Method: packageAssertionStatus - * Signature: ()Ljava_util_Map; - */ -JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse) -{ - java_handle_t *hm; -#if defined(ENABLE_ASSERTION) - java_handle_t *js; - methodinfo *m; - assertion_name_t *item; -#endif - - /* new HashMap() */ - - hm = native_new_and_init(class_java_util_HashMap); - if (hm == NULL) { - return NULL; - } - -#if defined(ENABLE_ASSERTION) - /* if nothing todo, return now */ - - if (assertion_package_count == 0) { - return (java_util_Map *) hm; - } - - /* get HashMap.put method */ - - m = class_resolveclassmethod(class_java_util_HashMap, - utf_put, - utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), - NULL, - true); - - if (m == NULL) { - return NULL; - } - - item = (assertion_name_t *)list_first(list_assertion_names); - - while (item != NULL) { - if (item->package == false) { - item = (assertion_name_t *)list_next(list_assertion_names, item); - continue; - } - - if (strcmp(item->name, "") == 0) { - /* unnamed package wanted */ - js = NULL; - } - else { - js = javastring_new_from_ascii(item->name); - if (js == NULL) { - return NULL; - } - } - - if (item->enabled == true) { - vm_call_method(m, hm, js, jtrue); - } - else { - vm_call_method(m, hm, js, jfalse); - } - - item = (assertion_name_t *)list_next(list_assertion_names, item); - } -#endif - - return (java_util_Map *) hm; -} - -/* - * Class: java/lang/VMClassLoader - * Method: classAssertionStatus - * Signature: ()Ljava_util_Map; - */ -JNIEXPORT java_util_Map* JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, java_lang_Boolean *jtrue, java_lang_Boolean *jfalse) -{ - java_handle_t *hm; -#if defined(ENABLE_ASSERTION) - java_handle_t *js; - methodinfo *m; - assertion_name_t *item; -#endif - - /* new HashMap() */ - - hm = native_new_and_init(class_java_util_HashMap); - if (hm == NULL) { - return NULL; - } - -#if defined(ENABLE_ASSERTION) - /* if nothing todo, return now */ - - if (assertion_class_count == 0) { - return (java_util_Map *) hm; - } - - /* get HashMap.put method */ - - m = class_resolveclassmethod(class_java_util_HashMap, - utf_put, - utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), - NULL, - true); - - if (m == NULL) { - return NULL; - } - - item = (assertion_name_t *)list_first(list_assertion_names); - - while (item != NULL) { - if (item->package == true) { - item = (assertion_name_t *)list_next(list_assertion_names, item); - continue; - } - - js = javastring_new_from_ascii(item->name); - if (js == NULL) { - return NULL; - } - - if (item->enabled == true) { - vm_call_method(m, hm, js, jtrue); - } - else { - vm_call_method(m, hm, js, jfalse); - } - - item = (assertion_name_t *)list_next(list_assertion_names, item); - } -#endif - - return (java_util_Map *) hm; -} - - -/* - * Class: java/lang/VMClassLoader - * Method: findLoadedClass - * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *loader, java_lang_String *name) -{ - classloader_t *cl; - classinfo *c; - utf *u; - - /* XXX is it correct to add the classloader to the hashtable here? */ - - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - /* replace `.' by `/', this is required by the classcache */ - - u = javastring_toutf((java_handle_t *) name, true); - - /* lookup for defining classloader */ - - c = classcache_lookup_defined(cl, u); - - /* if not found, lookup for initiating classloader */ - - if (c == NULL) - c = classcache_lookup(cl, u); - - return LLNI_classinfo_wrap(c); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp new file mode 100644 index 000000000..fe0491cf5 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp @@ -0,0 +1,635 @@ +/* src/native/vm/gnuclasspath/java_lang_VMClassLoader.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMClassLoader.h" +#endif + +#include "toolbox/logging.h" +#include "toolbox/list.h" + +#if defined(ENABLE_ASSERTION) +#include "vm/assertion.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/statistics.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" +#include "vm/zip.h" + +#include "vm/jit/asmpart.h" + +#if defined(ENABLE_JVMTI) +#include "native/jvmti/cacaodbg.h" +#endif + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMClassLoader + * Method: defineClass + * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_defineClass(JNIEnv *env, jclass clazz, jobject cl, jstring name, jbyteArray data, jint offset, jint len, jobject pd) +{ + utf *utfname; + classinfo *c; + classloader_t *loader; + java_handle_bytearray_t* ba; + uint8_t* stream; + +#if defined(ENABLE_JVMTI) + jint new_class_data_len = 0; + unsigned char* new_class_data = NULL; +#endif + + /* check if data was passed */ + + if (data == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* check the indexes passed */ + + if ((offset < 0) || (len < 0) || ((offset + len) > LLNI_array_size(data))) { + exceptions_throw_arrayindexoutofboundsexception(); + return NULL; + } + + /* add classloader to classloader hashtable */ + + loader = loader_hashtable_classloader_add((java_handle_t *) cl); + + if (name != NULL) { + /* convert '.' to '/' in java string */ + + utfname = javastring_toutf((java_handle_t *) name, true); + } + else { + utfname = NULL; + } + +#if defined(ENABLE_JVMTI) + /* XXX again this will not work because of the indirection cell for classloaders */ + assert(0); + /* fire Class File Load Hook JVMTI event */ + + if (jvmti) + jvmti_ClassFileLoadHook(utfname, len, (unsigned char *) data->data, + loader, (java_handle_t *) pd, + &new_class_data_len, &new_class_data); +#endif + + /* define the class */ + +#if defined(ENABLE_JVMTI) + /* check if the JVMTI wants to modify the class */ + + if (new_class_data == NULL) + c = class_define(utfname, loader, new_class_data_len, new_class_data, pd); + else +#endif + { + ba = (java_handle_bytearray_t*) data; + stream = (uint8_t *) &LLNI_array_direct(ba, offset); + c = class_define(utfname, loader, len, stream, (java_handle_t *) pd); + } + + if (c == NULL) + return NULL; + + // REMOVEME + java_handle_t* h = LLNI_classinfo_wrap(c); + + // Set ProtectionDomain. + java_lang_Class jlc(h); + jlc.set_pd(pd); + + return (jclass) jlc.get_handle(); +} + + +/* + * Class: java/lang/VMClassLoader + * Method: getPrimitiveClass + * Signature: (C)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_getPrimitiveClass(JNIEnv *env, jclass clazz, jchar type) +{ + classinfo *c; + + c = Primitive::get_class_by_char(type); + + if (c == NULL) { + exceptions_throw_classnotfoundexception(utf_null); + return NULL; + } + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* + * Class: java/lang/VMClassLoader + * Method: resolveClass + * Signature: (Ljava/lang/Class;)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jclass clazz, jclass c) +{ + classinfo *ci; + + ci = LLNI_classinfo_unwrap(c); + + if (!ci) { + exceptions_throw_nullpointerexception(); + return; + } + + /* link the class */ + + if (!(ci->state & CLASS_LINKED)) + (void) link_class(ci); + + return; +} + + +/* + * Class: java/lang/VMClassLoader + * Method: loadClass + * Signature: (Ljava/lang/String;Z)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, jstring name, jboolean resolve) +{ + classinfo *c; + utf *u; + + if (name == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* create utf string in which '.' is replaced by '/' */ + + u = javastring_toutf((java_handle_t *) name, true); + + /* load class */ + + c = load_class_bootstrap(u); + + if (c == NULL) + return NULL; + + /* resolve class -- if requested */ + +/* if (resolve) */ + if (!link_class(c)) + return NULL; + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* + * Class: java/lang/VMClassLoader + * Method: nativeGetResources + * Signature: (Ljava/lang/String;)Ljava/util/Vector; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_nativeGetResources(JNIEnv *env, jclass clazz, jstring name) +{ + java_handle_t *o; /* vector being created */ + methodinfo *m; /* "add" method of vector */ + java_handle_t *path; /* path to be added */ + list_classpath_entry *lce; /* classpath entry */ + utf *utfname; /* utf to look for */ + char *buffer; /* char buffer */ + char *namestart; /* start of name to use */ + char *tmppath; /* temporary buffer */ + int32_t namelen; /* length of name to use */ + int32_t searchlen; /* length of name to search */ + int32_t bufsize; /* size of buffer allocated */ + int32_t pathlen; /* name of path to assemble */ + struct stat buf; /* buffer for stat */ + jboolean ret; /* return value of "add" */ + + /* get the resource name as utf string */ + + utfname = javastring_toutf((java_handle_t *) name, false); + + if (utfname == NULL) + return NULL; + + /* copy it to a char buffer */ + + namelen = utf_bytes(utfname); + searchlen = namelen; + bufsize = namelen + strlen("0"); + buffer = MNEW(char, bufsize); + + utf_copy(buffer, utfname); + namestart = buffer; + + /* skip leading '/' */ + + if (namestart[0] == '/') { + namestart++; + namelen--; + searchlen--; + } + + /* remove trailing `.class' */ + + if (namelen >= 6 && strcmp(namestart + (namelen - 6), ".class") == 0) { + searchlen -= 6; + } + + /* create a new needle to look for, if necessary */ + + if (searchlen != bufsize-1) { + utfname = utf_new(namestart, searchlen); + if (utfname == NULL) + goto return_NULL; + } + + /* new Vector() */ + + o = native_new_and_init(class_java_util_Vector); + + if (o == NULL) + goto return_NULL; + + /* get Vector.add() method */ + + m = class_resolveclassmethod(class_java_util_Vector, + utf_add, + utf_new_char("(Ljava/lang/Object;)Z"), + NULL, + true); + + if (m == NULL) + goto return_NULL; + + /* iterate over all classpath entries */ + + for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL; + lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) { + /* clear path pointer */ + path = NULL; + +#if defined(ENABLE_ZLIB) + if (lce->type == CLASSPATH_ARCHIVE) { + + if (zip_find(lce, utfname)) { + pathlen = strlen("jar:file://") + lce->pathlen + strlen("!/") + + namelen + strlen("0"); + + tmppath = MNEW(char, pathlen); + + sprintf(tmppath, "jar:file://%s!/%s", lce->path, namestart); + path = javastring_new_from_utf_string(tmppath), + + MFREE(tmppath, char, pathlen); + } + + } else { +#endif /* defined(ENABLE_ZLIB) */ + pathlen = strlen("file://") + lce->pathlen + namelen + strlen("0"); + + tmppath = MNEW(char, pathlen); + + sprintf(tmppath, "file://%s%s", lce->path, namestart); + + /* Does this file exist? */ + + if (stat(tmppath + strlen("file://") - 1, &buf) == 0) + if (!S_ISDIR(buf.st_mode)) + path = javastring_new_from_utf_string(tmppath); + + MFREE(tmppath, char, pathlen); +#if defined(ENABLE_ZLIB) + } +#endif + + /* if a resource was found, add it to the vector */ + + if (path != NULL) { + ret = vm_call_method_int(m, o, path); + + if (exceptions_get_exception() != NULL) + goto return_NULL; + + if (ret == 0) + goto return_NULL; + } + } + + MFREE(buffer, char, bufsize); + + return (jobject) o; + +return_NULL: + MFREE(buffer, char, bufsize); + + return NULL; +} + + +/* + * Class: java/lang/VMClassLoader + * Method: defaultAssertionStatus + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClassLoader_defaultAssertionStatus(JNIEnv *env, jclass clazz) +{ +#if defined(ENABLE_ASSERTION) + return assertion_system_enabled; +#else + return false; +#endif +} + +/* + * Class: java/lang/VMClassLoader + * Method: userAssertionStatus + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMClassLoader_defaultUserAssertionStatus(JNIEnv *env, jclass clazz) +{ +#if defined(ENABLE_ASSERTION) + return assertion_user_enabled; +#else + return false; +#endif +} + +/* + * Class: java/lang/VMClassLoader + * Method: packageAssertionStatus + * Signature: (Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_packageAssertionStatus0(JNIEnv *env, jclass clazz, jobject jtrue, jobject jfalse) +{ + java_handle_t *hm; +#if defined(ENABLE_ASSERTION) + java_handle_t *js; + methodinfo *m; + assertion_name_t *item; +#endif + + /* new HashMap() */ + + hm = native_new_and_init(class_java_util_HashMap); + if (hm == NULL) { + return NULL; + } + +#if defined(ENABLE_ASSERTION) + /* if nothing todo, return now */ + + if (assertion_package_count == 0) { + return (jobject) hm; + } + + /* get HashMap.put method */ + + m = class_resolveclassmethod(class_java_util_HashMap, + utf_put, + utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), + NULL, + true); + + if (m == NULL) { + return NULL; + } + + item = (assertion_name_t *)list_first(list_assertion_names); + + while (item != NULL) { + if (item->package == false) { + item = (assertion_name_t *)list_next(list_assertion_names, item); + continue; + } + + if (strcmp(item->name, "") == 0) { + /* unnamed package wanted */ + js = NULL; + } + else { + js = javastring_new_from_ascii(item->name); + if (js == NULL) { + return NULL; + } + } + + if (item->enabled == true) { + vm_call_method(m, hm, js, jtrue); + } + else { + vm_call_method(m, hm, js, jfalse); + } + + item = (assertion_name_t *)list_next(list_assertion_names, item); + } +#endif + + return (jobject) hm; +} + +/* + * Class: java/lang/VMClassLoader + * Method: classAssertionStatus + * Signature: (Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMClassLoader_classAssertionStatus0(JNIEnv *env, jclass clazz, jobject jtrue, jobject jfalse) +{ + java_handle_t *hm; +#if defined(ENABLE_ASSERTION) + java_handle_t *js; + methodinfo *m; + assertion_name_t *item; +#endif + + /* new HashMap() */ + + hm = native_new_and_init(class_java_util_HashMap); + if (hm == NULL) { + return NULL; + } + +#if defined(ENABLE_ASSERTION) + /* if nothing todo, return now */ + + if (assertion_class_count == 0) { + return (jobject) hm; + } + + /* get HashMap.put method */ + + m = class_resolveclassmethod(class_java_util_HashMap, + utf_put, + utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), + NULL, + true); + + if (m == NULL) { + return NULL; + } + + item = (assertion_name_t *)list_first(list_assertion_names); + + while (item != NULL) { + if (item->package == true) { + item = (assertion_name_t *)list_next(list_assertion_names, item); + continue; + } + + js = javastring_new_from_ascii(item->name); + if (js == NULL) { + return NULL; + } + + if (item->enabled == true) { + vm_call_method(m, hm, js, jtrue); + } + else { + vm_call_method(m, hm, js, jfalse); + } + + item = (assertion_name_t *)list_next(list_assertion_names, item); + } +#endif + + return (jobject) hm; +} + + +/* + * Class: java/lang/VMClassLoader + * Method: findLoadedClass + * Signature: (Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMClassLoader_findLoadedClass(JNIEnv *env, jclass clazz, jobject loader, jstring name) +{ + classloader_t *cl; + classinfo *c; + utf *u; + + /* XXX is it correct to add the classloader to the hashtable here? */ + + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + /* replace `.' by `/', this is required by the classcache */ + + u = javastring_toutf((java_handle_t *) name, true); + + /* lookup for defining classloader */ + + c = classcache_lookup_defined(cl, u); + + /* if not found, lookup for initiating classloader */ + + if (c == NULL) + c = classcache_lookup(cl, u); + + return (jclass) LLNI_classinfo_wrap(c); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "defineClass", (char*) "(Ljava/lang/ClassLoader;Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_defineClass }, + { (char*) "getPrimitiveClass", (char*) "(C)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_getPrimitiveClass }, + { (char*) "resolveClass", (char*) "(Ljava/lang/Class;)V", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_resolveClass }, + { (char*) "loadClass", (char*) "(Ljava/lang/String;Z)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_loadClass }, + { (char*) "nativeGetResources", (char*) "(Ljava/lang/String;)Ljava/util/Vector;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_nativeGetResources }, + { (char*) "defaultAssertionStatus", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_defaultAssertionStatus }, + { (char*) "defaultUserAssertionStatus", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_defaultUserAssertionStatus }, + { (char*) "packageAssertionStatus0", (char*) "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_packageAssertionStatus0 }, + { (char*) "classAssertionStatus0", (char*) "(Ljava/lang/Boolean;Ljava/lang/Boolean;)Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_classAssertionStatus0 }, + { (char*) "findLoadedClass", (char*) "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMClassLoader_findLoadedClass }, +}; + + +/* _Jv_java_lang_VMClassLoader_init ******************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMClassLoader_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMClassLoader"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMObject.c b/src/native/vm/gnuclasspath/java_lang_VMObject.c deleted file mode 100644 index ea0ba0e69..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMObject.c +++ /dev/null @@ -1,176 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMObject.c - java/lang/VMObject - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Class.h" /* required by j.l.VMO */ -#include "native/include/java_lang_Cloneable.h" /* required by j.l.VMO */ -#include "native/include/java_lang_Object.h" /* required by j.l.VMO */ - -#include "native/include/java_lang_VMObject.h" - -#include "threads/lock-common.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" - -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getClass", "(Ljava/lang/Object;)Ljava/lang/Class;", (void *) (intptr_t) &Java_java_lang_VMObject_getClass }, - { "clone", "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void *) (intptr_t) &Java_java_lang_VMObject_clone }, - { "notify", "(Ljava/lang/Object;)V", (void *) (intptr_t) &Java_java_lang_VMObject_notify }, - { "notifyAll", "(Ljava/lang/Object;)V", (void *) (intptr_t) &Java_java_lang_VMObject_notifyAll }, - { "wait", "(Ljava/lang/Object;JI)V", (void *) (intptr_t) &Java_java_lang_VMObject_wait }, -}; - - -/* _Jv_java_lang_VMObject_init ************************************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMObject_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMObject"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMObject - * Method: getClass - * Signature: (Ljava/lang/Object;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, java_lang_Object *obj) -{ - classinfo *c; - - if (obj == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - LLNI_class_get(obj, c); - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: java/lang/VMObject - * Method: clone - * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, java_lang_Cloneable *this) -{ - java_handle_t *o; - java_handle_t *co; - - o = (java_handle_t *) this; - - co = builtin_clone(NULL, o); - - return (java_lang_Object *) co; -} - - -/* - * Class: java/lang/VMObject - * Method: notify - * Signature: (Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this) -{ -#if defined(ENABLE_THREADS) - lock_notify_object((java_handle_t *) this); -#endif -} - - -/* - * Class: java/lang/VMObject - * Method: notifyAll - * Signature: (Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *this) -{ -#if defined(ENABLE_THREADS) - lock_notify_all_object((java_handle_t *) this); -#endif -} - - -/* - * Class: java/lang/VMObject - * Method: wait - * Signature: (Ljava/lang/Object;JI)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, java_lang_Object *o, int64_t ms, int32_t ns) -{ -#if defined(ENABLE_JVMTI) - /* Monitor Wait */ - if (jvmti) jvmti_MonitorWaiting(true, o, ms); -#endif - -#if defined(ENABLE_THREADS) - lock_wait_for_object((java_handle_t *) o, ms, ns); -#endif - -#if defined(ENABLE_JVMTI) - /* Monitor Waited */ - /* XXX: How do you know if wait timed out ?*/ - if (jvmti) jvmti_MonitorWaiting(false, o, 0); -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMObject.cpp b/src/native/vm/gnuclasspath/java_lang_VMObject.cpp new file mode 100644 index 000000000..69459ba94 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMObject.cpp @@ -0,0 +1,178 @@ +/* src/native/vm/gnuclasspath/java_lang_VMObject.cpp - java/lang/VMObject + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMObject.h" +#endif + +#include "threads/lock-common.h" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/javaobjects.hpp" +#include "vm/utf8.h" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMObject + * Method: getClass + * Signature: (Ljava/lang/Object;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_VMObject_getClass(JNIEnv *env, jclass clazz, jobject obj) +{ + if (obj == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + java_lang_Object o(obj); + + return (jclass) LLNI_classinfo_wrap(o.get_Class()); +} + + +/* + * Class: java/lang/VMObject + * Method: clone + * Signature: (Ljava/lang/Cloneable;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, jclass clazz, jobject _this) +{ + java_handle_t *o; + java_handle_t *co; + + o = (java_handle_t *) _this; + + co = builtin_clone(NULL, o); + + return (jobject) co; +} + + +/* + * Class: java/lang/VMObject + * Method: notify + * Signature: (Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, jobject _this) +{ +#if defined(ENABLE_THREADS) + lock_notify_object((java_handle_t *) _this); +#endif +} + + +/* + * Class: java/lang/VMObject + * Method: notifyAll + * Signature: (Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, jobject _this) +{ +#if defined(ENABLE_THREADS) + lock_notify_all_object((java_handle_t *) _this); +#endif +} + + +/* + * Class: java/lang/VMObject + * Method: wait + * Signature: (Ljava/lang/Object;JI)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMObject_wait(JNIEnv *env, jclass clazz, jobject o, jlong ms, jint ns) +{ +#if defined(ENABLE_JVMTI) + /* Monitor Wait */ + if (jvmti) jvmti_MonitorWaiting(true, o, ms); +#endif + +#if defined(ENABLE_THREADS) + lock_wait_for_object((java_handle_t *) o, ms, ns); +#endif + +#if defined(ENABLE_JVMTI) + /* Monitor Waited */ + /* XXX: How do you know if wait timed out ?*/ + if (jvmti) jvmti_MonitorWaiting(false, o, 0); +#endif +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getClass", (char*) "(Ljava/lang/Object;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_VMObject_getClass }, + { (char*) "clone", (char*) "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_VMObject_clone }, + { (char*) "notify", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notify }, + { (char*) "notifyAll", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_VMObject_notifyAll }, + { (char*) "wait", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_java_lang_VMObject_wait }, +}; + + +/* _Jv_java_lang_VMObject_init ************************************************* + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMObject_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMObject"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMRuntime.c b/src/native/vm/gnuclasspath/java_lang_VMRuntime.c deleted file mode 100644 index 25be0db79..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMRuntime.c +++ /dev/null @@ -1,331 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMRuntime.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#if defined(__DARWIN__) -# if defined(__POWERPC__) -# define OS_INLINE /* required for */ -# endif -# include -#endif - -#include "mm/dumpmemory.h" -#include "mm/gc-common.h" - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_io_File.h" -#include "native/include/java_lang_ClassLoader.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Process.h" - -#include "native/include/java_lang_VMRuntime.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/system.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "exit", "(I)V", (void *) (intptr_t) &Java_java_lang_VMRuntime_exit }, - { "freeMemory", "()J", (void *) (intptr_t) &Java_java_lang_VMRuntime_freeMemory }, - { "totalMemory", "()J", (void *) (intptr_t) &Java_java_lang_VMRuntime_totalMemory }, - { "maxMemory", "()J", (void *) (intptr_t) &Java_java_lang_VMRuntime_maxMemory }, - { "gc", "()V", (void *) (intptr_t) &Java_java_lang_VMRuntime_gc }, - { "runFinalization", "()V", (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalization }, - { "runFinalizersOnExit", "(Z)V", (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizersOnExit }, - { "runFinalizationForExit", "()V", (void *) (intptr_t) &Java_java_lang_VMRuntime_runFinalizationForExit }, - { "traceInstructions", "(Z)V", (void *) (intptr_t) &Java_java_lang_VMRuntime_traceInstructions }, - { "traceMethodCalls", "(Z)V", (void *) (intptr_t) &Java_java_lang_VMRuntime_traceMethodCalls }, - { "availableProcessors", "()I", (void *) (intptr_t) &Java_java_lang_VMRuntime_availableProcessors }, - { "nativeLoad", "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void *) (intptr_t) &Java_java_lang_VMRuntime_nativeLoad }, - { "mapLibraryName", "(Ljava/lang/String;)Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_VMRuntime_mapLibraryName }, -}; - - -/* _Jv_java_lang_VMRuntime_init ************************************************ - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMRuntime_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMRuntime"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -static bool finalizeOnExit = false; - - -/* - * Class: java/lang/VMRuntime - * Method: exit - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, int32_t status) -{ - if (finalizeOnExit) - gc_finalize_all(); - - vm_shutdown(status); -} - - -/* - * Class: java/lang/VMRuntime - * Method: freeMemory - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz) -{ - return gc_get_free_bytes(); -} - - -/* - * Class: java/lang/VMRuntime - * Method: totalMemory - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz) -{ - return gc_get_heap_size(); -} - - -/* - * Class: java/lang/VMRuntime - * Method: maxMemory - * Signature: ()J - */ -JNIEXPORT int64_t JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz) -{ - return gc_get_max_heap_size(); -} - - -/* - * Class: java/lang/VMRuntime - * Method: gc - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_gc(JNIEnv *env, jclass clazz) -{ - gc_call(); -} - - -/* - * Class: java/lang/VMRuntime - * Method: runFinalization - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(JNIEnv *env, jclass clazz) -{ - gc_invoke_finalizers(); -} - - -/* - * Class: java/lang/VMRuntime - * Method: runFinalizersOnExit - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, int32_t value) -{ - /* XXX threading */ - - finalizeOnExit = value; -} - - -/* - * Class: java/lang/VMRuntime - * Method: runFinalizationsForExit - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizationForExit(JNIEnv *env, jclass clazz) -{ -/* if (finalizeOnExit) { */ -/* gc_call(); */ - /* gc_finalize_all(); */ -/* } */ -/* log_text("Java_java_lang_VMRuntime_runFinalizationForExit called"); */ - /*gc_finalize_all();*/ - /*gc_invoke_finalizers();*/ - /*gc_call();*/ -} - - -/* - * Class: java/lang/VMRuntime - * Method: traceInstructions - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, int32_t par1) -{ - /* not supported */ -} - - -/* - * Class: java/lang/VMRuntime - * Method: traceMethodCalls - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, int32_t par1) -{ - /* not supported */ -} - - -/* - * Class: java/lang/VMRuntime - * Method: availableProcessors - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz) -{ - return system_processors_online(); -} - - -/* - * Class: java/lang/VMRuntime - * Method: nativeLoad - * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, java_lang_String *libname, java_lang_ClassLoader *loader) -{ - classloader_t *cl; - utf *name; - - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - /* REMOVEME When we use Java-strings internally. */ - - if (libname == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - name = javastring_toutf((java_handle_t *) libname, false); - - return native_library_load(env, name, cl); -} - - -/* - * Class: java/lang/VMRuntime - * Method: mapLibraryName - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, java_lang_String *libname) -{ - utf *u; - char *buffer; - int32_t buffer_len; - java_handle_t *o; - int32_t dumpmarker; - - if (libname == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - u = javastring_toutf((java_handle_t *) libname, false); - - /* calculate length of library name */ - - buffer_len = strlen("lib"); - - buffer_len += utf_bytes(u); - -#if defined(__DARWIN__) - buffer_len += strlen(".dylib"); -#else - buffer_len += strlen(".so"); -#endif - - buffer_len += strlen("0"); - - DMARKER; - - buffer = DMNEW(char, buffer_len); - - /* generate library name */ - - strcpy(buffer, "lib"); - utf_cat(buffer, u); - -#if defined(__DARWIN__) - strcat(buffer, ".dylib"); -#else - strcat(buffer, ".so"); -#endif - - o = javastring_new_from_utf_string(buffer); - - /* release memory */ - - DRELEASE; - - return (java_lang_String *) o; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp b/src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp new file mode 100644 index 000000000..ba23fcc7e --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp @@ -0,0 +1,321 @@ +/* src/native/vm/gnuclasspath/java_lang_VMRuntime.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#if defined(__DARWIN__) +# if defined(__POWERPC__) +# define OS_INLINE /* required for */ +# endif +# include +#endif + +#include "mm/memory.h" +#include "mm/gc.hpp" + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMRuntime.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/os.hpp" +#include "vm/string.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +static bool finalizeOnExit = false; + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMRuntime + * Method: exit + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_exit(JNIEnv *env, jclass clazz, jint status) +{ + if (finalizeOnExit) + gc_finalize_all(); + + vm_shutdown(status); +} + + +/* + * Class: java/lang/VMRuntime + * Method: freeMemory + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_freeMemory(JNIEnv *env, jclass clazz) +{ + return gc_get_free_bytes(); +} + + +/* + * Class: java/lang/VMRuntime + * Method: totalMemory + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_totalMemory(JNIEnv *env, jclass clazz) +{ + return gc_get_heap_size(); +} + + +/* + * Class: java/lang/VMRuntime + * Method: maxMemory + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_java_lang_VMRuntime_maxMemory(JNIEnv *env, jclass clazz) +{ + return gc_get_max_heap_size(); +} + + +/* + * Class: java/lang/VMRuntime + * Method: gc + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_gc(JNIEnv *env, jclass clazz) +{ + gc_call(); +} + + +/* + * Class: java/lang/VMRuntime + * Method: runFinalization + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalization(JNIEnv *env, jclass clazz) +{ + gc_invoke_finalizers(); +} + + +/* + * Class: java/lang/VMRuntime + * Method: runFinalizersOnExit + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizersOnExit(JNIEnv *env, jclass clazz, jboolean value) +{ + /* XXX threading */ + + finalizeOnExit = value; +} + + +/* + * Class: java/lang/VMRuntime + * Method: runFinalizationsForExit + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_runFinalizationForExit(JNIEnv *env, jclass clazz) +{ +/* if (finalizeOnExit) { */ +/* gc_call(); */ + /* gc_finalize_all(); */ +/* } */ +/* log_text("Java_java_lang_VMRuntime_runFinalizationForExit called"); */ + /*gc_finalize_all();*/ + /*gc_invoke_finalizers();*/ + /*gc_call();*/ +} + + +/* + * Class: java/lang/VMRuntime + * Method: traceInstructions + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceInstructions(JNIEnv *env, jclass clazz, jboolean par1) +{ + /* not supported */ +} + + +/* + * Class: java/lang/VMRuntime + * Method: traceMethodCalls + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMRuntime_traceMethodCalls(JNIEnv *env, jclass clazz, jboolean par1) +{ + /* not supported */ +} + + +/* + * Class: java/lang/VMRuntime + * Method: availableProcessors + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_availableProcessors(JNIEnv *env, jclass clazz) +{ + return os::processors_online(); +} + + +/* + * Class: java/lang/VMRuntime + * Method: nativeLoad + * Signature: (Ljava/lang/String;Ljava/lang/ClassLoader;)I + */ +JNIEXPORT jint JNICALL Java_java_lang_VMRuntime_nativeLoad(JNIEnv *env, jclass clazz, jstring libname, jobject loader) +{ + classloader_t *cl; + utf *name; + + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + /* REMOVEME When we use Java-strings internally. */ + + if (libname == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + name = javastring_toutf((java_handle_t *) libname, false); + + return native_library_load(env, name, cl); +} + + +/* + * Class: java/lang/VMRuntime + * Method: mapLibraryName + * Signature: (Ljava/lang/String;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_VMRuntime_mapLibraryName(JNIEnv *env, jclass clazz, jstring libname) +{ + utf *u; + char *buffer; + int32_t buffer_len; + java_handle_t *o; + + if (libname == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + u = javastring_toutf((java_handle_t *) libname, false); + + /* calculate length of library name */ + + buffer_len = + strlen(NATIVE_LIBRARY_PREFIX) + + utf_bytes(u) + + strlen(NATIVE_LIBRARY_SUFFIX) + + strlen("0"); + + buffer = MNEW(char, buffer_len); + + /* generate library name */ + + strcpy(buffer, NATIVE_LIBRARY_PREFIX); + utf_cat(buffer, u); + strcat(buffer, NATIVE_LIBRARY_SUFFIX); + + o = javastring_new_from_utf_string(buffer); + + /* release memory */ + + MFREE(buffer, char, buffer_len); + + return (jstring) o; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "exit", (char*) "(I)V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_exit }, + { (char*) "freeMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_VMRuntime_freeMemory }, + { (char*) "totalMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_VMRuntime_totalMemory }, + { (char*) "maxMemory", (char*) "()J", (void*) (uintptr_t) &Java_java_lang_VMRuntime_maxMemory }, + { (char*) "gc", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_gc }, + { (char*) "runFinalization", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_runFinalization }, + { (char*) "runFinalizersOnExit", (char*) "(Z)V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_runFinalizersOnExit }, + { (char*) "runFinalizationForExit", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_runFinalizationForExit }, + { (char*) "traceInstructions", (char*) "(Z)V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_traceInstructions }, + { (char*) "traceMethodCalls", (char*) "(Z)V", (void*) (uintptr_t) &Java_java_lang_VMRuntime_traceMethodCalls }, + { (char*) "availableProcessors", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_VMRuntime_availableProcessors }, + { (char*) "nativeLoad", (char*) "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void*) (uintptr_t) &Java_java_lang_VMRuntime_nativeLoad }, + { (char*) "mapLibraryName", (char*) "(Ljava/lang/String;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMRuntime_mapLibraryName }, +}; + + +/* _Jv_java_lang_VMRuntime_init ************************************************ + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMRuntime_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMRuntime"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMString.c b/src/native/vm/gnuclasspath/java_lang_VMString.c deleted file mode 100644 index 993b6616c..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMString.c +++ /dev/null @@ -1,89 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMString.c - java/lang/VMString - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_VMString.h" - -#include "vm/stringlocal.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "intern", "(Ljava/lang/String;)Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_VMString_intern }, -}; - - -/* _Jv_java_lang_VMString_init ************************************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMString_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMString"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMString - * Method: intern - * Signature: (Ljava/lang/String;)Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, java_lang_String *str) -{ - if (str == NULL) - return NULL; - - return (java_lang_String *) javastring_intern((java_handle_t *) str); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMString.cpp b/src/native/vm/gnuclasspath/java_lang_VMString.cpp new file mode 100644 index 000000000..6b1dd3d17 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMString.cpp @@ -0,0 +1,97 @@ +/* src/native/vm/gnuclasspath/java_lang_VMString.cpp - java/lang/VMString + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMString.h" +#endif + +#include "vm/string.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMString + * Method: intern + * Signature: (Ljava/lang/String;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_VMString_intern(JNIEnv *env, jclass clazz, jstring str) +{ + if (str == NULL) + return NULL; + + return (jstring) javastring_intern((java_handle_t *) str); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "intern", (char*) "(Ljava/lang/String;)Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMString_intern }, +}; + + +/* _Jv_java_lang_VMString_init ************************************************* + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMString_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMString"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMSystem.c b/src/native/vm/gnuclasspath/java_lang_VMSystem.c deleted file mode 100644 index 40c978c8a..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMSystem.c +++ /dev/null @@ -1,112 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMSystem.c - java/lang/VMSystem - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "mm/gc-common.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_io_InputStream.h" /* required by j.l.VMS */ -#include "native/include/java_io_PrintStream.h" /* required by j.l.VMS */ - -#include "native/include/java_lang_VMSystem.h" - -#include "vm/builtin.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void *) (uintptr_t) &Java_java_lang_VMSystem_arraycopy }, - { "identityHashCode", "(Ljava/lang/Object;)I", (void *) (uintptr_t) &Java_java_lang_VMSystem_identityHashCode }, -}; - - -/* _Jv_java_lang_VMSystem_init ************************************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMSystem_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMSystem"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMSystem - * Method: arraycopy - * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, java_lang_Object *src, int32_t srcStart, java_lang_Object *dest, int32_t destStart, int32_t len) -{ - builtin_arraycopy((java_handle_t *) src, srcStart, - (java_handle_t *) dest, destStart, len); -} - - -/* - * Class: java/lang/VMSystem - * Method: identityHashCode - * Signature: (Ljava/lang/Object;)I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, java_lang_Object *o) -{ - int32_t hashcode; - - LLNI_CRITICAL_START; - - hashcode = heap_hashcode(LLNI_UNWRAP((java_handle_t *) o)); - - LLNI_CRITICAL_END; - - return hashcode; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMSystem.cpp b/src/native/vm/gnuclasspath/java_lang_VMSystem.cpp new file mode 100644 index 000000000..8334ebfea --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMSystem.cpp @@ -0,0 +1,113 @@ +/* src/native/vm/gnuclasspath/java_lang_VMSystem.cpp - java/lang/VMSystem + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "mm/gc.hpp" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vminclude/java_lang_VMSystem.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/javaobjects.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMSystem + * Method: arraycopy + * Signature: (Ljava/lang/Object;ILjava/lang/Object;II)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMSystem_arraycopy(JNIEnv *env, jclass clazz, jobject src, jint srcStart, jobject dest, jint destStart, jint len) +{ + builtin_arraycopy((java_handle_t *) src, srcStart, + (java_handle_t *) dest, destStart, len); +} + + +/* + * Class: java/lang/VMSystem + * Method: identityHashCode + * Signature: (Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_java_lang_VMSystem_identityHashCode(JNIEnv *env, jclass clazz, jobject obj) +{ + java_lang_Object o(obj); + + return o.get_hashcode(); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "arraycopy", (char*) "(Ljava/lang/Object;ILjava/lang/Object;II)V", (void*) (uintptr_t) &Java_java_lang_VMSystem_arraycopy }, + { (char*) "identityHashCode", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_java_lang_VMSystem_identityHashCode }, +}; + + +/* _Jv_java_lang_VMSystem_init ************************************************* + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMSystem_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMSystem"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMThread.c b/src/native/vm/gnuclasspath/java_lang_VMThread.c deleted file mode 100644 index 178bd41f5..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMThread.c +++ /dev/null @@ -1,360 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMThread.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_ThreadGroup.h" -#include "native/include/java_lang_Object.h" /* java_lang_Thread.h */ -#include "native/include/java_lang_Throwable.h" /* java_lang_Thread.h */ -#include "native/include/java_lang_VMThread.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Thread.h" - -#include "threads/lock-common.h" -#include "threads/thread.h" - -#include "vm/exceptions.h" -#include "vm/stringlocal.h" - -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "countStackFrames", "()I", (void *) (intptr_t) &Java_java_lang_VMThread_countStackFrames }, - { "start", "(J)V", (void *) (intptr_t) &Java_java_lang_VMThread_start }, - { "interrupt", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_interrupt }, - { "isInterrupted", "()Z", (void *) (intptr_t) &Java_java_lang_VMThread_isInterrupted }, - { "suspend", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_suspend }, - { "resume", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_resume }, - { "nativeSetPriority", "(I)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeSetPriority }, - { "nativeStop", "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_java_lang_VMThread_nativeStop }, - { "currentThread", "()Ljava/lang/Thread;", (void *) (intptr_t) &Java_java_lang_VMThread_currentThread }, - { "yield", "()V", (void *) (intptr_t) &Java_java_lang_VMThread_yield }, - { "interrupted", "()Z", (void *) (intptr_t) &Java_java_lang_VMThread_interrupted }, - { "holdsLock", "(Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_java_lang_VMThread_holdsLock }, - { "getState", "()Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_VMThread_getState }, -}; - - -/* _Jv_java_lang_VMThread_init ************************************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMThread_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMThread"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMThread - * Method: countStackFrames - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, java_lang_VMThread *this) -{ - java_lang_Thread *thread; - - LLNI_field_get_ref(this, thread, thread); - - log_println("Java_java_lang_VMThread_countStackFrames: IMPLEMENT ME!"); - - return 0; -} - - -/* - * Class: java/lang/VMThread - * Method: start - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, java_lang_VMThread *this, int64_t stacksize) -{ - java_lang_Thread *thread; - - LLNI_field_get_ref(this, thread, thread); - -#if defined(ENABLE_THREADS) - threads_thread_start((java_handle_t *) thread); -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: interrupt - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, java_lang_VMThread *this) -{ -#if defined(ENABLE_THREADS) - java_handle_t *h; - threadobject *t; - - h = (java_handle_t *) this; - t = thread_get_thread(h); - - threads_thread_interrupt(t); -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: isInterrupted - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, java_lang_VMThread *this) -{ -#if defined(ENABLE_THREADS) - java_handle_t *h; - threadobject *t; - - h = (java_handle_t *) this; - t = thread_get_thread(h); - - return thread_is_interrupted(t); -#else - return 0; -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: suspend - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, java_lang_VMThread *this) -{ -#if defined(ENABLE_THREADS) - /* TODO Should we implement this or is it obsolete? */ -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: resume - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, java_lang_VMThread *this) -{ -#if defined(ENABLE_THREADS) - /* TODO Should we implement this or is it obsolete? */ -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: nativeSetPriority - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, java_lang_VMThread *this, int32_t priority) -{ -#if defined(ENABLE_THREADS) - java_handle_t *h; - threadobject *t; - - h = (java_handle_t *) this; - t = thread_get_thread(h); - - threads_set_thread_priority(t->tid, priority); -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: nativeStop - * Signature: (Ljava/lang/Throwable;)V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t) -{ -#if defined(ENABLE_THREADS) - /* TODO Should we implement this or is it obsolete? */ -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: currentThread - * Signature: ()Ljava/lang/Thread; - */ -JNIEXPORT java_lang_Thread* JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz) -{ - java_lang_Thread *to; - - to = (java_lang_Thread *) thread_get_current_object(); - - return to; -} - - -/* - * Class: java/lang/VMThread - * Method: yield - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz) -{ -#if defined(ENABLE_THREADS) - threads_yield(); -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: interrupted - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz) -{ -#if defined(ENABLE_THREADS) - threadobject *t; - int32_t interrupted; - - t = thread_get_current(); - - interrupted = thread_is_interrupted(t); - - if (interrupted) - thread_set_interrupted(t, false); - - return interrupted; -#else - return 0; -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: holdsLock - * Signature: (Ljava/lang/Object;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, java_lang_Object* o) -{ -#if defined(ENABLE_THREADS) - java_handle_t *h; - - h = (java_handle_t *) o; - - if (h == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - return lock_is_held_by_current_thread(h); -#else - return 0; -#endif -} - - -/* - * Class: java/lang/VMThread - * Method: getState - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, java_lang_VMThread *this) -{ -#if defined(ENABLE_THREADS) - java_handle_t *h; - threadobject *t; - int state; - utf *u; - java_handle_t *o; - - h = (java_handle_t *) this; - t = thread_get_thread(h); - - state = cacaothread_get_state(t); - - switch (state) { - case THREAD_STATE_NEW: - u = utf_new_char("NEW"); - break; - case THREAD_STATE_RUNNABLE: - u = utf_new_char("RUNNABLE"); - break; - case THREAD_STATE_BLOCKED: - u = utf_new_char("BLOCKED"); - break; - case THREAD_STATE_WAITING: - u = utf_new_char("WAITING"); - break; - case THREAD_STATE_TIMED_WAITING: - u = utf_new_char("TIMED_WAITING"); - break; - case THREAD_STATE_TERMINATED: - u = utf_new_char("TERMINATED"); - break; - default: - vm_abort("Java_java_lang_VMThread_getState: unknown thread state %d", state); - - /* Keep compiler happy. */ - - u = NULL; - } - - o = javastring_new(u); - - return (java_lang_String *) o; -#else - return NULL; -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMThread.cpp b/src/native/vm/gnuclasspath/java_lang_VMThread.cpp new file mode 100644 index 000000000..1cb86b3a9 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMThread.cpp @@ -0,0 +1,373 @@ +/* src/native/vm/gnuclasspath/java_lang_VMThread.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMThread.h" +#endif + +#include "threads/lock-common.h" +#include "threads/thread.hpp" + +#include "vm/exceptions.hpp" +#include "vm/javaobjects.hpp" +#include "vm/string.hpp" +#include "vm/utf8.h" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMThread + * Method: countStackFrames + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_VMThread_countStackFrames(JNIEnv *env, jobject _this) +{ + log_println("Java_java_lang_VMThread_countStackFrames: Deprecated. Not implemented."); + + return 0; +} + + +/* + * Class: java/lang/VMThread + * Method: start + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_start(JNIEnv *env, jobject _this, jlong stacksize) +{ +#if defined(ENABLE_THREADS) + java_lang_VMThread jlvmt(_this); + + threads_thread_start(jlvmt.get_thread()); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: interrupt + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_interrupt(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + java_handle_t *h; + threadobject *t; + + h = (java_handle_t *) _this; + t = thread_get_thread(h); + + threads_thread_interrupt(t); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: isInterrupted + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_isInterrupted(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + java_handle_t *h; + threadobject *t; + + h = (java_handle_t *) _this; + t = thread_get_thread(h); + + return thread_is_interrupted(t); +#else + return 0; +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: suspend + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_suspend(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + log_println("Java_java_lang_VMThread_suspend: Deprecated. Not implemented."); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: resume + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_resume(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + log_println("Java_java_lang_VMThread_resume: Deprecated. Not implemented."); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: nativeSetPriority + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, jobject _this, jint priority) +{ +#if defined(ENABLE_THREADS) + java_handle_t *h; + threadobject *t; + + h = (java_handle_t *) _this; + t = thread_get_thread(h); + + threads_set_thread_priority(t->tid, priority); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: nativeStop + * Signature: (Ljava/lang/Throwable;)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, jobject _this, jobject t) +{ +#if defined(ENABLE_THREADS) + log_println("Java_java_lang_VMThread_nativeStop: Deprecated. Not implemented."); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: currentThread + * Signature: ()Ljava/lang/Thread; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMThread_currentThread(JNIEnv *env, jclass clazz) +{ + java_handle_t* h; + + h = thread_get_current_object(); + + return (jobject) h; +} + + +/* + * Class: java/lang/VMThread + * Method: yield + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_yield(JNIEnv *env, jclass clazz) +{ +#if defined(ENABLE_THREADS) + threads_yield(); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: sleep + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_java_lang_VMThread_sleep(JNIEnv *env, jclass clazz, int64_t ms, int32_t ns) +{ +#if defined(ENABLE_THREADS) + threads_sleep(ms, ns); +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: interrupted + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_interrupted(JNIEnv *env, jclass clazz) +{ +#if defined(ENABLE_THREADS) + threadobject *t; + int32_t interrupted; + + t = thread_get_current(); + + interrupted = thread_is_interrupted(t); + + if (interrupted) + thread_set_interrupted(t, false); + + return interrupted; +#else + return 0; +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: holdsLock + * Signature: (Ljava/lang/Object;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_VMThread_holdsLock(JNIEnv *env, jclass clazz, jobject o) +{ +#if defined(ENABLE_THREADS) + java_handle_t *h; + + h = (java_handle_t *) o; + + if (h == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + return lock_is_held_by_current_thread(h); +#else + return 0; +#endif +} + + +/* + * Class: java/lang/VMThread + * Method: getState + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_VMThread_getState(JNIEnv *env, jobject _this) +{ +#if defined(ENABLE_THREADS) + java_handle_t *h; + threadobject *t; + int state; + utf *u; + java_handle_t *o; + + h = (java_handle_t *) _this; + t = thread_get_thread(h); + + state = cacaothread_get_state(t); + + switch (state) { + case THREAD_STATE_NEW: + u = utf_new_char("NEW"); + break; + case THREAD_STATE_RUNNABLE: + u = utf_new_char("RUNNABLE"); + break; + case THREAD_STATE_BLOCKED: + u = utf_new_char("BLOCKED"); + break; + case THREAD_STATE_WAITING: + u = utf_new_char("WAITING"); + break; + case THREAD_STATE_TIMED_WAITING: + u = utf_new_char("TIMED_WAITING"); + break; + case THREAD_STATE_TERMINATED: + u = utf_new_char("TERMINATED"); + break; + default: + vm_abort("Java_java_lang_VMThread_getState: unknown thread state %d", state); + + /* Keep compiler happy. */ + + u = NULL; + } + + o = javastring_new(u); + + return (jstring) o; +#else + return NULL; +#endif +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "countStackFrames", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_VMThread_countStackFrames }, + { (char*) "start", (char*) "(J)V", (void*) (uintptr_t) &Java_java_lang_VMThread_start }, + { (char*) "interrupt", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMThread_interrupt }, + { (char*) "isInterrupted", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_VMThread_isInterrupted }, + { (char*) "suspend", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMThread_suspend }, + { (char*) "resume", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMThread_resume }, + { (char*) "nativeSetPriority", (char*) "(I)V", (void*) (uintptr_t) &Java_java_lang_VMThread_nativeSetPriority }, + { (char*) "nativeStop", (char*) "(Ljava/lang/Throwable;)V", (void*) (uintptr_t) &Java_java_lang_VMThread_nativeStop }, + { (char*) "currentThread", (char*) "()Ljava/lang/Thread;", (void*) (uintptr_t) &Java_java_lang_VMThread_currentThread }, + { (char*) "yield", (char*) "()V", (void*) (uintptr_t) &Java_java_lang_VMThread_yield }, + { (char*) "sleep", (char*) "(JI)V", (void*) (uintptr_t) &Java_java_lang_VMThread_sleep }, + { (char*) "interrupted", (char*) "()Z", (void*) (uintptr_t) &Java_java_lang_VMThread_interrupted }, + { (char*) "holdsLock", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_VMThread_holdsLock }, + { (char*) "getState", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_VMThread_getState }, +}; + + +/* _Jv_java_lang_VMThread_init ************************************************* + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_VMThread_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMThread"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMThrowable.c b/src/native/vm/gnuclasspath/java_lang_VMThrowable.c deleted file mode 100644 index 29d6f654b..000000000 --- a/src/native/vm/gnuclasspath/java_lang_VMThrowable.c +++ /dev/null @@ -1,219 +0,0 @@ -/* src/native/vm/gnu/java_lang_VMThrowable.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_StackTraceElement.h" -#include "native/include/java_lang_Throwable.h" - -#include "native/include/java_lang_VMThrowable.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" - -#include "vm/jit/code.h" -#include "vm/jit/linenumbertable.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "fillInStackTrace", "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;", (void *) (ptrint) &Java_java_lang_VMThrowable_fillInStackTrace }, - { "getStackTrace", "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void *) (ptrint) &Java_java_lang_VMThrowable_getStackTrace }, -}; - - -/* _Jv_java_lang_VMThrowable_init ********************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_VMThrowable_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/VMThrowable"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/VMThrowable - * Method: fillInStackTrace - * Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable; - */ -JNIEXPORT java_lang_VMThrowable* JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, java_lang_Throwable *t) -{ - java_lang_VMThrowable *vmto; - java_handle_bytearray_t *ba; - java_lang_Object *o; - - vmto = (java_lang_VMThrowable *) - native_new_and_init(class_java_lang_VMThrowable); - - if (vmto == NULL) - return NULL; - - ba = stacktrace_get_current(); - - if (ba == NULL) - return NULL; - - o = (java_lang_Object *) ba; - - LLNI_field_set_ref(vmto, vmdata, o); - - return vmto; -} - - -/* - * Class: java/lang/VMThrowable - * Method: getStackTrace - * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, java_lang_VMThrowable *this, java_lang_Throwable *t) -{ - java_lang_Object *o; - java_handle_bytearray_t *ba; - stacktrace_t *st; - stacktrace_entry_t *ste; - java_handle_objectarray_t *oa; - java_lang_StackTraceElement *steo; - codeinfo *code; - methodinfo *m; - java_lang_String *filename; - s4 linenumber; - java_handle_t *declaringclass; - int i; - - /* Get the stacktrace from the VMThrowable object. */ - - LLNI_field_get_ref(this, vmdata, o); - - ba = (java_handle_bytearray_t *) o; - - st = (stacktrace_t *) LLNI_array_data(ba); - - assert(st != NULL); - - ste = st->entries; - - /* Create the stacktrace element array. */ - - oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement); - - if (oa == NULL) - return NULL; - - for (i = 0; i < st->length; i++, ste++) { - /* allocate a new stacktrace element */ - - steo = (java_lang_StackTraceElement *) - builtin_new(class_java_lang_StackTraceElement); - - if (steo == NULL) - return NULL; - - /* Get the codeinfo and methodinfo. */ - - code = ste->code; - m = code->m; - - /* Get filename. */ - - if (!(m->flags & ACC_NATIVE)) { - if (m->clazz->sourcefile) - filename = (java_lang_String *) javastring_new(m->clazz->sourcefile); - else - filename = NULL; - } - else - filename = NULL; - - /* get line number */ - - if (m->flags & ACC_NATIVE) { - linenumber = -1; - } - else { - /* FIXME The linenumbertable_linenumber_for_pc could - change the methodinfo pointer when hitting an inlined - method. */ - - linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc); - linenumber = (linenumber == 0) ? -1 : linenumber; - } - - /* get declaring class name */ - - declaringclass = class_get_classname(m->clazz); - - /* Fill the java.lang.StackTraceElement object. */ - - LLNI_field_set_ref(steo, fileName , filename); - LLNI_field_set_val(steo, lineNumber , linenumber); - LLNI_field_set_ref(steo, declaringClass, (java_lang_String*) declaringclass); - LLNI_field_set_ref(steo, methodName , (java_lang_String *) javastring_new(m->name)); - LLNI_field_set_val(steo, isNative , (m->flags & ACC_NATIVE) ? 1 : 0); - - array_objectarray_element_set(oa, i, (java_handle_t *) steo); - } - - return oa; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp b/src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp new file mode 100644 index 000000000..a3c26cf1b --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp @@ -0,0 +1,207 @@ +/* src/native/vm/gnuclasspath/java_lang_VMThrowable.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_VMThrowable.h" +#endif + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/loader.hpp" +#include "vm/string.hpp" + +#include "vm/jit/code.hpp" +#include "vm/jit/linenumbertable.h" +#include "vm/jit/stacktrace.hpp" + + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/VMThrowable + * Method: fillInStackTrace + * Signature: (Ljava/lang/Throwable;)Ljava/lang/VMThrowable; + */ +JNIEXPORT jobject JNICALL Java_java_lang_VMThrowable_fillInStackTrace(JNIEnv *env, jclass clazz, jobject t) +{ + java_handle_t* h; + java_handle_bytearray_t* ba; + + h = native_new_and_init(class_java_lang_VMThrowable); + + if (h == NULL) + return NULL; + + java_lang_VMThrowable vmt(h); + + ba = stacktrace_get_current(); + + if (ba == NULL) + return NULL; + + vmt.set_vmdata(ba); + + return (jobject) vmt.get_handle(); +} + + +/* + * Class: java/lang/VMThrowable + * Method: getStackTrace + * Signature: (Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_VMThrowable_getStackTrace(JNIEnv *env, jobject _this, jobject t) +{ + java_lang_VMThrowable vmt(_this); + + // Get the stacktrace from the VMThrowable object. + + java_handle_bytearray_t* ba = vmt.get_vmdata(); + + // XXX Critical GC section? + stacktrace_t* st = (stacktrace_t*) LLNI_array_data(ba); + + assert(st != NULL); + + stacktrace_entry_t* ste = st->entries; + + /* Create the stacktrace element array. */ + + java_handle_objectarray_t* oa = builtin_anewarray(st->length, class_java_lang_StackTraceElement); + + if (oa == NULL) + return NULL; + + for (int i = 0; i < st->length; i++, ste++) { + /* Get the codeinfo and methodinfo. */ + + codeinfo* code = ste->code; + methodinfo* m = code->m; + + /* Get filename. */ + + java_handle_t* filename; + + if (!(m->flags & ACC_NATIVE)) { + if (m->clazz->sourcefile) + filename = javastring_new(m->clazz->sourcefile); + else + filename = NULL; + } + else + filename = NULL; + + /* get line number */ + + int32_t linenumber; + + if (m->flags & ACC_NATIVE) { + linenumber = -1; + } + else { + /* FIXME The linenumbertable_linenumber_for_pc could + change the methodinfo pointer when hitting an inlined + method. */ + + linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc); + linenumber = (linenumber == 0) ? -1 : linenumber; + } + + /* get declaring class name */ + + java_handle_t* declaringclass = class_get_classname(m->clazz); + + /* allocate a new stacktrace element */ + + java_handle_t* h = builtin_new(class_java_lang_StackTraceElement); + + if (h == NULL) + return NULL; + + java_lang_StackTraceElement ste(h, filename, linenumber, declaringclass, javastring_new(m->name), ((m->flags & ACC_NATIVE) ? 1 : 0)); + + array_objectarray_element_set(oa, i, ste.get_handle()); + } + + return (jobjectArray) oa; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "fillInStackTrace", (char*) "(Ljava/lang/Throwable;)Ljava/lang/VMThrowable;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_fillInStackTrace }, + { (char*) "getStackTrace", (char*) "(Ljava/lang/Throwable;)[Ljava/lang/StackTraceElement;", (void*) (uintptr_t) &Java_java_lang_VMThrowable_getStackTrace }, +}; + + +/* _Jv_java_lang_VMThrowable_init ********************************************** + + Register native functions. + +*******************************************************************************/ + +extern "C" { +void _Jv_java_lang_VMThrowable_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/VMThrowable"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c b/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c index 62e1a8ff8..b92404a43 100644 --- a/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c +++ b/src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c @@ -1,9 +1,7 @@ -/* src/native/vm/gnu/java_lang_management_VMManagementFactory.c +/* src/native/vm/gnuclasspath/java_lang_management_VMManagementFactory.c - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -31,41 +29,17 @@ #include "vm/types.h" -#include "native/jni.h" +#include "native/jni.hpp" #include "native/native.h" -#include "native/include/java_lang_management_VMManagementFactory.h" +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_management_VMManagementFactory.h" +#endif #include "toolbox/logging.h" -#include "vm/builtin.h" - -#include "vmcore/class.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getMemoryPoolNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames }, - { "getMemoryManagerNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames }, - { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void *) (ptrint) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames }, -}; - - -/* _Jv_java_lang_management_VMManagementFactory_init *************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_management_VMManagementFactory_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/management/VMManagementFactory"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} +#include "vm/jit/builtin.hpp" +#include "vm/globals.hpp" /* @@ -73,7 +47,7 @@ void _Jv_java_lang_management_VMManagementFactory_init(void) * Method: getMemoryPoolNames * Signature: ()[Ljava/lang/String; */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz) +JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getMemoryPoolNames(JNIEnv *env, jclass clazz) { java_handle_objectarray_t *oa; @@ -90,7 +64,7 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagem * Method: getMemoryManagerNames * Signature: ()[Ljava/lang/String; */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz) +JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getMemoryManagerNames(JNIEnv *env, jclass clazz) { java_handle_objectarray_t *oa; @@ -107,7 +81,7 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagem * Method: getGarbageCollectorNames * Signature: ()[Ljava/lang/String; */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz) +JNIEXPORT jobjectArray JNICALL Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames(JNIEnv *env, jclass clazz) { java_handle_objectarray_t *oa; @@ -119,6 +93,31 @@ JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_management_VMManagem } +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { "getMemoryPoolNames", "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getMemoryPoolNames }, + { "getMemoryManagerNames", "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getMemoryManagerNames }, + { "getGarbageCollectorNames", "()[Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames }, +}; + + +/* _Jv_java_lang_management_VMManagementFactory_init *************************** + + Register native functions. + +*******************************************************************************/ + +void _Jv_java_lang_management_VMManagementFactory_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/management/VMManagementFactory"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c deleted file mode 100644 index db90cf975..000000000 --- a/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.c +++ /dev/null @@ -1,275 +0,0 @@ -/* src/native/vm/gnu/java_lang_reflect_VMConstructor.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#if defined(ENABLE_ANNOTATIONS) -#include "vm/vm.h" -#include "vm/exceptions.h" -#endif - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" - -#if defined(ENABLE_ANNOTATIONS) -# include "native/include/java_util_Map.h" -# include "native/include/sun_reflect_ConstantPool.h" -#endif - -#include "native/include/java_lang_reflect_Constructor.h" -#include "native/include/java_lang_reflect_VMConstructor.h" - -#include "native/vm/reflect.h" - -#include "vm/stringlocal.h" - -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getModifiersInternal", "()I", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal }, - { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes }, - { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes }, - { "construct", "([Ljava/lang/Object;)Ljava/lang/Object;", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_construct }, - { "getSignature", "()Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getSignature }, -#if defined(ENABLE_ANNOTATIONS) - { "declaredAnnotations", "()Ljava/util/Map;", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations }, - { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;", (void *) (intptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations }, -#endif -}; - - -/* _Jv_java_lang_reflect_VMConstructor_init ************************************ - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_reflect_VMConstructor_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/reflect/VMConstructor"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/reflect/VMConstructor - * Method: getModifiersInternal - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMConstructor *this) -{ - classinfo *c; - methodinfo *m; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot, slot); - - m = &(c->methods[slot]); - - return m->flags; -} - - -/* - * Class: java/lang/reflect/VMConstructor - * Method: getParameterTypes - * Signature: ()[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this) -{ - classinfo *c; - methodinfo *m; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot, slot); - - m = &(c->methods[slot]); - - return method_get_parametertypearray(m); -} - - -/* - * Class: java/lang/reflect/VMConstructor - * Method: getExceptionTypes - * Signature: ()[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMConstructor *this) -{ - classinfo *c; - methodinfo *m; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot, slot); - - m = &(c->methods[slot]); - - return method_get_exceptionarray(m); -} - - -/* - * Class: java/lang/reflect/VMConstructor - * Method: construct - * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, java_lang_reflect_VMConstructor *this, java_handle_objectarray_t *args) -{ - classinfo *c; - int32_t slot; - java_lang_reflect_Constructor *rc; - int32_t override; - methodinfo *m; - java_handle_t *o; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot, slot); - - LLNI_field_get_ref(this, cons, rc); - LLNI_field_get_val(rc, flag, override); - - m = &(c->methods[slot]); - - o = reflect_constructor_newinstance(m, args, override); - - return (java_lang_Object *) o; -} - - -/* - * Class: java/lang/reflect/VMConstructor - * Method: getSignature - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, java_lang_reflect_VMConstructor *this) -{ - classinfo *c; - methodinfo *m; - java_handle_t *o; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot, slot); - - m = &(c->methods[slot]); - - if (m->signature == NULL) - return NULL; - - o = javastring_new(m->signature); - - /* In error case o is NULL. */ - - return (java_lang_String *) o; -} - - -#if defined(ENABLE_ANNOTATIONS) -/* - * Class: java/lang/reflect/VMConstructor - * Method: declaredAnnotations - * Signature: ()Ljava/util/Map; - * - * Parses the annotations (if they aren't parsed yet) and stores them into - * the declaredAnnotations map and return this map. - */ -JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this) -{ - java_util_Map *declaredAnnotations = NULL; /* parsed annotations */ - java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ - java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */ - classinfo *referer = NULL; /* class, which calles the annotation parser */ - /* (for the parameter 'referer' of vm_call_method()) */ - - LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations); - - /* are the annotations parsed yet? */ - if (declaredAnnotations == NULL) { - LLNI_field_get_ref(this, annotations, annotations); - LLNI_field_get_ref(this, clazz, declaringClass); - LLNI_class_get(this, referer); - - declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer); - - LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations); - } - - return declaredAnnotations; -} - - -/* - * Class: java/lang/reflect/VMConstructor - * Method: getParameterAnnotations - * Signature: ()[[Ljava/lang/annotation/Annotation; - * - * Parses the parameter annotations and returns them in an 2 dimensional array. - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMConstructor *this) -{ - java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */ - int32_t slot = -1; /* slot of the method */ - java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */ - classinfo *referer = NULL; /* class, which calles the annotation parser */ - /* (for the parameter 'referer' of vm_call_method()) */ - - LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations); - LLNI_field_get_val(this, slot, slot); - LLNI_field_get_ref(this, clazz, declaringClass); - LLNI_class_get(this, referer); - - return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer); -} -#endif - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp b/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp new file mode 100644 index 000000000..ffb0bb737 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp @@ -0,0 +1,230 @@ +/* src/native/vm/gnuclasspath/java_lang_reflect_VMConstructor.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_reflect_VMConstructor.h" +#endif + +#include "native/vm/reflection.hpp" + +#include "vm/javaobjects.hpp" +#include "vm/string.hpp" +#include "vm/utf8.h" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/reflect/VMConstructor + * Method: getModifiersInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_reflect_VMConstructor_getModifiersInternal(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMConstructor rvmc(_this); + methodinfo* m = rvmc.get_method(); + return m->flags; +} + + +/* + * Class: java/lang/reflect/VMConstructor + * Method: getParameterTypes + * Signature: ()[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterTypes(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMConstructor rvmc(_this); + methodinfo* m = rvmc.get_method(); + + java_handle_objectarray_t* hoa = method_get_parametertypearray(m); + + return (jobjectArray) hoa; +} + + +/* + * Class: java/lang/reflect/VMConstructor + * Method: getExceptionTypes + * Signature: ()[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getExceptionTypes(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMConstructor rvmc(_this); + methodinfo* m = rvmc.get_method(); + + java_handle_objectarray_t* hoa = method_get_exceptionarray(m); + + return (jobjectArray) hoa; +} + + +/* + * Class: java/lang/reflect/VMConstructor + * Method: construct + * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_construct(JNIEnv *env, jobject _this, jobjectArray args) +{ + java_lang_reflect_VMConstructor jlrvmc(_this); + java_lang_reflect_Constructor jlrc(jlrvmc.get_cons()); + + java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args); + + return (jobject) o; +} + + +/* + * Class: java/lang/reflect/VMConstructor + * Method: getSignature + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMConstructor_getSignature(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMConstructor rvmc(_this); + methodinfo* m = rvmc.get_method(); + java_handle_t *o; + + if (m->signature == NULL) + return NULL; + + o = javastring_new(m->signature); + + /* In error case o is NULL. */ + + return (jstring) o; +} + + +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/reflect/VMConstructor + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; + * + * Parses the annotations (if they aren't parsed yet) and stores them into + * the declaredAnnotations map and return this map. + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMConstructor_declaredAnnotations(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMConstructor rvmc(_this); + + java_handle_t* declaredAnnotations = rvmc.get_declaredAnnotations(); + + /* are the annotations parsed yet? */ + if (declaredAnnotations == NULL) { + java_handle_bytearray_t* annotations = rvmc.get_annotations(); + classinfo* declaringClass = rvmc.get_clazz(); + classinfo* referer = rvmc.get_Class(); + + declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer); + + rvmc.set_declaredAnnotations(declaredAnnotations); + } + + return (jobject) declaredAnnotations; +} + + +/* + * Class: java/lang/reflect/VMConstructor + * Method: getParameterAnnotations + * Signature: ()[[Ljava/lang/annotation/Annotation; + * + * Parses the parameter annotations and returns them in an 2 dimensional array. + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMConstructor_getParameterAnnotations(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMConstructor rvmc(_this); + + java_handle_bytearray_t* parameterAnnotations = rvmc.get_parameterAnnotations(); + methodinfo* m = rvmc.get_method(); + classinfo* referer = rvmc.get_Class(); + + java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer); + + return (jobjectArray) oa; +} +#endif + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getModifiersInternal }, + { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterTypes }, + { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getExceptionTypes }, + { (char*) "construct", (char*) "([Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_construct }, + { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getSignature }, +#if defined(ENABLE_ANNOTATIONS) + { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_declaredAnnotations }, + { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMConstructor_getParameterAnnotations }, +#endif +}; + + +/* _Jv_java_lang_reflect_VMConstructor_init ************************************ + + Register native functions. + +*******************************************************************************/ + +extern "C" { +void _Jv_java_lang_reflect_VMConstructor_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/reflect/VMConstructor"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMField.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMField.c deleted file mode 100644 index b3da6215e..000000000 --- a/src/native/vm/gnuclasspath/java_lang_reflect_VMField.c +++ /dev/null @@ -1,1345 +0,0 @@ -/* src/native/vm/gnu/java_lang_reflect_VMField.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Boolean.h" -#include "native/include/java_lang_Byte.h" -#include "native/include/java_lang_Character.h" -#include "native/include/java_lang_Short.h" -#include "native/include/java_lang_Integer.h" -#include "native/include/java_lang_Long.h" -#include "native/include/java_lang_Float.h" -#include "native/include/java_lang_Double.h" -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_String.h" - -#include "native/include/java_lang_reflect_Field.h" -#include "native/include/java_lang_reflect_VMField.h" - -#if defined(ENABLE_ANNOTATIONS) -#include "native/include/java_util_Map.h" -#include "native/include/sun_reflect_ConstantPool.h" -#include "native/vm/reflect.h" -#endif - -#include "vm/access.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/initialize.h" -#include "vm/primitive.h" -#include "vm/resolve.h" -#include "vm/stringlocal.h" - -#include "vm/jit/stacktrace.h" - -#include "vmcore/loader.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getModifiersInternal", "()I", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal }, - { "getType", "()Ljava/lang/Class;", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getType }, - { "get", "(Ljava/lang/Object;)Ljava/lang/Object;", (void *) (intptr_t) &Java_java_lang_reflect_VMField_get }, - { "getBoolean", "(Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getBoolean }, - { "getByte", "(Ljava/lang/Object;)B", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getByte }, - { "getChar", "(Ljava/lang/Object;)C", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getChar }, - { "getShort", "(Ljava/lang/Object;)S", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getShort }, - { "getInt", "(Ljava/lang/Object;)I", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getInt }, - { "getLong", "(Ljava/lang/Object;)J", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getLong }, - { "getFloat", "(Ljava/lang/Object;)F", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getFloat }, - { "getDouble", "(Ljava/lang/Object;)D", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getDouble }, - { "set", "(Ljava/lang/Object;Ljava/lang/Object;)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_set }, - { "setBoolean", "(Ljava/lang/Object;Z)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setBoolean }, - { "setByte", "(Ljava/lang/Object;B)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setByte }, - { "setChar", "(Ljava/lang/Object;C)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setChar }, - { "setShort", "(Ljava/lang/Object;S)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setShort }, - { "setInt", "(Ljava/lang/Object;I)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setInt }, - { "setLong", "(Ljava/lang/Object;J)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setLong }, - { "setFloat", "(Ljava/lang/Object;F)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setFloat }, - { "setDouble", "(Ljava/lang/Object;D)V", (void *) (intptr_t) &Java_java_lang_reflect_VMField_setDouble }, - { "getSignature", "()Ljava/lang/String;", (void *) (intptr_t) &Java_java_lang_reflect_VMField_getSignature }, -#if defined(ENABLE_ANNOTATIONS) - { "declaredAnnotations", "()Ljava/util/Map;", (void *) (intptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations }, -#endif -}; - - -/* _Jv_java_lang_reflect_VMField_init ****************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_reflect_VMField_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/reflect/VMField"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* _field_access_check ********************************************************* - - Checks if the field can be accessed. - - RETURN VALUE: - true......field can be accessed, or - false.....otherwise (maybe an Exception was thrown). - -*******************************************************************************/ - -static bool _field_access_check(java_lang_reflect_VMField *this, - fieldinfo *f, classinfo *c, java_handle_t *o) -{ - java_lang_reflect_Field *rf; - int32_t flag; - - /* check if we should bypass security checks (AccessibleObject) */ - - LLNI_field_get_ref(this, f, rf); - LLNI_field_get_val(rf, flag, flag); - - if (flag == false) { - /* This function is always called like this: - [0] java.lang.reflect.VMField.xxx (Native Method) - [1] java.lang.reflect.Field.xxx - [2] - */ - - if (!access_check_field(f, 2)) - return false; - } - - /* some general checks */ - - if (f->flags & ACC_STATIC) { - /* initialize class if required */ - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return false; - - /* everything is ok */ - - return true; - } - else { - /* obj is required for not-static fields */ - - if (o == NULL) { - exceptions_throw_nullpointerexception(); - return false; - } - - if (builtin_instanceof(o, c)) - return true; - } - - /* exception path */ - - exceptions_throw_illegalargumentexception(); - return false; -} - - -/* _field_get_type ************************************************************* - - Returns the content of the given field. - -*******************************************************************************/ - -#define _FIELD_GET_TYPE(name, type, uniontype) \ -static inline type _field_get_##name(fieldinfo *f, java_lang_Object *o) \ -{ \ - type ret; \ - if (f->flags & ACC_STATIC) { \ - ret = f->value->uniontype; \ - } else { \ - LLNI_CRITICAL_START; \ - ret = *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset); \ - LLNI_CRITICAL_END; \ - } \ - return ret; \ -} - -static inline java_handle_t *_field_get_handle(fieldinfo *f, java_lang_Object *o) -{ - java_object_t *obj; - java_handle_t *hdl; - - LLNI_CRITICAL_START; - - if (f->flags & ACC_STATIC) { - obj = f->value->a; - } else { - obj = *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset); - } - - hdl = LLNI_WRAP(obj); - - LLNI_CRITICAL_END; - - return hdl; -} - -_FIELD_GET_TYPE(int, int32_t, i) -_FIELD_GET_TYPE(long, int64_t, l) -_FIELD_GET_TYPE(float, float, f) -_FIELD_GET_TYPE(double, double, d) - - -/* _field_set_type ************************************************************* - - Sets the content of the given field to the given value. - -*******************************************************************************/ - -#define _FIELD_SET_TYPE(name, type, uniontype) \ -static inline void _field_set_##name(fieldinfo *f, java_lang_Object *o, type value) \ -{ \ - if (f->flags & ACC_STATIC) { \ - f->value->uniontype = value; \ - } else { \ - LLNI_CRITICAL_START; \ - *(type *) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = value; \ - LLNI_CRITICAL_END; \ - } \ -} - -static inline void _field_set_handle(fieldinfo *f, java_lang_Object *o, java_handle_t *value) -{ - LLNI_CRITICAL_START; - - if (f->flags & ACC_STATIC) { - f->value->a = LLNI_DIRECT(value); - } else { - *(java_object_t **) (((intptr_t) LLNI_DIRECT(o)) + f->offset) = LLNI_DIRECT(value); - } - - LLNI_CRITICAL_END; -} - -_FIELD_SET_TYPE(int, int32_t, i) -_FIELD_SET_TYPE(long, int64_t, l) -_FIELD_SET_TYPE(float, float, f) -_FIELD_SET_TYPE(double, double, d) - - -/* - * Class: java/lang/reflect/VMField - * Method: getModifiersInternal - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMField *this) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &(c->fields[slot]); - - return f->flags; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getType - * Signature: ()Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, java_lang_reflect_VMField *this) -{ - classinfo *c; - typedesc *desc; - classinfo *ret; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - desc = c->fields[slot].parseddesc; - - if (desc == NULL) - return NULL; - - if (!resolve_class_from_typedesc(desc, true, false, &ret)) - return NULL; - - return LLNI_classinfo_wrap(ret); -} - - -/* - * Class: java/lang/reflect/VMField - * Method: get - * Signature: (Ljava/lang/Object;)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - imm_union value; - java_handle_t *object; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return NULL; - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BOOLEAN: - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - value.i = _field_get_int(f, o); - break; - - case PRIMITIVETYPE_LONG: - value.l = _field_get_long(f, o); - break; - - case PRIMITIVETYPE_FLOAT: - value.f = _field_get_float(f, o); - break; - - case PRIMITIVETYPE_DOUBLE: - value.d = _field_get_double(f, o); - break; - - case TYPE_ADR: - return (java_lang_Object *) _field_get_handle(f, o); - } - - /* Now box the primitive types. */ - - object = primitive_box(f->parseddesc->decltype, value); - - return (java_lang_Object *) object; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getBoolean - * Signature: (Ljava/lang/Object;)Z - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BOOLEAN: - return (int32_t) _field_get_int(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getByte - * Signature: (Ljava/lang/Object;)B - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - return (int32_t) _field_get_int(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getChar - * Signature: (Ljava/lang/Object;)C - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_CHAR: - return (int32_t) _field_get_int(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getShort - * Signature: (Ljava/lang/Object;)S - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_SHORT: - return (int32_t) _field_get_int(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getInt - * Signature: (Ljava/lang/Object;)I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - return (int32_t) _field_get_int(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getLong - * Signature: (Ljava/lang/Object;)J - */ -JNIEXPORT int64_t JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - return (int64_t) _field_get_int(f, o); - case PRIMITIVETYPE_LONG: - return (int64_t) _field_get_long(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getFloat - * Signature: (Ljava/lang/Object;)F - */ -JNIEXPORT float JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - return (float) _field_get_int(f, o); - case PRIMITIVETYPE_LONG: - return (float) _field_get_long(f, o); - case PRIMITIVETYPE_FLOAT: - return (float) _field_get_float(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getDouble - * Signature: (Ljava/lang/Object;)D - */ -JNIEXPORT double JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , java_lang_reflect_VMField *this, java_lang_Object *o) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return 0; - - /* check the field type and return the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - return (double) _field_get_int(f, o); - case PRIMITIVETYPE_LONG: - return (double) _field_get_long(f, o); - case PRIMITIVETYPE_FLOAT: - return (double) _field_get_float(f, o); - case PRIMITIVETYPE_DOUBLE: - return (double) _field_get_double(f, o); - default: - exceptions_throw_illegalargumentexception(); - return 0; - } -} - - -/* - * Class: java/lang/reflect/VMField - * Method: set - * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, java_lang_Object *value) -{ - classinfo *sc; - classinfo *dc; - fieldinfo *sf; - fieldinfo *df; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, dc); - LLNI_field_get_val(this, slot , slot); - df = &dc->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, df, dc, (java_handle_t *) o)) - return; - - /* get the source classinfo from the object */ - - if (value == NULL) - sc = NULL; - else - LLNI_class_get(value, sc); - - /* The fieldid is used to set the new value, for primitive - types the value has to be retrieved from the wrapping - object */ - - switch (df->parseddesc->decltype) { - case PRIMITIVETYPE_BOOLEAN: { - int32_t val; - - /* determine the field to read the value */ - - if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_Z))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BOOLEAN: - LLNI_field_get_val((java_lang_Boolean *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_int(df, o, val); - return; - } - - case PRIMITIVETYPE_BYTE: { - int32_t val; - - if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - LLNI_field_get_val((java_lang_Byte *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_int(df, o, val); - return; - } - - case PRIMITIVETYPE_CHAR: { - int32_t val; - - if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_CHAR: - LLNI_field_get_val((java_lang_Character *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_int(df, o, val); - return; - } - - case PRIMITIVETYPE_SHORT: { - int32_t val; - - /* get field only by name, it can be one of B, S */ - - if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - LLNI_field_get_val((java_lang_Byte *) value, value, val); - break; - case PRIMITIVETYPE_SHORT: - LLNI_field_get_val((java_lang_Short *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_int(df, o, val); - return; - } - - case PRIMITIVETYPE_INT: { - int32_t val; - - /* get field only by name, it can be one of B, S, C, I */ - - if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - LLNI_field_get_val((java_lang_Byte *) value, value, val); - break; - case PRIMITIVETYPE_CHAR: - LLNI_field_get_val((java_lang_Character *) value, value, val); - break; - case PRIMITIVETYPE_SHORT: - LLNI_field_get_val((java_lang_Short *) value, value, val); - break; - case PRIMITIVETYPE_INT: - LLNI_field_get_val((java_lang_Integer *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_int(df, o, val); - return; - } - - case PRIMITIVETYPE_LONG: { - int64_t val; - - /* get field only by name, it can be one of B, S, C, I, J */ - - if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - LLNI_field_get_val((java_lang_Byte *) value, value, val); - break; - case PRIMITIVETYPE_CHAR: - LLNI_field_get_val((java_lang_Character *) value, value, val); - break; - case PRIMITIVETYPE_SHORT: - LLNI_field_get_val((java_lang_Short *) value, value, val); - break; - case PRIMITIVETYPE_INT: - LLNI_field_get_val((java_lang_Integer *) value, value, val); - break; - case PRIMITIVETYPE_LONG: - LLNI_field_get_val((java_lang_Long *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_long(df, o, val); - return; - } - - case PRIMITIVETYPE_FLOAT: { - float val; - - /* get field only by name, it can be one of B, S, C, I, J, F */ - - if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - LLNI_field_get_val((java_lang_Byte *) value, value, val); - break; - case PRIMITIVETYPE_CHAR: - LLNI_field_get_val((java_lang_Character *) value, value, val); - break; - case PRIMITIVETYPE_SHORT: - LLNI_field_get_val((java_lang_Short *) value, value, val); - break; - case PRIMITIVETYPE_INT: - LLNI_field_get_val((java_lang_Integer *) value, value, val); - break; - case PRIMITIVETYPE_LONG: - LLNI_field_get_val((java_lang_Long *) value, value, val); - break; - case PRIMITIVETYPE_FLOAT: - LLNI_field_get_val((java_lang_Float *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_float(df, o, val); - return; - } - - case PRIMITIVETYPE_DOUBLE: { - double val; - - /* get field only by name, it can be one of B, S, C, I, J, F, D */ - - if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) - break; - - switch (sf->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - LLNI_field_get_val((java_lang_Byte *) value, value, val); - break; - case PRIMITIVETYPE_CHAR: - LLNI_field_get_val((java_lang_Character *) value, value, val); - break; - case PRIMITIVETYPE_SHORT: - LLNI_field_get_val((java_lang_Short *) value, value, val); - break; - case PRIMITIVETYPE_INT: - LLNI_field_get_val((java_lang_Integer *) value, value, val); - break; - case PRIMITIVETYPE_LONG: - LLNI_field_get_val((java_lang_Long *) value, value, val); - break; - case PRIMITIVETYPE_FLOAT: - LLNI_field_get_val((java_lang_Float *) value, value, val); - break; - case PRIMITIVETYPE_DOUBLE: - LLNI_field_get_val((java_lang_Double *) value, value, val); - break; - default: - exceptions_throw_illegalargumentexception(); - return; - } - - _field_set_double(df, o, val); - return; - } - - case TYPE_ADR: - /* check if value is an instance of the destination class */ - - /* XXX TODO */ - /* if (!builtin_instanceof((java_handle_t *) value, df->class)) */ - /* break; */ - - _field_set_handle(df, o, (java_handle_t *) value); - return; - } - - /* raise exception */ - - exceptions_throw_illegalargumentexception(); -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setBoolean - * Signature: (Ljava/lang/Object;Z)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BOOLEAN: - _field_set_int(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setByte - * Signature: (Ljava/lang/Object;B)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - _field_set_int(f, o, value); - break; - case PRIMITIVETYPE_LONG: - _field_set_long(f, o, value); - break; - case PRIMITIVETYPE_FLOAT: - _field_set_float(f, o, value); - break; - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setChar - * Signature: (Ljava/lang/Object;C)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_INT: - _field_set_int(f, o, value); - break; - case PRIMITIVETYPE_LONG: - _field_set_long(f, o, value); - break; - case PRIMITIVETYPE_FLOAT: - _field_set_float(f, o, value); - break; - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setShort - * Signature: (Ljava/lang/Object;S)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - _field_set_int(f, o, value); - break; - case PRIMITIVETYPE_LONG: - _field_set_long(f, o, value); - break; - case PRIMITIVETYPE_FLOAT: - _field_set_float(f, o, value); - break; - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setInt - * Signature: (Ljava/lang/Object;I)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int32_t value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_INT: - _field_set_int(f, o, value); - break; - case PRIMITIVETYPE_LONG: - _field_set_long(f, o, value); - break; - case PRIMITIVETYPE_FLOAT: - _field_set_float(f, o, value); - break; - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setLong - * Signature: (Ljava/lang/Object;J)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, int64_t value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_LONG: - _field_set_long(f, o, value); - break; - case PRIMITIVETYPE_FLOAT: - _field_set_float(f, o, value); - break; - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setFloat - * Signature: (Ljava/lang/Object;F)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, float value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_FLOAT: - _field_set_float(f, o, value); - break; - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: setDouble - * Signature: (Ljava/lang/Object;D)V - */ -JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, java_lang_reflect_VMField *this, java_lang_Object *o, double value) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - /* check if the field can be accessed */ - - if (!_field_access_check(this, f, c, (java_handle_t *) o)) - return; - - /* check the field type and set the value */ - - switch (f->parseddesc->decltype) { - case PRIMITIVETYPE_DOUBLE: - _field_set_double(f, o, value); - break; - default: - exceptions_throw_illegalargumentexception(); - } - - return; -} - - -/* - * Class: java/lang/reflect/VMField - * Method: getSignature - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, java_lang_reflect_VMField* this) -{ - classinfo *c; - fieldinfo *f; - java_handle_t *o; - int32_t slot; - - /* get the class and the field */ - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - f = &c->fields[slot]; - - if (f->signature == NULL) - return NULL; - - o = javastring_new(f->signature); - - /* in error case o is NULL */ - - return (java_lang_String *) o; -} - - -#if defined(ENABLE_ANNOTATIONS) -/* - * Class: java/lang/reflect/VMField - * Method: declaredAnnotations - * Signature: ()Ljava/util/Map; - */ -JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMField *this) -{ - java_util_Map *declaredAnnotations = NULL; /* parsed annotations */ - java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ - java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */ - classinfo *referer = NULL; /* class, which calles the annotation parser */ - /* (for the parameter 'referer' of vm_call_method()) */ - - LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations); - - /* are the annotations parsed yet? */ - if (declaredAnnotations == NULL) { - LLNI_field_get_ref(this, annotations, annotations); - LLNI_field_get_ref(this, clazz, declaringClass); - LLNI_class_get(this, referer); - - declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer); - - LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations); - } - - return declaredAnnotations; -} -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp b/src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp new file mode 100644 index 000000000..d595cfc45 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp @@ -0,0 +1,1212 @@ +/* src/native/vm/gnuclasspath/java_lang_reflect_VMField.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_reflect_VMField.h" +#endif + +#if defined(ENABLE_ANNOTATIONS) +// REMOVEME +# include "native/vm/reflection.hpp" +#endif + +#include "vm/access.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/loader.hpp" +#include "vm/primitive.hpp" +#include "vm/resolve.h" +#include "vm/string.hpp" +#include "vm/utf8.h" + + +/* _field_access_check ********************************************************* + + Checks if the field can be accessed. + + RETURN VALUE: + true......field can be accessed, or + false.....otherwise (maybe an Exception was thrown). + +*******************************************************************************/ + +static bool _field_access_check(const java_lang_reflect_VMField& rvmf, fieldinfo *f, java_handle_t *o) +{ + // Check if we should bypass security checks (AccessibleObject). + + java_lang_reflect_Field rf(rvmf.get_f()); + int32_t override = rf.get_flag(); + + if (override == false) { + /* This function is always called like this: + [0] java.lang.reflect.VMField.xxx (Native Method) + [1] java.lang.reflect.Field.xxx + [2] + */ + + if (!access_check_field(f, 2)) + return false; + } + + /* some general checks */ + + if (f->flags & ACC_STATIC) { + /* initialize class if required */ + + if (!(f->clazz->state & CLASS_INITIALIZED)) + if (!initialize_class(f->clazz)) + return false; + + /* everything is ok */ + + return true; + } + else { + /* obj is required for not-static fields */ + + if (o == NULL) { + exceptions_throw_nullpointerexception(); + return false; + } + + if (builtin_instanceof(o, f->clazz)) + return true; + } + + /* exception path */ + + exceptions_throw_illegalargumentexception(); + return false; +} + + +/* _field_get_type ************************************************************* + + Returns the content of the given field. + +*******************************************************************************/ + +#define _FIELD_GET_TYPE(name, type, uniontype) \ +static inline type _field_get_##name(fieldinfo *f, java_handle_t* h) \ +{ \ + type ret; \ + if (f->flags & ACC_STATIC) { \ + ret = f->value->uniontype; \ + } else { \ + LLNI_CRITICAL_START; \ + ret = *(type *) (((intptr_t) LLNI_DIRECT(h)) + f->offset); \ + LLNI_CRITICAL_END; \ + } \ + return ret; \ +} + +static inline java_handle_t *_field_get_handle(fieldinfo *f, java_handle_t* h) +{ + java_object_t* result; + java_handle_t* hresult; + + LLNI_CRITICAL_START; + + if (f->flags & ACC_STATIC) { + result = (java_object_t*) f->value->a; + } else { + result = *(java_object_t**) (((intptr_t) LLNI_DIRECT(h)) + f->offset); + } + + hresult = LLNI_WRAP(result); + + LLNI_CRITICAL_END; + + return hresult; +} + +_FIELD_GET_TYPE(int, int32_t, i) +_FIELD_GET_TYPE(long, int64_t, l) +_FIELD_GET_TYPE(float, float, f) +_FIELD_GET_TYPE(double, double, d) + + +/* _field_set_type ************************************************************* + + Sets the content of the given field to the given value. + +*******************************************************************************/ + +#define _FIELD_SET_TYPE(name, type, uniontype) \ +static inline void _field_set_##name(fieldinfo* f, java_handle_t* h, type value) \ +{ \ + if (f->flags & ACC_STATIC) { \ + f->value->uniontype = value; \ + } else { \ + LLNI_CRITICAL_START; \ + *(type *) (((intptr_t) LLNI_DIRECT(h)) + f->offset) = value; \ + LLNI_CRITICAL_END; \ + } \ +} + +static inline void _field_set_handle(fieldinfo* f, java_handle_t* h, java_handle_t* hvalue) +{ + LLNI_CRITICAL_START; + + if (f->flags & ACC_STATIC) { + f->value->a = LLNI_DIRECT(hvalue); + } else { + *(java_object_t**) (((intptr_t) LLNI_DIRECT(h)) + f->offset) = LLNI_DIRECT(hvalue); + } + + LLNI_CRITICAL_END; +} + +_FIELD_SET_TYPE(int, int32_t, i) +_FIELD_SET_TYPE(long, int64_t, l) +_FIELD_SET_TYPE(float, float, f) +_FIELD_SET_TYPE(double, double, d) + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/reflect/VMField + * Method: getModifiersInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_reflect_VMField_getModifiersInternal(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + return f->flags; +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getType + * Signature: ()Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_reflect_VMField_getType(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + classinfo *ret; + + typedesc* desc = f->parseddesc; + + if (desc == NULL) + return NULL; + + if (!resolve_class_from_typedesc(desc, true, false, &ret)) + return NULL; + + return (jclass) LLNI_classinfo_wrap(ret); +} + + +/* + * Class: java/lang/reflect/VMField + * Method: get + * Signature: (Ljava/lang/Object;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMField_get(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return NULL; + + imm_union value; + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BOOLEAN: + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + value.i = _field_get_int(f, ho); + break; + + case PRIMITIVETYPE_LONG: + value.l = _field_get_long(f, ho); + break; + + case PRIMITIVETYPE_FLOAT: + value.f = _field_get_float(f, ho); + break; + + case PRIMITIVETYPE_DOUBLE: + value.d = _field_get_double(f, ho); + break; + + case TYPE_ADR: + return (jobject) _field_get_handle(f, ho); + } + + /* Now box the primitive types. */ + + java_handle_t* object = Primitive::box(f->parseddesc->primitivetype, value); + + return (jobject) object; +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getBoolean + * Signature: (Ljava/lang/Object;)Z + */ +JNIEXPORT jboolean JNICALL Java_java_lang_reflect_VMField_getBoolean(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BOOLEAN: + return (int32_t) _field_get_int(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getByte + * Signature: (Ljava/lang/Object;)B + */ +JNIEXPORT jbyte JNICALL Java_java_lang_reflect_VMField_getByte(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + return (int32_t) _field_get_int(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getChar + * Signature: (Ljava/lang/Object;)C + */ +JNIEXPORT jchar JNICALL Java_java_lang_reflect_VMField_getChar(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_CHAR: + return (int32_t) _field_get_int(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getShort + * Signature: (Ljava/lang/Object;)S + */ +JNIEXPORT jshort JNICALL Java_java_lang_reflect_VMField_getShort(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_SHORT: + return (int32_t) _field_get_int(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getInt + * Signature: (Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_java_lang_reflect_VMField_getInt(JNIEnv *env , jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + return (int32_t) _field_get_int(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getLong + * Signature: (Ljava/lang/Object;)J + */ +JNIEXPORT jlong JNICALL Java_java_lang_reflect_VMField_getLong(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + return (int64_t) _field_get_int(f, ho); + case PRIMITIVETYPE_LONG: + return (int64_t) _field_get_long(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getFloat + * Signature: (Ljava/lang/Object;)F + */ +JNIEXPORT jfloat JNICALL Java_java_lang_reflect_VMField_getFloat(JNIEnv *env, jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + return (float) _field_get_int(f, ho); + case PRIMITIVETYPE_LONG: + return (float) _field_get_long(f, ho); + case PRIMITIVETYPE_FLOAT: + return (float) _field_get_float(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getDouble + * Signature: (Ljava/lang/Object;)D + */ +JNIEXPORT jdouble JNICALL Java_java_lang_reflect_VMField_getDouble(JNIEnv *env , jobject _this, jobject o) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return 0; + + /* check the field type and return the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + return (jdouble) _field_get_int(f, ho); + case PRIMITIVETYPE_LONG: + return (jdouble) _field_get_long(f, ho); + case PRIMITIVETYPE_FLOAT: + return (jdouble) _field_get_float(f, ho); + case PRIMITIVETYPE_DOUBLE: + return (jdouble) _field_get_double(f, ho); + default: + exceptions_throw_illegalargumentexception(); + return 0; + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: set + * Signature: (Ljava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_set(JNIEnv *env, jobject _this, jobject o, jobject value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* df = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + java_handle_t* hvalue = (java_handle_t*) value; + + classinfo *sc; + fieldinfo *sf; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, df, ho)) + return; + + /* get the source classinfo from the object */ + + if (hvalue == NULL) + sc = NULL; + else + LLNI_class_get(hvalue, sc); + + /* The fieldid is used to set the new value, for primitive + types the value has to be retrieved from the wrapping + object */ + + switch (df->parseddesc->primitivetype) { + case PRIMITIVETYPE_BOOLEAN: { + int32_t val; + + /* determine the field to read the value */ + + if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_Z))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BOOLEAN: + val = java_lang_Boolean(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_int(df, ho, val); + return; + } + + case PRIMITIVETYPE_BYTE: { + int32_t val; + + if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_B))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + val = java_lang_Byte(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_int(df, ho, val); + return; + } + + case PRIMITIVETYPE_CHAR: { + int32_t val; + + if ((sc == NULL) || !(sf = class_findfield(sc, utf_value, utf_C))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_CHAR: + val = java_lang_Character(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_int(df, ho, val); + return; + } + + case PRIMITIVETYPE_SHORT: { + int32_t val; + + /* get field only by name, it can be one of B, S */ + + if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + val = java_lang_Byte(hvalue).get_value(); + break; + case PRIMITIVETYPE_SHORT: + val = java_lang_Short(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_int(df, ho, val); + return; + } + + case PRIMITIVETYPE_INT: { + int32_t val; + + /* get field only by name, it can be one of B, S, C, I */ + + if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + val = java_lang_Byte(hvalue).get_value(); + break; + case PRIMITIVETYPE_CHAR: + val = java_lang_Character(hvalue).get_value(); + break; + case PRIMITIVETYPE_SHORT: + val = java_lang_Short(hvalue).get_value(); + break; + case PRIMITIVETYPE_INT: + val = java_lang_Integer(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_int(df, ho, val); + return; + } + + case PRIMITIVETYPE_LONG: { + int64_t val; + + /* get field only by name, it can be one of B, S, C, I, J */ + + if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + val = java_lang_Byte(hvalue).get_value(); + break; + case PRIMITIVETYPE_CHAR: + val = java_lang_Character(hvalue).get_value(); + break; + case PRIMITIVETYPE_SHORT: + val = java_lang_Short(hvalue).get_value(); + break; + case PRIMITIVETYPE_INT: + val = java_lang_Integer(hvalue).get_value(); + break; + case PRIMITIVETYPE_LONG: + val = java_lang_Long(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_long(df, ho, val); + return; + } + + case PRIMITIVETYPE_FLOAT: { + float val; + + /* get field only by name, it can be one of B, S, C, I, J, F */ + + if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + val = java_lang_Byte(hvalue).get_value(); + break; + case PRIMITIVETYPE_CHAR: + val = java_lang_Character(hvalue).get_value(); + break; + case PRIMITIVETYPE_SHORT: + val = java_lang_Short(hvalue).get_value(); + break; + case PRIMITIVETYPE_INT: + val = java_lang_Integer(hvalue).get_value(); + break; + case PRIMITIVETYPE_LONG: + val = java_lang_Long(hvalue).get_value(); + break; + case PRIMITIVETYPE_FLOAT: + val = java_lang_Float(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_float(df, ho, val); + return; + } + + case PRIMITIVETYPE_DOUBLE: { + double val; + + /* get field only by name, it can be one of B, S, C, I, J, F, D */ + + if ((sc == NULL) || !(sf = class_findfield_by_name(sc, utf_value))) + break; + + switch (sf->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + val = java_lang_Byte(hvalue).get_value(); + break; + case PRIMITIVETYPE_CHAR: + val = java_lang_Character(hvalue).get_value(); + break; + case PRIMITIVETYPE_SHORT: + val = java_lang_Short(hvalue).get_value(); + break; + case PRIMITIVETYPE_INT: + val = java_lang_Integer(hvalue).get_value(); + break; + case PRIMITIVETYPE_LONG: + val = java_lang_Long(hvalue).get_value(); + break; + case PRIMITIVETYPE_FLOAT: + val = java_lang_Float(hvalue).get_value(); + break; + case PRIMITIVETYPE_DOUBLE: + val = java_lang_Double(hvalue).get_value(); + break; + default: + exceptions_throw_illegalargumentexception(); + return; + } + + _field_set_double(df, ho, val); + return; + } + + case TYPE_ADR: + /* check if value is an instance of the destination class */ + + /* XXX TODO */ + /* if (!builtin_instanceof((java_handle_t *) value, df->class)) */ + /* break; */ + + _field_set_handle(df, ho, hvalue); + return; + } + + /* raise exception */ + + exceptions_throw_illegalargumentexception(); +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setBoolean + * Signature: (Ljava/lang/Object;Z)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setBoolean(JNIEnv *env, jobject _this, jobject o, jboolean value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BOOLEAN: + _field_set_int(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setByte + * Signature: (Ljava/lang/Object;B)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setByte(JNIEnv *env, jobject _this, jobject o, jbyte value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + _field_set_int(f, ho, value); + break; + case PRIMITIVETYPE_LONG: + _field_set_long(f, ho, value); + break; + case PRIMITIVETYPE_FLOAT: + _field_set_float(f, ho, value); + break; + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setChar + * Signature: (Ljava/lang/Object;C)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setChar(JNIEnv *env, jobject _this, jobject o, jchar value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_INT: + _field_set_int(f, ho, value); + break; + case PRIMITIVETYPE_LONG: + _field_set_long(f, ho, value); + break; + case PRIMITIVETYPE_FLOAT: + _field_set_float(f, ho, value); + break; + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setShort + * Signature: (Ljava/lang/Object;S)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setShort(JNIEnv *env, jobject _this, jobject o, jshort value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + _field_set_int(f, ho, value); + break; + case PRIMITIVETYPE_LONG: + _field_set_long(f, ho, value); + break; + case PRIMITIVETYPE_FLOAT: + _field_set_float(f, ho, value); + break; + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setInt + * Signature: (Ljava/lang/Object;I)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setInt(JNIEnv *env, jobject _this, jobject o, jint value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_INT: + _field_set_int(f, ho, value); + break; + case PRIMITIVETYPE_LONG: + _field_set_long(f, ho, value); + break; + case PRIMITIVETYPE_FLOAT: + _field_set_float(f, ho, value); + break; + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setLong + * Signature: (Ljava/lang/Object;J)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setLong(JNIEnv *env, jobject _this, jobject o, jlong value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_LONG: + _field_set_long(f, ho, value); + break; + case PRIMITIVETYPE_FLOAT: + _field_set_float(f, ho, value); + break; + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setFloat + * Signature: (Ljava/lang/Object;F)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setFloat(JNIEnv *env, jobject _this, jobject o, jfloat value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_FLOAT: + _field_set_float(f, ho, value); + break; + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: setDouble + * Signature: (Ljava/lang/Object;D)V + */ +JNIEXPORT void JNICALL Java_java_lang_reflect_VMField_setDouble(JNIEnv *env, jobject _this, jobject o, jdouble value) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + java_handle_t* ho = (java_handle_t*) o; + + /* check if the field can be accessed */ + + if (!_field_access_check(rvmf, f, ho)) + return; + + /* check the field type and set the value */ + + switch (f->parseddesc->primitivetype) { + case PRIMITIVETYPE_DOUBLE: + _field_set_double(f, ho, value); + break; + default: + exceptions_throw_illegalargumentexception(); + } +} + + +/* + * Class: java/lang/reflect/VMField + * Method: getSignature + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMField_getSignature(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMField rvmf(_this); + fieldinfo* f = rvmf.get_field(); + + if (f->signature == NULL) + return NULL; + + java_handle_t* o = javastring_new(f->signature); + + /* in error case o is NULL */ + + return (jstring) o; +} + + +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/reflect/VMField + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMField_declaredAnnotations(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMField rvmf(_this); + + java_handle_t* declaredAnnotations = rvmf.get_declaredAnnotations(); + + // Are the annotations parsed yet? + if (declaredAnnotations == NULL) { + java_handle_bytearray_t* annotations = rvmf.get_annotations(); + classinfo* declaringClass = rvmf.get_clazz(); + classinfo* referer = rvmf.get_Class(); + + declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer); + + rvmf.set_declaredAnnotations(declaredAnnotations); + } + + return (jobject) declaredAnnotations; +} +#endif + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static const JNINativeMethod methods[] = { + { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getModifiersInternal }, + { (char*) "getType", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getType }, + { (char*) "get", (char*) "(Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_get }, + { (char*) "getBoolean", (char*) "(Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getBoolean }, + { (char*) "getByte", (char*) "(Ljava/lang/Object;)B", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getByte }, + { (char*) "getChar", (char*) "(Ljava/lang/Object;)C", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getChar }, + { (char*) "getShort", (char*) "(Ljava/lang/Object;)S", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getShort }, + { (char*) "getInt", (char*) "(Ljava/lang/Object;)I", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getInt }, + { (char*) "getLong", (char*) "(Ljava/lang/Object;)J", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getLong }, + { (char*) "getFloat", (char*) "(Ljava/lang/Object;)F", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getFloat }, + { (char*) "getDouble", (char*) "(Ljava/lang/Object;)D", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getDouble }, + { (char*) "set", (char*) "(Ljava/lang/Object;Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_set }, + { (char*) "setBoolean", (char*) "(Ljava/lang/Object;Z)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setBoolean }, + { (char*) "setByte", (char*) "(Ljava/lang/Object;B)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setByte }, + { (char*) "setChar", (char*) "(Ljava/lang/Object;C)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setChar }, + { (char*) "setShort", (char*) "(Ljava/lang/Object;S)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setShort }, + { (char*) "setInt", (char*) "(Ljava/lang/Object;I)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setInt }, + { (char*) "setLong", (char*) "(Ljava/lang/Object;J)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setLong }, + { (char*) "setFloat", (char*) "(Ljava/lang/Object;F)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setFloat }, + { (char*) "setDouble", (char*) "(Ljava/lang/Object;D)V", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_setDouble }, + { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_getSignature }, +#if defined(ENABLE_ANNOTATIONS) + { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMField_declaredAnnotations }, +#endif +}; + + +/* _Jv_java_lang_reflect_VMField_init ****************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_reflect_VMField_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/reflect/VMField"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c deleted file mode 100644 index 8b1853f06..000000000 --- a/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.c +++ /dev/null @@ -1,372 +0,0 @@ -/* src/native/vm/gnu/java_lang_reflect_VMMethod.c - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#if defined(ENABLE_ANNOTATIONS) -#include "vm/vm.h" -#endif - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_String.h" - -#if defined(ENABLE_ANNOTATIONS) -# include "native/include/java_util_Map.h" -# include "native/include/sun_reflect_ConstantPool.h" -#endif - -#include "native/include/java_lang_reflect_Method.h" -#include "native/include/java_lang_reflect_VMMethod.h" - -#include "native/vm/reflect.h" - -#include "vm/access.h" -#include "vm/global.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/initialize.h" -#include "vm/resolve.h" -#include "vm/stringlocal.h" - -#include "vmcore/method.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getModifiersInternal", "()I", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal }, - { "getReturnType", "()Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType }, - { "getParameterTypes", "()[Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes }, - { "getExceptionTypes", "()[Ljava/lang/Class;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes }, - { "invoke", "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke }, - { "getSignature", "()Ljava/lang/String;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature }, -#if defined(ENABLE_ANNOTATIONS) - { "getDefaultValue", "()Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue }, - { "declaredAnnotations", "()Ljava/util/Map;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations }, - { "getParameterAnnotations", "()[[Ljava/lang/annotation/Annotation;", (void *) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations }, -#endif -}; - - -/* _Jv_java_lang_reflect_VMMethod_init ******************************************* - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_lang_reflect_VMMethod_init(void) -{ - utf *u; - - u = utf_new_char("java/lang/reflect/VMMethod"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: getModifiersInternal - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, java_lang_reflect_VMMethod *this) -{ - classinfo *c; - methodinfo *m; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - m = &(c->methods[slot]); - - return m->flags; -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: getReturnType - * Signature: ()Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, java_lang_reflect_VMMethod *this) -{ - classinfo *c; - methodinfo *m; - classinfo *result; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - m = &(c->methods[slot]); - - result = method_returntype_get(m); - - return LLNI_classinfo_wrap(result); -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: getParameterTypes - * Signature: ()[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, java_lang_reflect_VMMethod *this) -{ - classinfo *c; - methodinfo *m; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - m = &(c->methods[slot]); - - return method_get_parametertypearray(m); -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: getExceptionTypes - * Signature: ()[Ljava/lang/Class; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, java_lang_reflect_VMMethod *this) -{ - classinfo *c; - methodinfo *m; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - m = &(c->methods[slot]); - - return method_get_exceptionarray(m); -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: invoke - * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, java_lang_reflect_VMMethod *this, java_lang_Object *o, java_handle_objectarray_t *args) -{ - classinfo *c; - int32_t slot; - java_lang_reflect_Method *rm; - int32_t override; - methodinfo *m; - java_handle_t *ro; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot, slot); - - LLNI_field_get_ref(this, m, rm); - LLNI_field_get_val(rm, flag, override); - - m = &(c->methods[slot]); - - ro = reflect_method_invoke(m, (java_handle_t *) o, args, override); - - return (java_lang_Object *) ro; -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: getSignature - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT java_lang_String* JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, java_lang_reflect_VMMethod* this) -{ - classinfo *c; - methodinfo *m; - java_handle_t *o; - int32_t slot; - - LLNI_field_get_cls(this, clazz, c); - LLNI_field_get_val(this, slot , slot); - m = &(c->methods[slot]); - - if (m->signature == NULL) - return NULL; - - o = javastring_new(m->signature); - - /* in error case o is NULL */ - - return (java_lang_String *) o; -} - -#if defined(ENABLE_ANNOTATIONS) -/* - * Class: java/lang/reflect/VMMethod - * Method: getDefaultValue - * Signature: ()Ljava/lang/Object; - * - * Parses the annotation default value and returnes it (boxed, if it's a primitive). - */ -JNIEXPORT struct java_lang_Object* JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, struct java_lang_reflect_VMMethod* this) -{ - java_handle_bytearray_t *annotationDefault = NULL; /* unparsed annotation default value */ - static methodinfo *m_parseAnnotationDefault = NULL; /* parser method (will be chached, therefore static) */ - utf *utf_parseAnnotationDefault = NULL; /* parser method name */ - utf *utf_desc = NULL; /* parser method descriptor (signature) */ - sun_reflect_ConstantPool *constantPool = NULL; /* constant pool object to use */ - java_lang_Class *constantPoolOop = NULL; /* methods declaring class */ - classinfo *referer = NULL; /* class, which calles the annotation parser */ - /* (for the parameter 'referer' of vm_call_method()) */ - java_lang_reflect_Method* rm; - java_handle_t* h; - - if (this == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - constantPool = - (sun_reflect_ConstantPool*)native_new_and_init( - class_sun_reflect_ConstantPool); - - if (constantPool == NULL) { - /* out of memory */ - return NULL; - } - - LLNI_field_get_ref(this, clazz, constantPoolOop); - LLNI_field_set_ref(constantPool, constantPoolOop, (java_lang_Object*)constantPoolOop); - - /* only resolve the parser method the first time */ - if (m_parseAnnotationDefault == NULL) { - utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault"); - utf_desc = utf_new_char( - "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)" - "Ljava/lang/Object;"); - - if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) { - /* out of memory */ - return NULL; - } - - LLNI_class_get(this, referer); - - m_parseAnnotationDefault = class_resolveclassmethod( - class_sun_reflect_annotation_AnnotationParser, - utf_parseAnnotationDefault, - utf_desc, - referer, - true); - - if (m_parseAnnotationDefault == NULL) { - /* method not found */ - return NULL; - } - } - - LLNI_field_get_ref(this, m, rm); - LLNI_field_get_ref(this, annotationDefault, annotationDefault); - - h = vm_call_method(m_parseAnnotationDefault, NULL, rm, annotationDefault, constantPool); - - return (java_lang_Object*) h; -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: declaredAnnotations - * Signature: ()Ljava/util/Map; - * - * Parses the annotations (if they aren't parsed yet) and stores them into - * the declaredAnnotations map and return this map. - */ -JNIEXPORT struct java_util_Map* JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this) -{ - java_util_Map *declaredAnnotations = NULL; /* parsed annotations */ - java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ - java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */ - classinfo *referer = NULL; /* class, which calles the annotation parser */ - /* (for the parameter 'referer' of vm_call_method()) */ - - LLNI_field_get_ref(this, declaredAnnotations, declaredAnnotations); - - /* are the annotations parsed yet? */ - if (declaredAnnotations == NULL) { - LLNI_field_get_ref(this, annotations, annotations); - LLNI_field_get_ref(this, clazz, declaringClass); - LLNI_class_get(this, referer); - - declaredAnnotations = reflect_get_declaredannotatios(annotations, declaringClass, referer); - - LLNI_field_set_ref(this, declaredAnnotations, declaredAnnotations); - } - - return declaredAnnotations; -} - - -/* - * Class: java/lang/reflect/VMMethod - * Method: getParameterAnnotations - * Signature: ()[[Ljava/lang/annotation/Annotation; - * - * Parses the parameter annotations and returns them in an 2 dimensional array. - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, java_lang_reflect_VMMethod *this) -{ - java_handle_bytearray_t *parameterAnnotations = NULL; /* unparsed parameter annotations */ - int32_t slot = -1; /* slot of the method */ - java_lang_Class *declaringClass = NULL; /* the constant pool of this class is used */ - classinfo *referer = NULL; /* class, which calles the annotation parser */ - /* (for the parameter 'referer' of vm_call_method()) */ - - LLNI_field_get_ref(this, parameterAnnotations, parameterAnnotations); - LLNI_field_get_val(this, slot, slot); - LLNI_field_get_ref(this, clazz, declaringClass); - LLNI_class_get(this, referer); - - return reflect_get_parameterannotations((java_handle_t*)parameterAnnotations, slot, declaringClass, referer); -} -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp b/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp new file mode 100644 index 000000000..23435edc6 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp @@ -0,0 +1,312 @@ +/* src/native/vm/gnuclasspath/java_lang_reflect_VMMethod.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#if defined(ENABLE_ANNOTATIONS) +#include "vm/vm.hpp" +#endif + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_lang_reflect_VMMethod.h" +#endif + +#include "native/vm/reflection.hpp" + +#include "vm/access.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/method.h" +#include "vm/resolve.h" +#include "vm/string.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/lang/reflect/VMMethod + * Method: getModifiersInternal + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_java_lang_reflect_VMMethod_getModifiersInternal(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + methodinfo* m = rvmm.get_method(); + return m->flags; +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: getReturnType + * Signature: ()Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_java_lang_reflect_VMMethod_getReturnType(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + methodinfo* m = rvmm.get_method(); + classinfo* c = method_returntype_get(m); + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: getParameterTypes + * Signature: ()[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getParameterTypes(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + methodinfo* m = rvmm.get_method(); + java_handle_objectarray_t* oa = method_get_parametertypearray(m); + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: getExceptionTypes + * Signature: ()[Ljava/lang/Class; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getExceptionTypes(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + methodinfo* m = rvmm.get_method(); + java_handle_objectarray_t* oa = method_get_exceptionarray(m); + return (jobjectArray) oa; +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: invoke + * Signature: (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_invoke(JNIEnv *env, jobject _this, jobject o, jobjectArray args) +{ + java_lang_reflect_VMMethod jlrvmm(_this); + java_lang_reflect_Method jlrm(jlrvmm.get_m()); + + java_handle_t* result = jlrm.invoke((java_handle_t*) o, (java_handle_objectarray_t*) args); + + return (jobject) result; +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: getSignature + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_java_lang_reflect_VMMethod_getSignature(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + methodinfo* m = rvmm.get_method(); + + if (m->signature == NULL) + return NULL; + + java_handle_t* s = javastring_new(m->signature); + + /* in error case o is NULL */ + + return (jstring) s; +} + + +#if defined(ENABLE_ANNOTATIONS) +/* + * Class: java/lang/reflect/VMMethod + * Method: getDefaultValue + * Signature: ()Ljava/lang/Object; + * + * Parses the annotation default value and returnes it (boxed, if it's a primitive). + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_getDefaultValue(JNIEnv *env, jobject _this) +{ + static methodinfo *m_parseAnnotationDefault = NULL; /* parser method (will be chached, therefore static) */ + utf *utf_parseAnnotationDefault = NULL; /* parser method name */ + utf *utf_desc = NULL; /* parser method descriptor (signature) */ + + if (_this == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + // TODO Use a constructor. + java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool); + + if (h == NULL) + return NULL; + + sun_reflect_ConstantPool cp(h); + + java_lang_reflect_VMMethod rvmm(_this); + classinfo* declaringClass = rvmm.get_clazz(); + cp.set_constantPoolOop(declaringClass); + + /* only resolve the parser method the first time */ + if (m_parseAnnotationDefault == NULL) { + utf_parseAnnotationDefault = utf_new_char("parseAnnotationDefault"); + utf_desc = utf_new_char( + "(Ljava/lang/reflect/Method;[BLsun/reflect/ConstantPool;)" + "Ljava/lang/Object;"); + + if (utf_parseAnnotationDefault == NULL || utf_desc == NULL) { + /* out of memory */ + return NULL; + } + + classinfo *referer = rvmm.get_Class(); + + m_parseAnnotationDefault = class_resolveclassmethod( + class_sun_reflect_annotation_AnnotationParser, + utf_parseAnnotationDefault, + utf_desc, + referer, + true); + + if (m_parseAnnotationDefault == NULL) { + /* method not found */ + return NULL; + } + } + + java_lang_reflect_Method rm(rvmm.get_m()); + java_handle_bytearray_t* annotationDefault = rvmm.get_annotationDefault(); + + java_handle_t* result = vm_call_method(m_parseAnnotationDefault, NULL, rm.get_handle(), annotationDefault, cp.get_handle()); + + return (jobject) result; +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: declaredAnnotations + * Signature: ()Ljava/util/Map; + */ +JNIEXPORT jobject JNICALL Java_java_lang_reflect_VMMethod_declaredAnnotations(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + java_handle_t* declaredAnnotations = rvmm.get_declaredAnnotations(); + + // Are the annotations parsed yet? + if (declaredAnnotations == NULL) { + java_handle_bytearray_t* annotations = rvmm.get_annotations(); + classinfo* declaringClass = rvmm.get_clazz(); + classinfo* referer = rvmm.get_Class(); + + declaredAnnotations = Reflection::get_declaredannotations(annotations, declaringClass, referer); + + rvmm.set_declaredAnnotations(declaredAnnotations); + } + + return (jobject) declaredAnnotations; +} + + +/* + * Class: java/lang/reflect/VMMethod + * Method: getParameterAnnotations + * Signature: ()[[Ljava/lang/annotation/Annotation; + */ +JNIEXPORT jobjectArray JNICALL Java_java_lang_reflect_VMMethod_getParameterAnnotations(JNIEnv *env, jobject _this) +{ + java_lang_reflect_VMMethod rvmm(_this); + java_handle_bytearray_t* parameterAnnotations = rvmm.get_parameterAnnotations(); + methodinfo* m = rvmm.get_method(); + classinfo* referer = rvmm.get_Class(); + + java_handle_objectarray_t* oa = Reflection::get_parameterannotations(parameterAnnotations, m, referer); + return (jobjectArray) oa; +} +#endif + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getModifiersInternal", (char*) "()I", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getModifiersInternal }, + { (char*) "getReturnType", (char*) "()Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getReturnType }, + { (char*) "getParameterTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterTypes }, + { (char*) "getExceptionTypes", (char*) "()[Ljava/lang/Class;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getExceptionTypes }, + { (char*) "invoke", (char*) "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_invoke }, + { (char*) "getSignature", (char*) "()Ljava/lang/String;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getSignature }, +#if defined(ENABLE_ANNOTATIONS) + { (char*) "getDefaultValue", (char*) "()Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getDefaultValue }, + { (char*) "declaredAnnotations", (char*) "()Ljava/util/Map;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_declaredAnnotations }, + { (char*) "getParameterAnnotations", (char*) "()[[Ljava/lang/annotation/Annotation;", (void*) (uintptr_t) &Java_java_lang_reflect_VMMethod_getParameterAnnotations }, +#endif +}; + + +/* _Jv_java_lang_reflect_VMMethod_init ***************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_lang_reflect_VMMethod_init(void) +{ + utf *u; + + u = utf_new_char("java/lang/reflect/VMMethod"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c b/src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c index b2138421f..da0c62bc4 100644 --- a/src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c +++ b/src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c @@ -1,9 +1,7 @@ -/* src/native/vm/gnu/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy +/* src/native/vm/gnuclasspath/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -29,13 +27,11 @@ #include -#include "native/jni.h" +#include "native/jni.hpp" #include "native/native.h" -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_ClassLoader.h" - -#include "native/include/java_lang_reflect_VMProxy.h" +// FIXME +//#include "native/include/java_lang_reflect_VMProxy.h" /* native methods implemented by this file ************************************/ diff --git a/src/native/vm/gnuclasspath/java_security_VMAccessController.c b/src/native/vm/gnuclasspath/java_security_VMAccessController.c deleted file mode 100644 index 7e86b6892..000000000 --- a/src/native/vm/gnuclasspath/java_security_VMAccessController.c +++ /dev/null @@ -1,89 +0,0 @@ -/* src/native/vm/gnu/java_security_VMAccessController.c - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_security_VMAccessController.h" - -#include "vm/global.h" - -#include "vm/jit/stacktrace.h" - -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getStack", "()[[Ljava/lang/Object;", (void *) (uintptr_t) &Java_java_security_VMAccessController_getStack }, -}; - - -/* _Jv_java_security_VMAccessController_init *********************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_security_VMAccessController_init(void) -{ - utf *u; - - u = utf_new_char("java/security/VMAccessController"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/security/VMAccessController - * Method: getStack - * Signature: ()[[Ljava/lang/Object; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz) -{ - return stacktrace_get_stack(); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_security_VMAccessController.cpp b/src/native/vm/gnuclasspath/java_security_VMAccessController.cpp new file mode 100644 index 000000000..4ad6e3c7e --- /dev/null +++ b/src/native/vm/gnuclasspath/java_security_VMAccessController.cpp @@ -0,0 +1,96 @@ +/* src/native/vm/gnuclasspath/java_security_VMAccessController.cpp + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/vm/include/java_security_VMAccessController.h" +#endif + +#include "vm/global.h" +#include "vm/utf8.h" + +#include "vm/jit/stacktrace.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/security/VMAccessController + * Method: getStack + * Signature: ()[[Ljava/lang/Object; + */ +JNIEXPORT jobjectArray JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz) +{ + return (jobjectArray) stacktrace_get_stack(); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getStack", (char*) "()[[Ljava/lang/Object;", (void*) (uintptr_t) &Java_java_security_VMAccessController_getStack }, +}; + + +/* _Jv_java_security_VMAccessController_init *********************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_security_VMAccessController_init(void) +{ + utf *u; + + u = utf_new_char("java/security/VMAccessController"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c b/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c deleted file mode 100644 index 7105e65f8..000000000 --- a/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.c +++ /dev/null @@ -1,87 +0,0 @@ -/* src/native/vm/gnu/java_util_concurrent_atomic_AtomicLong.c - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/native.h" - -#include "native/include/java_util_concurrent_atomic_AtomicLong.h" - -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "VMSupportsCS8", "()Z", (void *) (intptr_t) &Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8 }, -}; - - -/* _Jv_java_util_concurrent_atomic_AtomicLong_init ***************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_java_util_concurrent_atomic_AtomicLong_init(void) -{ - utf *u; - - u = utf_new_char("java/util/concurrent/atomic/AtomicLong"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: java/util/concurrent/atomic/AtomicLong - * Method: VMSupportsCS8 - * Signature: ()Z - */ -JNIEXPORT int32_t JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz) -{ - /* IMPLEMENT ME */ - - return 0; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp b/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp new file mode 100644 index 000000000..26ef8a4e4 --- /dev/null +++ b/src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp @@ -0,0 +1,94 @@ +/* src/native/vm/gnuclasspath/java_util_concurrent_atomic_AtomicLong.cpp + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/jni.hpp" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/java_util_concurrent_atomic_AtomicLong.h" +#endif + +#include "vm/utf8.h" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: java/util/concurrent/atomic/AtomicLong + * Method: VMSupportsCS8 + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8(JNIEnv *env, jclass clazz) +{ + // IMPLEMENT ME + return 0; +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "VMSupportsCS8", (char*) "()Z", (void*) (uintptr_t) &Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8 }, +}; + + +/* _Jv_java_util_concurrent_atomic_AtomicLong_init ***************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_java_util_concurrent_atomic_AtomicLong_init(void) +{ + utf *u; + + u = utf_new_char("java/util/concurrent/atomic/AtomicLong"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c b/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c deleted file mode 100644 index 66b7ac450..000000000 --- a/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.c +++ /dev/null @@ -1,427 +0,0 @@ -/* src/native/vm/gnu/sun_reflect_ConstantPool.c - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, M. S. Panzenböck Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -/******************************************************************************* - - XXX: The Methods in this file are very redundant to thouse in - src/native/vm/sun/jvm.c Unless someone has a good idea how to cover - such redundancy I leave it how it is. - - The ConstantPool class represents an interface to the constant pool of a - class and is used by the annotations parser (sun.reflect.annotation. - AnnotationParser) to get the values of the constants refered by the - annotations. - -*******************************************************************************/ - -#include "config.h" - -#include -#include - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Class.h" -#include "native/include/sun_reflect_ConstantPool.h" - -#include "native/vm/reflect.h" - -#include "toolbox/logging.h" - -#include "vm/vm.h" -#include "vm/exceptions.h" -#include "vm/resolve.h" -#include "vm/stringlocal.h" - -#include "vmcore/class.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "getSize0", "(Ljava/lang/Object;I)I", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getSize0 }, - { "getClassAt0", "(Ljava/lang/Object;I)Ljava/lang/Class;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAt0 }, - { "getClassAtIfLoaded0", "(Ljava/lang/Object;I)Ljava/lang/Class;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0 }, - { "getMethodAt0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0 }, - { "getMethodAtIfLoaded0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 }, - { "getFieldAt0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0 }, - { "getFieldAtIfLoaded0", "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0 }, - { "getMemberRefInfoAt0", "(Ljava/lang/Object;I)[Ljava/lang/String;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0 }, - { "getIntAt0", "(Ljava/lang/Object;I)I", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getIntAt0 }, - { "getLongAt0", "(Ljava/lang/Object;I)J", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getLongAt0 }, - { "getFloatAt0", "(Ljava/lang/Object;I)F", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0 }, - { "getDoubleAt0", "(Ljava/lang/Object;I)D", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0 }, - { "getStringAt0", "(Ljava/lang/Object;I)Ljava/lang/String;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getStringAt0 }, - { "getUTF8At0", "(Ljava/lang/Object;I)Ljava/lang/String;", (void *) (intptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0 }, -}; - - -/* _Jv_sun_reflect_ConstantPool_init ****************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_sun_reflect_ConstantPool_init(void) -{ - native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT); -} - -/* - * Class: sun/reflect/ConstantPool - * Method: getSize0 - * Signature: (Ljava/lang/Object;)I - */ -JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool) -{ - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - return cls->cpcount; -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getClassAt0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/Class; - */ -JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_classref *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_classref*)class_getconstant( - cls, index, CONSTANT_Class); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - return LLNI_classinfo_wrap(resolve_classref_eager(ref)); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getClassAtIfLoaded0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/Class; - */ -JNIEXPORT struct java_lang_Class* JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_classref *ref; - classinfo *c = NULL; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_classref*)class_getconstant( - cls, index, CONSTANT_Class); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - if (!resolve_classref(NULL,ref,resolveLazy,true,true,&c)) { - return NULL; - } - - if (c == NULL || !(c->state & CLASS_LOADED)) { - return NULL; - } - - return LLNI_classinfo_wrap(c); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getMethodAt0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member; - */ -JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_FMIref *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_FMIref*)class_getconstant( - cls, index, CONSTANT_Methodref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX: is that right? or do I have to use resolve_method_*? */ - return (jobject)reflect_method_new(ref->p.method); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getMethodAtIfLoaded0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member; - */ -JNIEXPORT struct java_lang_reflect_Member* JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_FMIref *ref; - classinfo *c = NULL; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_FMIref*)class_getconstant( - cls, index, CONSTANT_Methodref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) { - return NULL; - } - - if (c == NULL || !(c->state & CLASS_LOADED)) { - return NULL; - } - - return (jobject)reflect_method_new(ref->p.method); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getFieldAt0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field; - */ -JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_FMIref *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_FMIref*)class_getconstant( - cls, index, CONSTANT_Fieldref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - return (jobject)reflect_field_new(ref->p.field); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getFieldAtIfLoaded0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field; - */ -JNIEXPORT struct java_lang_reflect_Field* JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_FMIref *ref; - classinfo *c; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_FMIref*)class_getconstant( - cls, index, CONSTANT_Fieldref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) { - return NULL; - } - - if (c == NULL || !(c->state & CLASS_LOADED)) { - return NULL; - } - - return (jobject)reflect_field_new(ref->p.field); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getMemberRefInfoAt0 - * Signature: (Ljava/lang/Object;I)[Ljava/lang/String; - */ -JNIEXPORT java_handle_objectarray_t* JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index); - return NULL; -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getIntAt0 - * Signature: (Ljava/lang/Object;I)I - */ -JNIEXPORT int32_t JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_integer *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_integer*)class_getconstant( - cls, index, CONSTANT_Integer); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getLongAt0 - * Signature: (Ljava/lang/Object;I)J - */ -JNIEXPORT int64_t JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_long *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_long*)class_getconstant( - cls, index, CONSTANT_Long); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getFloatAt0 - * Signature: (Ljava/lang/Object;I)F - */ -JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_float *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_float*)class_getconstant( - cls, index, CONSTANT_Float); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getDoubleAt0 - * Signature: (Ljava/lang/Object;I)D - */ -JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - constant_double *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_double*)class_getconstant( - cls, index, CONSTANT_Double); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getStringAt0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/String; - */ -JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - utf *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (utf*)class_getconstant(cls, index, CONSTANT_String); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX: I hope literalstring_new is the right Function. */ - return (java_lang_String*)literalstring_new(ref); -} - - -/* - * Class: sun/reflect/ConstantPool - * Method: getUTF8At0 - * Signature: (Ljava/lang/Object;I)Ljava/lang/String; - */ -JNIEXPORT struct java_lang_String* JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, struct sun_reflect_ConstantPool* this, struct java_lang_Object* jcpool, int32_t index) -{ - utf *ref; - classinfo *cls = LLNI_classinfo_unwrap(jcpool); - - ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX: I hope literalstring_new is the right Function. */ - return (java_lang_String*)literalstring_new(ref); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp b/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp new file mode 100644 index 000000000..3b5404665 --- /dev/null +++ b/src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp @@ -0,0 +1,440 @@ +/* src/native/vm/gnuclasspath/sun_reflect_ConstantPool.cpp + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + +/******************************************************************************* + + XXX: The Methods in this file are very redundant to thouse in + src/native/vm/sun/jvm.c Unless someone has a good idea how to cover + such redundancy I leave it how it is. + + The ConstantPool class represents an interface to the constant pool of a + class and is used by the annotations parser (sun.reflect.annotation. + AnnotationParser) to get the values of the constants refered by the + annotations. + +*******************************************************************************/ + +#include "config.h" + +#include +#include + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +// FIXME +//#include "native/include/sun_reflect_ConstantPool.h" + +#include "native/vm/reflection.hpp" + +#include "toolbox/logging.h" + +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/javaobjects.hpp" +#include "vm/resolve.h" +#include "vm/string.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: sun/reflect/ConstantPool + * Method: getSize0 + * Signature: (Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getSize0(JNIEnv *env, jobject _this, jobject jcpool) +{ + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + return cls->cpcount; +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getClassAt0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_classref *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_classref*)class_getconstant( + cls, index, CONSTANT_Class); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + return (jclass) LLNI_classinfo_wrap(resolve_classref_eager(ref)); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getClassAtIfLoaded0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_sun_reflect_ConstantPool_getClassAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_classref *ref; + classinfo *c = NULL; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_classref*)class_getconstant( + cls, index, CONSTANT_Class); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + if (!resolve_classref(NULL,ref,resolveLazy,true,true,&c)) { + return NULL; + } + + if (c == NULL || !(c->state & CLASS_LOADED)) { + return NULL; + } + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getMethodAt0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member; + */ +JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_FMIref *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_FMIref*)class_getconstant( + cls, index, CONSTANT_Methodref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* XXX: is that right? or do I have to use resolve_method_*? */ + java_lang_reflect_Method jlrm(ref->p.method); + + return (jobject) jlrm.get_handle(); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getMethodAtIfLoaded0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Member; + */ +JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_FMIref *ref; + classinfo *c = NULL; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_FMIref*)class_getconstant( + cls, index, CONSTANT_Methodref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) { + return NULL; + } + + if (c == NULL || !(c->state & CLASS_LOADED)) { + return NULL; + } + + java_lang_reflect_Method jlrm(ref->p.method); + + return (jobject) jlrm.get_handle(); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getFieldAt0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field; + */ +JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_FMIref *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + // Create a new java.lang.reflect.Field Java object. + java_lang_reflect_Field jlrf(ref->p.field); + + return (jobject) jlrf.get_handle(); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getFieldAtIfLoaded0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/reflect/Field; + */ +JNIEXPORT jobject JNICALL Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_FMIref *ref; + classinfo *c; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_FMIref*) class_getconstant(cls, index, CONSTANT_Fieldref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + if (!resolve_classref(NULL,ref->p.classref,resolveLazy,true,true,&c)) { + return NULL; + } + + if (c == NULL || !(c->state & CLASS_LOADED)) { + return NULL; + } + + // Create a new java.lang.reflect.Field Java object. + java_lang_reflect_Field jlrf(ref->p.field); + + return (jobject) jlrf.get_handle(); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getMemberRefInfoAt0 + * Signature: (Ljava/lang/Object;I)[Ljava/lang/String; + */ +JNIEXPORT jobjectArray JNICALL Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + log_println("Java_sun_reflect_ConstantPool_getMemberRefInfoAt0(env=%p, jcpool=%p, index=%d): IMPLEMENT ME!", env, jcpool, index); + return NULL; +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getIntAt0 + * Signature: (Ljava/lang/Object;I)I + */ +JNIEXPORT jint JNICALL Java_sun_reflect_ConstantPool_getIntAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_integer *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_integer*) class_getconstant(cls, index, CONSTANT_Integer); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getLongAt0 + * Signature: (Ljava/lang/Object;I)J + */ +JNIEXPORT jlong JNICALL Java_sun_reflect_ConstantPool_getLongAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_long *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_long*)class_getconstant( + cls, index, CONSTANT_Long); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getFloatAt0 + * Signature: (Ljava/lang/Object;I)F + */ +JNIEXPORT float JNICALL Java_sun_reflect_ConstantPool_getFloatAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_float *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_float*)class_getconstant( + cls, index, CONSTANT_Float); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getDoubleAt0 + * Signature: (Ljava/lang/Object;I)D + */ +JNIEXPORT double JNICALL Java_sun_reflect_ConstantPool_getDoubleAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + constant_double *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_double*)class_getconstant( + cls, index, CONSTANT_Double); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getStringAt0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getStringAt0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + utf *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (utf*)class_getconstant(cls, index, CONSTANT_String); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* XXX: I hope literalstring_new is the right Function. */ + return (jstring) literalstring_new(ref); +} + + +/* + * Class: sun/reflect/ConstantPool + * Method: getUTF8At0 + * Signature: (Ljava/lang/Object;I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_sun_reflect_ConstantPool_getUTF8At0(JNIEnv *env, jobject _this, jobject jcpool, jint index) +{ + utf *ref; + classinfo *cls = LLNI_classinfo_unwrap(jcpool); + + ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* XXX: I hope literalstring_new is the right Function. */ + return (jstring) literalstring_new(ref); +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "getSize0", (char*) "(Ljava/lang/Object;I)I", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getSize0 }, + { (char*) "getClassAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAt0 }, + { (char*) "getClassAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getClassAtIfLoaded0 }, + { (char*) "getMethodAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAt0 }, + { (char*) "getMethodAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Member;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMethodAtIfLoaded0 }, + { (char*) "getFieldAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAt0 }, + { (char*) "getFieldAtIfLoaded0", (char*) "(Ljava/lang/Object;I)Ljava/lang/reflect/Field;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFieldAtIfLoaded0 }, + { (char*) "getMemberRefInfoAt0", (char*) "(Ljava/lang/Object;I)[Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getMemberRefInfoAt0 }, + { (char*) "getIntAt0", (char*) "(Ljava/lang/Object;I)I", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getIntAt0 }, + { (char*) "getLongAt0", (char*) "(Ljava/lang/Object;I)J", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getLongAt0 }, + { (char*) "getFloatAt0", (char*) "(Ljava/lang/Object;I)F", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getFloatAt0 }, + { (char*) "getDoubleAt0", (char*) "(Ljava/lang/Object;I)D", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getDoubleAt0 }, + { (char*) "getStringAt0", (char*) "(Ljava/lang/Object;I)Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getStringAt0 }, + { (char*) "getUTF8At0", (char*) "(Ljava/lang/Object;I)Ljava/lang/String;", (void*) (uintptr_t) &Java_sun_reflect_ConstantPool_getUTF8At0 }, +}; + + +/* _Jv_sun_reflect_ConstantPool_init ****************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_sun_reflect_ConstantPool_init(void) +{ + native_method_register(utf_new_char("sun/reflect/ConstantPool"), methods, NATIVE_METHODS_COUNT); +} +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/nativevm.c b/src/native/vm/nativevm.c index ed3806ec0..7558d1040 100644 --- a/src/native/vm/nativevm.c +++ b/src/native/vm/nativevm.c @@ -29,12 +29,11 @@ #include "native/vm/nativevm.h" +#include "vm/class.h" #include "vm/initialize.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/system.h" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/os.hpp" #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) # include "mm/memory.h" @@ -43,10 +42,10 @@ # include "native/vm/openjdk/hpi.h" -# include "vm/properties.h" -# include "vm/vm.h" - -# include "vmcore/utf8.h" +# include "vm/globals.hpp" +# include "vm/properties.hpp" +# include "vm/utf8.h" +# include "vm/vm.hpp" #endif @@ -95,27 +94,27 @@ void nativevm_preinit(void) # elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - char *boot_library_path; - int len; - char *p; - utf *u; - lt_dlhandle handle; + const char* boot_library_path; + int len; + char* p; + utf* u; + void* handle; TRACESUBSYSTEMINITIALIZATION("nativevm_preinit"); /* Load libjava.so */ - boot_library_path = properties_get("sun.boot.library.path"); + boot_library_path = Properties_get("sun.boot.library.path"); len = - system_strlen(boot_library_path) + - system_strlen("/libjava.so") + - system_strlen("0"); + os_strlen(boot_library_path) + + os_strlen("/libjava.so") + + os_strlen("0"); p = MNEW(char, len); - system_strcpy(p, boot_library_path); - system_strcat(p, "/libjava.so"); + os_strcpy(p, boot_library_path); + os_strcat(p, "/libjava.so"); u = utf_new_char(p); diff --git a/src/native/vm/nativevm.h b/src/native/vm/nativevm.h index db22ee650..de4ba48a1 100644 --- a/src/native/vm/nativevm.h +++ b/src/native/vm/nativevm.h @@ -27,6 +27,11 @@ #define _NATIVEVM_H #include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/types.h" #include "vm/global.h" @@ -97,8 +102,13 @@ void _Jv_java_lang_Throwable_init(); # error unknown Java configuration #endif +#ifdef __cplusplus +} +#endif + #endif /* _NATIVEVM_H */ + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/native/vm/openjdk/Makefile.am b/src/native/vm/openjdk/Makefile.am index 1f1753140..49677897a 100644 --- a/src/native/vm/openjdk/Makefile.am +++ b/src/native/vm/openjdk/Makefile.am @@ -1,4 +1,4 @@ -## src/native/vm/sun/Makefile.am +## src/native/vm/openjdk/Makefile.am ## ## Copyright (C) 2007, 2008 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO @@ -31,7 +31,7 @@ noinst_LTLIBRARIES = \ libnativevmcore_la_SOURCES = \ hpi.c \ hpi.h \ - jvm.c + jvm.cpp ## Local variables: diff --git a/src/native/vm/openjdk/hpi.c b/src/native/vm/openjdk/hpi.c index 87f0a7d40..d0d0d1f01 100644 --- a/src/native/vm/openjdk/hpi.c +++ b/src/native/vm/openjdk/hpi.c @@ -33,15 +33,16 @@ #include "mm/memory.h" -#include "native/jni.h" +#include "native/jni.hpp" #include "native/native.h" -#include "vm/properties.h" -#include "vm/vm.h" +#include "native/vm/openjdk/hpi.h" -#include "vmcore/options.h" -#include "vmcore/system.h" -#include "vmcore/utf8.h" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/properties.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" /* VM callback functions ******************************************************/ @@ -78,30 +79,31 @@ HPI_SystemInterface *hpi_system = NULL; void hpi_initialize(void) { - char *boot_library_path; - int len; - char *p; - utf *u; - lt_dlhandle handle; - lt_ptr dll_initialize; - int result; + const char* boot_library_path; + int len; + char* p; + utf* u; + void* handle; + void* dll_initialize; + int result; + jint (JNICALL * DLL_Initialize)(GetInterfaceFunc *, void *); TRACESUBSYSTEMINITIALIZATION("hpi_init"); /* Load libhpi.so */ - boot_library_path = properties_get("sun.boot.library.path"); + boot_library_path = Properties_get("sun.boot.library.path"); len = - system_strlen(boot_library_path) + - system_strlen("/native_threads/libhpi.so") + - system_strlen("0"); + os_strlen(boot_library_path) + + os_strlen("/native_threads/libhpi.so") + + os_strlen("0"); p = MNEW(char, len); - system_strcpy(p, boot_library_path); - system_strcat(p, "/native_threads/libhpi.so"); + os_strcpy(p, boot_library_path); + os_strcat(p, "/native_threads/libhpi.so"); u = utf_new_char(p); @@ -118,12 +120,12 @@ void hpi_initialize(void) /* Resolve the DLL_Initialize function from the library. */ - dll_initialize = lt_dlsym(handle, "DLL_Initialize"); + dll_initialize = os_dlsym(handle, "DLL_Initialize"); DLL_Initialize = (jint (JNICALL *)(GetInterfaceFunc *, void *)) (intptr_t) dll_initialize; if (opt_TraceHPI && DLL_Initialize == NULL) - log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", lt_dlerror()); + log_println("hpi_init: HPI dlsym of DLL_Initialize failed: %s", os_dlerror()); if (DLL_Initialize == NULL || (*DLL_Initialize)(&hpi_get_interface, &callbacks) < 0) { diff --git a/src/native/vm/openjdk/hpi.h b/src/native/vm/openjdk/hpi.h index 03880e6f1..356b8358e 100644 --- a/src/native/vm/openjdk/hpi.h +++ b/src/native/vm/openjdk/hpi.h @@ -26,6 +26,10 @@ #ifndef _HPI_H #define _HPI_H +#ifdef __cplusplus +extern "C" { +#endif + #include "config.h" /* HPI headers ***************************************************************** @@ -56,6 +60,10 @@ extern HPI_SystemInterface *hpi_system; void hpi_initialize(void); int hpi_initialize_socket_library(void); +#ifdef __cplusplus +} +#endif + #endif /* _HPI_H */ diff --git a/src/native/vm/openjdk/jvm.c b/src/native/vm/openjdk/jvm.c deleted file mode 100644 index 4723b5c4e..000000000 --- a/src/native/vm/openjdk/jvm.c +++ /dev/null @@ -1,3738 +0,0 @@ -/* src/native/vm/openjdk/jvm.c - HotSpot JVM interface functions - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include - -#if defined(HAVE_SYS_IOCTL_H) -#define BSD_COMP /* Get FIONREAD on Solaris2 */ -#include -#endif - -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_AssertionStatusDirectives.h" -#include "native/include/java_lang_String.h" /* required by j.l.CL */ -#include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -#include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */ -#include "native/include/java_lang_StackTraceElement.h" -#include "native/include/java_lang_Throwable.h" -#include "native/include/java_security_ProtectionDomain.h" - -#if defined(ENABLE_ANNOTATIONS) -#include "native/include/sun_reflect_ConstantPool.h" -#endif - -#include "native/vm/reflect.h" - -#include "native/vm/openjdk/hpi.h" - -#include "threads/lock-common.h" -#include "threads/thread.h" - -#include "toolbox/logging.h" -#include "toolbox/list.h" - -#include "vm/array.h" - -#if defined(ENABLE_ASSERTION) -#include "vm/assertion.h" -#endif - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/initialize.h" -#include "vm/package.h" -#include "vm/primitive.h" -#include "vm/properties.h" -#include "vm/resolve.h" -#include "vm/signallocal.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/stacktrace.h" - -#include "vmcore/classcache.h" -#include "vmcore/options.h" -#include "vmcore/system.h" - - -/* debugging macros ***********************************************************/ - -#if !defined(NDEBUG) - -# define TRACEJVMCALLS(x) \ - do { \ - if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \ - log_println x; \ - } \ - } while (0) - -# define TRACEJVMCALLSENTER(x) \ - do { \ - if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \ - log_start(); \ - log_print x; \ - } \ - } while (0) - -# define TRACEJVMCALLSEXIT(x) \ - do { \ - if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \ - log_print x; \ - log_finish(); \ - } \ - } while (0) - -# define TRACEJVMCALLSVERBOSE(x) \ - do { \ - if (opt_TraceJVMCallsVerbose) { \ - log_println x; \ - } \ - } while (0) - -# define PRINTJVMWARNINGS(x) -/* do { \ */ -/* if (opt_PrintJVMWarnings) { \ */ -/* log_println x; \ */ -/* } \ */ -/* } while (0) */ - -#else - -# define TRACEJVMCALLS(x) -# define TRACEJVMCALLSENTER(x) -# define TRACEJVMCALLSEXIT(x) -# define TRACEJVMCALLSVERBOSE(x) -# define PRINTJVMWARNINGS(x) - -#endif - - -typedef struct { - /* Naming convention of RE build version string: n.n.n[_uu[c]][-]-bxx */ - unsigned int jvm_version; /* Consists of major, minor, micro (n.n.n) */ - /* and build number (xx) */ - unsigned int update_version : 8; /* Update release version (uu) */ - unsigned int special_update_version : 8; /* Special update release version (c) */ - unsigned int reserved1 : 16; - unsigned int reserved2; - - /* The following bits represents JVM supports that JDK has dependency on. - * JDK can use these bits to determine which JVM version - * and support it has to maintain runtime compatibility. - * - * When a new bit is added in a minor or update release, make sure - * the new bit is also added in the main/baseline. - */ - unsigned int is_attachable : 1; - unsigned int : 31; - unsigned int : 32; - unsigned int : 32; -} jvm_version_info; - - -/* - * A structure used to a capture exception table entry in a Java method. - */ -typedef struct { - jint start_pc; - jint end_pc; - jint handler_pc; - jint catchType; -} JVM_ExceptionTableEntryType; - - -int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) -{ - if ((intptr_t) count <= 0) - return -1; - - return vsnprintf(str, count, fmt, args); -} - - -int jio_snprintf(char *str, size_t count, const char *fmt, ...) -{ - va_list ap; - int len; - - va_start(ap, fmt); - len = jio_vsnprintf(str, count, fmt, ap); - va_end(ap); - - return len; -} - - -int jio_fprintf(FILE* f, const char *fmt, ...) -{ - log_println("jio_fprintf: IMPLEMENT ME!"); - - return 0; -} - - -int jio_vfprintf(FILE* f, const char *fmt, va_list args) -{ - log_println("jio_vfprintf: IMPLEMENT ME!"); - - return 0; -} - - -int jio_printf(const char *fmt, ...) -{ - log_println("jio_printf: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetInterfaceVersion */ - -jint JVM_GetInterfaceVersion() -{ - /* This is defined in hotspot/src/share/vm/prims/jvm.h */ - -#define JVM_INTERFACE_VERSION 4 - - return JVM_INTERFACE_VERSION; -} - - -/* JVM_CurrentTimeMillis */ - -jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored) -{ - TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored)); - - return (jlong) builtin_currenttimemillis(); -} - - -/* JVM_NanoTime */ - -jlong JVM_NanoTime(JNIEnv *env, jclass ignored) -{ - TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored)); - - return (jlong) builtin_nanotime(); -} - - -/* JVM_ArrayCopy */ - -void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) -{ - java_handle_t *s; - java_handle_t *d; - - s = (java_handle_t *) src; - d = (java_handle_t *) dst; - - TRACEJVMCALLSVERBOSE(("JVM_ArrayCopy(env=%p, ignored=%p, src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d)", env, ignored, src, src_pos, dst, dst_pos, length)); - - builtin_arraycopy(s, src_pos, d, dst_pos, length); -} - - -/* JVM_InitProperties */ - -jobject JVM_InitProperties(JNIEnv *env, jobject properties) -{ - java_handle_t *h; - char buf[256]; - - TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties)); - - h = (java_handle_t *) properties; - - /* Convert the -XX:MaxDirectMemorySize= command line flag to the - sun.nio.MaxDirectMemorySize property. Do this after setting - user properties to prevent people from setting the value with a - -D option, as requested. */ - - jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize); - properties_add("sun.nio.MaxDirectMemorySize", buf); - - /* Add all properties. */ - - properties_system_add_all(h); - - return properties; -} - - -/* JVM_Exit */ - -void JVM_Exit(jint code) -{ - log_println("JVM_Exit: IMPLEMENT ME!"); -} - - -/* JVM_Halt */ - -void JVM_Halt(jint code) -{ - TRACEJVMCALLS(("JVM_Halt(code=%d)", code)); - -/* vm_exit(code); */ - vm_shutdown(code); -} - - -/* JVM_OnExit(void (*func)) */ - -void JVM_OnExit(void (*func)(void)) -{ - log_println("JVM_OnExit(void (*func): IMPLEMENT ME!"); -} - - -/* JVM_GC */ - -void JVM_GC(void) -{ - TRACEJVMCALLS(("JVM_GC()")); - - gc_call(); -} - - -/* JVM_MaxObjectInspectionAge */ - -jlong JVM_MaxObjectInspectionAge(void) -{ - log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_TraceInstructions */ - -void JVM_TraceInstructions(jboolean on) -{ - log_println("JVM_TraceInstructions: IMPLEMENT ME!"); -} - - -/* JVM_TraceMethodCalls */ - -void JVM_TraceMethodCalls(jboolean on) -{ - log_println("JVM_TraceMethodCalls: IMPLEMENT ME!"); -} - - -/* JVM_TotalMemory */ - -jlong JVM_TotalMemory(void) -{ - TRACEJVMCALLS(("JVM_TotalMemory()")); - - return gc_get_heap_size(); -} - - -/* JVM_FreeMemory */ - -jlong JVM_FreeMemory(void) -{ - TRACEJVMCALLS(("JVM_FreeMemory()")); - - return gc_get_free_bytes(); -} - - -/* JVM_MaxMemory */ - -jlong JVM_MaxMemory(void) -{ - TRACEJVMCALLS(("JVM_MaxMemory()")); - - return gc_get_max_heap_size(); -} - - -/* JVM_ActiveProcessorCount */ - -jint JVM_ActiveProcessorCount(void) -{ - TRACEJVMCALLS(("JVM_ActiveProcessorCount()")); - - return system_processors_online(); -} - - -/* JVM_FillInStackTrace */ - -void JVM_FillInStackTrace(JNIEnv *env, jobject receiver) -{ - java_lang_Throwable *o; - java_handle_bytearray_t *ba; - - TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver)); - - o = (java_lang_Throwable *) receiver; - - ba = stacktrace_get_current(); - - if (ba == NULL) - return; - - LLNI_field_set_ref(o, backtrace, (java_lang_Object *) ba); -} - - -/* JVM_PrintStackTrace */ - -void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable) -{ - log_println("JVM_PrintStackTrace: IMPLEMENT ME!"); -} - - -/* JVM_GetStackTraceDepth */ - -jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable) -{ - java_lang_Throwable *to; - java_lang_Object *o; - java_handle_bytearray_t *ba; - stacktrace_t *st; - int32_t depth; - - TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable)); - - if (throwable == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - to = (java_lang_Throwable *) throwable; - - LLNI_field_get_ref(to, backtrace, o); - - ba = (java_handle_bytearray_t *) o; - - if (ba == NULL) - return 0; - - /* We need a critical section here as the stacktrace structure is - mapped onto a Java byte-array. */ - - LLNI_CRITICAL_START; - - st = (stacktrace_t *) LLNI_array_data(ba); - - depth = st->length; - - LLNI_CRITICAL_END; - - return depth; -} - - -/* JVM_GetStackTraceElement */ - -jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index) -{ - java_lang_Throwable *to; - java_lang_Object *o; - java_handle_bytearray_t *ba; - stacktrace_t *st; - stacktrace_entry_t *ste; - codeinfo *code; - methodinfo *m; - classinfo *c; - java_lang_StackTraceElement *steo; - java_handle_t* declaringclass; - java_lang_String *filename; - int32_t linenumber; - - TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index)); - - to = (java_lang_Throwable *) throwable; - - LLNI_field_get_ref(to, backtrace, o); - - ba = (java_handle_bytearray_t *) o; - - /* FIXME critical section */ - - st = (stacktrace_t *) LLNI_array_data(ba); - - if ((index < 0) || (index >= st->length)) { - /* XXX This should be an IndexOutOfBoundsException (check this - again). */ - - exceptions_throw_arrayindexoutofboundsexception(); - return NULL; - } - - /* Get the stacktrace entry. */ - - ste = &(st->entries[index]); - - /* Get the codeinfo, methodinfo and classinfo. */ - - code = ste->code; - m = code->m; - c = m->clazz; - - /* allocate a new StackTraceElement */ - - steo = (java_lang_StackTraceElement *) - builtin_new(class_java_lang_StackTraceElement); - - if (steo == NULL) - return NULL; - - /* get filename */ - - if (!(m->flags & ACC_NATIVE)) { - if (c->sourcefile != NULL) - filename = (java_lang_String *) javastring_new(c->sourcefile); - else - filename = NULL; - } - else - filename = NULL; - - /* get line number */ - - if (m->flags & ACC_NATIVE) { - linenumber = -2; - } - else { - /* FIXME The linenumbertable_linenumber_for_pc could change - the methodinfo pointer when hitting an inlined method. */ - - linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc); - linenumber = (linenumber == 0) ? -1 : linenumber; - } - - /* get declaring class name */ - - declaringclass = class_get_classname(c); - - /* fill the java.lang.StackTraceElement element */ - - /* FIXME critical section */ - - steo->declaringClass = (java_lang_String*) declaringclass; - steo->methodName = (java_lang_String*) javastring_new(m->name); - steo->fileName = filename; - steo->lineNumber = linenumber; - - return (jobject) steo; -} - - -/* JVM_IHashCode */ - -jint JVM_IHashCode(JNIEnv* env, jobject handle) -{ - TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle)); - - return (jint) ((ptrint) handle); -} - - -/* JVM_MonitorWait */ - -void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms) -{ -#if defined(ENABLE_THREADS) - java_handle_t *o; -#endif - - TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms)); - if (ms < 0) { -/* exceptions_throw_illegalargumentexception("argument out of range"); */ - exceptions_throw_illegalargumentexception(); - return; - } - -#if defined(ENABLE_THREADS) - o = (java_handle_t *) handle; - - lock_wait_for_object(o, ms, 0); -#endif -} - - -/* JVM_MonitorNotify */ - -void JVM_MonitorNotify(JNIEnv* env, jobject handle) -{ -#if defined(ENABLE_THREADS) - java_handle_t *o; -#endif - - TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle)); - -#if defined(ENABLE_THREADS) - o = (java_handle_t *) handle; - - lock_notify_object(o); -#endif -} - - -/* JVM_MonitorNotifyAll */ - -void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle) -{ -#if defined(ENABLE_THREADS) - java_handle_t *o; -#endif - - TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle)); - -#if defined(ENABLE_THREADS) - o = (java_handle_t *) handle; - - lock_notify_all_object(o); -#endif -} - - -/* JVM_Clone */ - -jobject JVM_Clone(JNIEnv* env, jobject handle) -{ - TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle)); - - return (jobject) builtin_clone(env, (java_handle_t *) handle); -} - - -/* JVM_InitializeCompiler */ - -void JVM_InitializeCompiler (JNIEnv *env, jclass compCls) -{ - log_println("JVM_InitializeCompiler : IMPLEMENT ME!"); -} - - -/* JVM_IsSilentCompiler */ - -jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls) -{ - log_println("JVM_IsSilentCompiler: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_CompileClass */ - -jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls) -{ - log_println("JVM_CompileClass: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_CompileClasses */ - -jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname) -{ - log_println("JVM_CompileClasses: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_CompilerCommand */ - -jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg) -{ - log_println("JVM_CompilerCommand: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_EnableCompiler */ - -void JVM_EnableCompiler(JNIEnv *env, jclass compCls) -{ - TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls)); - PRINTJVMWARNINGS(("JVM_EnableCompiler not supported")); -} - - -/* JVM_DisableCompiler */ - -void JVM_DisableCompiler(JNIEnv *env, jclass compCls) -{ - TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls)); - PRINTJVMWARNINGS(("JVM_DisableCompiler not supported")); -} - - -/* JVM_GetLastErrorString */ - -jint JVM_GetLastErrorString(char *buf, int len) -{ - TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len)); - - return hpi_system->GetLastErrorString(buf, len); -} - - -/* JVM_NativePath */ - -char *JVM_NativePath(char *path) -{ - TRACEJVMCALLS(("JVM_NativePath(path=%s)", path)); - - return hpi_file->NativePath(path); -} - - -/* JVM_GetCallerClass */ - -jclass JVM_GetCallerClass(JNIEnv* env, int depth) -{ - classinfo *c; - - TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth)); - - c = stacktrace_get_caller_class(depth); - - return (jclass) c; -} - - -/* JVM_FindPrimitiveClass */ - -jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s) -{ - classinfo *c; - utf *u; - - TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s)); - - u = utf_new_char(s); - c = primitive_class_get_by_name(u); - - return (jclass) LLNI_classinfo_wrap(c); -} - - -/* JVM_ResolveClass */ - -void JVM_ResolveClass(JNIEnv* env, jclass cls) -{ - TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls)); - PRINTJVMWARNINGS(("JVM_ResolveClass not implemented")); -} - - -/* JVM_FindClassFromClassLoader */ - -jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError) -{ - classinfo *c; - utf *u; - classloader_t *cl; - - TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError)); - - /* As of now, OpenJDK does not call this function with throwError - is true. */ - - assert(throwError == false); - - u = utf_new_char(name); - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - c = load_class_from_classloader(u, cl); - - if (c == NULL) - return NULL; - - if (init) - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return NULL; - - return (jclass) LLNI_classinfo_wrap(c); -} - - -/* JVM_FindClassFromClass */ - -jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from) -{ - log_println("JVM_FindClassFromClass: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_DefineClass */ - -jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd) -{ - log_println("JVM_DefineClass: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_DefineClassWithSource */ - -jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source) -{ - classinfo *c; - utf *u; - classloader_t *cl; - - TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source)); - - if (name != NULL) - u = utf_new_char(name); - else - u = NULL; - - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - /* XXX do something with source */ - - c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd); - - return (jclass) LLNI_classinfo_wrap(c); -} - - -/* JVM_FindLoadedClass */ - -jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name) -{ - classloader_t *cl; - utf *u; - classinfo *c; - - TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name)); - - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - u = javastring_toutf((java_handle_t *) name, true); - c = classcache_lookup(cl, u); - - return (jclass) LLNI_classinfo_wrap(c); -} - - -/* JVM_GetClassName */ - -jstring JVM_GetClassName(JNIEnv *env, jclass cls) -{ - classinfo* c; - - TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - return (jstring) class_get_classname(c); -} - - -/* JVM_GetClassInterfaces */ - -jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - oa = class_get_interfaces(c); - - return (jobjectArray) oa; -} - - -/* JVM_GetClassLoader */ - -jobject JVM_GetClassLoader(JNIEnv *env, jclass cls) -{ - classinfo *c; - classloader_t *cl; - - TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - cl = class_get_classloader(c); - - TRACEJVMCALLSEXIT(("->%p", cl)); - - return (jobject) cl; -} - - -/* JVM_IsInterface */ - -jboolean JVM_IsInterface(JNIEnv *env, jclass cls) -{ - classinfo *c; - - TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - return class_is_interface(c); -} - - -/* JVM_GetClassSigners */ - -jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls) -{ - log_println("JVM_GetClassSigners: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_SetClassSigners */ - -void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers) -{ - classinfo *c; - java_handle_objectarray_t *hoa; - - TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers)); - - c = LLNI_classinfo_unwrap(cls); - - hoa = (java_handle_objectarray_t *) signers; - - /* This call is ignored for primitive types and arrays. Signers - are only set once, ClassLoader.java, and thus shouldn't be - called with an array. Only the bootstrap loader creates - arrays. */ - - if (class_is_primitive(c) || class_is_array(c)) - return; - - LLNI_classinfo_field_set(c, signers, hoa); -} - - -/* JVM_GetProtectionDomain */ - -jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls) -{ - classinfo *c; - - TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - if (c == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* Primitive types do not have a protection domain. */ - - if (class_is_primitive(c)) - return NULL; - - return (jobject) c->protectiondomain; -} - - -/* JVM_SetProtectionDomain */ - -void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain) -{ - log_println("JVM_SetProtectionDomain: IMPLEMENT ME!"); -} - - -/* JVM_DoPrivileged */ - -jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException) -{ - java_handle_t *h; - classinfo *c; - methodinfo *m; - java_handle_t *result; - java_handle_t *e; - - TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException)); - - h = (java_handle_t *) action; - LLNI_class_get(h, c); - - if (action == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* lookup run() method (throw no exceptions) */ - - m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c, - false); - - if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) { - exceptions_throw_internalerror("No run method"); - return NULL; - } - - /* XXX It seems something with a privileged stack needs to be done - here. */ - - result = vm_call_method(m, h); - - e = exceptions_get_exception(); - - if (e != NULL) { - if ( builtin_instanceof(e, class_java_lang_Exception) && - !builtin_instanceof(e, class_java_lang_RuntimeException)) { - exceptions_clear_exception(); - exceptions_throw_privilegedactionexception(e); - } - - return NULL; - } - - return (jobject) result; -} - - -/* JVM_GetInheritedAccessControlContext */ - -jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls) -{ - log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetStackAccessControlContext */ - -jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls) -{ - TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls)); - - /* XXX All stuff I tested so far works without that function. At - some point we have to implement it, but I disable the output - for now to make IcedTea happy. */ - - return NULL; -} - - -/* JVM_IsArrayClass */ - -jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls) -{ - classinfo *c; - - TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - return class_is_array(c); -} - - -/* JVM_IsPrimitiveClass */ - -jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls) -{ - classinfo *c; - - TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - return class_is_primitive(c); -} - - -/* JVM_GetComponentType */ - -jclass JVM_GetComponentType(JNIEnv *env, jclass cls) -{ - classinfo *component; - classinfo *c; - - TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - component = class_get_componenttype(c); - - return (jclass) LLNI_classinfo_wrap(component); -} - - -/* JVM_GetClassModifiers */ - -jint JVM_GetClassModifiers(JNIEnv *env, jclass cls) -{ - classinfo *c; - int32_t flags; - - TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - flags = class_get_modifiers(c, false); - - return flags; -} - - -/* JVM_GetDeclaredClasses */ - -jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass)); - - c = LLNI_classinfo_unwrap(ofClass); - - oa = class_get_declaredclasses(c, false); - - return (jobjectArray) oa; -} - - -/* JVM_GetDeclaringClass */ - -jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass) -{ - classinfo *c; - classinfo *dc; - - TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass)); - - c = LLNI_classinfo_unwrap(ofClass); - - dc = class_get_declaringclass(c); - - return (jclass) LLNI_classinfo_wrap(dc); -} - - -/* JVM_GetClassSignature */ - -jstring JVM_GetClassSignature(JNIEnv *env, jclass cls) -{ - classinfo *c; - utf *u; - java_handle_t *s; - - TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - /* Get the signature of the class. */ - - u = class_get_signature(c); - - if (u == NULL) - return NULL; - - /* Convert UTF-string to a Java-string. */ - - s = javastring_new(u); - - return (jstring) s; -} - - -/* JVM_GetClassAnnotations */ - -jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls) -{ - classinfo *c = NULL; /* classinfo for 'cls' */ - java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ - - TRACEJVMCALLS(("JVM_GetClassAnnotations: cls=%p", cls)); - - if (cls == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - c = LLNI_classinfo_unwrap(cls); - - /* get annotations: */ - annotations = class_get_annotations(c); - - return (jbyteArray)annotations; -} - - -/* JVM_GetFieldAnnotations */ - -jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field) -{ - java_lang_reflect_Field *rf = NULL; /* java.lang.reflect.Field for 'field' */ - java_handle_bytearray_t *ba = NULL; /* unparsed annotations */ - - TRACEJVMCALLS(("JVM_GetFieldAnnotations: field=%p", field)); - - if (field == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - rf = (java_lang_reflect_Field*)field; - - LLNI_field_get_ref(rf, annotations, ba); - - return (jbyteArray)ba; -} - - -/* JVM_GetMethodAnnotations */ - -jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method) -{ - java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */ - java_handle_bytearray_t *ba = NULL; /* unparsed annotations */ - - TRACEJVMCALLS(("JVM_GetMethodAnnotations: method=%p", method)); - - if (method == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - rm = (java_lang_reflect_Method*)method; - - LLNI_field_get_ref(rm, annotations, ba); - - return (jbyteArray)ba; -} - - -/* JVM_GetMethodDefaultAnnotationValue */ - -jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method) -{ - java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */ - java_handle_bytearray_t *ba = NULL; /* unparsed annotation default value */ - - TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue: method=%p", method)); - - if (method == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - rm = (java_lang_reflect_Method*)method; - - LLNI_field_get_ref(rm, annotationDefault, ba); - - return (jbyteArray)ba; -} - - -/* JVM_GetMethodParameterAnnotations */ - -jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method) -{ - java_lang_reflect_Method *rm = NULL; /* java.lang.reflect.Method for 'method' */ - java_handle_bytearray_t *ba = NULL; /* unparsed parameter annotations */ - - TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations: method=%p", method)); - - if (method == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - rm = (java_lang_reflect_Method*)method; - - LLNI_field_get_ref(rm, parameterAnnotations, ba); - - return (jbyteArray)ba; -} - - -/* JVM_GetClassDeclaredFields */ - -jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly)); - - c = LLNI_classinfo_unwrap(ofClass); - - oa = class_get_declaredfields(c, publicOnly); - - return (jobjectArray) oa; -} - - -/* JVM_GetClassDeclaredMethods */ - -jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly)); - - c = LLNI_classinfo_unwrap(ofClass); - - oa = class_get_declaredmethods(c, publicOnly); - - return (jobjectArray) oa; -} - - -/* JVM_GetClassDeclaredConstructors */ - -jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly) -{ - classinfo *c; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly)); - - c = LLNI_classinfo_unwrap(ofClass); - - oa = class_get_declaredconstructors(c, publicOnly); - - return (jobjectArray) oa; -} - - -/* JVM_GetClassAccessFlags */ - -jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls) -{ - classinfo *c; - - TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls)); - - c = LLNI_classinfo_unwrap(cls); - - /* Primitive type classes have the correct access flags. */ - - return c->flags & ACC_CLASS_REFLECT_MASK; -} - - -/* JVM_GetClassConstantPool */ - -jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls) -{ -#if defined(ENABLE_ANNOTATIONS) - sun_reflect_ConstantPool *constantPool = NULL; - /* constant pool object for the class refered by 'cls' */ - java_lang_Object *constantPoolOop = (java_lang_Object*)cls; - /* constantPoolOop field of the constant pool object */ - - TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls)); - - constantPool = - (sun_reflect_ConstantPool*)native_new_and_init( - class_sun_reflect_ConstantPool); - - if (constantPool == NULL) { - /* out of memory */ - return NULL; - } - - LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop); - - return (jobject)constantPool; -#else - log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls); - return NULL; -#endif -} - - -/* JVM_ConstantPoolGetSize */ - -jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool) -{ - classinfo *c; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool)); - - c = LLNI_classinfo_unwrap(jcpool); - - return c->cpcount; -} - - -/* JVM_ConstantPoolGetClassAt */ - -jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_classref *ref; /* classref to the class at constant pool index 'index' */ - classinfo *c; /* classinfo of the class for which 'this' is the constant pool */ - classinfo *result; /* classinfo of the class at constant pool index 'index' */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index)); - - c = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - result = resolve_classref_eager(ref); - - return (jclass) LLNI_classinfo_wrap(result); -} - - -/* JVM_ConstantPoolGetClassAtIfLoaded */ - -jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_classref *ref; /* classref to the class at constant pool index 'index' */ - classinfo *c; /* classinfo of the class for which 'this' is the constant pool */ - classinfo *result; /* classinfo of the class at constant pool index 'index' */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index)); - - c = LLNI_classinfo_unwrap(jcpool); - - ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - if (!resolve_classref(NULL, ref, resolveLazy, true, true, &result)) { - return NULL; - } - - if ((result == NULL) || !(result->state & CLASS_LOADED)) { - return NULL; - } - - return (jclass) LLNI_classinfo_wrap(result); -} - - -/* JVM_ConstantPoolGetMethodAt */ - -jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX: is that right? or do I have to use resolve_method_*? */ - return (jobject)reflect_method_new(ref->p.method); -} - - -/* JVM_ConstantPoolGetMethodAtIfLoaded */ - -jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */ - classinfo *c = NULL; /* resolved declaring class of the method */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) { - return NULL; - } - - if (c == NULL || !(c->state & CLASS_LOADED)) { - return NULL; - } - - return (jobject)reflect_method_new(ref->p.method); -} - - -/* JVM_ConstantPoolGetFieldAt */ - -jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - return (jobject)reflect_field_new(ref->p.field); -} - - -/* JVM_ConstantPoolGetFieldAtIfLoaded */ - -jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */ - classinfo *c; /* resolved declaring class for the field */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) { - return NULL; - } - - if (c == NULL || !(c->state & CLASS_LOADED)) { - return NULL; - } - - return (jobject)reflect_field_new(ref->p.field); -} - - -/* JVM_ConstantPoolGetMemberRefInfoAt */ - -jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index); - - /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */ - - return NULL; -} - - -/* JVM_ConstantPoolGetIntAt */ - -jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_integer *ref; /* reference to the int value in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* JVM_ConstantPoolGetLongAt */ - -jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_long *ref; /* reference to the long value in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* JVM_ConstantPoolGetFloatAt */ - -jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_float *ref; /* reference to the float value in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* JVM_ConstantPoolGetDoubleAt */ - -jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - constant_double *ref; /* reference to the double value in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - return ref->value; -} - - -/* JVM_ConstantPoolGetStringAt */ - -jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - utf *ref; /* utf object for the string in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (utf*)class_getconstant(cls, index, CONSTANT_String); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX: I hope literalstring_new is the right Function. */ - return (jstring)literalstring_new(ref); -} - - -/* JVM_ConstantPoolGetUTF8At */ - -jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index) -{ - utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */ - classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ - - TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index)); - - cls = LLNI_classinfo_unwrap(jcpool); - ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8); - - if (ref == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX: I hope literalstring_new is the right Function. */ - return (jstring)literalstring_new(ref); -} - - -/* JVM_DesiredAssertionStatus */ - -jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls) -{ -#if defined(ENABLE_ASSERTION) - assertion_name_t *item; - classinfo *c; - jboolean status; - utf *name; - - TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls)); - - c = LLNI_classinfo_unwrap(cls); - - if (c->classloader == NULL) { - status = (jboolean)assertion_system_enabled; - } - else { - status = (jboolean)assertion_user_enabled; - } - - if (list_assertion_names != NULL) { - item = (assertion_name_t *)list_first(list_assertion_names); - while (item != NULL) { - name = utf_new_char(item->name); - if (name == c->packagename) { - status = (jboolean)item->enabled; - } - else if (name == c->name) { - status = (jboolean)item->enabled; - } - - item = (assertion_name_t *)list_next(list_assertion_names, item); - } - } - - return status; -#else - return (jboolean)false; -#endif -} - - -/* JVM_AssertionStatusDirectives */ - -jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused) -{ - classinfo *c; - java_lang_AssertionStatusDirectives *o; - java_handle_objectarray_t *classes; - java_handle_objectarray_t *packages; - java_booleanarray_t *classEnabled; - java_booleanarray_t *packageEnabled; -#if defined(ENABLE_ASSERTION) - assertion_name_t *item; - java_handle_t *js; - s4 i, j; -#endif - - TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused)); - - c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives")); - - if (c == NULL) - return NULL; - - o = (java_lang_AssertionStatusDirectives *) builtin_new(c); - - if (o == NULL) - return NULL; - -#if defined(ENABLE_ASSERTION) - classes = builtin_anewarray(assertion_class_count, class_java_lang_Object); -#else - classes = builtin_anewarray(0, class_java_lang_Object); -#endif - if (classes == NULL) - return NULL; - -#if defined(ENABLE_ASSERTION) - packages = builtin_anewarray(assertion_package_count, class_java_lang_Object); -#else - packages = builtin_anewarray(0, class_java_lang_Object); -#endif - if (packages == NULL) - return NULL; - -#if defined(ENABLE_ASSERTION) - classEnabled = builtin_newarray_boolean(assertion_class_count); -#else - classEnabled = builtin_newarray_boolean(0); -#endif - if (classEnabled == NULL) - return NULL; - -#if defined(ENABLE_ASSERTION) - packageEnabled = builtin_newarray_boolean(assertion_package_count); -#else - packageEnabled = builtin_newarray_boolean(0); -#endif - if (packageEnabled == NULL) - return NULL; - -#if defined(ENABLE_ASSERTION) - /* initialize arrays */ - - if (list_assertion_names != NULL) { - i = 0; - j = 0; - - item = (assertion_name_t *)list_first(list_assertion_names); - while (item != NULL) { - js = javastring_new_from_ascii(item->name); - if (js == NULL) { - return NULL; - } - - if (item->package == false) { - classes->data[i] = js; - classEnabled->data[i] = (jboolean) item->enabled; - i += 1; - } - else { - packages->data[j] = js; - packageEnabled->data[j] = (jboolean) item->enabled; - j += 1; - } - - item = (assertion_name_t *)list_next(list_assertion_names, item); - } - } -#endif - - /* set instance fields */ - - o->classes = classes; - o->packages = packages; - o->classEnabled = classEnabled; - o->packageEnabled = packageEnabled; - - return (jobject) o; -} - - -/* JVM_GetClassNameUTF */ - -const char *JVM_GetClassNameUTF(JNIEnv *env, jclass cls) -{ - log_println("JVM_GetClassNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassCPTypes */ - -void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types) -{ - log_println("JVM_GetClassCPTypes: IMPLEMENT ME!"); -} - - -/* JVM_GetClassCPEntriesCount */ - -jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls) -{ - log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetClassFieldsCount */ - -jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls) -{ - log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetClassMethodsCount */ - -jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls) -{ - log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxExceptionIndexes */ - -void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions) -{ - log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!"); -} - - -/* JVM_GetMethodIxExceptionsCount */ - -jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index) -{ - log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxByteCode */ - -void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code) -{ - log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!"); -} - - -/* JVM_GetMethodIxByteCodeLength */ - -jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index) -{ - log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxExceptionTableEntry */ - -void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry) -{ - log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!"); -} - - -/* JVM_GetMethodIxExceptionTableLength */ - -jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index) -{ - log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxModifiers */ - -jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index) -{ - log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetFieldIxModifiers */ - -jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index) -{ - log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxLocalsCount */ - -jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index) -{ - log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxArgsSize */ - -jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index) -{ - log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxMaxStack */ - -jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index) -{ - log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_IsConstructorIx */ - -jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index) -{ - log_println("JVM_IsConstructorIx: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetMethodIxNameUTF */ - -const char *JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index) -{ - log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetMethodIxSignatureUTF */ - -const char *JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index) -{ - log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPFieldNameUTF */ - -const char *JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPMethodNameUTF */ - -const char *JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPMethodSignatureUTF */ - -const char *JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPFieldSignatureUTF */ - -const char *JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPClassNameUTF */ - -const char *JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPFieldClassNameUTF */ - -const char *JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPMethodClassNameUTF */ - -const char *JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) -{ - log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetCPFieldModifiers */ - -jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls) -{ - log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetCPMethodModifiers */ - -jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls) -{ - log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_ReleaseUTF */ - -void JVM_ReleaseUTF(const char *utf) -{ - log_println("JVM_ReleaseUTF: IMPLEMENT ME!"); -} - - -/* JVM_IsSameClassPackage */ - -jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2) -{ - log_println("JVM_IsSameClassPackage: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_Open */ - -/* Taken from: hotspot/src/share/vm/prims/jvm.h */ - -/* - * JVM I/O error codes - */ -#define JVM_EEXIST -100 - -jint JVM_Open(const char *fname, jint flags, jint mode) -{ - int result; - - TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode)); - - result = hpi_file->Open(fname, flags, mode); - - if (result >= 0) { - return result; - } - else { - switch (errno) { - case EEXIST: - return JVM_EEXIST; - default: - return -1; - } - } -} - - -/* JVM_Close */ - -jint JVM_Close(jint fd) -{ - TRACEJVMCALLS(("JVM_Close(fd=%d)", fd)); - - return hpi_file->Close(fd); -} - - -/* JVM_Read */ - -jint JVM_Read(jint fd, char *buf, jint nbytes) -{ - TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes)); - - return (jint) hpi_file->Read(fd, buf, nbytes); -} - - -/* JVM_Write */ - -jint JVM_Write(jint fd, char *buf, jint nbytes) -{ - TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes)); - - return (jint) hpi_file->Write(fd, buf, nbytes); -} - - -/* JVM_Available */ - -jint JVM_Available(jint fd, jlong *pbytes) -{ - TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes)); - - return hpi_file->Available(fd, pbytes); -} - - -/* JVM_Lseek */ - -jlong JVM_Lseek(jint fd, jlong offset, jint whence) -{ - TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence)); - - return hpi_file->Seek(fd, (off_t) offset, whence); -} - - -/* JVM_SetLength */ - -jint JVM_SetLength(jint fd, jlong length) -{ - TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length)); - - return hpi_file->SetLength(fd, length); -} - - -/* JVM_Sync */ - -jint JVM_Sync(jint fd) -{ - TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd)); - - return hpi_file->Sync(fd); -} - - -/* JVM_StartThread */ - -void JVM_StartThread(JNIEnv* env, jobject jthread) -{ - TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread)); - - threads_thread_start((java_handle_t *) jthread); -} - - -/* JVM_StopThread */ - -void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable) -{ - log_println("JVM_StopThread: IMPLEMENT ME!"); -} - - -/* JVM_IsThreadAlive */ - -jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread) -{ - java_handle_t *h; - threadobject *t; - bool result; - - TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread)); - - h = (java_handle_t *) jthread; - t = thread_get_thread(h); - - /* The threadobject is null when a thread is created in Java. The - priority is set later during startup. */ - - if (t == NULL) - return 0; - - result = threads_thread_is_alive(t); - - return result; -} - - -/* JVM_SuspendThread */ - -void JVM_SuspendThread(JNIEnv* env, jobject jthread) -{ - log_println("JVM_SuspendThread: IMPLEMENT ME!"); -} - - -/* JVM_ResumeThread */ - -void JVM_ResumeThread(JNIEnv* env, jobject jthread) -{ - log_println("JVM_ResumeThread: IMPLEMENT ME!"); -} - - -/* JVM_SetThreadPriority */ - -void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio) -{ - java_handle_t *h; - threadobject *t; - - TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio)); - - h = (java_handle_t *) jthread; - t = thread_get_thread(h); - - /* The threadobject is null when a thread is created in Java. The - priority is set later during startup. */ - - if (t == NULL) - return; - - threads_set_thread_priority(t->tid, prio); -} - - -/* JVM_Yield */ - -void JVM_Yield(JNIEnv *env, jclass threadClass) -{ - TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass)); - - threads_yield(); -} - - -/* JVM_Sleep */ - -void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis) -{ - TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis)); - - threads_sleep(millis, 0); -} - - -/* JVM_CurrentThread */ - -jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass) -{ - java_object_t *o; - - TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass)); - - o = thread_get_current_object(); - - return (jobject) o; -} - - -/* JVM_CountStackFrames */ - -jint JVM_CountStackFrames(JNIEnv* env, jobject jthread) -{ - log_println("JVM_CountStackFrames: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_Interrupt */ - -void JVM_Interrupt(JNIEnv* env, jobject jthread) -{ - java_handle_t *h; - threadobject *t; - - TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread)); - - h = (java_handle_t *) jthread; - t = thread_get_thread(h); - - if (t == NULL) - return; - - threads_thread_interrupt(t); -} - - -/* JVM_IsInterrupted */ - -jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted) -{ - java_handle_t *h; - threadobject *t; - jboolean interrupted; - - TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted)); - - h = (java_handle_t *) jthread; - t = thread_get_thread(h); - - interrupted = thread_is_interrupted(t); - - if (interrupted && clear_interrupted) - thread_set_interrupted(t, false); - - return interrupted; -} - - -/* JVM_HoldsLock */ - -jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj) -{ - java_handle_t *h; - bool result; - - TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj)); - - h = (java_handle_t *) obj; - - if (h == NULL) { - exceptions_throw_nullpointerexception(); - return JNI_FALSE; - } - - result = lock_is_held_by_current_thread(h); - - return result; -} - - -/* JVM_DumpAllStacks */ - -void JVM_DumpAllStacks(JNIEnv* env, jclass unused) -{ - log_println("JVM_DumpAllStacks: IMPLEMENT ME!"); -} - - -/* JVM_CurrentLoadedClass */ - -jclass JVM_CurrentLoadedClass(JNIEnv *env) -{ - log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_CurrentClassLoader */ - -jobject JVM_CurrentClassLoader(JNIEnv *env) -{ - /* XXX if a method in a class in a trusted loader is in a - doPrivileged, return NULL */ - - log_println("JVM_CurrentClassLoader: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassContext */ - -jobjectArray JVM_GetClassContext(JNIEnv *env) -{ - TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env)); - - return (jobjectArray) stacktrace_getClassContext(); -} - - -/* JVM_ClassDepth */ - -jint JVM_ClassDepth(JNIEnv *env, jstring name) -{ - log_println("JVM_ClassDepth: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_ClassLoaderDepth */ - -jint JVM_ClassLoaderDepth(JNIEnv *env) -{ - log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetSystemPackage */ - -jstring JVM_GetSystemPackage(JNIEnv *env, jstring name) -{ - java_handle_t *s; - utf *u; - utf *result; - - TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name)); - -/* s = package_find(name); */ - u = javastring_toutf((java_handle_t *) name, false); - - result = package_find(u); - - if (result != NULL) - s = javastring_new(result); - else - s = NULL; - - return (jstring) s; -} - - -/* JVM_GetSystemPackages */ - -jobjectArray JVM_GetSystemPackages(JNIEnv *env) -{ - log_println("JVM_GetSystemPackages: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_AllocateNewObject */ - -jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass) -{ - log_println("JVM_AllocateNewObject: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_AllocateNewArray */ - -jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length) -{ - log_println("JVM_AllocateNewArray: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_LatestUserDefinedLoader */ - -jobject JVM_LatestUserDefinedLoader(JNIEnv *env) -{ - classloader_t *cl; - - TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env)); - - cl = stacktrace_first_nonnull_classloader(); - - return (jobject) cl; -} - - -/* JVM_LoadClass0 */ - -jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName) -{ - log_println("JVM_LoadClass0: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetArrayLength */ - -jint JVM_GetArrayLength(JNIEnv *env, jobject arr) -{ - java_handle_t *a; - - TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr)); - - a = (java_handle_t *) arr; - - return array_length_get(a); -} - - -/* JVM_GetArrayElement */ - -jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index) -{ - java_handle_t *a; - java_handle_t *o; - - TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index)); - - a = (java_handle_t *) arr; - -/* if (!class_is_array(a->objheader.vftbl->class)) { */ -/* exceptions_throw_illegalargumentexception(); */ -/* return NULL; */ -/* } */ - - o = array_element_get(a, index); - - return (jobject) o; -} - - -/* JVM_GetPrimitiveArrayElement */ - -jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode) -{ - jvalue jv; - - log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!"); - - jv.l = NULL; - - return jv; -} - - -/* JVM_SetArrayElement */ - -void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val) -{ - java_handle_t *a; - java_handle_t *value; - - TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val)); - - a = (java_handle_t *) arr; - value = (java_handle_t *) val; - - array_element_set(a, index, value); -} - - -/* JVM_SetPrimitiveArrayElement */ - -void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode) -{ - log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!"); -} - - -/* JVM_NewArray */ - -jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length) -{ - classinfo *c; - classinfo *pc; - java_handle_t *a; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length)); - - if (eltClass == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* NegativeArraySizeException is checked in builtin_newarray. */ - - c = LLNI_classinfo_unwrap(eltClass); - - /* Create primitive or object array. */ - - if (class_is_primitive(c)) { - pc = primitive_arrayclass_get_by_name(c->name); - - /* void arrays are not allowed. */ - - if (pc == NULL) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - a = builtin_newarray(length, pc); - - return (jobject) a; - } - else { - oa = builtin_anewarray(length, c); - - return (jobject) oa; - } -} - - -/* JVM_NewMultiArray */ - -jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim) -{ - classinfo *c; - java_handle_intarray_t *ia; - int32_t length; - long *dims; - int32_t value; - int32_t i; - classinfo *ac; - java_handle_objectarray_t *a; - - TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim)); - - if (eltClass == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* NegativeArraySizeException is checked in builtin_newarray. */ - - c = LLNI_classinfo_unwrap(eltClass); - - ia = (java_handle_intarray_t *) dim; - - length = array_length_get((java_handle_t *) ia); - - /* We check here for exceptions thrown in array_length_get, - otherwise these exceptions get overwritten by the following - IllegalArgumentException. */ - - if (length < 0) - return NULL; - - if ((length <= 0) || (length > /* MAX_DIM */ 255)) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* XXX This is just a quick hack to get it working. */ - - dims = MNEW(long, length); - - for (i = 0; i < length; i++) { - value = LLNI_array_direct(ia, i); - dims[i] = (long) value; - } - - /* Create an array-class if necessary. */ - - if (class_is_primitive(c)) - ac = primitive_arrayclass_get_by_name(c->name); - else - ac = class_array_of(c, true); - - if (ac == NULL) - return NULL; - - a = builtin_multianewarray(length, (java_handle_t *) ac, dims); - - return (jobject) a; -} - - -/* JVM_InitializeSocketLibrary */ - -jint JVM_InitializeSocketLibrary() -{ - TRACEJVMCALLS(("JVM_InitializeSocketLibrary()")); - - return hpi_initialize_socket_library(); -} - - -/* JVM_Socket */ - -jint JVM_Socket(jint domain, jint type, jint protocol) -{ - TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol)); - - return system_socket(domain, type, protocol); -} - - -/* JVM_SocketClose */ - -jint JVM_SocketClose(jint fd) -{ - TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd)); - - return system_close(fd); -} - - -/* JVM_SocketShutdown */ - -jint JVM_SocketShutdown(jint fd, jint howto) -{ - TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto)); - - return system_shutdown(fd, howto); -} - - -/* JVM_Recv */ - -jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags) -{ - log_println("JVM_Recv: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_Send */ - -jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags) -{ - log_println("JVM_Send: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_Timeout */ - -jint JVM_Timeout(int fd, long timeout) -{ - log_println("JVM_Timeout: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_Listen */ - -jint JVM_Listen(jint fd, jint count) -{ - TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count)); - - return system_listen(fd, count); -} - - -/* JVM_Connect */ - -jint JVM_Connect(jint fd, struct sockaddr *him, jint len) -{ - TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len)); - - return system_connect(fd, him, len); -} - - -/* JVM_Bind */ - -jint JVM_Bind(jint fd, struct sockaddr *him, jint len) -{ - log_println("JVM_Bind: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_Accept */ - -jint JVM_Accept(jint fd, struct sockaddr *him, jint *len) -{ - TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len)); - - return system_accept(fd, him, (socklen_t *) len); -} - - -/* JVM_RecvFrom */ - -jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen) -{ - log_println("JVM_RecvFrom: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetSockName */ - -jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len) -{ - TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len)); - - return system_getsockname(fd, him, (socklen_t *) len); -} - - -/* JVM_SendTo */ - -jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen) -{ - log_println("JVM_SendTo: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_SocketAvailable */ - -jint JVM_SocketAvailable(jint fd, jint *pbytes) -{ -#if defined(FIONREAD) - int bytes; - int result; - - TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes)); - - *pbytes = 0; - - result = ioctl(fd, FIONREAD, &bytes); - - if (result < 0) - return 0; - - *pbytes = bytes; - - return 1; -#else -# error FIONREAD not defined -#endif -} - - -/* JVM_GetSockOpt */ - -jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen) -{ - TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen)); - - return system_getsockopt(fd, level, optname, optval, (socklen_t *) optlen); -} - - -/* JVM_SetSockOpt */ - -jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen) -{ - TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen)); - - return system_setsockopt(fd, level, optname, optval, optlen); -} - - -/* JVM_GetHostName */ - -int JVM_GetHostName(char *name, int namelen) -{ - int result; - - TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen)); - - result = system_gethostname(name, namelen); - - TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name)); - - return result; -} - - -/* JVM_GetHostByAddr */ - -struct hostent *JVM_GetHostByAddr(const char* name, int len, int type) -{ - log_println("JVM_GetHostByAddr: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetHostByName */ - -struct hostent *JVM_GetHostByName(char* name) -{ - log_println("JVM_GetHostByName: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetProtoByName */ - -struct protoent *JVM_GetProtoByName(char* name) -{ - log_println("JVM_GetProtoByName: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_LoadLibrary */ - -void *JVM_LoadLibrary(const char *name) -{ - utf* u; - void* handle; - - TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name)); - - u = utf_new_char(name); - - handle = native_library_open(u); - - TRACEJVMCALLSEXIT(("->%p", handle)); - - return handle; -} - - -/* JVM_UnloadLibrary */ - -void JVM_UnloadLibrary(void* handle) -{ - TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle)); - - native_library_close(handle); -} - - -/* JVM_FindLibraryEntry */ - -void *JVM_FindLibraryEntry(void *handle, const char *name) -{ - lt_ptr symbol; - - TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name)); - - symbol = lt_dlsym(handle, name); - - TRACEJVMCALLSEXIT(("->%p", symbol)); - - return symbol; -} - - -/* JVM_IsNaN */ - -jboolean JVM_IsNaN(jdouble a) -{ - log_println("JVM_IsNaN: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_IsSupportedJNIVersion */ - -jboolean JVM_IsSupportedJNIVersion(jint version) -{ - TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version)); - - return jni_version_check(version); -} - - -/* JVM_InternString */ - -jstring JVM_InternString(JNIEnv *env, jstring str) -{ - TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str)); - - return (jstring) javastring_intern((java_handle_t *) str); -} - - -/* JVM_RawMonitorCreate */ - -JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void) -{ - java_object_t *o; - - TRACEJVMCALLS(("JVM_RawMonitorCreate()")); - - o = NEW(java_object_t); - - lock_init_object_lock(o); - - return o; -} - - -/* JVM_RawMonitorDestroy */ - -JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon) -{ - TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon)); - - FREE(mon, java_object_t); -} - - -/* JVM_RawMonitorEnter */ - -JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon) -{ - TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon)); - - (void) lock_monitor_enter((java_object_t *) mon); - - return 0; -} - - -/* JVM_RawMonitorExit */ - -JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) -{ - TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon)); - - (void) lock_monitor_exit((java_object_t *) mon); -} - - -/* JVM_SetPrimitiveFieldValues */ - -void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data) -{ - log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!"); -} - - -/* JVM_GetPrimitiveFieldValues */ - -void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data) -{ - log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!"); -} - - -/* JVM_AccessVMBooleanFlag */ - -jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get) -{ - log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_AccessVMIntFlag */ - -jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get) -{ - log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_VMBreakPoint */ - -void JVM_VMBreakPoint(JNIEnv *env, jobject obj) -{ - log_println("JVM_VMBreakPoint: IMPLEMENT ME!"); -} - - -/* JVM_GetClassFields */ - -jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which) -{ - log_println("JVM_GetClassFields: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassMethods */ - -jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which) -{ - log_println("JVM_GetClassMethods: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassConstructors */ - -jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which) -{ - log_println("JVM_GetClassConstructors: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassField */ - -jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which) -{ - log_println("JVM_GetClassField: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassMethod */ - -jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which) -{ - log_println("JVM_GetClassMethod: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetClassConstructor */ - -jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which) -{ - log_println("JVM_GetClassConstructor: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_NewInstance */ - -jobject JVM_NewInstance(JNIEnv *env, jclass cls) -{ - log_println("JVM_NewInstance: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetField */ - -jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj) -{ - log_println("JVM_GetField: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetPrimitiveField */ - -jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode) -{ - jvalue jv; - - log_println("JVM_GetPrimitiveField: IMPLEMENT ME!"); - - jv.l = NULL; - - return jv; -} - - -/* JVM_SetField */ - -void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val) -{ - log_println("JVM_SetField: IMPLEMENT ME!"); -} - - -/* JVM_SetPrimitiveField */ - -void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode) -{ - log_println("JVM_SetPrimitiveField: IMPLEMENT ME!"); -} - - -/* JVM_InvokeMethod */ - -jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0) -{ - java_lang_reflect_Method *rm; - classinfo *c; - int32_t slot; - int32_t override; - methodinfo *m; - java_handle_t *ro; - - TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0)); - - rm = (java_lang_reflect_Method *) method; - - LLNI_field_get_cls(rm, clazz, c); - LLNI_field_get_val(rm, slot, slot); - LLNI_field_get_val(rm, override, override); - - m = &(c->methods[slot]); - - ro = reflect_method_invoke(m, (java_handle_t *) obj, (java_handle_objectarray_t *) args0, override); - - return (jobject) ro; -} - - -/* JVM_NewInstanceFromConstructor */ - -jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0) -{ - java_lang_reflect_Constructor *rc; - classinfo *c; - int32_t slot; - int32_t override; - methodinfo *m; - java_handle_t *o; - - TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0)); - - rc = (java_lang_reflect_Constructor *) con; - - LLNI_field_get_cls(rc, clazz, c); - LLNI_field_get_val(rc, slot, slot); - LLNI_field_get_val(rc, override, override); - - m = &(c->methods[slot]); - - o = reflect_constructor_newinstance(m, (java_handle_objectarray_t *) args0, override); - - return (jobject) o; -} - - -/* JVM_SupportsCX8 */ - -jboolean JVM_SupportsCX8() -{ - TRACEJVMCALLS(("JVM_SupportsCX8()")); - - /* IMPLEMENT ME */ - - return 0; -} - - -/* JVM_CX8Field */ - -jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal) -{ - log_println("JVM_CX8Field: IMPLEMENT ME!"); - - return 0; -} - - -/* JVM_GetAllThreads */ - -jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy) -{ - log_println("JVM_GetAllThreads: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_DumpThreads */ - -jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads) -{ - log_println("JVM_DumpThreads: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetManagement */ - -void *JVM_GetManagement(jint version) -{ - TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version)); - - /* TODO We current don't support the management interface. */ - - return NULL; -} - - -/* JVM_InitAgentProperties */ - -jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties) -{ - log_println("JVM_InitAgentProperties: IMPLEMENT ME!"); - - return NULL; -} - - -/* JVM_GetEnclosingMethodInfo */ - -jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass) -{ - classinfo *c; - methodinfo *m; - java_handle_objectarray_t *oa; - - TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass)); - - c = LLNI_classinfo_unwrap(ofClass); - - if ((c == NULL) || class_is_primitive(c)) - return NULL; - - m = class_get_enclosingmethod_raw(c); - - if (m == NULL) - return NULL; - - oa = builtin_anewarray(3, class_java_lang_Object); - - if (oa == NULL) - return NULL; - - array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz)); - array_objectarray_element_set(oa, 1, javastring_new(m->name)); - array_objectarray_element_set(oa, 2, javastring_new(m->descriptor)); - - return (jobjectArray) oa; -} - - -/* JVM_GetThreadStateValues */ - -jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState) -{ - java_handle_intarray_t *ia; - - TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)", - env, javaThreadState)); - - /* If new thread states are added in future JDK and VM versions, - this should check if the JDK version is compatible with thread - states supported by the VM. Return NULL if not compatible. - - This function must map the VM java_lang_Thread::ThreadStatus - to the Java thread state that the JDK supports. */ - - switch (javaThreadState) { - case THREAD_STATE_NEW: - ia = builtin_newarray_int(1); - - if (ia == NULL) - return NULL; - - array_intarray_element_set(ia, 0, THREAD_STATE_NEW); - break; - - case THREAD_STATE_RUNNABLE: - ia = builtin_newarray_int(1); - - if (ia == NULL) - return NULL; - - array_intarray_element_set(ia, 0, THREAD_STATE_RUNNABLE); - break; - - case THREAD_STATE_BLOCKED: - ia = builtin_newarray_int(1); - - if (ia == NULL) - return NULL; - - array_intarray_element_set(ia, 0, THREAD_STATE_BLOCKED); - break; - - case THREAD_STATE_WAITING: - ia = builtin_newarray_int(2); - - if (ia == NULL) - return NULL; - - array_intarray_element_set(ia, 0, THREAD_STATE_WAITING); - /* XXX Implement parked stuff. */ -/* array_intarray_element_set(ia, 1, PARKED); */ - break; - - case THREAD_STATE_TIMED_WAITING: - ia = builtin_newarray_int(3); - - if (ia == NULL) - return NULL; - - /* XXX Not sure about that one. */ -/* array_intarray_element_set(ia, 0, SLEEPING); */ - array_intarray_element_set(ia, 0, THREAD_STATE_TIMED_WAITING); - /* XXX Implement parked stuff. */ -/* array_intarray_element_set(ia, 2, PARKED); */ - break; - - case THREAD_STATE_TERMINATED: - ia = builtin_newarray_int(1); - - if (ia == NULL) - return NULL; - - array_intarray_element_set(ia, 0, THREAD_STATE_TERMINATED); - break; - - default: - /* Unknown state - probably incompatible JDK version */ - return NULL; - } - - return (jintArray) ia; -} - - -/* JVM_GetThreadStateNames */ - -jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values) -{ - java_handle_intarray_t *ia; - java_handle_objectarray_t *oa; - java_object_t *s; - - TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)", - env, javaThreadState, values)); - - ia = (java_handle_intarray_t *) values; - - /* If new thread states are added in future JDK and VM versions, - this should check if the JDK version is compatible with thread - states supported by the VM. Return NULL if not compatible. - - This function must map the VM java_lang_Thread::ThreadStatus - to the Java thread state that the JDK supports. */ - - if (values == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - switch (javaThreadState) { - case THREAD_STATE_NEW: - assert(ia->header.size == 1 && ia->data[0] == THREAD_STATE_NEW); - - oa = builtin_anewarray(1, class_java_lang_String); - - if (oa == NULL) - return NULL; - - s = javastring_new(utf_new_char("NEW")); - - if (s == NULL) - return NULL; - - array_objectarray_element_set(oa, 0, s); - break; - - case THREAD_STATE_RUNNABLE: - oa = builtin_anewarray(1, class_java_lang_String); - - if (oa == NULL) - return NULL; - - s = javastring_new(utf_new_char("RUNNABLE")); - - if (s == NULL) - return NULL; - - array_objectarray_element_set(oa, 0, s); - break; - - case THREAD_STATE_BLOCKED: - oa = builtin_anewarray(1, class_java_lang_String); - - if (oa == NULL) - return NULL; - - s = javastring_new(utf_new_char("BLOCKED")); - - if (s == NULL) - return NULL; - - array_objectarray_element_set(oa, 0, s); - break; - - case THREAD_STATE_WAITING: - oa = builtin_anewarray(2, class_java_lang_String); - - if (oa == NULL) - return NULL; - - s = javastring_new(utf_new_char("WAITING.OBJECT_WAIT")); -/* s = javastring_new(utf_new_char("WAITING.PARKED")); */ - - if (s == NULL) - return NULL; - - array_objectarray_element_set(oa, 0, s); -/* array_objectarray_element_set(oa, 1, s); */ - break; - - case THREAD_STATE_TIMED_WAITING: - oa = builtin_anewarray(3, class_java_lang_String); - - if (oa == NULL) - return NULL; - -/* s = javastring_new(utf_new_char("TIMED_WAITING.SLEEPING")); */ - s = javastring_new(utf_new_char("TIMED_WAITING.OBJECT_WAIT")); -/* s = javastring_new(utf_new_char("TIMED_WAITING.PARKED")); */ - - if (s == NULL) - return NULL; - -/* array_objectarray_element_set(oa, 0, s); */ - array_objectarray_element_set(oa, 0, s); -/* array_objectarray_element_set(oa, 2, s); */ - break; - - case THREAD_STATE_TERMINATED: - oa = builtin_anewarray(1, class_java_lang_String); - - if (oa == NULL) - return NULL; - - s = javastring_new(utf_new_char("TERMINATED")); - - if (s == NULL) - return NULL; - - array_objectarray_element_set(oa, 0, s); - break; - - default: - /* Unknown state - probably incompatible JDK version */ - return NULL; - } - - return (jobjectArray) oa; -} - - -/* JVM_GetVersionInfo */ - -void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size) -{ - log_println("JVM_GetVersionInfo: IMPLEMENT ME!"); -} - - -/* OS: JVM_RegisterSignal */ - -void *JVM_RegisterSignal(jint sig, void *handler) -{ - functionptr newHandler; - - TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler)); - - if (handler == (void *) 2) - newHandler = (functionptr) signal_thread_handler; - else - newHandler = (functionptr) (uintptr_t) handler; - - switch (sig) { - case SIGILL: - case SIGFPE: - case SIGUSR1: - case SIGSEGV: - /* These signals are already used by the VM. */ - return (void *) -1; - - case SIGQUIT: - /* This signal is used by the VM to dump thread stacks unless - ReduceSignalUsage is set, in which case the user is allowed - to set his own _native_ handler for this signal; thus, in - either case, we do not allow JVM_RegisterSignal to change - the handler. */ - return (void *) -1; - - case SIGHUP: - case SIGINT: - case SIGTERM: - break; - } - - signal_register_signal(sig, newHandler, 0); - - /* XXX Should return old handler. */ - - return (void *) 2; -} - - -/* OS: JVM_RaiseSignal */ - -jboolean JVM_RaiseSignal(jint sig) -{ - log_println("JVM_RaiseSignal: IMPLEMENT ME! sig=%s", sig); - - return false; -} - - -/* OS: JVM_FindSignal */ - -jint JVM_FindSignal(const char *name) -{ - TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name)); - -#if defined(__LINUX__) - if (strcmp(name, "HUP") == 0) - return SIGHUP; - - if (strcmp(name, "INT") == 0) - return SIGINT; - - if (strcmp(name, "TERM") == 0) - return SIGTERM; -#else -# error not implemented for this OS -#endif - - return -1; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/openjdk/jvm.cpp b/src/native/vm/openjdk/jvm.cpp new file mode 100644 index 000000000..9a6e152a0 --- /dev/null +++ b/src/native/vm/openjdk/jvm.cpp @@ -0,0 +1,3636 @@ +/* src/native/vm/openjdk/jvm.cpp - HotSpot VM interface functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_SYS_IOCTL_H) +#define BSD_COMP /* Get FIONREAD on Solaris2 */ +#include +#endif + +#include +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#include "native/vm/reflection.hpp" + +#include "native/vm/openjdk/hpi.h" + +#include "threads/lock-common.h" +#include "threads/thread.hpp" + +#include "toolbox/logging.h" +#include "toolbox/list.h" + +#include "vm/array.h" + +#if defined(ENABLE_ASSERTION) +#include "vm/assertion.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/package.hpp" +#include "vm/primitive.hpp" +#include "vm/properties.hpp" +#include "vm/resolve.h" +#include "vm/signallocal.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/stacktrace.hpp" + + +/* debugging macros ***********************************************************/ + +#if !defined(NDEBUG) + +# define TRACEJVMCALLS(x) \ + do { \ + if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \ + log_println x; \ + } \ + } while (0) + +# define TRACEJVMCALLSENTER(x) \ + do { \ + if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \ + log_start(); \ + log_print x; \ + } \ + } while (0) + +# define TRACEJVMCALLSEXIT(x) \ + do { \ + if (opt_TraceJVMCalls || opt_TraceJVMCallsVerbose) { \ + log_print x; \ + log_finish(); \ + } \ + } while (0) + +# define TRACEJVMCALLSVERBOSE(x) \ + do { \ + if (opt_TraceJVMCallsVerbose) { \ + log_println x; \ + } \ + } while (0) + +# define PRINTJVMWARNINGS(x) +/* do { \ */ +/* if (opt_PrintJVMWarnings) { \ */ +/* log_println x; \ */ +/* } \ */ +/* } while (0) */ + +#else + +# define TRACEJVMCALLS(x) +# define TRACEJVMCALLSENTER(x) +# define TRACEJVMCALLSEXIT(x) +# define TRACEJVMCALLSVERBOSE(x) +# define PRINTJVMWARNINGS(x) + +#endif + + +typedef struct { + /* Naming convention of RE build version string: n.n.n[_uu[c]][-]-bxx */ + unsigned int jvm_version; /* Consists of major, minor, micro (n.n.n) */ + /* and build number (xx) */ + unsigned int update_version : 8; /* Update release version (uu) */ + unsigned int special_update_version : 8; /* Special update release version (c) */ + unsigned int reserved1 : 16; + unsigned int reserved2; + + /* The following bits represents JVM supports that JDK has dependency on. + * JDK can use these bits to determine which JVM version + * and support it has to maintain runtime compatibility. + * + * When a new bit is added in a minor or update release, make sure + * the new bit is also added in the main/baseline. + */ + unsigned int is_attachable : 1; + unsigned int : 31; + unsigned int : 32; + unsigned int : 32; +} jvm_version_info; + + +/* + * A structure used to a capture exception table entry in a Java method. + */ +typedef struct { + jint start_pc; + jint end_pc; + jint handler_pc; + jint catchType; +} JVM_ExceptionTableEntryType; + + +// Interface functions are exported as C functions. +extern "C" { + +int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args) +{ + if ((intptr_t) count <= 0) + return -1; + + return vsnprintf(str, count, fmt, args); +} + + +int jio_snprintf(char *str, size_t count, const char *fmt, ...) +{ + va_list ap; + int len; + + va_start(ap, fmt); + len = jio_vsnprintf(str, count, fmt, ap); + va_end(ap); + + return len; +} + + +int jio_fprintf(FILE* f, const char *fmt, ...) +{ + log_println("jio_fprintf: IMPLEMENT ME!"); + + return 0; +} + + +int jio_vfprintf(FILE* f, const char *fmt, va_list args) +{ + log_println("jio_vfprintf: IMPLEMENT ME!"); + + return 0; +} + + +int jio_printf(const char *fmt, ...) +{ + log_println("jio_printf: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetInterfaceVersion */ + +jint JVM_GetInterfaceVersion() +{ + /* This is defined in hotspot/src/share/vm/prims/jvm.h */ + +#define JVM_INTERFACE_VERSION 4 + + return JVM_INTERFACE_VERSION; +} + + +/* JVM_CurrentTimeMillis */ + +jlong JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored) +{ + TRACEJVMCALLS(("JVM_CurrentTimeMillis(env=%p, ignored=%p)", env, ignored)); + + return (jlong) builtin_currenttimemillis(); +} + + +/* JVM_NanoTime */ + +jlong JVM_NanoTime(JNIEnv *env, jclass ignored) +{ + TRACEJVMCALLS(("JVM_NanoTime(env=%p, ignored=%p)", env, ignored)); + + return (jlong) builtin_nanotime(); +} + + +/* JVM_ArrayCopy */ + +void JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) +{ + java_handle_t *s; + java_handle_t *d; + + s = (java_handle_t *) src; + d = (java_handle_t *) dst; + + TRACEJVMCALLSVERBOSE(("JVM_ArrayCopy(env=%p, ignored=%p, src=%p, src_pos=%d, dst=%p, dst_pos=%d, length=%d)", env, ignored, src, src_pos, dst, dst_pos, length)); + + builtin_arraycopy(s, src_pos, d, dst_pos, length); +} + + +/* JVM_InitProperties */ + +jobject JVM_InitProperties(JNIEnv *env, jobject properties) +{ + java_handle_t *h; + char buf[256]; + + TRACEJVMCALLS(("JVM_InitProperties(env=%p, properties=%p)", env, properties)); + + h = (java_handle_t *) properties; + + /* Convert the -XX:MaxDirectMemorySize= command line flag to the + sun.nio.MaxDirectMemorySize property. Do this after setting + user properties to prevent people from setting the value with a + -D option, as requested. */ + + jio_snprintf(buf, sizeof(buf), PRINTF_FORMAT_INT64_T, opt_MaxDirectMemorySize); + VM::get_current()->get_properties().put("sun.nio.MaxDirectMemorySize", buf); + + // Fill the java.util.Properties object. + VM::get_current()->get_properties().fill(h); + + return properties; +} + + +/* JVM_Exit */ + +void JVM_Exit(jint code) +{ + log_println("JVM_Exit: IMPLEMENT ME!"); +} + + +/* JVM_Halt */ + +void JVM_Halt(jint code) +{ + TRACEJVMCALLS(("JVM_Halt(code=%d)", code)); + +/* vm_exit(code); */ + vm_shutdown(code); +} + + +/* JVM_OnExit(void (*func)) */ + +void JVM_OnExit(void (*func)(void)) +{ + log_println("JVM_OnExit(void (*func): IMPLEMENT ME!"); +} + + +/* JVM_GC */ + +void JVM_GC(void) +{ + TRACEJVMCALLS(("JVM_GC()")); + + gc_call(); +} + + +/* JVM_MaxObjectInspectionAge */ + +jlong JVM_MaxObjectInspectionAge(void) +{ + log_println("JVM_MaxObjectInspectionAge: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_TraceInstructions */ + +void JVM_TraceInstructions(jboolean on) +{ + log_println("JVM_TraceInstructions: IMPLEMENT ME!"); +} + + +/* JVM_TraceMethodCalls */ + +void JVM_TraceMethodCalls(jboolean on) +{ + log_println("JVM_TraceMethodCalls: IMPLEMENT ME!"); +} + + +/* JVM_TotalMemory */ + +jlong JVM_TotalMemory(void) +{ + TRACEJVMCALLS(("JVM_TotalMemory()")); + + return gc_get_heap_size(); +} + + +/* JVM_FreeMemory */ + +jlong JVM_FreeMemory(void) +{ + TRACEJVMCALLS(("JVM_FreeMemory()")); + + return gc_get_free_bytes(); +} + + +/* JVM_MaxMemory */ + +jlong JVM_MaxMemory(void) +{ + TRACEJVMCALLS(("JVM_MaxMemory()")); + + return gc_get_max_heap_size(); +} + + +/* JVM_ActiveProcessorCount */ + +jint JVM_ActiveProcessorCount(void) +{ + TRACEJVMCALLS(("JVM_ActiveProcessorCount()")); + + return os::processors_online(); +} + + +/* JVM_FillInStackTrace */ + +void JVM_FillInStackTrace(JNIEnv *env, jobject receiver) +{ + TRACEJVMCALLS(("JVM_FillInStackTrace(env=%p, receiver=%p)", env, receiver)); + + java_handle_bytearray_t* ba = stacktrace_get_current(); + + if (ba == NULL) + return; + + java_lang_Throwable jlt(receiver, ba); +} + + +/* JVM_PrintStackTrace */ + +void JVM_PrintStackTrace(JNIEnv *env, jobject receiver, jobject printable) +{ + log_println("JVM_PrintStackTrace: IMPLEMENT ME!"); +} + + +/* JVM_GetStackTraceDepth */ + +jint JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable) +{ + TRACEJVMCALLS(("JVM_GetStackTraceDepth(env=%p, throwable=%p)", env, throwable)); + + java_lang_Throwable jlt(throwable); + + if (jlt.is_null()) { + exceptions_throw_nullpointerexception(); + return 0; + } + + java_handle_bytearray_t* ba = jlt.get_backtrace(); + + if (ba == NULL) + return 0; + + // We need a critical section here as the stacktrace structure is + // mapped onto a Java byte-array. + + LLNI_CRITICAL_START; + + stacktrace_t* st = (stacktrace_t *) LLNI_array_data(ba); + + int32_t depth = st->length; + + LLNI_CRITICAL_END; + + return depth; +} + + +/* JVM_GetStackTraceElement */ + +jobject JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index) +{ + TRACEJVMCALLS(("JVM_GetStackTraceElement(env=%p, throwable=%p, index=%d)", env, throwable, index)); + + java_lang_Throwable jlt(throwable); + java_handle_bytearray_t* ba = jlt.get_backtrace(); + + // We need a critical section here as the stacktrace structure is + // mapped onto a Java byte-array. + LLNI_CRITICAL_START; + + stacktrace_t* st = (stacktrace_t *) LLNI_array_data(ba); + + if ((index < 0) || (index >= st->length)) { + /* XXX This should be an IndexOutOfBoundsException (check this + again). */ + exceptions_throw_arrayindexoutofboundsexception(); + return NULL; + } + + // Get the stacktrace entry. + stacktrace_entry_t* ste = &(st->entries[index]); + + // Get the codeinfo, methodinfo and classinfo. + codeinfo* code = ste->code; + methodinfo* m = code->m; + classinfo* c = m->clazz; + + // Get filename. + java_handle_t* filename; + + if (!(m->flags & ACC_NATIVE)) { + if (c->sourcefile != NULL) + filename = javastring_new(c->sourcefile); + else + filename = NULL; + } + else + filename = NULL; + + // Get line number. + int32_t linenumber; + + if (m->flags & ACC_NATIVE) { + linenumber = -2; + } + else { + /* FIXME The linenumbertable_linenumber_for_pc could change + the methodinfo pointer when hitting an inlined method. */ + + linenumber = linenumbertable_linenumber_for_pc(&m, code, ste->pc); + linenumber = (linenumber == 0) ? -1 : linenumber; + } + + LLNI_CRITICAL_END; + + // Get declaring class name. + java_handle_t* declaringclass = class_get_classname(c); + + // Allocate a new StackTraceElement object. + java_lang_StackTraceElement jlste(declaringclass, javastring_new(m->name), filename, linenumber); + + if (jlste.is_null()) + return NULL; + + return (jobject) jlste.get_handle(); +} + + +/* JVM_IHashCode */ + +jint JVM_IHashCode(JNIEnv* env, jobject handle) +{ + TRACEJVMCALLS(("JVM_IHashCode(env=%p, jobject=%p)", env, handle)); + + java_lang_Object o(handle); + + return o.get_hashcode(); +} + + +/* JVM_MonitorWait */ + +void JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms) +{ +#if defined(ENABLE_THREADS) + java_handle_t *o; +#endif + + TRACEJVMCALLS(("JVM_MonitorWait(env=%p, handle=%p, ms=%ld)", env, handle, ms)); + if (ms < 0) { +/* exceptions_throw_illegalargumentexception("argument out of range"); */ + exceptions_throw_illegalargumentexception(); + return; + } + +#if defined(ENABLE_THREADS) + o = (java_handle_t *) handle; + + lock_wait_for_object(o, ms, 0); +#endif +} + + +/* JVM_MonitorNotify */ + +void JVM_MonitorNotify(JNIEnv* env, jobject handle) +{ +#if defined(ENABLE_THREADS) + java_handle_t *o; +#endif + + TRACEJVMCALLS(("JVM_MonitorNotify(env=%p, handle=%p)", env, handle)); + +#if defined(ENABLE_THREADS) + o = (java_handle_t *) handle; + + lock_notify_object(o); +#endif +} + + +/* JVM_MonitorNotifyAll */ + +void JVM_MonitorNotifyAll(JNIEnv* env, jobject handle) +{ +#if defined(ENABLE_THREADS) + java_handle_t *o; +#endif + + TRACEJVMCALLS(("JVM_MonitorNotifyAll(env=%p, handle=%p)", env, handle)); + +#if defined(ENABLE_THREADS) + o = (java_handle_t *) handle; + + lock_notify_all_object(o); +#endif +} + + +/* JVM_Clone */ + +jobject JVM_Clone(JNIEnv* env, jobject handle) +{ + TRACEJVMCALLS(("JVM_Clone(env=%p, handle=%p)", env, handle)); + + return (jobject) builtin_clone(env, (java_handle_t *) handle); +} + + +/* JVM_InitializeCompiler */ + +void JVM_InitializeCompiler (JNIEnv *env, jclass compCls) +{ + log_println("JVM_InitializeCompiler : IMPLEMENT ME!"); +} + + +/* JVM_IsSilentCompiler */ + +jboolean JVM_IsSilentCompiler(JNIEnv *env, jclass compCls) +{ + log_println("JVM_IsSilentCompiler: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_CompileClass */ + +jboolean JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls) +{ + log_println("JVM_CompileClass: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_CompileClasses */ + +jboolean JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname) +{ + log_println("JVM_CompileClasses: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_CompilerCommand */ + +jobject JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg) +{ + log_println("JVM_CompilerCommand: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_EnableCompiler */ + +void JVM_EnableCompiler(JNIEnv *env, jclass compCls) +{ + TRACEJVMCALLS(("JVM_EnableCompiler(env=%p, compCls=%p)", env, compCls)); + PRINTJVMWARNINGS(("JVM_EnableCompiler not supported")); +} + + +/* JVM_DisableCompiler */ + +void JVM_DisableCompiler(JNIEnv *env, jclass compCls) +{ + TRACEJVMCALLS(("JVM_DisableCompiler(env=%p, compCls=%p)", env, compCls)); + PRINTJVMWARNINGS(("JVM_DisableCompiler not supported")); +} + + +/* JVM_GetLastErrorString */ + +jint JVM_GetLastErrorString(char *buf, int len) +{ + TRACEJVMCALLS(("JVM_GetLastErrorString(buf=%p, len=%d", buf, len)); + + return hpi_system->GetLastErrorString(buf, len); +} + + +/* JVM_NativePath */ + +char *JVM_NativePath(char *path) +{ + TRACEJVMCALLS(("JVM_NativePath(path=%s)", path)); + + return hpi_file->NativePath(path); +} + + +/* JVM_GetCallerClass */ + +jclass JVM_GetCallerClass(JNIEnv* env, int depth) +{ + classinfo *c; + + TRACEJVMCALLS(("JVM_GetCallerClass(env=%p, depth=%d)", env, depth)); + + c = stacktrace_get_caller_class(depth); + + return (jclass) c; +} + + +/* JVM_FindPrimitiveClass */ + +jclass JVM_FindPrimitiveClass(JNIEnv* env, const char* s) +{ + classinfo *c; + utf *u; + + TRACEJVMCALLS(("JVM_FindPrimitiveClass(env=%p, s=%s)", env, s)); + + u = utf_new_char(s); + c = Primitive::get_class_by_name(u); + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* JVM_ResolveClass */ + +void JVM_ResolveClass(JNIEnv* env, jclass cls) +{ + TRACEJVMCALLS(("JVM_ResolveClass(env=%p, cls=%p)", env, cls)); + PRINTJVMWARNINGS(("JVM_ResolveClass not implemented")); +} + + +/* JVM_FindClassFromClassLoader */ + +jclass JVM_FindClassFromClassLoader(JNIEnv* env, const char* name, jboolean init, jobject loader, jboolean throwError) +{ + classinfo *c; + utf *u; + classloader_t *cl; + + TRACEJVMCALLS(("JVM_FindClassFromClassLoader(name=%s, init=%d, loader=%p, throwError=%d)", name, init, loader, throwError)); + + /* As of now, OpenJDK does not call this function with throwError + is true. */ + + assert(throwError == false); + + u = utf_new_char(name); + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + c = load_class_from_classloader(u, cl); + + if (c == NULL) + return NULL; + + if (init) + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return NULL; + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* JVM_FindClassFromClass */ + +jclass JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, jclass from) +{ + log_println("JVM_FindClassFromClass: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_DefineClass */ + +jclass JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd) +{ + log_println("JVM_DefineClass: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_DefineClassWithSource */ + +jclass JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd, const char *source) +{ + classinfo *c; + utf *u; + classloader_t *cl; + + TRACEJVMCALLS(("JVM_DefineClassWithSource(env=%p, name=%s, loader=%p, buf=%p, len=%d, pd=%p, source=%s)", env, name, loader, buf, len, pd, source)); + + if (name != NULL) + u = utf_new_char(name); + else + u = NULL; + + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + /* XXX do something with source */ + + c = class_define(u, cl, len, (uint8_t *) buf, (java_handle_t *) pd); + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* JVM_FindLoadedClass */ + +jclass JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name) +{ + classloader_t *cl; + utf *u; + classinfo *c; + + TRACEJVMCALLS(("JVM_FindLoadedClass(env=%p, loader=%p, name=%p)", env, loader, name)); + + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + u = javastring_toutf((java_handle_t *) name, true); + c = classcache_lookup(cl, u); + + return (jclass) LLNI_classinfo_wrap(c); +} + + +/* JVM_GetClassName */ + +jstring JVM_GetClassName(JNIEnv *env, jclass cls) +{ + classinfo* c; + + TRACEJVMCALLS(("JVM_GetClassName(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + return (jstring) class_get_classname(c); +} + + +/* JVM_GetClassInterfaces */ + +jobjectArray JVM_GetClassInterfaces(JNIEnv *env, jclass cls) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + TRACEJVMCALLS(("JVM_GetClassInterfaces(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + oa = class_get_interfaces(c); + + return (jobjectArray) oa; +} + + +/* JVM_GetClassLoader */ + +jobject JVM_GetClassLoader(JNIEnv *env, jclass cls) +{ + classinfo *c; + classloader_t *cl; + + TRACEJVMCALLSENTER(("JVM_GetClassLoader(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + cl = class_get_classloader(c); + + TRACEJVMCALLSEXIT(("->%p", cl)); + + return (jobject) cl; +} + + +/* JVM_IsInterface */ + +jboolean JVM_IsInterface(JNIEnv *env, jclass cls) +{ + classinfo *c; + + TRACEJVMCALLS(("JVM_IsInterface(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + return class_is_interface(c); +} + + +/* JVM_GetClassSigners */ + +jobjectArray JVM_GetClassSigners(JNIEnv *env, jclass cls) +{ + log_println("JVM_GetClassSigners: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_SetClassSigners */ + +void JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers) +{ + classinfo *c; + java_handle_objectarray_t *hoa; + + TRACEJVMCALLS(("JVM_SetClassSigners(env=%p, cls=%p, signers=%p)", env, cls, signers)); + + c = LLNI_classinfo_unwrap(cls); + + hoa = (java_handle_objectarray_t *) signers; + + /* This call is ignored for primitive types and arrays. Signers + are only set once, ClassLoader.java, and thus shouldn't be + called with an array. Only the bootstrap loader creates + arrays. */ + + if (class_is_primitive(c) || class_is_array(c)) + return; + + LLNI_classinfo_field_set(c, signers, hoa); +} + + +/* JVM_GetProtectionDomain */ + +jobject JVM_GetProtectionDomain(JNIEnv *env, jclass cls) +{ + classinfo *c; + + TRACEJVMCALLS(("JVM_GetProtectionDomain(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + if (c == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* Primitive types do not have a protection domain. */ + + if (class_is_primitive(c)) + return NULL; + + return (jobject) c->protectiondomain; +} + + +/* JVM_SetProtectionDomain */ + +void JVM_SetProtectionDomain(JNIEnv *env, jclass cls, jobject protection_domain) +{ + log_println("JVM_SetProtectionDomain: IMPLEMENT ME!"); +} + + +/* JVM_DoPrivileged */ + +jobject JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException) +{ + java_handle_t *h; + classinfo *c; + methodinfo *m; + java_handle_t *result; + java_handle_t *e; + + TRACEJVMCALLS(("JVM_DoPrivileged(env=%p, cls=%p, action=%p, context=%p, wrapException=%d)", env, cls, action, context, wrapException)); + + h = (java_handle_t *) action; + LLNI_class_get(h, c); + + if (action == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* lookup run() method (throw no exceptions) */ + + m = class_resolveclassmethod(c, utf_run, utf_void__java_lang_Object, c, + false); + + if ((m == NULL) || !(m->flags & ACC_PUBLIC) || (m->flags & ACC_STATIC)) { + exceptions_throw_internalerror("No run method"); + return NULL; + } + + /* XXX It seems something with a privileged stack needs to be done + here. */ + + result = vm_call_method(m, h); + + e = exceptions_get_exception(); + + if (e != NULL) { + if ( builtin_instanceof(e, class_java_lang_Exception) && + !builtin_instanceof(e, class_java_lang_RuntimeException)) { + exceptions_clear_exception(); + exceptions_throw_privilegedactionexception(e); + } + + return NULL; + } + + return (jobject) result; +} + + +/* JVM_GetInheritedAccessControlContext */ + +jobject JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls) +{ + log_println("JVM_GetInheritedAccessControlContext: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetStackAccessControlContext */ + +jobject JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls) +{ + TRACEJVMCALLS(("JVM_GetStackAccessControlContext(env=%p, cls=%p): IMPLEMENT ME!", env, cls)); + + /* XXX All stuff I tested so far works without that function. At + some point we have to implement it, but I disable the output + for now to make IcedTea happy. */ + + return NULL; +} + + +/* JVM_IsArrayClass */ + +jboolean JVM_IsArrayClass(JNIEnv *env, jclass cls) +{ + classinfo *c; + + TRACEJVMCALLS(("JVM_IsArrayClass(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + return class_is_array(c); +} + + +/* JVM_IsPrimitiveClass */ + +jboolean JVM_IsPrimitiveClass(JNIEnv *env, jclass cls) +{ + classinfo *c; + + TRACEJVMCALLS(("JVM_IsPrimitiveClass(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + return class_is_primitive(c); +} + + +/* JVM_GetComponentType */ + +jclass JVM_GetComponentType(JNIEnv *env, jclass cls) +{ + classinfo *component; + classinfo *c; + + TRACEJVMCALLS(("JVM_GetComponentType(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + component = class_get_componenttype(c); + + return (jclass) LLNI_classinfo_wrap(component); +} + + +/* JVM_GetClassModifiers */ + +jint JVM_GetClassModifiers(JNIEnv *env, jclass cls) +{ + classinfo *c; + int32_t flags; + + TRACEJVMCALLS(("JVM_GetClassModifiers(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + flags = class_get_modifiers(c, false); + + return flags; +} + + +/* JVM_GetDeclaredClasses */ + +jobjectArray JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + TRACEJVMCALLS(("JVM_GetDeclaredClasses(env=%p, ofClass=%p)", env, ofClass)); + + c = LLNI_classinfo_unwrap(ofClass); + + oa = class_get_declaredclasses(c, false); + + return (jobjectArray) oa; +} + + +/* JVM_GetDeclaringClass */ + +jclass JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass) +{ + classinfo *c; + classinfo *dc; + + TRACEJVMCALLS(("JVM_GetDeclaringClass(env=%p, ofClass=%p)", env, ofClass)); + + c = LLNI_classinfo_unwrap(ofClass); + + dc = class_get_declaringclass(c); + + return (jclass) LLNI_classinfo_wrap(dc); +} + + +/* JVM_GetClassSignature */ + +jstring JVM_GetClassSignature(JNIEnv *env, jclass cls) +{ + classinfo *c; + utf *u; + java_handle_t *s; + + TRACEJVMCALLS(("JVM_GetClassSignature(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + /* Get the signature of the class. */ + + u = class_get_signature(c); + + if (u == NULL) + return NULL; + + /* Convert UTF-string to a Java-string. */ + + s = javastring_new(u); + + return (jstring) s; +} + + +/* JVM_GetClassAnnotations */ + +jbyteArray JVM_GetClassAnnotations(JNIEnv *env, jclass cls) +{ + TRACEJVMCALLS(("JVM_GetClassAnnotations(env=%p, cls=%p)", env, cls)); + + if (cls == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + classinfo* c = LLNI_classinfo_unwrap(cls); + + /* get annotations: */ + java_handle_bytearray_t* annotations = class_get_annotations(c); + + return (jbyteArray) annotations; +} + + +/* JVM_GetFieldAnnotations */ + +jbyteArray JVM_GetFieldAnnotations(JNIEnv *env, jobject field) +{ + TRACEJVMCALLS(("JVM_GetFieldAnnotations(env=%p, field=%p)", env, field)); + + java_lang_reflect_Field jlrf(field); + + if (jlrf.is_null()) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return (jbyteArray) jlrf.get_annotations(); +} + + +/* JVM_GetMethodAnnotations */ + +jbyteArray JVM_GetMethodAnnotations(JNIEnv *env, jobject method) +{ + TRACEJVMCALLS(("JVM_GetMethodAnnotations(env=%p, method=%p)", env, method)); + + java_lang_reflect_Method jlrm(method); + + if (jlrm.is_null()) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return (jbyteArray) jlrm.get_annotations(); +} + + +/* JVM_GetMethodDefaultAnnotationValue */ + +jbyteArray JVM_GetMethodDefaultAnnotationValue(JNIEnv *env, jobject method) +{ + TRACEJVMCALLS(("JVM_GetMethodDefaultAnnotationValue(env=%p, method=%p)", env, method)); + + java_lang_reflect_Method jlrm(method); + + if (jlrm.is_null()) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return (jbyteArray) jlrm.get_annotationDefault(); +} + + +/* JVM_GetMethodParameterAnnotations */ + +jbyteArray JVM_GetMethodParameterAnnotations(JNIEnv *env, jobject method) +{ + TRACEJVMCALLS(("JVM_GetMethodParameterAnnotations(env=%p, method=%p)", env, method)); + + java_lang_reflect_Method jlrm(method); + + if (jlrm.is_null()) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + return (jbyteArray) jlrm.get_parameterAnnotations(); +} + + +/* JVM_GetClassDeclaredFields */ + +jobjectArray JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + TRACEJVMCALLS(("JVM_GetClassDeclaredFields(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly)); + + c = LLNI_classinfo_unwrap(ofClass); + + oa = class_get_declaredfields(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* JVM_GetClassDeclaredMethods */ + +jobjectArray JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly) +{ + TRACEJVMCALLS(("JVM_GetClassDeclaredMethods(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly)); + + classinfo* c = LLNI_classinfo_unwrap(ofClass); + + java_handle_objectarray_t* oa = class_get_declaredmethods(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* JVM_GetClassDeclaredConstructors */ + +jobjectArray JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly) +{ + classinfo *c; + java_handle_objectarray_t *oa; + + TRACEJVMCALLS(("JVM_GetClassDeclaredConstructors(env=%p, ofClass=%p, publicOnly=%d)", env, ofClass, publicOnly)); + + c = LLNI_classinfo_unwrap(ofClass); + + oa = class_get_declaredconstructors(c, publicOnly); + + return (jobjectArray) oa; +} + + +/* JVM_GetClassAccessFlags */ + +jint JVM_GetClassAccessFlags(JNIEnv *env, jclass cls) +{ + classinfo *c; + + TRACEJVMCALLS(("JVM_GetClassAccessFlags(env=%p, cls=%p)", env, cls)); + + c = LLNI_classinfo_unwrap(cls); + + /* Primitive type classes have the correct access flags. */ + + return c->flags & ACC_CLASS_REFLECT_MASK; +} + + +/* JVM_GetClassConstantPool */ + +jobject JVM_GetClassConstantPool(JNIEnv *env, jclass cls) +{ +#if defined(ENABLE_ANNOTATIONS) + TRACEJVMCALLS(("JVM_GetClassConstantPool(env=%p, cls=%p)", env, cls)); + + java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool); + sun_reflect_ConstantPool cp(h, cls); + + if (cp.is_null()) { + return NULL; + } + + return (jobject) cp.get_handle(); +#else + log_println("JVM_GetClassConstantPool(env=%p, cls=%p): not implemented in this configuration!", env, cls); + return NULL; +#endif +} + + +/* JVM_ConstantPoolGetSize */ + +jint JVM_ConstantPoolGetSize(JNIEnv *env, jobject unused, jobject jcpool) +{ + classinfo *c; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetSize(env=%p, unused=%p, jcpool=%p)", env, unused, jcpool)); + + c = LLNI_classinfo_unwrap(jcpool); + + return c->cpcount; +} + + +/* JVM_ConstantPoolGetClassAt */ + +jclass JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_classref *ref; /* classref to the class at constant pool index 'index' */ + classinfo *c; /* classinfo of the class for which 'this' is the constant pool */ + classinfo *result; /* classinfo of the class at constant pool index 'index' */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetClassAt(env=%p, jcpool=%p, index=%d)", env, jcpool, index)); + + c = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + result = resolve_classref_eager(ref); + + return (jclass) LLNI_classinfo_wrap(result); +} + + +/* JVM_ConstantPoolGetClassAtIfLoaded */ + +jclass JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_classref *ref; /* classref to the class at constant pool index 'index' */ + classinfo *c; /* classinfo of the class for which 'this' is the constant pool */ + classinfo *result; /* classinfo of the class at constant pool index 'index' */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetClassAtIfLoaded(env=%p, unused=%p, jcpool=%p, index=%d)", env, unused, jcpool, index)); + + c = LLNI_classinfo_unwrap(jcpool); + + ref = (constant_classref *) class_getconstant(c, index, CONSTANT_Class); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + if (!resolve_classref(NULL, ref, resolveLazy, true, true, &result)) { + return NULL; + } + + if ((result == NULL) || !(result->state & CLASS_LOADED)) { + return NULL; + } + + return (jclass) LLNI_classinfo_wrap(result); +} + + +/* JVM_ConstantPoolGetMethodAt */ + +jobject JVM_ConstantPoolGetMethodAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + // Create a new java.lang.reflect.Method Java object. + /* XXX: is that right? or do I have to use resolve_method_*? */ + java_lang_reflect_Method jlrm(ref->p.method); + + return (jobject) jlrm.get_handle(); +} + + +/* JVM_ConstantPoolGetMethodAtIfLoaded */ + +jobject JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_FMIref *ref; /* reference to the method in constant pool at index 'index' */ + classinfo *c = NULL; /* resolved declaring class of the method */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetMethodAtIfLoaded: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Methodref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) { + return NULL; + } + + if (c == NULL || !(c->state & CLASS_LOADED)) { + return NULL; + } + + // Create a new java.lang.reflect.Method Java object. + java_lang_reflect_Method jlrm(ref->p.method); + + return (jobject) jlrm.get_handle(); +} + + +/* JVM_ConstantPoolGetFieldAt */ + +jobject JVM_ConstantPoolGetFieldAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + // Create a new java.lang.reflect.Field Java object. + java_lang_reflect_Field jlrf(ref->p.field); + + return (jobject) jlrf.get_handle(); +} + + +/* JVM_ConstantPoolGetFieldAtIfLoaded */ + +jobject JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_FMIref *ref; /* reference to the field in constant pool at index 'index' */ + classinfo *c; /* resolved declaring class for the field */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetFieldAtIfLoaded: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_FMIref*)class_getconstant(cls, index, CONSTANT_Fieldref); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + if (!resolve_classref(NULL, ref->p.classref, resolveLazy, true, true, &c)) { + return NULL; + } + + if (c == NULL || !(c->state & CLASS_LOADED)) { + return NULL; + } + + // Create a new java.lang.reflect.Field Java object. + java_lang_reflect_Field jlrf(ref->p.field); + + return (jobject) jlrf.get_handle(); +} + + +/* JVM_ConstantPoolGetMemberRefInfoAt */ + +jobjectArray JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + log_println("JVM_ConstantPoolGetMemberRefInfoAt: jcpool=%p, index=%d, IMPLEMENT ME!", jcpool, index); + + /* TODO: implement. (this is yet unused be OpenJDK but, so very low priority) */ + + return NULL; +} + + +/* JVM_ConstantPoolGetIntAt */ + +jint JVM_ConstantPoolGetIntAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_integer *ref; /* reference to the int value in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetIntAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_integer*)class_getconstant(cls, index, CONSTANT_Integer); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* JVM_ConstantPoolGetLongAt */ + +jlong JVM_ConstantPoolGetLongAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_long *ref; /* reference to the long value in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetLongAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_long*)class_getconstant(cls, index, CONSTANT_Long); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* JVM_ConstantPoolGetFloatAt */ + +jfloat JVM_ConstantPoolGetFloatAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_float *ref; /* reference to the float value in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetFloatAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_float*)class_getconstant(cls, index, CONSTANT_Float); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* JVM_ConstantPoolGetDoubleAt */ + +jdouble JVM_ConstantPoolGetDoubleAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + constant_double *ref; /* reference to the double value in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetDoubleAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (constant_double*)class_getconstant(cls, index, CONSTANT_Double); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + return ref->value; +} + + +/* JVM_ConstantPoolGetStringAt */ + +jstring JVM_ConstantPoolGetStringAt(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + utf *ref; /* utf object for the string in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetStringAt: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (utf*)class_getconstant(cls, index, CONSTANT_String); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* XXX: I hope literalstring_new is the right Function. */ + return (jstring)literalstring_new(ref); +} + + +/* JVM_ConstantPoolGetUTF8At */ + +jstring JVM_ConstantPoolGetUTF8At(JNIEnv *env, jobject unused, jobject jcpool, jint index) +{ + utf *ref; /* utf object for the utf8 data in constant pool at index 'index' */ + classinfo *cls; /* classinfo of the class for which 'this' is the constant pool */ + + TRACEJVMCALLS(("JVM_ConstantPoolGetUTF8At: jcpool=%p, index=%d", jcpool, index)); + + cls = LLNI_classinfo_unwrap(jcpool); + ref = (utf*)class_getconstant(cls, index, CONSTANT_Utf8); + + if (ref == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* XXX: I hope literalstring_new is the right Function. */ + return (jstring)literalstring_new(ref); +} + + +/* JVM_DesiredAssertionStatus */ + +jboolean JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls) +{ +#if defined(ENABLE_ASSERTION) + assertion_name_t *item; + classinfo *c; + jboolean status; + utf *name; + + TRACEJVMCALLS(("JVM_DesiredAssertionStatus(env=%p, unused=%p, cls=%p)", env, unused, cls)); + + c = LLNI_classinfo_unwrap(cls); + + if (c->classloader == NULL) { + status = (jboolean)assertion_system_enabled; + } + else { + status = (jboolean)assertion_user_enabled; + } + + if (list_assertion_names != NULL) { + item = (assertion_name_t *)list_first(list_assertion_names); + while (item != NULL) { + name = utf_new_char(item->name); + if (name == c->packagename) { + status = (jboolean)item->enabled; + } + else if (name == c->name) { + status = (jboolean)item->enabled; + } + + item = (assertion_name_t *)list_next(list_assertion_names, item); + } + } + + return status; +#else + return (jboolean)false; +#endif +} + + +/* JVM_AssertionStatusDirectives */ + +jobject JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused) +{ + java_handle_objectarray_t *classes; + java_handle_objectarray_t *packages; + java_booleanarray_t *classEnabled; + java_booleanarray_t *packageEnabled; +#if defined(ENABLE_ASSERTION) + assertion_name_t *item; + java_handle_t *js; + s4 i, j; +#endif + + TRACEJVMCALLS(("JVM_AssertionStatusDirectives(env=%p, unused=%p)", env, unused)); + +#if defined(ENABLE_ASSERTION) + classes = builtin_anewarray(assertion_class_count, class_java_lang_Object); +#else + classes = builtin_anewarray(0, class_java_lang_Object); +#endif + if (classes == NULL) + return NULL; + +#if defined(ENABLE_ASSERTION) + packages = builtin_anewarray(assertion_package_count, class_java_lang_Object); +#else + packages = builtin_anewarray(0, class_java_lang_Object); +#endif + if (packages == NULL) + return NULL; + +#if defined(ENABLE_ASSERTION) + classEnabled = builtin_newarray_boolean(assertion_class_count); +#else + classEnabled = builtin_newarray_boolean(0); +#endif + if (classEnabled == NULL) + return NULL; + +#if defined(ENABLE_ASSERTION) + packageEnabled = builtin_newarray_boolean(assertion_package_count); +#else + packageEnabled = builtin_newarray_boolean(0); +#endif + if (packageEnabled == NULL) + return NULL; + +#if defined(ENABLE_ASSERTION) + /* initialize arrays */ + + if (list_assertion_names != NULL) { + i = 0; + j = 0; + + item = (assertion_name_t *)list_first(list_assertion_names); + while (item != NULL) { + js = javastring_new_from_ascii(item->name); + if (js == NULL) { + return NULL; + } + + if (item->package == false) { + classes->data[i] = js; + classEnabled->data[i] = (jboolean) item->enabled; + i += 1; + } + else { + packages->data[j] = js; + packageEnabled->data[j] = (jboolean) item->enabled; + j += 1; + } + + item = (assertion_name_t *)list_next(list_assertion_names, item); + } + } +#endif + + /* set instance fields */ + + java_lang_AssertionStatusDirectives jlasd(classes, classEnabled, packages, packageEnabled); + + return (jobject) jlasd.get_handle(); +} + + +/* JVM_GetClassNameUTF */ + +const char *JVM_GetClassNameUTF(JNIEnv *env, jclass cls) +{ + log_println("JVM_GetClassNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassCPTypes */ + +void JVM_GetClassCPTypes(JNIEnv *env, jclass cls, unsigned char *types) +{ + log_println("JVM_GetClassCPTypes: IMPLEMENT ME!"); +} + + +/* JVM_GetClassCPEntriesCount */ + +jint JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls) +{ + log_println("JVM_GetClassCPEntriesCount: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetClassFieldsCount */ + +jint JVM_GetClassFieldsCount(JNIEnv *env, jclass cls) +{ + log_println("JVM_GetClassFieldsCount: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetClassMethodsCount */ + +jint JVM_GetClassMethodsCount(JNIEnv *env, jclass cls) +{ + log_println("JVM_GetClassMethodsCount: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxExceptionIndexes */ + +void JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions) +{ + log_println("JVM_GetMethodIxExceptionIndexes: IMPLEMENT ME!"); +} + + +/* JVM_GetMethodIxExceptionsCount */ + +jint JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index) +{ + log_println("JVM_GetMethodIxExceptionsCount: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxByteCode */ + +void JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code) +{ + log_println("JVM_GetMethodIxByteCode: IMPLEMENT ME!"); +} + + +/* JVM_GetMethodIxByteCodeLength */ + +jint JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index) +{ + log_println("JVM_GetMethodIxByteCodeLength: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxExceptionTableEntry */ + +void JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry) +{ + log_println("JVM_GetMethodIxExceptionTableEntry: IMPLEMENT ME!"); +} + + +/* JVM_GetMethodIxExceptionTableLength */ + +jint JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index) +{ + log_println("JVM_GetMethodIxExceptionTableLength: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxModifiers */ + +jint JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index) +{ + log_println("JVM_GetMethodIxModifiers: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetFieldIxModifiers */ + +jint JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index) +{ + log_println("JVM_GetFieldIxModifiers: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxLocalsCount */ + +jint JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index) +{ + log_println("JVM_GetMethodIxLocalsCount: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxArgsSize */ + +jint JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index) +{ + log_println("JVM_GetMethodIxArgsSize: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxMaxStack */ + +jint JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index) +{ + log_println("JVM_GetMethodIxMaxStack: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_IsConstructorIx */ + +jboolean JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index) +{ + log_println("JVM_IsConstructorIx: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetMethodIxNameUTF */ + +const char *JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cls, jint method_index) +{ + log_println("JVM_GetMethodIxNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetMethodIxSignatureUTF */ + +const char *JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cls, jint method_index) +{ + log_println("JVM_GetMethodIxSignatureUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPFieldNameUTF */ + +const char *JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPFieldNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPMethodNameUTF */ + +const char *JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPMethodNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPMethodSignatureUTF */ + +const char *JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPMethodSignatureUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPFieldSignatureUTF */ + +const char *JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPFieldSignatureUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPClassNameUTF */ + +const char *JVM_GetCPClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPClassNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPFieldClassNameUTF */ + +const char *JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPFieldClassNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPMethodClassNameUTF */ + +const char *JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cls, jint cp_index) +{ + log_println("JVM_GetCPMethodClassNameUTF: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetCPFieldModifiers */ + +jint JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls) +{ + log_println("JVM_GetCPFieldModifiers: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetCPMethodModifiers */ + +jint JVM_GetCPMethodModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls) +{ + log_println("JVM_GetCPMethodModifiers: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_ReleaseUTF */ + +void JVM_ReleaseUTF(const char *utf) +{ + log_println("JVM_ReleaseUTF: IMPLEMENT ME!"); +} + + +/* JVM_IsSameClassPackage */ + +jboolean JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2) +{ + log_println("JVM_IsSameClassPackage: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_Open */ + +/* Taken from: hotspot/src/share/vm/prims/jvm.h */ + +/* + * JVM I/O error codes + */ +#define JVM_EEXIST -100 + +jint JVM_Open(const char *fname, jint flags, jint mode) +{ + int result; + + TRACEJVMCALLS(("JVM_Open(fname=%s, flags=%d, mode=%d)", fname, flags, mode)); + + result = hpi_file->Open(fname, flags, mode); + + if (result >= 0) { + return result; + } + else { + switch (errno) { + case EEXIST: + return JVM_EEXIST; + default: + return -1; + } + } +} + + +/* JVM_Close */ + +jint JVM_Close(jint fd) +{ + TRACEJVMCALLS(("JVM_Close(fd=%d)", fd)); + + return hpi_file->Close(fd); +} + + +/* JVM_Read */ + +jint JVM_Read(jint fd, char *buf, jint nbytes) +{ + TRACEJVMCALLS(("JVM_Read(fd=%d, buf=%p, nbytes=%d)", fd, buf, nbytes)); + + return (jint) hpi_file->Read(fd, buf, nbytes); +} + + +/* JVM_Write */ + +jint JVM_Write(jint fd, char *buf, jint nbytes) +{ + TRACEJVMCALLS(("JVM_Write(fd=%d, buf=%s, nbytes=%d)", fd, buf, nbytes)); + + return (jint) hpi_file->Write(fd, buf, nbytes); +} + + +/* JVM_Available */ + +jint JVM_Available(jint fd, jlong *pbytes) +{ + TRACEJVMCALLS(("JVM_Available(fd=%d, pbytes=%p)", fd, pbytes)); + + return hpi_file->Available(fd, pbytes); +} + + +/* JVM_Lseek */ + +jlong JVM_Lseek(jint fd, jlong offset, jint whence) +{ + TRACEJVMCALLS(("JVM_Lseek(fd=%d, offset=%ld, whence=%d)", fd, offset, whence)); + + return hpi_file->Seek(fd, (off_t) offset, whence); +} + + +/* JVM_SetLength */ + +jint JVM_SetLength(jint fd, jlong length) +{ + TRACEJVMCALLS(("JVM_SetLength(fd=%d, length=%ld)", length)); + + return hpi_file->SetLength(fd, length); +} + + +/* JVM_Sync */ + +jint JVM_Sync(jint fd) +{ + TRACEJVMCALLS(("JVM_Sync(fd=%d)", fd)); + + return hpi_file->Sync(fd); +} + + +/* JVM_StartThread */ + +void JVM_StartThread(JNIEnv* env, jobject jthread) +{ + TRACEJVMCALLS(("JVM_StartThread(env=%p, jthread=%p)", env, jthread)); + + threads_thread_start((java_handle_t *) jthread); +} + + +/* JVM_StopThread */ + +void JVM_StopThread(JNIEnv* env, jobject jthread, jobject throwable) +{ + log_println("JVM_StopThread: Deprecated. Not implemented."); +} + + +/* JVM_IsThreadAlive */ + +jboolean JVM_IsThreadAlive(JNIEnv* env, jobject jthread) +{ + java_handle_t *h; + threadobject *t; + bool result; + + TRACEJVMCALLS(("JVM_IsThreadAlive(env=%p, jthread=%p)", env, jthread)); + + h = (java_handle_t *) jthread; + t = thread_get_thread(h); + + /* The threadobject is null when a thread is created in Java. The + priority is set later during startup. */ + + if (t == NULL) + return 0; + + result = threads_thread_is_alive(t); + + return result; +} + + +/* JVM_SuspendThread */ + +void JVM_SuspendThread(JNIEnv* env, jobject jthread) +{ + log_println("JVM_SuspendThread: Deprecated. Not implemented."); +} + + +/* JVM_ResumeThread */ + +void JVM_ResumeThread(JNIEnv* env, jobject jthread) +{ + log_println("JVM_ResumeThread: Deprecated. Not implemented."); +} + + +/* JVM_SetThreadPriority */ + +void JVM_SetThreadPriority(JNIEnv* env, jobject jthread, jint prio) +{ + java_handle_t *h; + threadobject *t; + + TRACEJVMCALLS(("JVM_SetThreadPriority(env=%p, jthread=%p, prio=%d)", env, jthread, prio)); + + h = (java_handle_t *) jthread; + t = thread_get_thread(h); + + /* The threadobject is null when a thread is created in Java. The + priority is set later during startup. */ + + if (t == NULL) + return; + + threads_set_thread_priority(t->tid, prio); +} + + +/* JVM_Yield */ + +void JVM_Yield(JNIEnv *env, jclass threadClass) +{ + TRACEJVMCALLS(("JVM_Yield(env=%p, threadClass=%p)", env, threadClass)); + + threads_yield(); +} + + +/* JVM_Sleep */ + +void JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis) +{ + TRACEJVMCALLS(("JVM_Sleep(env=%p, threadClass=%p, millis=%ld)", env, threadClass, millis)); + + threads_sleep(millis, 0); +} + + +/* JVM_CurrentThread */ + +jobject JVM_CurrentThread(JNIEnv* env, jclass threadClass) +{ + java_object_t *o; + + TRACEJVMCALLSVERBOSE(("JVM_CurrentThread(env=%p, threadClass=%p)", env, threadClass)); + + o = thread_get_current_object(); + + return (jobject) o; +} + + +/* JVM_CountStackFrames */ + +jint JVM_CountStackFrames(JNIEnv* env, jobject jthread) +{ + log_println("JVM_CountStackFrames: Deprecated. Not implemented."); + + return 0; +} + + +/* JVM_Interrupt */ + +void JVM_Interrupt(JNIEnv* env, jobject jthread) +{ + java_handle_t *h; + threadobject *t; + + TRACEJVMCALLS(("JVM_Interrupt(env=%p, jthread=%p)", env, jthread)); + + h = (java_handle_t *) jthread; + t = thread_get_thread(h); + + if (t == NULL) + return; + + threads_thread_interrupt(t); +} + + +/* JVM_IsInterrupted */ + +jboolean JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted) +{ + java_handle_t *h; + threadobject *t; + jboolean interrupted; + + TRACEJVMCALLS(("JVM_IsInterrupted(env=%p, jthread=%p, clear_interrupted=%d)", env, jthread, clear_interrupted)); + + h = (java_handle_t *) jthread; + t = thread_get_thread(h); + + interrupted = thread_is_interrupted(t); + + if (interrupted && clear_interrupted) + thread_set_interrupted(t, false); + + return interrupted; +} + + +/* JVM_HoldsLock */ + +jboolean JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj) +{ + java_handle_t *h; + bool result; + + TRACEJVMCALLS(("JVM_HoldsLock(env=%p, threadClass=%p, obj=%p)", env, threadClass, obj)); + + h = (java_handle_t *) obj; + + if (h == NULL) { + exceptions_throw_nullpointerexception(); + return JNI_FALSE; + } + + result = lock_is_held_by_current_thread(h); + + return result; +} + + +/* JVM_DumpAllStacks */ + +void JVM_DumpAllStacks(JNIEnv* env, jclass unused) +{ + log_println("JVM_DumpAllStacks: IMPLEMENT ME!"); +} + + +/* JVM_CurrentLoadedClass */ + +jclass JVM_CurrentLoadedClass(JNIEnv *env) +{ + log_println("JVM_CurrentLoadedClass: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_CurrentClassLoader */ + +jobject JVM_CurrentClassLoader(JNIEnv *env) +{ + /* XXX if a method in a class in a trusted loader is in a + doPrivileged, return NULL */ + + log_println("JVM_CurrentClassLoader: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassContext */ + +jobjectArray JVM_GetClassContext(JNIEnv *env) +{ + TRACEJVMCALLS(("JVM_GetClassContext(env=%p)", env)); + + return (jobjectArray) stacktrace_getClassContext(); +} + + +/* JVM_ClassDepth */ + +jint JVM_ClassDepth(JNIEnv *env, jstring name) +{ + log_println("JVM_ClassDepth: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_ClassLoaderDepth */ + +jint JVM_ClassLoaderDepth(JNIEnv *env) +{ + log_println("JVM_ClassLoaderDepth: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetSystemPackage */ + +jstring JVM_GetSystemPackage(JNIEnv *env, jstring name) +{ + java_handle_t *s; + utf *u; + utf *result; + + TRACEJVMCALLS(("JVM_GetSystemPackage(env=%p, name=%p)", env, name)); + +/* s = Package::find(name); */ + u = javastring_toutf((java_handle_t *) name, false); + + result = Package::find(u); + + if (result != NULL) + s = javastring_new(result); + else + s = NULL; + + return (jstring) s; +} + + +/* JVM_GetSystemPackages */ + +jobjectArray JVM_GetSystemPackages(JNIEnv *env) +{ + log_println("JVM_GetSystemPackages: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_AllocateNewObject */ + +jobject JVM_AllocateNewObject(JNIEnv *env, jobject receiver, jclass currClass, jclass initClass) +{ + log_println("JVM_AllocateNewObject: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_AllocateNewArray */ + +jobject JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, jint length) +{ + log_println("JVM_AllocateNewArray: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_LatestUserDefinedLoader */ + +jobject JVM_LatestUserDefinedLoader(JNIEnv *env) +{ + classloader_t *cl; + + TRACEJVMCALLS(("JVM_LatestUserDefinedLoader(env=%p)", env)); + + cl = stacktrace_first_nonnull_classloader(); + + return (jobject) cl; +} + + +/* JVM_LoadClass0 */ + +jclass JVM_LoadClass0(JNIEnv *env, jobject receiver, jclass currClass, jstring currClassName) +{ + log_println("JVM_LoadClass0: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetArrayLength */ + +jint JVM_GetArrayLength(JNIEnv *env, jobject arr) +{ + java_handle_t *a; + + TRACEJVMCALLS(("JVM_GetArrayLength(arr=%p)", arr)); + + a = (java_handle_t *) arr; + + return array_length_get(a); +} + + +/* JVM_GetArrayElement */ + +jobject JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index) +{ + java_handle_t *a; + java_handle_t *o; + + TRACEJVMCALLS(("JVM_GetArrayElement(env=%p, arr=%p, index=%d)", env, arr, index)); + + a = (java_handle_t *) arr; + +/* if (!class_is_array(a->objheader.vftbl->class)) { */ +/* exceptions_throw_illegalargumentexception(); */ +/* return NULL; */ +/* } */ + + o = array_element_get(a, index); + + return (jobject) o; +} + + +/* JVM_GetPrimitiveArrayElement */ + +jvalue JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode) +{ + jvalue jv; + + log_println("JVM_GetPrimitiveArrayElement: IMPLEMENT ME!"); + + jv.l = NULL; + + return jv; +} + + +/* JVM_SetArrayElement */ + +void JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val) +{ + java_handle_t *a; + java_handle_t *value; + + TRACEJVMCALLS(("JVM_SetArrayElement(env=%p, arr=%p, index=%d, val=%p)", env, arr, index, val)); + + a = (java_handle_t *) arr; + value = (java_handle_t *) val; + + array_element_set(a, index, value); +} + + +/* JVM_SetPrimitiveArrayElement */ + +void JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, unsigned char vCode) +{ + log_println("JVM_SetPrimitiveArrayElement: IMPLEMENT ME!"); +} + + +/* JVM_NewArray */ + +jobject JVM_NewArray(JNIEnv *env, jclass eltClass, jint length) +{ + classinfo *c; + classinfo *pc; + java_handle_t *a; + java_handle_objectarray_t *oa; + + TRACEJVMCALLS(("JVM_NewArray(env=%p, eltClass=%p, length=%d)", env, eltClass, length)); + + if (eltClass == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* NegativeArraySizeException is checked in builtin_newarray. */ + + c = LLNI_classinfo_unwrap(eltClass); + + /* Create primitive or object array. */ + + if (class_is_primitive(c)) { + pc = Primitive::get_arrayclass_by_name(c->name); + + /* void arrays are not allowed. */ + + if (pc == NULL) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + a = builtin_newarray(length, pc); + + return (jobject) a; + } + else { + oa = builtin_anewarray(length, c); + + return (jobject) oa; + } +} + + +/* JVM_NewMultiArray */ + +jobject JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim) +{ + classinfo *c; + java_handle_intarray_t *ia; + int32_t length; + long *dims; + int32_t value; + int32_t i; + classinfo *ac; + java_handle_objectarray_t *a; + + TRACEJVMCALLS(("JVM_NewMultiArray(env=%p, eltClass=%p, dim=%p)", env, eltClass, dim)); + + if (eltClass == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* NegativeArraySizeException is checked in builtin_newarray. */ + + c = LLNI_classinfo_unwrap(eltClass); + + ia = (java_handle_intarray_t *) dim; + + length = array_length_get((java_handle_t *) ia); + + /* We check here for exceptions thrown in array_length_get, + otherwise these exceptions get overwritten by the following + IllegalArgumentException. */ + + if (length < 0) + return NULL; + + if ((length <= 0) || (length > /* MAX_DIM */ 255)) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* XXX This is just a quick hack to get it working. */ + + dims = MNEW(long, length); + + for (i = 0; i < length; i++) { + value = LLNI_array_direct(ia, i); + dims[i] = (long) value; + } + + /* Create an array-class if necessary. */ + + if (class_is_primitive(c)) + ac = Primitive::get_arrayclass_by_name(c->name); + else + ac = class_array_of(c, true); + + if (ac == NULL) + return NULL; + + a = builtin_multianewarray(length, (java_handle_t *) ac, dims); + + return (jobject) a; +} + + +/* JVM_InitializeSocketLibrary */ + +jint JVM_InitializeSocketLibrary() +{ + TRACEJVMCALLS(("JVM_InitializeSocketLibrary()")); + + return hpi_initialize_socket_library(); +} + + +/* JVM_Socket */ + +jint JVM_Socket(jint domain, jint type, jint protocol) +{ + TRACEJVMCALLS(("JVM_Socket(domain=%d, type=%d, protocol=%d)", domain, type, protocol)); + + return os::socket(domain, type, protocol); +} + + +/* JVM_SocketClose */ + +jint JVM_SocketClose(jint fd) +{ + TRACEJVMCALLS(("JVM_SocketClose(fd=%d)", fd)); + + return os::close(fd); +} + + +/* JVM_SocketShutdown */ + +jint JVM_SocketShutdown(jint fd, jint howto) +{ + TRACEJVMCALLS(("JVM_SocketShutdown(fd=%d, howto=%d)", fd, howto)); + + return os::shutdown(fd, howto); +} + + +/* JVM_Recv */ + +jint JVM_Recv(jint fd, char *buf, jint nBytes, jint flags) +{ + log_println("JVM_Recv: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_Send */ + +jint JVM_Send(jint fd, char *buf, jint nBytes, jint flags) +{ + log_println("JVM_Send: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_Timeout */ + +jint JVM_Timeout(int fd, long timeout) +{ + log_println("JVM_Timeout: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_Listen */ + +jint JVM_Listen(jint fd, jint count) +{ + TRACEJVMCALLS(("JVM_Listen(fd=%d, count=%d)", fd, count)); + + return os::listen(fd, count); +} + + +/* JVM_Connect */ + +jint JVM_Connect(jint fd, struct sockaddr *him, jint len) +{ + TRACEJVMCALLS(("JVM_Connect(fd=%d, him=%p, len=%d)", fd, him, len)); + + return os::connect(fd, him, len); +} + + +/* JVM_Bind */ + +jint JVM_Bind(jint fd, struct sockaddr *him, jint len) +{ + log_println("JVM_Bind: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_Accept */ + +jint JVM_Accept(jint fd, struct sockaddr *him, jint *len) +{ + TRACEJVMCALLS(("JVM_Accept(fd=%d, him=%p, len=%p)", fd, him, len)); + + return os::accept(fd, him, (socklen_t *) len); +} + + +/* JVM_RecvFrom */ + +jint JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen) +{ + log_println("JVM_RecvFrom: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetSockName */ + +jint JVM_GetSockName(jint fd, struct sockaddr *him, int *len) +{ + TRACEJVMCALLS(("JVM_GetSockName(fd=%d, him=%p, len=%p)", fd, him, len)); + + return os::getsockname(fd, him, (socklen_t *) len); +} + + +/* JVM_SendTo */ + +jint JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen) +{ + log_println("JVM_SendTo: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_SocketAvailable */ + +jint JVM_SocketAvailable(jint fd, jint *pbytes) +{ +#if defined(FIONREAD) + int bytes; + int result; + + TRACEJVMCALLS(("JVM_SocketAvailable(fd=%d, pbytes=%p)", fd, pbytes)); + + *pbytes = 0; + + result = ioctl(fd, FIONREAD, &bytes); + + if (result < 0) + return 0; + + *pbytes = bytes; + + return 1; +#else +# error FIONREAD not defined +#endif +} + + +/* JVM_GetSockOpt */ + +jint JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen) +{ + TRACEJVMCALLS(("JVM_GetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%p)", fd, level, optname, optval, optlen)); + + return os::getsockopt(fd, level, optname, optval, (socklen_t *) optlen); +} + + +/* JVM_SetSockOpt */ + +jint JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen) +{ + TRACEJVMCALLS(("JVM_SetSockOpt(fd=%d, level=%d, optname=%d, optval=%s, optlen=%d)", fd, level, optname, optval, optlen)); + + return os::setsockopt(fd, level, optname, optval, optlen); +} + + +/* JVM_GetHostName */ + +int JVM_GetHostName(char *name, int namelen) +{ + int result; + + TRACEJVMCALLSENTER(("JVM_GetHostName(name=%s, namelen=%d)", name, namelen)); + + result = os::gethostname(name, namelen); + + TRACEJVMCALLSEXIT(("->%d (name=%s)", result, name)); + + return result; +} + + +/* JVM_GetHostByAddr */ + +struct hostent *JVM_GetHostByAddr(const char* name, int len, int type) +{ + log_println("JVM_GetHostByAddr: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetHostByName */ + +struct hostent *JVM_GetHostByName(char* name) +{ + log_println("JVM_GetHostByName: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetProtoByName */ + +struct protoent *JVM_GetProtoByName(char* name) +{ + log_println("JVM_GetProtoByName: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_LoadLibrary */ + +void *JVM_LoadLibrary(const char *name) +{ + utf* u; + void* handle; + + TRACEJVMCALLSENTER(("JVM_LoadLibrary(name=%s)", name)); + + u = utf_new_char(name); + + handle = native_library_open(u); + + TRACEJVMCALLSEXIT(("->%p", handle)); + + return handle; +} + + +/* JVM_UnloadLibrary */ + +void JVM_UnloadLibrary(void* handle) +{ + TRACEJVMCALLS(("JVM_UnloadLibrary(handle=%p)", handle)); + + native_library_close(handle); +} + + +/* JVM_FindLibraryEntry */ + +void *JVM_FindLibraryEntry(void *handle, const char *name) +{ + void* symbol; + + TRACEJVMCALLSENTER(("JVM_FindLibraryEntry(handle=%p, name=%s)", handle, name)); + + symbol = hpi_library->FindLibraryEntry(handle, name); + + TRACEJVMCALLSEXIT(("->%p", symbol)); + + return symbol; +} + + +/* JVM_IsNaN */ + +jboolean JVM_IsNaN(jdouble a) +{ + log_println("JVM_IsNaN: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_IsSupportedJNIVersion */ + +jboolean JVM_IsSupportedJNIVersion(jint version) +{ + TRACEJVMCALLS(("JVM_IsSupportedJNIVersion(version=%d)", version)); + + return jni_version_check(version); +} + + +/* JVM_InternString */ + +jstring JVM_InternString(JNIEnv *env, jstring str) +{ + TRACEJVMCALLS(("JVM_InternString(env=%p, str=%p)", env, str)); + + return (jstring) javastring_intern((java_handle_t *) str); +} + + +/* JVM_RawMonitorCreate */ + +JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void) +{ + java_object_t *o; + + TRACEJVMCALLS(("JVM_RawMonitorCreate()")); + + o = NEW(java_object_t); + + lock_init_object_lock(o); + + return o; +} + + +/* JVM_RawMonitorDestroy */ + +JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon) +{ + TRACEJVMCALLS(("JVM_RawMonitorDestroy(mon=%p)", mon)); + + FREE(mon, java_object_t); +} + + +/* JVM_RawMonitorEnter */ + +JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon) +{ + TRACEJVMCALLS(("JVM_RawMonitorEnter(mon=%p)", mon)); + + (void) lock_monitor_enter((java_object_t *) mon); + + return 0; +} + + +/* JVM_RawMonitorExit */ + +JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) +{ + TRACEJVMCALLS(("JVM_RawMonitorExit(mon=%p)", mon)); + + (void) lock_monitor_exit((java_object_t *) mon); +} + + +/* JVM_SetPrimitiveFieldValues */ + +void JVM_SetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data) +{ + log_println("JVM_SetPrimitiveFieldValues: IMPLEMENT ME!"); +} + + +/* JVM_GetPrimitiveFieldValues */ + +void JVM_GetPrimitiveFieldValues(JNIEnv *env, jclass cb, jobject obj, jlongArray fieldIDs, jcharArray typecodes, jbyteArray data) +{ + log_println("JVM_GetPrimitiveFieldValues: IMPLEMENT ME!"); +} + + +/* JVM_AccessVMBooleanFlag */ + +jboolean JVM_AccessVMBooleanFlag(const char* name, jboolean* value, jboolean is_get) +{ + log_println("JVM_AccessVMBooleanFlag: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_AccessVMIntFlag */ + +jboolean JVM_AccessVMIntFlag(const char* name, jint* value, jboolean is_get) +{ + log_println("JVM_AccessVMIntFlag: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_VMBreakPoint */ + +void JVM_VMBreakPoint(JNIEnv *env, jobject obj) +{ + log_println("JVM_VMBreakPoint: IMPLEMENT ME!"); +} + + +/* JVM_GetClassFields */ + +jobjectArray JVM_GetClassFields(JNIEnv *env, jclass cls, jint which) +{ + log_println("JVM_GetClassFields: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassMethods */ + +jobjectArray JVM_GetClassMethods(JNIEnv *env, jclass cls, jint which) +{ + log_println("JVM_GetClassMethods: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassConstructors */ + +jobjectArray JVM_GetClassConstructors(JNIEnv *env, jclass cls, jint which) +{ + log_println("JVM_GetClassConstructors: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassField */ + +jobject JVM_GetClassField(JNIEnv *env, jclass cls, jstring name, jint which) +{ + log_println("JVM_GetClassField: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassMethod */ + +jobject JVM_GetClassMethod(JNIEnv *env, jclass cls, jstring name, jobjectArray types, jint which) +{ + log_println("JVM_GetClassMethod: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetClassConstructor */ + +jobject JVM_GetClassConstructor(JNIEnv *env, jclass cls, jobjectArray types, jint which) +{ + log_println("JVM_GetClassConstructor: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_NewInstance */ + +jobject JVM_NewInstance(JNIEnv *env, jclass cls) +{ + log_println("JVM_NewInstance: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetField */ + +jobject JVM_GetField(JNIEnv *env, jobject field, jobject obj) +{ + log_println("JVM_GetField: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetPrimitiveField */ + +jvalue JVM_GetPrimitiveField(JNIEnv *env, jobject field, jobject obj, unsigned char wCode) +{ + jvalue jv; + + log_println("JVM_GetPrimitiveField: IMPLEMENT ME!"); + + jv.l = NULL; + + return jv; +} + + +/* JVM_SetField */ + +void JVM_SetField(JNIEnv *env, jobject field, jobject obj, jobject val) +{ + log_println("JVM_SetField: IMPLEMENT ME!"); +} + + +/* JVM_SetPrimitiveField */ + +void JVM_SetPrimitiveField(JNIEnv *env, jobject field, jobject obj, jvalue v, unsigned char vCode) +{ + log_println("JVM_SetPrimitiveField: IMPLEMENT ME!"); +} + + +/* JVM_InvokeMethod */ + +jobject JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0) +{ + TRACEJVMCALLS(("JVM_InvokeMethod(env=%p, method=%p, obj=%p, args0=%p)", env, method, obj, args0)); + + java_lang_reflect_Method jlrm(method); + + java_handle_t* result = jlrm.invoke((java_handle_t*) obj, (java_handle_objectarray_t*) args0); + + return (jobject) result; +} + + +/* JVM_NewInstanceFromConstructor */ + +jobject JVM_NewInstanceFromConstructor(JNIEnv *env, jobject con, jobjectArray args0) +{ + TRACEJVMCALLS(("JVM_NewInstanceFromConstructor(env=%p, c=%p, args0=%p)", env, con, args0)); + + java_lang_reflect_Constructor jlrc(con); + java_handle_t* o = jlrc.new_instance((java_handle_objectarray_t*) args0); + + return (jobject) o; +} + + +/* JVM_SupportsCX8 */ + +jboolean JVM_SupportsCX8() +{ + TRACEJVMCALLS(("JVM_SupportsCX8()")); + + /* IMPLEMENT ME */ + + return 0; +} + + +/* JVM_CX8Field */ + +jboolean JVM_CX8Field(JNIEnv *env, jobject obj, jfieldID fid, jlong oldVal, jlong newVal) +{ + log_println("JVM_CX8Field: IMPLEMENT ME!"); + + return 0; +} + + +/* JVM_GetAllThreads */ + +jobjectArray JVM_GetAllThreads(JNIEnv *env, jclass dummy) +{ + log_println("JVM_GetAllThreads: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_DumpThreads */ + +jobjectArray JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads) +{ + log_println("JVM_DumpThreads: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetManagement */ + +void *JVM_GetManagement(jint version) +{ + TRACEJVMCALLS(("JVM_GetManagement(version=%d)", version)); + + /* TODO We current don't support the management interface. */ + + return NULL; +} + + +/* JVM_InitAgentProperties */ + +jobject JVM_InitAgentProperties(JNIEnv *env, jobject properties) +{ + log_println("JVM_InitAgentProperties: IMPLEMENT ME!"); + + return NULL; +} + + +/* JVM_GetEnclosingMethodInfo */ + +jobjectArray JVM_GetEnclosingMethodInfo(JNIEnv *env, jclass ofClass) +{ + classinfo *c; + methodinfo *m; + java_handle_objectarray_t *oa; + + TRACEJVMCALLS(("JVM_GetEnclosingMethodInfo(env=%p, ofClass=%p)", env, ofClass)); + + c = LLNI_classinfo_unwrap(ofClass); + + if ((c == NULL) || class_is_primitive(c)) + return NULL; + + m = class_get_enclosingmethod_raw(c); + + if (m == NULL) + return NULL; + + oa = builtin_anewarray(3, class_java_lang_Object); + + if (oa == NULL) + return NULL; + + array_objectarray_element_set(oa, 0, (java_handle_t *) LLNI_classinfo_wrap(m->clazz)); + array_objectarray_element_set(oa, 1, javastring_new(m->name)); + array_objectarray_element_set(oa, 2, javastring_new(m->descriptor)); + + return (jobjectArray) oa; +} + + +/* JVM_GetThreadStateValues */ + +jintArray JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState) +{ + java_handle_intarray_t *ia; + + TRACEJVMCALLS(("JVM_GetThreadStateValues(env=%p, javaThreadState=%d)", + env, javaThreadState)); + + /* If new thread states are added in future JDK and VM versions, + this should check if the JDK version is compatible with thread + states supported by the VM. Return NULL if not compatible. + + This function must map the VM java_lang_Thread::ThreadStatus + to the Java thread state that the JDK supports. */ + + switch (javaThreadState) { + case THREAD_STATE_NEW: + ia = builtin_newarray_int(1); + + if (ia == NULL) + return NULL; + + array_intarray_element_set(ia, 0, THREAD_STATE_NEW); + break; + + case THREAD_STATE_RUNNABLE: + ia = builtin_newarray_int(1); + + if (ia == NULL) + return NULL; + + array_intarray_element_set(ia, 0, THREAD_STATE_RUNNABLE); + break; + + case THREAD_STATE_BLOCKED: + ia = builtin_newarray_int(1); + + if (ia == NULL) + return NULL; + + array_intarray_element_set(ia, 0, THREAD_STATE_BLOCKED); + break; + + case THREAD_STATE_WAITING: + ia = builtin_newarray_int(2); + + if (ia == NULL) + return NULL; + + array_intarray_element_set(ia, 0, THREAD_STATE_WAITING); + /* XXX Implement parked stuff. */ +/* array_intarray_element_set(ia, 1, PARKED); */ + break; + + case THREAD_STATE_TIMED_WAITING: + ia = builtin_newarray_int(3); + + if (ia == NULL) + return NULL; + + /* XXX Not sure about that one. */ +/* array_intarray_element_set(ia, 0, SLEEPING); */ + array_intarray_element_set(ia, 0, THREAD_STATE_TIMED_WAITING); + /* XXX Implement parked stuff. */ +/* array_intarray_element_set(ia, 2, PARKED); */ + break; + + case THREAD_STATE_TERMINATED: + ia = builtin_newarray_int(1); + + if (ia == NULL) + return NULL; + + array_intarray_element_set(ia, 0, THREAD_STATE_TERMINATED); + break; + + default: + /* Unknown state - probably incompatible JDK version */ + return NULL; + } + + return (jintArray) ia; +} + + +/* JVM_GetThreadStateNames */ + +jobjectArray JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values) +{ + java_handle_intarray_t *ia; + java_handle_objectarray_t *oa; + java_object_t *s; + + TRACEJVMCALLS(("JVM_GetThreadStateNames(env=%p, javaThreadState=%d, values=%p)", + env, javaThreadState, values)); + + ia = (java_handle_intarray_t *) values; + + /* If new thread states are added in future JDK and VM versions, + this should check if the JDK version is compatible with thread + states supported by the VM. Return NULL if not compatible. + + This function must map the VM java_lang_Thread::ThreadStatus + to the Java thread state that the JDK supports. */ + + if (values == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + switch (javaThreadState) { + case THREAD_STATE_NEW: + assert(ia->header.size == 1 && ia->data[0] == THREAD_STATE_NEW); + + oa = builtin_anewarray(1, class_java_lang_String); + + if (oa == NULL) + return NULL; + + s = javastring_new(utf_new_char("NEW")); + + if (s == NULL) + return NULL; + + array_objectarray_element_set(oa, 0, s); + break; + + case THREAD_STATE_RUNNABLE: + oa = builtin_anewarray(1, class_java_lang_String); + + if (oa == NULL) + return NULL; + + s = javastring_new(utf_new_char("RUNNABLE")); + + if (s == NULL) + return NULL; + + array_objectarray_element_set(oa, 0, s); + break; + + case THREAD_STATE_BLOCKED: + oa = builtin_anewarray(1, class_java_lang_String); + + if (oa == NULL) + return NULL; + + s = javastring_new(utf_new_char("BLOCKED")); + + if (s == NULL) + return NULL; + + array_objectarray_element_set(oa, 0, s); + break; + + case THREAD_STATE_WAITING: + oa = builtin_anewarray(2, class_java_lang_String); + + if (oa == NULL) + return NULL; + + s = javastring_new(utf_new_char("WAITING.OBJECT_WAIT")); +/* s = javastring_new(utf_new_char("WAITING.PARKED")); */ + + if (s == NULL) + return NULL; + + array_objectarray_element_set(oa, 0, s); +/* array_objectarray_element_set(oa, 1, s); */ + break; + + case THREAD_STATE_TIMED_WAITING: + oa = builtin_anewarray(3, class_java_lang_String); + + if (oa == NULL) + return NULL; + +/* s = javastring_new(utf_new_char("TIMED_WAITING.SLEEPING")); */ + s = javastring_new(utf_new_char("TIMED_WAITING.OBJECT_WAIT")); +/* s = javastring_new(utf_new_char("TIMED_WAITING.PARKED")); */ + + if (s == NULL) + return NULL; + +/* array_objectarray_element_set(oa, 0, s); */ + array_objectarray_element_set(oa, 0, s); +/* array_objectarray_element_set(oa, 2, s); */ + break; + + case THREAD_STATE_TERMINATED: + oa = builtin_anewarray(1, class_java_lang_String); + + if (oa == NULL) + return NULL; + + s = javastring_new(utf_new_char("TERMINATED")); + + if (s == NULL) + return NULL; + + array_objectarray_element_set(oa, 0, s); + break; + + default: + /* Unknown state - probably incompatible JDK version */ + return NULL; + } + + return (jobjectArray) oa; +} + + +/* JVM_GetVersionInfo */ + +void JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size) +{ + log_println("JVM_GetVersionInfo: IMPLEMENT ME!"); +} + + +/* OS: JVM_RegisterSignal */ + +void *JVM_RegisterSignal(jint sig, void *handler) +{ + functionptr newHandler; + + TRACEJVMCALLS(("JVM_RegisterSignal(sig=%d, handler=%p)", sig, handler)); + + if (handler == (void *) 2) + newHandler = (functionptr) signal_thread_handler; + else + newHandler = (functionptr) (uintptr_t) handler; + + switch (sig) { + case SIGILL: + case SIGFPE: + case SIGUSR1: + case SIGSEGV: + /* These signals are already used by the VM. */ + return (void *) -1; + + case SIGQUIT: + /* This signal is used by the VM to dump thread stacks unless + ReduceSignalUsage is set, in which case the user is allowed + to set his own _native_ handler for this signal; thus, in + either case, we do not allow JVM_RegisterSignal to change + the handler. */ + return (void *) -1; + + case SIGHUP: + case SIGINT: + case SIGTERM: + break; + } + + signal_register_signal(sig, newHandler, SA_RESTART | SA_SIGINFO); + + /* XXX Should return old handler. */ + + return (void *) 2; +} + + +/* OS: JVM_RaiseSignal */ + +jboolean JVM_RaiseSignal(jint sig) +{ + log_println("JVM_RaiseSignal: IMPLEMENT ME! sig=%s", sig); + + return false; +} + + +/* OS: JVM_FindSignal */ + +jint JVM_FindSignal(const char *name) +{ + TRACEJVMCALLS(("JVM_FindSignal(name=%s)", name)); + +#if defined(__LINUX__) + if (strcmp(name, "HUP") == 0) + return SIGHUP; + + if (strcmp(name, "INT") == 0) + return SIGINT; + + if (strcmp(name, "TERM") == 0) + return SIGTERM; +#elif defined(__SOLARIS__) + int signum; + + if (os::str2sig(name, &signum) == -1) + return -1; + + return signum; +#else +# error Not implemented for this OS. +#endif + + return -1; +} + +} // extern "C" + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/native/vm/reflect.c b/src/native/vm/reflect.c deleted file mode 100644 index 90b172989..000000000 --- a/src/native/vm/reflect.c +++ /dev/null @@ -1,700 +0,0 @@ -/* src/native/vm/reflect.c - helper functions for java/lang/reflect - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -/* keep this order of the native includes */ - -#include "native/include/java_lang_String.h" - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -#endif -#include "native/include/java_lang_ClassLoader.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_reflect_Constructor.h" -#include "native/include/java_lang_reflect_Field.h" -#include "native/include/java_lang_reflect_Method.h" - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/java_lang_reflect_VMConstructor.h" -# include "native/include/java_lang_reflect_VMField.h" -# include "native/include/java_lang_reflect_VMMethod.h" -#endif - -#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "vm/vm.h" -# include "native/include/sun_reflect_ConstantPool.h" -#endif - -#include "native/vm/reflect.h" - -#include "vm/access.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/initialize.h" -#include "vm/stringlocal.h" - -#include "vmcore/method.h" - - -/* reflect_constructor_new ***************************************************** - - Allocates a new java.lang.reflect.Constructor object and - initializes the fields with the method passed. - -*******************************************************************************/ - -java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m) -{ - java_handle_t *o; - java_lang_reflect_Constructor *rc; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMConstructor *rvmc; -#endif - - /* Allocate a java.lang.reflect.Constructor object. */ - - o = builtin_new(class_java_lang_reflect_Constructor); - - if (o == NULL) - return NULL; - - /* Initialize instance fields. */ - - rc = (java_lang_reflect_Constructor *) o; - - /* Calculate the slot. */ - - slot = m - m->clazz->methods; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Allocate a java.lang.reflect.VMConstructor object. */ - - o = builtin_new(class_java_lang_reflect_VMConstructor); - - if (o == NULL) - return NULL; - - rvmc = (java_lang_reflect_VMConstructor *) o; - - /* Link the two Java objects. */ - - LLNI_field_set_ref(rc, cons, rvmc); - LLNI_field_set_ref(rvmc, cons, rc); - - /* Set Java object instance fields. */ - - LLNI_field_set_cls(rvmc, clazz, m->clazz); - LLNI_field_set_val(rvmc, slot, slot); - LLNI_field_set_ref(rvmc, annotations, method_get_annotations(m)); - LLNI_field_set_ref(rvmc, parameterAnnotations, method_get_parameterannotations(m)); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* Set Java object instance fields. */ - - LLNI_field_set_cls(rc, clazz , m->clazz); - LLNI_field_set_ref(rc, parameterTypes , method_get_parametertypearray(m)); - LLNI_field_set_ref(rc, exceptionTypes , method_get_exceptionarray(m)); - LLNI_field_set_val(rc, modifiers , m->flags & ACC_CLASS_REFLECT_MASK); - LLNI_field_set_val(rc, slot , slot); - LLNI_field_set_ref(rc, signature , m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL); - LLNI_field_set_ref(rc, annotations , method_get_annotations(m)); - LLNI_field_set_ref(rc, parameterAnnotations, method_get_parameterannotations(m)); - -#else -# error unknown classpath configuration -#endif - - return rc; -} - - -/* reflect_field_new *********************************************************** - - Allocates a new java.lang.reflect.Field object and initializes the - fields with the field passed. - -*******************************************************************************/ - -java_lang_reflect_Field *reflect_field_new(fieldinfo *f) -{ - java_handle_t *o; - java_lang_reflect_Field *rf; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMField *rvmf; -#endif - - /* Allocate a java.lang.reflect.Field object. */ - - o = builtin_new(class_java_lang_reflect_Field); - - if (o == NULL) - return NULL; - - /* initialize instance fields */ - - rf = (java_lang_reflect_Field *) o; - - /* Calculate the slot. */ - - slot = f - f->clazz->fields; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Allocate a java.lang.reflect.VMField object. */ - - o = builtin_new(class_java_lang_reflect_VMField); - - if (o == NULL) - return NULL; - - rvmf = (java_lang_reflect_VMField *) o; - - /* Link the two Java objects. */ - - LLNI_field_set_ref(rf, f, rvmf); - LLNI_field_set_ref(rvmf, f, rf); - - /* Set the Java object fields. */ - - LLNI_field_set_cls(rvmf, clazz, f->clazz); - - /* The name needs to be interned */ - /* XXX implement me better! */ - - LLNI_field_set_ref(rvmf, name, (java_lang_String *) javastring_intern(javastring_new(f->name))); - LLNI_field_set_val(rvmf, slot, slot); - LLNI_field_set_ref(rvmf, annotations, field_get_annotations(f)); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* Set the Java object fields. */ - - LLNI_field_set_cls(rf, clazz, f->clazz); - - /* The name needs to be interned */ - /* XXX implement me better! */ - - LLNI_field_set_ref(rf, name, (java_lang_String *) javastring_intern(javastring_new(f->name))); - LLNI_field_set_cls(rf, type, (java_lang_Class *) field_get_type(f)); - LLNI_field_set_val(rf, modifiers, f->flags); - LLNI_field_set_val(rf, slot, slot); - LLNI_field_set_ref(rf, signature, f->signature ? (java_lang_String *) javastring_new(f->signature) : NULL); - LLNI_field_set_ref(rf, annotations, field_get_annotations(f)); - -#else -# error unknown classpath configuration -#endif - - return rf; -} - - -/* reflect_method_new ********************************************************** - - Allocates a new java.lang.reflect.Method object and initializes the - fields with the method passed. - -*******************************************************************************/ - -java_lang_reflect_Method *reflect_method_new(methodinfo *m) -{ - java_handle_t *o; - java_lang_reflect_Method *rm; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMMethod *rvmm; -#endif - - /* Allocate a java.lang.reflect.Method object. */ - - o = builtin_new(class_java_lang_reflect_Method); - - if (o == NULL) - return NULL; - - /* initialize instance fields */ - - rm = (java_lang_reflect_Method *) o; - - /* Calculate the slot. */ - - slot = m - m->clazz->methods; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Allocate a java.lang.reflect.VMMethod object. */ - - o = builtin_new(class_java_lang_reflect_VMMethod); - - if (o == NULL) - return NULL; - - rvmm = (java_lang_reflect_VMMethod *) o; - - /* Link the two Java objects. */ - - LLNI_field_set_ref(rm, m, rvmm); - LLNI_field_set_ref(rvmm, m, rm); - - /* Set Java object instance fields. */ - - LLNI_field_set_cls(rvmm, clazz, m->clazz); - - /* The name needs to be interned */ - /* XXX implement me better! */ - - LLNI_field_set_ref(rvmm, name, (java_lang_String *) javastring_intern(javastring_new(m->name))); - LLNI_field_set_val(rvmm, slot, slot); - LLNI_field_set_ref(rvmm, annotations, method_get_annotations(m)); - LLNI_field_set_ref(rvmm, parameterAnnotations, method_get_parameterannotations(m)); - LLNI_field_set_ref(rvmm, annotationDefault, method_get_annotationdefault(m)); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - LLNI_field_set_cls(rm, clazz, m->clazz); - - /* The name needs to be interned */ - /* XXX implement me better! */ - - LLNI_field_set_ref(rm, name, (java_lang_String *) javastring_intern(javastring_new(m->name))); - LLNI_field_set_ref(rm, parameterTypes, method_get_parametertypearray(m)); - LLNI_field_set_cls(rm, returnType, (java_lang_Class *) method_returntype_get(m)); - LLNI_field_set_ref(rm, exceptionTypes, method_get_exceptionarray(m)); - LLNI_field_set_val(rm, modifiers, m->flags & ACC_CLASS_REFLECT_MASK); - LLNI_field_set_val(rm, slot, slot); - LLNI_field_set_ref(rm, signature, m->signature ? (java_lang_String *) javastring_new(m->signature) : NULL); - LLNI_field_set_ref(rm, annotations, method_get_annotations(m)); - LLNI_field_set_ref(rm, parameterAnnotations, method_get_parameterannotations(m)); - LLNI_field_set_ref(rm, annotationDefault, method_get_annotationdefault(m)); - -#else -# error unknown classpath configuration -#endif - - return rm; -} - - -/* reflect_invoke ************************************************************** - - Invoke a method on the given object with the given arguments. - - For instance methods OBJ must be != NULL and the method is looked up - in the vftbl of the object. - - For static methods, OBJ is ignored. - -*******************************************************************************/ - -static java_handle_t *reflect_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params) -{ - methodinfo *resm; - java_handle_t *ro; - int argcount; - int paramcount; - - /* Sanity check. */ - - assert(m != NULL); - - argcount = m->parseddesc->paramcount; - paramcount = argcount; - - /* If method is non-static, remove the `this' pointer. */ - - if (!(m->flags & ACC_STATIC)) - paramcount--; - - /* For instance methods the object has to be an instance of the - class the method belongs to. For static methods the obj - parameter is ignored. */ - - if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->clazz))) { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* check if we got the right number of arguments */ - - if (((params == NULL) && (paramcount != 0)) || - (params && (LLNI_array_size(params) != paramcount))) - { - exceptions_throw_illegalargumentexception(); - return NULL; - } - - /* for instance methods we need an object */ - - if (!(m->flags & ACC_STATIC) && (o == NULL)) { - /* XXX not sure if that is the correct exception */ - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* for static methods, zero object to make subsequent code simpler */ - if (m->flags & ACC_STATIC) - o = NULL; - - if (o != NULL) { - /* for instance methods we must do a vftbl lookup */ - resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m); - } - else { - /* for static methods, just for convenience */ - resm = m; - } - - ro = vm_call_method_objectarray(resm, o, params); - - return ro; -} - - -/* reflect_constructor_newinstance ******************************************** - - Creates an Java object instance of the given constructor. - - ARGUMENTS: - m .......... methodinfo of the constructor - args ....... constructor arguments - override ... override security checks - - RETURN: - constructed Java object - -*******************************************************************************/ - -java_handle_t *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override) -{ - java_handle_t *o; - - /* Should we bypass security the checks (AccessibleObject)? */ - - if (override == false) { - /* This method is always called like this: - [0] java.lang.reflect.Constructor.constructNative (Native Method) - [1] java.lang.reflect.Constructor.newInstance - [2] - */ - - if (!access_check_method(m, 2)) - return NULL; - } - - /* Create a Java object. */ - - o = builtin_new(m->clazz); - - if (o == NULL) - return NULL; - - /* Call initializer. */ - - (void) reflect_invoke(m, o, args); - - return o; -} - - -/* reflect_method_invoke ******************************************************* - - Invokes the given method. - - ARGUMENTS: - m .......... methodinfo - args ....... method arguments - override ... override security checks - - RETURN: - return value of the method - -*******************************************************************************/ - -java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override) -{ - java_handle_t *ro; - - /* Should we bypass security the checks (AccessibleObject)? */ - - if (override == false) { -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - /* This method is always called like this: - [0] java.lang.reflect.Method.invokeNative (Native Method) - [1] java.lang.reflect.Method.invoke (Method.java:329) - [2] - */ - - if (!access_check_method(m, 2)) - return NULL; -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - /* We only pass 1 here as stacktrace_get_caller_class, which - is called from access_check_method, skips - java.lang.reflect.Method.invoke(). */ - - if (!access_check_method(m, 1)) - return NULL; -#else -# error unknown classpath configuration -#endif - } - - /* Check if method class is initialized. */ - - if (!(m->clazz->state & CLASS_INITIALIZED)) - if (!initialize_class(m->clazz)) - return NULL; - - /* Call the Java method. */ - - ro = reflect_invoke(m, o, args); - - return ro; -} - - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS) -/* reflect_get_declaredannotatios ********************************************* - - Calls the annotation parser with the unparsed annotations and returnes - the parsed annotations as a map. - - IN: - annotations........the unparsed annotations - declaringClass.....the class in which the annotated element is declared - referer............the calling class (for the 'referer' parameter of - vm_call_method()) - - RETURN VALUE: - The parsed annotations as a - java.util.Map, Annotation>. - -*******************************************************************************/ - -struct java_util_Map* reflect_get_declaredannotatios( - java_handle_bytearray_t *annotations, - java_lang_Class *declaringClass, - classinfo *referer) -{ - static methodinfo *m_parseAnnotations = NULL; - /* parser method (chached, therefore static) */ - utf *utf_parseAnnotations = NULL; - /* parser method name */ - utf *utf_desc = NULL; - /* parser method descriptor (signature) */ - sun_reflect_ConstantPool *constantPool = NULL; - /* constant pool of the declaring class */ - java_lang_Object *constantPoolOop = (java_lang_Object*)declaringClass; - /* constantPoolOop field of the constant pool */ - /* object (sun.reflect.ConstantPool) */ - - constantPool = - (sun_reflect_ConstantPool*)native_new_and_init( - class_sun_reflect_ConstantPool); - - if(constantPool == NULL) { - /* out of memory */ - return NULL; - } - - LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop); - - /* only resolve the parser method the first time */ - if (m_parseAnnotations == NULL) { - utf_parseAnnotations = utf_new_char("parseAnnotations"); - utf_desc = utf_new_char( - "([BLsun/reflect/ConstantPool;Ljava/lang/Class;)" - "Ljava/util/Map;"); - - if (utf_parseAnnotations == NULL || utf_desc == NULL) { - /* out of memory */ - return NULL; - } - - m_parseAnnotations = class_resolveclassmethod( - class_sun_reflect_annotation_AnnotationParser, - utf_parseAnnotations, - utf_desc, - referer, - true); - - if (m_parseAnnotations == NULL) { - /* method not found */ - return NULL; - } - } - - return (struct java_util_Map*)vm_call_method( - m_parseAnnotations, NULL, annotations, - constantPool, declaringClass); -} - - -/* reflect_get_parameterannotations ******************************************* - - Calls the annotation parser with the unparsed parameter annotations of - a method and returnes the parsed parameter annotations in a 2 dimensional - array. - - IN: - parameterAnnotations....the unparsed parameter annotations - slot....................the slot of the method - declaringClass..........the class in which the annotated element is - declared - referer.................the calling class (for the 'referer' parameter - of vm_call_method()) - - RETURN VALUE: - The parsed parameter annotations in a 2 dimensional array. - -*******************************************************************************/ - -java_handle_objectarray_t* reflect_get_parameterannotations( - java_handle_t *parameterAnnotations, - int32_t slot, - java_lang_Class *declaringClass, - classinfo *referer) -{ - /* This method in java would be basically the following. - * We don't do it in java because we don't want to make a - * public method with wich you can get a ConstantPool, because - * with that you could read any kind of constants (even private - * ones). - * - * ConstantPool constPool = new ConstantPool(); - * constPool.constantPoolOop = method.getDeclaringClass(); - * return sun.reflect.AnnotationParser.parseParameterAnnotations( - * parameterAnnotations, - * constPool, - * method.getDeclaringClass(), - * method.getParameterTypes().length); - */ - static methodinfo *m_parseParameterAnnotations = NULL; - /* parser method (cached, therefore static) */ - utf *utf_parseParameterAnnotations = NULL; - /* parser method name */ - utf *utf_desc = NULL; - /* parser method descriptor (signature) */ - sun_reflect_ConstantPool *constantPool = NULL; - /* constant pool of the declaring class */ - java_lang_Object *constantPoolOop = (java_lang_Object*)declaringClass; - /* constantPoolOop field of the constant pool object */ - classinfo *c = NULL; - /* classinfo of the decaring class */ - methodinfo *m = NULL; - /* method info of the annotated method */ - int32_t numParameters = -1; - /* parameter count of the annotated method */ - - /* get parameter count */ - - c = LLNI_classinfo_unwrap(declaringClass); - m = &(c->methods[slot]); - - numParameters = method_get_parametercount(m); - - if (numParameters < 0) { - /* error parsing descriptor */ - return NULL; - } - - /* get ConstantPool */ - - constantPool = - (sun_reflect_ConstantPool*)native_new_and_init( - class_sun_reflect_ConstantPool); - - if(constantPool == NULL) { - /* out of memory */ - return NULL; - } - - LLNI_field_set_ref(constantPool, constantPoolOop, constantPoolOop); - - /* only resolve the parser method the first time */ - if (m_parseParameterAnnotations == NULL) { - utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations"); - utf_desc = utf_new_char( - "([BLsun/reflect/ConstantPool;Ljava/lang/Class;I)" - "[[Ljava/lang/annotation/Annotation;"); - - if (utf_parseParameterAnnotations == NULL || utf_desc == NULL) { - /* out of memory */ - return NULL; - } - - /* get parser method */ - - m_parseParameterAnnotations = class_resolveclassmethod( - class_sun_reflect_annotation_AnnotationParser, - utf_parseParameterAnnotations, - utf_desc, - referer, - true); - - if (m_parseParameterAnnotations == NULL) - { - /* method not found */ - return NULL; - } - } - - return (java_handle_objectarray_t*)vm_call_method( - m_parseParameterAnnotations, NULL, parameterAnnotations, - constantPool, declaringClass, numParameters); -} -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/reflect.h b/src/native/vm/reflect.h deleted file mode 100644 index 6c6b45182..000000000 --- a/src/native/vm/reflect.h +++ /dev/null @@ -1,96 +0,0 @@ -/* src/native/vm/reflect.h - helper functions for java/lang/reflect - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _REFLECT_H -#define _REFLECT_H - -#include "config.h" - -#include - -#include "native/jni.h" -#include "native/native.h" - -/* Keep this order of the native includes. */ - -#include "native/include/java_lang_String.h" - -#if defined(ENABLE_JAVASE) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -# endif -# include "native/include/java_lang_ClassLoader.h" -#endif - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Class.h" - -#if defined(ENABLE_JAVASE) -# include "native/include/java_lang_reflect_Constructor.h" -# include "native/include/java_lang_reflect_Field.h" -# include "native/include/java_lang_reflect_Method.h" -#endif - -#include "vmcore/field.h" -#include "vmcore/method.h" - - -/* function prototypes ********************************************************/ - -java_lang_reflect_Constructor *reflect_constructor_new(methodinfo *m); -java_lang_reflect_Field *reflect_field_new(fieldinfo *f); -java_lang_reflect_Method *reflect_method_new(methodinfo *m); -java_handle_t *reflect_constructor_newinstance(methodinfo *m, java_handle_objectarray_t *args, bool override); -java_handle_t *reflect_method_invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *args, bool override); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS) -struct java_util_Map* reflect_get_declaredannotatios( - java_handle_bytearray_t *annotations, - java_lang_Class *declaringClass, - classinfo *referer); - -java_handle_objectarray_t* reflect_get_parameterannotations( - java_handle_t *parameterAnnotations, - int32_t slot, - java_lang_Class *declaringClass, - classinfo *referer); -#endif - -#endif /* _REFLECT_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/native/vm/reflection.cpp b/src/native/vm/reflection.cpp new file mode 100644 index 000000000..14ba348a2 --- /dev/null +++ b/src/native/vm/reflection.cpp @@ -0,0 +1,269 @@ +/* src/native/vm/reflection.cpp - helper functions for java/lang/reflect + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_ANNOTATIONS) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +# include "vm/vm.hpp" +#endif + +#include "native/vm/reflection.hpp" + +#include "vm/access.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/method.h" +#include "vm/string.hpp" + + +/** + * Invoke a method on the given object with the given arguments. + * + * For instance methods OBJ must be != NULL and the method is looked up + * in the vftbl of the object. + * + * For static methods, OBJ is ignored. + */ +java_handle_t* Reflection::invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params) +{ + methodinfo *resm; + java_handle_t *ro; + int argcount; + int paramcount; + + /* Sanity check. */ + + assert(m != NULL); + + argcount = m->parseddesc->paramcount; + paramcount = argcount; + + /* If method is non-static, remove the `this' pointer. */ + + if (!(m->flags & ACC_STATIC)) + paramcount--; + + /* For instance methods the object has to be an instance of the + class the method belongs to. For static methods the obj + parameter is ignored. */ + + if (!(m->flags & ACC_STATIC) && o && (!builtin_instanceof(o, m->clazz))) { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* check if we got the right number of arguments */ + + if (((params == NULL) && (paramcount != 0)) || + (params && (LLNI_array_size(params) != paramcount))) + { + exceptions_throw_illegalargumentexception(); + return NULL; + } + + /* for instance methods we need an object */ + + if (!(m->flags & ACC_STATIC) && (o == NULL)) { + /* XXX not sure if that is the correct exception */ + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* for static methods, zero object to make subsequent code simpler */ + if (m->flags & ACC_STATIC) + o = NULL; + + if (o != NULL) { + /* for instance methods we must do a vftbl lookup */ + resm = method_vftbl_lookup(LLNI_vftbl_direct(o), m); + } + else { + /* for static methods, just for convenience */ + resm = m; + } + + ro = vm_call_method_objectarray(resm, o, params); + + return ro; +} + + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS) +/* reflect_get_declaredannotations ********************************************* + + Calls the annotation parser with the unparsed annotations and returnes + the parsed annotations as a map. + + IN: + annotations........the unparsed annotations + declaringClass.....the class in which the annotated element is declared + referer............the calling class (for the 'referer' parameter of + vm_call_method()) + + RETURN VALUE: + The parsed annotations as a + java.util.Map, Annotation>. + +*******************************************************************************/ + +java_handle_t* Reflection::get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer) +{ + static methodinfo* m_parseAnnotations = NULL; + + java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool); + + if (h == NULL) + return NULL; + + sun_reflect_ConstantPool cp(h); + cp.set_constantPoolOop(declaringClass); + + /* only resolve the parser method the first time */ + if (m_parseAnnotations == NULL) { + // FIXME Use globals. + utf* utf_parseAnnotations = utf_new_char("parseAnnotations"); + utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;)Ljava/util/Map;"); + + if (utf_parseAnnotations == NULL || utf_desc == NULL) + return NULL; + + m_parseAnnotations = class_resolveclassmethod( + class_sun_reflect_annotation_AnnotationParser, + utf_parseAnnotations, + utf_desc, + referer, + true); + + if (m_parseAnnotations == NULL) + return NULL; + } + + return (java_handle_t*) vm_call_method(m_parseAnnotations, NULL, annotations, cp.get_handle(), declaringClass); +} + + +/* reflect_get_parameterannotations ******************************************* + + Calls the annotation parser with the unparsed parameter annotations of + a method and returnes the parsed parameter annotations in a 2 dimensional + array. + + IN: + parameterAnnotations....the unparsed parameter annotations + slot....................the slot of the method + declaringClass..........the class in which the annotated element is + declared + referer.................the calling class (for the 'referer' parameter + of vm_call_method()) + + RETURN VALUE: + The parsed parameter annotations in a 2 dimensional array. + +*******************************************************************************/ + +java_handle_objectarray_t* Reflection::get_parameterannotations(java_handle_bytearray_t* parameterAnnotations, methodinfo* m, classinfo* referer) +{ + /* This method in java would be basically the following. + * We don't do it in java because we don't want to make a + * public method with wich you can get a ConstantPool, because + * with that you could read any kind of constants (even private + * ones). + * + * ConstantPool constPool = new ConstantPool(); + * constPool.constantPoolOop = method.getDeclaringClass(); + * return sun.reflect.AnnotationParser.parseParameterAnnotations( + * parameterAnnotations, + * constPool, + * method.getDeclaringClass(), + * method.getParameterTypes().length); + */ + + static methodinfo* m_parseParameterAnnotations = NULL; + + /* get parameter count */ + + int32_t numParameters = method_get_parametercount(m); + + if (numParameters < 0) + return NULL; + + /* get ConstantPool */ + + java_handle_t* h = native_new_and_init(class_sun_reflect_ConstantPool); + + if (h == NULL) + return NULL; + + sun_reflect_ConstantPool cp(h); + cp.set_constantPoolOop(m->clazz); + + /* only resolve the parser method the first time */ + if (m_parseParameterAnnotations == NULL) { + utf* utf_parseParameterAnnotations = utf_new_char("parseParameterAnnotations"); + utf* utf_desc = utf_new_char("([BLsun/reflect/ConstantPool;Ljava/lang/Class;I)[[Ljava/lang/annotation/Annotation;"); + + if (utf_parseParameterAnnotations == NULL || utf_desc == NULL) + return NULL; + + /* get parser method */ + + m_parseParameterAnnotations = class_resolveclassmethod( + class_sun_reflect_annotation_AnnotationParser, + utf_parseParameterAnnotations, + utf_desc, + referer, + true); + + if (m_parseParameterAnnotations == NULL) + return NULL; + } + + return (java_handle_objectarray_t*) vm_call_method(m_parseParameterAnnotations, NULL, parameterAnnotations, cp.get_handle(), m->clazz, numParameters); +} +#endif + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/reflection.hpp b/src/native/vm/reflection.hpp new file mode 100644 index 000000000..4e4fbb4c7 --- /dev/null +++ b/src/native/vm/reflection.hpp @@ -0,0 +1,64 @@ +/* src/native/vm/reflection.hpp - helper functions for java/lang/reflect + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _REFLECTION_HPP +#define _REFLECTION_HPP + +#include "config.h" + +#include + +#include "native/native.h" + +#include "vm/field.hpp" +#include "vm/method.h" + + +class Reflection { +public: + static java_handle_t* invoke(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) && defined(ENABLE_ANNOTATIONS) + static java_handle_t* get_declaredannotations(java_handle_bytearray_t *annotations, classinfo* declaringClass, classinfo *referer); + static java_handle_objectarray_t* get_parameterannotations(java_handle_bytearray_t* parameterAnnotations, methodinfo* m, classinfo *referer); +#endif +}; + +#endif // _REFLECTION_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/native/vm/sun_misc_Unsafe.c b/src/native/vm/sun_misc_Unsafe.c deleted file mode 100644 index 737559da5..000000000 --- a/src/native/vm/sun_misc_Unsafe.c +++ /dev/null @@ -1,1381 +0,0 @@ -/* src/native/vm/sun_misc_Unsafe.c - sun/misc/Unsafe - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "machine-instr.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" /* before c.l.C */ -#include "native/include/java_lang_String.h" /* required by j.l.CL */ - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -#endif - -#include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */ -#include "native/include/java_lang_Class.h" -#include "native/include/java_lang_reflect_Field.h" -#include "native/include/java_lang_Thread.h" /* required by s.m.U */ -#include "native/include/java_lang_Throwable.h" - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/java_lang_reflect_VMField.h" -#endif - -#include "native/include/java_security_ProtectionDomain.h" /* required by smU */ - -#include "native/include/sun_misc_Unsafe.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/initialize.h" -#include "vm/stringlocal.h" - -#include "vmcore/system.h" -#include "vmcore/utf8.h" - - -/* native methods implemented by this file ************************************/ - -static JNINativeMethod methods[] = { - { "registerNatives", "()V", (void *) (intptr_t) &Java_sun_misc_Unsafe_registerNatives }, - { "getInt", "(Ljava/lang/Object;J)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J }, - { "putInt", "(Ljava/lang/Object;JI)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI }, - { "getObject", "(Ljava/lang/Object;J)Ljava/lang/Object;", (void *) (intptr_t) &Java_sun_misc_Unsafe_getObject }, - { "putObject", "(Ljava/lang/Object;JLjava/lang/Object;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putObject }, - { "getBoolean", "(Ljava/lang/Object;J)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_getBoolean }, - { "putBoolean", "(Ljava/lang/Object;JZ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putBoolean }, - { "getByte", "(Ljava/lang/Object;J)B", (void *) (intptr_t) &Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J }, - { "putByte", "(Ljava/lang/Object;JB)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB }, - { "getShort", "(Ljava/lang/Object;J)S", (void *) (intptr_t) &Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J }, - { "putShort", "(Ljava/lang/Object;JS)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS }, - { "getChar", "(Ljava/lang/Object;J)C", (void *) (intptr_t) &Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J }, - { "putChar", "(Ljava/lang/Object;JC)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC }, - { "getLong", "(Ljava/lang/Object;J)J", (void *) (intptr_t) &Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J }, - { "putLong", "(Ljava/lang/Object;JJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ }, - { "getFloat", "(Ljava/lang/Object;J)F", (void *) (intptr_t) &Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J }, - { "putFloat", "(Ljava/lang/Object;JF)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF }, - { "getDouble", "(Ljava/lang/Object;J)D", (void *) (intptr_t) &Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J }, - { "putDouble", "(Ljava/lang/Object;JD)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD }, - { "getByte", "(J)B", (void *) (intptr_t) &Java_sun_misc_Unsafe_getByte__J }, - { "putByte", "(JB)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putByte__JB }, - { "getShort", "(J)S", (void *) (intptr_t) &Java_sun_misc_Unsafe_getShort__J }, - { "putShort", "(JS)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putShort__JS }, - { "getChar", "(J)C", (void *) (intptr_t) &Java_sun_misc_Unsafe_getChar__J }, - { "putChar", "(JC)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putChar__JC }, - { "getInt", "(J)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_getInt__J }, - { "putInt", "(JI)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putInt__JI }, - { "getLong", "(J)J", (void *) (intptr_t) &Java_sun_misc_Unsafe_getLong__J }, - { "putLong", "(JJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putLong__JJ }, - { "getFloat", "(J)F", (void *) (intptr_t) &Java_sun_misc_Unsafe_getFloat__J }, - { "objectFieldOffset", "(Ljava/lang/reflect/Field;)J", (void *) (intptr_t) &Java_sun_misc_Unsafe_objectFieldOffset }, - { "allocateMemory", "(J)J", (void *) (intptr_t) &Java_sun_misc_Unsafe_allocateMemory }, -#if 0 - /* OpenJDK 7 */ - { "setMemory", "(Ljava/lang/Object;JJB)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_setMemory }, - { "copyMemory", "(Ljava/lang/Object;JLjava/lang/Object;JJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_copyMemory }, -#else - { "setMemory", "(JJB)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_setMemory }, - { "copyMemory", "(JJJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_copyMemory }, -#endif - { "freeMemory", "(J)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_freeMemory }, - { "staticFieldOffset", "(Ljava/lang/reflect/Field;)J", (void *) (intptr_t) &Java_sun_misc_Unsafe_staticFieldOffset }, - { "staticFieldBase", "(Ljava/lang/reflect/Field;)Ljava/lang/Object;", (void *) (intptr_t) &Java_sun_misc_Unsafe_staticFieldBase }, - { "ensureClassInitialized", "(Ljava/lang/Class;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_ensureClassInitialized }, - { "arrayBaseOffset", "(Ljava/lang/Class;)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset }, - { "arrayIndexScale", "(Ljava/lang/Class;)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_arrayIndexScale }, - { "addressSize", "()I", (void *) (intptr_t) &Java_sun_misc_Unsafe_addressSize }, - { "pageSize", "()I", (void *) (intptr_t) &Java_sun_misc_Unsafe_pageSize }, - { "defineClass", "(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", (void *) (intptr_t) &Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2 }, - { "allocateInstance", "(Ljava/lang/Class;)Ljava/lang/Object;", (void *) (intptr_t) &Java_sun_misc_Unsafe_allocateInstance }, - { "throwException", "(Ljava/lang/Throwable;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_throwException }, - { "compareAndSwapObject", "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject }, - { "compareAndSwapInt", "(Ljava/lang/Object;JII)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt }, - { "compareAndSwapLong", "(Ljava/lang/Object;JJJ)Z", (void *) (intptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong }, - { "getObjectVolatile", "(Ljava/lang/Object;J)Ljava/lang/Object;", (void *) (intptr_t) &Java_sun_misc_Unsafe_getObjectVolatile }, - { "putObjectVolatile", "(Ljava/lang/Object;JLjava/lang/Object;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putObjectVolatile }, - { "getIntVolatile", "(Ljava/lang/Object;J)I", (void *) (intptr_t) &Java_sun_misc_Unsafe_getIntVolatile }, - { "putIntVolatile", "(Ljava/lang/Object;JI)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putIntVolatile }, - { "getLongVolatile", "(Ljava/lang/Object;J)J", (void *) (intptr_t) &Java_sun_misc_Unsafe_getLongVolatile }, - { "putLongVolatile", "(Ljava/lang/Object;JJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putLongVolatile }, - { "putOrderedObject", "(Ljava/lang/Object;JLjava/lang/Object;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedObject }, - { "putOrderedInt", "(Ljava/lang/Object;JI)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedInt }, - { "putOrderedLong", "(Ljava/lang/Object;JJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_putOrderedLong }, - { "unpark", "(Ljava/lang/Object;)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_unpark }, - { "park", "(ZJ)V", (void *) (intptr_t) &Java_sun_misc_Unsafe_park }, -}; - - -/* _Jv_sun_misc_Unsafe_init **************************************************** - - Register native functions. - -*******************************************************************************/ - -void _Jv_sun_misc_Unsafe_init(void) -{ - utf *u; - - u = utf_new_char("sun/misc/Unsafe"); - - native_method_register(u, methods, NATIVE_METHODS_COUNT); -} - - -/* - * Class: sun/misc/Unsafe - * Method: registerNatives - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_registerNatives(JNIEnv *env, jclass clazz) -{ - /* The native methods of this function are already registered in - _Jv_sun_misc_Unsafe_init() which is called during VM - startup. */ -} - - -/* - * Class: sun/misc/Unsafe - * Method: getInt - * Signature: (Ljava/lang/Object;J)I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - int32_t *p; - int32_t value; - - p = (int32_t *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putInt - * Signature: (Ljava/lang/Object;JI)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - int32_t *p; - - p = (int32_t *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getObject - * Signature: (Ljava/lang/Object;J)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - void **p; - void *value; - - p = (void **) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putObject - * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *x) -{ - void **p; - - p = (void **) (((uint8_t *) o) + offset); - - *p = (void *) x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getBoolean - * Signature: (Ljava/lang/Object;J)Z - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - int32_t *p; - int32_t value; - - p = (int32_t *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putBoolean - * Signature: (Ljava/lang/Object;JZ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - int32_t *p; - - p = (int32_t *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getByte - * Signature: (Ljava/lang/Object;J)B - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - int32_t *p; - int32_t value; - - p = (int32_t *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putByte - * Signature: (Ljava/lang/Object;JB)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - int32_t *p; - - p = (int32_t *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getShort - * Signature: (Ljava/lang/Object;J)S - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - int32_t *p; - int32_t value; - - p = (int32_t *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putShort - * Signature: (Ljava/lang/Object;JS)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - int32_t *p; - - p = (int32_t *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getChar - * Signature: (Ljava/lang/Object;J)C - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - int32_t *p; - int32_t value; - - p = (int32_t *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putChar - * Signature: (Ljava/lang/Object;JC)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - int32_t *p; - - p = (int32_t *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getLong - * Signature: (Ljava/lang/Object;J)J - */ -JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - int64_t *p; - int64_t value; - - p = (int64_t *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putLong - * Signature: (Ljava/lang/Object;JJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t x) -{ - int64_t *p; - - p = (int64_t *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getFloat - * Signature: (Ljava/lang/Object;J)F - */ -JNIEXPORT float JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - float *p; - float value; - - p = (float *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putFloat - * Signature: (Ljava/lang/Object;JF)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, float x) -{ - float *p; - - p = (float *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getDouble - * Signature: (Ljava/lang/Object;J)D - */ -JNIEXPORT double JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - double *p; - double value; - - p = (double *) (((uint8_t *) o) + offset); - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putDouble - * Signature: (Ljava/lang/Object;JD)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, double x) -{ - double *p; - - p = (double *) (((uint8_t *) o) + offset); - - *p = x; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getByte - * Signature: (J)B - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - int8_t *p; - int8_t value; - - p = (int8_t *) (intptr_t) address; - - value = *p; - - return (int32_t) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putByte - * Signature: (JB)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int32_t value) -{ - int8_t *p; - - p = (int8_t *) (intptr_t) address; - - *p = (int8_t) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getShort - * Signature: (J)S - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - int16_t *p; - int16_t value; - - p = (int16_t *) (intptr_t) address; - - value = *p; - - return (int32_t) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putShort - * Signature: (JS)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int32_t value) -{ - int16_t *p; - - p = (int16_t *) (intptr_t) address; - - *p = (int16_t) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getChar - * Signature: (J)C - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - uint16_t *p; - uint16_t value; - - p = (uint16_t *) (intptr_t) address; - - value = *p; - - return (int32_t) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putChar - * Signature: (JC)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int32_t value) -{ - uint16_t *p; - - p = (uint16_t *) (intptr_t) address; - - *p = (uint16_t) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getInt - * Signature: (J)I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - int32_t *p; - int32_t value; - - p = (int32_t *) (intptr_t) address; - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putInt - * Signature: (JI)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, struct sun_misc_Unsafe* this, int64_t address, int32_t value) -{ - int32_t *p; - - p = (int32_t *) (intptr_t) address; - - *p = value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getLong - * Signature: (J)J - */ -JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - int64_t *p; - int64_t value; - - p = (int64_t *) (intptr_t) address; - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putLong - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int64_t value) -{ - int64_t *p; - - p = (int64_t *) (intptr_t) address; - - *p = value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getFloat - * Signature: (J)F - */ -JNIEXPORT float JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - float *p; - float value; - - p = (float *) (intptr_t) address; - - value = *p; - - return value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: objectFieldOffset - * Signature: (Ljava/lang/reflect/Field;)J - */ -JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *field) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMField *rvmf; -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - LLNI_field_get_ref(field, f, rvmf); - LLNI_field_get_cls(rvmf, clazz, c); - LLNI_field_get_val(rvmf, slot , slot); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - LLNI_field_get_cls(field, clazz, c); - LLNI_field_get_val(field, slot , slot); - -#else -# error unknown configuration -#endif - - f = &(c->fields[slot]); - - return (int64_t) f->offset; -} - - -/* - * Class: sun/misc/Unsafe - * Method: allocateMemory - * Signature: (J)J - */ -JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t bytes) -{ - size_t length; - void *p; - - length = (size_t) bytes; - - if ((length != (uint64_t) bytes) || (bytes < 0)) { - exceptions_throw_illegalargumentexception(); - return 0; - } - - p = MNEW(uint8_t, length); - - return (int64_t) (intptr_t) p; -} - - -#if 0 -/* OpenJDK 7 */ - -/* - * Class: sun/misc/Unsafe - * Method: setMemory - * Signature: (Ljava/lang/Object;JJB)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t bytes, int32_t value) -{ - size_t length; - void *p; - - length = (size_t) bytes; - - if ((length != (uint64_t) bytes) || (bytes < 0)) { - exceptions_throw_illegalargumentexception(); - return; - } - - /* XXX Missing LLNI: we need to unwrap this object. */ - - p = (void *) (((uint8_t *) o) + offset); - - /* XXX Not sure this is correct. */ - - system_memset(p, value, length); -} - - -/* - * Class: sun/misc/Unsafe - * Method: copyMemory - * Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *srcBase, int64_t srcOffset, java_lang_Object *destBase, int64_t destOffset, int64_t bytes) -{ - size_t length; - void *src; - void *dest; - - if (bytes == 0) - return; - - length = (size_t) bytes; - - if ((length != (uint64_t) bytes) || (bytes < 0)) { - exceptions_throw_illegalargumentexception(); - return; - } - - /* XXX Missing LLNI: We need to unwrap these objects. */ - - src = (void *) (((uint8_t *) srcBase) + srcOffset); - dest = (void *) (((uint8_t *) destBase) + destOffset); - - system_memcpy(dest, src, length); -} -#else -/* - * Class: sun/misc/Unsafe - * Method: setMemory - * Signature: (JJB)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t address, int64_t bytes, int32_t value) -{ - size_t length; - void *p; - - length = (size_t) bytes; - - if ((length != (uint64_t) bytes) || (bytes < 0)) { - exceptions_throw_illegalargumentexception(); - return; - } - - p = (void *) (intptr_t) address; - - /* XXX Not sure this is correct. */ - - system_memset(p, value, length); -} - - -/* - * Class: sun/misc/Unsafe - * Method: copyMemory - * Signature: (JJJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t srcAddress, int64_t destAddress, int64_t bytes) -{ - size_t length; - void *src; - void *dest; - - if (bytes == 0) - return; - - length = (size_t) bytes; - - if ((length != (uint64_t) bytes) || (bytes < 0)) { - exceptions_throw_illegalargumentexception(); - return; - } - - src = (void *) (intptr_t) srcAddress; - dest = (void *) (intptr_t) destAddress; - - system_memcpy(dest, src, length); -} -#endif - - -/* - * Class: sun/misc/Unsafe - * Method: freeMemory - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, sun_misc_Unsafe *this, int64_t address) -{ - void *p; - - p = (void *) (intptr_t) address; - - if (p == NULL) - return; - - /* we pass length 1 to trick the free function */ - - MFREE(p, uint8_t, 1); -} - - -/* - * Class: sun/misc/Unsafe - * Method: staticFieldOffset - * Signature: (Ljava/lang/reflect/Field;)J - */ -JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *f) -{ - /* The offset of static fields is 0. */ - - return 0; -} - - -/* - * Class: sun/misc/Unsafe - * Method: staticFieldBase - * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, sun_misc_Unsafe *this, java_lang_reflect_Field *rf) -{ - classinfo *c; - fieldinfo *f; - int32_t slot; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_reflect_VMField *rvmf; -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - LLNI_field_get_ref(rf, f, rvmf); - LLNI_field_get_cls(rvmf, clazz, c); - LLNI_field_get_val(rvmf, slot , slot); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - LLNI_field_get_cls(rf, clazz, c); - LLNI_field_get_val(rf, slot , slot); - -#else -# error unknown configuration -#endif - - f = &(c->fields[slot]); - - return (java_lang_Object *) (f->value); -} - - -/* - * Class: sun/misc/Unsafe - * Method: ensureClassInitialized - * Signature: (Ljava/lang/Class;)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *class) -{ - classinfo *c; - - c = LLNI_classinfo_unwrap(class); - - if (!(c->state & CLASS_INITIALIZED)) - initialize_class(c); -} - - -/* - * Class: sun/misc/Unsafe - * Method: arrayBaseOffset - * Signature: (Ljava/lang/Class;)I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *arrayClass) -{ - classinfo *c; - arraydescriptor *ad; - - c = LLNI_classinfo_unwrap(arrayClass); - ad = c->vftbl->arraydesc; - - if (ad == NULL) { - /* XXX does that exception exist? */ - exceptions_throw_internalerror("java/lang/InvalidClassException"); - return 0; - } - - return ad->dataoffset; -} - - -/* - * Class: sun/misc/Unsafe - * Method: arrayIndexScale - * Signature: (Ljava/lang/Class;)I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *arrayClass) -{ - classinfo *c; - arraydescriptor *ad; - - c = LLNI_classinfo_unwrap(arrayClass); - ad = c->vftbl->arraydesc; - - if (ad == NULL) { - /* XXX does that exception exist? */ - exceptions_throw_internalerror("java/lang/InvalidClassException"); - return 0; - } - - return ad->componentsize; -} - - -/* - * Class: sun/misc/Unsafe - * Method: addressSize - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, sun_misc_Unsafe *this) -{ - return SIZEOF_VOID_P; -} - - -/* - * Class: sun/misc/Unsafe - * Method: pageSize - * Signature: ()I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, sun_misc_Unsafe *this) -{ - int sz; - - sz = getpagesize(); - - return sz; -} - - -/* - * Class: sun/misc/Unsafe - * Method: defineClass - * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class; - */ -JNIEXPORT java_lang_Class* JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, sun_misc_Unsafe *this, java_lang_String *name, java_handle_bytearray_t *b, int32_t off, int32_t len, java_lang_ClassLoader *loader, java_security_ProtectionDomain *protectionDomain) -{ - classloader_t *cl; - utf *utfname; - classinfo *c; - java_lang_Class *o; - - cl = loader_hashtable_classloader_add((java_handle_t *) loader); - - /* check if data was passed */ - - if (b == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - /* check the indexes passed */ - - if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) { - exceptions_throw_arrayindexoutofboundsexception(); - return NULL; - } - - if (name != NULL) { - /* convert '.' to '/' in java string */ - - utfname = javastring_toutf((java_handle_t *) name, true); - } - else { - utfname = NULL; - } - - /* define the class */ - - c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct(b, off)), - (java_handle_t *) protectionDomain); - - if (c == NULL) - return NULL; - - /* for convenience */ - - o = LLNI_classinfo_wrap(c); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - /* set ProtectionDomain */ - - LLNI_field_set_ref(o, pd, protectionDomain); -#endif - - return o; -} - - -/* - * Class: sun/misc/Unsafe - * Method: allocateInstance - * Signature: (Ljava/lang/Class;)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Class *cls) -{ - classinfo *c; - java_handle_t *o; - - c = LLNI_classinfo_unwrap(cls); - - o = builtin_new(c); - - return (java_lang_Object *) o; -} - - -/* - * Class: sun/misc/Unsafe - * Method: throwException - * Signature: (Ljava/lang/Throwable;)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Throwable *ee) -{ - java_handle_t *o; - - o = (java_handle_t *) ee; - - exceptions_set_exception(o); -} - - -/* - * Class: sun/misc/Unsafe - * Method: compareAndSwapObject - * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *expected, java_lang_Object *x) -{ -#if 1 - void **p; - void *value; - - p = (void **) (((uint8_t *) o) + offset); - - /* XXX this should be atomic */ - - value = *p; - - if (value == expected) { - *p = x; - - return true; - } - - return false; -#else - volatile void **p; - void *result; - - /* XXX Use LLNI */ - - p = (volatile void **) (((uint8_t *) o) + offset); - - result = atomic_compare_and_swap_address(p, expected, x); - - if (result == expected) - return true; - - return false; -#endif -} - - -/* - * Class: sun/misc/Unsafe - * Method: compareAndSwapInt - * Signature: (Ljava/lang/Object;JII)Z - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, sun_misc_Unsafe* this, java_lang_Object* o, int64_t offset, int32_t expected, int32_t x) -{ -#if 1 - int32_t *p; - int32_t value; - - p = (int32_t *) (((uint8_t *) o) + offset); - - /* XXX this should be atomic */ - - value = *p; - - if (value == expected) { - *p = x; - - return true; - } - - return false; -#else - int32_t *p; - int32_t result; - - /* XXX Use LLNI */ - - p = (int32_t *) (((uint8_t *) o) + offset); - - result = atomic_compare_and_swap_int(p, expected, x); - - if (result == expected) - return true; - - return false; -#endif -} - - -/* - * Class: sun/misc/Unsafe - * Method: compareAndSwapLong - * Signature: (Ljava/lang/Object;JJJ)Z - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t expected, int64_t x) -{ - int64_t *p; - int64_t value; - - p = (int64_t *) (((uint8_t *) o) + offset); - - /* XXX this should be atomic */ - - value = *p; - - if (value == expected) { - *p = x; - - return true; - } - - return false; -} - - -/* - * Class: sun/misc/Unsafe - * Method: getObjectVolatile - * Signature: (Ljava/lang/Object;J)Ljava/lang/Object; - */ -JNIEXPORT java_lang_Object* JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - volatile void **p; - volatile void *value; - - p = (volatile void **) (((uint8_t *) o) + offset); - - value = *p; - - return (java_lang_Object *) value; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putObjectVolatile - * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *x) -{ - volatile void **p; - - p = (volatile void **) (((uint8_t *) o) + offset); - - *p = x; -} - - -#define UNSAFE_GET_VOLATILE(type) \ - java_handle_t *_h; \ - java_object_t *_o; \ - volatile type *_p; \ - volatile type _x; \ - \ - _h = (java_handle_t *) o; \ - \ - LLNI_CRITICAL_START; \ - \ - _o = LLNI_UNWRAP(_h); \ - _p = (volatile type *) (((uint8_t *) _o) + offset); \ - \ - _x = *_p; \ - \ - LLNI_CRITICAL_END; \ - \ - return _x; - - -#define UNSAFE_PUT_VOLATILE(type) \ - java_handle_t *_h; \ - java_object_t *_o; \ - volatile type *_p; \ - \ - _h = (java_handle_t *) o; \ - \ - LLNI_CRITICAL_START; \ - \ - _o = LLNI_UNWRAP(_h); \ - _p = (volatile type *) (((uint8_t *) _o) + offset); \ - \ - *_p = x; \ - \ - MEMORY_BARRIER(); \ - \ - LLNI_CRITICAL_END; - - -/* - * Class: sun/misc/Unsafe - * Method: getIntVolatile - * Signature: (Ljava/lang/Object;J)I - */ -JNIEXPORT int32_t JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - UNSAFE_GET_VOLATILE(int32_t); -} - - -/* - * Class: sun/misc/Unsafe - * Method: putIntVolatile - * Signature: (Ljava/lang/Object;JI)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - UNSAFE_PUT_VOLATILE(int32_t); -} - - -/* - * Class: sun/misc/Unsafe - * Method: getLongVolatile - * Signature: (Ljava/lang/Object;J)J - */ -JNIEXPORT int64_t JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset) -{ - UNSAFE_GET_VOLATILE(int64_t); -} - - -/* - * Class: sun/misc/Unsafe - * Method: putLongVolatile - * Signature: (Ljava/lang/Object;JJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t x) -{ - UNSAFE_PUT_VOLATILE(int64_t); -} - - -/* - * Class: sun/misc/Unsafe - * Method: putOrderedObject - * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, java_lang_Object *x) -{ - java_handle_t *_h; - java_handle_t *_hx; - java_object_t *_o; - java_object_t *_x; - volatile void **_p; - - _h = (java_handle_t *) o; - _hx = (java_handle_t *) x; - - LLNI_CRITICAL_START; - - _o = LLNI_UNWRAP(_h); - _x = LLNI_UNWRAP(_hx); - _p = (volatile void **) (((uint8_t *) _o) + offset); - - *_p = _x; - - MEMORY_BARRIER(); - - LLNI_CRITICAL_END; -} - - -/* - * Class: sun/misc/Unsafe - * Method: putOrderedInt - * Signature: (Ljava/lang/Object;JI)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int32_t x) -{ - UNSAFE_PUT_VOLATILE(int32_t); -} - - -/* - * Class: sun/misc/Unsafe - * Method: putOrderedLong - * Signature: (Ljava/lang/Object;JJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *o, int64_t offset, int64_t x) -{ - UNSAFE_PUT_VOLATILE(int64_t); -} - - -/* - * Class: sun/misc/Unsafe - * Method: unpark - * Signature: (Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, sun_misc_Unsafe *this, java_lang_Object *thread) -{ - /* XXX IMPLEMENT ME */ -} - - -/* - * Class: sun/misc/Unsafe - * Method: park - * Signature: (ZJ)V - */ -JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, sun_misc_Unsafe *this, int32_t isAbsolute, int64_t time) -{ - /* XXX IMPLEMENT ME */ -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/native/vm/sun_misc_Unsafe.cpp b/src/native/vm/sun_misc_Unsafe.cpp new file mode 100644 index 000000000..ba4ca65c8 --- /dev/null +++ b/src/native/vm/sun_misc_Unsafe.cpp @@ -0,0 +1,1335 @@ +/* src/native/vm/sun_misc_Unsafe.cpp - sun/misc/Unsafe + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "threads/atomic.hpp" + +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/native.h" + +#if defined(ENABLE_JNI_HEADERS) +# include "native/include/sun_misc_Unsafe.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" +#include "vm/os.hpp" +#include "vm/string.hpp" +#include "vm/utf8.h" + + +// Native functions are exported as C functions. +extern "C" { + +/* + * Class: sun/misc/Unsafe + * Method: registerNatives + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_registerNatives(JNIEnv *env, jclass clazz) +{ + /* The native methods of this function are already registered in + _Jv_sun_misc_Unsafe_init() which is called during VM + startup. */ +} + + +/* + * Class: sun/misc/Unsafe + * Method: getInt + * Signature: (Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + int32_t *p; + int32_t value; + + p = (int32_t *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putInt + * Signature: (Ljava/lang/Object;JI)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x) +{ + int32_t *p; + + p = (int32_t *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getObject + * Signature: (Ljava/lang/Object;J)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObject(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + void **p; + void *value; + + p = (void **) (((uint8_t *) o) + offset); + + value = *p; + + return (jobject) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putObject + * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x) +{ + void **p; + + p = (void **) (((uint8_t *) o) + offset); + + *p = (void *) x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getBoolean + * Signature: (Ljava/lang/Object;J)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_getBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + int32_t *p; + int32_t value; + + p = (int32_t *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putBoolean + * Signature: (Ljava/lang/Object;JZ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putBoolean(JNIEnv *env, jobject _this, jobject o, jlong offset, jboolean x) +{ + int32_t *p; + + p = (int32_t *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getByte + * Signature: (Ljava/lang/Object;J)B + */ +JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + int32_t *p; + int32_t value; + + p = (int32_t *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putByte + * Signature: (Ljava/lang/Object;JB)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB(JNIEnv *env, jobject _this, jobject o, jlong offset, jbyte x) +{ + int32_t *p; + + p = (int32_t *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getShort + * Signature: (Ljava/lang/Object;J)S + */ +JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + int32_t *p; + int32_t value; + + p = (int32_t *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putShort + * Signature: (Ljava/lang/Object;JS)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS(JNIEnv *env, jobject _this, jobject o, jlong offset, jshort x) +{ + int32_t *p; + + p = (int32_t *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getChar + * Signature: (Ljava/lang/Object;J)C + */ +JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + int32_t *p; + int32_t value; + + p = (int32_t *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putChar + * Signature: (Ljava/lang/Object;JC)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC(JNIEnv *env, jobject _this, jobject o, jlong offset, jchar x) +{ + int32_t *p; + + p = (int32_t *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getLong + * Signature: (Ljava/lang/Object;J)J + */ +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + int64_t *p; + int64_t value; + + p = (int64_t *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putLong + * Signature: (Ljava/lang/Object;JJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x) +{ + int64_t *p; + + p = (int64_t *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getFloat + * Signature: (Ljava/lang/Object;J)F + */ +JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + float *p; + float value; + + p = (float *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putFloat + * Signature: (Ljava/lang/Object;JF)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF(JNIEnv *env, jobject _this, jobject o, jlong offset, jfloat x) +{ + float *p; + + p = (float *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getDouble + * Signature: (Ljava/lang/Object;J)D + */ +JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + double *p; + double value; + + p = (double *) (((uint8_t *) o) + offset); + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putDouble + * Signature: (Ljava/lang/Object;JD)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD(JNIEnv *env, jobject _this, jobject o, jlong offset, jdouble x) +{ + double *p; + + p = (double *) (((uint8_t *) o) + offset); + + *p = x; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getByte + * Signature: (J)B + */ +JNIEXPORT jbyte JNICALL Java_sun_misc_Unsafe_getByte__J(JNIEnv *env, jobject _this, jlong address) +{ + int8_t *p; + int8_t value; + + p = (int8_t *) (intptr_t) address; + + value = *p; + + return (int32_t) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putByte + * Signature: (JB)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putByte__JB(JNIEnv *env, jobject _this, jlong address, jbyte value) +{ + int8_t *p; + + p = (int8_t *) (intptr_t) address; + + *p = (int8_t) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getShort + * Signature: (J)S + */ +JNIEXPORT jshort JNICALL Java_sun_misc_Unsafe_getShort__J(JNIEnv *env, jobject _this, jlong address) +{ + int16_t *p; + int16_t value; + + p = (int16_t *) (intptr_t) address; + + value = *p; + + return (int32_t) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putShort + * Signature: (JS)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putShort__JS(JNIEnv *env, jobject _this, jlong address, jshort value) +{ + int16_t *p; + + p = (int16_t *) (intptr_t) address; + + *p = (int16_t) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getChar + * Signature: (J)C + */ +JNIEXPORT jchar JNICALL Java_sun_misc_Unsafe_getChar__J(JNIEnv *env, jobject _this, jlong address) +{ + uint16_t *p; + uint16_t value; + + p = (uint16_t *) (intptr_t) address; + + value = *p; + + return (int32_t) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putChar + * Signature: (JC)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putChar__JC(JNIEnv *env, jobject _this, jlong address, jchar value) +{ + uint16_t *p; + + p = (uint16_t *) (intptr_t) address; + + *p = (uint16_t) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getInt + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getInt__J(JNIEnv *env, jobject _this, jlong address) +{ + int32_t *p; + int32_t value; + + p = (int32_t *) (intptr_t) address; + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putInt + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putInt__JI(JNIEnv *env, jobject _this, jlong address, jint value) +{ + int32_t *p; + + p = (int32_t *) (intptr_t) address; + + *p = value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getLong + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLong__J(JNIEnv *env, jobject _this, jlong address) +{ + int64_t *p; + int64_t value; + + p = (int64_t *) (intptr_t) address; + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putLong + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLong__JJ(JNIEnv *env, jobject _this, jlong address, jlong value) +{ + int64_t *p; + + p = (int64_t *) (intptr_t) address; + + *p = value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getFloat + * Signature: (J)F + */ +JNIEXPORT jfloat JNICALL Java_sun_misc_Unsafe_getFloat__J(JNIEnv *env, jobject _this, jlong address) +{ + float *p; + float value; + + p = (float *) (intptr_t) address; + + value = *p; + + return value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putFloat + * Signature: (JF)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putFloat__JF(JNIEnv *env, jobject _this, jlong address, jfloat value) +{ + float* p; + + p = (float*) (intptr_t) address; + + *p = value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: objectFieldOffset + * Signature: (Ljava/lang/reflect/Field;)J + */ +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset(JNIEnv *env, jobject _this, jobject field) +{ +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + java_lang_reflect_Field rf(field); + java_lang_reflect_VMField rvmf(rf.get_f()); + fieldinfo* f = rvmf.get_field(); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + java_lang_reflect_Field rf(field); + fieldinfo* f = rf.get_field(); + +#else +# error unknown configuration +#endif + + return (jlong) f->offset; +} + + +/* + * Class: sun/misc/Unsafe + * Method: allocateMemory + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_allocateMemory(JNIEnv *env, jobject _this, jlong bytes) +{ + size_t length; + void *p; + + length = (size_t) bytes; + + if ((length != (uint64_t) bytes) || (bytes < 0)) { + exceptions_throw_illegalargumentexception(); + return 0; + } + + p = MNEW(uint8_t, length); + + return (int64_t) (intptr_t) p; +} + + +#if 0 +/* OpenJDK 7 */ + +/* + * Class: sun/misc/Unsafe + * Method: setMemory + * Signature: (Ljava/lang/Object;JJB)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong bytes, jbyte value) +{ + size_t length; + void *p; + + length = (size_t) bytes; + + if ((length != (uint64_t) bytes) || (bytes < 0)) { + exceptions_throw_illegalargumentexception(); + return; + } + + /* XXX Missing LLNI: we need to unwrap _this object. */ + + p = (void *) (((uint8_t *) o) + offset); + + /* XXX Not sure this is correct. */ + + os::memset(p, value, length); +} + + +/* + * Class: sun/misc/Unsafe + * Method: copyMemory + * Signature: (Ljava/lang/Object;JLjava/lang/Object;JJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jobject srcBase, jlong srcOffset, jobject destBase, jlong destOffset, jlong bytes) +{ + size_t length; + void *src; + void *dest; + + if (bytes == 0) + return; + + length = (size_t) bytes; + + if ((length != (uint64_t) bytes) || (bytes < 0)) { + exceptions_throw_illegalargumentexception(); + return; + } + + /* XXX Missing LLNI: We need to unwrap these objects. */ + + src = (void *) (((uint8_t *) srcBase) + srcOffset); + dest = (void *) (((uint8_t *) destBase) + destOffset); + + os::memcpy(dest, src, length); +} +#else +/* + * Class: sun/misc/Unsafe + * Method: setMemory + * Signature: (JJB)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_setMemory(JNIEnv *env, jobject _this, jlong address, jlong bytes, jbyte value) +{ + size_t length; + void *p; + + length = (size_t) bytes; + + if ((length != (uint64_t) bytes) || (bytes < 0)) { + exceptions_throw_illegalargumentexception(); + return; + } + + p = (void *) (intptr_t) address; + + /* XXX Not sure this is correct. */ + + os::memset(p, value, length); +} + + +/* + * Class: sun/misc/Unsafe + * Method: copyMemory + * Signature: (JJJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_copyMemory(JNIEnv *env, jobject _this, jlong srcAddress, jlong destAddress, jlong bytes) +{ + size_t length; + void *src; + void *dest; + + if (bytes == 0) + return; + + length = (size_t) bytes; + + if ((length != (uint64_t) bytes) || (bytes < 0)) { + exceptions_throw_illegalargumentexception(); + return; + } + + src = (void *) (intptr_t) srcAddress; + dest = (void *) (intptr_t) destAddress; + + os::memcpy(dest, src, length); +} +#endif + + +/* + * Class: sun/misc/Unsafe + * Method: freeMemory + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_freeMemory(JNIEnv *env, jobject _this, jlong address) +{ + void *p; + + p = (void *) (intptr_t) address; + + if (p == NULL) + return; + + /* we pass length 1 to trick the free function */ + + MFREE(p, uint8_t, 1); +} + + +/* + * Class: sun/misc/Unsafe + * Method: staticFieldOffset + * Signature: (Ljava/lang/reflect/Field;)J + */ +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_staticFieldOffset(JNIEnv *env, jobject _this, jobject f) +{ + /* The offset of static fields is 0. */ + + return 0; +} + + +/* + * Class: sun/misc/Unsafe + * Method: staticFieldBase + * Signature: (Ljava/lang/reflect/Field;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_staticFieldBase(JNIEnv *env, jobject _this, jobject field) +{ +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + java_lang_reflect_Field rf(field); + java_lang_reflect_VMField rvmf(rf.get_f()); + fieldinfo* f = rvmf.get_field(); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + java_lang_reflect_Field rf(field); + fieldinfo* f = rf.get_field(); + +#else +# error unknown configuration +#endif + + return (jobject) (f->value); +} + + +/* + * Class: sun/misc/Unsafe + * Method: ensureClassInitialized + * Signature: (Ljava/lang/Class;)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_ensureClassInitialized(JNIEnv *env, jobject _this, jclass clazz) +{ + classinfo *c; + + c = LLNI_classinfo_unwrap(clazz); + + if (!(c->state & CLASS_INITIALIZED)) + initialize_class(c); +} + + +/* + * Class: sun/misc/Unsafe + * Method: arrayBaseOffset + * Signature: (Ljava/lang/Class;)I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayBaseOffset(JNIEnv *env, jobject _this, jclass arrayClass) +{ + classinfo *c; + arraydescriptor *ad; + + c = LLNI_classinfo_unwrap(arrayClass); + ad = c->vftbl->arraydesc; + + if (ad == NULL) { + /* XXX does that exception exist? */ + exceptions_throw_internalerror("java/lang/InvalidClassException"); + return 0; + } + + return ad->dataoffset; +} + + +/* + * Class: sun/misc/Unsafe + * Method: arrayIndexScale + * Signature: (Ljava/lang/Class;)I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv *env, jobject _this, jclass arrayClass) +{ + classinfo *c; + arraydescriptor *ad; + + c = LLNI_classinfo_unwrap(arrayClass); + ad = c->vftbl->arraydesc; + + if (ad == NULL) { + /* XXX does that exception exist? */ + exceptions_throw_internalerror("java/lang/InvalidClassException"); + return 0; + } + + return ad->componentsize; +} + + +/* + * Class: sun/misc/Unsafe + * Method: addressSize + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv *env, jobject _this) +{ + return SIZEOF_VOID_P; +} + + +/* + * Class: sun/misc/Unsafe + * Method: pageSize + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_pageSize(JNIEnv *env, jobject _this) +{ + int sz; + + sz = getpagesize(); + + return sz; +} + + +/* + * Class: sun/misc/Unsafe + * Method: defineClass + * Signature: (Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class; + */ +JNIEXPORT jclass JNICALL Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2(JNIEnv *env, jobject _this, jstring name, jbyteArray b, jint off, jint len, jobject loader, jobject protectionDomain) +{ + classloader_t *cl; + utf *utfname; + classinfo *c; + + cl = loader_hashtable_classloader_add((java_handle_t *) loader); + + /* check if data was passed */ + + if (b == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + /* check the indexes passed */ + + if ((off < 0) || (len < 0) || ((off + len) > LLNI_array_size(b))) { + exceptions_throw_arrayindexoutofboundsexception(); + return NULL; + } + + if (name != NULL) { + /* convert '.' to '/' in java string */ + + utfname = javastring_toutf((java_handle_t *) name, true); + } + else { + utfname = NULL; + } + + /* define the class */ + + c = class_define(utfname, cl, len, (uint8_t *) &(LLNI_array_direct((java_handle_bytearray_t*) b, off)), + (java_handle_t *) protectionDomain); + + if (c == NULL) + return NULL; + + java_handle_t* h = LLNI_classinfo_wrap(c); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + // Set ProtectionDomain. + java_lang_Class jlc(h); + jlc.set_pd(protectionDomain); +#endif + + return (jclass) h; +} + + +/* + * Class: sun/misc/Unsafe + * Method: allocateInstance + * Signature: (Ljava/lang/Class;)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_allocateInstance(JNIEnv *env, jobject _this, jclass cls) +{ + classinfo *c; + java_handle_t *o; + + c = LLNI_classinfo_unwrap(cls); + + o = builtin_new(c); + + return (jobject ) o; +} + + +/* + * Class: sun/misc/Unsafe + * Method: throwException + * Signature: (Ljava/lang/Throwable;)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_throwException(JNIEnv *env, jobject _this, jobject ee) +{ + java_handle_t *o; + + o = (java_handle_t *) ee; + + exceptions_set_exception(o); +} + + +/* + * Class: sun/misc/Unsafe + * Method: compareAndSwapObject + * Signature: (Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject expected, jobject x) +{ + volatile void **p; + void *result; + + /* XXX Use LLNI */ + + p = (volatile void **) (((uint8_t *) o) + offset); + + result = Atomic::compare_and_swap(p, expected, x); + + if (result == expected) + return true; + + return false; +} + + +/* + * Class: sun/misc/Unsafe + * Method: compareAndSwapInt + * Signature: (Ljava/lang/Object;JII)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint expected, jint x) +{ + uint32_t *p; + uint32_t result; + + /* XXX Use LLNI */ + + p = (uint32_t *) (((uint8_t *) o) + offset); + + result = Atomic::compare_and_swap(p, expected, x); + + if (result == (uint32_t) expected) + return true; + + return false; +} + + +/* + * Class: sun/misc/Unsafe + * Method: compareAndSwapLong + * Signature: (Ljava/lang/Object;JJJ)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_misc_Unsafe_compareAndSwapLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong expected, jlong x) +{ + uint64_t *p; + uint64_t result; + + /* XXX Use LLNI */ + + p = (uint64_t *) (((uint8_t *) o) + offset); + + result = Atomic::compare_and_swap(p, expected, x); + + if (result == (uint64_t) expected) + return true; + + return false; +} + + +/* + * Class: sun/misc/Unsafe + * Method: getObjectVolatile + * Signature: (Ljava/lang/Object;J)Ljava/lang/Object; + */ +JNIEXPORT jobject JNICALL Java_sun_misc_Unsafe_getObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + volatile void **p; + volatile void *value; + + p = (volatile void **) (((uint8_t *) o) + offset); + + value = *p; + + return (jobject ) value; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putObjectVolatile + * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putObjectVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x) +{ + volatile void **p; + + p = (volatile void **) (((uint8_t *) o) + offset); + + *p = x; +} + + +#define UNSAFE_GET_VOLATILE(type) \ + java_handle_t *_h; \ + java_object_t *_o; \ + volatile type *_p; \ + volatile type _x; \ + \ + _h = (java_handle_t *) o; \ + \ + LLNI_CRITICAL_START; \ + \ + _o = LLNI_UNWRAP(_h); \ + _p = (volatile type *) (((uint8_t *) _o) + offset); \ + \ + _x = *_p; \ + \ + LLNI_CRITICAL_END; \ + \ + return _x; + + +#define UNSAFE_PUT_VOLATILE(type) \ + java_handle_t *_h; \ + java_object_t *_o; \ + volatile type *_p; \ + \ + _h = (java_handle_t *) o; \ + \ + LLNI_CRITICAL_START; \ + \ + _o = LLNI_UNWRAP(_h); \ + _p = (volatile type *) (((uint8_t *) _o) + offset); \ + \ + *_p = x; \ + \ + Atomic::memory_barrier(); \ + \ + LLNI_CRITICAL_END; + + +/* + * Class: sun/misc/Unsafe + * Method: getIntVolatile + * Signature: (Ljava/lang/Object;J)I + */ +JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_getIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + UNSAFE_GET_VOLATILE(int32_t); +} + + +/* + * Class: sun/misc/Unsafe + * Method: putIntVolatile + * Signature: (Ljava/lang/Object;JI)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putIntVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x) +{ + UNSAFE_PUT_VOLATILE(int32_t); +} + + +/* + * Class: sun/misc/Unsafe + * Method: getLongVolatile + * Signature: (Ljava/lang/Object;J)J + */ +JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_getLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset) +{ + UNSAFE_GET_VOLATILE(int64_t); +} + + +/* + * Class: sun/misc/Unsafe + * Method: putLongVolatile + * Signature: (Ljava/lang/Object;JJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putLongVolatile(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x) +{ + UNSAFE_PUT_VOLATILE(int64_t); +} + + +/* + * Class: sun/misc/Unsafe + * Method: getDoubleVolatile + * Signature: (Ljava/lang/Object;J)D + */ +JNIEXPORT jdouble JNICALL Java_sun_misc_Unsafe_getDoubleVolatile(JNIEnv *env, jobject __this, jobject o, jlong offset) +{ + UNSAFE_GET_VOLATILE(double); +} + + +/* + * Class: sun/misc/Unsafe + * Method: putOrderedObject + * Signature: (Ljava/lang/Object;JLjava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedObject(JNIEnv *env, jobject _this, jobject o, jlong offset, jobject x) +{ + java_handle_t *_h; + java_handle_t *_hx; + java_object_t *_o; + java_object_t *_x; + volatile void **_p; + + _h = (java_handle_t *) o; + _hx = (java_handle_t *) x; + + LLNI_CRITICAL_START; + + _o = LLNI_UNWRAP(_h); + _x = LLNI_UNWRAP(_hx); + _p = (volatile void **) (((uint8_t *) _o) + offset); + + *_p = _x; + + Atomic::memory_barrier(); + + LLNI_CRITICAL_END; +} + + +/* + * Class: sun/misc/Unsafe + * Method: putOrderedInt + * Signature: (Ljava/lang/Object;JI)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedInt(JNIEnv *env, jobject _this, jobject o, jlong offset, jint x) +{ + UNSAFE_PUT_VOLATILE(int32_t); +} + + +/* + * Class: sun/misc/Unsafe + * Method: putOrderedLong + * Signature: (Ljava/lang/Object;JJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_putOrderedLong(JNIEnv *env, jobject _this, jobject o, jlong offset, jlong x) +{ + UNSAFE_PUT_VOLATILE(int64_t); +} + + +/* + * Class: sun/misc/Unsafe + * Method: unpark + * Signature: (Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_unpark(JNIEnv *env, jobject _this, jobject thread) +{ + /* XXX IMPLEMENT ME */ +} + + +/* + * Class: sun/misc/Unsafe + * Method: park + * Signature: (ZJ)V + */ +JNIEXPORT void JNICALL Java_sun_misc_Unsafe_park(JNIEnv *env, jobject _this, jboolean isAbsolute, jlong time) +{ + /* XXX IMPLEMENT ME */ +} + +} // extern "C" + + +/* native methods implemented by this file ************************************/ + +static JNINativeMethod methods[] = { + { (char*) "registerNatives", (char*) "()V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_registerNatives }, + { (char*) "getInt", (char*) "(Ljava/lang/Object;J)I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__Ljava_lang_Object_2J }, + { (char*) "putInt", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__Ljava_lang_Object_2JI }, + { (char*) "getObject", (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObject }, + { (char*) "putObject", (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObject }, + { (char*) "getBoolean", (char*) "(Ljava/lang/Object;J)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getBoolean }, + { (char*) "putBoolean", (char*) "(Ljava/lang/Object;JZ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putBoolean }, + { (char*) "getByte", (char*) "(Ljava/lang/Object;J)B", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__Ljava_lang_Object_2J }, + { (char*) "putByte", (char*) "(Ljava/lang/Object;JB)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__Ljava_lang_Object_2JB }, + { (char*) "getShort", (char*) "(Ljava/lang/Object;J)S", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__Ljava_lang_Object_2J }, + { (char*) "putShort", (char*) "(Ljava/lang/Object;JS)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__Ljava_lang_Object_2JS }, + { (char*) "getChar", (char*) "(Ljava/lang/Object;J)C", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__Ljava_lang_Object_2J }, + { (char*) "putChar", (char*) "(Ljava/lang/Object;JC)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__Ljava_lang_Object_2JC }, + { (char*) "getLong", (char*) "(Ljava/lang/Object;J)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__Ljava_lang_Object_2J }, + { (char*) "putLong", (char*) "(Ljava/lang/Object;JJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__Ljava_lang_Object_2JJ }, + { (char*) "getFloat", (char*) "(Ljava/lang/Object;J)F", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__Ljava_lang_Object_2J }, + { (char*) "putFloat", (char*) "(Ljava/lang/Object;JF)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__Ljava_lang_Object_2JF }, + { (char*) "getDouble", (char*) "(Ljava/lang/Object;J)D", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDouble__Ljava_lang_Object_2J }, + { (char*) "putDouble", (char*) "(Ljava/lang/Object;JD)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putDouble__Ljava_lang_Object_2JD }, + { (char*) "getByte", (char*) "(J)B", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getByte__J }, + { (char*) "putByte", (char*) "(JB)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putByte__JB }, + { (char*) "getShort", (char*) "(J)S", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getShort__J }, + { (char*) "putShort", (char*) "(JS)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putShort__JS }, + { (char*) "getChar", (char*) "(J)C", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getChar__J }, + { (char*) "putChar", (char*) "(JC)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putChar__JC }, + { (char*) "getInt", (char*) "(J)I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getInt__J }, + { (char*) "putInt", (char*) "(JI)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putInt__JI }, + { (char*) "getLong", (char*) "(J)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLong__J }, + { (char*) "putLong", (char*) "(JJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLong__JJ }, + { (char*) "getFloat", (char*) "(J)F", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getFloat__J }, + { (char*) "putFloat", (char*) "(JF)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putFloat__JF }, + { (char*) "objectFieldOffset", (char*) "(Ljava/lang/reflect/Field;)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_objectFieldOffset }, + { (char*) "allocateMemory", (char*) "(J)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateMemory }, +#if 0 + // OpenJDK 7 + { (char*) "setMemory", (char*) "(Ljava/lang/Object;JJB)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory }, + { (char*) "copyMemory", (char*) "(Ljava/lang/Object;JLjava/lang/Object;JJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory }, +#else + { (char*) "setMemory", (char*) "(JJB)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_setMemory }, + { (char*) "copyMemory", (char*) "(JJJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_copyMemory }, +#endif + { (char*) "freeMemory", (char*) "(J)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_freeMemory }, + { (char*) "staticFieldOffset", (char*) "(Ljava/lang/reflect/Field;)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldOffset }, + { (char*) "staticFieldBase", (char*) "(Ljava/lang/reflect/Field;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_staticFieldBase }, + { (char*) "ensureClassInitialized", (char*) "(Ljava/lang/Class;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_ensureClassInitialized }, + { (char*) "arrayBaseOffset", (char*) "(Ljava/lang/Class;)I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayBaseOffset }, + { (char*) "arrayIndexScale", (char*) "(Ljava/lang/Class;)I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_arrayIndexScale }, + { (char*) "addressSize", (char*) "()I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_addressSize }, + { (char*) "pageSize", (char*) "()I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_pageSize }, + { (char*) "defineClass", (char*) "(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2 }, + { (char*) "allocateInstance", (char*) "(Ljava/lang/Class;)Ljava/lang/Object;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_allocateInstance }, + { (char*) "throwException", (char*) "(Ljava/lang/Throwable;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_throwException }, + { (char*) "compareAndSwapObject", (char*) "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapObject }, + { (char*) "compareAndSwapInt", (char*) "(Ljava/lang/Object;JII)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapInt }, + { (char*) "compareAndSwapLong", (char*) "(Ljava/lang/Object;JJJ)Z", (void*) (uintptr_t) &Java_sun_misc_Unsafe_compareAndSwapLong }, + { (char*) "getObjectVolatile", (char*) "(Ljava/lang/Object;J)Ljava/lang/Object;", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getObjectVolatile }, + { (char*) "putObjectVolatile", (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putObjectVolatile }, + { (char*) "getIntVolatile", (char*) "(Ljava/lang/Object;J)I", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getIntVolatile }, + { (char*) "putIntVolatile", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putIntVolatile }, + { (char*) "getLongVolatile", (char*) "(Ljava/lang/Object;J)J", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getLongVolatile }, + { (char*) "putLongVolatile", (char*) "(Ljava/lang/Object;JJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putLongVolatile }, + { (char*) "getDoubleVolatile", (char*) "(Ljava/lang/Object;J)D", (void*) (uintptr_t) &Java_sun_misc_Unsafe_getDoubleVolatile }, + { (char*) "putOrderedObject", (char*) "(Ljava/lang/Object;JLjava/lang/Object;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedObject }, + { (char*) "putOrderedInt", (char*) "(Ljava/lang/Object;JI)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedInt }, + { (char*) "putOrderedLong", (char*) "(Ljava/lang/Object;JJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_putOrderedLong }, + { (char*) "unpark", (char*) "(Ljava/lang/Object;)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_unpark }, + { (char*) "park", (char*) "(ZJ)V", (void*) (uintptr_t) &Java_sun_misc_Unsafe_park }, +}; + + +/* _Jv_sun_misc_Unsafe_init **************************************************** + + Register native functions. + +*******************************************************************************/ + +// FIXME +extern "C" { +void _Jv_sun_misc_Unsafe_init(void) +{ + utf *u; + + u = utf_new_char("sun/misc/Unsafe"); + + native_method_register(u, methods, NATIVE_METHODS_COUNT); +} +} + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/threads/Makefile.am b/src/threads/Makefile.am index b6cf86dd5..68cdfd9ec 100644 --- a/src/threads/Makefile.am +++ b/src/threads/Makefile.am @@ -49,14 +49,16 @@ noinst_LTLIBRARIES = \ if ENABLE_THREADS libthreads_la_SOURCES = \ - critical.c \ - critical.h \ + atomic.cpp \ + atomic.hpp \ + condition.hpp \ lock-common.h \ - mutex.h \ + removeme.cpp \ + mutex.hpp \ threadlist.c \ threadlist.h \ - thread.c \ - thread.h + thread.cpp \ + thread.hpp else libthreads_la_SOURCES = endif diff --git a/src/threads/atomic.cpp b/src/threads/atomic.cpp new file mode 100644 index 000000000..e5ca7c806 --- /dev/null +++ b/src/threads/atomic.cpp @@ -0,0 +1,159 @@ +/* src/threads/atomic.cpp - atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "threads/atomic.hpp" +#include "threads/mutex.hpp" + +// Gobal mutex for generic atomic instructions. +static Mutex lock; + + +/** + * A generic atomic compare and swap for 32-bit integer values. This + * function is using a mutex to provide atomicity. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +uint32_t Atomic::generic_compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t result; + + lock.lock(); + + // Do the compare-and-swap. + + result = *p; + + if (oldval == result) + *p = newval; + + lock.unlock(); + + return result; +} + + +/** + * A generic atomic compare and swap for 64-bit integer values. This + * function is using a mutex to provide atomicity. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +uint64_t Atomic::generic_compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + uint64_t result; + + lock.lock(); + + // Do the compare-and-swap. + + result = *p; + + if (oldval == result) + *p = newval; + + lock.unlock(); + + return result; +} + + +/** + * A generic atomic compare and swap for pointer values. This + * function is using a mutex to provide atomicity. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +void* Atomic::generic_compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + void* result; + + lock.lock(); + + // Do the compare-and-swap. + + result = (void*) *p; + + if (oldval == result) + *p = newval; + + lock.lock(); + + return result; +} + + +/** + * A generic memory barrier. This function is using a mutex to + * provide atomicity. + */ +void Atomic::generic_memory_barrier(void) +{ + lock.lock(); + lock.unlock(); +} + + +// Legacy C interface. + +extern "C" { +uint32_t Atomic_compare_and_swap_32(volatile uint32_t *p, uint32_t oldval, uint32_t newval) { return Atomic::compare_and_swap(p, oldval, newval); } +uint64_t Atomic_compare_and_swap_64(volatile uint64_t *p, uint64_t oldval, uint64_t newval) { return Atomic::compare_and_swap(p, oldval, newval); } +void* Atomic_compare_and_swap_ptr(volatile void** p, void* oldval, void* newval) { return Atomic::compare_and_swap(p, oldval, newval); } +void Atomic_memory_barrier(void) { Atomic::memory_barrier(); } +void Atomic_write_memory_barrier(void) { Atomic::write_memory_barrier(); } +void Atomic_instruction_barrier(void) { Atomic::instruction_barrier(); } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/atomic.hpp b/src/threads/atomic.hpp new file mode 100644 index 000000000..382a8724b --- /dev/null +++ b/src/threads/atomic.hpp @@ -0,0 +1,83 @@ +/* src/threads/atomic.hpp - atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _ATOMIC_HPP +#define _ATOMIC_HPP + +#include "config.h" + +#include + +#ifdef __cplusplus + +class Atomic { +public: + // Generic functions. + static uint32_t generic_compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval); + static uint64_t generic_compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval); + static void* generic_compare_and_swap(volatile void** p, void* oldval, void* newval); + static void generic_memory_barrier(void); + + // Machine dependent functions. + static uint32_t compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval); + static uint64_t compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval); + static void* compare_and_swap(volatile void** p, void* oldval, void* newval); + static void memory_barrier(void); + static void write_memory_barrier(void); + static void instruction_barrier(void); +}; + +// Include machine dependent implementation. +#include "md-atomic.hpp" + +#else + +// Legacy C interface. + +uint32_t Atomic_compare_and_swap_32(volatile uint32_t *p, uint32_t oldval, uint32_t newval); +uint64_t Atomic_compare_and_swap_64(volatile uint64_t *p, uint64_t oldval, uint64_t newval); +void* Atomic_compare_and_swap_ptr(volatile void** p, void* oldval, void* newval); +void Atomic_memory_barrier(void); +void Atomic_write_memory_barrier(void); +void Atomic_instruction_barrier(void); + +#endif + +#endif // _ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/condition.hpp b/src/threads/condition.hpp new file mode 100644 index 000000000..b2378357e --- /dev/null +++ b/src/threads/condition.hpp @@ -0,0 +1,52 @@ +/* src/threads/condition.hpp - condition variable + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _CONDITION_HPP +#define _CONDITION_HPP + +#include "config.h" + +#include "threads/mutex.hpp" + +#if defined(ENABLE_THREADS) +# include "threads/posix/condition-posix.hpp" +#endif + +#endif /* _CONDITION_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/critical.c b/src/threads/critical.c deleted file mode 100644 index 51c331747..000000000 --- a/src/threads/critical.c +++ /dev/null @@ -1,169 +0,0 @@ -/* src/threads/critical.c - restartable critical sections - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "threads/critical.h" - -#include "toolbox/avl.h" - - -/* the AVL tree containing the critical sections */ - -static avl_tree_t *criticaltree; - - -/* prototypes *****************************************************************/ - -static int critical_comparator(const void *treenode, const void *node); - - -/* critical_init *************************************************************** - - Init global data structures. - -*******************************************************************************/ - -void critical_init(void) -{ - criticaltree = avl_create(&critical_comparator); -} - - -/* critical_comparator ********************************************************* - - Comparison function for AVL tree of critical section. - - IN: - treenode....node in the tree - node........node to compare with tree-node - - RETURN VALUE: - -1, 0, +1 for (pa <, ==, > pb) - -*******************************************************************************/ - -static int critical_comparator(const void *treenode, const void *node) -{ - const critical_section_node_t *treecsn; - const critical_section_node_t *csn; - - treecsn = treenode; - csn = node; - -#ifdef __S390__ -# define ADDR_MASK(x) ((u1 *)((s4)(x) & 0x7FFFFFFF)) -#else -# define ADDR_MASK(x) (x) -#endif - - /* compare for avl_find if we have found an entry */ - - if ( - (ADDR_MASK(treecsn->start) <= ADDR_MASK(csn->start)) && - (ADDR_MASK(csn->start) < ADDR_MASK(treecsn->end)) - ) - return 0; - - /* these are for walking the tree */ - - if (ADDR_MASK(treecsn->start) < ADDR_MASK(csn->start)) - return -1; - else - return 1; - -#undef ADDR_MASK -} - - -/* critical_section_register *************************************************** - - Register a critical section. - - IN: - csn....node for the critical section - -*******************************************************************************/ - -void critical_section_register(critical_section_node_t *csn) -{ - (void) avl_insert(criticaltree, csn); -} - - -/* critical_find_restart_point ************************************************* - - Find a restart point for the given PC, in case it is in a critical - section. - - IN: - pc.........PC - - OUT: - PC of the restart point, or - NULL if the given mcodeptr is not in a critical section - -*******************************************************************************/ - -u1 *critical_find_restart_point(u1 *pc) -{ - critical_section_node_t csnpc; - const critical_section_node_t *csn; - - /* fill the temporary node for comparison */ - - csnpc.start = pc; - - /* see if there's an entry for that PC */ - - csn = avl_find(criticaltree, &csnpc); - - if (csn == NULL) - return NULL; - - return csn->restart; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/critical.h b/src/threads/critical.h deleted file mode 100644 index 7bb2917c3..000000000 --- a/src/threads/critical.h +++ /dev/null @@ -1,86 +0,0 @@ -/* src/threads/native/critical.h - restartable critical sections - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contact: cacao@cacaojvm.org - - Authors: Stefan Ring - Edwin Steiner - - Changes: Christian Thalinger - -*/ - - -#ifndef _CRITICAL_H -#define _CRITICAL_H - -#include "config.h" - -#include /* required on some older Darwin systems for ucontext.h */ -#include - - -/* forward typedefs ***********************************************************/ - -typedef struct critical_section_node_t critical_section_node_t; - - -/* critical_section_node_t ***************************************************** - - A node representing a restartable critical section. - -*******************************************************************************/ - -struct critical_section_node_t { - u1 *start; - u1 *end; - u1 *restart; -}; - - -/* functions ******************************************************************/ - -void critical_init(void); -void critical_section_register(critical_section_node_t *); -u1 *critical_find_restart_point(u1*); - -/* this is a machine dependent function (see src/vm/jit/$(ARCH_DIR)/md.c) */ -void md_critical_section_restart(ucontext_t *_uc); - -#endif /* _CRITICAL_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/lock-common.h b/src/threads/lock-common.h index 1bc3cdc2b..e0a8f674b 100644 --- a/src/threads/lock-common.h +++ b/src/threads/lock-common.h @@ -27,6 +27,11 @@ #define _LOCK_COMMON_H #include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/types.h" #include "vm/global.h" @@ -64,6 +69,10 @@ void lock_notify_all_object(java_handle_t *o); #endif /* ENABLE_THREADS */ +#ifdef __cplusplus +} +#endif + #endif /* _LOCK_COMMON_H */ diff --git a/src/threads/mutex.h b/src/threads/mutex.h deleted file mode 100644 index 7458b0d8e..000000000 --- a/src/threads/mutex.h +++ /dev/null @@ -1,51 +0,0 @@ -/* src/threads/mutex.h - machine independent mutual exclusion functions - - Copyright (C) 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _MUTEX_H -#define _MUTEX_H - -#include "config.h" - -#if defined(ENABLE_THREADS) -# include "threads/posix/mutex-posix.h" -#endif - - -#endif /* _MUTEX_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/mutex.hpp b/src/threads/mutex.hpp new file mode 100644 index 000000000..e8bbce33c --- /dev/null +++ b/src/threads/mutex.hpp @@ -0,0 +1,50 @@ +/* src/threads/mutex.hpp - machine independent mutual exclusion functions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MUTEX_HPP +#define _MUTEX_HPP + +#include "config.h" + +#if defined(ENABLE_THREADS) +# include "threads/posix/mutex-posix.hpp" +#endif + +#endif /* _MUTEX_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/none/thread-none.c b/src/threads/none/thread-none.c index 8c333adaf..de21e8aed 100644 --- a/src/threads/none/thread-none.c +++ b/src/threads/none/thread-none.c @@ -27,9 +27,9 @@ #include -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" /* global variables ***********************************************************/ diff --git a/src/threads/none/thread-none.h b/src/threads/none/thread-none.h index cefeeaceb..21b3bee53 100644 --- a/src/threads/none/thread-none.h +++ b/src/threads/none/thread-none.h @@ -32,9 +32,10 @@ #include "vm/types.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" +#include "vm/globals.hpp" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" /* define some stuff we need to no-ops ****************************************/ diff --git a/src/threads/posix/Makefile.am b/src/threads/posix/Makefile.am index 880d47f29..c4a9f7361 100644 --- a/src/threads/posix/Makefile.am +++ b/src/threads/posix/Makefile.am @@ -29,11 +29,12 @@ noinst_LTLIBRARIES = \ libthreadsposix.la libthreadsposix_la_SOURCES = \ + condition-posix.hpp \ lock.c \ lock.h \ - mutex-posix.h \ - thread-posix.c \ - thread-posix.h + mutex-posix.hpp \ + thread-posix.cpp \ + thread-posix.hpp ## Local variables: diff --git a/src/threads/posix/condition-posix.hpp b/src/threads/posix/condition-posix.hpp new file mode 100644 index 000000000..1307195cc --- /dev/null +++ b/src/threads/posix/condition-posix.hpp @@ -0,0 +1,178 @@ +/* src/threads/posix/condition-posix.hpp - POSIX condition variable + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _CONDITION_POSIX_HPP +#define _CONDITION_POSIX_HPP + +#include "config.h" + +#include +#include + +#include "vm/vm.hpp" + +#ifdef __cplusplus + +/** + * POSIX condition variable. + */ +class Condition { +private: + // POSIX condition structure. + pthread_cond_t _cond; + +public: + Condition(); + ~Condition(); + + void broadcast(); + void signal(); + void timedwait(Mutex* mutex, const struct timespec* abstime); + void wait(Mutex* mutex); +}; + + +/** + * Initialize a POSIX condition variable. + */ +inline Condition::Condition() +{ + int result; + + result = pthread_cond_init(&_cond, NULL); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Condition::Condition(): pthread_cond_init failed"); + } +} + + +/** + * Destroys a POSIX condition variable. + */ +inline Condition::~Condition() +{ + int result; + + result = pthread_cond_destroy(&_cond); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Condition::~Condition(): pthread_cond_destroy failed"); + } +} + + +/** + * Restarts all the threads that are waiting on the condition + * variable. + */ +inline void Condition::broadcast() +{ + int result; + + result = pthread_cond_broadcast(&_cond); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Condition::broadcast(): pthread_cond_broadcast failed"); + } +} + + +/** + * Restarts one of the threads that are waiting on this condition + * variable. + */ +inline void Condition::signal() +{ + int result; + + result = pthread_cond_signal(&_cond); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Condition::signal(): pthread_cond_signal failed"); + } +} + + +/** + * Waits on the condition variable, as wait() does, but it also bounds + * the duration of the wait. + */ +inline void Condition::timedwait(Mutex* mutex, const struct timespec* abstime) +{ + // This function can return return values which are valid. + (void) pthread_cond_timedwait(&_cond, &(mutex->_mutex), abstime); +} + + +/** + * Waits for the condition variable. + */ +inline void Condition::wait(Mutex* mutex) +{ + int result; + + result = pthread_cond_wait(&_cond, &(mutex->_mutex)); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Condition::wait(): pthread_cond_wait failed"); + } +} + +#else + +// This structure must have the same layout as the class above. +typedef struct Condition { + pthread_mutex_t _mutex; + pthread_cond_t _cond; +} Condition; + +Condition* Condition_new(); +void Condition_delete(Condition* cond); +void Condition_lock(Condition* cond); +void Condition_unlock(Condition* cond); +void Condition_broadcast(Condition* cond); +void Condition_signal(Condition* cond); +void Condition_timedwait(Condition* cond, Mutex *mutex, const struct timespec* abstime); +void Condition_wait(Condition* cond, Mutex* mutex); + +#endif + +#endif /* _CONDITION_POSIX_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/posix/generic-primitives.h b/src/threads/posix/generic-primitives.h deleted file mode 100644 index 2ab03a155..000000000 --- a/src/threads/posix/generic-primitives.h +++ /dev/null @@ -1,87 +0,0 @@ -/* src/threads/native/generic-primitives.h - machine independent atomic - operations - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - Anton Ertl - - Changes: - - -*/ - - -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -#include - -#include "threads/mutex.h" - - -extern mutex_t _cas_lock; -extern mutex_t _mb_lock; - - -static inline long compare_and_swap(volatile long *p, long oldval, long newval) -{ - long ret; - - mutex_lock(&_cas_lock); - - /* do the compare-and-swap */ - - ret = *p; - - if (oldval == ret) - *p = newval; - - mutex_unlock(&_cas_lock); - - return ret; -} - - -#define MEMORY_BARRIER() (mutex_lock(&_mb_lock), \ - mutex_unlock(&_mb_lock)) -#define STORE_ORDER_BARRIER() MEMORY_BARRIER() -#define MEMORY_BARRIER_AFTER_ATOMIC() /* nothing */ - -#endif /* _MACHINE_INSTR_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/threads/posix/lock.c b/src/threads/posix/lock.c index 4d69503ba..81c363336 100644 --- a/src/threads/posix/lock.c +++ b/src/threads/posix/lock.c @@ -39,24 +39,23 @@ #include "native/llni.h" #include "threads/lock-common.h" -#include "threads/mutex.h" +#include "threads/mutex.hpp" #include "threads/threadlist.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "threads/posix/lock.h" #include "toolbox/list.h" -#include "vm/global.h" -#include "vm/exceptions.h" +#include "vm/exceptions.hpp" #include "vm/finalizer.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/options.h" +#include "vm/global.h" +#include "vm/options.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" #if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" +# include "vm/statistics.h" #endif #if defined(ENABLE_VMLOG) @@ -72,7 +71,7 @@ #if defined(USE_FAKE_ATOMIC_INSTRUCTIONS) #include "threads/posix/generic-primitives.h" #else -#include "machine-instr.h" +#include "threads/atomic.hpp" #endif #if defined(ENABLE_JVMTI) @@ -107,9 +106,6 @@ #define LOCK_INITIAL_HASHTABLE_SIZE 1613 /* a prime in the middle between 1024 and 2048 */ -#define COMPARE_AND_SWAP_OLD_VALUE(address, oldvalue, newvalue) \ - ((ptrint) compare_and_swap((long *)(address), (long)(oldvalue), (long)(newvalue))) - /******************************************************************************/ /* MACROS FOR THIN/FAT LOCKS */ @@ -273,7 +269,7 @@ static lock_record_t *lock_record_new(void) /* initialize the mutex */ - mutex_init(&(lr->mutex)); + lr->mutex = Mutex_new(); DEBUGLOCKS(("[lock_record_new : lr=%p]", (void *) lr)); @@ -296,7 +292,7 @@ static void lock_record_free(lock_record_t *lr) /* Destroy the mutex. */ - mutex_destroy(&(lr->mutex)); + Mutex_delete(lr->mutex); #if defined(ENABLE_GC_CACAO) /* unregister the lock object reference with the GC */ @@ -331,7 +327,7 @@ static void lock_record_free(lock_record_t *lr) static void lock_hashtable_init(void) { - mutex_init(&(lock_hashtable.mutex)); + lock_hashtable.mutex = Mutex_new(); lock_hashtable.size = LOCK_INITIAL_HASHTABLE_SIZE; lock_hashtable.entries = 0; @@ -434,7 +430,7 @@ void lock_hashtable_cleanup(void) /* lock the hashtable */ - mutex_lock(&(lock_hashtable.mutex)); + Mutex_lock(lock_hashtable.mutex); /* search the hashtable for cleared references */ @@ -470,7 +466,7 @@ void lock_hashtable_cleanup(void) /* unlock the hashtable */ - mutex_unlock(&(lock_hashtable.mutex)); + Mutex_unlock(lock_hashtable.mutex); } #endif @@ -506,7 +502,7 @@ static lock_record_t *lock_hashtable_get(threadobject *t, java_handle_t *o) /* lock the hashtable */ - mutex_lock(&(lock_hashtable.mutex)); + Mutex_lock(lock_hashtable.mutex); /* lookup the lock record in the hashtable */ @@ -550,7 +546,7 @@ static lock_record_t *lock_hashtable_get(threadobject *t, java_handle_t *o) /* unlock the hashtable */ - mutex_unlock(&(lock_hashtable.mutex)); + Mutex_unlock(lock_hashtable.mutex); /* return the new lock record */ @@ -578,7 +574,7 @@ static void lock_hashtable_remove(threadobject *t, java_handle_t *o) /* lock the hashtable */ - mutex_lock(&(lock_hashtable.mutex)); + Mutex_lock(lock_hashtable.mutex); /* get lock record */ @@ -617,7 +613,7 @@ static void lock_hashtable_remove(threadobject *t, java_handle_t *o) /* unlock the hashtable */ - mutex_unlock(&(lock_hashtable.mutex)); + Mutex_unlock(lock_hashtable.mutex); /* free the lock record */ @@ -745,7 +741,7 @@ static inline void lock_lockword_set(threadobject *t, java_handle_t *o, uintptr_ static inline void lock_record_enter(threadobject *t, lock_record_t *lr) { - mutex_lock(&(lr->mutex)); + Mutex_lock(lr->mutex); lr->owner = t; } @@ -767,7 +763,7 @@ static inline void lock_record_enter(threadobject *t, lock_record_t *lr) static inline void lock_record_exit(threadobject *t, lock_record_t *lr) { lr->owner = NULL; - mutex_unlock(&(lr->mutex)); + Mutex_unlock(lr->mutex); } @@ -848,7 +844,7 @@ static void sable_flc_waiting(ptrint lockword, threadobject *t, java_handle_t *o /* failure, TODO: add statistics */ return; - mutex_lock(&t_other->flc_lock); + Mutex_lock(t_other->flc_lock); old_flc = t_other->flc_bit; t_other->flc_bit = true; @@ -856,7 +852,7 @@ static void sable_flc_waiting(ptrint lockword, threadobject *t, java_handle_t *o t->index, t_other->index)); /* Set FLC bit first, then read the lockword again */ - MEMORY_BARRIER(); + Atomic_memory_barrier(); lockword = lock_lockword_get(t, o); @@ -874,7 +870,7 @@ static void sable_flc_waiting(ptrint lockword, threadobject *t, java_handle_t *o /* Wait until another thread sees the flc bit and notifies us of unlocking. */ - pthread_cond_wait(&t->flc_cond, &t_other->flc_lock); + Condition_wait(t->flc_cond, t_other->flc_lock); /* Traverse FLC list looking if we're still there */ current = t_other->flc_list; @@ -895,14 +891,14 @@ static void sable_flc_waiting(ptrint lockword, threadobject *t, java_handle_t *o else t_other->flc_bit = old_flc; - mutex_unlock(&t_other->flc_lock); + Mutex_unlock(t_other->flc_lock); } static void notify_flc_waiters(threadobject *t, java_handle_t *o) { threadobject *current; - mutex_lock(&t->flc_lock); + Mutex_lock(t->flc_lock); current = t->flc_list; while (current) @@ -925,14 +921,14 @@ static void notify_flc_waiters(threadobject *t, java_handle_t *o) } } /* Wake the waiting thread */ - pthread_cond_broadcast(¤t->flc_cond); + Condition_broadcast(current->flc_cond); current = current->flc_next; } t->flc_list = NULL; t->flc_bit = false; - mutex_unlock(&t->flc_lock); + Mutex_unlock(t->flc_lock); } /* lock_monitor_enter ********************************************************** @@ -973,14 +969,14 @@ retry: /* most common case: try to thin-lock an unlocked object */ LLNI_CRITICAL_START_THREAD(t); - lockword = COMPARE_AND_SWAP_OLD_VALUE(&(LLNI_DIRECT(o)->lockword), THIN_UNLOCKED, thinlock); + lockword = Atomic_compare_and_swap_ptr(&(LLNI_DIRECT(o)->lockword), THIN_UNLOCKED, thinlock); LLNI_CRITICAL_END_THREAD(t); if (lockword == THIN_UNLOCKED) { /* success. we locked it */ /* The Java Memory Model requires a memory barrier here: */ /* Because of the CAS above, this barrier is a nop on x86 / x86_64 */ - MEMORY_BARRIER_AFTER_ATOMIC(); + Atomic_instruction_barrier(); return true; } @@ -1095,10 +1091,10 @@ bool lock_monitor_exit(java_handle_t *o) if (lockword == thinlock) { /* memory barrier for Java Memory Model */ - STORE_ORDER_BARRIER(); + Atomic_write_memory_barrier(); lock_lockword_set(t, o, THIN_UNLOCKED); - /* memory barrier for thin locking */ - MEMORY_BARRIER(); + /* Memory barrier for thin locking. */ + Atomic_memory_barrier(); /* check if there has been a flat lock contention on this object */ @@ -1148,7 +1144,7 @@ bool lock_monitor_exit(java_handle_t *o) /* unlock this lock record */ lr->owner = NULL; - mutex_unlock(&(lr->mutex)); + Mutex_unlock(lr->mutex); return true; } @@ -1416,19 +1412,12 @@ static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one) /* Enter the wait-mutex. */ - mutex_lock(&(waitingthread->waitmutex)); - - DEBUGLOCKS(("[lock_record_notify: lr=%p, t=%p, waitingthread=%p, sleeping=%d, one=%d]", - lr, t, waitingthread, waitingthread->sleeping, one)); + Mutex_lock(waitingthread->waitmutex); - /* Signal the thread if it's sleeping. sleeping can be false - when the waiting thread is blocked between giving up the - monitor and entering the waitmutex. It will eventually - observe that it's signaled and refrain from going to - sleep. */ + DEBUGLOCKS(("[lock_record_notify: lr=%p, t=%p, waitingthread=%p, one=%d]", + lr, t, waitingthread, one)); - if (waitingthread->sleeping) - pthread_cond_signal(&(waitingthread->waitcond)); + Condition_signal(waitingthread->waitcond); /* Mark the thread as signaled. */ @@ -1436,7 +1425,7 @@ static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one) /* Leave the wait-mutex. */ - mutex_unlock(&(waitingthread->waitmutex)); + Mutex_unlock(waitingthread->waitmutex); /* if we should only wake one, we are done */ diff --git a/src/threads/posix/lock.h b/src/threads/posix/lock.h index 56e17222c..263459ddc 100644 --- a/src/threads/posix/lock.h +++ b/src/threads/posix/lock.h @@ -34,13 +34,16 @@ #include "native/llni.h" -#include "threads/mutex.h" +#include "threads/mutex.hpp" #include "toolbox/list.h" #include "vm/global.h" +#ifdef __cplusplus +extern "C" { +#endif /* typedefs *******************************************************************/ @@ -71,7 +74,7 @@ struct lock_record_t { java_object_t *object; /* object for which this lock is */ struct threadobject *owner; /* current owner of this monitor */ s4 count; /* recursive lock count */ - mutex_t mutex; /* mutex for synchronizing */ + Mutex* mutex; /* mutex for synchronizing */ list_t *waiters; /* list of threads waiting */ lock_record_t *hashlink; /* next record in hash chain */ }; @@ -84,7 +87,7 @@ struct lock_record_t { *******************************************************************************/ struct lock_hashtable_t { - mutex_t mutex; /* mutex for synch. access to the table */ + Mutex* mutex; /* mutex for synch. access to the table */ u4 size; /* number of slots */ u4 entries; /* current number of entries */ lock_record_t **ptr; /* the table of slots, uses ext. chain. */ @@ -98,8 +101,9 @@ struct lock_hashtable_t { #define LOCK_MONITOR_ENTER(o) lock_monitor_enter((java_handle_t *) LLNI_QUICKWRAP(o)) #define LOCK_MONITOR_EXIT(o) lock_monitor_exit((java_handle_t *) LLNI_QUICKWRAP(o)) -#define LOCK_WAIT_FOREVER(o) lock_wait_for_object((java_handle_t *) LLNI_QUICKWRAP(o), 0, 0) -#define LOCK_NOTIFY(o) lock_notify_object((java_handle_t *) LLNI_QUICKWRAP(o)) +#ifdef __cplusplus +} +#endif #endif /* _LOCK_H */ diff --git a/src/threads/posix/mutex-posix.h b/src/threads/posix/mutex-posix.h deleted file mode 100644 index b178c51d2..000000000 --- a/src/threads/posix/mutex-posix.h +++ /dev/null @@ -1,150 +0,0 @@ -/* src/threads/posix/mutex-posix.h - POSIX mutual exclusion functions - - Copyright (C) 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _MUTEX_POSIX_H -#define _MUTEX_POSIX_H - -#include "config.h" - -#include - -#include "vm/vm.h" - - -/* POSIX mutex object *********************************************************/ - -typedef pthread_mutex_t mutex_t; - - -/* static mutex initializer ***************************************************/ - -#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - - -/* inline functions ***********************************************************/ - -/* mutex_init ****************************************************************** - - Initializes the given mutex object and checks for errors. - - ARGUMENTS: - mutex ... POSIX mutex object - -*******************************************************************************/ - -inline static void mutex_init(mutex_t *mutex) -{ - int result; - - result = pthread_mutex_init(mutex, NULL); - - if (result != 0) - vm_abort_errnum(result, "mutex_init: pthread_mutex_init failed"); -} - - -/* mutex_lock ****************************************************************** - - Locks the given mutex object and checks for errors. If the mutex is - already locked by another thread, the calling thread is suspended until - the mutex is unlocked. - - If the mutex is already locked by the calling thread, the same applies, - thus effectively causing the calling thread to deadlock. (This is because - we use "fast" pthread mutexes without error checking.) - - ARGUMENTS: - mutex ... POSIX mutex object - -*******************************************************************************/ - -inline static void mutex_lock(mutex_t *mutex) -{ - int result; - - result = pthread_mutex_lock(mutex); - - if (result != 0) - vm_abort_errnum(result, "mutex_lock: pthread_mutex_lock failed"); -} - - -/* mutex_unlock **************************************************************** - - Unlocks the given mutex object and checks for errors. The mutex is - assumed to be locked and owned by the calling thread. - - ARGUMENTS: - mutex ... POSIX mutex object - -*******************************************************************************/ - -inline static void mutex_unlock(mutex_t *mutex) -{ - int result; - - result = pthread_mutex_unlock(mutex); - - if (result != 0) - vm_abort_errnum(result, "mutex_unlock: pthread_mutex_unlock failed"); -} - - -/* mutex_destroy *************************************************************** - - Destroys the given mutex object and checks for errors. - - ARGUMENTS: - mutex ... POSIX mutex object - -*******************************************************************************/ - -inline static void mutex_destroy(mutex_t *mutex) -{ - int result; - - result = pthread_mutex_destroy(mutex); - - if (result != 0) - vm_abort_errnum(result, "mutex_destroy: pthread_mutex_destroy failed"); -} - - -#endif /* _MUTEX_POSIX_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/posix/mutex-posix.hpp b/src/threads/posix/mutex-posix.hpp new file mode 100644 index 000000000..db9851cc6 --- /dev/null +++ b/src/threads/posix/mutex-posix.hpp @@ -0,0 +1,178 @@ +/* src/threads/posix/mutex-posix.hpp - POSIX mutual exclusion functions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MUTEX_POSIX_HPP +#define _MUTEX_POSIX_HPP + +#include "config.h" + +#include + + +#ifdef __cplusplus + +/** + * POSIX implementation of a mutex. + */ +class Mutex { +private: + // POSIX mutex structure. + pthread_mutex_t _mutex; + pthread_mutexattr_t _attr; + + // Condition class needs to access _mutex for wait() and + // timedwait(). + friend class Condition; + +public: + inline Mutex(); + inline ~Mutex(); + + inline void lock(); + inline void unlock(); +}; + +#else + +// Forward typedefs +typedef struct Mutex Mutex; + +#endif + + +// Includes. +#include "vm/vm.hpp" + + +#ifdef __cplusplus + +/** + * Initializes the given mutex object and checks for errors. + */ +inline Mutex::Mutex() +{ + int result = pthread_mutexattr_init(&_attr); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_init failed"); + } + + result = pthread_mutexattr_settype(&_attr, PTHREAD_MUTEX_RECURSIVE); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::Mutex(): pthread_mutexattr_settype failed"); + } + + result = pthread_mutex_init(&_mutex, &_attr); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::Mutex(): pthread_mutex_init failed"); + } +} + + +/** + * Destroys the given mutex object and checks for errors. + */ +inline Mutex::~Mutex() +{ + int result = pthread_mutexattr_destroy(&_attr); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::~Mutex(): pthread_mutexattr_destroy failed"); + } + + result = pthread_mutex_destroy(&_mutex); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::~Mutex(): pthread_mutex_destroy failed"); + } +} + + +/** + * Locks the given mutex object and checks for errors. If the mutex is + * already locked by another thread, the calling thread is suspended until + * the mutex is unlocked. + * + * If the mutex is already locked by the calling thread, the same applies, + * thus effectively causing the calling thread to deadlock. (This is because + * we use "fast" pthread mutexes without error checking.) + */ +inline void Mutex::lock() +{ + int result = pthread_mutex_lock(&_mutex); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::lock(): pthread_mutex_lock failed"); + } +} + + +/** + * Unlocks the given mutex object and checks for errors. The mutex is + * assumed to be locked and owned by the calling thread. + */ +inline void Mutex::unlock() +{ + int result = pthread_mutex_unlock(&_mutex); + + if (result != 0) { + VM::get_current()->abort_errnum(result, "Mutex::unlock: pthread_mutex_unlock failed"); + } +} + +#else + +// This structure must have the same layout as the class above. +struct Mutex { + pthread_mutex_t _mutex; + pthread_mutexattr_t _attr; +}; + +Mutex* Mutex_new(); +void Mutex_delete(Mutex* mutex); +void Mutex_lock(Mutex* mutex); +void Mutex_unlock(Mutex* mutex); + +#endif + +#endif /* _MUTEX_POSIX_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/posix/thread-posix.c b/src/threads/posix/thread-posix.c deleted file mode 100644 index 9ed9ad8e8..000000000 --- a/src/threads/posix/thread-posix.c +++ /dev/null @@ -1,1822 +0,0 @@ -/* src/threads/posix/thread-posix.c - POSIX thread functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -/* XXX cleanup these includes */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "vm/types.h" - -#include "arch.h" - -#if !defined(USE_FAKE_ATOMIC_INSTRUCTIONS) -# include "machine-instr.h" -#else -# include "threads/posix/generic-primitives.h" -#endif - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#if defined(ENABLE_GC_CACAO) -# include "mm/cacao-gc/gc.h" -#endif - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Throwable.h" -#include "native/include/java_lang_Thread.h" - -#if defined(ENABLE_JAVASE) -# include "native/include/java_lang_ThreadGroup.h" -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/java_lang_VMThread.h" -#endif - -#include "threads/lock-common.h" -#include "threads/mutex.h" -#include "threads/threadlist.h" -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" - -#include "vmcore/options.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#if !defined(__DARWIN__) -# include -#endif -# if defined(__LINUX__) -# define GC_LINUX_THREADS -# elif defined(__IRIX__) -# define GC_IRIX_THREADS -# elif defined(__DARWIN__) -# define GC_DARWIN_THREADS -# endif -# if defined(ENABLE_GC_BOEHM) -/* We need to include Boehm's gc.h here because it overrides - pthread_create and friends. */ -# include "mm/boehm-gc/include/gc.h" -# endif - -#if defined(ENABLE_JVMTI) -#include "native/jvmti/cacaodbg.h" -#endif - -#if defined(__DARWIN__) -/* Darwin has no working semaphore implementation. This one is taken - from Boehm-GC. */ - -/* - This is a very simple semaphore implementation for darwin. It - is implemented in terms of pthreads calls so it isn't async signal - safe. This isn't a problem because signals aren't used to - suspend threads on darwin. -*/ - -static int sem_init(sem_t *sem, int pshared, int value) -{ - if (pshared) - assert(0); - - sem->value = value; - - mutex_init(&sem->mutex); - - if (pthread_cond_init(&sem->cond, NULL) < 0) - return -1; - - return 0; -} - -static int sem_post(sem_t *sem) -{ - mutex_lock(&sem->mutex); - - sem->value++; - - if (pthread_cond_signal(&sem->cond) < 0) { - mutex_unlock(&sem->mutex); - return -1; - } - - mutex_unlock(&sem->mutex); - - return 0; -} - -static int sem_wait(sem_t *sem) -{ - mutex_lock(&sem->mutex); - - while (sem->value == 0) { - pthread_cond_wait(&sem->cond, &sem->mutex); - } - - sem->value--; - - mutex_unlock(&sem->mutex); - - return 0; -} - -static int sem_destroy(sem_t *sem) -{ - if (pthread_cond_destroy(&sem->cond) < 0) - return -1; - - mutex_destroy(&sem->mutex); - - return 0; -} -#endif /* defined(__DARWIN__) */ - - -/* internally used constants **************************************************/ - -/* CAUTION: Do not change these values. Boehm GC code depends on them. */ -#define STOPWORLD_FROM_GC 1 -#define STOPWORLD_FROM_CLASS_NUMBERING 2 - - -/* startupinfo ***************************************************************** - - Struct used to pass info from threads_start_thread to - threads_startup_thread. - -******************************************************************************/ - -typedef struct { - threadobject *thread; /* threadobject for this thread */ - functionptr function; /* function to run in the new thread */ - sem_t *psem; /* signals when thread has been entered */ - /* in the thread list */ - sem_t *psem_first; /* signals when pthread_create has returned */ -} startupinfo; - - -/* prototypes *****************************************************************/ - -static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos); - - -/******************************************************************************/ -/* GLOBAL VARIABLES */ -/******************************************************************************/ - -/* the thread object of the current thread */ -/* This is either a thread-local variable defined with __thread, or */ -/* a thread-specific value stored with key threads_current_threadobject_key. */ -#if defined(HAVE___THREAD) -__thread threadobject *thread_current; -#else -pthread_key_t thread_current_key; -#endif - -/* global mutex for stop-the-world */ -static mutex_t stopworldlock; - -#if defined(ENABLE_GC_CACAO) -/* global mutex for the GC */ -static mutex_t mutex_gc; -#endif - -/* global mutex and condition for joining threads on exit */ -static mutex_t mutex_join; -static pthread_cond_t cond_join; - -/* this is one of the STOPWORLD_FROM_ constants, telling why the world is */ -/* being stopped */ -static volatile int stopworldwhere; - -#if defined(ENABLE_GC_CACAO) - -/* semaphore used for acknowleding thread suspension */ -static sem_t suspend_ack; -#if defined(__IRIX__) -static mutex_t suspend_ack_lock = MUTEX_INITIALIZER; -static pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER; -#endif - -#endif /* ENABLE_GC_CACAO */ - -/* mutexes used by the fake atomic instructions */ -#if defined(USE_FAKE_ATOMIC_INSTRUCTIONS) -mutex_t _cas_lock = MUTEX_INITIALIZER; -mutex_t _mb_lock = MUTEX_INITIALIZER; -#endif - - -/* threads_sem_init ************************************************************ - - Initialize a semaphore. Checks against errors and interruptions. - - IN: - sem..............the semaphore to initialize - shared...........true if this semaphore will be shared between processes - value............the initial value for the semaphore - -*******************************************************************************/ - -void threads_sem_init(sem_t *sem, bool shared, int value) -{ - int r; - - assert(sem); - - do { - r = sem_init(sem, shared, value); - if (r == 0) - return; - } while (errno == EINTR); - - vm_abort("sem_init failed: %s", strerror(errno)); -} - - -/* threads_sem_wait ************************************************************ - - Wait for a semaphore, non-interruptible. - - IMPORTANT: Always use this function instead of `sem_wait` directly, as - `sem_wait` may be interrupted by signals! - - IN: - sem..............the semaphore to wait on - -*******************************************************************************/ - -void threads_sem_wait(sem_t *sem) -{ - int r; - - assert(sem); - - do { - r = sem_wait(sem); - if (r == 0) - return; - } while (errno == EINTR); - - vm_abort("sem_wait failed: %s", strerror(errno)); -} - - -/* threads_sem_post ************************************************************ - - Increase the count of a semaphore. Checks for errors. - - IN: - sem..............the semaphore to increase the count of - -*******************************************************************************/ - -void threads_sem_post(sem_t *sem) -{ - int r; - - assert(sem); - - /* unlike sem_wait, sem_post is not interruptible */ - - r = sem_post(sem); - if (r == 0) - return; - - vm_abort("sem_post failed: %s", strerror(errno)); -} - - -/* lock_stopworld ************************************************************** - - Enter the stopworld lock, specifying why the world shall be stopped. - - IN: - where........ STOPWORLD_FROM_GC (1) from within GC - STOPWORLD_FROM_CLASS_NUMBERING (2) class numbering - -******************************************************************************/ - -void lock_stopworld(int where) -{ - mutex_lock(&stopworldlock); -/* stopworldwhere = where; */ -} - - -/* unlock_stopworld ************************************************************ - - Release the stopworld lock. - -******************************************************************************/ - -void unlock_stopworld(void) -{ -/* stopworldwhere = 0; */ - mutex_unlock(&stopworldlock); -} - -/* XXX We disable that whole bunch of code until we have the exact-GC - running. Some of it may only be needed by the old Boehm-based - suspension handling. */ - -#if 0 - -#if !defined(__DARWIN__) -/* Caller must hold threadlistlock */ -static s4 threads_cast_sendsignals(s4 sig) -{ - threadobject *t; - threadobject *self; - s4 count; - - self = THREADOBJECT; - - /* iterate over all started threads */ - - count = 0; - - for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { - /* don't send the signal to ourself */ - - if (t == self) - continue; - - /* don't send the signal to NEW threads (because they are not - completely initialized) */ - - if (t->state == THREAD_STATE_NEW) - continue; - - /* send the signal */ - - pthread_kill(t->tid, sig); - - /* increase threads count */ - - count++; - } - - return count; -} - -#else - -static void threads_cast_darwinstop(void) -{ - threadobject *tobj = mainthreadobj; - threadobject *self = THREADOBJECT; - - do { - if (tobj != self) - { - thread_state_flavor_t flavor = MACHINE_THREAD_STATE; - mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT; -#if defined(__I386__) - i386_thread_state_t thread_state; -#else - ppc_thread_state_t thread_state; -#endif - mach_port_t thread = tobj->mach_thread; - kern_return_t r; - - r = thread_suspend(thread); - - if (r != KERN_SUCCESS) - vm_abort("thread_suspend failed"); - - r = thread_get_state(thread, flavor, (natural_t *) &thread_state, - &thread_state_count); - - if (r != KERN_SUCCESS) - vm_abort("thread_get_state failed"); - - md_critical_section_restart((ucontext_t *) &thread_state); - - r = thread_set_state(thread, flavor, (natural_t *) &thread_state, - thread_state_count); - - if (r != KERN_SUCCESS) - vm_abort("thread_set_state failed"); - } - - tobj = tobj->next; - } while (tobj != mainthreadobj); -} - -static void threads_cast_darwinresume(void) -{ - threadobject *tobj = mainthreadobj; - threadobject *self = THREADOBJECT; - - do { - if (tobj != self) - { - mach_port_t thread = tobj->mach_thread; - kern_return_t r; - - r = thread_resume(thread); - - if (r != KERN_SUCCESS) - vm_abort("thread_resume failed"); - } - - tobj = tobj->next; - } while (tobj != mainthreadobj); -} - -#endif - -#if defined(__IRIX__) -static void threads_cast_irixresume(void) -{ - mutex_lock(&suspend_ack_lock); - pthread_cond_broadcast(&suspend_cond); - mutex_unlock(&suspend_ack_lock); -} -#endif - -#if defined(ENABLE_GC_BOEHM) && !defined(__DARWIN__) -static void threads_sigsuspend_handler(ucontext_t *_uc) -{ - int sig; - sigset_t sigs; - - /* XXX TWISTI: this is just a quick hack */ -#if defined(ENABLE_JIT) - md_critical_section_restart(_uc); -#endif - - /* Do as Boehm does. On IRIX a condition variable is used for wake-up - (not POSIX async-safe). */ -#if defined(__IRIX__) - mutex_lock(&suspend_ack_lock); - threads_sem_post(&suspend_ack); - pthread_cond_wait(&suspend_cond, &suspend_ack_lock); - mutex_unlock(&suspend_ack_lock); -#elif defined(__CYGWIN__) - /* TODO */ - assert(0); -#else - - sig = GC_signum2(); - sigfillset(&sigs); - sigdelset(&sigs, sig); - sigsuspend(&sigs); -#endif -} -#endif - - -/* threads_stopworld *********************************************************** - - Stops the world from turning. All threads except the calling one - are suspended. The function returns as soon as all threads have - acknowledged their suspension. - -*******************************************************************************/ - -void threads_stopworld(void) -{ -#if !defined(__DARWIN__) && !defined(__CYGWIN__) - threadobject *t; - threadobject *self; - bool result; - s4 count, i; -#endif - - lock_stopworld(STOPWORLD_FROM_CLASS_NUMBERING); - - /* lock the threads lists */ - - threadlist_lock(); - -#if defined(__DARWIN__) - /*threads_cast_darwinstop();*/ - assert(0); -#elif defined(__CYGWIN__) - /* TODO */ - assert(0); -#else - self = THREADOBJECT; - - DEBUGTHREADS("stops World", self); - - count = 0; - - /* suspend all running threads */ - for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { - /* don't send the signal to ourself */ - - if (t == self) - continue; - - /* don't send the signal to NEW threads (because they are not - completely initialized) */ - - if (t->state == THREAD_STATE_NEW) - continue; - - /* send the signal */ - - result = threads_suspend_thread(t, SUSPEND_REASON_STOPWORLD); - assert(result); - - /* increase threads count */ - - count++; - } - - /* wait for all threads signaled to suspend */ - for (i = 0; i < count; i++) - threads_sem_wait(&suspend_ack); -#endif - - /* ATTENTION: Don't unlock the threads-lists here so that - non-signaled NEW threads can't change their state and execute - code. */ -} - - -/* threads_startworld ********************************************************** - - Starts the world again after it has previously been stopped. - -*******************************************************************************/ - -void threads_startworld(void) -{ -#if !defined(__DARWIN__) && !defined(__CYGWIN__) - threadobject *t; - threadobject *self; - bool result; - s4 count, i; -#endif - -#if defined(__DARWIN__) - /*threads_cast_darwinresume();*/ - assert(0); -#elif defined(__IRIX__) - threads_cast_irixresume(); -#elif defined(__CYGWIN__) - /* TODO */ - assert(0); -#else - self = THREADOBJECT; - - DEBUGTHREADS("starts World", self); - - count = 0; - - /* resume all thread we haltet */ - for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { - /* don't send the signal to ourself */ - - if (t == self) - continue; - - /* don't send the signal to NEW threads (because they are not - completely initialized) */ - - if (t->state == THREAD_STATE_NEW) - continue; - - /* send the signal */ - - result = threads_resume_thread(t); - assert(result); - - /* increase threads count */ - - count++; - } - - /* wait for all threads signaled to suspend */ - for (i = 0; i < count; i++) - threads_sem_wait(&suspend_ack); - -#endif - - /* unlock the threads lists */ - - threadlist_unlock(); - - unlock_stopworld(); -} - -#endif - - -/* threads_impl_thread_init **************************************************** - - Initialize OS-level locking constructs in threadobject. - - IN: - t....the threadobject - -*******************************************************************************/ - -void threads_impl_thread_init(threadobject *t) -{ - int result; - - /* initialize the mutex and the condition */ - - mutex_init(&t->flc_lock); - - result = pthread_cond_init(&t->flc_cond, NULL); - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed"); - - mutex_init(&(t->waitmutex)); - - result = pthread_cond_init(&(t->waitcond), NULL); - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed"); - - mutex_init(&(t->suspendmutex)); - - result = pthread_cond_init(&(t->suspendcond), NULL); - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_new: pthread_cond_init failed"); -} - -/* threads_impl_thread_clear *************************************************** - - Clears all fields in threadobject the way an MZERO would have - done. MZERO cannot be used anymore because it would mess up the - pthread_* bits. - - IN: - t....the threadobject - -*******************************************************************************/ - -void threads_impl_thread_clear(threadobject *t) -{ - t->object = NULL; - - t->thinlock = 0; - - t->index = 0; - t->flags = 0; - t->state = 0; - - t->tid = 0; - -#if defined(__DARWIN__) - t->mach_thread = 0; -#endif - - t->interrupted = false; - t->signaled = false; - t->sleeping = false; - - t->suspended = false; - t->suspend_reason = 0; - - t->pc = NULL; - - t->_exceptionptr = NULL; - t->_stackframeinfo = NULL; - t->_localref_table = NULL; - -#if defined(ENABLE_INTRP) - t->_global_sp = NULL; -#endif - -#if defined(ENABLE_GC_CACAO) - t->gc_critical = false; - - t->ss = NULL; - t->es = NULL; -#endif - - MZERO(&t->dumpinfo, dumpinfo_t, 1); -} - -/* threads_impl_thread_reuse *************************************************** - - Resets some implementation fields in threadobject. This was - previously done in threads_impl_thread_new. - - IN: - t....the threadobject - -*******************************************************************************/ - -void threads_impl_thread_reuse(threadobject *t) -{ - /* get the pthread id */ - - t->tid = pthread_self(); - -#if defined(ENABLE_DEBUG_FILTER) - /* Initialize filter counters */ - t->filterverbosecallctr[0] = 0; - t->filterverbosecallctr[1] = 0; -#endif - -#if !defined(NDEBUG) - t->tracejavacallindent = 0; - t->tracejavacallcount = 0; -#endif - - t->flc_bit = false; - t->flc_next = NULL; - t->flc_list = NULL; - -/* not really needed */ - t->flc_object = NULL; -} - - -/* threads_impl_thread_free **************************************************** - - Cleanup thread stuff. - - IN: - t....the threadobject - -*******************************************************************************/ - -#if 0 -/* never used */ -void threads_impl_thread_free(threadobject *t) -{ - int result; - - /* Destroy the mutex and the condition. */ - - mutex_destroy(&(t->flc_lock)); - - result = pthread_cond_destroy(&(t->flc_cond)); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); - - mutex_destroy(&(t->waitmutex)); - - result = pthread_cond_destroy(&(t->waitcond)); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); - - mutex_destroy(&(t->suspendmutex)); - - result = pthread_cond_destroy(&(t->suspendcond)); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); -} -#endif - - -/* threads_impl_preinit ******************************************************** - - Do some early initialization of stuff required. - - ATTENTION: Do NOT use any Java heap allocation here, as gc_init() - is called AFTER this function! - -*******************************************************************************/ - -void threads_impl_preinit(void) -{ - int result; - - mutex_init(&stopworldlock); - - /* initialize exit mutex and condition (on exit we join all - threads) */ - - mutex_init(&mutex_join); - - result = pthread_cond_init(&cond_join, NULL); - if (result != 0) - vm_abort_errnum(result, "threads_impl_preinit: pthread_cond_init failed"); - -#if defined(ENABLE_GC_CACAO) - /* initialize the GC mutex & suspend semaphore */ - - mutex_init(&mutex_gc); - threads_sem_init(&suspend_ack, 0, 0); -#endif - -#if !defined(HAVE___THREAD) - result = pthread_key_create(&thread_current_key, NULL); - if (result != 0) - vm_abort_errnum(result, "threads_impl_preinit: pthread_key_create failed"); -#endif -} - - -/* threads_mutex_gc_lock ******************************************************* - - Enter the global GC mutex. - -*******************************************************************************/ - -#if defined(ENABLE_GC_CACAO) -void threads_mutex_gc_lock(void) -{ - mutex_lock(&mutex_gc); -} -#endif - - -/* threads_mutex_gc_unlock ***************************************************** - - Leave the global GC mutex. - -*******************************************************************************/ - -#if defined(ENABLE_GC_CACAO) -void threads_mutex_gc_unlock(void) -{ - mutex_unlock(&mutex_gc); -} -#endif - -/* threads_mutex_join_lock ***************************************************** - - Enter the join mutex. - -*******************************************************************************/ - -void threads_mutex_join_lock(void) -{ - mutex_lock(&mutex_join); -} - - -/* threads_mutex_join_unlock *************************************************** - - Leave the join mutex. - -*******************************************************************************/ - -void threads_mutex_join_unlock(void) -{ - mutex_unlock(&mutex_join); -} - - -/* threads_impl_init *********************************************************** - - Initializes the implementation specific bits. - -*******************************************************************************/ - -void threads_impl_init(void) -{ - pthread_attr_t attr; - int result; - - threads_set_thread_priority(pthread_self(), NORM_PRIORITY); - - /* Initialize the thread attribute object. */ - - result = pthread_attr_init(&attr); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_init: pthread_attr_init failed"); - - result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_init: pthread_attr_setdetachstate failed"); -} - - -/* threads_startup_thread ****************************************************** - - Thread startup function called by pthread_create. - - Thread which have a startup.function != NULL are marked as internal - threads. All other threads are threated as normal Java threads. - - NOTE: This function is not called directly by pthread_create. The Boehm GC - inserts its own GC_start_routine in between, which then calls - threads_startup. - - IN: - arg..........the argument passed to pthread_create, ie. a pointer to - a startupinfo struct. CAUTION: When the `psem` semaphore - is posted, the startupinfo struct becomes invalid! (It - is allocated on the stack of threads_start_thread.) - -******************************************************************************/ - -static void *threads_startup_thread(void *arg) -{ - startupinfo *startup; - threadobject *t; - java_lang_Thread *object; -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_VMThread *vmt; -#endif - sem_t *psem; - classinfo *c; - methodinfo *m; - java_handle_t *o; - functionptr function; - -#if defined(ENABLE_INTRP) - u1 *intrp_thread_stack; - - /* create interpreter stack */ - - if (opt_intrp) { - intrp_thread_stack = GCMNEW(u1, opt_stacksize); - MSET(intrp_thread_stack, 0, u1, opt_stacksize); - } - else - intrp_thread_stack = NULL; -#endif - - /* get passed startupinfo structure and the values in there */ - - startup = arg; - - t = startup->thread; - function = startup->function; - psem = startup->psem; - - /* Seems like we've encountered a situation where thread->tid was - not set by pthread_create. We alleviate this problem by waiting - for pthread_create to return. */ - - threads_sem_wait(startup->psem_first); - -#if defined(__DARWIN__) - t->mach_thread = mach_thread_self(); -#endif - - /* Now that we are in the new thread, we can store the internal - thread data-structure in the TSD. */ - - thread_set_current(t); - - /* get the java.lang.Thread object for this thread */ - - object = (java_lang_Thread *) thread_get_object(t); - - /* set our priority */ - - threads_set_thread_priority(t->tid, LLNI_field_direct(object, priority)); - - /* Thread is completely initialized. */ - - thread_set_state_runnable(t); - - /* tell threads_startup_thread that we registered ourselves */ - /* CAUTION: *startup becomes invalid with this! */ - - startup = NULL; - threads_sem_post(psem); - -#if defined(ENABLE_INTRP) - /* set interpreter stack */ - - if (opt_intrp) - thread->_global_sp = (Cell *) (intrp_thread_stack + opt_stacksize); -#endif - -#if defined(ENABLE_JVMTI) - /* fire thread start event */ - - if (jvmti) - jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_START); -#endif - - DEBUGTHREADS("starting", t); - - /* find and run the Thread.run()V method if no other function was passed */ - - if (function == NULL) { -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - /* We need to start the run method of - java.lang.VMThread. Since this is a final class, we can use - the class object directly. */ - - c = class_java_lang_VMThread; -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - LLNI_class_get(object, c); -#else -# error unknown classpath configuration -#endif - - m = class_resolveclassmethod(c, utf_run, utf_void__void, c, true); - - if (m == NULL) - vm_abort("threads_startup_thread: run() method not found in class"); - - /* set ThreadMXBean variables */ - - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; - _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; - - if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - /* we need to start the run method of java.lang.VMThread */ - - LLNI_field_get_ref(object, vmThread, vmt); - o = (java_handle_t *) vmt; - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - o = (java_handle_t *) object; -#else -# error unknown classpath configuration -#endif - - /* Run the thread. */ - - (void) vm_call_method(m, o); - } - else { - /* set ThreadMXBean variables */ - - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; - _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; - - if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; - - /* call passed function, e.g. finalizer_thread */ - - (function)(); - } - - DEBUGTHREADS("stopping", t); - -#if defined(ENABLE_JVMTI) - /* fire thread end event */ - - if (jvmti) - jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_END); -#endif - - /* We ignore the return value. */ - - (void) threads_detach_thread(t); - - /* set ThreadMXBean variables */ - - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount--; - - return NULL; -} - - -/* threads_impl_thread_start *************************************************** - - Start a thread in the JVM. Both (vm internal and java) thread - objects exist. - - IN: - thread....the thread object - f.........function to run in the new thread. NULL means that the - "run" method of the object `t` should be called - -******************************************************************************/ - -void threads_impl_thread_start(threadobject *thread, functionptr f) -{ - sem_t sem; - sem_t sem_first; - pthread_attr_t attr; - startupinfo startup; - int result; - - /* fill startupinfo structure passed by pthread_create to - * threads_startup_thread */ - - startup.thread = thread; - startup.function = f; /* maybe we don't call Thread.run()V */ - startup.psem = &sem; - startup.psem_first = &sem_first; - - threads_sem_init(&sem, 0, 0); - threads_sem_init(&sem_first, 0, 0); - - /* Initialize thread attributes. */ - - result = pthread_attr_init(&attr); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_init failed"); - - result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setdetachstate failed"); - - /* initialize thread stacksize */ - - result = pthread_attr_setstacksize(&attr, opt_stacksize); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setstacksize failed"); - - /* create the thread */ - - result = pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_create failed"); - - /* destroy the thread attributes */ - - result = pthread_attr_destroy(&attr); - - if (result != 0) - vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_destroy failed"); - - /* signal that pthread_create has returned, so thread->tid is valid */ - - threads_sem_post(&sem_first); - - /* wait here until the thread has entered itself into the thread list */ - - threads_sem_wait(&sem); - - /* cleanup */ - - sem_destroy(&sem); - sem_destroy(&sem_first); -} - - -/* threads_set_thread_priority ************************************************* - - Set the priority of the given thread. - - IN: - tid..........thread id - priority.....priority to set - -******************************************************************************/ - -void threads_set_thread_priority(pthread_t tid, int priority) -{ - struct sched_param schedp; - int policy; - - pthread_getschedparam(tid, &policy, &schedp); - schedp.sched_priority = priority; - pthread_setschedparam(tid, policy, &schedp); -} - - -/* threads_detach_thread ******************************************************* - - Detaches the passed thread from the VM. Used in JNI. - -*******************************************************************************/ - -bool threads_detach_thread(threadobject *t) -{ - bool result; - java_lang_Thread *object; - java_handle_t *o; -#if defined(ENABLE_JAVASE) - java_lang_ThreadGroup *group; - java_handle_t *e; - void *handler; - classinfo *c; - methodinfo *m; -#endif - - /* If the given thread has already been detached, this operation - is a no-op. */ - - result = thread_is_attached(t); - - if (result == false) - return true; - - DEBUGTHREADS("detaching", t); - - object = (java_lang_Thread *) thread_get_object(t); - -#if defined(ENABLE_JAVASE) - LLNI_field_get_ref(object, group, group); - - /* If there's an uncaught exception, call uncaughtException on the - thread's exception handler, or the thread's group if this is - unset. */ - - e = exceptions_get_and_clear_exception(); - - if (e != NULL) { - /* We use the type void* for handler here, as it's not trivial - to build the java_lang_Thread_UncaughtExceptionHandler - header file with cacaoh. */ - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - LLNI_field_get_ref(object, exceptionHandler, handler); -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - LLNI_field_get_ref(object, uncaughtExceptionHandler, handler); -# endif - - if (handler != NULL) { - LLNI_class_get(handler, c); - o = (java_handle_t *) handler; - } - else { - LLNI_class_get(group, c); - o = (java_handle_t *) group; - } - - m = class_resolveclassmethod(c, - utf_uncaughtException, - utf_java_lang_Thread_java_lang_Throwable__V, - NULL, - true); - - if (m == NULL) - return false; - - (void) vm_call_method(m, o, object, e); - - if (exceptions_get_exception()) - return false; - } - - /* XXX TWISTI: should all threads be in a ThreadGroup? */ - - /* Remove thread from the thread group. */ - - if (group != NULL) { - LLNI_class_get(group, c); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - m = class_resolveclassmethod(c, - utf_removeThread, - utf_java_lang_Thread__V, - class_java_lang_ThreadGroup, - true); -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - m = class_resolveclassmethod(c, - utf_remove, - utf_java_lang_Thread__V, - class_java_lang_ThreadGroup, - true); -# else -# error unknown classpath configuration -# endif - - if (m == NULL) - return false; - - o = (java_handle_t *) group; - - (void) vm_call_method(m, o, object); - - if (exceptions_get_exception()) - return false; - - /* Reset the threadgroup in the Java thread object (Mauve - test: gnu/testlet/java/lang/Thread/getThreadGroup). */ - - LLNI_field_set_ref(object, group, NULL); - } -#endif - - /* Thread has terminated. */ - - thread_set_state_terminated(t); - - /* Notify all threads waiting on this thread. These are joining - this thread. */ - - o = (java_handle_t *) object; - - /* XXX Care about exceptions? */ - (void) lock_monitor_enter(o); - - lock_notify_all_object(o); - - /* XXX Care about exceptions? */ - (void) lock_monitor_exit(o); - - /* Enter the join-mutex before calling thread_free, so - threads_join_all_threads gets the correct number of non-daemon - threads. */ - - threads_mutex_join_lock(); - - /* Free the internal thread data-structure. */ - - thread_free(t); - - /* Signal that this thread has finished and leave the mutex. */ - - pthread_cond_signal(&cond_join); - threads_mutex_join_unlock(); - - return true; -} - - -#if defined(ENABLE_GC_CACAO) - -/* threads_suspend_thread ****************************************************** - - Suspend the passed thread. Execution stops until the thread - is explicitly resumend again. - - IN: - reason.....Reason for suspending this thread. - -*******************************************************************************/ - -bool threads_suspend_thread(threadobject *thread, s4 reason) -{ - /* acquire the suspendmutex */ - mutex_lock(&(thread->suspendmutex)); - - if (thread->suspended) { - mutex_unlock(&(thread->suspendmutex)); - return false; - } - - /* set the reason for the suspension */ - thread->suspend_reason = reason; - - /* send the suspend signal to the thread */ - assert(thread != THREADOBJECT); - if (pthread_kill(thread->tid, SIGUSR1) != 0) - vm_abort("threads_suspend_thread: pthread_kill failed: %s", - strerror(errno)); - - /* REMEMBER: do not release the suspendmutex, this is done - by the thread itself in threads_suspend_ack(). */ - - return true; -} - - -/* threads_suspend_ack ********************************************************* - - Acknowledges the suspension of the current thread. - - IN: - pc.....The PC where the thread suspended its execution. - sp.....The SP before the thread suspended its execution. - -*******************************************************************************/ - -void threads_suspend_ack(u1* pc, u1* sp) -{ - threadobject *thread; - - thread = THREADOBJECT; - - assert(thread->suspend_reason != 0); - - /* TODO: remember dump memory size */ - - /* inform the GC about the suspension */ - if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD && gc_pending) { - - /* check if the GC wants to leave the thread running */ - if (!gc_suspend(thread, pc, sp)) { - - /* REMEMBER: we do not unlock the suspendmutex because the thread - will suspend itself again at a later time */ - return; - - } - } - - /* mark this thread as suspended and remember the PC */ - thread->pc = pc; - thread->suspended = true; - - /* if we are stopping the world, we should send a global ack */ - if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) { - threads_sem_post(&suspend_ack); - } - - DEBUGTHREADS("suspending", thread); - - /* release the suspension mutex and wait till we are resumed */ - pthread_cond_wait(&(thread->suspendcond), &(thread->suspendmutex)); - - DEBUGTHREADS("resuming", thread); - - /* if we are stopping the world, we should send a global ack */ - if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) { - threads_sem_post(&suspend_ack); - } - - /* TODO: free dump memory */ - - /* release the suspendmutex */ - mutex_unlock(&(thread->suspendmutex)); -} - - -/* threads_resume_thread ******************************************************* - - Resumes the execution of the passed thread. - -*******************************************************************************/ - -bool threads_resume_thread(threadobject *thread) -{ - /* acquire the suspendmutex */ - mutex_lock(&(thread->suspendmutex)); - - if (!thread->suspended) { - mutex_unlock(&(thread->suspendmutex)); - return false; - } - - thread->suspended = false; - - /* tell everyone that the thread should resume */ - assert(thread != THREADOBJECT); - pthread_cond_broadcast(&(thread->suspendcond)); - - /* release the suspendmutex */ - mutex_unlock(&(thread->suspendmutex)); - - return true; -} - -#endif - -/* threads_join_all_threads **************************************************** - - Join all non-daemon threads. - -*******************************************************************************/ - -void threads_join_all_threads(void) -{ - threadobject *t; - - /* get current thread */ - - t = THREADOBJECT; - - /* This thread is waiting for all non-daemon threads to exit. */ - - thread_set_state_waiting(t); - - /* enter join mutex */ - - threads_mutex_join_lock(); - - /* Wait for condition as long as we have non-daemon threads. We - compare against 1 because the current (main thread) is also a - non-daemon thread. */ - - while (threadlist_get_non_daemons() > 1) - pthread_cond_wait(&cond_join, &mutex_join); - - /* leave join mutex */ - - threads_mutex_join_unlock(); -} - - -/* threads_timespec_earlier **************************************************** - - Return true if timespec tv1 is earlier than timespec tv2. - - IN: - tv1..........first timespec - tv2..........second timespec - - RETURN VALUE: - true, if the first timespec is earlier - -*******************************************************************************/ - -static inline bool threads_timespec_earlier(const struct timespec *tv1, - const struct timespec *tv2) -{ - return (tv1->tv_sec < tv2->tv_sec) - || - (tv1->tv_sec == tv2->tv_sec && tv1->tv_nsec < tv2->tv_nsec); -} - - -/* threads_current_time_is_earlier_than **************************************** - - Check if the current time is earlier than the given timespec. - - IN: - tv...........the timespec to compare against - - RETURN VALUE: - true, if the current time is earlier - -*******************************************************************************/ - -static bool threads_current_time_is_earlier_than(const struct timespec *tv) -{ - struct timeval tvnow; - struct timespec tsnow; - - /* get current time */ - - if (gettimeofday(&tvnow, NULL) != 0) - vm_abort("gettimeofday failed: %s\n", strerror(errno)); - - /* convert it to a timespec */ - - tsnow.tv_sec = tvnow.tv_sec; - tsnow.tv_nsec = tvnow.tv_usec * 1000; - - /* compare current time with the given timespec */ - - return threads_timespec_earlier(&tsnow, tv); -} - - -/* threads_wait_with_timeout *************************************************** - - Wait until the given point in time on a monitor until either - we are notified, we are interrupted, or the time is up. - - IN: - t............the current thread - wakeupTime...absolute (latest) wakeup time - If both tv_sec and tv_nsec are zero, this function - waits for an unlimited amount of time. - -*******************************************************************************/ - -static void threads_wait_with_timeout(threadobject *t, struct timespec *wakeupTime) -{ - /* acquire the waitmutex */ - - mutex_lock(&t->waitmutex); - - /* mark us as sleeping */ - - t->sleeping = true; - - /* wait on waitcond */ - - if (wakeupTime->tv_sec || wakeupTime->tv_nsec) { - /* with timeout */ - while (!t->interrupted && !t->signaled - && threads_current_time_is_earlier_than(wakeupTime)) - { - thread_set_state_timed_waiting(t); - - pthread_cond_timedwait(&t->waitcond, &t->waitmutex, - wakeupTime); - - thread_set_state_runnable(t); - } - } - else { - /* no timeout */ - while (!t->interrupted && !t->signaled) { - thread_set_state_waiting(t); - - pthread_cond_wait(&t->waitcond, &t->waitmutex); - - thread_set_state_runnable(t); - } - } - - t->sleeping = false; - - /* release the waitmutex */ - - mutex_unlock(&t->waitmutex); -} - - -/* threads_wait_with_timeout_relative ****************************************** - - Wait for the given maximum amount of time on a monitor until either - we are notified, we are interrupted, or the time is up. - - IN: - t............the current thread - millis.......milliseconds to wait - nanos........nanoseconds to wait - -*******************************************************************************/ - -void threads_wait_with_timeout_relative(threadobject *thread, s8 millis, - s4 nanos) -{ - struct timespec wakeupTime; - - /* calculate the the (latest) wakeup time */ - - threads_calc_absolute_time(&wakeupTime, millis, nanos); - - /* wait */ - - threads_wait_with_timeout(thread, &wakeupTime); -} - - -/* threads_calc_absolute_time ************************************************** - - Calculate the absolute point in time a given number of ms and ns from now. - - IN: - millis............milliseconds from now - nanos.............nanoseconds from now - - OUT: - *tm...............receives the timespec of the absolute point in time - -*******************************************************************************/ - -static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos) -{ - if ((millis != 0x7fffffffffffffffLLU) && (millis || nanos)) { - struct timeval tv; - long nsec; - gettimeofday(&tv, NULL); - tv.tv_sec += millis / 1000; - millis %= 1000; - nsec = tv.tv_usec * 1000 + (s4) millis * 1000000 + nanos; - tm->tv_sec = tv.tv_sec + nsec / 1000000000; - tm->tv_nsec = nsec % 1000000000; - } - else { - tm->tv_sec = 0; - tm->tv_nsec = 0; - } -} - - -/* threads_thread_interrupt **************************************************** - - Interrupt the given thread. - - The thread gets the "waitcond" signal and - its interrupted flag is set to true. - - IN: - thread............the thread to interrupt - -*******************************************************************************/ - -void threads_thread_interrupt(threadobject *thread) -{ - /* Signal the thread a "waitcond" and tell it that it has been - interrupted. */ - - mutex_lock(&thread->waitmutex); - - DEBUGTHREADS("interrupted", thread); - - /* Interrupt blocking system call using a signal. */ - - pthread_kill(thread->tid, SIGHUP); - - if (thread->sleeping) - pthread_cond_signal(&thread->waitcond); - - thread->interrupted = true; - - mutex_unlock(&thread->waitmutex); -} - - -/* threads_sleep *************************************************************** - - Sleep the current thread for the specified amount of time. - -*******************************************************************************/ - -void threads_sleep(int64_t millis, int32_t nanos) -{ - threadobject *t; - struct timespec wakeupTime; - bool interrupted; - - if (millis < 0) { -/* exceptions_throw_illegalargumentexception("timeout value is negative"); */ - exceptions_throw_illegalargumentexception(); - return; - } - - t = thread_get_current(); - - if (thread_is_interrupted(t) && !exceptions_get_exception()) { - /* Clear interrupted flag (Mauve test: - gnu/testlet/java/lang/Thread/interrupt). */ - - thread_set_interrupted(t, false); - -/* exceptions_throw_interruptedexception("sleep interrupted"); */ - exceptions_throw_interruptedexception(); - return; - } - - threads_calc_absolute_time(&wakeupTime, millis, nanos); - - threads_wait_with_timeout(t, &wakeupTime); - - interrupted = thread_is_interrupted(t); - - if (interrupted) { - thread_set_interrupted(t, false); - - /* An other exception could have been thrown - (e.g. ThreadDeathException). */ - - if (!exceptions_get_exception()) - exceptions_throw_interruptedexception(); - } -} - - -/* threads_yield *************************************************************** - - Yield to the scheduler. - -*******************************************************************************/ - -void threads_yield(void) -{ - sched_yield(); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/posix/thread-posix.cpp b/src/threads/posix/thread-posix.cpp new file mode 100644 index 000000000..84603487e --- /dev/null +++ b/src/threads/posix/thread-posix.cpp @@ -0,0 +1,1593 @@ +/* src/threads/posix/thread-posix.cpp - POSIX thread functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +/* XXX cleanup these includes */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vm/types.h" + +#include "arch.h" + +#include "mm/gc.hpp" +#include "mm/memory.h" + +#if defined(ENABLE_GC_CACAO) +# include "mm/cacao-gc/gc.h" +#endif + +#include "native/llni.h" +#include "native/native.h" + +#include "threads/condition.hpp" +#include "threads/lock-common.h" +#include "threads/mutex.hpp" +#include "threads/threadlist.h" +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/options.h" +#include "vm/signallocal.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/jit/asmpart.h" + +#if !defined(__DARWIN__) +# include +#endif + +#if defined(__LINUX__) +# define GC_LINUX_THREADS +#elif defined(__IRIX__) +# define GC_IRIX_THREADS +#elif defined(__DARWIN__) +# define GC_DARWIN_THREADS +#endif + +#if defined(ENABLE_GC_BOEHM) +/* We need to include Boehm's gc.h here because it overrides + pthread_create and friends. */ +# include "mm/boehm-gc/include/gc.h" +#endif + +#if defined(ENABLE_JVMTI) +#include "native/jvmti/cacaodbg.h" +#endif + + +#if defined(__DARWIN__) +/* Darwin has no working semaphore implementation. This one is taken + from Boehm-GC. */ + +/* + This is a very simple semaphore implementation for Darwin. It + is implemented in terms of pthreads calls so it isn't async signal + safe. This isn't a problem because signals aren't used to + suspend threads on Darwin. +*/ + +static int sem_init(sem_t *sem, int pshared, int value) +{ + if (pshared) + assert(0); + + sem->mutex = new Mutex(); + sem->cond = new Condition(); + sem->value = value; + + return 0; +} + +static int sem_post(sem_t *sem) +{ + sem->mutex->lock(); + sem->value++; + sem->cond->signal(); + sem->mutex->unlock(); + + return 0; +} + +static int sem_wait(sem_t *sem) +{ + sem->mutex->lock(); + + while (sem->value == 0) { + sem->cond->wait(sem->mutex); + } + + sem->value--; + sem->mutex->unlock(); + + return 0; +} + +static int sem_destroy(sem_t *sem) +{ + delete sem->cond; + delete sem->mutex; + + return 0; +} +#endif /* defined(__DARWIN__) */ + + +/* startupinfo ***************************************************************** + + Struct used to pass info from threads_start_thread to + threads_startup_thread. + +******************************************************************************/ + +typedef struct { + threadobject *thread; /* threadobject for this thread */ + functionptr function; /* function to run in the new thread */ + sem_t *psem; /* signals when thread has been entered */ + /* in the thread list */ + sem_t *psem_first; /* signals when pthread_create has returned */ +} startupinfo; + + +/* prototypes *****************************************************************/ + +static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos); + + +/******************************************************************************/ +/* GLOBAL VARIABLES */ +/******************************************************************************/ + +/* the thread object of the current thread */ +/* This is either a thread-local variable defined with __thread, or */ +/* a thread-specific value stored with key threads_current_threadobject_key. */ +#if defined(HAVE___THREAD) +__thread threadobject *thread_current; +#else +pthread_key_t thread_current_key; +#endif + +/* global mutex for stop-the-world */ +static Mutex* stopworldlock; + +#if defined(ENABLE_GC_CACAO) +/* global mutex for the GC */ +static Mutex* mutex_gc; +#endif + +/* global mutex and condition for joining threads on exit */ +static Mutex* mutex_join; +static Condition* cond_join; + +#if defined(ENABLE_GC_CACAO) +/* semaphore used for acknowleding thread suspension */ +static sem_t suspend_ack; +#endif + + +/* threads_sem_init ************************************************************ + + Initialize a semaphore. Checks against errors and interruptions. + + IN: + sem..............the semaphore to initialize + shared...........true if this semaphore will be shared between processes + value............the initial value for the semaphore + +*******************************************************************************/ + +void threads_sem_init(sem_t *sem, bool shared, int value) +{ + int r; + + assert(sem); + + do { + r = sem_init(sem, shared, value); + if (r == 0) + return; + } while (errno == EINTR); + + vm_abort("sem_init failed: %s", strerror(errno)); +} + + +/* threads_sem_wait ************************************************************ + + Wait for a semaphore, non-interruptible. + + IMPORTANT: Always use this function instead of `sem_wait` directly, as + `sem_wait` may be interrupted by signals! + + IN: + sem..............the semaphore to wait on + +*******************************************************************************/ + +void threads_sem_wait(sem_t *sem) +{ + int r; + + assert(sem); + + do { + r = sem_wait(sem); + if (r == 0) + return; + } while (errno == EINTR); + + vm_abort("sem_wait failed: %s", strerror(errno)); +} + + +/* threads_sem_post ************************************************************ + + Increase the count of a semaphore. Checks for errors. + + IN: + sem..............the semaphore to increase the count of + +*******************************************************************************/ + +void threads_sem_post(sem_t *sem) +{ + int r; + + assert(sem); + + /* unlike sem_wait, sem_post is not interruptible */ + + r = sem_post(sem); + if (r == 0) + return; + + vm_abort("sem_post failed: %s", strerror(errno)); +} + + +/* threads_stopworld *********************************************************** + + Stops the world from turning. All threads except the calling one + are suspended. The function returns as soon as all threads have + acknowledged their suspension. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +void threads_stopworld(void) +{ +#if !defined(__DARWIN__) && !defined(__CYGWIN__) + threadobject *t; + threadobject *self; + bool result; + s4 count, i; +#endif + + stopworldlock->lock(); + + /* lock the threads lists */ + + threadlist_lock(); + +#if defined(__DARWIN__) + /*threads_cast_darwinstop();*/ + assert(0); +#elif defined(__CYGWIN__) + /* TODO */ + assert(0); +#else + self = THREADOBJECT; + + DEBUGTHREADS("stops World", self); + + count = 0; + + /* suspend all running threads */ + for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { + /* don't send the signal to ourself */ + + if (t == self) + continue; + + /* don't send the signal to NEW threads (because they are not + completely initialized) */ + + if (t->state == THREAD_STATE_NEW) + continue; + + /* send the signal */ + + result = threads_suspend_thread(t, SUSPEND_REASON_STOPWORLD); + assert(result); + + /* increase threads count */ + + count++; + } + + /* wait for all threads signaled to suspend */ + for (i = 0; i < count; i++) + threads_sem_wait(&suspend_ack); +#endif + + /* ATTENTION: Don't unlock the threads-lists here so that + non-signaled NEW threads can't change their state and execute + code. */ +} +#endif + + +/* threads_startworld ********************************************************** + + Starts the world again after it has previously been stopped. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +void threads_startworld(void) +{ +#if !defined(__DARWIN__) && !defined(__CYGWIN__) + threadobject *t; + threadobject *self; + bool result; + s4 count, i; +#endif + +#if defined(__DARWIN__) + /*threads_cast_darwinresume();*/ + assert(0); +#elif defined(__IRIX__) + threads_cast_irixresume(); +#elif defined(__CYGWIN__) + /* TODO */ + assert(0); +#else + self = THREADOBJECT; + + DEBUGTHREADS("starts World", self); + + count = 0; + + /* resume all thread we haltet */ + for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { + /* don't send the signal to ourself */ + + if (t == self) + continue; + + /* don't send the signal to NEW threads (because they are not + completely initialized) */ + + if (t->state == THREAD_STATE_NEW) + continue; + + /* send the signal */ + + result = threads_resume_thread(t); + assert(result); + + /* increase threads count */ + + count++; + } + + /* wait for all threads signaled to suspend */ + for (i = 0; i < count; i++) + threads_sem_wait(&suspend_ack); + +#endif + + /* unlock the threads lists */ + + threadlist_unlock(); + + stopworldlock->unlock(); +} +#endif + + +/* threads_impl_thread_clear *************************************************** + + Clears all fields in threadobject the way an MZERO would have + done. MZERO cannot be used anymore because it would mess up the + pthread_* bits. + + IN: + t....the threadobject + +*******************************************************************************/ + +void threads_impl_thread_clear(threadobject *t) +{ + t->object = NULL; + + t->thinlock = 0; + + t->index = 0; + t->flags = 0; + t->state = 0; + + t->tid = 0; + +#if defined(__DARWIN__) + t->mach_thread = 0; +#endif + + t->interrupted = false; + t->signaled = false; + + t->suspended = false; + t->suspend_reason = 0; + + t->pc = NULL; + + t->_exceptionptr = NULL; + t->_stackframeinfo = NULL; + t->_localref_table = NULL; + +#if defined(ENABLE_INTRP) + t->_global_sp = NULL; +#endif + +#if defined(ENABLE_GC_CACAO) + t->gc_critical = false; + + t->ss = NULL; + t->es = NULL; +#endif + + // Simply reuse the existing dump memory. +} + +/* threads_impl_thread_reuse *************************************************** + + Resets some implementation fields in threadobject. This was + previously done in threads_impl_thread_new. + + IN: + t....the threadobject + +*******************************************************************************/ + +void threads_impl_thread_reuse(threadobject *t) +{ + /* get the pthread id */ + + t->tid = pthread_self(); + +#if defined(ENABLE_DEBUG_FILTER) + /* Initialize filter counters */ + t->filterverbosecallctr[0] = 0; + t->filterverbosecallctr[1] = 0; +#endif + +#if !defined(NDEBUG) + t->tracejavacallindent = 0; + t->tracejavacallcount = 0; +#endif + + t->flc_bit = false; + t->flc_next = NULL; + t->flc_list = NULL; + +/* not really needed */ + t->flc_object = NULL; + +#if defined(ENABLE_TLH) + tlh_destroy(&(t->tlh)); + tlh_init(&(t->tlh)); +#endif +} + + +/* threads_impl_thread_free **************************************************** + + Cleanup thread stuff. + + IN: + t....the threadobject + +*******************************************************************************/ + +#if 0 +/* never used */ +void threads_impl_thread_free(threadobject *t) +{ + int result; + + /* Destroy the mutex and the condition. */ + + delete t->flc_lock; + + result = pthread_cond_destroy(&(t->flc_cond)); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); + + delete t->waitmutex; + + result = pthread_cond_destroy(&(t->waitcond)); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); + + delete t->suspendmutex; + + result = pthread_cond_destroy(&(t->suspendcond)); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_free: pthread_cond_destroy failed"); +} +#endif + + +/* threads_impl_preinit ******************************************************** + + Do some early initialization of stuff required. + + ATTENTION: Do NOT use any Java heap allocation here, as gc_init() + is called AFTER this function! + +*******************************************************************************/ + +void threads_impl_preinit(void) +{ + int result; + + stopworldlock = new Mutex(); + + /* initialize exit mutex and condition (on exit we join all + threads) */ + + mutex_join = new Mutex(); + cond_join = new Condition(); + +#if defined(ENABLE_GC_CACAO) + /* initialize the GC mutex & suspend semaphore */ + + mutex_gc = new Mutex(); + threads_sem_init(&suspend_ack, 0, 0); +#endif + +#if !defined(HAVE___THREAD) + result = pthread_key_create(&thread_current_key, NULL); + if (result != 0) + vm_abort_errnum(result, "threads_impl_preinit: pthread_key_create failed"); +#endif +} + + +/* threads_mutex_gc_lock ******************************************************* + + Enter the global GC mutex. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +void threads_mutex_gc_lock(void) +{ + mutex_gc->lock(); +} +#endif + + +/* threads_mutex_gc_unlock ***************************************************** + + Leave the global GC mutex. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +void threads_mutex_gc_unlock(void) +{ + mutex_gc->unlock(); +} +#endif + +/* threads_mutex_join_lock ***************************************************** + + Enter the join mutex. + +*******************************************************************************/ + +void threads_mutex_join_lock(void) +{ + mutex_join->lock(); +} + + +/* threads_mutex_join_unlock *************************************************** + + Leave the join mutex. + +*******************************************************************************/ + +void threads_mutex_join_unlock(void) +{ + mutex_join->unlock(); +} + + +/* threads_impl_init *********************************************************** + + Initializes the implementation specific bits. + +*******************************************************************************/ + +void threads_impl_init(void) +{ + pthread_attr_t attr; + int result; + + threads_set_thread_priority(pthread_self(), NORM_PRIORITY); + + /* Initialize the thread attribute object. */ + + result = pthread_attr_init(&attr); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_init: pthread_attr_init failed"); + + result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_init: pthread_attr_setdetachstate failed"); +} + + +/* threads_startup_thread ****************************************************** + + Thread startup function called by pthread_create. + + Thread which have a startup.function != NULL are marked as internal + threads. All other threads are threated as normal Java threads. + + NOTE: This function is not called directly by pthread_create. The Boehm GC + inserts its own GC_start_routine in between, which then calls + threads_startup. + + IN: + arg..........the argument passed to pthread_create, ie. a pointer to + a startupinfo struct. CAUTION: When the `psem` semaphore + is posted, the startupinfo struct becomes invalid! (It + is allocated on the stack of threads_start_thread.) + +******************************************************************************/ + +static void *threads_startup_thread(void *arg) +{ + startupinfo *startup; + threadobject *t; + sem_t *psem; + classinfo *c; + methodinfo *m; + functionptr function; + +#if defined(ENABLE_GC_BOEHM) +# if !defined(__DARWIN__) + struct GC_stack_base sb; + int result; +# endif +#endif + +#if defined(ENABLE_INTRP) + u1 *intrp_thread_stack; +#endif + +#if defined(ENABLE_INTRP) + /* create interpreter stack */ + + if (opt_intrp) { + intrp_thread_stack = GCMNEW(u1, opt_stacksize); + MSET(intrp_thread_stack, 0, u1, opt_stacksize); + } + else + intrp_thread_stack = NULL; +#endif + + /* get passed startupinfo structure and the values in there */ + + startup = (startupinfo*) arg; + + t = startup->thread; + function = startup->function; + psem = startup->psem; + + /* Seems like we've encountered a situation where thread->tid was + not set by pthread_create. We alleviate this problem by waiting + for pthread_create to return. */ + + threads_sem_wait(startup->psem_first); + +#if defined(__DARWIN__) + t->mach_thread = mach_thread_self(); +#endif + + /* Now that we are in the new thread, we can store the internal + thread data-structure in the TSD. */ + + thread_set_current(t); + +#if defined(ENABLE_GC_BOEHM) +# if defined(__DARWIN__) + // This is currently not implemented in Boehm-GC. Just fail silently. +# else + /* Register the thread with Boehm-GC. This must happen before the + thread allocates any memory from the GC heap.*/ + + result = GC_get_stack_base(&sb); + + if (result != 0) + vm_abort("threads_startup_thread: GC_get_stack_base failed: result=%d", result); + + GC_register_my_thread(&sb); +# endif +#endif + + // Get the java.lang.Thread object for this thread. + java_handle_t* object = thread_get_object(t); + java_lang_Thread jlt(object); + + /* set our priority */ + + threads_set_thread_priority(t->tid, jlt.get_priority()); + + /* Thread is completely initialized. */ + + thread_set_state_runnable(t); + + /* tell threads_startup_thread that we registered ourselves */ + /* CAUTION: *startup becomes invalid with this! */ + + startup = NULL; + threads_sem_post(psem); + +#if defined(ENABLE_INTRP) + /* set interpreter stack */ + + if (opt_intrp) + thread->_global_sp = (Cell *) (intrp_thread_stack + opt_stacksize); +#endif + +#if defined(ENABLE_JVMTI) + /* fire thread start event */ + + if (jvmti) + jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_START); +#endif + + DEBUGTHREADS("starting", t); + + /* find and run the Thread.run()V method if no other function was passed */ + + if (function == NULL) { +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + /* We need to start the run method of + java.lang.VMThread. Since this is a final class, we can use + the class object directly. */ + + c = class_java_lang_VMThread; +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + LLNI_class_get(object, c); +#else +# error unknown classpath configuration +#endif + + m = class_resolveclassmethod(c, utf_run, utf_void__void, c, true); + + if (m == NULL) + vm_abort("threads_startup_thread: run() method not found in class"); + + /* set ThreadMXBean variables */ + +/* _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; */ + +/* if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; */ +#warning Move to C++ + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + // We need to start the run method of java.lang.VMThread. + java_lang_VMThread jlvmt(jlt.get_vmThread()); + java_handle_t* h = jlvmt.get_handle(); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + java_handle_t* h = jlt.get_handle(); + +#else +# error unknown classpath configuration +#endif + + /* Run the thread. */ + + (void) vm_call_method(m, h); + } + else { + /* set ThreadMXBean variables */ + +/* _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; */ + +/* if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = */ +/* _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; */ +#warning Move to C++ + + /* call passed function, e.g. finalizer_thread */ + + (function)(); + } + + DEBUGTHREADS("stopping", t); + +#if defined(ENABLE_JVMTI) + /* fire thread end event */ + + if (jvmti) + jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_END); +#endif + + /* We ignore the return value. */ + + (void) thread_detach_current_thread(); + + /* set ThreadMXBean variables */ + +/* _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount--; */ +#warning Move to C++ + + return NULL; +} + + +/* threads_impl_thread_start *************************************************** + + Start a thread in the JVM. Both (vm internal and java) thread + objects exist. + + IN: + thread....the thread object + f.........function to run in the new thread. NULL means that the + "run" method of the object `t` should be called + +******************************************************************************/ + +void threads_impl_thread_start(threadobject *thread, functionptr f) +{ + sem_t sem; + sem_t sem_first; + pthread_attr_t attr; + startupinfo startup; + int result; + + /* fill startupinfo structure passed by pthread_create to + * threads_startup_thread */ + + startup.thread = thread; + startup.function = f; /* maybe we don't call Thread.run()V */ + startup.psem = &sem; + startup.psem_first = &sem_first; + + threads_sem_init(&sem, 0, 0); + threads_sem_init(&sem_first, 0, 0); + + /* Initialize thread attributes. */ + + result = pthread_attr_init(&attr); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_init failed"); + + result = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setdetachstate failed"); + + /* initialize thread stacksize */ + + result = pthread_attr_setstacksize(&attr, opt_stacksize); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_setstacksize failed"); + + /* create the thread */ + + result = pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_start: pthread_create failed"); + + /* destroy the thread attributes */ + + result = pthread_attr_destroy(&attr); + + if (result != 0) + vm_abort_errnum(result, "threads_impl_thread_start: pthread_attr_destroy failed"); + + /* signal that pthread_create has returned, so thread->tid is valid */ + + threads_sem_post(&sem_first); + + /* wait here until the thread has entered itself into the thread list */ + + threads_sem_wait(&sem); + + /* cleanup */ + + sem_destroy(&sem); + sem_destroy(&sem_first); +} + + +/* threads_set_thread_priority ************************************************* + + Set the priority of the given thread. + + IN: + tid..........thread id + priority.....priority to set + +******************************************************************************/ + +void threads_set_thread_priority(pthread_t tid, int priority) +{ + struct sched_param schedp; + int policy; + + pthread_getschedparam(tid, &policy, &schedp); + schedp.sched_priority = priority; + pthread_setschedparam(tid, policy, &schedp); +} + + +/** + * Detaches the current thread from the VM. + * + * @return true on success, false otherwise + */ +bool thread_detach_current_thread(void) +{ + threadobject* t = thread_get_current(); + + /* Sanity check. */ + + assert(t != NULL); + + /* If the given thread has already been detached, this operation + is a no-op. */ + + if (thread_is_attached(t) == false) + return true; + + DEBUGTHREADS("detaching", t); + + java_handle_t* object = thread_get_object(t); + java_lang_Thread jlt(object); + +#if defined(ENABLE_JAVASE) + java_handle_t* group = jlt.get_group(); + + /* If there's an uncaught exception, call uncaughtException on the + thread's exception handler, or the thread's group if this is + unset. */ + + java_handle_t* e = exceptions_get_and_clear_exception(); + + if (e != NULL) { + /* We use the type void* for handler here, as it's not trivial + to build the java_lang_Thread_UncaughtExceptionHandler + header file with cacaoh. */ + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + java_handle_t* handler = jlt.get_exceptionHandler(); + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + java_handle_t* handler = jlt.get_uncaughtExceptionHandler(); + +# endif + + classinfo* c; + java_handle_t* h; + + if (handler != NULL) { + LLNI_class_get(handler, c); + h = (java_handle_t *) handler; + } + else { + LLNI_class_get(group, c); + h = (java_handle_t *) group; + } + + methodinfo* m = class_resolveclassmethod(c, + utf_uncaughtException, + utf_java_lang_Thread_java_lang_Throwable__V, + NULL, + true); + + if (m == NULL) + return false; + + (void) vm_call_method(m, h, object, e); + + if (exceptions_get_exception()) + return false; + } + + /* XXX TWISTI: should all threads be in a ThreadGroup? */ + + /* Remove thread from the thread group. */ + + if (group != NULL) { + classinfo* c; + LLNI_class_get(group, c); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + methodinfo* m = class_resolveclassmethod(c, + utf_removeThread, + utf_java_lang_Thread__V, + class_java_lang_ThreadGroup, + true); +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + methodinfo* m = class_resolveclassmethod(c, + utf_remove, + utf_java_lang_Thread__V, + class_java_lang_ThreadGroup, + true); +# else +# error unknown classpath configuration +# endif + + if (m == NULL) + return false; + + (void) vm_call_method(m, group, object); + + if (exceptions_get_exception()) + return false; + + // Clear the ThreadGroup in the Java thread object (Mauve + // test: gnu/testlet/java/lang/Thread/getThreadGroup). + jlt.set_group(NULL); + } +#endif + + /* Thread has terminated. */ + + thread_set_state_terminated(t); + + /* Notify all threads waiting on this thread. These are joining + this thread. */ + + /* XXX Care about exceptions? */ + (void) lock_monitor_enter(jlt.get_handle()); + + lock_notify_all_object(jlt.get_handle()); + + /* XXX Care about exceptions? */ + (void) lock_monitor_exit(jlt.get_handle()); + + /* Enter the join-mutex before calling thread_free, so + threads_join_all_threads gets the correct number of non-daemon + threads. */ + + threads_mutex_join_lock(); + + /* Free the internal thread data-structure. */ + + thread_free(t); + + /* Signal that this thread has finished and leave the mutex. */ + + cond_join->signal(); + threads_mutex_join_unlock(); + + return true; +} + + +/* threads_suspend_thread ****************************************************** + + Suspend the passed thread. Execution stops until the thread + is explicitly resumend again. + + IN: + reason.....Reason for suspending this thread. + +*******************************************************************************/ + +bool threads_suspend_thread(threadobject *thread, s4 reason) +{ + /* acquire the suspendmutex */ + thread->suspendmutex->lock(); + + if (thread->suspended) { + thread->suspendmutex->unlock(); + return false; + } + + /* set the reason for the suspension */ + thread->suspend_reason = reason; + + /* send the suspend signal to the thread */ + assert(thread != THREADOBJECT); + if (pthread_kill(thread->tid, SIGUSR1) != 0) + vm_abort("threads_suspend_thread: pthread_kill failed: %s", + strerror(errno)); + + /* REMEMBER: do not release the suspendmutex, this is done + by the thread itself in threads_suspend_ack(). */ + + return true; +} + + +/* threads_suspend_ack ********************************************************* + + Acknowledges the suspension of the current thread. + + IN: + pc.....The PC where the thread suspended its execution. + sp.....The SP before the thread suspended its execution. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +void threads_suspend_ack(u1* pc, u1* sp) +{ + threadobject *thread; + + thread = THREADOBJECT; + + assert(thread->suspend_reason != 0); + + /* TODO: remember dump memory size */ + + /* inform the GC about the suspension */ + if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD && gc_pending) { + + /* check if the GC wants to leave the thread running */ + if (!gc_suspend(thread, pc, sp)) { + + /* REMEMBER: we do not unlock the suspendmutex because the thread + will suspend itself again at a later time */ + return; + + } + } + + /* mark this thread as suspended and remember the PC */ + thread->pc = pc; + thread->suspended = true; + + /* if we are stopping the world, we should send a global ack */ + if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) { + threads_sem_post(&suspend_ack); + } + + DEBUGTHREADS("suspending", thread); + + /* release the suspension mutex and wait till we are resumed */ + thread->suspendcond->wait(thread->suspendmutex); + + DEBUGTHREADS("resuming", thread); + + /* if we are stopping the world, we should send a global ack */ + if (thread->suspend_reason == SUSPEND_REASON_STOPWORLD) { + threads_sem_post(&suspend_ack); + } + + /* TODO: free dump memory */ + + /* release the suspendmutex */ + thread->suspendmutex->unlock(); +} +#endif + + +/* threads_resume_thread ******************************************************* + + Resumes the execution of the passed thread. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +bool threads_resume_thread(threadobject *thread) +{ + /* acquire the suspendmutex */ + thread->suspendmutex->lock(); + + if (!thread->suspended) { + thread->suspendmutex->unlock(); + return false; + } + + thread->suspended = false; + + /* tell everyone that the thread should resume */ + assert(thread != THREADOBJECT); + thread->suspendcond->broadcast(); + + /* release the suspendmutex */ + thread->suspendmutex->unlock(); + + return true; +} +#endif + + +/* threads_join_all_threads **************************************************** + + Join all non-daemon threads. + +*******************************************************************************/ + +void threads_join_all_threads(void) +{ + threadobject *t; + + /* get current thread */ + + t = THREADOBJECT; + + /* This thread is waiting for all non-daemon threads to exit. */ + + thread_set_state_waiting(t); + + /* enter join mutex */ + + threads_mutex_join_lock(); + + /* Wait for condition as long as we have non-daemon threads. We + compare against 1 because the current (main thread) is also a + non-daemon thread. */ + + while (threadlist_get_non_daemons() > 1) + cond_join->wait(mutex_join); + + /* leave join mutex */ + + threads_mutex_join_unlock(); +} + + +/* threads_timespec_earlier **************************************************** + + Return true if timespec tv1 is earlier than timespec tv2. + + IN: + tv1..........first timespec + tv2..........second timespec + + RETURN VALUE: + true, if the first timespec is earlier + +*******************************************************************************/ + +static inline bool threads_timespec_earlier(const struct timespec *tv1, + const struct timespec *tv2) +{ + return (tv1->tv_sec < tv2->tv_sec) + || + (tv1->tv_sec == tv2->tv_sec && tv1->tv_nsec < tv2->tv_nsec); +} + + +/* threads_current_time_is_earlier_than **************************************** + + Check if the current time is earlier than the given timespec. + + IN: + tv...........the timespec to compare against + + RETURN VALUE: + true, if the current time is earlier + +*******************************************************************************/ + +static bool threads_current_time_is_earlier_than(const struct timespec *tv) +{ + struct timeval tvnow; + struct timespec tsnow; + + /* get current time */ + + if (gettimeofday(&tvnow, NULL) != 0) + vm_abort("gettimeofday failed: %s\n", strerror(errno)); + + /* convert it to a timespec */ + + tsnow.tv_sec = tvnow.tv_sec; + tsnow.tv_nsec = tvnow.tv_usec * 1000; + + /* compare current time with the given timespec */ + + return threads_timespec_earlier(&tsnow, tv); +} + + +/* threads_wait_with_timeout *************************************************** + + Wait until the given point in time on a monitor until either + we are notified, we are interrupted, or the time is up. + + IN: + t............the current thread + wakeupTime...absolute (latest) wakeup time + If both tv_sec and tv_nsec are zero, this function + waits for an unlimited amount of time. + +*******************************************************************************/ + +static void threads_wait_with_timeout(threadobject *t, struct timespec *wakeupTime) +{ + // Acquire the waitmutex. + t->waitmutex->lock(); + + /* wait on waitcond */ + + if (wakeupTime->tv_sec || wakeupTime->tv_nsec) { + /* with timeout */ + while (!t->interrupted && !t->signaled + && threads_current_time_is_earlier_than(wakeupTime)) + { + thread_set_state_timed_waiting(t); + + t->waitcond->timedwait(t->waitmutex, wakeupTime); + + thread_set_state_runnable(t); + } + } + else { + /* no timeout */ + while (!t->interrupted && !t->signaled) { + thread_set_state_waiting(t); + + t->waitcond->wait(t->waitmutex); + + thread_set_state_runnable(t); + } + } + + // Release the waitmutex. + t->waitmutex->unlock(); +} + + +/* threads_wait_with_timeout_relative ****************************************** + + Wait for the given maximum amount of time on a monitor until either + we are notified, we are interrupted, or the time is up. + + IN: + t............the current thread + millis.......milliseconds to wait + nanos........nanoseconds to wait + +*******************************************************************************/ + +void threads_wait_with_timeout_relative(threadobject *thread, s8 millis, + s4 nanos) +{ + struct timespec wakeupTime; + + /* calculate the the (latest) wakeup time */ + + threads_calc_absolute_time(&wakeupTime, millis, nanos); + + /* wait */ + + threads_wait_with_timeout(thread, &wakeupTime); +} + + +/* threads_calc_absolute_time ************************************************** + + Calculate the absolute point in time a given number of ms and ns from now. + + IN: + millis............milliseconds from now + nanos.............nanoseconds from now + + OUT: + *tm...............receives the timespec of the absolute point in time + +*******************************************************************************/ + +static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos) +{ + if ((millis != 0x7fffffffffffffffLLU) && (millis || nanos)) { + struct timeval tv; + long nsec; + gettimeofday(&tv, NULL); + tv.tv_sec += millis / 1000; + millis %= 1000; + nsec = tv.tv_usec * 1000 + (s4) millis * 1000000 + nanos; + tm->tv_sec = tv.tv_sec + nsec / 1000000000; + tm->tv_nsec = nsec % 1000000000; + } + else { + tm->tv_sec = 0; + tm->tv_nsec = 0; + } +} + + +/* threads_thread_interrupt **************************************************** + + Interrupt the given thread. + + The thread gets the "waitcond" signal and + its interrupted flag is set to true. + + IN: + thread............the thread to interrupt + +*******************************************************************************/ + +void threads_thread_interrupt(threadobject *t) +{ + /* Signal the thread a "waitcond" and tell it that it has been + interrupted. */ + + t->waitmutex->lock(); + + DEBUGTHREADS("interrupted", t); + + /* Interrupt blocking system call using a signal. */ + + pthread_kill(t->tid, Signal_INTERRUPT_SYSTEM_CALL); + + t->waitcond->signal(); + + t->interrupted = true; + + t->waitmutex->unlock(); +} + + +/** + * Sleep the current thread for the specified amount of time. + * + * @param millis Milliseconds to sleep. + * @param nanos Nanoseconds to sleep. + */ +void threads_sleep(int64_t millis, int32_t nanos) +{ + threadobject *t; + struct timespec wakeupTime; + bool interrupted; + + if (millis < 0) { +/* exceptions_throw_illegalargumentexception("timeout value is negative"); */ + exceptions_throw_illegalargumentexception(); + return; + } + + t = thread_get_current(); + + if (thread_is_interrupted(t) && !exceptions_get_exception()) { + /* Clear interrupted flag (Mauve test: + gnu/testlet/java/lang/Thread/interrupt). */ + + thread_set_interrupted(t, false); + +/* exceptions_throw_interruptedexception("sleep interrupted"); */ + exceptions_throw_interruptedexception(); + return; + } + + // (Note taken from classpath/vm/reference/java/lang/VMThread.java (sleep)) + // Note: JDK treats a zero length sleep is like Thread.yield(), + // without checking the interrupted status of the thread. It's + // unclear if this is a bug in the implementation or the spec. + // See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213203 */ + if (millis == 0 && nanos == 0) { + threads_yield(); + } + else { + threads_calc_absolute_time(&wakeupTime, millis, nanos); + + threads_wait_with_timeout(t, &wakeupTime); + + interrupted = thread_is_interrupted(t); + + if (interrupted) { + thread_set_interrupted(t, false); + + // An other exception could have been thrown + // (e.g. ThreadDeathException). + if (!exceptions_get_exception()) + exceptions_throw_interruptedexception(); + } + } +} + + +/* threads_yield *************************************************************** + + Yield to the scheduler. + +*******************************************************************************/ + +void threads_yield(void) +{ + sched_yield(); +} + +#if defined(ENABLE_TLH) + +void threads_tlh_add_frame() { + tlh_add_frame(&(THREADOBJECT->tlh)); +} + +void threads_tlh_remove_frame() { + tlh_remove_frame(&(THREADOBJECT->tlh)); +} + +#endif + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/posix/thread-posix.h b/src/threads/posix/thread-posix.h deleted file mode 100644 index 58f7d845c..000000000 --- a/src/threads/posix/thread-posix.h +++ /dev/null @@ -1,305 +0,0 @@ -/* src/threads/posix/thread-posix.h - POSIX thread functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _THREAD_POSIX_H -#define _THREAD_POSIX_H - -/* forward typedefs ***********************************************************/ - -typedef struct threadobject threadobject; - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/localref.h" - -#include "threads/mutex.h" - -#include "threads/posix/lock.h" - -#include "vm/global.h" -#include "vm/vm.h" - -#if defined(ENABLE_GC_CACAO) -# include "vm/jit/replace.h" -#endif - -#include "vm/jit/stacktrace.h" - -#if defined(ENABLE_INTRP) -#include "vm/jit/intrp/intrp.h" -#endif - -#if defined(__DARWIN__) -# include - -typedef struct { - mutex_t mutex; - pthread_cond_t cond; - int value; -} sem_t; - -#else -# include -#endif - - -/* current threadobject *******************************************************/ - -#if defined(HAVE___THREAD) - -#define THREADOBJECT thread_current - -extern __thread threadobject *thread_current; - -#else /* defined(HAVE___THREAD) */ - -#define THREADOBJECT \ - ((threadobject *) pthread_getspecific(thread_current_key)) - -extern pthread_key_t thread_current_key; - -#endif /* defined(HAVE___THREAD) */ - - -/* threadobject **************************************************************** - - Struct holding thread local variables. - -*******************************************************************************/ - -#define THREAD_FLAG_JAVA 0x01 /* a normal Java thread */ -#define THREAD_FLAG_INTERNAL 0x02 /* CACAO internal thread */ -#define THREAD_FLAG_DAEMON 0x04 /* daemon thread */ -#define THREAD_FLAG_IN_NATIVE 0x08 /* currently executing native code */ - -#define SUSPEND_REASON_JNI 1 /* suspended from JNI */ -#define SUSPEND_REASON_STOPWORLD 2 /* suspended from stop-thw-world */ - - -struct threadobject { - java_object_t *object; /* link to java.lang.Thread object */ - - ptrint thinlock; /* pre-computed thin lock value */ - - s4 index; /* thread index, starting with 1 */ - u4 flags; /* flag field */ - u4 state; /* state field */ - - pthread_t tid; /* pthread id */ - -#if defined(__DARWIN__) - mach_port_t mach_thread; /* Darwin thread id */ -#endif - - /* for the sable tasuki lock extension */ - bool flc_bit; - struct threadobject *flc_list; /* FLC list head for this thread */ - struct threadobject *flc_next; /* next pointer for FLC list */ - java_handle_t *flc_object; - mutex_t flc_lock; /* controlling access to these fields */ - pthread_cond_t flc_cond; - - /* these are used for the wait/notify implementation */ - mutex_t waitmutex; - pthread_cond_t waitcond; - - mutex_t suspendmutex; /* lock before suspending this thread */ - pthread_cond_t suspendcond; /* notify to resume this thread */ - - bool interrupted; - bool signaled; - bool sleeping; - - bool suspended; /* is this thread suspended? */ - s4 suspend_reason; /* reason for suspending */ - - u1 *pc; /* current PC (used for profiling) */ - - java_object_t *_exceptionptr; /* current exception */ - stackframeinfo_t *_stackframeinfo; /* current native stackframeinfo */ - localref_table *_localref_table; /* JNI local references */ - -#if defined(ENABLE_INTRP) - Cell *_global_sp; /* stack pointer for interpreter */ -#endif - -#if defined(ENABLE_GC_CACAO) - bool gc_critical; /* indicates a critical section */ - - sourcestate_t *ss; - executionstate_t *es; -#endif - - dumpinfo_t dumpinfo; /* dump memory info structure */ - -#if defined(ENABLE_DEBUG_FILTER) - u2 filterverbosecallctr[2]; /* counters for verbose call filter */ -#endif - -#if !defined(NDEBUG) - s4 tracejavacallindent; - u4 tracejavacallcount; -#endif - - listnode_t linkage; /* threads-list */ - listnode_t linkage_free; /* free-list */ -}; - - -/* native-world flags *********************************************************/ - -#if defined(ENABLE_GC_CACAO) -# define THREAD_NATIVEWORLD_ENTER THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE -# define THREAD_NATIVEWORLD_EXIT THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE -#else -# define THREAD_NATIVEWORLD_ENTER /*nop*/ -# define THREAD_NATIVEWORLD_EXIT /*nop*/ -#endif - - -/* counter for verbose call filter ********************************************/ - -#if defined(ENABLE_DEBUG_FILTER) -# define FILTERVERBOSECALLCTR (THREADOBJECT->filterverbosecallctr) -#endif - -/* state for trace java call **************************************************/ - -#if !defined(NDEBUG) -# define TRACEJAVACALLINDENT (THREADOBJECT->tracejavacallindent) -# define TRACEJAVACALLCOUNT (THREADOBJECT->tracejavacallcount) -#endif - - -/* inline functions ***********************************************************/ - -/* thread_get_current ********************************************************** - - Return the threadobject of the current thread. - - RETURN: - the current threadobject * - -*******************************************************************************/ - -inline static threadobject *thread_get_current(void) -{ - threadobject *t; - -#if defined(HAVE___THREAD) - t = thread_current; -#else - t = (threadobject *) pthread_getspecific(thread_current_key); -#endif - - return t; -} - - -/* thread_set_current ********************************************************** - - Set the current thread object. - - IN: - t ... the thread object to set - -*******************************************************************************/ - -inline static void thread_set_current(threadobject *t) -{ -#if defined(HAVE___THREAD) - thread_current = t; -#else - int result; - - result = pthread_setspecific(thread_current_key, t); - - if (result != 0) - vm_abort_errnum(result, "thread_set_current: pthread_setspecific failed"); -#endif -} - - -inline static stackframeinfo_t *threads_get_current_stackframeinfo(void) -{ - return THREADOBJECT->_stackframeinfo; -} - -inline static void threads_set_current_stackframeinfo(stackframeinfo_t *sfi) -{ - THREADOBJECT->_stackframeinfo = sfi; -} - - -/* functions ******************************************************************/ - -void threads_sem_init(sem_t *sem, bool shared, int value); -void threads_sem_wait(sem_t *sem); -void threads_sem_post(sem_t *sem); - -void threads_start_thread(threadobject *thread, functionptr function); - -void threads_set_thread_priority(pthread_t tid, int priority); - -bool threads_detach_thread(threadobject *thread); - -#if defined(ENABLE_GC_CACAO) -bool threads_suspend_thread(threadobject *thread, s4 reason); -void threads_suspend_ack(u1* pc, u1* sp); -bool threads_resume_thread(threadobject *thread); -#endif - -void threads_join_all_threads(void); - -void threads_sleep(int64_t millis, int32_t nanos); - -void threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos); - -void threads_thread_interrupt(threadobject *thread); - -#endif /* _THREAD_POSIX_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/posix/thread-posix.hpp b/src/threads/posix/thread-posix.hpp new file mode 100644 index 000000000..89c6d1671 --- /dev/null +++ b/src/threads/posix/thread-posix.hpp @@ -0,0 +1,334 @@ +/* src/threads/posix/thread-posix.hpp - POSIX thread functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _THREAD_POSIX_HPP +#define _THREAD_POSIX_HPP + +#include "config.h" + +#include +#include + +#include "vm/types.h" + + +// Includes required by Thread. + +#if defined(ENABLE_TLH) +# include "mm/tlh.h" +#endif + +#include "threads/condition.hpp" +#include "threads/mutex.hpp" + + +/* threadobject **************************************************************** + + Struct holding thread local variables. + +*******************************************************************************/ + +#define THREAD_FLAG_JAVA 0x01 /* a normal Java thread */ +#define THREAD_FLAG_INTERNAL 0x02 /* CACAO internal thread */ +#define THREAD_FLAG_DAEMON 0x04 /* daemon thread */ +#define THREAD_FLAG_IN_NATIVE 0x08 /* currently executing native code */ + +#define SUSPEND_REASON_JNI 1 /* suspended from JNI */ +#define SUSPEND_REASON_STOPWORLD 2 /* suspended from stop-thw-world */ + + +typedef struct threadobject threadobject; + +struct threadobject { + java_object_t *object; /* link to java.lang.Thread object */ + + ptrint thinlock; /* pre-computed thin lock value */ + + s4 index; /* thread index, starting with 1 */ + u4 flags; /* flag field */ + u4 state; /* state field */ + + pthread_t tid; /* pthread id */ + +#if defined(__DARWIN__) + mach_port_t mach_thread; /* Darwin thread id */ +#endif + + /* for the sable tasuki lock extension */ + bool flc_bit; + struct threadobject *flc_list; /* FLC list head for this thread */ + struct threadobject *flc_next; /* next pointer for FLC list */ + java_handle_t *flc_object; + Mutex* flc_lock; /* controlling access to these fields */ + Condition* flc_cond; + + /* these are used for the wait/notify implementation */ + Mutex* waitmutex; + Condition* waitcond; + + Mutex* suspendmutex; /* lock before suspending this thread */ + Condition* suspendcond; /* notify to resume this thread */ + + bool interrupted; + bool signaled; + + bool suspended; /* is this thread suspended? */ + s4 suspend_reason; /* reason for suspending */ + + u1 *pc; /* current PC (used for profiling) */ + + java_object_t *_exceptionptr; /* current exception */ + struct stackframeinfo_t *_stackframeinfo; /* current native stackframeinfo */ + struct localref_table *_localref_table; /* JNI local references */ + +#if defined(ENABLE_INTRP) + Cell *_global_sp; /* stack pointer for interpreter */ +#endif + +#if defined(ENABLE_GC_CACAO) + bool gc_critical; /* indicates a critical section */ + + sourcestate_t *ss; + executionstate_t *es; +#endif + + struct DumpMemory* _dumpmemory; ///< Dump memory structure. + +#if defined(ENABLE_DEBUG_FILTER) + u2 filterverbosecallctr[2]; /* counters for verbose call filter */ +#endif + +#if !defined(NDEBUG) + s4 tracejavacallindent; + u4 tracejavacallcount; +#endif + +#if defined(ENABLE_TLH) + tlh_t tlh; +#endif + +#if defined(ENABLE_ESCAPE_REASON) + void *escape_reasons; +#endif + + listnode_t linkage; /* threads-list */ + listnode_t linkage_free; /* free-list */ +}; + + +/* current threadobject *******************************************************/ + +#if defined(HAVE___THREAD) + +#define THREADOBJECT thread_current + +extern __thread threadobject *thread_current; + +#else /* defined(HAVE___THREAD) */ + +#define THREADOBJECT \ + ((threadobject *) pthread_getspecific(thread_current_key)) + +extern pthread_key_t thread_current_key; + +#endif /* defined(HAVE___THREAD) */ + + +/* native-world flags *********************************************************/ + +#if defined(ENABLE_GC_CACAO) +# define THREAD_NATIVEWORLD_ENTER THREADOBJECT->flags |= THREAD_FLAG_IN_NATIVE +# define THREAD_NATIVEWORLD_EXIT THREADOBJECT->flags &= ~THREAD_FLAG_IN_NATIVE +#else +# define THREAD_NATIVEWORLD_ENTER /*nop*/ +# define THREAD_NATIVEWORLD_EXIT /*nop*/ +#endif + + +/* counter for verbose call filter ********************************************/ + +#if defined(ENABLE_DEBUG_FILTER) +# define FILTERVERBOSECALLCTR (THREADOBJECT->filterverbosecallctr) +#endif + +/* state for trace java call **************************************************/ + +#if !defined(NDEBUG) +# define TRACEJAVACALLINDENT (THREADOBJECT->tracejavacallindent) +# define TRACEJAVACALLCOUNT (THREADOBJECT->tracejavacallcount) +#endif + + +// FIXME +#ifdef __cplusplus +extern "C" { +#endif +inline static threadobject* thread_get_current(void); +#ifdef __cplusplus +} +#endif + + +// Includes. +#include "mm/memory.h" + +#include "native/localref.h" + +#include "threads/posix/lock.h" + +#include "vm/global.h" +#include "vm/vm.hpp" + +#if defined(ENABLE_GC_CACAO) +# include "vm/jit/executionstate.h" +# include "vm/jit/replace.hpp" +#endif + +#include "vm/jit/stacktrace.hpp" + +#if defined(ENABLE_INTRP) +#include "vm/jit/intrp/intrp.h" +#endif + +#if defined(__DARWIN__) +# include + +typedef struct { + Mutex* mutex; + Condition* cond; + int value; +} sem_t; + +#else +# include +#endif + + +// FIXME +#ifdef __cplusplus +extern "C" { +#endif + +/* inline functions ***********************************************************/ + +/** + * Return the Thread object of the current thread. + * + * @return The current Thread object. + */ +inline static threadobject* thread_get_current(void) +{ + threadobject *t; + +#if defined(HAVE___THREAD) + t = thread_current; +#else + t = (threadobject *) pthread_getspecific(thread_current_key); +#endif + + return t; +} + + +/** + * Set the current Thread object. + * + * @param t The thread object to set. + */ +inline static void thread_set_current(threadobject* t) +{ +#if defined(HAVE___THREAD) + thread_current = t; +#else + int result; + + result = pthread_setspecific(thread_current_key, t); + + if (result != 0) + vm_abort_errnum(result, "thread_set_current: pthread_setspecific failed"); +#endif +} + + +inline static stackframeinfo_t *threads_get_current_stackframeinfo(void) +{ + return THREADOBJECT->_stackframeinfo; +} + +inline static void threads_set_current_stackframeinfo(stackframeinfo_t *sfi) +{ + THREADOBJECT->_stackframeinfo = sfi; +} + + +/* functions ******************************************************************/ + +void threads_sem_init(sem_t *sem, bool shared, int value); +void threads_sem_wait(sem_t *sem); +void threads_sem_post(sem_t *sem); + +void threads_start_thread(threadobject *thread, functionptr function); + +void threads_set_thread_priority(pthread_t tid, int priority); + +#if defined(ENABLE_GC_CACAO) +bool threads_suspend_thread(threadobject *thread, s4 reason); +void threads_suspend_ack(u1* pc, u1* sp); +bool threads_resume_thread(threadobject *thread); +#endif + +void threads_join_all_threads(void); + +void threads_sleep(int64_t millis, int32_t nanos); + +void threads_wait_with_timeout_relative(threadobject *t, s8 millis, s4 nanos); + +void threads_thread_interrupt(threadobject *thread); + +#if defined(ENABLE_TLH) +void threads_tlh_add_frame(); +void threads_tlh_remove_frame(); +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _THREAD_POSIX_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/removeme.cpp b/src/threads/removeme.cpp new file mode 100644 index 000000000..60878ce5a --- /dev/null +++ b/src/threads/removeme.cpp @@ -0,0 +1,61 @@ +/* src/threads/removeme.cpp + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + +// XXX Remove me as soon as all using files have been converted to C++! + +#include "config.h" + +#include "threads/condition.hpp" +#include "threads/mutex.hpp" + +extern "C" { + +Mutex* Mutex_new() { return new Mutex(); } +void Mutex_delete(Mutex* mutex) { delete mutex; } +void Mutex_lock(Mutex* mutex) { mutex->lock(); } +void Mutex_unlock(Mutex* mutex) { mutex->unlock(); } + +Condition* Condition_new() { return new Condition(); } +void Condition_delete(Condition* cond) { delete cond; } +void Condition_broadcast(Condition* cond) { cond->broadcast(); } +void Condition_signal(Condition* cond) { cond->signal(); } +void Condition_timedwait(Condition* cond, Mutex* mutex, const struct timespec* abstime) { cond->timedwait(mutex, abstime); } +void Condition_wait(Condition* cond, Mutex* mutex) { cond->wait(mutex); } + +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/thread.c b/src/threads/thread.c deleted file mode 100644 index aa0609a52..000000000 --- a/src/threads/thread.c +++ /dev/null @@ -1,1224 +0,0 @@ -/* src/threads/thread.c - machine independent thread functions - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Thread.h" - -#if defined(ENABLE_JAVASE) -# include "native/include/java_lang_ThreadGroup.h" -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/java_lang_VMThread.h" -#endif - -#include "threads/critical.h" -#include "threads/lock-common.h" -#include "threads/threadlist.h" -#include "threads/thread.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/options.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#include "vmcore/utf8.h" - - -/* global variables ***********************************************************/ - -static methodinfo *thread_method_init; -static java_handle_t *threadgroup_system; -static java_handle_t *threadgroup_main; - -#if defined(__LINUX__) -/* XXX Remove for exact-GC. */ -bool threads_pthreads_implementation_nptl; -#endif - - -/* static functions ***********************************************************/ - -static void thread_create_initial_threadgroups(void); -static void thread_create_initial_thread(void); -static threadobject *thread_new(void); - - -/* threads_preinit ************************************************************* - - Do some early initialization of stuff required. - -*******************************************************************************/ - -void threads_preinit(void) -{ - threadobject *mainthread; -#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION) - char *pathbuf; - size_t len; -#endif - - TRACESUBSYSTEMINITIALIZATION("threads_preinit"); - -#if defined(__LINUX__) - /* XXX Remove for exact-GC. */ - - /* On Linux we need to check the pthread implementation. */ - - /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */ - /* If the glibc is a pre-2.3.2 version, we fall back to - linuxthreads. */ - -# if defined(_CS_GNU_LIBPTHREAD_VERSION) - len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0); - - /* Some systems return as length 0 (maybe cross-compilation - related). In this case we also fall back to linuxthreads. */ - - if (len > 0) { - pathbuf = MNEW(char, len); - - (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len); - - if (strstr(pathbuf, "NPTL") != NULL) - threads_pthreads_implementation_nptl = true; - else - threads_pthreads_implementation_nptl = false; - } - else - threads_pthreads_implementation_nptl = false; -# else - threads_pthreads_implementation_nptl = false; -# endif -#endif - - /* Initialize the threads implementation (sets the thinlock on the - main thread). */ - - threads_impl_preinit(); - - /* Create internal thread data-structure for the main thread. */ - - mainthread = thread_new(); - - /* The main thread should always have index 1. */ - - if (mainthread->index != 1) - vm_abort("threads_preinit: main thread index not 1: %d != 1", - mainthread->index); - - /* thread is a Java thread and running */ - - mainthread->flags |= THREAD_FLAG_JAVA; - mainthread->state = THREAD_STATE_RUNNABLE; - - /* Store the internal thread data-structure in the TSD. */ - - thread_set_current(mainthread); -} - - -/* threads_init **************************************************************** - - Initialize the main thread. - -*******************************************************************************/ - -void threads_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("threads_init"); - - /* Create the system and main thread groups. */ - - thread_create_initial_threadgroups(); - - /* Cache the java.lang.Thread initialization method. */ - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - thread_method_init = - class_resolveclassmethod(class_java_lang_Thread, - utf_init, - utf_new_char("(Ljava/lang/VMThread;Ljava/lang/String;IZ)V"), - class_java_lang_Thread, - true); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - thread_method_init = - class_resolveclassmethod(class_java_lang_Thread, - utf_init, - utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"), - class_java_lang_Thread, - true); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - thread_method_init = - class_resolveclassmethod(class_java_lang_Thread, - utf_init, - utf_java_lang_String__void, - class_java_lang_Thread, - true); - -#else -# error unknown classpath configuration -#endif - - if (thread_method_init == NULL) - vm_abort("threads_init: failed to resolve thread init method"); - - thread_create_initial_thread(); -} - - -/* thread_create_object ******************************************************** - - Create a Java thread object for the given thread data-structure, - initializes it and adds the thread to the threadgroup. - - ARGUMENTS: - - t ....... thread - name .... thread name - group ... threadgroup - - RETURN: - -*******************************************************************************/ - -static bool thread_create_object(threadobject *t, java_handle_t *name, java_handle_t *group) -{ - java_handle_t *o; - java_lang_Thread *to; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_VMThread *vmto; - classinfo *c; - methodinfo *m; - bool isdaemon; -#endif - - /* Create a java.lang.Thread Java object. */ - - o = builtin_new(class_java_lang_Thread); - - if (o == NULL) - return false; - - to = (java_lang_Thread *) o; - - /* Set the Java object in the thread data-structure. This - indicates that the thread is attached to the VM. */ - - thread_set_object(t, (java_handle_t *) to); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Create a java.lang.VMThread Java object. */ - - vmto = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread); - - if (vmto == NULL) - return false; - - /* Set the Java thread object in the Java VM-thread object. */ - - LLNI_field_set_ref(vmto, thread, to); - - /* Set the thread data-structure in the Java VM-thread object. */ - - LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t); - - /* Call: - java.lang.Thread.(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */ - - isdaemon = thread_is_daemon(t); - - (void) vm_call_method(thread_method_init, o, vmto, name, NORM_PRIORITY, - isdaemon); - - if (exceptions_get_exception()) - return false; - - /* Set the threadgroup in the Java thread object. */ - - LLNI_field_set_ref(to, group, (java_lang_ThreadGroup *) group); - - /* Add thread to the threadgroup. */ - - LLNI_class_get(group, c); - - m = class_resolveclassmethod(c, - utf_addThread, - utf_java_lang_Thread__V, - class_java_lang_ThreadGroup, - true); - - if (m == NULL) - return false; - - (void) vm_call_method(m, group, to); - - if (exceptions_get_exception()) - return false; - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* OpenJDK's java.lang.Thread does not have a VMThread field in - the class. Nothing to do here. */ - - /* Set the priority. java.lang.Thread. requires it because - it sets the priority of the current thread to the parent's one - (which is the current thread in this case). */ - - LLNI_field_set_val(to, priority, NORM_PRIORITY); - - /* Call: - java.lang.Thread.(Ljava/lang/ThreadGroup;Ljava/lang/String;)V */ - - (void) vm_call_method(thread_method_init, o, group, name); - - if (exceptions_get_exception()) - return false; - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - /* Set the thread data-structure in the Java thread object. */ - - LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t); - - /* Call: public Thread(Ljava/lang/String;)V */ - - (void) vm_call_method(thread_method_init, o, name); - - if (exceptions_get_exception()) - return false; - -#else -# error unknown classpath configuration -#endif - - return true; -} - - -/* thread_create_initial_threadgroups ****************************************** - - Create the initial threadgroups. - - GNU Classpath: - Create the main threadgroup only and set the system - threadgroup to the main threadgroup. - - SUN: - Create the system and main threadgroup. - - CLDC: - This function is a no-op. - -*******************************************************************************/ - -static void thread_create_initial_threadgroups(void) -{ -#if defined(ENABLE_JAVASE) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Allocate and initialize the main thread group. */ - - threadgroup_main = native_new_and_init(class_java_lang_ThreadGroup); - - if (threadgroup_main == NULL) - vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup"); - - /* Use the same threadgroup for system as for main. */ - - threadgroup_system = threadgroup_main; - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - java_handle_t *name; - methodinfo *m; - - /* Allocate and initialize the system thread group. */ - - threadgroup_system = native_new_and_init(class_java_lang_ThreadGroup); - - if (threadgroup_system == NULL) - vm_abort("thread_create_initial_threadgroups: failed to allocate system threadgroup"); - - /* Allocate and initialize the main thread group. */ - - threadgroup_main = builtin_new(class_java_lang_ThreadGroup); - - if (threadgroup_main == NULL) - vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup"); - - name = javastring_new(utf_main); - - m = class_resolveclassmethod(class_java_lang_ThreadGroup, - utf_init, - utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V, - class_java_lang_ThreadGroup, - true); - - if (m == NULL) - vm_abort("thread_create_initial_threadgroups: failed to resolve threadgroup init method"); - - (void) vm_call_method(m, threadgroup_main, threadgroup_system, name); - - if (exceptions_get_exception()) - vm_abort("thread_create_initial_threadgroups: exception while initializing main threadgroup"); - -# else -# error unknown classpath configuration -# endif -#endif -} - - -/* thread_create_initial_thread *********************************************** - - Create the initial thread: main - -*******************************************************************************/ - -static void thread_create_initial_thread(void) -{ - threadobject *t; - java_handle_t *name; - - /* Get the main-thread (NOTE: The main thread is always the first - thread in the list). */ - - t = threadlist_first(); - - /* The thread name. */ - - name = javastring_new(utf_main); - -#if defined(ENABLE_INTRP) - /* create interpreter stack */ - - if (opt_intrp) { - MSET(intrp_main_stack, 0, u1, opt_stacksize); - mainthread->_global_sp = (Cell*) (intrp_main_stack + opt_stacksize); - } -#endif - - /* Create the Java thread object. */ - - if (!thread_create_object(t, name, threadgroup_main)) - vm_abort("thread_create_initial_thread: failed to create Java object"); - - /* Initialize the implementation specific bits. */ - - threads_impl_init(); - - DEBUGTHREADS("starting (main)", t); -} - - -/* thread_new ****************************************************************** - - Allocates and initializes an internal thread data-structure and - adds it to the threads list. - -*******************************************************************************/ - -static threadobject *thread_new(void) -{ - int32_t index; - threadobject *t; - - /* Lock the thread lists */ - - threadlist_lock(); - - index = threadlist_get_free_index(); - - /* Allocate a thread data structure. */ - - /* First, try to get one from the free-list. */ - - t = threadlist_free_first(); - - if (t != NULL) { - /* Remove from free list. */ - - threadlist_free_remove(t); - - /* Equivalent of MZERO on the else path */ - - threads_impl_thread_clear(t); - } - else { -#if defined(ENABLE_GC_BOEHM) - t = GCNEW_UNCOLLECTABLE(threadobject, 1); -#else - t = NEW(threadobject); -#endif - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_threadobject += sizeof(threadobject); -#endif - - /* Clear memory. */ - - MZERO(t, threadobject, 1); - -#if defined(ENABLE_GC_CACAO) - /* Register reference to java.lang.Thread with the GC. */ - /* FIXME is it ok to do this only once? */ - - gc_reference_register(&(t->object), GC_REFTYPE_THREADOBJECT); - gc_reference_register(&(t->_exceptionptr), GC_REFTYPE_THREADOBJECT); -#endif - - /* Initialize the implementation-specific bits. */ - - threads_impl_thread_init(t); - } - - /* Pre-compute the thinlock-word. */ - - assert(index != 0); - - t->index = index; - t->thinlock = lock_pre_compute_thinlock(t->index); - t->flags = 0; - t->state = THREAD_STATE_NEW; - -#if defined(ENABLE_GC_CACAO) - t->flags |= THREAD_FLAG_IN_NATIVE; -#endif - - /* Initialize the implementation-specific bits. */ - - threads_impl_thread_reuse(t); - - /* Add the thread to the thread list. */ - - threadlist_add(t); - - /* Unlock the thread lists. */ - - threadlist_unlock(); - - return t; -} - - -/* thread_free ***************************************************************** - - Remove the thread from the threads-list and free the internal - thread data structure. The thread index is added to the - thread-index free-list. - - IN: - t ... thread data structure - -*******************************************************************************/ - -void thread_free(threadobject *t) -{ - /* Lock the thread lists. */ - - threadlist_lock(); - - /* Remove the thread from the thread-list. */ - - threadlist_remove(t); - - /* Add the thread index to the free list. */ - - threadlist_index_add(t->index); - - /* Set the reference to the Java object to NULL. */ - - thread_set_object(t, NULL); - - /* Add the thread data structure to the free list. */ - - threadlist_free_add(t); - - /* Unlock the thread lists. */ - - threadlist_unlock(); -} - - -/* threads_thread_start_internal *********************************************** - - Start an internal thread in the JVM. No Java thread objects exists - so far. - - IN: - name.......UTF-8 name of the thread - f..........function pointer to C function to start - -*******************************************************************************/ - -bool threads_thread_start_internal(utf *name, functionptr f) -{ - threadobject *t; - - /* Enter the join-mutex, so if the main-thread is currently - waiting to join all threads, the number of non-daemon threads - is correct. */ - - threads_mutex_join_lock(); - - /* Create internal thread data-structure. */ - - t = thread_new(); - - t->flags |= THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON; - - /* The thread is flagged as (non-)daemon thread, we can leave the - mutex. */ - - threads_mutex_join_unlock(); - - /* Create the Java thread object. */ - - if (!thread_create_object(t, javastring_new(name), threadgroup_system)) - return false; - - /* Start the thread. */ - - threads_impl_thread_start(t, f); - - /* everything's ok */ - - return true; -} - - -/* threads_thread_start ******************************************************** - - Start a Java thread in the JVM. Only the java thread object exists - so far. - - IN: - object.....the java thread object java.lang.Thread - -*******************************************************************************/ - -void threads_thread_start(java_handle_t *object) -{ - java_lang_Thread *to; - threadobject *t; -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_VMThread *vmto; -#endif - - to = (java_lang_Thread *) object; - - /* Enter the join-mutex, so if the main-thread is currently - waiting to join all threads, the number of non-daemon threads - is correct. */ - - threads_mutex_join_lock(); - - /* Create internal thread data-structure. */ - - t = thread_new(); - - /* this is a normal Java thread */ - - t->flags |= THREAD_FLAG_JAVA; - -#if defined(ENABLE_JAVASE) - /* Is this a daemon thread? */ - - if (LLNI_field_direct(to, daemon) == true) - t->flags |= THREAD_FLAG_DAEMON; -#endif - - /* The thread is flagged and (non-)daemon thread, we can leave the - mutex. */ - - threads_mutex_join_unlock(); - - /* Link the two objects together. */ - - thread_set_object(t, object); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Get the java.lang.VMThread object and do some sanity checks. */ - - LLNI_field_get_ref(to, vmThread, vmto); - - assert(vmto); - assert(LLNI_field_direct(vmto, vmdata) == NULL); - - LLNI_field_set_val(vmto, vmdata, (java_lang_Object *) t); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* Nothing to do. */ - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - LLNI_field_set_val(to, vm_thread, (java_lang_Object *) t); - -#else -# error unknown classpath configuration -#endif - - /* Start the thread. Don't pass a function pointer (NULL) since - we want Thread.run()V here. */ - - threads_impl_thread_start(t, NULL); -} - - -/* threads_attach_current_thread *********************************************** - - Attaches the current thread to the VM. Used in JNI. - -*******************************************************************************/ - -bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) -{ - bool result; - threadobject *t; - utf *u; - java_handle_t *name; - java_handle_t *group; - - /* If the current thread has already been attached, this operation - is a no-op. */ - - result = thread_current_is_attached(); - - if (result == true) - return true; - - /* Enter the join-mutex, so if the main-thread is currently - waiting to join all threads, the number of non-daemon threads - is correct. */ - - threads_mutex_join_lock(); - - /* Create internal thread data structure. */ - - t = thread_new(); - - /* Thread is a Java thread and running. */ - - t->flags = THREAD_FLAG_JAVA; - - if (isdaemon) - t->flags |= THREAD_FLAG_DAEMON; - - /* Store the internal thread data-structure in the TSD. */ - - thread_set_current(t); - - /* The thread is flagged and (non-)daemon thread, we can leave the - mutex. */ - - threads_mutex_join_unlock(); - - DEBUGTHREADS("attaching", t); - - /* Get the thread name. */ - - if (vm_aargs != NULL) { - u = utf_new_char(vm_aargs->name); - } - else { - u = utf_null; - } - - name = javastring_new(u); - -#if defined(ENABLE_JAVASE) - /* Get the threadgroup. */ - - if (vm_aargs != NULL) - group = (java_handle_t *) vm_aargs->group; - else - group = NULL; - - /* If no threadgroup was given, use the main threadgroup. */ - - if (group == NULL) - group = threadgroup_main; -#endif - -#if defined(ENABLE_INTRP) - /* create interpreter stack */ - - if (opt_intrp) { - MSET(intrp_main_stack, 0, u1, opt_stacksize); - thread->_global_sp = (Cell *) (intrp_main_stack + opt_stacksize); - } -#endif - - /* Create the Java thread object. */ - - if (!thread_create_object(t, name, group)) - return false; - - /* The thread is completely initialized. */ - - thread_set_state_runnable(t); - - return true; -} - - -/* thread_fprint_name ********************************************************** - - Print the name of the given thread to the given stream. - - ARGUMENTS: - t ........ thread data-structure - stream ... stream to print to - -*******************************************************************************/ - -void thread_fprint_name(threadobject *t, FILE *stream) -{ - java_lang_Thread *to; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_String *name; -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - java_chararray_t *name; -#endif - - to = (java_lang_Thread *) thread_get_object(t); - - if (to == NULL) - vm_abort(""); - - LLNI_field_get_ref(to, name, name); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - javastring_fprint((java_handle_t *) name, stream); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - /* FIXME: In OpenJDK and CLDC the name is a char[]. */ - /* FIXME This prints to stdout. */ - utf_display_printable_ascii(utf_null); - -#else -# error unknown classpath configuration -#endif -} - - -/* thread_print_info *********************************************************** - - Print information of the passed thread. - - ARGUMENTS: - t ... thread data-structure. - -*******************************************************************************/ - -void thread_print_info(threadobject *t) -{ - java_lang_Thread *to; - int state; - - /* If the thread is currently in initalization, don't print it. */ - - to = (java_lang_Thread *) thread_get_object(t); - - /* Print as much as we can when we are in state NEW. */ - - if (to != NULL) { - /* Print thread name. */ - - printf("\""); - thread_fprint_name(t, stdout); - printf("\""); - } - else { - } - - if (thread_is_daemon(t)) - printf(" daemon"); - - if (to != NULL) { - printf(" prio=%d", LLNI_field_direct(to, priority)); - } - -#if SIZEOF_VOID_P == 8 - printf(" t=0x%016lx tid=0x%016lx (%ld)", - (ptrint) t, (ptrint) t->tid, (ptrint) t->tid); -#else - printf(" t=0x%08x tid=0x%08x (%d)", - (ptrint) t, (ptrint) t->tid, (ptrint) t->tid); -#endif - - printf(" index=%d", t->index); - - /* Print thread state. */ - - state = cacaothread_get_state(t); - - switch (state) { - case THREAD_STATE_NEW: - printf(" new"); - break; - case THREAD_STATE_RUNNABLE: - printf(" runnable"); - break; - case THREAD_STATE_BLOCKED: - printf(" blocked"); - break; - case THREAD_STATE_WAITING: - printf(" waiting"); - break; - case THREAD_STATE_TIMED_WAITING: - printf(" waiting on condition"); - break; - case THREAD_STATE_TERMINATED: - printf(" terminated"); - break; - default: - vm_abort("thread_print_info: unknown thread state %d", state); - } -} - - -/* threads_get_current_tid ***************************************************** - - Return the tid of the current thread. - - RETURN VALUE: - the current tid - -*******************************************************************************/ - -intptr_t threads_get_current_tid(void) -{ - threadobject *thread; - - thread = THREADOBJECT; - - /* this may happen during bootstrap */ - - if (thread == NULL) - return 0; - - return (intptr_t) thread->tid; -} - - -/* thread_set_state_runnable *************************************************** - - Set the current state of the given thread to THREAD_STATE_RUNNABLE. - - NOTE: If the thread has already terminated, don't set the state. - This is important for threads_detach_thread. - -*******************************************************************************/ - -void thread_set_state_runnable(threadobject *t) -{ - /* Set the state inside a lock. */ - - threadlist_lock(); - - if (t->state != THREAD_STATE_TERMINATED) { - t->state = THREAD_STATE_RUNNABLE; - - DEBUGTHREADS("is RUNNABLE", t); - } - - threadlist_unlock(); -} - - -/* thread_set_state_waiting **************************************************** - - Set the current state of the given thread to THREAD_STATE_WAITING. - - NOTE: If the thread has already terminated, don't set the state. - This is important for threads_detach_thread. - -*******************************************************************************/ - -void thread_set_state_waiting(threadobject *t) -{ - /* Set the state inside a lock. */ - - threadlist_lock(); - - if (t->state != THREAD_STATE_TERMINATED) { - t->state = THREAD_STATE_WAITING; - - DEBUGTHREADS("is WAITING", t); - } - - threadlist_unlock(); -} - - -/* thread_set_state_timed_waiting ********************************************** - - Set the current state of the given thread to - THREAD_STATE_TIMED_WAITING. - - NOTE: If the thread has already terminated, don't set the state. - This is important for threads_detach_thread. - -*******************************************************************************/ - -void thread_set_state_timed_waiting(threadobject *t) -{ - /* Set the state inside a lock. */ - - threadlist_lock(); - - if (t->state != THREAD_STATE_TERMINATED) { - t->state = THREAD_STATE_TIMED_WAITING; - - DEBUGTHREADS("is TIMED_WAITING", t); - } - - threadlist_unlock(); -} - - -/* thread_set_state_terminated ************************************************* - - Set the current state of the given thread to - THREAD_STATE_TERMINATED. - -*******************************************************************************/ - -void thread_set_state_terminated(threadobject *t) -{ - /* Set the state inside a lock. */ - - threadlist_lock(); - - t->state = THREAD_STATE_TERMINATED; - - DEBUGTHREADS("is TERMINATED", t); - - threadlist_unlock(); -} - - -/* thread_get_thread ********************************************************** - - Return the thread data structure of the given Java thread object. - - ARGUMENTS: - h ... java.lang.{VM}Thread object - - RETURN VALUE: - the thread object - -*******************************************************************************/ - -threadobject *thread_get_thread(java_handle_t *h) -{ - threadobject *t; -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_VMThread *vmto; - java_lang_Object *to; -#endif -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - bool equal; -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - vmto = (java_lang_VMThread *) h; - - LLNI_field_get_val(vmto, vmdata, to); - - t = (threadobject *) to; - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* XXX This is just a quick hack. */ - - threadlist_lock(); - - for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { - LLNI_equals(t->object, h, equal); - - if (equal == true) - break; - } - - threadlist_unlock(); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - log_println("threads_get_thread: IMPLEMENT ME!"); - -#else -# error unknown classpath configuration -#endif - - return t; -} - - -/* threads_thread_is_alive ***************************************************** - - Returns if the give thread is alive. - -*******************************************************************************/ - -bool threads_thread_is_alive(threadobject *t) -{ - int state; - - state = cacaothread_get_state(t); - - switch (state) { - case THREAD_STATE_NEW: - case THREAD_STATE_TERMINATED: - return false; - - case THREAD_STATE_RUNNABLE: - case THREAD_STATE_BLOCKED: - case THREAD_STATE_WAITING: - case THREAD_STATE_TIMED_WAITING: - return true; - - default: - vm_abort("threads_thread_is_alive: unknown thread state %d", state); - } - - /* keep compiler happy */ - - return false; -} - - -/* threads_dump **************************************************************** - - Dumps info for all threads running in the JVM. This function is - called when SIGQUIT (-\) is sent to CACAO. - -*******************************************************************************/ - -void threads_dump(void) -{ - threadobject *t; - - /* XXX we should stop the world here */ - - /* Lock the thread lists. */ - - threadlist_lock(); - - printf("Full thread dump CACAO "VERSION":\n"); - - /* iterate over all started threads */ - - for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { - /* ignore threads which are in state NEW */ - if (t->state == THREAD_STATE_NEW) - continue; - -#if defined(ENABLE_GC_CACAO) - /* Suspend the thread. */ - /* XXX Is the suspend reason correct? */ - - if (threads_suspend_thread(t, SUSPEND_REASON_JNI) == false) - vm_abort("threads_dump: threads_suspend_thread failed"); -#endif - - /* Print thread info. */ - - printf("\n"); - thread_print_info(t); - printf("\n"); - - /* Print trace of thread. */ - - stacktrace_print_of_thread(t); - -#if defined(ENABLE_GC_CACAO) - /* Resume the thread. */ - - if (threads_resume_thread(t) == false) - vm_abort("threads_dump: threads_resume_thread failed"); -#endif - } - - /* Unlock the thread lists. */ - - threadlist_unlock(); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/thread.cpp b/src/threads/thread.cpp new file mode 100644 index 000000000..f41502504 --- /dev/null +++ b/src/threads/thread.cpp @@ -0,0 +1,1253 @@ +/* src/threads/thread.cpp - machine independent thread functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#if defined(ENABLE_GC_BOEHM) +/* We need to include Boehm's gc.h here for GC_register_my_thread and + friends. */ +# include "mm/boehm-gc/include/gc.h" +#endif + +#include "native/llni.h" +#include "native/native.h" + +#include "threads/lock-common.h" +#include "threads/threadlist.h" +#include "threads/thread.hpp" + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/string.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/jit/stacktrace.hpp" + + +/* global variables ***********************************************************/ + +static methodinfo *thread_method_init; +static java_handle_t *threadgroup_system; +static java_handle_t *threadgroup_main; + +#if defined(__LINUX__) +/* XXX Remove for exact-GC. */ +bool threads_pthreads_implementation_nptl; +#endif + + +/* static functions ***********************************************************/ + +static void thread_create_initial_threadgroups(void); +static void thread_create_initial_thread(void); +static threadobject *thread_new(void); + + +/* threads_preinit ************************************************************* + + Do some early initialization of stuff required. + +*******************************************************************************/ + +void threads_preinit(void) +{ + threadobject *mainthread; +#if defined(__LINUX__) && defined(_CS_GNU_LIBPTHREAD_VERSION) + char *pathbuf; + size_t len; +#endif + + TRACESUBSYSTEMINITIALIZATION("threads_preinit"); + +#if defined(__LINUX__) + /* XXX Remove for exact-GC. */ + + /* On Linux we need to check the pthread implementation. */ + + /* _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2) */ + /* If the glibc is a pre-2.3.2 version, we fall back to + linuxthreads. */ + +# if defined(_CS_GNU_LIBPTHREAD_VERSION) + len = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0); + + /* Some systems return as length 0 (maybe cross-compilation + related). In this case we also fall back to linuxthreads. */ + + if (len > 0) { + pathbuf = MNEW(char, len); + + (void) confstr(_CS_GNU_LIBPTHREAD_VERSION, pathbuf, len); + + if (strstr(pathbuf, "NPTL") != NULL) + threads_pthreads_implementation_nptl = true; + else + threads_pthreads_implementation_nptl = false; + } + else + threads_pthreads_implementation_nptl = false; +# else + threads_pthreads_implementation_nptl = false; +# endif +#endif + + /* Initialize the threads implementation (sets the thinlock on the + main thread). */ + + threads_impl_preinit(); + + /* Create internal thread data-structure for the main thread. */ + + mainthread = thread_new(); + + /* The main thread should always have index 1. */ + + if (mainthread->index != 1) + vm_abort("threads_preinit: main thread index not 1: %d != 1", + mainthread->index); + + /* thread is a Java thread and running */ + + mainthread->flags |= THREAD_FLAG_JAVA; + mainthread->state = THREAD_STATE_RUNNABLE; + + /* Store the internal thread data-structure in the TSD. */ + + thread_set_current(mainthread); +} + + +/* threads_init **************************************************************** + + Initialize the main thread. + +*******************************************************************************/ + +void threads_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("threads_init"); + + /* Create the system and main thread groups. */ + + thread_create_initial_threadgroups(); + + /* Cache the java.lang.Thread initialization method. */ + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + thread_method_init = + class_resolveclassmethod(class_java_lang_Thread, + utf_init, + utf_new_char("(Ljava/lang/VMThread;Ljava/lang/String;IZ)V"), + class_java_lang_Thread, + true); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + thread_method_init = + class_resolveclassmethod(class_java_lang_Thread, + utf_init, + utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"), + class_java_lang_Thread, + true); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + thread_method_init = + class_resolveclassmethod(class_java_lang_Thread, + utf_init, + utf_java_lang_String__void, + class_java_lang_Thread, + true); + +#else +# error unknown classpath configuration +#endif + + if (thread_method_init == NULL) + vm_abort("threads_init: failed to resolve thread init method"); + + thread_create_initial_thread(); +} + + +/* thread_create_object ******************************************************** + + Create a Java thread object for the given thread data-structure, + initializes it and adds the thread to the threadgroup. + + ARGUMENTS: + + t ....... thread + name .... thread name + group ... threadgroup + + RETURN: + +*******************************************************************************/ + +static bool thread_create_object(threadobject *t, java_handle_t *name, java_handle_t *group) +{ + /* Create a java.lang.Thread Java object. */ + + java_handle_t* h = builtin_new(class_java_lang_Thread); + + if (h == NULL) + return false; + + java_lang_Thread jlt(h); + + // Set the Java object in the thread data-structure. This + // indicates that the thread is attached to the VM. + thread_set_object(t, jlt.get_handle()); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + h = builtin_new(class_java_lang_VMThread); + + if (h == NULL) + return false; + + // Create and initialize a java.lang.VMThread object. + java_lang_VMThread jlvmt(h, jlt.get_handle(), t); + + /* Call: + java.lang.Thread.(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */ + + bool isdaemon = thread_is_daemon(t); + + (void) vm_call_method(thread_method_init, jlt.get_handle(), jlvmt.get_handle(), + name, NORM_PRIORITY, isdaemon); + + if (exceptions_get_exception()) + return false; + + // Set the ThreadGroup in the Java thread object. + jlt.set_group(group); + + /* Add thread to the threadgroup. */ + + classinfo* c; + LLNI_class_get(group, c); + + methodinfo* m = class_resolveclassmethod(c, + utf_addThread, + utf_java_lang_Thread__V, + class_java_lang_ThreadGroup, + true); + + if (m == NULL) + return false; + + (void) vm_call_method(m, group, jlt.get_handle()); + + if (exceptions_get_exception()) + return false; + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + /* Set the priority. java.lang.Thread. requires it because + it sets the priority of the current thread to the parent's one + (which is the current thread in this case). */ + jlt.set_priority(NORM_PRIORITY); + + // Call: java.lang.Thread.(Ljava/lang/ThreadGroup;Ljava/lang/String;)V + + (void) vm_call_method(thread_method_init, jlt.get_handle(), group, name); + + if (exceptions_get_exception()) + return false; + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + // Set the thread data-structure in the Java thread object. + jlt.set_vm_thread(t); + + // Call: public Thread(Ljava/lang/String;)V + (void) vm_call_method(thread_method_init, jlt.get_handle(), name); + + if (exceptions_get_exception()) + return false; + +#else +# error unknown classpath configuration +#endif + + return true; +} + + +/* thread_create_initial_threadgroups ****************************************** + + Create the initial threadgroups. + + GNU Classpath: + Create the main threadgroup only and set the system + threadgroup to the main threadgroup. + + SUN: + Create the system and main threadgroup. + + CLDC: + This function is a no-op. + +*******************************************************************************/ + +static void thread_create_initial_threadgroups(void) +{ +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + /* Allocate and initialize the main thread group. */ + + threadgroup_main = native_new_and_init(class_java_lang_ThreadGroup); + + if (threadgroup_main == NULL) + vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup"); + + /* Use the same threadgroup for system as for main. */ + + threadgroup_system = threadgroup_main; + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + java_handle_t *name; + methodinfo *m; + + /* Allocate and initialize the system thread group. */ + + threadgroup_system = native_new_and_init(class_java_lang_ThreadGroup); + + if (threadgroup_system == NULL) + vm_abort("thread_create_initial_threadgroups: failed to allocate system threadgroup"); + + /* Allocate and initialize the main thread group. */ + + threadgroup_main = builtin_new(class_java_lang_ThreadGroup); + + if (threadgroup_main == NULL) + vm_abort("thread_create_initial_threadgroups: failed to allocate main threadgroup"); + + name = javastring_new(utf_main); + + m = class_resolveclassmethod(class_java_lang_ThreadGroup, + utf_init, + utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V, + class_java_lang_ThreadGroup, + true); + + if (m == NULL) + vm_abort("thread_create_initial_threadgroups: failed to resolve threadgroup init method"); + + (void) vm_call_method(m, threadgroup_main, threadgroup_system, name); + + if (exceptions_get_exception()) + vm_abort("thread_create_initial_threadgroups: exception while initializing main threadgroup"); + +# else +# error unknown classpath configuration +# endif +#endif +} + + +/* thread_create_initial_thread *********************************************** + + Create the initial thread: main + +*******************************************************************************/ + +static void thread_create_initial_thread(void) +{ + threadobject *t; + java_handle_t *name; + + /* Get the main-thread (NOTE: The main thread is always the first + thread in the list). */ + + t = threadlist_first(); + + /* The thread name. */ + + name = javastring_new(utf_main); + +#if defined(ENABLE_INTRP) + /* create interpreter stack */ + + if (opt_intrp) { + MSET(intrp_main_stack, 0, u1, opt_stacksize); + mainthread->_global_sp = (Cell*) (intrp_main_stack + opt_stacksize); + } +#endif + + /* Create the Java thread object. */ + + if (!thread_create_object(t, name, threadgroup_main)) + vm_abort("thread_create_initial_thread: failed to create Java object"); + + /* Initialize the implementation specific bits. */ + + threads_impl_init(); + + DEBUGTHREADS("starting (main)", t); +} + + +/* thread_new ****************************************************************** + + Allocates and initializes an internal thread data-structure and + adds it to the threads list. + +*******************************************************************************/ + +static threadobject *thread_new(void) +{ + int32_t index; + threadobject *t; + + /* Lock the thread lists */ + + threadlist_lock(); + + index = threadlist_get_free_index(); + + /* Allocate a thread data structure. */ + + /* First, try to get one from the free-list. */ + + t = threadlist_free_first(); + + if (t != NULL) { + /* Remove from free list. */ + + threadlist_free_remove(t); + + /* Equivalent of MZERO on the else path */ + + threads_impl_thread_clear(t); + } + else { +#if defined(ENABLE_GC_BOEHM) + t = GCNEW_UNCOLLECTABLE(threadobject, 1); +#else + t = NEW(threadobject); +#endif + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_threadobject += sizeof(threadobject); +#endif + + /* Clear memory. */ + + MZERO(t, threadobject, 1); + + // Initialize the mutex and the condition. + t->flc_lock = new Mutex(); + t->flc_cond = new Condition(); + + t->waitmutex = new Mutex(); + t->waitcond = new Condition(); + + t->suspendmutex = new Mutex(); + t->suspendcond = new Condition(); + +#if defined(ENABLE_TLH) + tlh_init(&(t->tlh)); +#endif + +#if defined(ENABLE_GC_CACAO) + /* Register reference to java.lang.Thread with the GC. */ + /* FIXME is it ok to do this only once? */ + + gc_reference_register(&(t->object), GC_REFTYPE_THREADOBJECT); + gc_reference_register(&(t->_exceptionptr), GC_REFTYPE_THREADOBJECT); +#endif + + t->_dumpmemory = new DumpMemory(); + } + + /* Pre-compute the thinlock-word. */ + + assert(index != 0); + + t->index = index; + t->thinlock = lock_pre_compute_thinlock(t->index); + t->flags = 0; + t->state = THREAD_STATE_NEW; + +#if defined(ENABLE_GC_CACAO) + t->flags |= THREAD_FLAG_IN_NATIVE; +#endif + + /* Initialize the implementation-specific bits. */ + + threads_impl_thread_reuse(t); + + /* Add the thread to the thread list. */ + + threadlist_add(t); + + /* Unlock the thread lists. */ + + threadlist_unlock(); + + return t; +} + + +/* thread_free ***************************************************************** + + Remove the thread from the threads-list and free the internal + thread data structure. The thread index is added to the + thread-index free-list. + + IN: + t ... thread data structure + +*******************************************************************************/ + +void thread_free(threadobject *t) +{ + /* Lock the thread lists. */ + + threadlist_lock(); + + /* Remove the thread from the thread-list. */ + + threadlist_remove(t); + + /* Add the thread index to the free list. */ + + threadlist_index_add(t->index); + + /* Set the reference to the Java object to NULL. */ + + thread_set_object(t, NULL); + + /* Add the thread data structure to the free list. */ + + threadlist_free_add(t); + + /* Unlock the thread lists. */ + + threadlist_unlock(); +} + + +/* threads_thread_start_internal *********************************************** + + Start an internal thread in the JVM. No Java thread objects exists + so far. + + IN: + name.......UTF-8 name of the thread + f..........function pointer to C function to start + +*******************************************************************************/ + +bool threads_thread_start_internal(utf *name, functionptr f) +{ + threadobject *t; + + /* Enter the join-mutex, so if the main-thread is currently + waiting to join all threads, the number of non-daemon threads + is correct. */ + + threads_mutex_join_lock(); + + /* Create internal thread data-structure. */ + + t = thread_new(); + + t->flags |= THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON; + + /* The thread is flagged as (non-)daemon thread, we can leave the + mutex. */ + + threads_mutex_join_unlock(); + + /* Create the Java thread object. */ + + if (!thread_create_object(t, javastring_new(name), threadgroup_system)) + return false; + + /* Start the thread. */ + + threads_impl_thread_start(t, f); + + /* everything's ok */ + + return true; +} + + +/* threads_thread_start ******************************************************** + + Start a Java thread in the JVM. Only the java thread object exists + so far. + + IN: + object.....the java thread object java.lang.Thread + +*******************************************************************************/ + +void threads_thread_start(java_handle_t *object) +{ + java_lang_Thread jlt(object); + + /* Enter the join-mutex, so if the main-thread is currently + waiting to join all threads, the number of non-daemon threads + is correct. */ + + threads_mutex_join_lock(); + + /* Create internal thread data-structure. */ + + threadobject* t = thread_new(); + + /* this is a normal Java thread */ + + t->flags |= THREAD_FLAG_JAVA; + +#if defined(ENABLE_JAVASE) + /* Is this a daemon thread? */ + + if (jlt.get_daemon() == true) + t->flags |= THREAD_FLAG_DAEMON; +#endif + + /* The thread is flagged and (non-)daemon thread, we can leave the + mutex. */ + + threads_mutex_join_unlock(); + + /* Link the two objects together. */ + + thread_set_object(t, object); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + /* Get the java.lang.VMThread object and do some sanity checks. */ + java_lang_VMThread jlvmt(jlt.get_vmThread()); + + assert(jlvmt.get_handle() != NULL); + assert(jlvmt.get_vmdata() == NULL); + + jlvmt.set_vmdata(t); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + // Nothing to do. + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + jlt.set_vm_thread(t); + +#else +# error unknown classpath configuration +#endif + + /* Start the thread. Don't pass a function pointer (NULL) since + we want Thread.run()V here. */ + + threads_impl_thread_start(t, NULL); +} + + +/** + * Attaches the current thread to the VM. + * + * @param vm_aargs Attach arguments. + * @param isdaemon true if the attached thread should be a daemon + * thread. + * + * @return true on success, false otherwise. + */ +bool thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) +{ + bool result; + threadobject *t; + utf *u; + java_handle_t *name; + java_handle_t *group; + + /* If the current thread has already been attached, this operation + is a no-op. */ + + result = thread_current_is_attached(); + + if (result == true) + return true; + + /* Enter the join-mutex, so if the main-thread is currently + waiting to join all threads, the number of non-daemon threads + is correct. */ + + threads_mutex_join_lock(); + + /* Create internal thread data structure. */ + + t = thread_new(); + + /* Thread is a Java thread and running. */ + + t->flags = THREAD_FLAG_JAVA; + + if (isdaemon) + t->flags |= THREAD_FLAG_DAEMON; + + /* Store the internal thread data-structure in the TSD. */ + + thread_set_current(t); + + /* The thread is flagged and (non-)daemon thread, we can leave the + mutex. */ + + threads_mutex_join_unlock(); + + DEBUGTHREADS("attaching", t); + + /* Get the thread name. */ + + if (vm_aargs != NULL) { + u = utf_new_char(vm_aargs->name); + } + else { + u = utf_null; + } + + name = javastring_new(u); + +#if defined(ENABLE_JAVASE) + /* Get the threadgroup. */ + + if (vm_aargs != NULL) + group = (java_handle_t *) vm_aargs->group; + else + group = NULL; + + /* If no threadgroup was given, use the main threadgroup. */ + + if (group == NULL) + group = threadgroup_main; +#endif + +#if defined(ENABLE_INTRP) + /* create interpreter stack */ + + if (opt_intrp) { + MSET(intrp_main_stack, 0, u1, opt_stacksize); + thread->_global_sp = (Cell *) (intrp_main_stack + opt_stacksize); + } +#endif + + /* Create the Java thread object. */ + + if (!thread_create_object(t, name, group)) + return false; + + /* The thread is completely initialized. */ + + thread_set_state_runnable(t); + + return true; +} + + +/** + * Attaches the current external thread to the VM. This function is + * called by JNI's AttachCurrentThread. + * + * @param vm_aargs Attach arguments. + * @param isdaemon true if the attached thread should be a daemon + * thread. + * + * @return true on success, false otherwise. + */ +bool thread_attach_current_external_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon) +{ + int result; + +#if defined(ENABLE_GC_BOEHM) + struct GC_stack_base sb; +#endif + +#if defined(ENABLE_GC_BOEHM) + /* Register the thread with Boehm-GC. This must happen before the + thread allocates any memory from the GC heap.*/ + + result = GC_get_stack_base(&sb); + + if (result != GC_SUCCESS) + vm_abort("threads_attach_current_thread: GC_get_stack_base failed"); + + GC_register_my_thread(&sb); +#endif + + result = thread_attach_current_thread(vm_aargs, isdaemon); + + if (result == false) { +#if defined(ENABLE_GC_BOEHM) + /* Unregister the thread. */ + + GC_unregister_my_thread(); +#endif + + return false; + } + + return true; +} + + +/** + * Detaches the current external thread from the VM. This function is + * called by JNI's DetachCurrentThread. + * + * @return true on success, false otherwise. + */ +bool thread_detach_current_external_thread(void) +{ + int result; + + result = thread_detach_current_thread(); + + if (result == false) + return false; + +#if defined(ENABLE_GC_BOEHM) + /* Unregister the thread with Boehm-GC. This must happen after + the thread allocates any memory from the GC heap. */ + + /* Don't detach the main thread. This is a workaround for + OpenJDK's java binary. */ + if (thread_get_current()->index != 1) + GC_unregister_my_thread(); +#endif + + return true; +} + + +/* thread_fprint_name ********************************************************** + + Print the name of the given thread to the given stream. + + ARGUMENTS: + t ........ thread data-structure + stream ... stream to print to + +*******************************************************************************/ + +void thread_fprint_name(threadobject *t, FILE *stream) +{ + if (thread_get_object(t) == NULL) + vm_abort(""); + + java_lang_Thread jlt(thread_get_object(t)); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + java_handle_t* name = jlt.get_name(); + javastring_fprint(name, stream); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + /* FIXME: In OpenJDK and CLDC the name is a char[]. */ + java_chararray_t *name; + + /* FIXME This prints to stdout. */ + utf_display_printable_ascii(utf_null); + +#else +# error unknown classpath configuration +#endif +} + + +/* thread_print_info *********************************************************** + + Print information of the passed thread. + + ARGUMENTS: + t ... thread data-structure. + +*******************************************************************************/ + +void thread_print_info(threadobject *t) +{ + java_lang_Thread jlt(thread_get_object(t)); + + /* Print as much as we can when we are in state NEW. */ + + if (jlt.get_handle() != NULL) { + /* Print thread name. */ + + printf("\""); + thread_fprint_name(t, stdout); + printf("\""); + } + else { + } + + if (thread_is_daemon(t)) + printf(" daemon"); + + if (jlt.get_handle() != NULL) { + printf(" prio=%d", jlt.get_priority()); + } + +#if SIZEOF_VOID_P == 8 + printf(" t=0x%016lx tid=0x%016lx (%ld)", + (ptrint) t, (ptrint) t->tid, (ptrint) t->tid); +#else + printf(" t=0x%08x tid=0x%08x (%d)", + (ptrint) t, (ptrint) t->tid, (ptrint) t->tid); +#endif + + printf(" index=%d", t->index); + + /* Print thread state. */ + + int state = cacaothread_get_state(t); + + switch (state) { + case THREAD_STATE_NEW: + printf(" new"); + break; + case THREAD_STATE_RUNNABLE: + printf(" runnable"); + break; + case THREAD_STATE_BLOCKED: + printf(" blocked"); + break; + case THREAD_STATE_WAITING: + printf(" waiting"); + break; + case THREAD_STATE_TIMED_WAITING: + printf(" waiting on condition"); + break; + case THREAD_STATE_TERMINATED: + printf(" terminated"); + break; + default: + vm_abort("thread_print_info: unknown thread state %d", state); + } +} + + +/* threads_get_current_tid ***************************************************** + + Return the tid of the current thread. + + RETURN VALUE: + the current tid + +*******************************************************************************/ + +intptr_t threads_get_current_tid(void) +{ + threadobject *thread; + + thread = THREADOBJECT; + + /* this may happen during bootstrap */ + + if (thread == NULL) + return 0; + + return (intptr_t) thread->tid; +} + + +/* thread_set_state_runnable *************************************************** + + Set the current state of the given thread to THREAD_STATE_RUNNABLE. + + NOTE: If the thread has already terminated, don't set the state. + This is important for threads_detach_thread. + +*******************************************************************************/ + +void thread_set_state_runnable(threadobject *t) +{ + /* Set the state inside a lock. */ + + threadlist_lock(); + + if (t->state != THREAD_STATE_TERMINATED) { + t->state = THREAD_STATE_RUNNABLE; + + DEBUGTHREADS("is RUNNABLE", t); + } + + threadlist_unlock(); +} + + +/* thread_set_state_waiting **************************************************** + + Set the current state of the given thread to THREAD_STATE_WAITING. + + NOTE: If the thread has already terminated, don't set the state. + This is important for threads_detach_thread. + +*******************************************************************************/ + +void thread_set_state_waiting(threadobject *t) +{ + /* Set the state inside a lock. */ + + threadlist_lock(); + + if (t->state != THREAD_STATE_TERMINATED) { + t->state = THREAD_STATE_WAITING; + + DEBUGTHREADS("is WAITING", t); + } + + threadlist_unlock(); +} + + +/* thread_set_state_timed_waiting ********************************************** + + Set the current state of the given thread to + THREAD_STATE_TIMED_WAITING. + + NOTE: If the thread has already terminated, don't set the state. + This is important for threads_detach_thread. + +*******************************************************************************/ + +void thread_set_state_timed_waiting(threadobject *t) +{ + /* Set the state inside a lock. */ + + threadlist_lock(); + + if (t->state != THREAD_STATE_TERMINATED) { + t->state = THREAD_STATE_TIMED_WAITING; + + DEBUGTHREADS("is TIMED_WAITING", t); + } + + threadlist_unlock(); +} + + +/* thread_set_state_terminated ************************************************* + + Set the current state of the given thread to + THREAD_STATE_TERMINATED. + +*******************************************************************************/ + +void thread_set_state_terminated(threadobject *t) +{ + /* Set the state inside a lock. */ + + threadlist_lock(); + + t->state = THREAD_STATE_TERMINATED; + + DEBUGTHREADS("is TERMINATED", t); + + threadlist_unlock(); +} + + +/* thread_get_thread ********************************************************** + + Return the thread data structure of the given Java thread object. + + ARGUMENTS: + h ... java.lang.{VM}Thread object + + RETURN VALUE: + the thread object + +*******************************************************************************/ + +threadobject *thread_get_thread(java_handle_t *h) +{ +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + java_lang_VMThread jlvmt(h); + threadobject* t = jlvmt.get_vmdata(); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + /* XXX This is just a quick hack. */ + threadobject* t; + bool equal; + + threadlist_lock(); + + for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { + LLNI_equals(t->object, h, equal); + + if (equal == true) + break; + } + + threadlist_unlock(); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + log_println("threads_get_thread: IMPLEMENT ME!"); + threadobject* t = NULL; + +#else +# error unknown classpath configuration +#endif + + return t; +} + + +/* threads_thread_is_alive ***************************************************** + + Returns if the give thread is alive. + +*******************************************************************************/ + +bool threads_thread_is_alive(threadobject *t) +{ + int state; + + state = cacaothread_get_state(t); + + switch (state) { + case THREAD_STATE_NEW: + case THREAD_STATE_TERMINATED: + return false; + + case THREAD_STATE_RUNNABLE: + case THREAD_STATE_BLOCKED: + case THREAD_STATE_WAITING: + case THREAD_STATE_TIMED_WAITING: + return true; + + default: + vm_abort("threads_thread_is_alive: unknown thread state %d", state); + } + + /* keep compiler happy */ + + return false; +} + + +/* threads_dump **************************************************************** + + Dumps info for all threads running in the JVM. This function is + called when SIGQUIT (-\) is sent to CACAO. + +*******************************************************************************/ + +void threads_dump(void) +{ + threadobject *t; + + /* XXX we should stop the world here */ + + /* Lock the thread lists. */ + + threadlist_lock(); + + printf("Full thread dump CACAO "VERSION":\n"); + + /* iterate over all started threads */ + + for (t = threadlist_first(); t != NULL; t = threadlist_next(t)) { + /* ignore threads which are in state NEW */ + if (t->state == THREAD_STATE_NEW) + continue; + +#if defined(ENABLE_GC_CACAO) + /* Suspend the thread. */ + /* XXX Is the suspend reason correct? */ + + if (threads_suspend_thread(t, SUSPEND_REASON_JNI) == false) + vm_abort("threads_dump: threads_suspend_thread failed"); +#endif + + /* Print thread info. */ + + printf("\n"); + thread_print_info(t); + printf("\n"); + + /* Print trace of thread. */ + + stacktrace_print_of_thread(t); + +#if defined(ENABLE_GC_CACAO) + /* Resume the thread. */ + + if (threads_resume_thread(t) == false) + vm_abort("threads_dump: threads_resume_thread failed"); +#endif + } + + /* Unlock the thread lists. */ + + threadlist_unlock(); +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/thread.h b/src/threads/thread.h deleted file mode 100644 index 50099e30b..000000000 --- a/src/threads/thread.h +++ /dev/null @@ -1,349 +0,0 @@ -/* src/threads/thread.h - machine independent thread functions - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _THREAD_H -#define _THREAD_H - -#include "config.h" - -#include "vmcore/system.h" - -#if defined(ENABLE_THREADS) -# include "threads/posix/thread-posix.h" -#else -# include "threads/none/thread-none.h" -#endif - -#include "vm/types.h" - -#include "vm/global.h" - -#include "native/jni.h" -#include "native/llni.h" - -#include "vmcore/utf8.h" - - -/* only define the following stuff with thread enabled ************************/ - -#if defined(ENABLE_THREADS) - -/* thread states **************************************************************/ - -#define THREAD_STATE_NEW 0 -#define THREAD_STATE_RUNNABLE 1 -#define THREAD_STATE_BLOCKED 2 -#define THREAD_STATE_WAITING 3 -#define THREAD_STATE_TIMED_WAITING 4 -#define THREAD_STATE_TERMINATED 5 - - -/* thread priorities **********************************************************/ - -#define MIN_PRIORITY 1 -#define NORM_PRIORITY 5 -#define MAX_PRIORITY 10 - - -/* debug **********************************************************************/ - -#if !defined(NDEBUG) -# define DEBUGTHREADS(message, thread) \ - do { \ - if (opt_DebugThreads) { \ - printf("[Thread %-16s: ", message); \ - thread_print_info(thread); \ - printf("]\n"); \ - } \ - } while (0) -#else -# define DEBUGTHREADS(message, thread) -#endif - - -/* global variables ***********************************************************/ - -#if defined(__LINUX__) -/* XXX Remove for exact-GC. */ -extern bool threads_pthreads_implementation_nptl; -#endif - - -/* inline functions ***********************************************************/ - -/* thread_get_object *********************************************************** - - Return the Java for the given thread. - - ARGUMENTS: - t ... thread - - RETURN: - the Java object - -*******************************************************************************/ - -inline static java_handle_t *thread_get_object(threadobject *t) -{ - return LLNI_WRAP(t->object); -} - - -/* threads_thread_set_object *************************************************** - - Set the Java object for the given thread. - - ARGUMENTS: - t ... thread - o ... Java object - -*******************************************************************************/ - -inline static void thread_set_object(threadobject *t, java_handle_t *o) -{ - t->object = LLNI_DIRECT(o); -} - - -/* thread_get_current_object ************************************************** - - Return the Java object of the current thread. - - RETURN VALUE: - the Java object - -*******************************************************************************/ - -inline static java_handle_t *thread_get_current_object(void) -{ - threadobject *t; - java_handle_t *o; - - t = THREADOBJECT; - o = thread_get_object(t); - - return o; -} - - -/* cacaothread_get_state ******************************************************* - - Returns the current state of the given thread. - - ARGUMENTS: - t ... the thread to check - - RETURN: - thread state - -*******************************************************************************/ - -inline static int cacaothread_get_state(threadobject *t) -{ - return t->state; -} - - -/* thread_is_attached ********************************************************** - - Returns if the given thread is attached to the VM. - - ARGUMENTS: - t ... the thread to check - - RETURN: - true .... the thread is attached to the VM - false ... the thread is not - -*******************************************************************************/ - -inline static bool thread_is_attached(threadobject *t) -{ - java_handle_t *o; - - o = thread_get_object(t); - - if (o != NULL) - return true; - else - return false; -} - - -/* thread_is_interrupted ******************************************************* - - Check if the given thread has been interrupted. - - ARGUMENTS: - t ... the thread to check - - RETURN VALUE: - true, if the given thread had been interrupted - -*******************************************************************************/ - -inline static bool thread_is_interrupted(threadobject *t) -{ - return t->interrupted; -} - - -/* thread_set_interrupted ****************************************************** - - Set the interrupted flag to the given value. - - ARGUMENTS: - interrupted ... value to set - -*******************************************************************************/ - -inline static void thread_set_interrupted(threadobject *t, bool interrupted) -{ - mutex_lock(&t->waitmutex); - - /* Set interrupted flag. */ - - t->interrupted = interrupted; - - mutex_unlock(&t->waitmutex); -} - - -/* thread_is_daemon ************************************************************ - - Returns if the given thread is a daemon thread. - - ARGUMENTS: - t ... the thread to check - - RETURN: - true .... the thread is a daemon thread - false ... the thread is not - -*******************************************************************************/ - -inline static bool thread_is_daemon(threadobject *t) -{ - if (t->flags & THREAD_FLAG_DAEMON) - return true; - else - return false; -} - - -/* thread_current_is_attached ************************************************** - - Returns if the current thread is attached to the VM. - - RETURN: - true .... the thread is attached to the VM - false ... the thread is not - -*******************************************************************************/ - -inline static bool thread_current_is_attached(void) -{ - threadobject *t; - bool result; - - t = thread_get_current(); - - if (t == NULL) - return false; - - result = thread_is_attached(t); - - return result; -} - - -/* function prototypes ********************************************************/ - -void threads_preinit(void); -void threads_init(void); - -void thread_free(threadobject *t); - -bool threads_thread_start_internal(utf *name, functionptr f); -void threads_thread_start(java_handle_t *object); - -bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon); - -void thread_fprint_name(threadobject *t, FILE *stream); -void thread_print_info(threadobject *t); - -intptr_t threads_get_current_tid(void); - -void thread_set_state_runnable(threadobject *t); -void thread_set_state_waiting(threadobject *t); -void thread_set_state_timed_waiting(threadobject *t); -void thread_set_state_terminated(threadobject *t); - -threadobject *thread_get_thread(java_handle_t *h); - -bool threads_thread_is_alive(threadobject *t); - -void threads_dump(void); - - -/* implementation specific functions */ - -void threads_impl_preinit(void); -void threads_impl_init(void); - -#if defined(ENABLE_GC_CACAO) -void threads_mutex_gc_lock(void); -void threads_mutex_gc_unlock(void); -#endif - -void threads_mutex_join_lock(void); -void threads_mutex_join_unlock(void); - -void threads_impl_thread_init(threadobject *t); -void threads_impl_thread_clear(threadobject *t); -void threads_impl_thread_reuse(threadobject *t); -void threads_impl_thread_free(threadobject *t); -void threads_impl_thread_start(threadobject *thread, functionptr f); - -void threads_yield(void); - -#endif /* ENABLE_THREADS */ - -#endif /* _THREAD_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/threads/thread.hpp b/src/threads/thread.hpp new file mode 100644 index 000000000..21dff9df6 --- /dev/null +++ b/src/threads/thread.hpp @@ -0,0 +1,379 @@ +/* src/threads/thread.hpp - machine independent thread functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _THREAD_HPP +#define _THREAD_HPP + +#include "config.h" + +#include "vm/types.h" + +// Include early to get threadobject. +#if defined(ENABLE_THREADS) +# include "threads/posix/thread-posix.hpp" +#else +# include "threads/none/thread-none.h" +#endif + +#include "vm/os.hpp" + +#include "native/llni.h" + +#include "threads/mutex.hpp" + +#include "vm/global.h" +#include "vm/utf8.h" + + +/* only define the following stuff with thread enabled ************************/ + +#if defined(ENABLE_THREADS) + +/* thread states **************************************************************/ + +#define THREAD_STATE_NEW 0 +#define THREAD_STATE_RUNNABLE 1 +#define THREAD_STATE_BLOCKED 2 +#define THREAD_STATE_WAITING 3 +#define THREAD_STATE_TIMED_WAITING 4 +#define THREAD_STATE_TERMINATED 5 + + +/* thread priorities **********************************************************/ + +#define MIN_PRIORITY 1 +#define NORM_PRIORITY 5 +#define MAX_PRIORITY 10 + + +/* debug **********************************************************************/ + +#if !defined(NDEBUG) +# define DEBUGTHREADS(message, thread) \ + do { \ + if (opt_DebugThreads) { \ + printf("[Thread %-16s: ", message); \ + thread_print_info(thread); \ + printf("]\n"); \ + } \ + } while (0) +#else +# define DEBUGTHREADS(message, thread) +#endif + + +/* global variables ***********************************************************/ + +#if defined(__LINUX__) +/* XXX Remove for exact-GC. */ +extern bool threads_pthreads_implementation_nptl; +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* inline functions ***********************************************************/ + +/* thread_get_object *********************************************************** + + Return the Java for the given thread. + + ARGUMENTS: + t ... thread + + RETURN: + the Java object + +*******************************************************************************/ + +inline static java_handle_t *thread_get_object(threadobject *t) +{ + return LLNI_WRAP(t->object); +} + + +/* threads_thread_set_object *************************************************** + + Set the Java object for the given thread. + + ARGUMENTS: + t ... thread + o ... Java object + +*******************************************************************************/ + +inline static void thread_set_object(threadobject *t, java_handle_t *o) +{ + t->object = LLNI_DIRECT(o); +} + + +/* thread_get_current_object ************************************************** + + Return the Java object of the current thread. + + RETURN VALUE: + the Java object + +*******************************************************************************/ + +inline static java_handle_t *thread_get_current_object(void) +{ + threadobject *t; + java_handle_t *o; + + t = THREADOBJECT; + o = thread_get_object(t); + + return o; +} + + +/* cacaothread_get_state ******************************************************* + + Returns the current state of the given thread. + + ARGUMENTS: + t ... the thread to check + + RETURN: + thread state + +*******************************************************************************/ + +inline static int cacaothread_get_state(threadobject *t) +{ + return t->state; +} + + +/* thread_is_attached ********************************************************** + + Returns if the given thread is attached to the VM. + + ARGUMENTS: + t ... the thread to check + + RETURN: + true .... the thread is attached to the VM + false ... the thread is not + +*******************************************************************************/ + +inline static bool thread_is_attached(threadobject *t) +{ + java_handle_t *o; + + o = thread_get_object(t); + + if (o != NULL) + return true; + else + return false; +} + + +/* thread_is_interrupted ******************************************************* + + Check if the given thread has been interrupted. + + ARGUMENTS: + t ... the thread to check + + RETURN VALUE: + true, if the given thread had been interrupted + +*******************************************************************************/ + +inline static bool thread_is_interrupted(threadobject *t) +{ + bool interrupted; + + /* We need the mutex because classpath will call this function when + a blocking system call is interrupted. The mutex ensures that it will + see the correct value for the interrupted flag. */ + +#ifdef __cplusplus + t->waitmutex->lock(); + interrupted = t->interrupted; + t->waitmutex->unlock(); +#else + Mutex_lock(t->waitmutex); + interrupted = t->interrupted; + Mutex_unlock(t->waitmutex); +#endif + + return interrupted; +} + + +/* thread_set_interrupted ****************************************************** + + Set the interrupted flag to the given value. + + ARGUMENTS: + interrupted ... value to set + +*******************************************************************************/ + +inline static void thread_set_interrupted(threadobject *t, bool interrupted) +{ +#ifdef __cplusplus + t->waitmutex->lock(); + t->interrupted = interrupted; + t->waitmutex->unlock(); +#else + Mutex_lock(t->waitmutex); + t->interrupted = interrupted; + Mutex_unlock(t->waitmutex); +#endif +} + + +/* thread_is_daemon ************************************************************ + + Returns if the given thread is a daemon thread. + + ARGUMENTS: + t ... the thread to check + + RETURN: + true .... the thread is a daemon thread + false ... the thread is not + +*******************************************************************************/ + +inline static bool thread_is_daemon(threadobject *t) +{ + if (t->flags & THREAD_FLAG_DAEMON) + return true; + else + return false; +} + + +/* thread_current_is_attached ************************************************** + + Returns if the current thread is attached to the VM. + + RETURN: + true .... the thread is attached to the VM + false ... the thread is not + +*******************************************************************************/ + +inline static bool thread_current_is_attached(void) +{ + threadobject *t; + bool result; + + t = thread_get_current(); + + if (t == NULL) + return false; + + result = thread_is_attached(t); + + return result; +} + + +/* function prototypes ********************************************************/ + +void threads_preinit(void); +void threads_init(void); + +void thread_free(threadobject *t); + +bool threads_thread_start_internal(utf *name, functionptr f); +void threads_thread_start(java_handle_t *object); + +bool thread_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon); +bool thread_attach_current_external_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon); +bool thread_detach_current_thread(void); + +bool thread_detach_current_external_thread(void); + +void thread_fprint_name(threadobject *t, FILE *stream); +void thread_print_info(threadobject *t); + +intptr_t threads_get_current_tid(void); + +void thread_set_state_runnable(threadobject *t); +void thread_set_state_waiting(threadobject *t); +void thread_set_state_timed_waiting(threadobject *t); +void thread_set_state_terminated(threadobject *t); + +threadobject *thread_get_thread(java_handle_t *h); + +bool threads_thread_is_alive(threadobject *t); + +void threads_dump(void); + + +/* implementation specific functions */ + +void threads_impl_preinit(void); +void threads_impl_init(void); + +#if defined(ENABLE_GC_CACAO) +void threads_mutex_gc_lock(void); +void threads_mutex_gc_unlock(void); +#endif + +void threads_mutex_join_lock(void); +void threads_mutex_join_unlock(void); + +void threads_impl_thread_clear(threadobject *t); +void threads_impl_thread_reuse(threadobject *t); +void threads_impl_thread_free(threadobject *t); +void threads_impl_thread_start(threadobject *thread, functionptr f); + +void threads_yield(void); + +#endif /* ENABLE_THREADS */ + +#ifdef __cplusplus +} +#endif + +#endif // _THREAD_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/threads/threadlist.c b/src/threads/threadlist.c index 8b7d92e3e..b585f22c5 100644 --- a/src/threads/threadlist.c +++ b/src/threads/threadlist.c @@ -29,18 +29,18 @@ #include "mm/memory.h" -#include "threads/mutex.h" +#include "threads/mutex.hpp" #include "threads/threadlist.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "toolbox/list.h" -#include "vmcore/options.h" +#include "vm/options.h" /* global variables ***********************************************************/ -static mutex_t threadlist_mutex; /* global mutex for the thread list */ +static Mutex* threadlist_mutex; /* global mutex for the thread list */ static list_t *list_thread; /* global threads list */ static list_t *list_thread_free; /* global free threads list */ @@ -65,7 +65,7 @@ void threadlist_init(void) /* Initialize the thread list mutex. */ - mutex_init(&threadlist_mutex); + threadlist_mutex = Mutex_new(); /* Initialize the thread lists. */ @@ -88,7 +88,7 @@ void threadlist_init(void) void threadlist_lock(void) { - mutex_lock(&threadlist_mutex); + Mutex_lock(threadlist_mutex); } @@ -100,7 +100,7 @@ void threadlist_lock(void) void threadlist_unlock(void) { - mutex_unlock(&threadlist_mutex); + Mutex_unlock(threadlist_mutex); } diff --git a/src/threads/threadlist.h b/src/threads/threadlist.h index b3dd2cbf3..6f2ae0ade 100644 --- a/src/threads/threadlist.h +++ b/src/threads/threadlist.h @@ -30,7 +30,11 @@ #include -#include "threads/thread.h" +#ifdef __cplusplus +extern "C" { +#endif + +#include "threads/thread.hpp" /* function prototypes ********************************************************/ @@ -58,6 +62,10 @@ void threadlist_impl_init(void); void threadlist_lock(void); void threadlist_unlock(void); +#ifdef __cplusplus +} +#endif + #endif /* _THREADLIST_H */ diff --git a/src/toolbox/Makefile.am b/src/toolbox/Makefile.am index e6d1085cd..b4d6ee7d9 100644 --- a/src/toolbox/Makefile.am +++ b/src/toolbox/Makefile.am @@ -1,9 +1,7 @@ ## src/toolbox/Makefile.am ## -## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, -## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -## J. Wenninger, Institut f. Computersprachen - TU Wien +## Copyright (C) 1996-2005, 2006, 2007, 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO ## ## This file is part of CACAO. ## @@ -21,12 +19,8 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. -## -## Contact: cacao@cacaojvm.org -## -## Authors: Christian Thalinger -## -## + + AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) LIBS = @@ -39,8 +33,6 @@ libtoolbox_la_SOURCES = \ avl.h \ bitvector.c \ bitvector.h \ - chain.c \ - chain.h \ hashtable.c \ hashtable.h \ list.c \ @@ -49,8 +41,6 @@ libtoolbox_la_SOURCES = \ logging.h \ set.h \ set.c \ - tree.c \ - tree.h \ util.c \ util.h \ worklist.c \ diff --git a/src/toolbox/avl.c b/src/toolbox/avl.c index 4fe67c5c9..404328c05 100644 --- a/src/toolbox/avl.c +++ b/src/toolbox/avl.c @@ -1,9 +1,7 @@ /* src/toolbox/avl.c - AVL tree implementation - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,13 +31,13 @@ #include "mm/memory.h" -#include "threads/lock-common.h" +#include "threads/mutex.hpp" #include "toolbox/avl.h" #include "toolbox/logging.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" /* avl_create ****************************************************************** @@ -54,18 +52,11 @@ avl_tree_t *avl_create(avl_comparator *comparator) t = NEW(avl_tree_t); + t->mutex = Mutex_new(); t->root = NULL; t->comparator = comparator; t->entries = 0; -#if defined(ENABLE_THREADS) - /* create lock object for this tree */ - - t->lock = NEW(java_object_t); - - LOCK_INIT_OBJECT_LOCK(t->lock); -#endif - return t; } @@ -312,7 +303,7 @@ bool avl_insert(avl_tree_t *tree, void *data) assert(tree); assert(data); - LOCK_MONITOR_ENTER(tree->lock); + Mutex_lock(tree->mutex); /* if we don't have a root node, create one */ @@ -325,7 +316,7 @@ bool avl_insert(avl_tree_t *tree, void *data) tree->entries++; - LOCK_MONITOR_EXIT(tree->lock); + Mutex_unlock(tree->mutex); /* insertion was ok */ @@ -348,7 +339,7 @@ void *avl_find(avl_tree_t *tree, void *data) assert(tree); assert(data); - LOCK_MONITOR_ENTER(tree->lock); + Mutex_lock(tree->mutex); /* search the tree for the given node */ @@ -360,7 +351,7 @@ void *avl_find(avl_tree_t *tree, void *data) /* was the entry found? return it */ if (res == 0) { - LOCK_MONITOR_EXIT(tree->lock); + Mutex_unlock(tree->mutex); return node->data; } @@ -370,7 +361,7 @@ void *avl_find(avl_tree_t *tree, void *data) node = node->childs[(res < 0) ? AVL_LEFT : AVL_RIGHT]; } - LOCK_MONITOR_EXIT(tree->lock); + Mutex_unlock(tree->mutex); /* entry was not found, returning NULL */ diff --git a/src/toolbox/avl.h b/src/toolbox/avl.h index a8dcaba58..c968fa8a9 100644 --- a/src/toolbox/avl.h +++ b/src/toolbox/avl.h @@ -1,9 +1,7 @@ /* src/toolbox/avl.h - AVL tree implementation - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -32,6 +30,8 @@ #include "vm/types.h" +#include "threads/mutex.hpp" + #include "vm/global.h" @@ -55,12 +55,10 @@ typedef struct avl_node_t avl_node_t; /* avl_tree_t *****************************************************************/ struct avl_tree_t { -#if defined(ENABLE_THREADS) - java_object_t *lock; /* threads lock object */ -#endif - avl_node_t *root; /* pointer to root node */ - avl_comparator *comparator; /* pointer to comparison function */ - s4 entries; /* contains number of entries */ + Mutex* mutex; ///< Mutex to lock the tree. + avl_node_t *root; /* pointer to root node */ + avl_comparator *comparator; /* pointer to comparison function */ + s4 entries; /* contains number of entries */ }; diff --git a/src/toolbox/bitvector.c b/src/toolbox/bitvector.c index bde41ff7c..66b9df115 100644 --- a/src/toolbox/bitvector.c +++ b/src/toolbox/bitvector.c @@ -1,9 +1,8 @@ /* src/toolbox/bitvector.c - bitvector implementation - Copyright (C) 2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien + Copyright (C) 2005, 2006 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. This file is part of CACAO. @@ -22,12 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Ullrich +*/ -*/ +#include "config.h" #include "mm/memory.h" #include "toolbox/bitvector.h" @@ -115,7 +112,7 @@ bitvector bv_new(int size) { /* n = (((size+7)/8) + sizeof(int) - 1)/sizeof(int); */ n = BV_NUM_INTS(size); - bv = DMNEW(int, n); + bv = DumpMemory_allocate(sizeof(int) * n); for(i = 0; i < n; i++) bv[i] = 0; diff --git a/src/toolbox/chain.c b/src/toolbox/chain.c deleted file mode 100644 index ae1bb7c2c..000000000 --- a/src/toolbox/chain.c +++ /dev/null @@ -1,315 +0,0 @@ -/* src/toolbox/chain.c - management of doubly linked lists with external linking - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contact: cacao@cacaojvm.org - - Authors: Reinhard Grafl - - Changes: Christian Thalinger - -*/ - - -#include -#include -#include - -#include "mm/memory.h" -#include "toolbox/chain.h" - - -chain *chain_new(void) -{ - chain *c; - - c = NEW(chain); - c->usedump = 0; - c->first = NULL; - c->last = NULL; - c->active = NULL; - - return c; -} - - -chain *chain_dnew(void) -{ - chain *c; - - c = DNEW(chain); - c->usedump = 1; - c->first = NULL; - c->last = NULL; - c->active = NULL; - - return c; -} - - -void chain_free(chain *c) -{ - chainlink *l; - - assert(!c->usedump); - - l = c->first; - while (l) { - chainlink *nextl = l->next; - - FREE(l, chainlink); - l = nextl; - } - - FREE(c, chain); -} - - -void chain_addafter(chain *c, void *element) -{ - chainlink *active; - chainlink *newlink; - - active = c->active; - - if (c->usedump) { - newlink = DNEW(chainlink); - - } else { - newlink = NEW(chainlink); - } - - newlink->element = element; - - if (active) { - newlink->next = active->next; - newlink->prev = active; - - active->next = newlink; - if (newlink->next) { - newlink->next->prev = newlink; - - } else { - c->last = newlink; - } - - } else { - newlink->next = NULL; - newlink->prev = NULL; - - c->active = newlink; - c->first = newlink; - c->last = newlink; - } -} - - -void chain_addbefore(chain *c, void *element) -{ - chainlink *active; - chainlink *newlink; - - active = c->active; - - if (c->usedump) { - newlink = DNEW(chainlink); - - } else { - newlink = NEW(chainlink); - } - - newlink->element = element; - - if (active) { - newlink->next = active; - newlink->prev = active->prev; - - active->prev = newlink; - if (newlink->prev) { - newlink->prev->next = newlink; - - } else { - c->first = newlink; - } - - } else { - newlink->next = NULL; - newlink->prev = NULL; - - c->active = newlink; - c->first = newlink; - c->last = newlink; - } -} - - -void chain_addlast(chain *c, void *e) -{ - chain_last(c); - chain_addafter(c, e); -} - - -void chain_addfirst(chain *c, void *e) -{ - chain_first(c); - chain_addbefore(c, e); -} - - -void chain_remove(chain *c) -{ - chainlink *active; - - active = c->active; - assert(active); - - if (active->next) { - active->next->prev = active->prev; - - } else { - c->last = active->prev; - } - - if (active->prev) { - active->prev->next = active->next; - - } else { - c->first = active->next; - } - - - if (active->prev) { - c->active = active->prev; - - } else { - c->active = active->next; - } - - if (!c->usedump) - FREE(active, chainlink); -} - - -void *chain_remove_go_prev(chain *c) -{ - chain_remove(c); - return chain_this(c); -} - - - -void chain_removespecific(chain *c, void *e) -{ - void *ce; - - ce = chain_first(c); - while (ce) { - if (e == ce) { - chain_remove(c); - return; - } - - ce = chain_next(c); - } -} - - -void *chain_next(chain *c) -{ - chainlink *active; - - active = c->active; - - if (!active) - return NULL; - - if (active->next) { - c->active = active->next; - return c->active->element; - } - - return NULL; -} - - -void *chain_prev(chain *c) -{ - chainlink *active; - - active = c->active; - - if (!active) - return NULL; - - if (active->prev) { - c->active = active->prev; - return c->active->element; - } - - return NULL; -} - - -void *chain_this(chain *c) -{ - if (c->active) - return c->active->element; - - return NULL; -} - - -void *chain_first(chain *c) -{ - c->active = c->first; - - if (c -> active) - return c->active->element; - - return NULL; -} - -void *chain_last(chain *c) -{ - c->active = c->last; - - if (c->active) - return c->active->element; - - return NULL; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/toolbox/chain.h b/src/toolbox/chain.h deleted file mode 100644 index 29ec7460a..000000000 --- a/src/toolbox/chain.h +++ /dev/null @@ -1,125 +0,0 @@ -/* toolbox/chain.h - management of doubly linked lists with external linking - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contact: cacao@cacaojvm.org - - Authors: Reinhard Grafl - - -*/ - - -#ifndef _CHAIN_H -#define _CHAIN_H - -typedef struct chainlink { /* structure for list element */ - struct chainlink *next; - struct chainlink *prev; - void *element; -} chainlink; - -typedef struct chain { /* structure for list */ - int usedump; - - chainlink *first; - chainlink *last; - chainlink *active; -} chain; - - -/* function prototypes */ -chain *chain_new(void); -chain *chain_dnew(void); -void chain_free(chain *c); - -void chain_addafter(chain *c, void *element); -void chain_addbefore(chain *c, void *element); -void chain_addlast(chain *c, void *element); -void chain_addfirst(chain *c, void *element); - -void chain_remove(chain *c); -void *chain_remove_go_prev(chain *c); -void chain_removespecific(chain *c, void *element); - -void *chain_next(chain *c); -void *chain_prev(chain *c); -void *chain_this(chain *c); - -void *chain_first(chain *c); -void *chain_last(chain *c); - - -/* ---------------------------- interface description ------------------------ - -Usage of these functions for list management is possible without additional -preparation in the element structures, as opposed to the module 'list'. - -Consequently, the functions are a little slower and need more memory. - -A new list is created with - chain_new -or chain_dnew. -The latter allocates all additional data structures on the dump memory (faster) -for which no explicit freeing is necessary after the processing. Care needs to -be taken to not accidentally free parts of these structures by calling -'dump_release' too early. - -After usage, a list can be freed with - chain_free. -(use only if the list was created with 'chain_new') - - -Adding elements is easy with: - chain_addafter, chain_addlast, chain_addbefore, chain_addfirst - -Search the list with: - chain_first, chain_last, chain_prev, chain_next, chain_this - -Delete elements from the list: - chain_remove, chain_remove_go_prev, chain_removespecific - - -ATTENTION: As mentioned earlier, there are no pointers to the list or to other -nodes inside the list elements, so list elements cannot be used as pointers -into the list. Therefore a 'cursor' is used to make one element current. Every -insertion/deletion occurs at a position relative to this cursor. - -*/ - -#endif /* _CHAIN_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/toolbox/hashtable.c b/src/toolbox/hashtable.c index f502fca4d..dd49f3de5 100644 --- a/src/toolbox/hashtable.c +++ b/src/toolbox/hashtable.c @@ -1,9 +1,7 @@ /* src/toolbox/hashtable.c - functions for internal hashtables - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -30,7 +28,7 @@ #include "mm/memory.h" -#include "threads/lock-common.h" +#include "threads/mutex.hpp" #include "toolbox/hashtable.h" @@ -41,7 +39,7 @@ Initializes a hashtable structure and allocates memory. The parameter size specifies the initial size of the hashtable. - + *******************************************************************************/ void hashtable_create(hashtable *hash, u4 size) @@ -49,13 +47,11 @@ void hashtable_create(hashtable *hash, u4 size) /* initialize locking pointer */ #if defined(ENABLE_THREADS) - /* We need to seperately allocate a java_object_t here, as we - need to store the lock object in the new hashtable if it's - resized. Otherwise we get an IllegalMonitorStateException. */ - - hash->header = NEW(java_object_t); + /* We need to seperately allocate a mutex here, as we need to + store the lock object in the new hashtable if it's resized. + Otherwise we get an IllegalMonitorStateException. */ - LOCK_INIT_OBJECT_LOCK(hash->header); + hash->mutex = Mutex_new(); #endif /* set initial hash values */ @@ -89,9 +85,9 @@ hashtable *hashtable_resize(hashtable *hash, u4 size) /* We need to store the old lock object in the new hashtable. Otherwise we get an IllegalMonitorStateException. */ - FREE(newhash->header, java_object_t); + Mutex_delete(newhash->mutex); - newhash->header = hash->header; + newhash->mutex = hash->mutex; #endif /* store the number of entries in the new hashtable */ diff --git a/src/toolbox/hashtable.h b/src/toolbox/hashtable.h index 1712ae99d..65b166e41 100644 --- a/src/toolbox/hashtable.h +++ b/src/toolbox/hashtable.h @@ -1,9 +1,7 @@ /* src/toolbox/hashtable.h - functions for internal hashtables - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,11 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Reinhard Grafl - Christian Thalinger - */ @@ -41,8 +34,10 @@ typedef struct hashtable hashtable; #include "config.h" #include "vm/types.h" +#include "threads/mutex.hpp" + #include "vm/global.h" -#include "vmcore/utf8.h" +#include "vm/utf8.h" /* data structures for hashtables ******************************************** @@ -100,7 +95,7 @@ hashtable.ptr-->+-------------------+ struct hashtable { #if defined(ENABLE_THREADS) - java_object_t *header; /* required for locking */ + Mutex *mutex; /* required for locking */ #endif u4 size; /* current size of the hashtable */ u4 entries; /* number of entries in the table */ @@ -110,6 +105,10 @@ struct hashtable { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + /* create hashtable */ void hashtable_create(hashtable *hash, u4 size); @@ -119,6 +118,10 @@ hashtable *hashtable_resize(hashtable *hash, u4 size); /* frees a hashtable */ void hashtable_free(hashtable *hash); +#ifdef __cplusplus +} +#endif + #endif /* _HASHTABLE_H */ diff --git a/src/toolbox/list.c b/src/toolbox/list.c index 4de7222f6..a9cf70541 100644 --- a/src/toolbox/list.c +++ b/src/toolbox/list.c @@ -31,7 +31,7 @@ #include "mm/memory.h" -#include "threads/lock-common.h" +#include "threads/mutex.hpp" #include "toolbox/list.h" @@ -48,8 +48,7 @@ list_t *list_create(int nodeoffset) l = NEW(list_t); - LOCK_INIT_OBJECT_LOCK(l); - + l->mutex = Mutex_new(); l->first = NULL; l->last = NULL; l->nodeoffset = nodeoffset; @@ -69,6 +68,8 @@ void list_free(list_t *l) { assert(l != NULL); + Mutex_delete(l->mutex); + FREE(l, list_t); } @@ -85,8 +86,9 @@ list_t *list_create_dump(int nodeoffset) { list_t *l; - l = DNEW(list_t); + l = DumpMemory_allocate(sizeof(list_t)); + l->mutex = NULL; l->first = NULL; l->last = NULL; l->nodeoffset = nodeoffset; @@ -104,7 +106,7 @@ list_t *list_create_dump(int nodeoffset) void list_lock(list_t *l) { - LOCK_MONITOR_ENTER(l); + Mutex_lock(l->mutex); } @@ -116,7 +118,7 @@ void list_lock(list_t *l) void list_unlock(list_t *l) { - LOCK_MONITOR_EXIT(l); + Mutex_unlock(l->mutex); } diff --git a/src/toolbox/list.h b/src/toolbox/list.h index 6837e3b78..b39df6b02 100644 --- a/src/toolbox/list.h +++ b/src/toolbox/list.h @@ -23,8 +23,8 @@ */ -#ifndef _LIST_H -#define _LIST_H +#ifndef _TOOLBOX_LIST_H +#define _TOOLBOX_LIST_H #include "config.h" @@ -32,6 +32,12 @@ #include "vm/global.h" +#include "threads/mutex.hpp" + + +#ifdef __cplusplus +extern "C" { +#endif /* ---------------------- interface description ----------------------------- @@ -105,9 +111,7 @@ struct listnode_t { typedef struct list_t list_t; struct list_t { -#if defined(ENABLE_THREADS) - java_object_t lock; /* threads lock object */ -#endif + Mutex* mutex; /* threads lock object */ listnode_t *first; listnode_t *last; int nodeoffset; @@ -137,7 +141,11 @@ void *list_last(list_t *l); void *list_next(list_t *l, void *element); void *list_prev(list_t *l, void *element); -#endif /* _LIST_H */ +#ifdef __cplusplus +} +#endif + +#endif /* _TOOLBOX_LIST_H */ /* diff --git a/src/toolbox/logging.c b/src/toolbox/logging.c index c9fea656a..7ff7f1b69 100644 --- a/src/toolbox/logging.c +++ b/src/toolbox/logging.c @@ -33,7 +33,7 @@ #include "mm/memory.h" -#include "threads/thread.h" +#include "threads/thread.hpp" #include "toolbox/logging.h" #include "toolbox/util.h" @@ -41,7 +41,7 @@ #include "vm/global.h" #if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" +# include "vm/statistics.h" #endif diff --git a/src/toolbox/logging.h b/src/toolbox/logging.h index f6def3805..bcf2e6538 100644 --- a/src/toolbox/logging.h +++ b/src/toolbox/logging.h @@ -1,9 +1,7 @@ /* src/toolbox/logging.h - contains logging functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,16 +31,14 @@ #include #include -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/utf8.h" +#include "vm/class.h" +#include "vm/method.h" +#include "vm/utf8.h" -/*500 is to small for eclipse traces, (builtin_trace_args, perhaps the -buffer should be created there dynamically, if the text is longer, -instead of setting the size for all invocations that big*/ - -#define MAXLOGTEXT 16383 +#ifdef __cplusplus +extern "C" { +#endif /* function prototypes ********************************************************/ @@ -67,6 +63,10 @@ void log_message_method(const char *msg, methodinfo *m); #define log_text(s) log_println("%s", (s)) #define dolog log_println +#ifdef __cplusplus +} +#endif + #endif /* _LOGGING_H */ diff --git a/src/toolbox/set.c b/src/toolbox/set.c index b4fd7e71e..c63ddf882 100644 --- a/src/toolbox/set.c +++ b/src/toolbox/set.c @@ -29,12 +29,18 @@ elements (pointers). */ -#include "toolbox/set.h" + +#include "config.h" #include +#include "toolbox/set.h" + #include "mm/memory.h" +#include "vm/global.h" + + /* struct set ****************************************************************** Represents the set. @@ -57,9 +63,9 @@ struct set { *******************************************************************************/ set *set_new(unsigned capacity) { - set *s = DNEW(set); + set *s = DumpMemory_allocate(sizeof(set)); - s->elements = DMNEW(void *, capacity); + s->elements = DumpMemory_allocate(sizeof(void*) * capacity); MZERO(s->elements, void *, capacity); s->capacity = capacity; s->size = 0; diff --git a/src/toolbox/set.h b/src/toolbox/set.h index 491ce4f17..5f11bf3c9 100644 --- a/src/toolbox/set.h +++ b/src/toolbox/set.h @@ -22,11 +22,15 @@ */ + #ifndef _TOOLBOX_SET_H #define _TOOLBOX_SET_H +#include "config.h" + #include "vm/global.h" + typedef struct set set; set *set_new(unsigned capacity); diff --git a/src/toolbox/tree.c b/src/toolbox/tree.c deleted file mode 100644 index e76fd23c6..000000000 --- a/src/toolbox/tree.c +++ /dev/null @@ -1,230 +0,0 @@ -/* toolbox/tree.h - binary tree management - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contact: cacao@cacaojvm.org - - Authors: Reinhard Grafl - - -*/ - - -#include -#include - -#include "mm/memory.h" -#include "toolbox/tree.h" - - -tree *tree_new(treeelementcomperator comperator) -{ - tree *t = NEW(tree); - - t->usedump = 0; - t->comperator = comperator; - t->top = NULL; - t->active = NULL; - - return t; -} - - -tree *tree_dnew(treeelementcomperator comperator) -{ - tree *t = DNEW(tree); - - t->usedump = 1; - t->comperator = comperator; - t->top = NULL; - t->active = NULL; - - return t; -} - - -static void tree_nodefree(treenode *tn) -{ - if (!tn) - return; - - tree_nodefree(tn->left); - tree_nodefree(tn->right); - FREE(tn, treenode); -} - - -void tree_free(tree *t) -{ - assert(!t->usedump); - - tree_nodefree(t->top); - FREE(t, tree); -} - - -static treenode *tree_nodeadd(tree *t, treenode *par, treenode *n, - void *element, void *key) -{ - if (!n) { - if (t->usedump) { - n = DNEW(treenode); - - } else { - n = NEW(treenode); - } - - n->left = NULL; - n->right = NULL; - n->parent = par; - n->element = element; - - } else { - if (t->comperator(key, n->element) < 0) { - n->left = tree_nodeadd(t, n, n->left, element, key); - - } else { - n->right = tree_nodeadd(t, n, n->right, element, key); - } - } - - return n; -} - - -void tree_add(tree *t, void *element, void *key) -{ - t->top = tree_nodeadd(t, NULL, t->top, element, key); - t->active = t->top; -} - - -static treenode *tree_nodefind(tree *t, treenode *n, void *key) -{ - int way; - - if (!n) - return NULL; - - way = t->comperator(key, n->element); - if (way == 0) - return n; - - if (way < 0) { - return tree_nodefind(t, n->left, key); - - } else { - return tree_nodefind (t, n -> right, key); - } -} - - -void *tree_find(tree *t, void *key) -{ - treenode *tn = tree_nodefind(t, t->top, key); - - if (!tn) - return NULL; - - t->active = tn; - - return tn->element; -} - - - -void *tree_this(tree *t) -{ - if (!t->active) - return NULL; - - return t->active->element; -} - - -static treenode *leftmostnode(treenode *t) -{ - while (t->left) { - t = t->left; - } - - return t; -} - - -void *tree_first(tree *t) -{ - treenode *a = t->top; - - if (!a) - return NULL; - - a = leftmostnode(a); - t->active = a; - - return a->element; -} - - -void *tree_next (tree *t) -{ - treenode *a = t->active; - treenode *comefrom = NULL; - - while (a) { - if (!a) - return NULL; - - if (a->left && (a->left == comefrom)) { - t -> active = a; - return a->element; - } - - if (a->right && (a->right != comefrom)) { - a = leftmostnode(a->right); - t -> active = a; - return a->element; - } - - comefrom = a; - a = a->parent; - } - - t->active = NULL; - - return NULL; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/toolbox/tree.h b/src/toolbox/tree.h deleted file mode 100644 index e031f9336..000000000 --- a/src/toolbox/tree.h +++ /dev/null @@ -1,82 +0,0 @@ -/* toolbox/tree.h - binary tree management - - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contact: cacao@cacaojvm.org - - Authors: Reinhard Grafl - - -*/ - - -#ifndef _TREE_H -#define _TREE_H - -typedef int (*treeelementcomperator) (void *key, void * element); - - -typedef struct treenode { - struct treenode *left,*right; - struct treenode *parent; - - void *element; -} treenode; - -typedef struct { - int usedump; - treeelementcomperator comperator; - - treenode *top; - treenode *active; -} tree; - - -/* function prototypes */ - -tree *tree_new(treeelementcomperator comperator); -tree *tree_dnew(treeelementcomperator comperator); -void tree_free(tree *t); - -void tree_add(tree *t, void *element, void *key); -void *tree_find(tree *t, void *key); - -void *tree_this(tree *t); -void *tree_first(tree *t); -void *tree_next(tree *t); - -#endif /* _TREE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/toolbox/util.c b/src/toolbox/util.c index 82acc8ff7..2e26c259b 100644 --- a/src/toolbox/util.c +++ b/src/toolbox/util.c @@ -1,9 +1,7 @@ /* src/toolbox/util.c - contains some utility functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -41,7 +33,7 @@ #include "vm/types.h" #include "mm/memory.h" -#include "vm/vm.h" +#include "vm/vm.hpp" /* _Jv_getcwd ****************************************************************** diff --git a/src/toolbox/util.h b/src/toolbox/util.h index 866f410a8..4952cd26f 100644 --- a/src/toolbox/util.h +++ b/src/toolbox/util.h @@ -1,9 +1,7 @@ /* src/toolbox/util.h - contains some utility functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,18 +20,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ #ifndef _UTIL_H #define _UTIL_H +#ifdef __cplusplus +extern "C" { +#endif + #include "config.h" #include @@ -46,6 +42,10 @@ char *_Jv_getcwd(void); int get_variable_message_length(const char *fmt, va_list ap); +#ifdef __cplusplus +} +#endif + #endif /* _UTIL_H */ diff --git a/src/vm/Makefile.am b/src/vm/Makefile.am index fb3c8ba88..97b04c69a 100644 --- a/src/vm/Makefile.am +++ b/src/vm/Makefile.am @@ -1,9 +1,7 @@ ## src/vm/Makefile.am ## -## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, -## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -## J. Wenninger, Institut f. Computersprachen - TU Wien +## Copyright (C) 1996-2005, 2006, 2007, 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO ## ## This file is part of CACAO. ## @@ -22,7 +20,6 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. -## Process this file with automake to produce Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) -I$(top_builddir)/src -I$(top_srcdir)/contrib/vmlog -I$(top_srcdir)/src/native @@ -42,6 +39,36 @@ CYCLES_STATS_SOURCES = \ cycles-stats.h endif +if ENABLE_JAVASE +if ENABLE_ANNOTATIONS +ANNOTATION_SOURCES = \ + annotation.c \ + annotation.h +endif + +STACKMAP_SOURCES = \ + stackmap.c \ + stackmap.h +endif + +if ENABLE_RT_TIMING +RT_TIMING_SOURCES = \ + rt-timing.c \ + rt-timing.h +endif + +if ENABLE_STATISTICS +STATISTICS_SOURCES = \ + statistics.c \ + statistics.h +endif + +if ENABLE_ZLIB +ZLIB_SOURCES = \ + zip.c \ + zip.h +endif + noinst_HEADERS = \ global.h \ types.h @@ -50,36 +77,65 @@ noinst_LTLIBRARIES = \ libvm.la libvm_la_SOURCES = \ - $(ASSERTION_SOURCES) \ access.c \ access.h \ + $(ANNOTATION_SOURCES) \ array.c \ array.h \ - builtin.c \ - builtin.h \ - builtintable.inc \ + $(ASSERTION_SOURCES) \ + class.c \ + class.h \ + classcache.c \ + classcache.h \ $(CYCLES_STATS_SOURCES) \ - exceptions.c \ - exceptions.h \ + descriptor.c \ + descriptor.h \ + exceptions.cpp \ + exceptions.hpp \ + field.cpp \ + field.hpp \ finalizer.c \ finalizer.h \ + globals.cpp \ + globals.hpp \ initialize.c \ initialize.h \ + javaobjects.cpp \ + javaobjects.hpp \ jit_interface.h \ - package.c \ - package.h \ - primitive.c \ - primitive.h \ - properties.c \ - properties.h \ + linker.c \ + linker.h \ + loader.cpp \ + loader.hpp \ + method.c \ + method.h \ + options.c \ + options.h \ + os.cpp \ + os.hpp \ + package.cpp \ + package.hpp \ + primitive.cpp \ + primitive.hpp \ + properties.cpp \ + properties.hpp \ + references.h \ resolve.c \ resolve.h \ + $(RT_TIMING_SOURCES) \ signal.c \ signallocal.h \ - string.c \ - stringlocal.h \ - vm.c \ - vm.h + $(STACKMAP_SOURCES) \ + $(STATISTICS_SOURCES) \ + string.cpp \ + string.hpp \ + suck.cpp \ + suck.hpp \ + utf8.c \ + utf8.h \ + vm.cpp \ + vm.hpp \ + $(ZLIB_SOURCES) libvm_la_LIBADD = \ jit/libjit.la diff --git a/src/vm/access.c b/src/vm/access.c index 81ea76412..9dd2b1e05 100644 --- a/src/vm/access.c +++ b/src/vm/access.c @@ -35,14 +35,14 @@ #include "native/llni.h" #include "vm/access.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" - -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/method.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/field.hpp" +#include "vm/globals.hpp" +#include "vm/method.h" + +#include "vm/jit/stacktrace.hpp" /* access_is_accessible_class ************************************************** diff --git a/src/vm/access.h b/src/vm/access.h index 2b8a10c17..0b1def476 100644 --- a/src/vm/access.h +++ b/src/vm/access.h @@ -30,11 +30,14 @@ #include -#include "vm/global.h" +#ifdef __cplusplus +extern "C" { +#endif -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/method.h" +#include "vm/class.h" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/method.h" /* macros *********************************************************************/ @@ -56,6 +59,10 @@ bool access_check_field(fieldinfo *f, int callerdepth); bool access_check_method(methodinfo *m, int callerdepth); #endif +#ifdef __cplusplus +} +#endif + #endif /* _ACCESS_H */ diff --git a/src/vm/annotation.c b/src/vm/annotation.c new file mode 100644 index 000000000..f6b0b102d --- /dev/null +++ b/src/vm/annotation.c @@ -0,0 +1,614 @@ +/* src/vm/annotation.c - class annotations + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/llni.h" + +#include "mm/memory.h" + +#include "toolbox/logging.h" + +#include "vm/annotation.h" +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/loader.hpp" +#include "vm/primitive.hpp" +#include "vm/suck.hpp" +#include "vm/types.h" + +#if !defined(ENABLE_ANNOTATIONS) +# error annotation support has to be enabled when compling this file! +#endif + + +/* annotation_bytearrays_resize *********************************************** + + Resize an array of bytearrays. + + IN: + bytearrays.....array of bytearrays + size...........new size of the refered array + + RETURN VALUE: + The new array if a resize was neccessarry, the old if the given size + equals the current size or NULL if an error occured. + +*******************************************************************************/ + +static java_handle_objectarray_t *annotation_bytearrays_resize( + java_handle_objectarray_t *bytearrays, uint32_t size) +{ + java_handle_objectarray_t *newbas = NULL; /* new array */ + uint32_t minsize = 0; /* count of object refs to copy */ + uint32_t oldsize = 0; /* size of old array */ + + if (bytearrays != NULL) { + oldsize = array_length_get((java_handle_t*)bytearrays); + + /* if the size already fits do nothing */ + if (size == oldsize) { + return bytearrays; + } + } + + newbas = builtin_anewarray(size, + Primitive_get_arrayclass_by_type(PRIMITIVETYPE_BYTE)); + + /* is there a old byte array array? */ + if (newbas != NULL && bytearrays != NULL) { + minsize = size < oldsize ? size : oldsize; + + LLNI_CRITICAL_START; + MCOPY( + LLNI_array_data(newbas), LLNI_array_data(bytearrays), + java_object_t*, minsize); + LLNI_CRITICAL_END; + } + + return newbas; +} + + +/* annotation_bytearrays_insert *********************************************** + + Insert a bytearray into an array of bytearrays. + + IN: + bytearrays........array of bytearrays where 'bytearray' has to be + inserted at position 'index'. + index.............position where 'ba' has to be inserted into + 'bytearrays'. + bytearray.........byte array which has to be inserted into + 'bytearrays'. + + RETURN VALUE: + The new array if a resize was neccessarry, the old if the given size + equals the current size or NULL if an error occured. + +*******************************************************************************/ + +static java_handle_t *annotation_bytearrays_insert( + java_handle_t *bytearrays, uint32_t index, + java_handle_bytearray_t *bytearray) +{ + java_handle_objectarray_t *bas; /* bytearrays */ + uint32_t size = 0; /* current size of the array */ + + /* do nothing if NULL is inserted but no array exists */ + if (bytearray == NULL && bytearrays == NULL) { + return NULL; + } + + /* get lengths if array exists */ + if (bytearrays != NULL) { + size = array_length_get(bytearrays); + } + + bas = (java_handle_objectarray_t*)bytearrays; + + if (bytearray == NULL) { + /* insert NULL only if array is big enough */ + if (size > index) { + array_objectarray_element_set(bas, index, NULL); + } + } + else { + /* resize array if it's not enough for inserted value */ + if (size <= index) { + bas = annotation_bytearrays_resize(bas, index + 1); + + if (bas == NULL) { + /* out of memory */ + return NULL; + } + } + + array_objectarray_element_set(bas, index, (java_handle_t*)bytearray); + } + + return (java_handle_t*)bas; +} + + +/* annotation_load_attribute_body ********************************************* + + This function loads the body of a generic attribute. + + XXX: Maybe this function should be called loader_load_attribute_body and + located in vm/loader.c? + + attribute_info { + u2 attribute_name_index; + u4 attribute_length; + u1 info[attribute_length]; + } + + IN: + cb.................classbuffer from which to read the data. + errormsg_prefix....prefix for error messages (if any). + + OUT: + attribute..........bytearray-pointer which will be set to the read data. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +static bool annotation_load_attribute_body(classbuffer *cb, + java_handle_bytearray_t **attribute, const char *errormsg_prefix) +{ + uint32_t size = 0; /* size of the attribute */ + java_handle_bytearray_t *ba = NULL; /* the raw attributes' bytes */ + + assert(cb != NULL); + assert(attribute != NULL); + + if (!suck_check_classbuffer_size(cb, 4)) { + log_println("%s: size missing", errormsg_prefix); + return false; + } + + /* load attribute_length */ + size = suck_u4(cb); + + if (!suck_check_classbuffer_size(cb, size)) { + log_println("%s: invalid size", errormsg_prefix); + return false; + } + + /* if attribute_length == 0 then NULL is + * the right value for this attribute */ + if (size > 0) { + ba = builtin_newarray_byte(size); + + if (ba == NULL) { + /* out of memory */ + return false; + } + + /* load data */ + LLNI_CRITICAL_START; + + suck_nbytes((uint8_t*)LLNI_array_data(ba), cb, size); + + LLNI_CRITICAL_END; + + /* return data */ + *attribute = ba; + } + + return true; +} + + +/* annotation_load_method_attribute_annotationdefault ************************* + + Load annotation default value. + + AnnotationDefault_attribute { + u2 attribute_name_index; + u4 attribute_length; + element_value default_value; + } + + IN: + cb.................classbuffer from which to read the data. + m..................methodinfo for the method of which the annotation + default value is read and into which the value is + stored into. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_method_attribute_annotationdefault( + classbuffer *cb, methodinfo *m) +{ + int slot = 0; + /* the slot of the method */ + java_handle_bytearray_t *annotationdefault = NULL; + /* unparsed annotation defalut value */ + java_handle_t *annotationdefaults = NULL; + /* array of unparsed annotation default values */ + + assert(cb != NULL); + assert(m != NULL); + + LLNI_classinfo_field_get( + m->clazz, method_annotationdefaults, annotationdefaults); + + if (!annotation_load_attribute_body( + cb, &annotationdefault, + "invalid annotation default method attribute")) { + return false; + } + + if (annotationdefault != NULL) { + slot = m - m->clazz->methods; + annotationdefaults = annotation_bytearrays_insert( + annotationdefaults, slot, annotationdefault); + + if (annotationdefaults == NULL) { + return false; + } + + LLNI_classinfo_field_set( + m->clazz, method_annotationdefaults, annotationdefaults); + } + + return true; +} + + +/* annotation_load_method_attribute_runtimevisibleparameterannotations ******** + + Load runtime visible parameter annotations. + + RuntimeVisibleParameterAnnotations_attribute { + u2 attribute_name_index; + u4 attribute_length; + u1 num_parameters; + { + u2 num_annotations; + annotation annotations[num_annotations]; + } parameter_annotations[num_parameters]; + } + + IN: + cb.................classbuffer from which to read the data. + m..................methodinfo for the method of which the parameter + annotations are read and into which the parameter + annotations are stored into. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimevisibleparameterannotations( + classbuffer *cb, methodinfo *m) +{ + int slot = 0; + /* the slot of the method */ + java_handle_bytearray_t *annotations = NULL; + /* unparsed parameter annotations */ + java_handle_t *parameterannotations = NULL; + /* array of unparsed parameter annotations */ + + assert(cb != NULL); + assert(m != NULL); + + LLNI_classinfo_field_get( + m->clazz, method_parameterannotations, parameterannotations); + + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible parameter annotations method attribute")) { + return false; + } + + if (annotations != NULL) { + slot = m - m->clazz->methods; + parameterannotations = annotation_bytearrays_insert( + parameterannotations, slot, annotations); + + if (parameterannotations == NULL) { + return false; + } + + LLNI_classinfo_field_set( + m->clazz, method_parameterannotations, parameterannotations); + } + + return true; +} + + +/* annotation_load_method_attribute_runtimeinvisibleparameterannotations ****** + + Load runtime invisible parameter annotations. + + + The RuntimeInvisibleParameterAnnotations attribute is similar to the + RuntimeVisibleParameterAnnotations attribute, except that the annotations + represented by a RuntimeInvisibleParameterAnnotations attribute must not be + made available for return by reflective APIs, unless the the JVM has + specifically been instructed to retain these annotations via some + implementation-specific mechanism such as a command line flag. In the + absence of such instructions, the JVM ignores this attribute. + + + Hotspot loads them into the same bytearray as the runtime visible parameter + annotations (after the runtime visible parameter annotations). But in J2SE + the bytearray will only be parsed as if there is only one annotation + structure in it, so the runtime invisible parameter annotatios will be + ignored. + + Therefore I do not even bother to read them. + + RuntimeInvisibleParameterAnnotations_attribute { + u2 attribute_name_index; + u4 attribute_length; + u1 num_parameters; + { + u2 num_annotations; + annotation annotations[num_annotations]; + } parameter_annotations[num_parameters]; + } + + IN: + cb.................classbuffer from which to read the data. + m..................methodinfo for the method of which the parameter + annotations are read and into which the parameter + annotations are stored into. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimeinvisibleparameterannotations( + classbuffer *cb, methodinfo *m) +{ + return loader_skip_attribute_body(cb); +} + + +/* annotation_load_class_attribute_runtimevisibleannotations ****************** + + Load runtime visible annotations of a class. + + IN: + cb........the classbuffer from which the attribute has to be loaded. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_class_attribute_runtimevisibleannotations( + classbuffer *cb) +{ + java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ + + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible annotations class attribute")) { + return false; + } + + LLNI_classinfo_field_set(cb->clazz, annotations, (java_handle_t*)annotations); + + return true; +} + + +/* annotation_load_class_attribute_runtimeinvisibleannotations **************** + + Load runtime invisible annotations of a class (just skip them). + + IN: + cb........the classbuffer from which the attribute has to be loaded. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_class_attribute_runtimeinvisibleannotations( + classbuffer *cb) +{ + return loader_skip_attribute_body(cb); +} + + +/* annotation_load_method_attribute_runtimevisibleannotations ***************** + + Load runtime visible annotations of a method. + + IN: + cb........the classbuffer from which the attribute has to be loaded. + m.........the method of which the runtime visible annotations have + to be loaded. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimevisibleannotations( + classbuffer *cb, methodinfo *m) +{ + int slot = 0; + /* slot of the method */ + java_handle_bytearray_t *annotations = NULL; + /* unparsed annotations */ + java_handle_t *method_annotations = NULL; + /* array of unparsed method annotations */ + + assert(cb != NULL); + assert(m != NULL); + + LLNI_classinfo_field_get( + m->clazz, method_annotations, method_annotations); + + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible annotations method attribute")) { + return false; + } + + if (annotations != NULL) { + slot = m - m->clazz->methods; + method_annotations = annotation_bytearrays_insert( + method_annotations, slot, annotations); + + if (method_annotations == NULL) { + return false; + } + + LLNI_classinfo_field_set( + m->clazz, method_annotations, method_annotations); + } + + return true; +} + + +/* annotation_load_method_attribute_runtimeinvisibleannotations **************** + + Load runtime invisible annotations of a method (just skip them). + + IN: + cb........the classbuffer from which the attribute has to be loaded. + m.........the method of which the runtime invisible annotations have + to be loaded. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_method_attribute_runtimeinvisibleannotations( + classbuffer *cb, methodinfo *m) +{ + return loader_skip_attribute_body(cb); +} + + +/* annotation_load_field_attribute_runtimevisibleannotations ****************** + + Load runtime visible annotations of a field. + + IN: + cb........the classbuffer from which the attribute has to be loaded. + f.........the field of which the runtime visible annotations have + to be loaded. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_field_attribute_runtimevisibleannotations( + classbuffer *cb, fieldinfo *f) +{ + int slot = 0; + /* slot of the field */ + java_handle_bytearray_t *annotations = NULL; + /* unparsed annotations */ + java_handle_t *field_annotations = NULL; + /* array of unparsed field annotations */ + + assert(cb != NULL); + assert(f != NULL); + + LLNI_classinfo_field_get( + f->clazz, field_annotations, field_annotations); + + if (!annotation_load_attribute_body( + cb, &annotations, + "invalid runtime visible annotations field attribute")) { + return false; + } + + if (annotations != NULL) { + slot = f - f->clazz->fields; + field_annotations = annotation_bytearrays_insert( + field_annotations, slot, annotations); + + if (field_annotations == NULL) { + return false; + } + + LLNI_classinfo_field_set( + f->clazz, field_annotations, field_annotations); + } + + return true; +} + + +/* annotation_load_field_attribute_runtimeinvisibleannotations **************** + + Load runtime invisible annotations of a field (just skip them). + + IN: + cb........the classbuffer from which the attribute has to be loaded. + f.........the field of which the runtime invisible annotations have + to be loaded. + + RETURN VALUE: + true if all went good. false otherwhise. + +*******************************************************************************/ + +bool annotation_load_field_attribute_runtimeinvisibleannotations( + classbuffer *cb, fieldinfo *f) +{ + return loader_skip_attribute_body(cb); +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/annotation.h b/src/vm/annotation.h new file mode 100644 index 000000000..2450132b2 --- /dev/null +++ b/src/vm/annotation.h @@ -0,0 +1,93 @@ +/* src/vm/annotation.h - class annotations + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _ANNOTATION_H +#define _ANNOTATION_H + + +#include "config.h" + +#include "vm/types.h" + +#include "vm/class.h" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/method.h" + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +bool annotation_load_class_attribute_runtimevisibleannotations( + classbuffer *cb); + +bool annotation_load_class_attribute_runtimeinvisibleannotations( + classbuffer *cb); + +bool annotation_load_method_attribute_runtimevisibleannotations( + classbuffer *cb, methodinfo *m); + +bool annotation_load_method_attribute_runtimeinvisibleannotations( + classbuffer *cb, methodinfo *m); + +bool annotation_load_field_attribute_runtimevisibleannotations( + classbuffer *cb, fieldinfo *f); + +bool annotation_load_field_attribute_runtimeinvisibleannotations( + classbuffer *cb, fieldinfo *f); + +bool annotation_load_method_attribute_annotationdefault( + classbuffer *cb, methodinfo *m); + +bool annotation_load_method_attribute_runtimevisibleparameterannotations( + classbuffer *cb, methodinfo *m); + +bool annotation_load_method_attribute_runtimeinvisibleparameterannotations( + classbuffer *cb, methodinfo *m); + +#ifdef __cplusplus +} +#endif + +#endif /* _ANNOTATION_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/array.c b/src/vm/array.c index 30f231d3e..58fdff3c7 100644 --- a/src/vm/array.c +++ b/src/vm/array.c @@ -30,10 +30,10 @@ #include "native/llni.h" #include "vm/array.h" -#include "vm/exceptions.h" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/primitive.h" -#include "vm/vm.h" +#include "vm/primitive.hpp" +#include "vm/vm.hpp" /* array_element_get *********************************************************** @@ -60,7 +60,7 @@ java_handle_t *array_element_get(java_handle_t *a, int32_t index) value = array_element_primitive_get(a, index); - o = primitive_box(type, value); + o = Primitive_box(type, value); return o; } @@ -76,7 +76,7 @@ void array_element_set(java_handle_t *a, int32_t index, java_handle_t *o) { imm_union value; - value = primitive_unbox(o); + value = Primitive_unbox(o); array_element_primitive_set(a, index, value); } diff --git a/src/vm/array.h b/src/vm/array.h index 3425d5912..132855ce8 100644 --- a/src/vm/array.h +++ b/src/vm/array.h @@ -30,8 +30,12 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/global.h" -#include "vm/primitive.h" +#include "vm/primitive.hpp" /* array types ****************************************************************/ @@ -81,6 +85,10 @@ void array_objectarray_element_set(java_handle_objectarray_t *a, int32 int32_t array_length_get(java_handle_t *a); +#ifdef __cplusplus +} +#endif + #endif /* _VM_ARRAY_H */ diff --git a/src/vm/assertion.c b/src/vm/assertion.c index 6a1f0f694..efe40b277 100644 --- a/src/vm/assertion.c +++ b/src/vm/assertion.c @@ -34,9 +34,8 @@ #include "vm/assertion.h" #include "vm/global.h" -#include "vm/vm.h" - -#include "vmcore/system.h" +#include "vm/os.hpp" +#include "vm/vm.hpp" /* -ea/-da options ************************************************************/ @@ -68,13 +67,13 @@ void assertion_ea_da(const char *name, bool enabled) } package = false; - len = system_strlen(name); + len = os_strlen(name); if (name[len - 1] == '/') { return; } - buf = system_strdup(name); + buf = os_strdup(name); if (buf == NULL) { vm_abort("assertion_ea_da: strdup failed: %s", strerror(errno)); @@ -94,7 +93,7 @@ void assertion_ea_da(const char *name, bool enabled) assertion_class_count += 1; } - len = system_strlen(buf); + len = os_strlen(buf); for (i = 0; i < len; i++) { #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) diff --git a/src/vm/assertion.h b/src/vm/assertion.h index 4175bec64..20add69cc 100644 --- a/src/vm/assertion.h +++ b/src/vm/assertion.h @@ -27,10 +27,16 @@ #define _ASSERTION_H #include "config.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/global.h" #include "toolbox/list.h" -#include typedef struct assertion_name_t assertion_name_t; @@ -53,6 +59,10 @@ extern bool assertion_system_enabled; void assertion_ea_da(const char *name, bool enabled); +#ifdef __cplusplus +} +#endif + #endif /* _ASSERTION_H */ diff --git a/src/vm/builtin.c b/src/vm/builtin.c deleted file mode 100644 index 9106a7255..000000000 --- a/src/vm/builtin.c +++ /dev/null @@ -1,2338 +0,0 @@ -/* src/vm/builtin.c - functions for unsupported operations - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Contains C functions for JavaVM Instructions that cannot be - translated to machine language directly. Consequently, the - generated machine code for these instructions contains function - calls instead of machine instructions, using the C calling - convention. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "vm/types.h" - -#include "arch.h" -#include "md-abi.h" - -#include "fdlibm/fdlibm.h" -#if defined(__CYGWIN__) && defined(Bias) -# undef Bias -#endif - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" - -#include "threads/lock-common.h" -#include "threads/thread.h" - -#include "toolbox/logging.h" -#include "toolbox/util.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/cycles-stats.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/initialize.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" - -#include "vm/jit/asmpart.h" -#include "vm/jit/trace.h" - -#include "vmcore/class.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/rt-timing.h" - -#if defined(ENABLE_VMLOG) -#include -#endif - - -/* include builtin tables *****************************************************/ - -#include "vm/builtintable.inc" - - -CYCLES_STATS_DECLARE(builtin_new ,100,5) -CYCLES_STATS_DECLARE(builtin_overhead , 80,1) - - -/*============================================================================*/ -/* BUILTIN TABLE MANAGEMENT FUNCTIONS */ -/*============================================================================*/ - -/* builtintable_init *********************************************************** - - Parse the descriptors of builtin functions and create the parsed - descriptors. - -*******************************************************************************/ - -static bool builtintable_init(void) -{ - descriptor_pool *descpool; - builtintable_entry *bte; - methodinfo *m; - int32_t dumpmarker; - - /* mark start of dump memory area */ - - DMARKER; - - /* create a new descriptor pool */ - - descpool = descriptor_pool_new(class_java_lang_Object); - - /* add some entries we need */ - - if (!descriptor_pool_add_class(descpool, utf_java_lang_Object)) - return false; - - if (!descriptor_pool_add_class(descpool, utf_java_lang_Class)) - return false; - - /* first add all descriptors to the pool */ - - for (bte = builtintable_internal; bte->fp != NULL; bte++) { - bte->name = utf_new_char(bte->cname); - bte->descriptor = utf_new_char(bte->cdescriptor); - - if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) { - /* release dump area */ - - DRELEASE; - - return false; - } - } - - for (bte = builtintable_automatic; bte->fp != NULL; bte++) { - bte->descriptor = utf_new_char(bte->cdescriptor); - - if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) { - DRELEASE; - return false; - } - } - - for (bte = builtintable_function; bte->fp != NULL; bte++) { - bte->classname = utf_new_char(bte->cclassname); - bte->name = utf_new_char(bte->cname); - bte->descriptor = utf_new_char(bte->cdescriptor); - - if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) { - DRELEASE; - return false; - } - } - - /* create the class reference table */ - - (void) descriptor_pool_create_classrefs(descpool, NULL); - - /* allocate space for the parsed descriptors */ - - descriptor_pool_alloc_parsed_descriptors(descpool); - - /* Now parse all descriptors. NOTE: builtin-functions are treated - like static methods (no `this' pointer). */ - - for (bte = builtintable_internal; bte->fp != NULL; bte++) { - bte->md = - descriptor_pool_parse_method_descriptor(descpool, - bte->descriptor, - ACC_STATIC | ACC_METHOD_BUILTIN, - NULL); - - /* generate a builtin stub if we need one */ - - if (bte->flags & BUILTINTABLE_FLAG_STUB) { - m = method_new_builtin(bte); - codegen_generate_stub_builtin(m, bte); - } - } - - for (bte = builtintable_automatic; bte->fp != NULL; bte++) { - bte->md = - descriptor_pool_parse_method_descriptor(descpool, - bte->descriptor, - ACC_STATIC | ACC_METHOD_BUILTIN, - NULL); - - /* no stubs should be needed for this table */ - - assert(!bte->flags & BUILTINTABLE_FLAG_STUB); - } - - for (bte = builtintable_function; bte->fp != NULL; bte++) { - bte->md = - descriptor_pool_parse_method_descriptor(descpool, - bte->descriptor, - ACC_STATIC | ACC_METHOD_BUILTIN, - NULL); - - /* generate a builtin stub if we need one */ - - if (bte->flags & BUILTINTABLE_FLAG_STUB) { - m = method_new_builtin(bte); - codegen_generate_stub_builtin(m, bte); - } - } - - /* release dump area */ - - DRELEASE; - - return true; -} - - -/* builtintable_comparator ***************************************************** - - qsort comparator for the automatic builtin table. - -*******************************************************************************/ - -static int builtintable_comparator(const void *a, const void *b) -{ - builtintable_entry *bte1; - builtintable_entry *bte2; - - bte1 = (builtintable_entry *) a; - bte2 = (builtintable_entry *) b; - - return (bte1->opcode < bte2->opcode) ? -1 : (bte1->opcode > bte2->opcode); -} - - -/* builtintable_sort_automatic ************************************************* - - Sorts the automatic builtin table. - -*******************************************************************************/ - -static void builtintable_sort_automatic(void) -{ - s4 entries; - - /* calculate table size statically (`- 1' comment see builtintable.inc) */ - - entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1; - - qsort(builtintable_automatic, entries, sizeof(builtintable_entry), - builtintable_comparator); -} - - -/* builtin_init **************************************************************** - - Initialize the global table of builtin functions. - -*******************************************************************************/ - -bool builtin_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("builtin_init"); - - /* initialize the builtin tables */ - - if (!builtintable_init()) - return false; - - /* sort builtin tables */ - - builtintable_sort_automatic(); - - return true; -} - - -/* builtintable_get_internal *************************************************** - - Finds an entry in the builtintable for internal functions and - returns the a pointer to the structure. - -*******************************************************************************/ - -builtintable_entry *builtintable_get_internal(functionptr fp) -{ - builtintable_entry *bte; - - for (bte = builtintable_internal; bte->fp != NULL; bte++) { - if (bte->fp == fp) - return bte; - } - - return NULL; -} - - -/* builtintable_get_automatic ************************************************** - - Finds an entry in the builtintable for functions which are replaced - automatically and returns the a pointer to the structure. - -*******************************************************************************/ - -builtintable_entry *builtintable_get_automatic(s4 opcode) -{ - builtintable_entry *first; - builtintable_entry *last; - builtintable_entry *middle; - s4 half; - s4 entries; - - /* calculate table size statically (`- 1' comment see builtintable.inc) */ - - entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1; - - first = builtintable_automatic; - last = builtintable_automatic + entries; - - while (entries > 0) { - half = entries / 2; - middle = first + half; - - if (middle->opcode < opcode) { - first = middle + 1; - entries -= half + 1; - } - else - entries = half; - } - - return (first != last ? first : NULL); -} - - -/* builtintable_replace_function *********************************************** - - XXX - -*******************************************************************************/ - -#if defined(ENABLE_JIT) -bool builtintable_replace_function(void *iptr_) -{ - constant_FMIref *mr; - builtintable_entry *bte; - instruction *iptr; - - iptr = (instruction *) iptr_; /* twisti will kill me ;) */ - - /* get name and descriptor of the function */ - - switch (iptr->opc) { - case ICMD_INVOKESTATIC: - /* The instruction MUST be resolved, otherwise we run into - lazy loading troubles. Anyway, we should/can only replace - very VM-close functions. */ - - if (INSTRUCTION_IS_UNRESOLVED(iptr)) - return false; - - mr = iptr->sx.s23.s3.fmiref; - break; - - default: - return false; - } - - /* search the function table */ - - for (bte = builtintable_function; bte->fp != NULL; bte++) { - if ((METHODREF_CLASSNAME(mr) == bte->classname) && - (mr->name == bte->name) && - (mr->descriptor == bte->descriptor)) { - - /* set the values in the instruction */ - - iptr->opc = bte->opcode; - iptr->sx.s23.s3.bte = bte; - - if (bte->flags & BUILTINTABLE_FLAG_EXCEPTION) - iptr->flags.bits |= INS_FLAG_CHECK; - else - iptr->flags.bits &= ~INS_FLAG_CHECK; - - return true; - } - } - - return false; -} -#endif /* defined(ENABLE_JIT) */ - - -/*============================================================================*/ -/* INTERNAL BUILTIN FUNCTIONS */ -/*============================================================================*/ - -/* builtin_instanceof ********************************************************** - - Checks if an object is an instance of some given class (or subclass - of that class). If class is an interface, checks if the interface - is implemented. - - RETURN VALUE: - 1......o is an instance of class or implements the interface - 0......otherwise or if o == NULL - - NOTE: This builtin can be called from NATIVE code only. - -*******************************************************************************/ - -bool builtin_instanceof(java_handle_t *o, classinfo *class) -{ - classinfo *c; - - if (o == NULL) - return 0; - - LLNI_class_get(o, c); - - return class_isanysubclass(c, class); -} - - - -/* builtin_checkcast *********************************************************** - - The same as builtin_instanceof but with the exception - that 1 is returned when (o == NULL). - - NOTE: This builtin can be called from NATIVE code only. - -*******************************************************************************/ - -bool builtin_checkcast(java_handle_t *o, classinfo *class) -{ - classinfo *c; - - if (o == NULL) - return 1; - - LLNI_class_get(o, c); - - if (class_isanysubclass(c, class)) - return 1; - - return 0; -} - - -/* builtin_descriptorscompatible *********************************************** - - Checks if two array type descriptors are assignment compatible. - - RETURN VALUE: - 1......target = desc is possible - 0......otherwise - -*******************************************************************************/ - -static bool builtin_descriptorscompatible(arraydescriptor *desc, arraydescriptor *target) -{ - if (desc == target) - return 1; - - if (desc->arraytype != target->arraytype) - return 0; - - if (desc->arraytype != ARRAYTYPE_OBJECT) - return 1; - - /* {both arrays are arrays of references} */ - - if (desc->dimension == target->dimension) { - if (!desc->elementvftbl) - return 0; - /* an array which contains elements of interface types is - allowed to be casted to Object (JOWENN)*/ - - if ((desc->elementvftbl->baseval < 0) && - (target->elementvftbl->baseval == 1)) - return 1; - - return class_isanysubclass(desc->elementvftbl->clazz, - target->elementvftbl->clazz); - } - - if (desc->dimension < target->dimension) - return 0; - - /* {desc has higher dimension than target} */ - - return class_isanysubclass(pseudo_class_Arraystub, - target->elementvftbl->clazz); -} - - -/* builtin_arraycheckcast ****************************************************** - - Checks if an object is really a subtype of the requested array - type. The object has to be an array to begin with. For simple - arrays (int, short, double, etc.) the types have to match exactly. - For arrays of objects, the type of elements in the array has to be - a subtype (or the same type) of the requested element type. For - arrays of arrays (which in turn can again be arrays of arrays), the - types at the lowest level have to satisfy the corresponding sub - class relation. - - NOTE: This is a FAST builtin and can be called from JIT code only. - -*******************************************************************************/ - -bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass) -{ - arraydescriptor *desc; - - if (o == NULL) - return 1; - - desc = o->vftbl->arraydesc; - - if (desc == NULL) - return 0; - - return builtin_descriptorscompatible(desc, targetclass->vftbl->arraydesc); -} - - -/* builtin_fast_arrayinstanceof ************************************************ - - NOTE: This is a FAST builtin and can be called from JIT code only. - -*******************************************************************************/ - -bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass) -{ - if (o == NULL) - return 0; - - return builtin_fast_arraycheckcast(o, targetclass); -} - - -/* builtin_arrayinstanceof ***************************************************** - - NOTE: This builtin can be called from NATIVE code only. - -*******************************************************************************/ - -bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass) -{ - bool result; - - LLNI_CRITICAL_START; - - result = builtin_fast_arrayinstanceof(LLNI_UNWRAP(h), targetclass); - - LLNI_CRITICAL_END; - - return result; -} - - -/* builtin_throw_exception ***************************************************** - - Sets the exception pointer with the thrown exception and prints some - debugging information. - - NOTE: This is a FAST builtin and can be called from JIT code, - or from asm_vm_call_method. - -*******************************************************************************/ - -void *builtin_throw_exception(java_object_t *xptr) -{ -#if !defined(NDEBUG) - /* print exception trace */ - - if (opt_TraceExceptions) - trace_exception_builtin(xptr); -#endif /* !defined(NDEBUG) */ - - /* actually set the exception */ - - exceptions_set_exception(LLNI_QUICKWRAP(xptr)); - - /* Return a NULL pointer. This is required for vm_call_method to - check for an exception. This is for convenience. */ - - return NULL; -} - - -/* builtin_retrieve_exception ************************************************** - - Gets and clears the exception pointer of the current thread. - - RETURN VALUE: - the exception object, or NULL if no exception was thrown. - - NOTE: This is a FAST builtin and can be called from JIT code, - or from the signal handlers. - -*******************************************************************************/ - -java_object_t *builtin_retrieve_exception(void) -{ - java_handle_t *h; - java_object_t *o; - - /* actually get and clear the exception */ - - h = exceptions_get_and_clear_exception(); - o = LLNI_UNWRAP(h); - - return o; -} - - -/* builtin_canstore ************************************************************ - - Checks, if an object can be stored in an array. - - RETURN VALUE: - 1......possible - 0......otherwise (throws an ArrayStoreException) - - NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. - -*******************************************************************************/ - -bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o) -{ - bool result; - - LLNI_CRITICAL_START; - - result = builtin_fast_canstore(LLNI_DIRECT(oa), LLNI_UNWRAP(o)); - - LLNI_CRITICAL_END; - - /* if not possible, throw an exception */ - - if (result == 0) - exceptions_throw_arraystoreexception(); - - return result; -} - - -/* builtin_fast_canstore ******************************************************* - - Checks, if an object can be stored in an array. - - RETURN VALUE: - 1......possible - 0......otherwise (no exception thrown!) - - NOTE: This is a FAST builtin and can be called from JIT code only. - -*******************************************************************************/ - -bool fast_subtype_check(struct _vftbl *s, struct _vftbl *t) -{ - if (s->subtype_display[t->subtype_depth] == t) - return true; - if (t->subtype_offset != OFFSET(vftbl_t, subtype_display[DISPLAY_SIZE])) - return false; - return s->subtype_depth >= t->subtype_depth && s->subtype_overflow[t->subtype_depth - DISPLAY_SIZE] == t; -} - -bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o) -{ - arraydescriptor *desc; - arraydescriptor *valuedesc; - vftbl_t *componentvftbl; - vftbl_t *valuevftbl; - int32_t baseval; - uint32_t diffval; - bool result; - - if (o == NULL) - return 1; - - /* The following is guaranteed (by verifier checks): - * - * *) oa->...vftbl->arraydesc != NULL - * *) oa->...vftbl->arraydesc->componentvftbl != NULL - * *) o->vftbl is not an interface vftbl - */ - - desc = oa->header.objheader.vftbl->arraydesc; - componentvftbl = desc->componentvftbl; - valuevftbl = o->vftbl; - valuedesc = valuevftbl->arraydesc; - - if ((desc->dimension - 1) == 0) { - /* {oa is a one-dimensional array} */ - /* {oa is an array of references} */ - - if (valuevftbl == componentvftbl) - return 1; - - baseval = componentvftbl->baseval; - - if (baseval <= 0) { - /* an array of interface references */ - - result = ((valuevftbl->interfacetablelength > -baseval) && - (valuevftbl->interfacetable[baseval] != NULL)); - } - else { - result = fast_subtype_check(valuevftbl, componentvftbl); - } - } - else if (valuedesc == NULL) { - /* {oa has dimension > 1} */ - /* {componentvftbl->arraydesc != NULL} */ - - /* check if o is an array */ - - return 0; - } - else { - /* {o is an array} */ - - result = builtin_descriptorscompatible(valuedesc, componentvftbl->arraydesc); - } - - /* return result */ - - return result; -} - - -/* This is an optimized version where a is guaranteed to be one-dimensional */ -bool builtin_fast_canstore_onedim(java_objectarray_t *a, java_object_t *o) -{ - arraydescriptor *desc; - vftbl_t *elementvftbl; - vftbl_t *valuevftbl; - int32_t baseval; - uint32_t diffval; - bool result; - - if (o == NULL) - return 1; - - /* The following is guaranteed (by verifier checks): - * - * *) a->...vftbl->arraydesc != NULL - * *) a->...vftbl->arraydesc->elementvftbl != NULL - * *) a->...vftbl->arraydesc->dimension == 1 - * *) o->vftbl is not an interface vftbl - */ - - desc = a->header.objheader.vftbl->arraydesc; - elementvftbl = desc->elementvftbl; - valuevftbl = o->vftbl; - - /* {a is a one-dimensional array} */ - - if (valuevftbl == elementvftbl) - return 1; - - baseval = elementvftbl->baseval; - - if (baseval <= 0) { - /* an array of interface references */ - result = ((valuevftbl->interfacetablelength > -baseval) && - (valuevftbl->interfacetable[baseval] != NULL)); - } - else { - result = fast_subtype_check(valuevftbl, elementvftbl); - } - - return result; -} - - -/* This is an optimized version where a is guaranteed to be a - * one-dimensional array of a class type */ -bool builtin_fast_canstore_onedim_class(java_objectarray_t *a, java_object_t *o) -{ - vftbl_t *elementvftbl; - vftbl_t *valuevftbl; - uint32_t diffval; - bool result; - - if (o == NULL) - return 1; - - /* The following is guaranteed (by verifier checks): - * - * *) a->...vftbl->arraydesc != NULL - * *) a->...vftbl->arraydesc->elementvftbl != NULL - * *) a->...vftbl->arraydesc->elementvftbl is not an interface vftbl - * *) a->...vftbl->arraydesc->dimension == 1 - * *) o->vftbl is not an interface vftbl - */ - - elementvftbl = a->header.objheader.vftbl->arraydesc->elementvftbl; - valuevftbl = o->vftbl; - - /* {a is a one-dimensional array} */ - - if (valuevftbl == elementvftbl) - return 1; - - result = fast_subtype_check(valuevftbl, elementvftbl); - - return result; -} - - -/* builtin_new ***************************************************************** - - Creates a new instance of class c on the heap. - - RETURN VALUE: - pointer to the object, or NULL if no memory is available - - NOTE: This builtin can be called from NATIVE code only. - -*******************************************************************************/ - -java_handle_t *builtin_new(classinfo *c) -{ - java_handle_t *o; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_end; -#endif -#if defined(ENABLE_CYCLES_STATS) - u8 cycles_start, cycles_end; -#endif - - RT_TIMING_GET_TIME(time_start); - CYCLES_STATS_GET(cycles_start); - - /* is the class loaded */ - - assert(c->state & CLASS_LOADED); - - /* check if we can instantiate this class */ - - if (c->flags & ACC_ABSTRACT) { - exceptions_throw_instantiationerror(c); - return NULL; - } - - /* is the class linked */ - - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - return NULL; - - if (!(c->state & CLASS_INITIALIZED)) { -#if !defined(NDEBUG) - if (initverbose) - log_message_class("Initialize class (from builtin_new): ", c); -#endif - - if (!initialize_class(c)) - return NULL; - } - - o = heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS, - c->finalizer, true); - - if (!o) - return NULL; - -#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) - /* XXX this is only a dirty hack to make Boehm work with handles */ - - o = LLNI_WRAP((java_object_t *) o); -#endif - - LLNI_vftbl_direct(o) = c->vftbl; - -#if defined(ENABLE_THREADS) - lock_init_object_lock(LLNI_DIRECT(o)); -#endif - - CYCLES_STATS_GET(cycles_end); - RT_TIMING_GET_TIME(time_end); - - CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start); - RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT); - - return o; -} - - -/* builtin_java_new ************************************************************ - - NOTE: This is a SLOW builtin and can be called from JIT code only. - -*******************************************************************************/ - -java_handle_t *builtin_java_new(java_handle_t *clazz) -{ - return builtin_new(LLNI_classinfo_unwrap(clazz)); -} - - -/* builtin_fast_new ************************************************************ - - Creates a new instance of class c on the heap. - - RETURN VALUE: - pointer to the object, or NULL if no fast return - is possible for any reason. - - NOTE: This is a FAST builtin and can be called from JIT code only. - -*******************************************************************************/ - -java_object_t *builtin_fast_new(classinfo *c) -{ - java_object_t *o; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_end; -#endif -#if defined(ENABLE_CYCLES_STATS) - u8 cycles_start, cycles_end; -#endif - - RT_TIMING_GET_TIME(time_start); - CYCLES_STATS_GET(cycles_start); - - /* is the class loaded */ - - assert(c->state & CLASS_LOADED); - - /* check if we can instantiate this class */ - - if (c->flags & ACC_ABSTRACT) - return NULL; - - /* is the class linked */ - - if (!(c->state & CLASS_LINKED)) - return NULL; - - if (!(c->state & CLASS_INITIALIZED)) - return NULL; - - o = heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS, - c->finalizer, false); - - if (!o) - return NULL; - - o->vftbl = c->vftbl; - -#if defined(ENABLE_THREADS) - lock_init_object_lock(o); -#endif - - CYCLES_STATS_GET(cycles_end); - RT_TIMING_GET_TIME(time_end); - - CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start); - RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT); - - return o; -} - - -/* builtin_newarray ************************************************************ - - Creates an array with the given vftbl on the heap. This function - takes as class argument an array class. - - RETURN VALUE: - pointer to the array or NULL if no memory is available - - NOTE: This builtin can be called from NATIVE code only. - -*******************************************************************************/ - -java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass) -{ - arraydescriptor *desc; - s4 dataoffset; - s4 componentsize; - s4 actualsize; - java_handle_t *a; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_end; -#endif - - RT_TIMING_GET_TIME(time_start); - - desc = arrayclass->vftbl->arraydesc; - dataoffset = desc->dataoffset; - componentsize = desc->componentsize; - - if (size < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } - - actualsize = dataoffset + size * componentsize; - - /* check for overflow */ - - if (((u4) actualsize) < ((u4) size)) { - exceptions_throw_outofmemoryerror(); - return NULL; - } - - a = heap_alloc(actualsize, (desc->arraytype == ARRAYTYPE_OBJECT), NULL, true); - - if (a == NULL) - return NULL; - -#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) - /* XXX this is only a dirty hack to make Boehm work with handles */ - - a = LLNI_WRAP((java_object_t *) a); -#endif - - LLNI_vftbl_direct(a) = arrayclass->vftbl; - -#if defined(ENABLE_THREADS) - lock_init_object_lock(LLNI_DIRECT(a)); -#endif - - LLNI_array_size(a) = size; - - RT_TIMING_GET_TIME(time_end); - RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_ARRAY); - - return a; -} - - -/* builtin_java_newarray ******************************************************* - - NOTE: This is a SLOW builtin and can be called from JIT code only. - -*******************************************************************************/ - -java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclazz) -{ - return builtin_newarray(size, LLNI_classinfo_unwrap(arrayclazz)); -} - - -/* builtin_anewarray *********************************************************** - - Creates an array of references to the given class type on the heap. - - RETURN VALUE: - pointer to the array or NULL if no memory is - available - - NOTE: This builtin can be called from NATIVE code only. - -*******************************************************************************/ - -java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass) -{ - classinfo *arrayclass; - - /* is class loaded */ - - assert(componentclass->state & CLASS_LOADED); - - /* is class linked */ - - if (!(componentclass->state & CLASS_LINKED)) - if (!link_class(componentclass)) - return NULL; - - arrayclass = class_array_of(componentclass, true); - - if (!arrayclass) - return NULL; - - return (java_handle_objectarray_t *) builtin_newarray(size, arrayclass); -} - - -/* builtin_newarray_type **************************************************** - - Creates an array of [type]s on the heap. - - RETURN VALUE: - pointer to the array or NULL if no memory is available - - NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. - -*******************************************************************************/ - -#define BUILTIN_NEWARRAY_TYPE(type, arraytype) \ -java_handle_##type##array_t *builtin_newarray_##type(int32_t size) \ -{ \ - return (java_handle_##type##array_t *) \ - builtin_newarray(size, primitivetype_table[arraytype].arrayclass); \ -} - -BUILTIN_NEWARRAY_TYPE(boolean, ARRAYTYPE_BOOLEAN) -BUILTIN_NEWARRAY_TYPE(byte, ARRAYTYPE_BYTE) -BUILTIN_NEWARRAY_TYPE(char, ARRAYTYPE_CHAR) -BUILTIN_NEWARRAY_TYPE(short, ARRAYTYPE_SHORT) -BUILTIN_NEWARRAY_TYPE(int, ARRAYTYPE_INT) -BUILTIN_NEWARRAY_TYPE(long, ARRAYTYPE_LONG) -BUILTIN_NEWARRAY_TYPE(float, ARRAYTYPE_FLOAT) -BUILTIN_NEWARRAY_TYPE(double, ARRAYTYPE_DOUBLE) - - -/* builtin_multianewarray_intern *********************************************** - - Creates a multi-dimensional array on the heap. The dimensions are - passed in an array of longs. - - ARGUMENTS: - n.............number of dimensions to create - arrayclass....the array class - dims..........array containing the size of each dimension to create - - RETURN VALUE: - pointer to the array or NULL if no memory is available - -******************************************************************************/ - -static java_handle_t *builtin_multianewarray_intern(int n, - classinfo *arrayclass, - long *dims) -{ - s4 size; - java_handle_t *a; - classinfo *componentclass; - s4 i; - - /* create this dimension */ - - size = (s4) dims[0]; - a = builtin_newarray(size, arrayclass); - - if (!a) - return NULL; - - /* if this is the last dimension return */ - - if (!--n) - return a; - - /* get the class of the components to create */ - - componentclass = arrayclass->vftbl->arraydesc->componentvftbl->clazz; - - /* The verifier guarantees that the dimension count is in the range. */ - - /* create the component arrays */ - - for (i = 0; i < size; i++) { - java_handle_t *ea = -#if defined(__MIPS__) && (SIZEOF_VOID_P == 4) - /* we save an s4 to a s8 slot, 8-byte aligned */ - - builtin_multianewarray_intern(n, componentclass, dims + 2); -#else - builtin_multianewarray_intern(n, componentclass, dims + 1); -#endif - - if (!ea) - return NULL; - - array_objectarray_element_set((java_handle_objectarray_t *) a, i, ea); - } - - return a; -} - - -/* builtin_multianewarray ****************************************************** - - Wrapper for builtin_multianewarray_intern which checks all - dimensions before we start allocating. - - NOTE: This is a SLOW builtin and can be called from JIT code only. - -******************************************************************************/ - -java_handle_objectarray_t *builtin_multianewarray(int n, - java_handle_t *arrayclazz, - long *dims) -{ - classinfo *c; - s4 i; - s4 size; - - /* check all dimensions before doing anything */ - - for (i = 0; i < n; i++) { -#if defined(__MIPS__) && (SIZEOF_VOID_P == 4) - /* we save an s4 to a s8 slot, 8-byte aligned */ - size = (s4) dims[i * 2]; -#else - size = (s4) dims[i]; -#endif - - if (size < 0) { - exceptions_throw_negativearraysizeexception(); - return NULL; - } - } - - c = LLNI_classinfo_unwrap(arrayclazz); - - /* now call the real function */ - - return (java_handle_objectarray_t *) - builtin_multianewarray_intern(n, c, dims); -} - - -/* builtin_verbosecall_enter *************************************************** - - Print method call with arguments for -verbose:call. - - XXX: Remove mew once all archs use the new tracer! - -*******************************************************************************/ - -#if !defined(NDEBUG) -#ifdef TRACE_ARGS_NUM -void builtin_verbosecall_enter(s8 a0, s8 a1, -# if TRACE_ARGS_NUM >= 4 - s8 a2, s8 a3, -# endif -# if TRACE_ARGS_NUM >= 6 - s8 a4, s8 a5, -# endif -# if TRACE_ARGS_NUM == 8 - s8 a6, s8 a7, -# endif - methodinfo *m) -{ - log_text("builtin_verbosecall_enter: Do not call me anymore!"); -} -#endif -#endif /* !defined(NDEBUG) */ - - -/* builtin_verbosecall_exit **************************************************** - - Print method exit for -verbose:call. - - XXX: Remove mew once all archs use the new tracer! - -*******************************************************************************/ - -#if !defined(NDEBUG) -void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m) -{ - log_text("builtin_verbosecall_exit: Do not call me anymore!"); -} -#endif /* !defined(NDEBUG) */ - - -/*============================================================================*/ -/* MISCELLANEOUS MATHEMATICAL HELPER FUNCTIONS */ -/*============================================================================*/ - -/*********** Functions for integer divisions ***************************** - - On some systems (eg. DEC ALPHA), integer division is not supported by the - CPU. These helper functions implement the missing functionality. - -******************************************************************************/ - -#if !SUPPORT_DIVISION || defined(DISABLE_GC) -s4 builtin_idiv(s4 a, s4 b) -{ - s4 c; - - c = a / b; - - return c; -} - -s4 builtin_irem(s4 a, s4 b) -{ - s4 c; - - c = a % b; - - return c; -} -#endif /* !SUPPORT_DIVISION || defined(DISABLE_GC) */ - - -/* functions for long arithmetics ********************************************** - - On systems where 64 bit Integers are not supported by the CPU, - these functions are needed. - -******************************************************************************/ - -#if !(SUPPORT_LONG && SUPPORT_LONG_ADD) -s8 builtin_ladd(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a + b; -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lsub(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a - b; -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lneg(s8 a) -{ - s8 c; - -#if U8_AVAILABLE - c = -a; -#else - c = builtin_i2l(0); -#endif - - return c; -} -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */ - - -#if !(SUPPORT_LONG && SUPPORT_LONG_MUL) -s8 builtin_lmul(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a * b; -#else - c = builtin_i2l(0); -#endif - - return c; -} -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_MUL) */ - - -#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined (DISABLE_GC) -s8 builtin_ldiv(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a / b; -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lrem(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a % b; -#else - c = builtin_i2l(0); -#endif - - return c; -} -#endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */ - - -#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) -s8 builtin_lshl(s8 a, s4 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a << (b & 63); -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lshr(s8 a, s4 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a >> (b & 63); -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lushr(s8 a, s4 b) -{ - s8 c; - -#if U8_AVAILABLE - c = ((u8) a) >> (b & 63); -#else - c = builtin_i2l(0); -#endif - - return c; -} -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */ - - -#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) -s8 builtin_land(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a & b; -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lor(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a | b; -#else - c = builtin_i2l(0); -#endif - - return c; -} - -s8 builtin_lxor(s8 a, s8 b) -{ - s8 c; - -#if U8_AVAILABLE - c = a ^ b; -#else - c = builtin_i2l(0); -#endif - - return c; -} -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */ - - -#if !(SUPPORT_LONG && SUPPORT_LONG_CMP) -s4 builtin_lcmp(s8 a, s8 b) -{ -#if U8_AVAILABLE - if (a < b) - return -1; - - if (a > b) - return 1; - - return 0; -#else - return 0; -#endif -} -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_CMP) */ - - -/* functions for unsupported floating instructions ****************************/ - -/* used to convert FLT_xxx defines into float values */ - -static inline float intBitsToFloat(s4 i) -{ - imm_union imb; - - imb.i = i; - return imb.f; -} - - -/* used to convert DBL_xxx defines into double values */ - -static inline float longBitsToDouble(s8 l) -{ - imm_union imb; - - imb.l = l; - return imb.d; -} - - -#if !SUPPORT_FLOAT -float builtin_fadd(float a, float b) -{ - if (isnanf(a)) return intBitsToFloat(FLT_NAN); - if (isnanf(b)) return intBitsToFloat(FLT_NAN); - if (finitef(a)) { - if (finitef(b)) - return a + b; - else - return b; - } - else { - if (finitef(b)) - return a; - else { - if (copysignf(1.0, a) == copysignf(1.0, b)) - return a; - else - return intBitsToFloat(FLT_NAN); - } - } -} - - -float builtin_fsub(float a, float b) -{ - return builtin_fadd(a, builtin_fneg(b)); -} - - -float builtin_fmul(float a, float b) -{ - if (isnanf(a)) return intBitsToFloat(FLT_NAN); - if (isnanf(b)) return intBitsToFloat(FLT_NAN); - if (finitef(a)) { - if (finitef(b)) return a * b; - else { - if (a == 0) return intBitsToFloat(FLT_NAN); - else return copysignf(b, copysignf(1.0, b)*a); - } - } - else { - if (finitef(b)) { - if (b == 0) return intBitsToFloat(FLT_NAN); - else return copysignf(a, copysignf(1.0, a)*b); - } - else { - return copysignf(a, copysignf(1.0, a)*copysignf(1.0, b)); - } - } -} - - -/* builtin_ddiv **************************************************************** - - Implementation as described in VM Spec. - -*******************************************************************************/ - -float builtin_fdiv(float a, float b) -{ - if (finitef(a)) { - if (finitef(b)) { - /* If neither value1' nor value2' is NaN, the sign of the result */ - /* is positive if both values have the same sign, negative if the */ - /* values have different signs. */ - - return a / b; - - } else { - if (isnanf(b)) { - /* If either value1' or value2' is NaN, the result is NaN. */ - - return intBitsToFloat(FLT_NAN); - - } else { - /* Division of a finite value by an infinity results in a */ - /* signed zero, with the sign-producing rule just given. */ - - /* is sign equal? */ - - if (copysignf(1.0, a) == copysignf(1.0, b)) - return 0.0; - else - return -0.0; - } - } - - } else { - if (isnanf(a)) { - /* If either value1' or value2' is NaN, the result is NaN. */ - - return intBitsToFloat(FLT_NAN); - - } else if (finitef(b)) { - /* Division of an infinity by a finite value results in a signed */ - /* infinity, with the sign-producing rule just given. */ - - /* is sign equal? */ - - if (copysignf(1.0, a) == copysignf(1.0, b)) - return intBitsToFloat(FLT_POSINF); - else - return intBitsToFloat(FLT_NEGINF); - - } else { - /* Division of an infinity by an infinity results in NaN. */ - - return intBitsToFloat(FLT_NAN); - } - } -} - - -float builtin_fneg(float a) -{ - if (isnanf(a)) return a; - else { - if (finitef(a)) return -a; - else return copysignf(a, -copysignf(1.0, a)); - } -} -#endif /* !SUPPORT_FLOAT */ - - -#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP) -s4 builtin_fcmpl(float a, float b) -{ - if (isnanf(a)) - return -1; - - if (isnanf(b)) - return -1; - - if (!finitef(a) || !finitef(b)) { - a = finitef(a) ? 0 : copysignf(1.0, a); - b = finitef(b) ? 0 : copysignf(1.0, b); - } - - if (a > b) - return 1; - - if (a == b) - return 0; - - return -1; -} - - -s4 builtin_fcmpg(float a, float b) -{ - if (isnanf(a)) return 1; - if (isnanf(b)) return 1; - if (!finitef(a) || !finitef(b)) { - a = finitef(a) ? 0 : copysignf(1.0, a); - b = finitef(b) ? 0 : copysignf(1.0, b); - } - if (a > b) return 1; - if (a == b) return 0; - return -1; -} -#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP) */ - - -float builtin_frem(float a, float b) -{ - return fmodf(a, b); -} - - -/* functions for unsupported double instructions ******************************/ - -#if !SUPPORT_DOUBLE -double builtin_dadd(double a, double b) -{ - if (isnan(a)) return longBitsToDouble(DBL_NAN); - if (isnan(b)) return longBitsToDouble(DBL_NAN); - if (finite(a)) { - if (finite(b)) return a + b; - else return b; - } - else { - if (finite(b)) return a; - else { - if (copysign(1.0, a)==copysign(1.0, b)) return a; - else return longBitsToDouble(DBL_NAN); - } - } -} - - -double builtin_dsub(double a, double b) -{ - return builtin_dadd(a, builtin_dneg(b)); -} - - -double builtin_dmul(double a, double b) -{ - if (isnan(a)) return longBitsToDouble(DBL_NAN); - if (isnan(b)) return longBitsToDouble(DBL_NAN); - if (finite(a)) { - if (finite(b)) return a * b; - else { - if (a == 0) return longBitsToDouble(DBL_NAN); - else return copysign(b, copysign(1.0, b) * a); - } - } - else { - if (finite(b)) { - if (b == 0) return longBitsToDouble(DBL_NAN); - else return copysign(a, copysign(1.0, a) * b); - } - else { - return copysign(a, copysign(1.0, a) * copysign(1.0, b)); - } - } -} - - -/* builtin_ddiv **************************************************************** - - Implementation as described in VM Spec. - -*******************************************************************************/ - -double builtin_ddiv(double a, double b) -{ - if (finite(a)) { - if (finite(b)) { - /* If neither value1' nor value2' is NaN, the sign of the result */ - /* is positive if both values have the same sign, negative if the */ - /* values have different signs. */ - - return a / b; - - } else { - if (isnan(b)) { - /* If either value1' or value2' is NaN, the result is NaN. */ - - return longBitsToDouble(DBL_NAN); - - } else { - /* Division of a finite value by an infinity results in a */ - /* signed zero, with the sign-producing rule just given. */ - - /* is sign equal? */ - - if (copysign(1.0, a) == copysign(1.0, b)) - return 0.0; - else - return -0.0; - } - } - - } else { - if (isnan(a)) { - /* If either value1' or value2' is NaN, the result is NaN. */ - - return longBitsToDouble(DBL_NAN); - - } else if (finite(b)) { - /* Division of an infinity by a finite value results in a signed */ - /* infinity, with the sign-producing rule just given. */ - - /* is sign equal? */ - - if (copysign(1.0, a) == copysign(1.0, b)) - return longBitsToDouble(DBL_POSINF); - else - return longBitsToDouble(DBL_NEGINF); - - } else { - /* Division of an infinity by an infinity results in NaN. */ - - return longBitsToDouble(DBL_NAN); - } - } -} - - -/* builtin_dneg **************************************************************** - - Implemented as described in VM Spec. - -*******************************************************************************/ - -double builtin_dneg(double a) -{ - if (isnan(a)) { - /* If the operand is NaN, the result is NaN (recall that NaN has no */ - /* sign). */ - - return a; - - } else { - if (finite(a)) { - /* If the operand is a zero, the result is the zero of opposite */ - /* sign. */ - - return -a; - - } else { - /* If the operand is an infinity, the result is the infinity of */ - /* opposite sign. */ - - return copysign(a, -copysign(1.0, a)); - } - } -} -#endif /* !SUPPORT_DOUBLE */ - - -#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP) -s4 builtin_dcmpl(double a, double b) -{ - if (isnan(a)) - return -1; - - if (isnan(b)) - return -1; - - if (!finite(a) || !finite(b)) { - a = finite(a) ? 0 : copysign(1.0, a); - b = finite(b) ? 0 : copysign(1.0, b); - } - - if (a > b) - return 1; - - if (a == b) - return 0; - - return -1; -} - - -s4 builtin_dcmpg(double a, double b) -{ - if (isnan(a)) - return 1; - - if (isnan(b)) - return 1; - - if (!finite(a) || !finite(b)) { - a = finite(a) ? 0 : copysign(1.0, a); - b = finite(b) ? 0 : copysign(1.0, b); - } - - if (a > b) - return 1; - - if (a == b) - return 0; - - return -1; -} -#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP) */ - - -double builtin_drem(double a, double b) -{ - return fmod(a, b); -} - - -/* conversion operations ******************************************************/ - -#if 0 -s8 builtin_i2l(s4 i) -{ -#if U8_AVAILABLE - return i; -#else - s8 v; - v.high = 0; - v.low = i; - return v; -#endif -} - -s4 builtin_l2i(s8 l) -{ -#if U8_AVAILABLE - return (s4) l; -#else - return l.low; -#endif -} -#endif - - -#if !(SUPPORT_FLOAT && SUPPORT_I2F) -float builtin_i2f(s4 a) -{ - float f = (float) a; - return f; -} -#endif /* !(SUPPORT_FLOAT && SUPPORT_I2F) */ - - -#if !(SUPPORT_DOUBLE && SUPPORT_I2D) -double builtin_i2d(s4 a) -{ - double d = (double) a; - return d; -} -#endif /* !(SUPPORT_DOUBLE && SUPPORT_I2D) */ - - -#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) -float builtin_l2f(s8 a) -{ -#if U8_AVAILABLE - float f = (float) a; - return f; -#else - return 0.0; -#endif -} -#endif /* !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) */ - - -#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) -double builtin_l2d(s8 a) -{ -#if U8_AVAILABLE - double d = (double) a; - return d; -#else - return 0.0; -#endif -} -#endif /* !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) */ - - -#if !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) -s4 builtin_f2i(float a) -{ - s4 i; - - i = builtin_d2i((double) a); - - return i; - - /* float f; - - if (isnanf(a)) - return 0; - if (finitef(a)) { - if (a > 2147483647) - return 2147483647; - if (a < (-2147483648)) - return (-2147483648); - return (s4) a; - } - f = copysignf((float) 1.0, a); - if (f > 0) - return 2147483647; - return (-2147483648); */ -} -#endif /* !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */ - - -#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) || defined(DISABLE_GC) -s8 builtin_f2l(float a) -{ - s8 l; - - l = builtin_d2l((double) a); - - return l; - - /* float f; - - if (finitef(a)) { - if (a > 9223372036854775807L) - return 9223372036854775807L; - if (a < (-9223372036854775808L)) - return (-9223372036854775808L); - return (s8) a; - } - if (isnanf(a)) - return 0; - f = copysignf((float) 1.0, a); - if (f > 0) - return 9223372036854775807L; - return (-9223372036854775808L); */ -} -#endif /* !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) */ - - -#if !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) -s4 builtin_d2i(double a) -{ - double d; - - if (finite(a)) { - if (a >= 2147483647) - return 2147483647; - if (a <= (-2147483647-1)) - return (-2147483647-1); - return (s4) a; - } - if (isnan(a)) - return 0; - d = copysign(1.0, a); - if (d > 0) - return 2147483647; - return (-2147483647-1); -} -#endif /* !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */ - - -#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) || defined(DISABLE_GC) -s8 builtin_d2l(double a) -{ - double d; - - if (finite(a)) { - if (a >= 9223372036854775807LL) - return 9223372036854775807LL; - if (a <= (-9223372036854775807LL-1)) - return (-9223372036854775807LL-1); - return (s8) a; - } - if (isnan(a)) - return 0; - d = copysign(1.0, a); - if (d > 0) - return 9223372036854775807LL; - return (-9223372036854775807LL-1); -} -#endif /* !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) */ - - -#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE) -double builtin_f2d(float a) -{ - if (finitef(a)) return (double) a; - else { - if (isnanf(a)) - return longBitsToDouble(DBL_NAN); - else - return copysign(longBitsToDouble(DBL_POSINF), (double) copysignf(1.0, a) ); - } -} - -float builtin_d2f(double a) -{ - if (finite(a)) - return (float) a; - else { - if (isnan(a)) - return intBitsToFloat(FLT_NAN); - else - return copysignf(intBitsToFloat(FLT_POSINF), (float) copysign(1.0, a)); - } -} -#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */ - - -/*============================================================================*/ -/* AUTOMATICALLY REPLACED FUNCTIONS */ -/*============================================================================*/ - -/* builtin_arraycopy *********************************************************** - - Builtin for java.lang.System.arraycopy. - - NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. - -*******************************************************************************/ - -void builtin_arraycopy(java_handle_t *src, s4 srcStart, - java_handle_t *dest, s4 destStart, s4 len) -{ - arraydescriptor *sdesc; - arraydescriptor *ddesc; - s4 i; - - if ((src == NULL) || (dest == NULL)) { - exceptions_throw_nullpointerexception(); - return; - } - - sdesc = LLNI_vftbl_direct(src)->arraydesc; - ddesc = LLNI_vftbl_direct(dest)->arraydesc; - - if (!sdesc || !ddesc || (sdesc->arraytype != ddesc->arraytype)) { - exceptions_throw_arraystoreexception(); - return; - } - - /* we try to throw exception with the same message as SUN does */ - - if ((len < 0) || (srcStart < 0) || (destStart < 0) || - (srcStart + len < 0) || (srcStart + len > LLNI_array_size(src)) || - (destStart + len < 0) || (destStart + len > LLNI_array_size(dest))) { - exceptions_throw_arrayindexoutofboundsexception(); - return; - } - - if (sdesc->componentvftbl == ddesc->componentvftbl) { - /* We copy primitive values or references of exactly the same type */ - - s4 dataoffset = sdesc->dataoffset; - s4 componentsize = sdesc->componentsize; - - LLNI_CRITICAL_START; - - MMOVE(((u1 *) LLNI_DIRECT(dest)) + dataoffset + componentsize * destStart, - ((u1 *) LLNI_DIRECT(src)) + dataoffset + componentsize * srcStart, - u1, (size_t) len * componentsize); - - LLNI_CRITICAL_END; - } - else { - /* We copy references of different type */ - - java_handle_objectarray_t *oas = (java_handle_objectarray_t *) src; - java_handle_objectarray_t *oad = (java_handle_objectarray_t *) dest; - - if (destStart <= srcStart) { - for (i = 0; i < len; i++) { - java_handle_t *o; - - o = array_objectarray_element_get(oas, srcStart + i); - - if (!builtin_canstore(oad, o)) - return; - - array_objectarray_element_set(oad, destStart + i, o); - } - } - else { - /* XXX this does not completely obey the specification! - If an exception is thrown only the elements above the - current index have been copied. The specification - requires that only the elements *below* the current - index have been copied before the throw. */ - - for (i = len - 1; i >= 0; i--) { - java_handle_t *o; - - o = array_objectarray_element_get(oas, srcStart + i); - - if (!builtin_canstore(oad, o)) - return; - - array_objectarray_element_set(oad, destStart + i, o); - } - } - } -} - - -/* builtin_nanotime ************************************************************ - - Return the current time in nanoseconds. - -*******************************************************************************/ - -s8 builtin_nanotime(void) -{ - struct timeval tv; - s8 usecs; - - if (gettimeofday(&tv, NULL) == -1) - vm_abort("gettimeofday failed: %s", strerror(errno)); - - usecs = (s8) tv.tv_sec * (1000 * 1000) + (s8) tv.tv_usec; - - return usecs * 1000; -} - - -/* builtin_currenttimemillis *************************************************** - - Return the current time in milliseconds. - -*******************************************************************************/ - -s8 builtin_currenttimemillis(void) -{ - s8 msecs; - - msecs = builtin_nanotime() / 1000 / 1000; - - return msecs; -} - - -/* builtin_clone *************************************************************** - - Function for cloning objects or arrays. - - NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. - -*******************************************************************************/ - -java_handle_t *builtin_clone(void *env, java_handle_t *o) -{ - arraydescriptor *ad; - u4 size; - classinfo *c; - java_handle_t *co; /* cloned object header */ - - /* get the array descriptor */ - - ad = LLNI_vftbl_direct(o)->arraydesc; - - /* we are cloning an array */ - - if (ad != NULL) { - size = ad->dataoffset + ad->componentsize * LLNI_array_size(o); - - co = heap_alloc(size, (ad->arraytype == ARRAYTYPE_OBJECT), NULL, true); - - if (co == NULL) - return NULL; - -#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) - /* XXX this is only a dirty hack to make Boehm work with handles */ - - co = LLNI_WRAP((java_object_t *) co); -#endif - - LLNI_CRITICAL_START; - - MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, size); - -#if defined(ENABLE_GC_CACAO) - heap_init_objectheader(LLNI_DIRECT(co), size); -#endif - -#if defined(ENABLE_THREADS) - lock_init_object_lock(LLNI_DIRECT(co)); -#endif - - LLNI_CRITICAL_END; - - return co; - } - - /* we are cloning a non-array */ - - if (!builtin_instanceof(o, class_java_lang_Cloneable)) { - exceptions_throw_clonenotsupportedexception(); - return NULL; - } - - /* get the class of the object */ - - LLNI_class_get(o, c); - - /* create new object */ - - co = builtin_new(c); - - if (co == NULL) - return NULL; - - LLNI_CRITICAL_START; - - MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, c->instancesize); - -#if defined(ENABLE_GC_CACAO) - heap_init_objectheader(LLNI_DIRECT(co), c->instancesize); -#endif - -#if defined(ENABLE_THREADS) - lock_init_object_lock(LLNI_DIRECT(co)); -#endif - - LLNI_CRITICAL_END; - - return co; -} - - -#if defined(ENABLE_CYCLES_STATS) -void builtin_print_cycles_stats(FILE *file) -{ - fprintf(file,"builtin cylce count statistics:\n"); - - CYCLES_STATS_PRINT_OVERHEAD(builtin_overhead,file); - CYCLES_STATS_PRINT(builtin_new ,file); - - fprintf(file,"\n"); -} -#endif /* defined(ENABLE_CYCLES_STATS) */ - - -#if defined(ENABLE_VMLOG) -#define NDEBUG -#include -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/builtin.h b/src/vm/builtin.h deleted file mode 100644 index 773d5c217..000000000 --- a/src/vm/builtin.h +++ /dev/null @@ -1,336 +0,0 @@ -/* src/vm/builtin.h - prototypes of builtin functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _BUILTIN_H -#define _BUILTIN_H - -/* forward typedefs ***********************************************************/ - -typedef struct builtintable_entry builtintable_entry; - -#include "config.h" -#include "vm/types.h" - -#include "arch.h" -#include "md-abi.h" - -#include "toolbox/logging.h" - -#include "vmcore/utf8.h" - - -/* define infinity for floating point numbers */ - -#define FLT_NAN 0x7fc00000 -#define FLT_POSINF 0x7f800000 -#define FLT_NEGINF 0xff800000 - -/* define infinity for double floating point numbers */ - -#define DBL_NAN 0x7ff8000000000000LL -#define DBL_POSINF 0x7ff0000000000000LL -#define DBL_NEGINF 0xfff0000000000000LL - - -/* float versions are not defined in GNU classpath's fdlibm */ - -#define copysignf copysign -#define finitef finite -#define fmodf fmod -#define isnanf isnan - - -/* builtin functions table ****************************************************/ - -struct builtintable_entry { - s4 opcode; /* opcode which is replaced */ - u4 flags; /* e.g. check for exception */ - functionptr fp; /* function pointer of builtin */ - u1 *stub; /* pointer to builtin stub code */ - char *cclassname; /* char name of the class */ - char *cname; /* char name of the function */ - char *cdescriptor; /* char name of the descriptor */ - utf *classname; /* class of the function */ - utf *name; /* name of the function */ - utf *descriptor; /* descriptor of the function */ - methoddesc *md; -}; - - -/* builtin table flag defines *************************************************/ - -#define BUILTINTABLE_FLAG_STUB 0x0001 /* builtin needs a stub */ -#define BUILTINTABLE_FLAG_EXCEPTION 0x0002 /* check for excepion on return */ - - -/* function prototypes ********************************************************/ - -bool builtin_init(void); - -builtintable_entry *builtintable_get_internal(functionptr fp); -builtintable_entry *builtintable_get_automatic(s4 opcode); - -bool builtintable_replace_function(void *iptr); - - -/**********************************************************************/ -/* BUILTIN FUNCTIONS */ -/**********************************************************************/ - -/* NOTE: Builtin functions which are used in the BUILTIN* opcodes must - * have a BUILTIN_... macro defined as seen below. In code dealing - * with the BUILTIN* opcodes the functions may only be addressed by - * these macros, never by their actual name! (This helps to make this - * code more portable.) - * - * C and assembler code which does not deal with the BUILTIN* opcodes, - * can use the builtin functions normally (like all other functions). - * - * IMPORTANT: - * For each builtin function which is used in a BUILTIN* opcode there - * must be an entry in the builtin_desc table in jit/jit.c. - * - * Below each prototype is either the BUILTIN_ macro definition or a - * comment specifiying that this function is not used in BUILTIN* - * opcodes. - * - * (The BUILTIN* opcodes are ICMD_BUILTIN1, ICMD_BUILTIN2 and - * ICMD_BUILTIN3.) - */ - -bool fast_subtype_check(struct _vftbl *, struct _vftbl *); - -bool builtin_instanceof(java_handle_t *obj, classinfo *class); -/* NOT AN OP */ -bool builtin_checkcast(java_handle_t *obj, classinfo *class); -/* NOT AN OP */ -bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass); -/* NOT AN OP */ -bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass); -#define BUILTIN_arrayinstanceof (functionptr) builtin_fast_arrayinstanceof -bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass); -#define BUILTIN_arraycheckcast (functionptr) builtin_fast_arraycheckcast - -bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o); -/* NOT AN OP */ -bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o); -#define BUILTIN_FAST_canstore (functionptr) builtin_fast_canstore - -void *builtin_throw_exception(java_object_t *exception); -/* NOT AN OP */ -java_object_t *builtin_retrieve_exception(void); -/* NOT AN OP */ - -java_handle_t *builtin_new(classinfo *c); -/* NOT AN OP */ -java_handle_t *builtin_java_new(java_handle_t *c); -#define BUILTIN_new (functionptr) builtin_java_new -java_object_t *builtin_fast_new(classinfo *c); -#define BUILTIN_FAST_new (functionptr) builtin_fast_new - -java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass); -/* NOT AN OP */ -java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclass); -#define BUILTIN_newarray (functionptr) builtin_java_newarray - -java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass); -/* NOT AN OP */ - -java_handle_booleanarray_t *builtin_newarray_boolean(int32_t size); -#define BUILTIN_newarray_boolean (functionptr) builtin_newarray_boolean -java_handle_chararray_t *builtin_newarray_char(int32_t size); -#define BUILTIN_newarray_char (functionptr) builtin_newarray_char -java_handle_floatarray_t *builtin_newarray_float(int32_t size); -#define BUILTIN_newarray_float (functionptr) builtin_newarray_float -java_handle_doublearray_t *builtin_newarray_double(int32_t size); -#define BUILTIN_newarray_double (functionptr) builtin_newarray_double -java_handle_bytearray_t *builtin_newarray_byte(int32_t size); -#define BUILTIN_newarray_byte (functionptr) builtin_newarray_byte -java_handle_shortarray_t *builtin_newarray_short(int32_t size); -#define BUILTIN_newarray_short (functionptr) builtin_newarray_short -java_handle_intarray_t *builtin_newarray_int(int32_t size); -#define BUILTIN_newarray_int (functionptr) builtin_newarray_int -java_handle_longarray_t *builtin_newarray_long(int32_t size); -#define BUILTIN_newarray_long (functionptr) builtin_newarray_long - -java_handle_objectarray_t *builtin_multianewarray(int n, - java_handle_t *arrayclass, - long *dims); -#define BUILTIN_multianewarray (functionptr) builtin_multianewarray - -#if defined(TRACE_ARGS_NUM) -void builtin_verbosecall_enter(s8 a0, s8 a1, -# if TRACE_ARGS_NUM >= 4 - s8 a2, s8 a3, -# endif -# if TRACE_ARGS_NUM >= 6 - s8 a4, s8 a5, -# endif -# if TRACE_ARGS_NUM == 8 - s8 a6, s8 a7, -# endif - methodinfo *m); -/* NOT AN OP */ -#endif /* defined(TRACE_ARGS_NUM) */ - -void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m); -/* NOT AN OP */ - -s4 builtin_idiv(s4 a, s4 b); -#define BUILTIN_idiv (functionptr) builtin_idiv -s4 builtin_irem(s4 a, s4 b); -#define BUILTIN_irem (functionptr) builtin_irem - -s8 builtin_ladd(s8 a, s8 b); -#define BUILTIN_ladd (functionptr) builtin_ladd -s8 builtin_lsub(s8 a, s8 b); -#define BUILTIN_lsub (functionptr) builtin_lsub -s8 builtin_lmul(s8 a, s8 b); -#define BUILTIN_lmul (functionptr) builtin_lmul - -s8 builtin_ldiv(s8 a, s8 b); -#define BUILTIN_ldiv (functionptr) builtin_ldiv -s8 builtin_lrem(s8 a, s8 b); -#define BUILTIN_lrem (functionptr) builtin_lrem - -s8 builtin_lshl(s8 a, s4 b); -#define BUILTIN_lshl (functionptr) builtin_lshl -s8 builtin_lshr(s8 a, s4 b); -#define BUILTIN_lshr (functionptr) builtin_lshr -s8 builtin_lushr(s8 a, s4 b); -#define BUILTIN_lushr (functionptr) builtin_lushr -s8 builtin_land(s8 a, s8 b); -#define BUILTIN_land (functionptr) builtin_land -s8 builtin_lor(s8 a, s8 b); -#define BUILTIN_lor (functionptr) builtin_lor -s8 builtin_lxor(s8 a, s8 b); -#define BUILTIN_lxor (functionptr) builtin_lxor -s8 builtin_lneg(s8 a); -#define BUILTIN_lneg (functionptr) builtin_lneg -s4 builtin_lcmp(s8 a, s8 b); -#define BUILTIN_lcmp (functionptr) builtin_lcmp - -float builtin_fadd(float a, float b); -#define BUILTIN_fadd (functionptr) builtin_fadd -float builtin_fsub(float a, float b); -#define BUILTIN_fsub (functionptr) builtin_fsub -float builtin_fmul(float a, float b); -#define BUILTIN_fmul (functionptr) builtin_fmul -float builtin_fdiv(float a, float b); -#define BUILTIN_fdiv (functionptr) builtin_fdiv -float builtin_fneg(float a); -#define BUILTIN_fneg (functionptr) builtin_fneg -s4 builtin_fcmpl(float a, float b); -#define BUILTIN_fcmpl (functionptr) builtin_fcmpl -s4 builtin_fcmpg(float a, float b); -#define BUILTIN_fcmpg (functionptr) builtin_fcmpg -float builtin_frem(float a, float b); -#define BUILTIN_frem (functionptr) builtin_frem - -double builtin_dadd(double a, double b); -#define BUILTIN_dadd (functionptr) builtin_dadd -double builtin_dsub(double a, double b); -#define BUILTIN_dsub (functionptr) builtin_dsub -double builtin_dmul(double a, double b); -#define BUILTIN_dmul (functionptr) builtin_dmul -double builtin_ddiv(double a, double b); -#define BUILTIN_ddiv (functionptr) builtin_ddiv -double builtin_dneg(double a); -#define BUILTIN_dneg (functionptr) builtin_dneg -s4 builtin_dcmpl(double a, double b); -#define BUILTIN_dcmpl (functionptr) builtin_dcmpl -s4 builtin_dcmpg(double a, double b); -#define BUILTIN_dcmpg (functionptr) builtin_dcmpg -double builtin_drem(double a, double b); -#define BUILTIN_drem (functionptr) builtin_drem - -s8 builtin_i2l(s4 i); -/* NOT AN OP */ -float builtin_i2f(s4 i); -#define BUILTIN_i2f (functionptr) builtin_i2f -double builtin_i2d(s4 i); -#define BUILTIN_i2d (functionptr) builtin_i2d -s4 builtin_l2i(s8 l); -/* NOT AN OP */ -float builtin_l2f(s8 l); -#define BUILTIN_l2f (functionptr) builtin_l2f -double builtin_l2d(s8 l); -#define BUILTIN_l2d (functionptr) builtin_l2d - -s4 builtin_f2i(float a); -#define BUILTIN_f2i (functionptr) builtin_f2i -s4 asm_builtin_f2i(float a); -/* NOT AN OP */ -s8 builtin_f2l(float a); -#define BUILTIN_f2l (functionptr) builtin_f2l -s8 asm_builtin_f2l(float a); -/* NOT AN OP */ - -double builtin_f2d(float a); -#define BUILTIN_f2d (functionptr) builtin_f2d - -s4 builtin_d2i(double a); -#define BUILTIN_d2i (functionptr) builtin_d2i -s4 asm_builtin_d2i(double a); -/* NOT AN OP */ -s8 builtin_d2l(double a); -#define BUILTIN_d2l (functionptr) builtin_d2l -s8 asm_builtin_d2l(double a); -/* NOT AN OP */ - -float builtin_d2f(double a); -#define BUILTIN_d2f (functionptr) builtin_d2f - -java_handle_t *builtin_clone(void *env, java_handle_t *o); -#define BUILTIN_clone (functionptr) builtin_clone - -void builtin_arraycopy(java_handle_t *src, s4 srcStart, - java_handle_t *dest, s4 destStart, s4 len); -#define BUILTIN_arraycopy (functionptr) builtin_arraycopy - -s8 builtin_nanotime(void); -s8 builtin_currenttimemillis(void); -#define BUILTIN_currenttimemillis (functionptr) builtin_currenttimemillis - -#if defined(ENABLE_CYCLES_STATS) -void builtin_print_cycles_stats(FILE *file); -#endif - -#endif /* _BUILTIN_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/builtintable.inc b/src/vm/builtintable.inc deleted file mode 100644 index 735c1de70..000000000 --- a/src/vm/builtintable.inc +++ /dev/null @@ -1,1076 +0,0 @@ -/* src/vm/builtintable.inc - tables of builtin functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include "arch.h" - -#include "threads/lock-common.h" - -#include "vm/builtin.h" - -#include "vm/jit/jit.h" - - -/* internal and not automatically replaced functions **************************/ - -static builtintable_entry builtintable_internal[] = { - -#if defined(__ALPHA__) || defined(DISABLE_GC) - { - ICMD_F2L, - 0, - BUILTIN_f2l, - NULL, - NULL, - "f2l", - "(F)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_D2L, - 0, - BUILTIN_d2l, - NULL, - NULL, - "d2l", - "(D)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_F2I, - 0, - BUILTIN_f2i, - NULL, - NULL, - "f2i", - "(F)I", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_D2I, - 0, - BUILTIN_d2i, - NULL, - NULL, - "d2i", - "(D)I", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !SUPPORT_DIVISION || defined(DISABLE_GC) - { - ICMD_IDIV, - 0, - BUILTIN_idiv, - NULL, - NULL, - "idiv", - "(II)I", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_IREM, - 0, - BUILTIN_irem, - NULL, - NULL, - "irem", - "(II)I", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined(DISABLE_GC) - { - ICMD_LDIV, - 0, - BUILTIN_ldiv, - NULL, - NULL, - "ldiv", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LREM, - 0, - BUILTIN_lrem, - NULL, - NULL, - "lrem", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, -#endif - - { - ICMD_FREM, - 0, - BUILTIN_frem, - NULL, - NULL, - "frem", - "(FF)F", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_DREM, - 0, - BUILTIN_drem, - NULL, - NULL, - "drem", - "(DD)D", - NULL, - NULL, - NULL, - NULL - }, - - - /* internal functions *****************************************************/ - - { - ICMD_NEW, - BUILTINTABLE_FLAG_STUB, - BUILTIN_new, - NULL, - NULL, - "new", - "(Ljava/lang/Class;)Ljava/lang/Object;", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEW, - 0, - BUILTIN_FAST_new, - NULL, - NULL, - "fast-new", - "(Ljava/lang/Class;)Ljava/lang/Object;", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_ANEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray, - NULL, - NULL, - "newarray", - "(ILjava/lang/Class;)[Ljava/lang/Object;", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_boolean, - NULL, - NULL, - "newarray_boolean", - "(I)[Z", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_byte, - NULL, - NULL, - "newarray_byte", - "(I)[B", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_char, - NULL, - NULL, - "newarray_char", - "(I)[C", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_short, - NULL, - NULL, - "newarray_short", - "(I)[S", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_int, - NULL, - NULL, - "newarray_int", - "(I)[I", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_long, - NULL, - NULL, - "newarray_long", - "(I)[J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_float, - NULL, - NULL, - "newarray_float", - "(I)[F", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_NEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_newarray_double, - NULL, - NULL, - "newarray_double", - "(I)[D", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_MULTIANEWARRAY, - BUILTINTABLE_FLAG_STUB, - BUILTIN_multianewarray, - NULL, - NULL, - "multianewarray", - /* XXX it should be: "(ILjava/lang/Class;[I)[Ljava/lang/Object;", */ - "(ILjava/lang/Class;I)[Ljava/lang/Object;", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_CHECKCAST, - 0, - BUILTIN_arraycheckcast, - NULL, - NULL, - "arraycheckcast", - "([Ljava/lang/Object;[Ljava/lang/Object;)[Ljava/lang/Object;", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_INSTANCEOF, - 0, - BUILTIN_arrayinstanceof, - NULL, - NULL, - "arrayinstanceof", - "([Ljava/lang/Object;[Ljava/lang/Object;)I", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_AASTORE, - 0, - BUILTIN_FAST_canstore, - NULL, - NULL, - "fast-canstore", - "([Ljava/lang/Object;Ljava/lang/Object;)I", - NULL, - NULL, - NULL, - NULL - }, - -#if defined(ENABLE_THREADS) - { - ICMD_MONITORENTER, - BUILTINTABLE_FLAG_STUB, - LOCK_monitor_enter, - NULL, - NULL, - "monitorenter", - "(Ljava/lang/Object;)V", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_MONITOREXIT, - BUILTINTABLE_FLAG_STUB, - LOCK_monitor_exit, - NULL, - NULL, - "monitorexit", - "(Ljava/lang/Object;)V", - NULL, - NULL, - NULL, - NULL - }, -#endif - - - /* stop entry */ - - { - 255, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL - }, -}; - - -/* automatically replaced functions *******************************************/ - -static builtintable_entry builtintable_automatic[] = { - -#if !(SUPPORT_LONG && SUPPORT_LONG_CMP) - { - ICMD_LCMP, - 0, - BUILTIN_lcmp, - NULL, - NULL, - "lcmp", - "(JJ)I", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) - { - ICMD_LAND, - 0, - BUILTIN_land, - NULL, - NULL, - "land", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LOR, - 0, - BUILTIN_lor, - NULL, - NULL, - "lor", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LXOR, - 0, - BUILTIN_lxor, - NULL, - NULL, - "lxor", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */ - -#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) - { - ICMD_LSHL, - 0, - BUILTIN_lshl, - NULL, - NULL, - "lshl", - "(JI)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LSHR, - 0, - BUILTIN_lshr, - NULL, - NULL, - "lshr", - "(JI)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LUSHR, - 0, - BUILTIN_lushr, - NULL, - NULL, - "lushr", - "(JI)J", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */ - -#if !(SUPPORT_LONG && SUPPORT_LONG_ADD) - { - ICMD_LADD, - 0, - BUILTIN_ladd, - NULL, - NULL, - "ladd", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LSUB, - 0, - BUILTIN_lsub, - NULL, - NULL, - "lsub", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_LNEG, - 0, - BUILTIN_lneg, - NULL, - NULL, - "lneg", - "(J)J", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */ - -#if !(SUPPORT_LONG && SUPPORT_LONG_MUL) - { - ICMD_LMUL, - 0, - BUILTIN_lmul, - NULL, - NULL, - "lmul", - "(JJ)J", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_FLOAT && SUPPORT_I2F) - { - ICMD_I2F, - 0, - BUILTIN_i2f, - NULL, - NULL, - "i2f", - "(I)F", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_DOUBLE && SUPPORT_I2D) - { - ICMD_I2D, - 0, - BUILTIN_i2d, - NULL, - NULL, - "i2d", - "(I)D", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) - { - ICMD_L2F, - 0, - BUILTIN_l2f, - NULL, - NULL, - "l2f", - "(J)F", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) - { - ICMD_L2D, - 0, - BUILTIN_l2d, - NULL, - NULL, - "l2d", - "(J)D", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_FLOAT && SUPPORT_F2I) - { - ICMD_F2I, - 0, - BUILTIN_f2i, - NULL, - NULL, - "f2i", - "(F)I", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) - { - ICMD_F2L, - 0, - BUILTIN_f2l, - NULL, - NULL, - "f2l", - "(F)J", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_DOUBLE && SUPPORT_D2I) - { - ICMD_D2I, - 0, - BUILTIN_d2i, - NULL, - NULL, - "d2i", - "(D)I", - NULL, - NULL, - NULL, - NULL - }, -#endif - -#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) - { - ICMD_D2L, - 0, - BUILTIN_d2l, - NULL, - NULL, - "d2l", - "(D)J", - NULL, - NULL, - NULL, - NULL - }, -#endif - - - /* float functions ********************************************************/ - -#if !SUPPORT_FLOAT - { - ICMD_FADD, - 0, - BUILTIN_fadd, - NULL, - NULL, - "fadd", - "(FF)F", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_FSUB, - 0, - BUILTIN_fsub, - NULL, - NULL, - "fsub", - "(FF)F", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_FMUL, - 0, - BUILTIN_fmul, - NULL, - NULL, - "fmul", - "(FF)F", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_FDIV, - 0, - BUILTIN_fdiv, - NULL, - NULL, - "fdiv", - "(FF)F", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_FNEG, - 0, - BUILTIN_fneg, - NULL, - NULL, - "fneg", - "(F)F", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !SUPPORT_FLOAT */ - -#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP - { - ICMD_FCMPL, - 0, - BUILTIN_fcmpl, - NULL, - NULL, - "fcmpl", - "(FF)I", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_FCMPG, - 0, - BUILTIN_fcmpg, - NULL, - NULL, - "fcmpg", - "(FF)I", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP */ - - - /* double functions *******************************************************/ - -#if !SUPPORT_DOUBLE - { - ICMD_DADD, - 0, - BUILTIN_dadd, - NULL, - NULL, - "dadd", - "(DD)D", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_DSUB, - 0, - BUILTIN_dsub, - NULL, - NULL, - "dsub", - "(DD)D", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_DMUL, - 0, - BUILTIN_dmul, - NULL, - NULL, - "dmul", - "(DD)D", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_DDIV, - 0, - BUILTIN_ddiv, - NULL, - NULL, - "ddiv", - "(DD)D", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_DNEG, - 0, - BUILTIN_dneg, - NULL, - NULL, - "dneg", - "(D)D", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !SUPPORT_DOUBLE */ - -#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP - { - ICMD_DCMPL, - 0, - BUILTIN_dcmpl, - NULL, - NULL, - "dcmpl", - "(DD)I", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_DCMPG, - 0, - BUILTIN_dcmpg, - NULL, - NULL, - "dcmpg", - "(DD)I", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP */ - - - /* float/double functions *************************************************/ - -#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE) - { - ICMD_F2D, - 0, - BUILTIN_f2d, - NULL, - NULL, - "f2d", - "(F)D", - NULL, - NULL, - NULL, - NULL - }, - { - ICMD_D2F, - 0, - BUILTIN_d2f, - NULL, - NULL, - "d2f", - "(D)F", - NULL, - NULL, - NULL, - NULL - }, -#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */ - - - /* prevent a compiler warning if everything is supported (e.g. i386) */ - - { - 255, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL - }, -}; - - -/* automatically replaced functions *******************************************/ - -static builtintable_entry builtintable_function[] = { -#if defined(ENABLE_JIT) - - /* java.lang.VMSystem.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V STATIC NATIVE */ - - { - ICMD_BUILTIN, - BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION, - BUILTIN_arraycopy, - NULL, - "java/lang/VMSystem", - "arraycopy", - "(Ljava/lang/Object;ILjava/lang/Object;II)V", - NULL, - NULL, - NULL, - NULL - }, - - /* java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V PUBLIC STATIC */ - -#if 0 - /* We disable this one until we have a fix for the stacktrace - issue. */ - - { - ICMD_BUILTIN, - BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION, - BUILTIN_arraycopy, - NULL, - "java/lang/System", - "arraycopy", - "(Ljava/lang/Object;ILjava/lang/Object;II)V", - NULL, - NULL, - NULL, - NULL - }, -#endif - - /* java.lang.VMSystem.currentTimeMillis()J PUBLIC STATIC */ - - { - ICMD_BUILTIN, - 0, - BUILTIN_currenttimemillis, - NULL, - "java/lang/VMSystem", - "currentTimeMillis", - "()J", - NULL, - NULL, - NULL, - NULL - }, - - /* java.lang.System.currentTimeMillis()J PUBLIC STATIC */ - - { - ICMD_BUILTIN, - 0, - BUILTIN_currenttimemillis, - NULL, - "java/lang/System", - "currentTimeMillis", - "()J", - NULL, - NULL, - NULL, - NULL - }, - -#endif /* defined(ENABLE_JIT) */ - - /* stop entry */ - - { - 255, - 0, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL - }, -}; - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/class.c b/src/vm/class.c new file mode 100644 index 000000000..a5b5812f6 --- /dev/null +++ b/src/vm/class.c @@ -0,0 +1,2463 @@ +/* src/vm/class.c - class related functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include + +#include "vm/types.h" + +#include "arch.h" + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "threads/lock-common.h" +#include "threads/mutex.hpp" + +#include "toolbox/logging.h" + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/resolve.h" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/suck.hpp" +#include "vm/utf8.h" + +#include "vm/jit/asmpart.h" + + +/* class_set_packagename ******************************************************* + + Derive the package name from the class name and store it in the + struct. + + An internal package name consists of the package name plus the + trailing '/', e.g. "java/lang/". + + For classes in the unnamed package, the package name is set to + NULL. + +*******************************************************************************/ + +void class_set_packagename(classinfo *c) +{ + char *p; + char *start; + + p = UTF_END(c->name) - 1; + start = c->name->text; + + if (c->name->text[0] == '[') { + /* Set packagename of arrays to the element's package. */ + + for (; *start == '['; start++); + + /* Skip the 'L' in arrays of references. */ + + if (*start == 'L') + start++; + } + + /* Search for last '/'. */ + + for (; (p > start) && (*p != '/'); --p); + + /* If we found a '/' we set the package name plus the trailing + '/'. Otherwise we set the packagename to NULL. */ + + if (p > start) + c->packagename = utf_new(start, p - start + 1); + else + c->packagename = NULL; +} + + +/* class_create_classinfo ****************************************************** + + Create a new classinfo struct. The class name is set to the given utf *, + most other fields are initialized to zero. + + Note: classname may be NULL. In this case a not-yet-named classinfo is + created. The name must be filled in later and class_set_packagename + must be called after that. + +*******************************************************************************/ + +classinfo *class_create_classinfo(utf *classname) +{ + classinfo *c; + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_classinfo += sizeof(classinfo); +#endif + + /* we use a safe name for temporarily unnamed classes */ + + if (classname == NULL) + classname = utf_not_named_yet; + +#if !defined(NDEBUG) + if (initverbose) + log_message_utf("Creating class: ", classname); +#endif + +#if !defined(ENABLE_GC_BOEHM) + c = (classinfo *) heap_alloc_uncollectable(sizeof(classinfo)); + /*c = NEW(classinfo); + MZERO(c, classinfo, 1);*/ +#else + c = GCNEW_UNCOLLECTABLE(classinfo, 1); + /* GCNEW_UNCOLLECTABLE clears the allocated memory */ +#endif + + c->name = classname; + + /* Set the header.vftbl of all loaded classes to the one of + java.lang.Class, so Java code can use a class as object. */ + + if (class_java_lang_Class != NULL) + if (class_java_lang_Class->vftbl != NULL) + c->object.header.vftbl = class_java_lang_Class->vftbl; + +#if defined(ENABLE_JAVASE) + /* check if the class is a reference class and flag it */ + + if (classname == utf_java_lang_ref_SoftReference) { + c->flags |= ACC_CLASS_REFERENCE_SOFT; + } + else if (classname == utf_java_lang_ref_WeakReference) { + c->flags |= ACC_CLASS_REFERENCE_WEAK; + } + else if (classname == utf_java_lang_ref_PhantomReference) { + c->flags |= ACC_CLASS_REFERENCE_PHANTOM; + } +#endif + + if (classname != utf_not_named_yet) + class_set_packagename(c); + + LOCK_INIT_OBJECT_LOCK(&c->object.header); + + return c; +} + + +/* class_postset_header_vftbl ************************************************** + + Set the header.vftbl of all classes created before java.lang.Class + was linked. This is necessary that Java code can use a class as + object. + +*******************************************************************************/ + +void class_postset_header_vftbl(void) +{ + classinfo *c; + u4 slot; + classcache_name_entry *nmen; + classcache_class_entry *clsen; + + assert(class_java_lang_Class); + + for (slot = 0; slot < hashtable_classcache.size; slot++) { + nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot]; + + for (; nmen; nmen = nmen->hashlink) { + /* iterate over all class entries */ + + for (clsen = nmen->classes; clsen; clsen = clsen->next) { + c = clsen->classobj; + + /* now set the the vftbl */ + + if (c->object.header.vftbl == NULL) + c->object.header.vftbl = class_java_lang_Class->vftbl; + } + } + } +} + +/* class_define **************************************************************** + + Calls the loader and defines a class in the VM. + +*******************************************************************************/ + +classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd) +{ + classinfo *c; + classinfo *r; + classbuffer *cb; + + if (name != NULL) { + /* check if this class has already been defined */ + + c = classcache_lookup_defined_or_initiated(cl, name); + + if (c != NULL) { + exceptions_throw_linkageerror("duplicate class definition: ", c); + return NULL; + } + } + + /* create a new classinfo struct */ + + c = class_create_classinfo(name); + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getloadingtime) + loadingtime_start(); +#endif + + /* build a classbuffer with the given data */ + + cb = NEW(classbuffer); + + cb->clazz = c; + cb->size = length; + cb->data = data; + cb->pos = cb->data; + + /* preset the defining classloader */ + + c->classloader = cl; + + /* load the class from this buffer */ + + r = load_class_from_classbuffer(cb); + + /* free memory */ + + FREE(cb, classbuffer); + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getloadingtime) + loadingtime_stop(); +#endif + + if (r == NULL) { + /* If return value is NULL, we had a problem and the class is + not loaded. Now free the allocated memory, otherwise we + could run into a DOS. */ + + class_free(c); + + return NULL; + } + +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + /* Store the protection domain. */ + + c->protectiondomain = pd; +# endif +#endif + + /* Store the newly defined class in the class cache. This call + also checks whether a class of the same name has already been + defined by the same defining loader, and if so, replaces the + newly created class by the one defined earlier. */ + + /* Important: The classinfo given to classcache_store must be + fully prepared because another thread may return + this pointer after the lookup at to top of this + function directly after the class cache lock has + been released. */ + + c = classcache_store(cl, c, true); + + return c; +} + + +/* class_load_attribute_sourcefile ********************************************* + + SourceFile_attribute { + u2 attribute_name_index; + u4 attribute_length; + u2 sourcefile_index; + } + +*******************************************************************************/ + +static bool class_load_attribute_sourcefile(classbuffer *cb) +{ + classinfo *c; + u4 attribute_length; + u2 sourcefile_index; + utf *sourcefile; + + /* get classinfo */ + + c = cb->clazz; + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* check attribute length */ + + attribute_length = suck_u4(cb); + + if (attribute_length != 2) { + exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); + return false; + } + + /* there can be no more than one SourceFile attribute */ + + if (c->sourcefile != NULL) { + exceptions_throw_classformaterror(c, "Multiple SourceFile attributes"); + return false; + } + + /* get sourcefile */ + + sourcefile_index = suck_u2(cb); + sourcefile = class_getconstant(c, sourcefile_index, CONSTANT_Utf8); + + if (sourcefile == NULL) + return false; + + /* store sourcefile */ + + c->sourcefile = sourcefile; + + return true; +} + + +/* class_load_attribute_enclosingmethod **************************************** + + EnclosingMethod_attribute { + u2 attribute_name_index; + u4 attribute_length; + u2 class_index; + u2 method_index; + } + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +static bool class_load_attribute_enclosingmethod(classbuffer *cb) +{ + classinfo *c; + u4 attribute_length; + u2 class_index; + u2 method_index; + classref_or_classinfo cr; + constant_nameandtype *cn; + + /* get classinfo */ + + c = cb->clazz; + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 4 + 2 + 2)) + return false; + + /* check attribute length */ + + attribute_length = suck_u4(cb); + + if (attribute_length != 4) { + exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); + return false; + } + + /* there can be no more than one EnclosingMethod attribute */ + + if (c->enclosingmethod != NULL) { + exceptions_throw_classformaterror(c, "Multiple EnclosingMethod attributes"); + return false; + } + + /* get class index */ + + class_index = suck_u2(cb); + cr.ref = innerclass_getconstant(c, class_index, CONSTANT_Class); + + /* get method index */ + + method_index = suck_u2(cb); + cn = innerclass_getconstant(c, method_index, CONSTANT_NameAndType); + + /* store info in classinfo */ + + c->enclosingclass.any = cr.any; + c->enclosingmethod = cn; + + return true; +} +#endif /* defined(ENABLE_JAVASE) */ + + +/* class_load_attributes ******************************************************* + + Read attributes from ClassFile. + + attribute_info { + u2 attribute_name_index; + u4 attribute_length; + u1 info[attribute_length]; + } + + InnerClasses_attribute { + u2 attribute_name_index; + u4 attribute_length; + } + +*******************************************************************************/ + +bool class_load_attributes(classbuffer *cb) +{ + classinfo *c; + uint16_t attributes_count; + uint16_t attribute_name_index; + utf *attribute_name; + innerclassinfo *info; + classref_or_classinfo inner; + classref_or_classinfo outer; + utf *name; + uint16_t flags; + int i, j; + + c = cb->clazz; + + /* get attributes count */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + attributes_count = suck_u2(cb); + + for (i = 0; i < attributes_count; i++) { + /* get attribute name */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + attribute_name_index = suck_u2(cb); + attribute_name = + class_getconstant(c, attribute_name_index, CONSTANT_Utf8); + + if (attribute_name == NULL) + return false; + + if (attribute_name == utf_InnerClasses) { + /* InnerClasses */ + + if (c->innerclass != NULL) { + exceptions_throw_classformaterror(c, "Multiple InnerClasses attributes"); + return false; + } + + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* skip attribute length */ + suck_u4(cb); + + /* number of records */ + c->innerclasscount = suck_u2(cb); + + if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * c->innerclasscount)) + return false; + + /* allocate memory for innerclass structure */ + c->innerclass = MNEW(innerclassinfo, c->innerclasscount); + + for (j = 0; j < c->innerclasscount; j++) { + /* The innerclass structure contains a class with an encoded + name, its defining scope, its simple name and a bitmask of + the access flags. */ + + info = c->innerclass + j; + + inner.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class); + outer.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class); + name = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8); + flags = suck_u2(cb); + + /* If the current inner-class is the currently loaded + class check for some special flags. */ + + if (inner.ref->name == c->name) { + /* If an inner-class is not a member, its + outer-class is NULL. */ + + if (outer.ref != NULL) { + c->flags |= ACC_CLASS_MEMBER; + + /* A member class doesn't have an + EnclosingMethod attribute, so set the + enclosing-class to be the same as the + declaring-class. */ + + c->declaringclass = outer; + c->enclosingclass = outer; + } + + /* If an inner-class is anonymous, its name is + NULL. */ + + if (name == NULL) + c->flags |= ACC_CLASS_ANONYMOUS; + } + + info->inner_class = inner; + info->outer_class = outer; + info->name = name; + info->flags = flags; + } + } + else if (attribute_name == utf_SourceFile) { + /* SourceFile */ + + if (!class_load_attribute_sourcefile(cb)) + return false; + } +#if defined(ENABLE_JAVASE) + else if (attribute_name == utf_EnclosingMethod) { + /* EnclosingMethod */ + + if (!class_load_attribute_enclosingmethod(cb)) + return false; + } + else if (attribute_name == utf_Signature) { + /* Signature */ + + if (!loader_load_attribute_signature(cb, &(c->signature))) + return false; + } +#endif + +#if defined(ENABLE_ANNOTATIONS) + else if (attribute_name == utf_RuntimeVisibleAnnotations) { + /* RuntimeVisibleAnnotations */ + if (!annotation_load_class_attribute_runtimevisibleannotations(cb)) + return false; + } + else if (attribute_name == utf_RuntimeInvisibleAnnotations) { + /* RuntimeInvisibleAnnotations */ + if (!annotation_load_class_attribute_runtimeinvisibleannotations(cb)) + return false; + } +#endif + + else { + /* unknown attribute */ + + if (!loader_skip_attribute_body(cb)) + return false; + } + } + + return true; +} + + +/* class_freepool ************************************************************** + + Frees all resources used by this classes Constant Pool. + +*******************************************************************************/ + +static void class_freecpool(classinfo *c) +{ + u4 idx; + u4 tag; + void* info; + + if (c->cptags && c->cpinfos) { + for (idx = 0; idx < c->cpcount; idx++) { + tag = c->cptags[idx]; + info = c->cpinfos[idx]; + + if (info != NULL) { + switch (tag) { + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + FREE(info, constant_FMIref); + break; + case CONSTANT_Integer: + FREE(info, constant_integer); + break; + case CONSTANT_Float: + FREE(info, constant_float); + break; + case CONSTANT_Long: + FREE(info, constant_long); + break; + case CONSTANT_Double: + FREE(info, constant_double); + break; + case CONSTANT_NameAndType: + FREE(info, constant_nameandtype); + break; + } + } + } + } + + if (c->cptags) + MFREE(c->cptags, u1, c->cpcount); + + if (c->cpinfos) + MFREE(c->cpinfos, void*, c->cpcount); +} + + +/* class_getconstant *********************************************************** + + Retrieves the value at position 'pos' of the constantpool of a + class. If the type of the value is other than 'ctype', an error is + thrown. + +*******************************************************************************/ + +void* class_getconstant(classinfo *c, u4 pos, u4 ctype) +{ + /* check index and type of constantpool entry */ + /* (pos == 0 is caught by type comparison) */ + + if ((pos >= c->cpcount) || (c->cptags[pos] != ctype)) { + exceptions_throw_classformaterror(c, "Illegal constant pool index"); + return NULL; + } + + return c->cpinfos[pos]; +} + + +/* innerclass_getconstant ****************************************************** + + Like class_getconstant, but if cptags is ZERO, null is returned. + +*******************************************************************************/ + +void* innerclass_getconstant(classinfo *c, u4 pos, u4 ctype) +{ + /* invalid position in constantpool */ + + if (pos >= c->cpcount) { + exceptions_throw_classformaterror(c, "Illegal constant pool index"); + return NULL; + } + + /* constantpool entry of type 0 */ + + if (c->cptags[pos] == 0) + return NULL; + + /* check type of constantpool entry */ + + if (c->cptags[pos] != ctype) { + exceptions_throw_classformaterror(c, "Illegal constant pool index"); + return NULL; + } + + return c->cpinfos[pos]; +} + + +/* class_free ****************************************************************** + + Frees all resources used by the class. + +*******************************************************************************/ + +void class_free(classinfo *c) +{ + s4 i; + vftbl_t *v; + + class_freecpool(c); + + if (c->interfaces != NULL) + MFREE(c->interfaces, classinfo*, c->interfacescount); + + if (c->fields) { + for (i = 0; i < c->fieldscount; i++) + field_free(&(c->fields[i])); + MFREE(c->fields, fieldinfo, c->fieldscount); + } + + if (c->methods) { + for (i = 0; i < c->methodscount; i++) + method_free(&(c->methods[i])); + MFREE(c->methods, methodinfo, c->methodscount); + } + + if ((v = c->vftbl) != NULL) { + if (v->arraydesc) + mem_free(v->arraydesc,sizeof(arraydescriptor)); + + for (i = 0; i < v->interfacetablelength; i++) { + MFREE(v->interfacetable[-i], methodptr, v->interfacevftbllength[i]); + } + MFREE(v->interfacevftbllength, s4, v->interfacetablelength); + + i = sizeof(vftbl_t) + sizeof(methodptr) * (v->vftbllength - 1) + + sizeof(methodptr*) * (v->interfacetablelength - + (v->interfacetablelength > 0)); + v = (vftbl_t*) (((methodptr*) v) - + (v->interfacetablelength - 1) * (v->interfacetablelength > 1)); + mem_free(v, i); + } + + if (c->innerclass) + MFREE(c->innerclass, innerclassinfo, c->innerclasscount); + + /* if (c->classvftbl) + mem_free(c->header.vftbl, sizeof(vftbl) + sizeof(methodptr)*(c->vftbl->vftbllength-1)); */ + +/* GCFREE(c); */ +} + + +/* get_array_class ************************************************************* + + Returns the array class with the given name for the given + classloader, or NULL if an exception occurred. + + Note: This function does eager loading. + +*******************************************************************************/ + +static classinfo *get_array_class(utf *name,classloader_t *initloader, + classloader_t *defloader,bool link) +{ + classinfo *c; + + /* lookup this class in the classcache */ + c = classcache_lookup(initloader,name); + if (!c) + c = classcache_lookup_defined(defloader,name); + + if (!c) { + /* we have to create it */ + c = class_create_classinfo(name); + c = load_newly_created_array(c,initloader); + if (c == NULL) + return NULL; + } + + assert(c); + assert(c->state & CLASS_LOADED); + assert(c->classloader == defloader); + + if (link && !(c->state & CLASS_LINKED)) + if (!link_class(c)) + return NULL; + + assert(!link || (c->state & CLASS_LINKED)); + + return c; +} + + +/* class_array_of ************************************************************** + + Returns an array class with the given component class. The array + class is dynamically created if neccessary. + +*******************************************************************************/ + +classinfo *class_array_of(classinfo *component, bool link) +{ + classloader_t *cl; + s4 namelen; + char *namebuf; + utf *u; + classinfo *c; + + cl = component->classloader; + + /* Assemble the array class name */ + namelen = component->name->blength; + + if (component->name->text[0] == '[') { + /* the component is itself an array */ + namebuf = MNEW(char, namelen + 1); + namebuf[0] = '['; + MCOPY(namebuf + 1, component->name->text, char, namelen); + namelen++; + } + else { + /* the component is a non-array class */ + namebuf = MNEW(char, namelen + 3); + namebuf[0] = '['; + namebuf[1] = 'L'; + MCOPY(namebuf + 2, component->name->text, char, namelen); + namebuf[2 + namelen] = ';'; + namelen += 3; + } + + u = utf_new(namebuf, namelen); + + MFREE(namebuf, char, namelen); + + c = get_array_class(u, cl, cl, link); + + return c; +} + + +/* class_multiarray_of ********************************************************* + + Returns an array class with the given dimension and element class. + The array class is dynamically created if neccessary. + +*******************************************************************************/ + +classinfo *class_multiarray_of(s4 dim, classinfo *element, bool link) +{ + s4 namelen; + char *namebuf; + classinfo *c; + + if (dim < 1) { + log_text("Invalid array dimension requested"); + assert(0); + } + + /* Assemble the array class name */ + namelen = element->name->blength; + + if (element->name->text[0] == '[') { + /* the element is itself an array */ + namebuf = MNEW(char, namelen + dim); + memcpy(namebuf + dim, element->name->text, namelen); + namelen += dim; + } + else { + /* the element is a non-array class */ + namebuf = MNEW(char, namelen + 2 + dim); + namebuf[dim] = 'L'; + memcpy(namebuf + dim + 1, element->name->text, namelen); + namelen += (2 + dim); + namebuf[namelen - 1] = ';'; + } + memset(namebuf, '[', dim); + + utf* u = utf_new(namebuf, namelen); + + MFREE(namebuf, char, namelen); + + c = get_array_class(u, + element->classloader, + element->classloader, + link); + + return c; +} + + +/* class_lookup_classref ******************************************************* + + Looks up the constant_classref for a given classname in the classref + tables of a class. + + IN: + cls..............the class containing the reference + name.............the name of the class refered to + + RETURN VALUE: + a pointer to a constant_classref, or + NULL if the reference was not found + +*******************************************************************************/ + +constant_classref *class_lookup_classref(classinfo *cls, utf *name) +{ + constant_classref *ref; + extra_classref *xref; + int count; + + assert(cls); + assert(name); + assert(!cls->classrefcount || cls->classrefs); + + /* first search the main classref table */ + count = cls->classrefcount; + ref = cls->classrefs; + for (; count; --count, ++ref) + if (ref->name == name) + return ref; + + /* next try the list of extra classrefs */ + for (xref = cls->extclassrefs; xref; xref = xref->next) { + if (xref->classref.name == name) + return &(xref->classref); + } + + /* not found */ + return NULL; +} + + +/* class_get_classref ********************************************************** + + Returns the constant_classref for a given classname. + + IN: + cls..............the class containing the reference + name.............the name of the class refered to + + RETURN VALUE: + a pointer to a constant_classref (never NULL) + + NOTE: + The given name is not checked for validity! + +*******************************************************************************/ + +constant_classref *class_get_classref(classinfo *cls, utf *name) +{ + constant_classref *ref; + extra_classref *xref; + + assert(cls); + assert(name); + + ref = class_lookup_classref(cls,name); + if (ref) + return ref; + + xref = NEW(extra_classref); + CLASSREF_INIT(xref->classref,cls,name); + + xref->next = cls->extclassrefs; + cls->extclassrefs = xref; + + return &(xref->classref); +} + + +/* class_get_self_classref ***************************************************** + + Returns the constant_classref to the class itself. + + IN: + cls..............the class containing the reference + + RETURN VALUE: + a pointer to a constant_classref (never NULL) + +*******************************************************************************/ + +constant_classref *class_get_self_classref(classinfo *cls) +{ + /* XXX this should be done in a faster way. Maybe always make */ + /* the classref of index 0 a self reference. */ + return class_get_classref(cls,cls->name); +} + +/* class_get_classref_multiarray_of ******************************************** + + Returns an array type reference with the given dimension and element class + reference. + + IN: + dim..............the requested dimension + dim must be in [1;255]. This is NOT checked! + ref..............the component class reference + + RETURN VALUE: + a pointer to the class reference for the array type + + NOTE: + The referer of `ref` is used as the referer for the new classref. + +*******************************************************************************/ + +constant_classref *class_get_classref_multiarray_of(s4 dim, constant_classref *ref) +{ + s4 namelen; + char *namebuf; + constant_classref *cr; + + assert(ref); + assert(dim >= 1 && dim <= 255); + + /* Assemble the array class name */ + namelen = ref->name->blength; + + if (ref->name->text[0] == '[') { + /* the element is itself an array */ + namebuf = MNEW(char, namelen + dim); + memcpy(namebuf + dim, ref->name->text, namelen); + namelen += dim; + } + else { + /* the element is a non-array class */ + namebuf = MNEW(char, namelen + 2 + dim); + namebuf[dim] = 'L'; + memcpy(namebuf + dim + 1, ref->name->text, namelen); + namelen += (2 + dim); + namebuf[namelen - 1] = ';'; + } + memset(namebuf, '[', dim); + + utf* u = utf_new(namebuf, namelen); + + MFREE(namebuf, char, namelen); + + cr = class_get_classref(ref->referer, u); + + return cr; +} + + +/* class_get_classref_component_of ********************************************* + + Returns the component classref of a given array type reference + + IN: + ref..............the array type reference + + RETURN VALUE: + a reference to the component class, or + NULL if `ref` is not an object array type reference + + NOTE: + The referer of `ref` is used as the referer for the new classref. + +*******************************************************************************/ + +constant_classref *class_get_classref_component_of(constant_classref *ref) +{ + s4 namelen; + char *name; + + assert(ref); + + name = ref->name->text; + if (*name++ != '[') + return NULL; + + namelen = ref->name->blength - 1; + if (*name == 'L') { + name++; + namelen -= 2; + } + else if (*name != '[') { + return NULL; + } + + return class_get_classref(ref->referer, utf_new(name, namelen)); +} + + +/* class_findmethod ************************************************************ + + Searches a 'classinfo' structure for a method having the given name + and descriptor. If descriptor is NULL, it is ignored. + +*******************************************************************************/ + +methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc) +{ + methodinfo *m; + s4 i; + + for (i = 0; i < c->methodscount; i++) { + m = &(c->methods[i]); + + if ((m->name == name) && ((desc == NULL) || (m->descriptor == desc))) + return m; + } + + return NULL; +} + + +/* class_resolvemethod ********************************************************* + + Searches a class and it's super classes for a method. + + Superinterfaces are *not* searched. + +*******************************************************************************/ + +methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *desc) +{ + methodinfo *m; + + while (c) { + m = class_findmethod(c, name, desc); + + if (m) + return m; + + /* JVM Specification bug: + + It is important NOT to resolve special and + methods to super classes or interfaces; yet, this is not + explicited in the specification. Section 5.4.3.3 should be + updated appropriately. */ + + if (name == utf_init || name == utf_clinit) + return NULL; + + c = c->super; + } + + return NULL; +} + + +/* class_resolveinterfacemethod_intern ***************************************** + + Internally used helper function. Do not use this directly. + +*******************************************************************************/ + +static methodinfo *class_resolveinterfacemethod_intern(classinfo *c, + utf *name, utf *desc) +{ + methodinfo *m; + s4 i; + + /* try to find the method in the class */ + + m = class_findmethod(c, name, desc); + + if (m != NULL) + return m; + + /* No method found? Try the super interfaces. */ + + for (i = 0; i < c->interfacescount; i++) { + m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc); + + if (m != NULL) + return m; + } + + /* no method found */ + + return NULL; +} + + +/* class_resolveclassmethod **************************************************** + + Resolves a reference from REFERER to a method with NAME and DESC in + class C. + + If the method cannot be resolved the return value is NULL. If + EXCEPT is true *exceptionptr is set, too. + +*******************************************************************************/ + +methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *desc, + classinfo *referer, bool throwexception) +{ + classinfo *cls; + methodinfo *m; + s4 i; + +/* if (c->flags & ACC_INTERFACE) { */ +/* if (throwexception) */ +/* *exceptionptr = */ +/* new_exception(string_java_lang_IncompatibleClassChangeError); */ +/* return NULL; */ +/* } */ + + /* try class c and its superclasses */ + + cls = c; + + m = class_resolvemethod(cls, name, desc); + + if (m != NULL) + goto found; + + /* Try the super interfaces. */ + + for (i = 0; i < c->interfacescount; i++) { + m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc); + + if (m != NULL) + goto found; + } + + if (throwexception) + exceptions_throw_nosuchmethoderror(c, name, desc); + + return NULL; + + found: + if ((m->flags & ACC_ABSTRACT) && !(c->flags & ACC_ABSTRACT)) { + if (throwexception) + exceptions_throw_abstractmethoderror(); + + return NULL; + } + + /* XXX check access rights */ + + return m; +} + + +/* class_resolveinterfacemethod ************************************************ + + Resolves a reference from REFERER to a method with NAME and DESC in + interface C. + + If the method cannot be resolved the return value is NULL. If + EXCEPT is true *exceptionptr is set, too. + +*******************************************************************************/ + +methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *desc, + classinfo *referer, bool throwexception) +{ + methodinfo *mi; + + if (!(c->flags & ACC_INTERFACE)) { + if (throwexception) + exceptions_throw_incompatibleclasschangeerror(c, "Not an interface"); + + return NULL; + } + + mi = class_resolveinterfacemethod_intern(c, name, desc); + + if (mi != NULL) + return mi; + + /* try class java.lang.Object */ + + mi = class_findmethod(class_java_lang_Object, name, desc); + + if (mi != NULL) + return mi; + + if (throwexception) + exceptions_throw_nosuchmethoderror(c, name, desc); + + return NULL; +} + + +/* class_findfield ************************************************************* + + Searches for field with specified name and type in a classinfo + structure. If no such field is found NULL is returned. + +*******************************************************************************/ + +fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc) +{ + s4 i; + + for (i = 0; i < c->fieldscount; i++) + if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) + return &(c->fields[i]); + + if (c->super != NULL) + return class_findfield(c->super, name, desc); + + return NULL; +} + + +/* class_findfield_approx ****************************************************** + + Searches in 'classinfo'-structure for a field with the specified + name. + +*******************************************************************************/ + +fieldinfo *class_findfield_by_name(classinfo* c, utf* name) +{ + for (int32_t i = 0; i < c->fieldscount; i++) { + fieldinfo* f = &(c->fields[i]); + + if (f->name == name) + return f; + } + + // Field not found. + exceptions_throw_nosuchfielderror(c, name); + return NULL; +} + + +/****************** Function: class_resolvefield_int *************************** + + This is an internally used helper function. Do not use this directly. + + Tries to resolve a field having the given name and type. + If the field cannot be resolved, NULL is returned. + +*******************************************************************************/ + +static fieldinfo *class_resolvefield_int(classinfo *c, utf *name, utf *desc) +{ + fieldinfo *fi; + s4 i; + + /* search for field in class c */ + + for (i = 0; i < c->fieldscount; i++) { + if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) { + return &(c->fields[i]); + } + } + + /* Try super interfaces recursively. */ + + for (i = 0; i < c->interfacescount; i++) { + fi = class_resolvefield_int(c->interfaces[i], name, desc); + + if (fi != NULL) + return fi; + } + + /* Try super class. */ + + if (c->super != NULL) + return class_resolvefield_int(c->super, name, desc); + + /* not found */ + + return NULL; +} + + +/********************* Function: class_resolvefield *************************** + + Resolves a reference from REFERER to a field with NAME and DESC in class C. + + If the field cannot be resolved, an exception is thrown and the + return value is NULL. + +*******************************************************************************/ + +fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer) +{ + fieldinfo *fi; + + fi = class_resolvefield_int(c, name, desc); + + if (!fi) { + exceptions_throw_nosuchfielderror(c, name); + return NULL; + } + + /* XXX check access rights */ + + return fi; +} + + +/* class_issubclass ************************************************************ + + Checks if sub is a descendant of super. + +*******************************************************************************/ + +bool class_issubclass(classinfo *sub, classinfo *super) +{ + classinfo *c; + + c = sub; + + for (;;) { + /* We reached java/lang/Object and did not find the requested + super class. */ + + if (c == NULL) + return false; + + /* We found the requested super class. */ + + if (c == super) + return true; + + c = c->super; + } +} + + +/* class_isanysubclass ********************************************************* + + Checks a subclass relation between two classes. Implemented + interfaces are interpreted as super classes. + + Return value: 1 ... sub is subclass of super + 0 ... otherwise + +*******************************************************************************/ + +bool class_isanysubclass(classinfo *sub, classinfo *super) +{ + uint32_t diffval; + bool result; + + /* This is the trivial case. */ + + if (sub == super) + return true; + + /* Primitive classes are only subclasses of themselves. */ + + if (class_is_primitive(sub) || class_is_primitive(super)) + return false; + + /* Check for interfaces. */ + + if (super->flags & ACC_INTERFACE) { + result = (sub->vftbl->interfacetablelength > super->index) && + (sub->vftbl->interfacetable[-super->index] != NULL); + } + else { + /* java.lang.Object is the only super class of any + interface. */ + + if (sub->flags & ACC_INTERFACE) + return (super == class_java_lang_Object); + + result = fast_subtype_check(sub->vftbl, super->vftbl); + } + + return result; +} + + +/* class_is_assignable_from **************************************************** + + Return whether an instance of the "from" class parameter would be + an instance of this class "to" as well. + + ARGUMENTS: + to ..... class + from ... class + + RETURN: + true .... is assignable + false ... is not assignable + +*******************************************************************************/ + +bool class_is_assignable_from(classinfo *to, classinfo *from) +{ + if (!(to->state & CLASS_LINKED)) + if (!link_class(to)) + return false; + + if (!(from->state & CLASS_LINKED)) + if (!link_class(from)) + return false; + + return class_isanysubclass(from, to); +} + + +/* class_is_instance *********************************************************** + + Return if the given Java object is an instance of the given class. + + ARGUMENTS: + c ... class + h ... Java object + + RETURN: + true .... is instance + false ... is not instance + +*******************************************************************************/ + +bool class_is_instance(classinfo *c, java_handle_t *h) +{ + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + return false; + + return builtin_instanceof(h, c); +} + + +/* class_get_componenttype ***************************************************** + + Return the component class of the given class. If the given class + is not an array, return NULL. + +*******************************************************************************/ + +classinfo *class_get_componenttype(classinfo *c) +{ + classinfo *component; + arraydescriptor *ad; + + /* XXX maybe we could find a way to do this without linking. */ + /* This way should be safe and easy, however. */ + + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + return NULL; + + ad = c->vftbl->arraydesc; + + if (ad == NULL) + return NULL; + + if (ad->arraytype == ARRAYTYPE_OBJECT) + component = ad->componentvftbl->clazz; + else + component = Primitive_get_class_by_type(ad->arraytype); + + return component; +} + + +/* class_get_declaredclasses *************************************************** + + Return an array of declared classes of the given class. + +*******************************************************************************/ + +java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly) +{ + classref_or_classinfo inner; + classref_or_classinfo outer; + utf *outername; + int declaredclasscount; /* number of declared classes */ + int pos; /* current declared class */ + java_handle_objectarray_t *oa; /* array of declared classes */ + int i; + classinfo *ic; + + declaredclasscount = 0; + + if (!class_is_primitive(c) && !class_is_array(c)) { + /* Determine number of declared classes. */ + + for (i = 0; i < c->innerclasscount; i++) { + /* Get outer-class. If the inner-class is not a member + class, the outer-class is NULL. */ + + outer = c->innerclass[i].outer_class; + + if (outer.any == NULL) + continue; + + /* Check if outer-class is a classref or a real class and + get the class name from the structure. */ + + outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name; + + /* Outer class is this class. */ + + if ((outername == c->name) && + ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) + declaredclasscount++; + } + } + + /* Allocate Class[] and check for OOM. */ + + oa = builtin_anewarray(declaredclasscount, class_java_lang_Class); + + if (oa == NULL) + return NULL; + + for (i = 0, pos = 0; i < c->innerclasscount; i++) { + inner = c->innerclass[i].inner_class; + outer = c->innerclass[i].outer_class; + + /* Get outer-class. If the inner-class is not a member class, + the outer-class is NULL. */ + + if (outer.any == NULL) + continue; + + /* Check if outer_class is a classref or a real class and get + the class name from the structure. */ + + outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name; + + /* Outer class is this class. */ + + if ((outername == c->name) && + ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) { + + ic = resolve_classref_or_classinfo_eager(inner, false); + + if (ic == NULL) + return NULL; + + if (!(ic->state & CLASS_LINKED)) + if (!link_class(ic)) + return NULL; + + LLNI_array_direct(oa, pos++) = (java_object_t *) ic; + } + } + + return oa; +} + + +/** + * Return an array of declared constructors of the given class. + * + * @param c class to get the constructors of + * @param publicOnly show only public fields + * + * @return array of java.lang.reflect.Constructor + */ +#if defined(ENABLE_JAVASE) +java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly) +{ + methodinfo* m; + java_handle_objectarray_t* oa; + java_handle_t* rc; + int count; + int index; + int i; + + /* Determine number of constructors. */ + + count = 0; + + for (i = 0; i < c->methodscount; i++) { + m = &(c->methods[i]); + + if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) && + (m->name == utf_init)) + count++; + } + + /* Create array of constructors. */ + + oa = builtin_anewarray(count, class_java_lang_reflect_Constructor); + + if (oa == NULL) + return NULL; + + /* Get the constructors and store them in the array. */ + + for (i = 0, index = 0; i < c->methodscount; i++) { + m = &(c->methods[i]); + + if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) && + (m->name == utf_init)) { + // Create a java.lang.reflect.Constructor object. + + rc = java_lang_reflect_Constructor_create(m); + + /* Store object into array. */ + + array_objectarray_element_set(oa, index, rc); + index++; + } + } + + return oa; +} +#endif + + +/* class_get_declaredfields **************************************************** + + Return an array of declared fields of the given class. + + ARGUMENTS: + c ............ class to get the fields of + publicOnly ... show only public fields + + RETURN: + array of java.lang.reflect.Field + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly) +{ + java_handle_objectarray_t *oa; + fieldinfo *f; + java_handle_t *h; + int count; + int index; + int i; + + /* Determine number of fields. */ + + count = 0; + + for (i = 0; i < c->fieldscount; i++) + if ((c->fields[i].flags & ACC_PUBLIC) || (publicOnly == 0)) + count++; + + /* Create array of fields. */ + + oa = builtin_anewarray(count, class_java_lang_reflect_Field); + + if (oa == NULL) + return NULL; + + /* Get the fields and store them in the array. */ + + for (i = 0, index = 0; i < c->fieldscount; i++) { + f = &(c->fields[i]); + + if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) { + // Create a java.lang.reflect.Field object. + + h = java_lang_reflect_Field_create(f); + + /* Store object into array. */ + + array_objectarray_element_set(oa, index, h); + index++; + } + } + + return oa; +} +#endif + + +/* class_get_declaredmethods *************************************************** + + Return an array of declared methods of the given class. + + ARGUMENTS: + c ............ class to get the methods of + publicOnly ... show only public methods + + RETURN: + array of java.lang.reflect.Method + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly) +{ + java_handle_objectarray_t *oa; /* result: array of Method-objects */ + methodinfo *m; /* the current method to be represented */ + java_handle_t *h; + int count; + int index; + int i; + + /* JOWENN: array classes do not declare methods according to mauve + test. It should be considered, if we should return to my old + clone method overriding instead of declaring it as a member + function. */ + + if (class_is_array(c)) + return builtin_anewarray(0, class_java_lang_reflect_Method); + + /* Determine number of methods. */ + + count = 0; + + for (i = 0; i < c->methodscount; i++) { + m = &(c->methods[i]); + + if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && + ((m->name != utf_init) && (m->name != utf_clinit)) && + !(m->flags & ACC_MIRANDA)) + count++; + } + + /* Create array of methods. */ + + oa = builtin_anewarray(count, class_java_lang_reflect_Method); + + if (oa == NULL) + return NULL; + + /* Get the methods and store them in the array. */ + + for (i = 0, index = 0; i < c->methodscount; i++) { + m = &(c->methods[i]); + + if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && + ((m->name != utf_init) && (m->name != utf_clinit)) && + !(m->flags & ACC_MIRANDA)) { + // Create java.lang.reflect.Method object. + + h = java_lang_reflect_Method_create(m); + + /* Store object into array. */ + + array_objectarray_element_set(oa, index, h); + index++; + } + } + + return oa; +} +#endif + + +/* class_get_declaringclass **************************************************** + + If the class or interface given is a member of another class, + return the declaring class. For array and primitive classes return + NULL. + +*******************************************************************************/ + +classinfo *class_get_declaringclass(classinfo *c) +{ + classref_or_classinfo cr; + classinfo *dc; + + /* Get declaring class. */ + + cr = c->declaringclass; + + if (cr.any == NULL) + return NULL; + + /* Resolve the class if necessary. */ + + if (IS_CLASSREF(cr)) { +/* dc = resolve_classref_eager(cr.ref); */ + dc = resolve_classref_or_classinfo_eager(cr, true); + + if (dc == NULL) + return NULL; + + /* Store the resolved class in the class structure. */ + + cr.cls = dc; + } + + dc = cr.cls; + + return dc; +} + + +/* class_get_enclosingclass **************************************************** + + Return the enclosing class for the given class. + +*******************************************************************************/ + +classinfo *class_get_enclosingclass(classinfo *c) +{ + classref_or_classinfo cr; + classinfo *ec; + + /* Get enclosing class. */ + + cr = c->enclosingclass; + + if (cr.any == NULL) + return NULL; + + /* Resolve the class if necessary. */ + + if (IS_CLASSREF(cr)) { +/* ec = resolve_classref_eager(cr.ref); */ + ec = resolve_classref_or_classinfo_eager(cr, true); + + if (ec == NULL) + return NULL; + + /* Store the resolved class in the class structure. */ + + cr.cls = ec; + } + + ec = cr.cls; + + return ec; +} + + +/** + * Return the enclosing constructor as java.lang.reflect.Constructor + * object for the given class. + * + * @param c class to return the enclosing constructor for + * + * @return java.lang.reflect.Constructor object of the enclosing + * constructor + */ +#if defined(ENABLE_JAVASE) +java_handle_t* class_get_enclosingconstructor(classinfo *c) +{ + methodinfo* m; + java_handle_t* rc; + + m = class_get_enclosingmethod_raw(c); + + if (m == NULL) + return NULL; + + /* Check for . */ + + if (m->name != utf_init) + return NULL; + + // Create a java.lang.reflect.Constructor object. + + rc = java_lang_reflect_Constructor_create(m); + + return rc; +} +#endif + + +/* class_get_enclosingmethod *************************************************** + + Return the enclosing method for the given class. + + IN: + c ... class to return the enclosing method for + + RETURN: + methodinfo of the enclosing method + +*******************************************************************************/ + +methodinfo *class_get_enclosingmethod_raw(classinfo *c) +{ + constant_nameandtype *cn; + classinfo *ec; + methodinfo *m; + + /* get enclosing class and method */ + + ec = class_get_enclosingclass(c); + cn = c->enclosingmethod; + + /* check for enclosing class and method */ + + if (ec == NULL) + return NULL; + + if (cn == NULL) + return NULL; + + /* find method in enclosing class */ + + m = class_findmethod(ec, cn->name, cn->descriptor); + + if (m == NULL) { + exceptions_throw_internalerror("Enclosing method doesn't exist"); + return NULL; + } + + return m; +} + + +/** + * Return the enclosing method as java.lang.reflect.Method object for + * the given class. + * + * @param c class to return the enclosing method for + * + * @return java.lang.reflect.Method object of the enclosing method + */ +#if defined(ENABLE_JAVASE) +java_handle_t* class_get_enclosingmethod(classinfo *c) +{ + methodinfo* m; + java_handle_t* rm; + + m = class_get_enclosingmethod_raw(c); + + if (m == NULL) + return NULL; + + /* check for */ + + if (m->name == utf_init) + return NULL; + + // Create a java.lang.reflect.Method object. + + rm = java_lang_reflect_Method_create(m); + + return rm; +} +#endif + + +/* class_get_interfaces ******************************************************** + + Return an array of interfaces of the given class. + +*******************************************************************************/ + +java_handle_objectarray_t *class_get_interfaces(classinfo *c) +{ + classinfo *ic; + java_handle_objectarray_t *oa; + u4 i; + + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + return NULL; + + oa = builtin_anewarray(c->interfacescount, class_java_lang_Class); + + if (oa == NULL) + return NULL; + + for (i = 0; i < c->interfacescount; i++) { + ic = c->interfaces[i]; + + LLNI_array_direct(oa, i) = (java_object_t *) ic; + } + + return oa; +} + + +/* class_get_annotations ******************************************************* + + Get the unparsed declared annotations in a byte array + of the given class. + + IN: + c........the class of which the annotations should be returned + + RETURN VALUE: + The unparsed declared annotations in a byte array + (or NULL if there aren't any). + +*******************************************************************************/ + +java_handle_bytearray_t *class_get_annotations(classinfo *c) +{ +#if defined(ENABLE_ANNOTATIONS) + java_handle_t *annotations; /* unparsed annotations */ + + LLNI_classinfo_field_get(c, annotations, annotations); + + return (java_handle_bytearray_t*)annotations; +#else + return NULL; +#endif +} + + +/* class_get_modifiers ********************************************************* + + Get the modifier flags of the given class. + + IN: + c....the class of which the modifier flags should be returned + ignoreInnerClassesAttrib + RETURN VALUE: + modifier flags + +*******************************************************************************/ + +int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib) +{ + classref_or_classinfo inner; + classref_or_classinfo outer; + utf *innername; + int i; + + if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) { + /* search for passed class as inner class */ + + for (i = 0; i < c->innerclasscount; i++) { + inner = c->innerclass[i].inner_class; + outer = c->innerclass[i].outer_class; + + /* Check if inner is a classref or a real class and get + the name of the structure */ + + innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name; + + /* innerclass is this class */ + + if (innername == c->name) { + /* has the class actually an outer class? */ + + if (outer.any) + /* return flags got from the outer class file */ + return c->innerclass[i].flags & ACC_CLASS_REFLECT_MASK; + else + return c->flags & ACC_CLASS_REFLECT_MASK; + } + } + } + + /* passed class is no inner class or it was not requested */ + + return c->flags & ACC_CLASS_REFLECT_MASK; +} + + +/* class_get_signature ********************************************************* + + Return the signature of the given class. For array and primitive + classes return NULL. + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +utf *class_get_signature(classinfo *c) +{ + /* For array and primitive classes return NULL. */ + + if (class_is_array(c) || class_is_primitive(c)) + return NULL; + + return c->signature; +} +#endif + + +/* class_printflags ************************************************************ + + Prints flags of a class. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_printflags(classinfo *c) +{ + if (c == NULL) { + printf("NULL"); + return; + } + + if (c->flags & ACC_PUBLIC) printf(" PUBLIC"); + if (c->flags & ACC_PRIVATE) printf(" PRIVATE"); + if (c->flags & ACC_PROTECTED) printf(" PROTECTED"); + if (c->flags & ACC_STATIC) printf(" STATIC"); + if (c->flags & ACC_FINAL) printf(" FINAL"); + if (c->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED"); + if (c->flags & ACC_VOLATILE) printf(" VOLATILE"); + if (c->flags & ACC_TRANSIENT) printf(" TRANSIENT"); + if (c->flags & ACC_NATIVE) printf(" NATIVE"); + if (c->flags & ACC_INTERFACE) printf(" INTERFACE"); + if (c->flags & ACC_ABSTRACT) printf(" ABSTRACT"); +} +#endif + + +/* class_print ***************************************************************** + + Prints classname plus flags. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_print(classinfo *c) +{ + if (c == NULL) { + printf("NULL"); + return; + } + + utf_display_printable_ascii(c->name); + class_printflags(c); +} +#endif + + +/* class_classref_print ******************************************************** + + Prints classname plus referer class. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_classref_print(constant_classref *cr) +{ + if (cr == NULL) { + printf("NULL"); + return; + } + + utf_display_printable_ascii(cr->name); + printf("(ref.by "); + if (cr->referer) + class_print(cr->referer); + else + printf("NULL"); + printf(")"); +} +#endif + + +/* class_println *************************************************************** + + Prints classname plus flags and new line. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_println(classinfo *c) +{ + class_print(c); + printf("\n"); +} +#endif + + +/* class_classref_println ****************************************************** + + Prints classname plus referer class and new line. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_classref_println(constant_classref *cr) +{ + class_classref_print(cr); + printf("\n"); +} +#endif + + +/* class_classref_or_classinfo_print ******************************************* + + Prints classname plus referer class. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_classref_or_classinfo_print(classref_or_classinfo c) +{ + if (c.any == NULL) { + printf("(classref_or_classinfo) NULL"); + return; + } + if (IS_CLASSREF(c)) + class_classref_print(c.ref); + else + class_print(c.cls); +} +#endif + + +/* class_classref_or_classinfo_println ***************************************** + + Prints classname plus referer class and a newline. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_classref_or_classinfo_println(classref_or_classinfo c) +{ + class_classref_or_classinfo_print(c); + printf("\n"); +} +#endif + + +/* class_showconstantpool ****************************************************** + + Dump the constant pool of the given class to stdout. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_showconstantpool (classinfo *c) +{ + u4 i; + void* e; + + printf ("---- dump of constant pool ----\n"); + + for (i=0; icpcount; i++) { + printf ("#%d: ", (int) i); + + e = c -> cpinfos [i]; + if (e) { + + switch (c -> cptags [i]) { + case CONSTANT_Class: + printf ("Classreference -> "); + utf_display_printable_ascii ( ((constant_classref*)e) -> name ); + break; + case CONSTANT_Fieldref: + printf ("Fieldref -> "); + field_fieldref_print((constant_FMIref *) e); + break; + case CONSTANT_Methodref: + printf ("Methodref -> "); + method_methodref_print((constant_FMIref *) e); + break; + case CONSTANT_InterfaceMethodref: + printf ("InterfaceMethod -> "); + method_methodref_print((constant_FMIref *) e); + break; + case CONSTANT_String: + printf ("String -> "); + utf_display_printable_ascii (e); + break; + case CONSTANT_Integer: + printf ("Integer -> %d", (int) ( ((constant_integer*)e) -> value) ); + break; + case CONSTANT_Float: + printf ("Float -> %f", ((constant_float*)e) -> value); + break; + case CONSTANT_Double: + printf ("Double -> %f", ((constant_double*)e) -> value); + break; + case CONSTANT_Long: + { + u8 v = ((constant_long*)e) -> value; +#if U8_AVAILABLE + printf ("Long -> %ld", (long int) v); +#else + printf ("Long -> HI: %ld, LO: %ld\n", + (long int) v.high, (long int) v.low); +#endif + } + break; + case CONSTANT_NameAndType: + { + constant_nameandtype *cnt = e; + printf ("NameAndType: "); + utf_display_printable_ascii (cnt->name); + printf (" "); + utf_display_printable_ascii (cnt->descriptor); + } + break; + case CONSTANT_Utf8: + printf ("Utf8 -> "); + utf_display_printable_ascii (e); + break; + default: + log_text("Invalid type of ConstantPool-Entry"); + assert(0); + } + } + + printf ("\n"); + } +} +#endif /* !defined(NDEBUG) */ + + +/* class_showmethods *********************************************************** + + Dump info about the fields and methods of the given class to stdout. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void class_showmethods (classinfo *c) +{ + s4 i; + + printf("--------- Fields and Methods ----------------\n"); + printf("Flags: "); + class_printflags(c); + printf("\n"); + + printf("This: "); + utf_display_printable_ascii(c->name); + printf("\n"); + + if (c->super) { + printf("Super: "); + utf_display_printable_ascii(c->super->name); + printf ("\n"); + } + + printf("Index: %d\n", c->index); + + printf("Interfaces:\n"); + for (i = 0; i < c->interfacescount; i++) { + printf(" "); + utf_display_printable_ascii(c->interfaces[i]->name); + printf (" (%d)\n", c->interfaces[i]->index); + } + + printf("Fields:\n"); + for (i = 0; i < c->fieldscount; i++) + field_println(&(c->fields[i])); + + printf("Methods:\n"); + for (i = 0; i < c->methodscount; i++) { + methodinfo *m = &(c->methods[i]); + + if (!(m->flags & ACC_STATIC)) + printf("vftblindex: %d ", m->vftblindex); + + method_println(m); + } + + printf ("Virtual function table:\n"); + for (i = 0; i < c->vftbl->vftbllength; i++) + printf ("entry: %d, %ld\n", i, (long int) (c->vftbl->table[i])); +} +#endif /* !defined(NDEBUG) */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/class.h b/src/vm/class.h new file mode 100644 index 000000000..5e25a51b7 --- /dev/null +++ b/src/vm/class.h @@ -0,0 +1,462 @@ +/* src/vm/class.h - class related functions header + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _CLASS_H +#define _CLASS_H + +/* forward typedefs ***********************************************************/ + +typedef struct classinfo classinfo; +typedef struct innerclassinfo innerclassinfo; +typedef struct extra_classref extra_classref; + + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "toolbox/list.h" + +#if defined(ENABLE_JAVASE) +# include "vm/annotation.h" +#endif + +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/references.h" +#include "vm/string.hpp" +#include "vm/utf8.h" + + +/* class state defines ********************************************************/ + +#define CLASS_LOADING 0x0001 +#define CLASS_LOADED 0x0002 +#define CLASS_LINKING 0x0004 +#define CLASS_LINKED 0x0008 +#define CLASS_INITIALIZING 0x0010 +#define CLASS_INITIALIZED 0x0020 +#define CLASS_ERROR 0x0040 + + +/* some macros ****************************************************************/ + +#define CLASS_IS_OR_ALMOST_INITIALIZED(c) \ + (((c)->state & CLASS_INITIALIZING) || ((c)->state & CLASS_INITIALIZED)) + + +/* classinfo ******************************************************************/ + +/* We define this dummy structure of java_lang_Class so we can + bootstrap cacaoh without needing a java_lang_Class.h file. Whether + the size of the dummy structure is big enough is checked during + runtime in vm_create. */ + +typedef struct { + java_object_t header; +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + intptr_t padding[4]; +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + intptr_t padding[19]; +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + intptr_t padding[3]; +#else +# error unknown classpath configuration +#endif +} dummy_java_lang_Class; + +struct classinfo { /* class structure */ + dummy_java_lang_Class object; + + s4 flags; /* ACC flags */ + utf *name; /* class name */ + + s4 cpcount; /* number of entries in constant pool */ + u1 *cptags; /* constant pool tags */ + void* *cpinfos; /* pointer to constant pool info structures */ + + s4 classrefcount; /* number of symbolic class references */ + constant_classref *classrefs; /* table of symbolic class references */ + extra_classref *extclassrefs; /* additional classrefs */ + s4 parseddescsize; /* size of the parsed descriptors block */ + u1 *parseddescs; /* parsed descriptors */ + + classinfo *super; /* super class */ + classinfo *sub; /* sub class pointer */ + classinfo *nextsub; /* pointer to next class in sub class list */ + + int32_t interfacescount; /* number of interfaces */ + classinfo **interfaces; /* super interfaces */ + + int32_t fieldscount; /* number of fields */ + fieldinfo *fields; /* field table */ + + int32_t methodscount; /* number of methods */ + methodinfo *methods; /* method table */ + + s4 state; /* current class state */ + s4 index; /* hierarchy depth (classes) or index */ + /* (interfaces) */ + s4 instancesize; /* size of an instance of this class */ + + vftbl_t *vftbl; /* pointer to virtual function table */ + + methodinfo *finalizer; /* finalizer method */ + + u2 innerclasscount; /* number of inner classes */ + innerclassinfo *innerclass; + + classref_or_classinfo declaringclass; + classref_or_classinfo enclosingclass; /* enclosing class */ + constant_nameandtype *enclosingmethod; /* enclosing method */ + + utf *packagename; /* full name of the package */ + utf *sourcefile; /* SourceFile attribute */ +#if defined(ENABLE_JAVASE) + utf *signature; /* Signature attribute */ +#if defined(ENABLE_ANNOTATIONS) + /* All the annotation attributes are NULL (and not a zero length array) */ + /* if there is nothing. */ + java_object_t *annotations; /* annotations of this class */ + + java_object_t *method_annotations; /* array of annotations of the methods */ + java_object_t *method_parameterannotations; /* array of parameter */ + /* annotations of the methods */ + java_object_t *method_annotationdefaults; /* array of annotation default */ + /* values of the methods */ + + java_object_t *field_annotations; /* array of annotations of the fields */ + +#endif +#endif + classloader_t *classloader; /* NULL for bootstrap classloader */ + +#if defined(ENABLE_JAVASE) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + java_object_t *protectiondomain; + java_objectarray_t *signers; +# endif +#endif +}; + + +/* innerclassinfo *************************************************************/ + +struct innerclassinfo { + classref_or_classinfo inner_class; /* inner class pointer */ + classref_or_classinfo outer_class; /* outer class pointer */ + utf *name; /* innerclass name */ + s4 flags; /* ACC flags */ +}; + + +/* extra_classref ************************************************************** + + for classrefs not occurring within descriptors + +*******************************************************************************/ + +struct extra_classref { + extra_classref *next; + constant_classref classref; +}; + + +/* inline functions ***********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Returns the classname of the class, where slashes ('/') are + * replaced by dots ('.'). + * + * @param c class to get name of + * @return classname + */ +inline static java_handle_t* class_get_classname(classinfo* c) +{ + java_handle_t *s; + + /* Create a java string. */ + + s = javastring_new_slash_to_dot(c->name); + + return s; +} + + +/* class_is_primitive ********************************************************** + + Checks if the given class is a primitive class. + +*******************************************************************************/ + +static inline bool class_is_primitive(classinfo *c) +{ + if (c->flags & ACC_CLASS_PRIMITIVE) + return true; + + return false; +} + + +/* class_is_anonymousclass ***************************************************** + + Checks if the given class is an anonymous class. + +*******************************************************************************/ + +static inline bool class_is_anonymousclass(classinfo *c) +{ + if (c->flags & ACC_CLASS_ANONYMOUS) + return true; + + return false; +} + + +/* class_is_array ************************************************************** + + Checks if the given class is an array class. + +*******************************************************************************/ + +static inline bool class_is_array(classinfo *c) +{ + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + return false; + + return (c->vftbl->arraydesc != NULL); +} + + +/* class_is_interface ********************************************************** + + Checks if the given class is an interface. + +*******************************************************************************/ + +static inline bool class_is_interface(classinfo *c) +{ + if (c->flags & ACC_INTERFACE) + return true; + + return false; +} + + +/* class_is_localclass ********************************************************* + + Checks if the given class is a local class. + +*******************************************************************************/ + +static inline bool class_is_localclass(classinfo *c) +{ + if ((c->enclosingmethod != NULL) && !class_is_anonymousclass(c)) + return true; + + return false; +} + + +/* class_is_memberclass ******************************************************** + + Checks if the given class is a member class. + +*******************************************************************************/ + +static inline bool class_is_memberclass(classinfo *c) +{ + if (c->flags & ACC_CLASS_MEMBER) + return true; + + return false; +} + + +/* class_get_classloader ******************************************************* + + Return the classloader of the given class. + +*******************************************************************************/ + +static inline classloader_t *class_get_classloader(classinfo *c) +{ + classloader_t *cl; + + cl = c->classloader; + + /* The classloader may be NULL. */ + + return cl; +} + + +/* class_get_superclass ******************************************************** + + Return the super class of the given class. + +*******************************************************************************/ + +static inline classinfo *class_get_superclass(classinfo *c) +{ + /* For interfaces we return NULL. */ + + if (c->flags & ACC_INTERFACE) + return NULL; + + /* For java/lang/Object, primitive-type and Void classes c->super + is NULL and we return NULL. */ + + return c->super; +} + + +/* function prototypes ********************************************************/ + +classinfo *class_create_classinfo(utf *u); +void class_postset_header_vftbl(void); +classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd); +void class_set_packagename(classinfo *c); + +bool class_load_attributes(classbuffer *cb); + +/* retrieve constantpool element */ +void* class_getconstant(classinfo *c, u4 pos, u4 ctype); +void* innerclass_getconstant(classinfo *c, u4 pos, u4 ctype); + +/* frees all resources used by the class */ +void class_free(classinfo *); + +/* return an array class with the given component class */ +classinfo *class_array_of(classinfo *component,bool link); + +/* return an array class with the given dimension and element class */ +classinfo *class_multiarray_of(s4 dim, classinfo *element,bool link); + +/* return a classref for the given class name */ +/* (does a linear search!) */ +constant_classref *class_lookup_classref(classinfo *cls,utf *name); + +/* return a classref for the given class name */ +/* (does a linear search!) */ +constant_classref *class_get_classref(classinfo *cls,utf *name); + +/* return a classref to the class itself */ +/* (does a linear search!) */ +constant_classref *class_get_self_classref(classinfo *cls); + +/* return a classref for an array with the given dimension of with the */ +/* given component type */ +constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref); + +/* return a classref for the component type of the given array type */ +constant_classref *class_get_classref_component_of(constant_classref *ref); + +/* get a class' field by name and descriptor */ +fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc); + +/* search 'classinfo'-structure for a field with the specified name */ +fieldinfo *class_findfield_by_name(classinfo *c, utf *name); + +/* search class for a field */ +fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer); + +/* search for a method with a specified name and descriptor */ +methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc); +methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest); +methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception); +methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception); + +bool class_issubclass(classinfo *sub, classinfo *super); +bool class_isanysubclass(classinfo *sub, classinfo *super); +bool class_is_assignable_from(classinfo *to, classinfo *from); +bool class_is_instance(classinfo *c, java_handle_t *h); + +classloader_t *class_get_classloader(classinfo *c); +classinfo *class_get_superclass(classinfo *c); +classinfo *class_get_componenttype(classinfo *c); +java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly); +java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly); +java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly); +java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly); +classinfo *class_get_declaringclass(classinfo *c); +classinfo *class_get_enclosingclass(classinfo *c); +java_handle_t* class_get_enclosingconstructor(classinfo *c); +methodinfo* class_get_enclosingmethod_raw(classinfo *c); +java_handle_t* class_get_enclosingmethod(classinfo *c); +java_handle_objectarray_t *class_get_interfaces(classinfo *c); +java_handle_bytearray_t *class_get_annotations(classinfo *c); +int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib); +java_handle_t *class_get_name(classinfo *c); + +#if defined(ENABLE_JAVASE) +utf *class_get_signature(classinfo *c); +#endif + +/* some debugging functions */ + +#if !defined(NDEBUG) +void class_printflags(classinfo *c); +void class_print(classinfo *c); +void class_println(classinfo *c); +void class_classref_print(constant_classref *cr); +void class_classref_println(constant_classref *cr); +void class_classref_or_classinfo_print(classref_or_classinfo c); +void class_classref_or_classinfo_println(classref_or_classinfo c); +#endif + +/* debug purposes */ +void class_showmethods(classinfo *c); +void class_showconstantpool(classinfo *c); + +#ifdef __cplusplus +} +#endif + +#endif /* _CLASS_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/classcache.c b/src/vm/classcache.c new file mode 100644 index 000000000..07356571e --- /dev/null +++ b/src/vm/classcache.c @@ -0,0 +1,1586 @@ +/* src/vm/classcache.c - loaded class cache and loading constraints + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "threads/lock-common.h" +#include "threads/mutex.hpp" + +#include "toolbox/hashtable.h" +#include "toolbox/logging.h" + +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/options.h" +#include "vm/utf8.h" + + +/************************************************************************* + + Class Cache + + The classcache has two functions: + + 1) caching the resolution of class references + 2) storing and checking loading constraints + + We will use the following terms in this description: + + N a class name: a utf string + (N,L) a class reference with initiating loader L and class name N + C a class (object): the result of resolving a reference (N,L) + We will write resultion as + C = *(N,L) + (N,L1,L2) a loading constraint indicating that (N,L1) and (N,L2) must + resolve to the same class C. So (N,L1,L2) means + *(N,L1) = *(N,L2) + + The functions of the classcache require: + + 1) a mapping (N,L) |--> C for looking up prior resolution results. + 2) storing the current set of loading constraints { (N,L1,L2) } + + These functions can be rearranged like that: + + a mapping N |--> (a mapping L |--> C or NULL, + a set of constraints {(L1,L2)}) + + Thus we can treat the mapping and constraints for each name N + separately. The implementation does this by keeping a hash table + mapping a name N to a `classcache_name_entry` which contains all + info with respect to N. + + For a class name N we can define an equivalence relation ~N~ on + class loaders: + + L1 ~N~ L2 <==> *(N,L1) = *(N,L2) + + A loading constraint (N,L1,L2) implies L1 ~N~ L2. + + Also, if two references (N,L1) and (N,L2) resolve to the same class C + we have L1 ~N~ L2 because class loaders are required to return + consistent resolutions for a name N [XXX]. + + A `classcache_name_entry` keeps a set of tuples { (Cx,IL,CL) }, + where + Cx...is a class C or NULL + IL...is the set of initiating loaders + CL...is the set of constrained loaders + + Such a tuple is called `classcache_class_entry` in the source code. + + The following holds for each tuple (Cx,IL,CL): + + . (Cx is NULL) implies IL = {}. + + . If Cx is a class, IL is the set of loaders that have been + recorded as initiating loaders for Cx. IL may be the + empty set {} in case Cx has already been defined but no + initiating loader has been recorded, yet. + + . (IL u CL) is a subset of an equivalence class of ~N~. + + (This means that all loaders in IL and CL must resolve + the name N to the same class.) + + The following holds for the set of tuples { (Cx,IL,CL) }: + + . For a given class C there is at most one tuple with Cx = C + in the set. (There may be an arbitrary number of tuples + with Cx = NULL, however.) + + . For a given loader L there is at most one tuple with + L in (IL u CL). + + The implementation stores sets of loaders as linked lists of + `classcache_loader_entry`s. + + Comments about manipulating the classcache can be found in the + individual functions below. + +*************************************************************************/ + + +/* initial number of slots in the classcache hash table */ +#define CLASSCACHE_INIT_SIZE 2048 + +/*============================================================================*/ +/* DEBUG HELPERS */ +/*============================================================================*/ + +/* #define CLASSCACHE_VERBOSE */ + +/*============================================================================*/ +/* STATISTICS */ +/*============================================================================*/ + +/*#define CLASSCACHE_STATS*/ + +#ifdef CLASSCACHE_STATS +static int stat_classnames_stored = 0; +static int stat_classes_stored = 0; +static int stat_trivial_constraints = 0; +static int stat_nontriv_constraints = 0; +static int stat_nontriv_constraints_both = 0; +static int stat_nontriv_constraints_merged = 0; +static int stat_nontriv_constraints_one = 0; +static int stat_nontriv_constraints_none = 0; +static int stat_new_loader_entry = 0; +static int stat_merge_class_entries = 0; +static int stat_merge_loader_entries = 0; +static int stat_lookup = 0; +static int stat_lookup_class_entry_checked = 0; +static int stat_lookup_loader_checked = 0; +static int stat_lookup_name = 0; +static int stat_lookup_name_entry = 0; +static int stat_lookup_name_notfound = 0; +static int stat_lookup_new_name = 0; +static int stat_lookup_new_name_entry = 0; +static int stat_lookup_new_name_collisions = 0; +static int stat_rehash_names = 0; +static int stat_rehash_names_collisions = 0; + +#define CLASSCACHE_COUNT(cnt) (cnt)++ +#define CLASSCACHE_COUNTIF(cond,cnt) do{if(cond) (cnt)++;} while(0) + +void classcache_print_statistics(FILE *file) { + fprintf(file,"classnames stored : %8d\n",stat_classnames_stored); + fprintf(file,"classes stored : %8d\n",stat_classes_stored); + fprintf(file,"trivial constraints : %8d\n",stat_trivial_constraints); + fprintf(file,"non-triv constraints: %8d\n",stat_nontriv_constraints); + fprintf(file," both loaders rec.: %8d\n",stat_nontriv_constraints_both); + fprintf(file," merged : %8d\n",stat_nontriv_constraints_merged); + fprintf(file," one loader rec. : %8d\n",stat_nontriv_constraints_one); + fprintf(file," no loaders rec. : %8d\n",stat_nontriv_constraints_none); + fprintf(file,"new loader entries : %8d\n",stat_new_loader_entry); + fprintf(file,"merge class entries : %8d\n",stat_merge_class_entries); + fprintf(file,"merge loader entries: %8d\n",stat_merge_loader_entries); + fprintf(file,"lookups : %8d\n",stat_lookup); + fprintf(file," class entries ckd: %8d\n",stat_lookup_class_entry_checked); + fprintf(file," loader checked : %8d\n",stat_lookup_loader_checked); + fprintf(file,"lookup name : %8d\n",stat_lookup_name); + fprintf(file," entries checked : %8d\n",stat_lookup_name_entry); + fprintf(file," not found : %8d\n",stat_lookup_name_notfound); + fprintf(file,"lookup (new) name : %8d\n",stat_lookup_new_name); + fprintf(file," entries checked : %8d\n",stat_lookup_new_name_entry); + fprintf(file," new collisions : %8d\n",stat_lookup_new_name_collisions); + fprintf(file,"names rehashed : %8d times\n",stat_rehash_names); + fprintf(file," collisions : %8d\n",stat_rehash_names_collisions); +} +#else +#define CLASSCACHE_COUNT(cnt) +#define CLASSCACHE_COUNTIF(cond,cnt) +#endif + +/*============================================================================*/ +/* THREAD-SAFE LOCKING */ +/*============================================================================*/ + + /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + /* CAUTION: The static functions below are */ + /* NOT synchronized! */ + /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +#if defined(ENABLE_THREADS) +# define CLASSCACHE_LOCK() Mutex_lock(classcache_hashtable_mutex) +# define CLASSCACHE_UNLOCK() Mutex_unlock(classcache_hashtable_mutex) +#else +# define CLASSCACHE_LOCK() +# define CLASSCACHE_UNLOCK() +#endif + +/*============================================================================*/ +/* GLOBAL VARIABLES */ +/*============================================================================*/ + +hashtable hashtable_classcache; + +#if defined(ENABLE_THREADS) +static Mutex *classcache_hashtable_mutex; +#endif + + +/*============================================================================*/ +/* */ +/*============================================================================*/ + +/* prototypes */ + +static void classcache_free_class_entry(classcache_class_entry *clsen); +static void classcache_remove_class_entry(classcache_name_entry *en, + classcache_class_entry *clsen); + +/* hash function to use */ + +#define CLASSCACHE_HASH utf_full_hashkey + +/* classcache_init ************************************************************* + + Initialize the class cache + + Note: NOT synchronized! + +*******************************************************************************/ + +bool classcache_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("classcache_init"); + + /* create the hashtable */ + + hashtable_create(&hashtable_classcache, CLASSCACHE_INIT_SIZE); + +#if defined(ENABLE_THREADS) + /* create utf hashtable mutex */ + + classcache_hashtable_mutex = Mutex_new(); +#endif + + /* everything's ok */ + + return true; +} + +/* classcache_new_loader_entry ************************************************* + + Create a new classcache_loader_entry struct + (internally used helper function) + + IN: + loader...........the ClassLoader object + next.............the next classcache_loader_entry + + RETURN VALUE: + the new classcache_loader_entry + +*******************************************************************************/ + +static classcache_loader_entry * classcache_new_loader_entry( + classloader_t * loader, + classcache_loader_entry * next) +{ + classcache_loader_entry *lden; + + lden = NEW(classcache_loader_entry); + lden->loader = loader; + lden->next = next; + CLASSCACHE_COUNT(stat_new_loader_entry); + + return lden; +} + +/* classcache_merge_loaders **************************************************** + + Merge two lists of loaders into one + (internally used helper function) + + IN: + lista............first list (may be NULL) + listb............second list (may be NULL) + + RETURN VALUE: + the merged list (may be NULL) + + NOTE: + The lists given as arguments are destroyed! + +*******************************************************************************/ + +static classcache_loader_entry * classcache_merge_loaders( + classcache_loader_entry * lista, + classcache_loader_entry * listb) +{ + classcache_loader_entry *result; + classcache_loader_entry *ldenA; + classcache_loader_entry *ldenB; + classcache_loader_entry **chain; + + CLASSCACHE_COUNT(stat_merge_loader_entries); + + /* XXX This is a quadratic algorithm. If this ever + * becomes a problem, the loader lists should be + * stored as sorted lists and merged in linear time. */ + + result = NULL; + chain = &result; + + for (ldenA = lista; ldenA; ldenA = ldenA->next) { + + for (ldenB = listb; ldenB; ldenB = ldenB->next) { + if (ldenB->loader == ldenA->loader) + goto common_element; + } + + /* this loader is only in lista */ + *chain = ldenA; + chain = &(ldenA->next); + + common_element: + /* XXX free the duplicated element */ + ; + } + + /* concat listb to the result */ + *chain = listb; + + return result; +} + +/* classcache_merge_class_entries ********************************************** + + Merge two `classcache_class_entry`s into one. + (internally used helper function) + + IN: + en...............the classcache_name_entry containing both class entries + clsenA...........first class entry, will receive the result + clsenB...........second class entry + + PRE-CONDITION: + Either both entries must have the same classobj, or one of them has + classobj == NULL. + + NOTE: + clsenB is freed by this function! + +*******************************************************************************/ + +static void classcache_merge_class_entries(classcache_name_entry *en, + classcache_class_entry *clsenA, + classcache_class_entry *clsenB) +{ +#ifdef CLASSCACHE_VERBOSE + char logbuffer[1024]; +#endif + + assert(en); + assert(clsenA); + assert(clsenB); + assert(!clsenA->classobj || !clsenB->classobj || clsenA->classobj == clsenB->classobj); + +#ifdef CLASSCACHE_VERBOSE + sprintf(logbuffer,"classcache_merge_class_entries(%p,%p->%p,%p->%p) ", + (void*)en,(void*)clsenA,(void*)clsenA->classobj,(void*)clsenB,(void*)clsenB->classobj); + if (clsenA->classobj) + utf_cat_classname(logbuffer, clsenA->classobj->name); + if (clsenB->classobj) + utf_cat_classname(logbuffer, clsenB->classobj->name); + log_println(logbuffer); +#endif + + CLASSCACHE_COUNT(stat_merge_class_entries); + + /* clsenB will be merged into clsenA */ + clsenA->loaders = classcache_merge_loaders(clsenA->loaders, clsenB->loaders); + clsenB->loaders = NULL; /* these have been freed or reused */ + + clsenA->constraints = classcache_merge_loaders(clsenA->constraints, + clsenB->constraints); + clsenB->constraints = NULL; /* these have been freed or reused */ + + if (!clsenA->classobj) + clsenA->classobj = clsenB->classobj; + + /* remove clsenB from the list of class entries */ + classcache_remove_class_entry(en, clsenB); +} + + +/* classcache_lookup_name ****************************************************** + + Lookup a name in the first level of the cache + (internally used helper function) + + IN: + name.............the name to look up + + RETURN VALUE: + a pointer to the classcache_name_entry for this name, or + null if no entry was found. + +*******************************************************************************/ + +static classcache_name_entry *classcache_lookup_name(utf *name) +{ + classcache_name_entry *c; /* hash table element */ + u4 key; /* hashkey computed from classname */ + u4 slot; /* slot in hashtable */ + + CLASSCACHE_COUNT(stat_lookup_name); + + key = CLASSCACHE_HASH(name->text, (u4) name->blength); + slot = key & (hashtable_classcache.size - 1); + c = hashtable_classcache.ptr[slot]; + + /* search external hash chain for the entry */ + + while (c) { + /* entry found in hashtable */ + CLASSCACHE_COUNT(stat_lookup_name_entry); + + if (c->name == name) + return c; + + c = c->hashlink; /* next element in external chain */ + } + + /* not found */ + + CLASSCACHE_COUNT(stat_lookup_name_notfound); + return NULL; +} + + +/* classcache_new_name ********************************************************* + + Return a classcache_name_entry for the given name. The entry is created + if it is not already in the cache. + (internally used helper function) + + IN: + name.............the name to look up / create an entry for + + RETURN VALUE: + a pointer to the classcache_name_entry for this name + +*******************************************************************************/ + +static classcache_name_entry *classcache_new_name(utf *name) +{ + classcache_name_entry *c; /* hash table element */ + u4 key; /* hashkey computed from classname */ + u4 slot; /* slot in hashtable */ + u4 i; + + CLASSCACHE_COUNT(stat_lookup_new_name); + + key = CLASSCACHE_HASH(name->text, (u4) name->blength); + slot = key & (hashtable_classcache.size - 1); + c = hashtable_classcache.ptr[slot]; + + /* search external hash chain for the entry */ + + while (c) { + /* entry found in hashtable */ + CLASSCACHE_COUNT(stat_lookup_new_name_entry); + + if (c->name == name) + return c; + + c = c->hashlink; /* next element in external chain */ + } + + /* location in hashtable found, create new entry */ + + c = NEW(classcache_name_entry); + + c->name = name; + c->classes = NULL; + + /* insert entry into hashtable */ + c->hashlink = (classcache_name_entry *) hashtable_classcache.ptr[slot]; + CLASSCACHE_COUNTIF(c->hashlink,stat_lookup_new_name_collisions); + hashtable_classcache.ptr[slot] = c; + + /* update number of hashtable-entries */ + hashtable_classcache.entries++; + CLASSCACHE_COUNT(stat_classnames_stored); + + if ((hashtable_classcache.entries*2) > hashtable_classcache.size) { + /* reorganization of hashtable */ + + classcache_name_entry *c2; + hashtable newhash; /* the new hashtable */ + + CLASSCACHE_COUNT(stat_rehash_names); + + /* create new hashtable, double the size */ + + hashtable_create(&newhash, hashtable_classcache.size * 2); + newhash.entries = hashtable_classcache.entries; + + /* transfer elements to new hashtable */ + + for (i = 0; i < hashtable_classcache.size; i++) { + c2 = (classcache_name_entry *) hashtable_classcache.ptr[i]; + while (c2) { + classcache_name_entry *nextc = c2->hashlink; + u4 newslot = + (CLASSCACHE_HASH(c2->name->text, (u4) c2->name->blength)) & (newhash.size - 1); + + c2->hashlink = (classcache_name_entry *) newhash.ptr[newslot]; + CLASSCACHE_COUNTIF(c2->hashlink,stat_rehash_names_collisions); + newhash.ptr[newslot] = c2; + + c2 = nextc; + } + } + + /* dispose old table */ + + MFREE(hashtable_classcache.ptr, void *, hashtable_classcache.size); + hashtable_classcache = newhash; + } + + return c; +} + + +/* classcache_lookup *********************************************************** + + Lookup a possibly loaded class + + IN: + initloader.......initiating loader for resolving the class name + classname........class name to look up + + RETURN VALUE: + The return value is a pointer to the cached class object, + or NULL, if the class is not in the cache. + + Note: synchronized with global tablelock + +*******************************************************************************/ + +classinfo *classcache_lookup(classloader_t *initloader, utf *classname) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; + classcache_loader_entry *lden; + classinfo *cls = NULL; + + CLASSCACHE_LOCK(); + + CLASSCACHE_COUNT(stat_lookup); + en = classcache_lookup_name(classname); + + if (en) { + /* iterate over all class entries */ + + for (clsen = en->classes; clsen; clsen = clsen->next) { + CLASSCACHE_COUNT(stat_lookup_class_entry_checked); + /* check if this entry has been loaded by initloader */ + + for (lden = clsen->loaders; lden; lden = lden->next) { + CLASSCACHE_COUNT(stat_lookup_loader_checked); + if (lden->loader == initloader) { + /* found the loaded class entry */ + + assert(clsen->classobj); + cls = clsen->classobj; + goto found; + } + } + } + } + + found: + CLASSCACHE_UNLOCK(); + return cls; +} + + +/* classcache_lookup_defined *************************************************** + + Lookup a class with the given name and defining loader + + IN: + defloader........defining loader + classname........class name + + RETURN VALUE: + The return value is a pointer to the cached class object, + or NULL, if the class is not in the cache. + +*******************************************************************************/ + +classinfo *classcache_lookup_defined(classloader_t *defloader, utf *classname) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; + classinfo *cls = NULL; + + CLASSCACHE_LOCK(); + + en = classcache_lookup_name(classname); + + if (en) { + /* iterate over all class entries */ + for (clsen = en->classes; clsen; clsen = clsen->next) { + if (!clsen->classobj) + continue; + + /* check if this entry has been defined by defloader */ + if (clsen->classobj->classloader == defloader) { + cls = clsen->classobj; + goto found; + } + } + } + + found: + CLASSCACHE_UNLOCK(); + return cls; +} + + +/* classcache_lookup_defined_or_initiated ************************************** + + Lookup a class that has been defined or initiated by the given loader + + IN: + loader...........defining or initiating loader + classname........class name to look up + + RETURN VALUE: + The return value is a pointer to the cached class object, + or NULL, if the class is not in the cache. + + Note: synchronized with global tablelock + +*******************************************************************************/ + +classinfo *classcache_lookup_defined_or_initiated(classloader_t *loader, + utf *classname) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; + classcache_loader_entry *lden; + classinfo *cls = NULL; + + CLASSCACHE_LOCK(); + + en = classcache_lookup_name(classname); + + if (en) { + /* iterate over all class entries */ + + for (clsen = en->classes; clsen; clsen = clsen->next) { + + /* check if this entry has been defined by loader */ + if (clsen->classobj && clsen->classobj->classloader == loader) { + cls = clsen->classobj; + goto found; + } + + /* check if this entry has been initiated by loader */ + for (lden = clsen->loaders; lden; lden = lden->next) { + if (lden->loader == loader) { + /* found the loaded class entry */ + + assert(clsen->classobj); + cls = clsen->classobj; + goto found; + } + } + } + } + + found: + CLASSCACHE_UNLOCK(); + return cls; +} + + +/* classcache_store ************************************************************ + + Store a loaded class. If a class of the same name has already been stored + with the same initiating loader, then the given class CLS is freed (if + possible) and the previously stored class is returned. + + IN: + initloader.......initiating loader used to load the class + (may be NULL indicating the bootstrap loader) + cls..............class object to cache + mayfree..........true if CLS may be freed in case another class is + returned + + RETURN VALUE: + cls..............everything ok, the class was stored in the cache, + other classinfo..another class with the same (initloader,name) has been + stored earlier. CLS has been freed[1] and the earlier + stored class is returned. + NULL.............an exception has been thrown. + + Note: synchronized with global tablelock + + [1]...in case MAYFREE is true + +*******************************************************************************/ + +classinfo *classcache_store(classloader_t *initloader, classinfo *cls, + bool mayfree) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; + classcache_class_entry *clsenB; + classcache_loader_entry *lden; +#ifdef CLASSCACHE_VERBOSE + char logbuffer[1024]; +#endif + + assert(cls); + assert(cls->state & CLASS_LOADED); + + CLASSCACHE_LOCK(); + +#ifdef CLASSCACHE_VERBOSE + sprintf(logbuffer,"classcache_store (%p,%d,%p=", (void*)initloader,mayfree,(void*)cls); + utf_cat_classname(logbuffer, cls->name); + strcat(logbuffer,")"); + log_println(logbuffer); +#endif + + en = classcache_new_name(cls->name); + + assert(en); + + /* iterate over all class entries */ + for (clsen = en->classes; clsen; clsen = clsen->next) { + + /* check if this entry has already been loaded by initloader */ + for (lden = clsen->loaders; lden; lden = lden->next) { + if (lden->loader == initloader) { + if (clsen->classobj != cls) { + /* A class with the same (initloader,name) pair has been stored already. */ + /* We free the given class and return the earlier one. */ +#ifdef CLASSCACHE_VERBOSE + log_println("replacing %p with earlier loaded class %p",cls,clsen->classobj); +#endif + assert(clsen->classobj); + if (mayfree) + class_free(cls); + cls = clsen->classobj; + } + goto return_success; + } + } + + /* {This entry has not been resolved with initloader} */ + + /* check if initloader is constrained to this entry */ + for (lden = clsen->constraints; lden; lden = lden->next) { + if (lden->loader == initloader) { + /* we have to use this entry. check if it has been resolved */ + if (clsen->classobj) { + /* check if is has already been resolved to another class */ + if (clsen->classobj != cls) { + /* a loading constraint is violated */ + exceptions_throw_linkageerror("loading constraint violated: ", cls); + goto return_exception; + } + + /* record initloader as initiating loader */ + clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders); + goto return_success; + } + + /* {this is the first resolution for this entry} */ + /* record initloader as initiating loader */ + clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders); + + /* maybe we can merge this entry with another one */ + for (clsenB = en->classes; clsenB; clsenB = clsenB->next) { + /* we dont want the entry that we have already */ + if (clsenB->classobj == cls) { + /* this entry has the same classobj. let's merge them */ + classcache_merge_class_entries(en,clsen,clsenB); + goto return_success; + } + } + + /* record the loaded class object */ + clsen->classobj = cls; + CLASSCACHE_COUNT(stat_classes_stored); + + /* done */ + goto return_success; + } + } + + } + + /* {There is no class entry containing initloader as initiating + * or constrained loader.} */ + + /* we look for a class entry with the same classobj we want to store */ + for (clsen = en->classes; clsen; clsen = clsen->next) { + if (clsen->classobj == cls) { + /* this entry is about the same classobj. let's use it */ + /* check if this entry has already been loaded by initloader */ + for (lden = clsen->loaders; lden; lden = lden->next) { + if (lden->loader == initloader) + goto return_success; + } + clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders); + goto return_success; + } + } + + /* create a new class entry for this class object with */ + /* initiating loader initloader */ + + clsen = NEW(classcache_class_entry); + clsen->classobj = cls; + clsen->loaders = classcache_new_loader_entry(initloader, NULL); + clsen->constraints = NULL; + + clsen->next = en->classes; + en->classes = clsen; + CLASSCACHE_COUNT(stat_classes_stored); + + return_success: +#ifdef CLASSCACHE_VERBOSE + classcache_debug_dump(stdout,cls->name); +#endif + CLASSCACHE_UNLOCK(); + return cls; + + return_exception: + CLASSCACHE_UNLOCK(); + return NULL; /* exception */ +} + +/* classcache_store_unique ***************************************************** + + Store a loaded class as loaded by the bootstrap loader. This is a wrapper + aroung classcache_store that throws an exception if a class with the same + name has already been loaded by the bootstrap loader. + + This function is used to register a few special classes during startup. + It should not be used otherwise. + + IN: + cls..............class object to cache + + RETURN VALUE: + true.............everything ok, the class was stored. + false............an exception has been thrown. + + Note: synchronized with global tablelock + +*******************************************************************************/ + +bool classcache_store_unique(classinfo *cls) +{ + classinfo *result; + + result = classcache_store(NULL,cls,false); + if (result == NULL) + return false; + + if (result != cls) { + exceptions_throw_internalerror("class already stored in the class cache"); + return false; + } + + return true; +} + +/* classcache_store_defined **************************************************** + + Store a loaded class after it has been defined. If the class has already + been defined by the same defining loader in another thread, free the given + class and returned the one which has been defined earlier. + + IN: + cls..............class object to store. classloader must be set + (classloader may be NULL, for bootloader) + + RETURN VALUE: + cls..............everything ok, the class was stored the cache, + other classinfo..the class had already been defined, CLS was freed, the + class which was defined earlier is returned, + NULL.............an exception has been thrown. + +*******************************************************************************/ + +classinfo *classcache_store_defined(classinfo *cls) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; +#ifdef CLASSCACHE_VERBOSE + char logbuffer[1024]; +#endif + + assert(cls); + assert(cls->state & CLASS_LOADED); + + CLASSCACHE_LOCK(); + +#ifdef CLASSCACHE_VERBOSE + sprintf(logbuffer,"classcache_store_defined (%p,", (void*)cls->classloader); + utf_cat_classname(logbuffer, cls->name); + strcat(logbuffer,")"); + log_println(logbuffer); +#endif + + en = classcache_new_name(cls->name); + + assert(en); + + /* iterate over all class entries */ + for (clsen = en->classes; clsen; clsen = clsen->next) { + + /* check if this class has been defined by the same classloader */ + if (clsen->classobj && clsen->classobj->classloader == cls->classloader) { + /* we found an earlier definition, delete the newer one */ + /* (if it is a different classinfo) */ + if (clsen->classobj != cls) { +#ifdef CLASSCACHE_VERBOSE + log_println("replacing %p with earlier defined class %p",cls,clsen->classobj); +#endif + class_free(cls); + cls = clsen->classobj; + } + goto return_success; + } + } + + /* create a new class entry for this class object */ + /* the list of initiating loaders is empty at this point */ + + clsen = NEW(classcache_class_entry); + clsen->classobj = cls; + clsen->loaders = NULL; + clsen->constraints = NULL; + + clsen->next = en->classes; + en->classes = clsen; + CLASSCACHE_COUNT(stat_classes_stored); + +return_success: +#ifdef CLASSCACHE_VERBOSE + classcache_debug_dump(stdout,cls->name); +#endif + CLASSCACHE_UNLOCK(); + return cls; +} + +/* classcache_find_loader ****************************************************** + + Find the class entry loaded by or constrained to a given loader + (internally used helper function) + + IN: + entry............the classcache_name_entry + loader...........the loader to look for + + RETURN VALUE: + the classcache_class_entry for the given loader, or + NULL if no entry was found + +*******************************************************************************/ + +static classcache_class_entry * classcache_find_loader( + classcache_name_entry * entry, + classloader_t * loader) +{ + classcache_class_entry *clsen; + classcache_loader_entry *lden; + + assert(entry); + + /* iterate over all class entries */ + for (clsen = entry->classes; clsen; clsen = clsen->next) { + + /* check if this entry has already been loaded by initloader */ + for (lden = clsen->loaders; lden; lden = lden->next) { + if (lden->loader == loader) + return clsen; /* found */ + } + + /* check if loader is constrained to this entry */ + for (lden = clsen->constraints; lden; lden = lden->next) { + if (lden->loader == loader) + return clsen; /* found */ + } + } + + /* not found */ + return NULL; +} + +/* classcache_free_class_entry ************************************************* + + Free the memory used by a class entry + + IN: + clsen............the classcache_class_entry to free + +*******************************************************************************/ + +static void classcache_free_class_entry(classcache_class_entry * clsen) +{ + classcache_loader_entry *lden; + classcache_loader_entry *next; + + assert(clsen); + + for (lden = clsen->loaders; lden; lden = next) { + next = lden->next; + FREE(lden, classcache_loader_entry); + } + for (lden = clsen->constraints; lden; lden = next) { + next = lden->next; + FREE(lden, classcache_loader_entry); + } + + FREE(clsen, classcache_class_entry); +} + +/* classcache_remove_class_entry *********************************************** + + Remove a classcache_class_entry from the list of possible resolution of + a name entry + (internally used helper function) + + IN: + entry............the classcache_name_entry + clsen............the classcache_class_entry to remove + +*******************************************************************************/ + +static void classcache_remove_class_entry(classcache_name_entry * entry, + classcache_class_entry * clsen) +{ + classcache_class_entry **chain; + + assert(entry); + assert(clsen); + + chain = &(entry->classes); + while (*chain) { + if (*chain == clsen) { + *chain = clsen->next; + classcache_free_class_entry(clsen); + return; + } + chain = &((*chain)->next); + } +} + +/* classcache_free_name_entry ************************************************** + + Free the memory used by a name entry + + IN: + entry............the classcache_name_entry to free + +*******************************************************************************/ + +static void classcache_free_name_entry(classcache_name_entry * entry) +{ + classcache_class_entry *clsen; + classcache_class_entry *next; + + assert(entry); + + for (clsen = entry->classes; clsen; clsen = next) { + next = clsen->next; + classcache_free_class_entry(clsen); + } + + FREE(entry, classcache_name_entry); +} + +/* classcache_free ************************************************************* + + Free the memory used by the class cache + + NOTE: + The class cache may not be used any more after this call, except + when it is reinitialized with classcache_init. + + Note: NOT synchronized! + +*******************************************************************************/ + +void classcache_free(void) +{ + u4 slot; + classcache_name_entry *entry; + classcache_name_entry *next; + + for (slot = 0; slot < hashtable_classcache.size; ++slot) { + for (entry = (classcache_name_entry *) hashtable_classcache.ptr[slot]; entry; entry = next) { + next = entry->hashlink; + classcache_free_name_entry(entry); + } + } + + MFREE(hashtable_classcache.ptr, void*, hashtable_classcache.size); + hashtable_classcache.size = 0; + hashtable_classcache.entries = 0; + hashtable_classcache.ptr = NULL; +} + +/* classcache_add_constraint *************************************************** + + Add a loading constraint + + IN: + a................first initiating loader + b................second initiating loader + classname........class name + + RETURN VALUE: + true.............everything ok, the constraint has been added, + false............an exception has been thrown. + + Note: synchronized with global tablelock + +*******************************************************************************/ + +#if defined(ENABLE_VERIFIER) +bool classcache_add_constraint(classloader_t * a, + classloader_t * b, + utf * classname) +{ + classcache_name_entry *en; + classcache_class_entry *clsenA; + classcache_class_entry *clsenB; + + assert(classname); + +#ifdef CLASSCACHE_VERBOSE + log_start(); + log_print("classcache_add_constraint(%p,%p,", (void *) a, (void *) b); + utf_fprint_printable_ascii_classname(stdout, classname); + log_print(")\n"); + log_finish(); +#endif + + /* a constraint with a == b is trivially satisfied */ + if (a == b) { + CLASSCACHE_COUNT(stat_trivial_constraints); + return true; + } + + CLASSCACHE_LOCK(); + + en = classcache_new_name(classname); + + assert(en); + CLASSCACHE_COUNT(stat_nontriv_constraints); + + /* find the entry loaded by / constrained to each loader */ + clsenA = classcache_find_loader(en, a); + clsenB = classcache_find_loader(en, b); + + if (clsenA && clsenB) { + /* { both loaders have corresponding entries } */ + CLASSCACHE_COUNT(stat_nontriv_constraints_both); + + /* if the entries are the same, the constraint is already recorded */ + if (clsenA == clsenB) + goto return_success; + + /* check if the entries can be merged */ + if (clsenA->classobj && clsenB->classobj + && clsenA->classobj != clsenB->classobj) { + /* no, the constraint is violated */ + exceptions_throw_linkageerror("loading constraint violated: ", + clsenA->classobj); + goto return_exception; + } + + /* yes, merge the entries */ + classcache_merge_class_entries(en,clsenA,clsenB); + CLASSCACHE_COUNT(stat_nontriv_constraints_merged); + } + else { + /* { at most one of the loaders has a corresponding entry } */ + + /* set clsenA to the single class entry we have */ + if (!clsenA) + clsenA = clsenB; + + if (!clsenA) { + /* { no loader has a corresponding entry } */ + CLASSCACHE_COUNT(stat_nontriv_constraints_none); + + /* create a new class entry with the constraint (a,b,en->name) */ + clsenA = NEW(classcache_class_entry); + clsenA->classobj = NULL; + clsenA->loaders = NULL; + clsenA->constraints = classcache_new_loader_entry(b, NULL); + clsenA->constraints = classcache_new_loader_entry(a, clsenA->constraints); + + clsenA->next = en->classes; + en->classes = clsenA; + } + else { + CLASSCACHE_COUNT(stat_nontriv_constraints_one); + + /* make b the loader that has no corresponding entry */ + if (clsenB) + b = a; + + /* loader b must be added to entry clsenA */ + clsenA->constraints = classcache_new_loader_entry(b, clsenA->constraints); + } + } + + return_success: + CLASSCACHE_UNLOCK(); + return true; + + return_exception: + CLASSCACHE_UNLOCK(); + return false; /* exception */ +} +#endif /* defined(ENABLE_VERIFIER) */ + +/* classcache_add_constraints_for_params *************************************** + + Add loading constraints for the parameters and return type of + the given method. + + IN: + a................first initiating loader + b................second initiating loader + m................methodinfo + + RETURN VALUE: + true.............everything ok, the constraints have been added, + false............an exception has been thrown. + + Note: synchronized with global tablelock + +*******************************************************************************/ + +#if defined(ENABLE_VERIFIER) +bool classcache_add_constraints_for_params(classloader_t * a, + classloader_t * b, + methodinfo *m) +{ + methoddesc *md; + typedesc *td; + s4 i; + + /* a constraint with a == b is trivially satisfied */ + + if (a == b) { + return true; + } + + /* get the parsed descriptor */ + + assert(m); + md = m->parseddesc; + assert(md); + + /* constrain the return type */ + + if (md->returntype.type == TYPE_ADR) { + if (!classcache_add_constraint(a, b, md->returntype.classref->name)) + return false; /* exception */ + } + + /* constrain each reference type used in the parameters */ + + td = md->paramtypes; + i = md->paramcount; + for (; i--; td++) { + if (td->type != TYPE_ADR) + continue; + + if (!classcache_add_constraint(a, b, td->classref->name)) + return false; /* exception */ + } + + /* everything ok */ + return true; +} +#endif /* defined(ENABLE_VERIFIER) */ + + +/* classcache_number_of_loaded_classes ***************************************** + + Counts the number of loaded classes and returns it. + + Note: This function assumes that the CLASSCACHE_LOCK is held by the + caller! + +*******************************************************************************/ + +static s4 classcache_number_of_loaded_classes(void) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; + s4 number; + s4 i; + + /* initialize class counter */ + + number = 0; + + for (i = 0; i < hashtable_classcache.size; i++) { + /* iterate over hashlink */ + + for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) { + /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */ + + if (en->name->text[0] == '$') + continue; + + /* iterate over classes with same name */ + + for (clsen = en->classes; clsen != NULL; clsen = clsen->next) { + /* get only loaded classes */ + + if (clsen->classobj != NULL) + number++; + } + } + } + + return number; +} + + +/* classcache_get_loaded_class_count ******************************************* + + Counts the number of loaded classes and returns it. + +*******************************************************************************/ + +s4 classcache_get_loaded_class_count(void) +{ + s4 count; + + CLASSCACHE_LOCK(); + + count = classcache_number_of_loaded_classes(); + + CLASSCACHE_UNLOCK(); + + return count; +} + + +/* classcache_get_loaded_classes *********************************************** + + Returns an array of all loaded classes as array. The array is + allocaed on the Java heap. + +*******************************************************************************/ + +#if defined(ENABLE_JVMTI) +void classcache_get_loaded_classes(s4 *class_count_ptr, + classinfo ***classes_ptr) +{ + classinfo **classes; + s4 class_count; + classcache_name_entry *en; + classcache_class_entry *clsen; + s4 i; + s4 j; + + CLASSCACHE_LOCK(); + + /* get the number of loaded classes and allocate the array */ + + class_count = classcache_number_of_loaded_classes(); + + classes = GCMNEW(classinfo*, class_count); + + /* look in every slot of the hashtable */ + + for (i = 0, j = 0; i < hashtable_classcache.size; i++) { + /* iterate over hashlink */ + + for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) { + /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */ + + if (en->name->text[0] == '$') + continue; + + /* iterate over classes with same name */ + + for (clsen = en->classes; clsen != NULL; clsen = clsen->next) { + /* get only loaded classes */ + + if (clsen->classobj != NULL) { + classes[j] = clsen->classobj; + j++; + } + } + } + } + + /* pass the return values */ + + *class_count_ptr = class_count; + *classes_ptr = classes; + + CLASSCACHE_UNLOCK(); +} +#endif /* defined(ENABLE_JVMTI) */ + + +/* classcache_foreach_loaded_class ********************************************* + + Calls the given function for each loaded class. + +*******************************************************************************/ + +void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func, + void *data) +{ + classcache_name_entry *en; + classcache_class_entry *clsen; + s4 i; + + CLASSCACHE_LOCK(); + + /* look in every slot of the hashtable */ + + for (i = 0; i < hashtable_classcache.size; i++) { + /* iterate over hashlink */ + + for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) { + /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */ + + if (en->name->text[0] == '$') + continue; + + /* iterate over classes with same name */ + + for (clsen = en->classes; clsen != NULL; clsen = clsen->next) { + /* get only loaded classes */ + + if (clsen->classobj != NULL) { + (*func)(clsen->classobj, data); + } + } + } + } + + CLASSCACHE_UNLOCK(); +} + + +/*============================================================================*/ +/* DEBUG DUMPS */ +/*============================================================================*/ + +/* classcache_debug_dump ******************************************************* + + Print the contents of the loaded class cache to a stream + + IN: + file.............output stream + only.............if != NULL, only print entries for this name + (Currently we print also the rest of the hash chain to + get a feel for the average length of hash chains.) + + Note: synchronized with global tablelock + +*******************************************************************************/ + +#ifndef NDEBUG +void classcache_debug_dump(FILE * file,utf *only) +{ + classcache_name_entry *c; + classcache_class_entry *clsen; + classcache_loader_entry *lden; + u4 slot; + + CLASSCACHE_LOCK(); + + log_println("=== [loaded class cache] ====================================="); + log_println("hash size : %d", (int) hashtable_classcache.size); + log_println("hash entries: %d", (int) hashtable_classcache.entries); + log_println(""); + + if (only) { + c = classcache_lookup_name(only); + slot = 0; /* avoid compiler warning */ + goto dump_it; + } + + for (slot = 0; slot < hashtable_classcache.size; ++slot) { + c = (classcache_name_entry *) hashtable_classcache.ptr[slot]; + +dump_it: + for (; c; c = c->hashlink) { + utf_fprint_printable_ascii_classname(file, c->name); + fprintf(file, "\n"); + + /* iterate over all class entries */ + for (clsen = c->classes; clsen; clsen = clsen->next) { + if (clsen->classobj) { + log_println(" loaded %p", (void *) clsen->classobj); + } + else { + log_println(" unresolved"); + } + + log_start(); + log_print(" loaders: "); + for (lden = clsen->loaders; lden; lden = lden->next) { + log_print("<%p> %p ", (void *) lden, (void *) lden->loader); + } + log_finish(); + + log_start(); + log_print(" constraints: "); + for (lden = clsen->constraints; lden; lden = lden->next) { + log_print("<%p> %p ", (void *) lden, (void *) lden->loader); + } + log_finish(); + } + } + + if (only) + break; + } + fprintf(file, "\n==============================================================\n\n"); + + CLASSCACHE_UNLOCK(); +} +#endif /* NDEBUG */ + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/classcache.h b/src/vm/classcache.h new file mode 100644 index 000000000..44ac5d80a --- /dev/null +++ b/src/vm/classcache.h @@ -0,0 +1,177 @@ +/* src/vm/classcache.h - loaded class cache and loading constraints + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _CLASSCACHE_H +#define _CLASSCACHE_H + +#include "config.h" + +#include "vm/types.h" + +#include /* for FILE */ + +#include "toolbox/hashtable.h" + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/references.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* forward declarations *******************************************************/ + +typedef struct classcache_name_entry classcache_name_entry; +typedef struct classcache_class_entry classcache_class_entry; +typedef struct classcache_loader_entry classcache_loader_entry; + +/* global variables ***********************************************************/ + +extern hashtable hashtable_classcache; + + +/* structs ********************************************************************/ + +/*----------------------------------------------------------------------------*/ +/* The Loaded Class Cache */ +/* */ +/* The loaded class cache is implemented as a two-level data structure. */ +/* */ +/* The first level is a hash table indexed by class names. For each class */ +/* name in the cache there is a classcache_name_entry, which collects all */ +/* information about classes with this class name. */ +/* */ +/* Second level: For each classcache_name_entry there is a list of */ +/* classcache_class_entry:s representing the possible different resolutions */ +/* of the class name. */ +/* */ +/* A classcache_class_entry records the following: */ +/* */ +/* - the loaded class object, if this entry has been resolved, otherwise NULL */ +/* - the list of initiating loaders which have resolved the class name to */ +/* this class object */ +/* - the list of initiating loaders which are constrained to resolve this */ +/* class name to this class object in the future */ +/* */ +/* The classcache_class_entry:s approximate the equivalence classes created */ +/* by the loading constraints and the equivalence of loaded classes. */ +/* */ +/* When a loading constraint (loaderA,loaderB,NAME) is added, then the */ +/* classcache_class_entry:s for NAME containing loaderA and loaderB resp. */ +/* must be merged into one entry. If this is impossible, because the entries */ +/* have already been resolved to different class objects, then the constraint */ +/* is violated and an expception must be thrown. */ +/*----------------------------------------------------------------------------*/ + + +/* classcache_name_entry + * + * For each classname a classcache_name_entry struct is created. + */ + +struct classcache_name_entry +{ + utf *name; /* class name */ + classcache_name_entry *hashlink; /* link for external chaining */ + classcache_class_entry *classes; /* equivalence classes for this name*/ +}; + +struct classcache_class_entry +{ + classinfo *classobj; /* the loaded class object, or NULL */ + classcache_loader_entry *loaders; + classcache_loader_entry *constraints; + classcache_class_entry *next; /* next class entry for same name */ +}; + +struct classcache_loader_entry +{ + classloader_t *loader; /* class loader object */ + classcache_loader_entry *next; /* next loader entry in the list */ +}; + + +/* callback function type for classcache_foreach_loaded_class */ + +typedef void (*classcache_foreach_functionptr_t)(classinfo *, void *); + + +/* function prototypes ********************************************************/ + +/* initialize the loaded class cache */ +bool classcache_init(void); +void classcache_free(void); + +classinfo * classcache_lookup(classloader_t *initloader,utf *classname); +classinfo * classcache_lookup_defined(classloader_t *defloader,utf *classname); +classinfo * classcache_lookup_defined_or_initiated(classloader_t *loader,utf *classname); + +bool classcache_store_unique(classinfo *cls); +classinfo * classcache_store(classloader_t *initloader,classinfo *cls,bool mayfree); +classinfo * classcache_store_defined(classinfo *cls); + +#if defined(ENABLE_VERIFIER) +bool classcache_add_constraint(classloader_t *a,classloader_t *b,utf *classname); +bool classcache_add_constraints_for_params(classloader_t *a,classloader_t *b, + methodinfo *m); +#endif + +s4 classcache_get_loaded_class_count(void); + +void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func, + void *data); + +#if defined(ENABLE_JVMTI) +void classcache_get_loaded_classes(s4 *class_count_ptr, + classinfo ***classes_ptr); +#endif + +#ifndef NDEBUG +void classcache_debug_dump(FILE *file,utf *only); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _CLASSCACHE_H */ + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ + diff --git a/src/vm/descriptor.c b/src/vm/descriptor.c new file mode 100644 index 000000000..235154e42 --- /dev/null +++ b/src/vm/descriptor.c @@ -0,0 +1,1398 @@ +/* src/vm/descriptor.c - checking and parsing of field / method descriptors + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "md-abi.h" + +#include "mm/memory.h" + +#include "vm/descriptor.h" +#include "vm/exceptions.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/abi.h" + + +/* constants (private to descriptor.c) ****************************************/ + +/* initial number of entries for the classrefhash of a descriptor_pool */ +/* (currently the hash is never grown!) */ +#define CLASSREFHASH_INIT_SIZE 64 + +/* initial number of entries for the descriptorhash of a descriptor_pool */ +/* (currently the hash is never grown!) */ +#define DESCRIPTORHASH_INIT_SIZE 128 + +/* data structures (private to descriptor.c) **********************************/ + +typedef struct classref_hash_entry classref_hash_entry; +typedef struct descriptor_hash_entry descriptor_hash_entry; + +/* entry struct for the classrefhash of descriptor_pool */ +struct classref_hash_entry { + classref_hash_entry *hashlink; /* for hash chaining */ + utf *name; /* name of the class refered to */ + u2 index; /* index into classref table */ +}; + +/* entry struct for the descriptorhash of descriptor_pool */ +struct descriptor_hash_entry { + descriptor_hash_entry *hashlink; + utf *desc; + parseddesc_t parseddesc; + s2 paramslots; /* number of params, LONG/DOUBLE counted as 2 */ +}; + + +/****************************************************************************/ +/* MACROS FOR DESCRIPTOR PARSING (private to descriptor.c) */ +/****************************************************************************/ + +/* SKIP_FIELDDESCRIPTOR: + * utf_ptr must point to the first character of a field descriptor. + * After the macro call utf_ptr points to the first character after + * the field descriptor. + * + * CAUTION: This macro does not check for an unexpected end of the + * descriptor. Better use SKIP_FIELDDESCRIPTOR_SAFE. + */ +#define SKIP_FIELDDESCRIPTOR(utf_ptr) \ + do { while (*(utf_ptr)=='[') (utf_ptr)++; \ + if (*(utf_ptr)++=='L') \ + while(*(utf_ptr)++ != ';') /* skip */; } while(0) + +/* SKIP_FIELDDESCRIPTOR_SAFE: + * utf_ptr must point to the first character of a field descriptor. + * After the macro call utf_ptr points to the first character after + * the field descriptor. + * + * Input: + * utf_ptr....points to first char of descriptor + * end_ptr....points to first char after the end of the string + * errorflag..must be initialized (to false) by the caller! + * Output: + * utf_ptr....points to first char after the descriptor + * errorflag..set to true if the string ended unexpectedly + */ +#define SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr,end_ptr,errorflag) \ + do { while ((utf_ptr) != (end_ptr) && *(utf_ptr)=='[') (utf_ptr)++; \ + if ((utf_ptr) == (end_ptr)) \ + (errorflag) = true; \ + else \ + if (*(utf_ptr)++=='L') { \ + while((utf_ptr) != (end_ptr) && *(utf_ptr)++ != ';') \ + /* skip */; \ + if ((utf_ptr)[-1] != ';') \ + (errorflag) = true; }} while(0) + + +/****************************************************************************/ +/* DEBUG HELPERS */ +/****************************************************************************/ + +/*#define DESCRIPTOR_VERBOSE*/ + +/****************************************************************************/ +/* FUNCTIONS */ +/****************************************************************************/ + +/* descriptor_to_basic_type **************************************************** + + Return the basic type to use for a value with this descriptor. + + IN: + utf..............descriptor utf string + + OUT: + A TYPE_* constant. + + PRECONDITIONS: + This function assumes that the descriptor has passed + descriptor_pool_add checks and that it does not start with '('. + +*******************************************************************************/ + +int descriptor_to_basic_type(utf *descriptor) +{ + assert(descriptor->blength >= 1); + + switch (descriptor->text[0]) { + case 'Z': + case 'B': + case 'C': + case 'S': + case 'I': + return TYPE_INT; + + case 'J': + return TYPE_LNG; + + case 'F': + return TYPE_FLT; + + case 'D': + return TYPE_DBL; + + case 'L': + case '[': + return TYPE_ADR; + + default: + vm_abort("descriptor_to_basic_type: invalid type %c", + descriptor->text[0]); + } + + /* keep the compiler happy */ + + return 0; +} + + +/* descriptor_typesize ********************************************************* + + Return the size in bytes needed for the given type. + + IN: + td..............typedesc describing the type + + OUT: + The number of bytes + +*******************************************************************************/ + +int descriptor_typesize(typedesc *td) +{ + assert(td); + + switch (td->type) { + case TYPE_INT: + case TYPE_FLT: + return 4; + + case TYPE_LNG: + case TYPE_DBL: + return 8; + + case TYPE_ADR: + return SIZEOF_VOID_P; + + default: + vm_abort("descriptor_typesize: invalid type %d", td->type); + } + + /* keep the compiler happy */ + + return 0; +} + + +/* name_from_descriptor ******************************************************** + + Return the class name indicated by the given descriptor + (Internally used helper function) + + IN: + c................class containing the descriptor + utf_ptr..........first character of descriptor + end_ptr..........first character after the end of the string + mode.............a combination (binary or) of the following flags: + + (Flags marked with * are the default settings.) + + How to handle "V" descriptors: + + * DESCRIPTOR_VOID.....handle it like other primitive types + DESCRIPTOR_NOVOID...treat it as an error + + How to deal with extra characters after the end of the + descriptor: + + * DESCRIPTOR_NOCHECKEND...ignore (useful for parameter lists) + DESCRIPTOR_CHECKEND.....treat them as an error + + OUT: + *next............if non-NULL, *next is set to the first character after + the descriptor. (Undefined if an error occurs.) + *name............set to the utf name of the class + + RETURN VALUE: + true.............descriptor parsed successfully + false............an exception has been thrown + +*******************************************************************************/ + +#define DESCRIPTOR_VOID 0 /* default */ +#define DESCRIPTOR_NOVOID 0x0040 +#define DESCRIPTOR_NOCHECKEND 0 /* default */ +#define DESCRIPTOR_CHECKEND 0x1000 + +static bool +name_from_descriptor(classinfo *c, + char *utf_ptr, char *end_ptr, + char **next, int mode, utf **name) +{ + char *start = utf_ptr; + bool error = false; + + assert(c); + assert(utf_ptr); + assert(end_ptr); + assert(name); + + *name = NULL; + SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr, end_ptr, error); + + if (mode & DESCRIPTOR_CHECKEND) + error |= (utf_ptr != end_ptr); + + if (!error) { + if (next) *next = utf_ptr; + + switch (*start) { + case 'V': + if (mode & DESCRIPTOR_NOVOID) + break; + /* FALLTHROUGH! */ + case 'I': + case 'J': + case 'F': + case 'D': + case 'B': + case 'C': + case 'S': + case 'Z': + return true; + + case 'L': + start++; + utf_ptr--; + /* FALLTHROUGH! */ + case '[': + *name = utf_new(start, utf_ptr - start); + return true; + } + } + + exceptions_throw_classformaterror(c, "Invalid descriptor"); + return false; +} + + +/* descriptor_to_typedesc ****************************************************** + + Parse the given type descriptor and fill a typedesc struct + (Internally used helper function) + + IN: + pool.............the descriptor pool + utf_ptr..........points to first character of type descriptor + end_pos..........points after last character of the whole descriptor + + OUT: + *next............set to next character after type descriptor + *d...............filled with parsed information + + RETURN VALUE: + true.............parsing succeeded + false............an exception has been thrown + +*******************************************************************************/ + +static bool +descriptor_to_typedesc(descriptor_pool *pool, char *utf_ptr, char *end_pos, + char **next, typedesc *td) +{ + utf *name; + + if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, next, 0, &name)) + return false; + + if (name) { + /* a reference type */ + td->type = TYPE_ADR; + td->primitivetype = TYPE_ADR; + td->arraydim = 0; + for (utf_ptr = name->text; *utf_ptr == '['; ++utf_ptr) + td->arraydim++; + td->classref = descriptor_pool_lookup_classref(pool, name); + + } else { + /* a primitive type */ + switch (*utf_ptr) { + case 'B': + td->primitivetype = PRIMITIVETYPE_BYTE; + td->type = TYPE_INT; + break; + case 'C': + td->primitivetype = PRIMITIVETYPE_CHAR; + td->type = TYPE_INT; + break; + case 'S': + td->primitivetype = PRIMITIVETYPE_SHORT; + td->type = TYPE_INT; + break; + case 'Z': + td->primitivetype = PRIMITIVETYPE_BOOLEAN; + td->type = TYPE_INT; + break; + case 'I': + td->primitivetype = PRIMITIVETYPE_INT; + td->type = TYPE_INT; + break; + case 'D': + td->primitivetype = PRIMITIVETYPE_DOUBLE; + td->type = TYPE_DBL; + break; + case 'F': + td->primitivetype = PRIMITIVETYPE_FLOAT; + td->type = TYPE_FLT; + break; + case 'J': + td->primitivetype = PRIMITIVETYPE_LONG; + td->type = TYPE_LNG; + break; + case 'V': + td->primitivetype = PRIMITIVETYPE_VOID; + td->type = TYPE_VOID; + break; + default: + assert(false); + } + + td->arraydim = 0; + td->classref = NULL; + } + + return true; +} + + +/* descriptor_pool_new ********************************************************* + + Allocate a new descriptor_pool + + IN: + referer..........class for which to create the pool + + RETURN VALUE: + a pointer to the new descriptor_pool + +*******************************************************************************/ + +descriptor_pool * +descriptor_pool_new(classinfo *referer) +{ + descriptor_pool *pool; + u4 hashsize; + u4 slot; + + pool = DNEW(descriptor_pool); + assert(pool); + + pool->referer = referer; + pool->fieldcount = 0; + pool->methodcount = 0; + pool->paramcount = 0; + pool->descriptorsize = 0; + pool->descriptors = NULL; + pool->descriptors_next = NULL; + pool->classrefs = NULL; + pool->descriptor_kind = NULL; + pool->descriptor_kind_next = NULL; + + hashsize = CLASSREFHASH_INIT_SIZE; + pool->classrefhash.size = hashsize; + pool->classrefhash.entries = 0; + pool->classrefhash.ptr = DMNEW(void*, hashsize); + for (slot=0; slotclassrefhash.ptr[slot] = NULL; + + hashsize = DESCRIPTORHASH_INIT_SIZE; + pool->descriptorhash.size = hashsize; + pool->descriptorhash.entries = 0; + pool->descriptorhash.ptr = DMNEW(void*, hashsize); + for (slot=0; slotdescriptorhash.ptr[slot] = NULL; + + return pool; +} + + +/* descriptor_pool_add_class *************************************************** + + Add the given class reference to the pool + + IN: + pool.............the descriptor_pool + name.............the class reference to add + + RETURN VALUE: + true.............reference has been added + false............an exception has been thrown + +*******************************************************************************/ + +bool +descriptor_pool_add_class(descriptor_pool *pool, utf *name) +{ + u4 key,slot; + classref_hash_entry *c; + + assert(pool); + assert(name); + +#ifdef DESCRIPTOR_VERBOSE + fprintf(stderr,"descriptor_pool_add_class(%p,",(void*)pool); + utf_fprint_printable_ascii(stderr,name);fprintf(stderr,")\n"); +#endif + + /* find a place in the hashtable */ + + key = utf_hashkey(name->text, name->blength); + slot = key & (pool->classrefhash.size - 1); + c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; + + while (c) { + if (c->name == name) + return true; /* already stored */ + c = c->hashlink; + } + + /* check if the name is a valid classname */ + + if (!is_valid_name(name->text,UTF_END(name))) { + exceptions_throw_classformaterror(pool->referer, "Invalid class name"); + return false; /* exception */ + } + + /* XXX check maximum array dimension */ + + c = DNEW(classref_hash_entry); + c->name = name; + c->index = pool->classrefhash.entries++; + c->hashlink = (classref_hash_entry *) pool->classrefhash.ptr[slot]; + pool->classrefhash.ptr[slot] = c; + + return true; +} + + +/* descriptor_pool_add ********************************************************* + + Check the given descriptor and add it to the pool + + IN: + pool.............the descriptor_pool + desc.............the descriptor to add. Maybe a field or method desc. + + OUT: + *paramslots......if non-NULL, set to the number of parameters. + LONG and DOUBLE are counted twice + + RETURN VALUE: + true.............descriptor has been added + false............an exception has been thrown + +*******************************************************************************/ + +bool +descriptor_pool_add(descriptor_pool *pool, utf *desc, int *paramslots) +{ + u4 key,slot; + descriptor_hash_entry *d; + char *utf_ptr; + char *end_pos; + utf *name; + s4 argcount = 0; + +#ifdef DESCRIPTOR_VERBOSE + fprintf(stderr,"descriptor_pool_add(%p,",(void*)pool); + utf_fprint_printable_ascii(stderr,desc);fprintf(stderr,")\n"); +#endif + + assert(pool); + assert(desc); + + /* find a place in the hashtable */ + + key = utf_hashkey(desc->text, desc->blength); + slot = key & (pool->descriptorhash.size - 1); + d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; + + /* Save all method descriptors in the hashtable, since the parsed */ + /* descriptor may vary between differenf methods (static vs. non-static). */ + + utf_ptr = desc->text; + + if (*utf_ptr != '(') { + while (d) { + if (d->desc == desc) { + if (paramslots) + *paramslots = d->paramslots; + return true; /* already stored */ + } + d = d->hashlink; + } + } + + /* add the descriptor to the pool */ + + d = DNEW(descriptor_hash_entry); + d->desc = desc; + d->parseddesc.any = NULL; + d->hashlink = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; + pool->descriptorhash.ptr[slot] = d; + + /* now check the descriptor */ + + end_pos = UTF_END(desc); + + if (*utf_ptr == '(') { + /* a method descriptor */ + + pool->methodcount++; + utf_ptr++; + + /* check arguments */ + + while ((utf_ptr != end_pos) && (*utf_ptr != ')')) { + pool->paramcount++; + + /* We cannot count the `this' argument here because + * we don't know if the method is static. */ + + if (*utf_ptr == 'J' || *utf_ptr == 'D') + argcount += 2; + else + argcount++; + + if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, &utf_ptr, + DESCRIPTOR_NOVOID, &name)) + return false; + + if (name) + if (!descriptor_pool_add_class(pool, name)) + return false; + } + + if (utf_ptr == end_pos) { + exceptions_throw_classformaterror(pool->referer, + "Missing ')' in method descriptor"); + return false; + } + + utf_ptr++; /* skip ')' */ + + if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL, + DESCRIPTOR_CHECKEND, &name)) + return false; + + if (name) + if (!descriptor_pool_add_class(pool,name)) + return false; + + if (argcount > 255) { + exceptions_throw_classformaterror(pool->referer, + "Too many arguments in signature"); + return false; + } + + } else { + /* a field descriptor */ + + pool->fieldcount++; + + if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL, + DESCRIPTOR_NOVOID | DESCRIPTOR_CHECKEND, + &name)) + return false; + + if (name) + if (!descriptor_pool_add_class(pool,name)) + return false; + } + + d->paramslots = argcount; + + if (paramslots) + *paramslots = argcount; + + return true; +} + + +/* descriptor_pool_create_classrefs ******************************************** + + Create a table containing all the classrefs which were added to the pool + + IN: + pool.............the descriptor_pool + + OUT: + *count...........if count is non-NULL, this is set to the number + of classrefs in the table + + RETURN VALUE: + a pointer to the constant_classref table + +*******************************************************************************/ + +constant_classref * +descriptor_pool_create_classrefs(descriptor_pool *pool, s4 *count) +{ + u4 nclasses; + u4 slot; + classref_hash_entry *c; + constant_classref *ref; + + assert(pool); + + nclasses = pool->classrefhash.entries; + pool->classrefs = MNEW(constant_classref,nclasses); + + /* fill the constant_classref structs */ + + for (slot = 0; slot < pool->classrefhash.size; ++slot) { + c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; + while (c) { + ref = pool->classrefs + c->index; + CLASSREF_INIT(*ref, pool->referer, c->name); + c = c->hashlink; + } + } + + if (count) + *count = nclasses; + + return pool->classrefs; +} + + +/* descriptor_pool_lookup_classref ********************************************* + + Return the constant_classref for the given class name + + IN: + pool.............the descriptor_pool + classname........name of the class to look up + + RETURN VALUE: + a pointer to the constant_classref, or + NULL if an exception has been thrown + +*******************************************************************************/ + +constant_classref * +descriptor_pool_lookup_classref(descriptor_pool *pool, utf *classname) +{ + u4 key,slot; + classref_hash_entry *c; + + assert(pool); + assert(pool->classrefs); + assert(classname); + + key = utf_hashkey(classname->text, classname->blength); + slot = key & (pool->classrefhash.size - 1); + c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; + + while (c) { + if (c->name == classname) + return pool->classrefs + c->index; + c = c->hashlink; + } + + exceptions_throw_internalerror("Class reference not found in descriptor pool"); + return NULL; +} + + +/* descriptor_pool_alloc_parsed_descriptors ************************************ + + Allocate space for the parsed descriptors + + IN: + pool.............the descriptor_pool + + NOTE: + This function must be called after all descriptors have been added + with descriptor_pool_add. + +*******************************************************************************/ + +void +descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool) +{ + u4 size; + + assert(pool); + + /* TWISTI: paramcount + 1: we don't know if the method is static or */ + /* not, i have no better solution yet. */ + + size = + pool->fieldcount * sizeof(typedesc) + + pool->methodcount * (sizeof(methoddesc) - sizeof(typedesc)) + + pool->paramcount * sizeof(typedesc) + + pool->methodcount * sizeof(typedesc); /* possible `this' pointer */ + + pool->descriptorsize = size; + if (size) { + pool->descriptors = MNEW(u1, size); + pool->descriptors_next = pool->descriptors; + } + + size = pool->fieldcount + pool->methodcount; + if (size) { + pool->descriptor_kind = DMNEW(u1, size); + pool->descriptor_kind_next = pool->descriptor_kind; + } +} + + +/* descriptor_pool_parse_field_descriptor ************************************** + + Parse the given field descriptor + + IN: + pool.............the descriptor_pool + desc.............the field descriptor + + RETURN VALUE: + a pointer to the parsed field descriptor, or + NULL if an exception has been thrown + + NOTE: + descriptor_pool_alloc_parsed_descriptors must be called (once) + before this function is used. + +*******************************************************************************/ + +typedesc * +descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc) +{ + u4 key,slot; + descriptor_hash_entry *d; + typedesc *td; + + assert(pool); + assert(pool->descriptors); + assert(pool->descriptors_next); + + /* lookup the descriptor in the hashtable */ + + key = utf_hashkey(desc->text, desc->blength); + slot = key & (pool->descriptorhash.size - 1); + d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; + + while (d) { + if (d->desc == desc) { + /* found */ + if (d->parseddesc.fd) + return d->parseddesc.fd; + break; + } + d = d->hashlink; + } + + assert(d); + + if (desc->text[0] == '(') { + exceptions_throw_classformaterror(pool->referer, + "Method descriptor used in field reference"); + return NULL; + } + + td = (typedesc *) pool->descriptors_next; + pool->descriptors_next += sizeof(typedesc); + + if (!descriptor_to_typedesc(pool, desc->text, UTF_END(desc), NULL, td)) + return NULL; + + *(pool->descriptor_kind_next++) = 'f'; + + d->parseddesc.fd = td; + + return td; +} + + +/* descriptor_pool_parse_method_descriptor ************************************* + + Parse the given method descriptor + + IN: + pool.............the descriptor_pool + desc.............the method descriptor + mflags...........the method flags + thisclass........classref to the class containing the method. + This is ignored if mflags contains ACC_STATIC. + The classref is stored for inserting the 'this' argument. + + RETURN VALUE: + a pointer to the parsed method descriptor, or + NULL if an exception has been thrown + + NOTE: + descriptor_pool_alloc_parsed_descriptors must be called + (once) before this function is used. + +*******************************************************************************/ + +methoddesc * +descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc, + s4 mflags,constant_classref *thisclass) +{ + u4 key, slot; + descriptor_hash_entry *d; + methoddesc *md; + typedesc *td; + char *utf_ptr; + char *end_pos; + s2 paramcount = 0; + s2 paramslots = 0; + +#ifdef DESCRIPTOR_VERBOSE + fprintf(stderr,"descriptor_pool_parse_method_descriptor(%p,%d,%p,", + (void*)pool,(int)mflags,(void*)thisclass); + utf_fprint_printable_ascii(stderr,desc); fprintf(stderr,")\n"); +#endif + + assert(pool); + assert(pool->descriptors); + assert(pool->descriptors_next); + + /* check that it is a method descriptor */ + + if (desc->text[0] != '(') { + exceptions_throw_classformaterror(pool->referer, + "Field descriptor used in method reference"); + return NULL; + } + + /* lookup the descriptor in the hashtable */ + + key = utf_hashkey(desc->text, desc->blength); + slot = key & (pool->descriptorhash.size - 1); + d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; + + /* find an un-parsed descriptor */ + + while (d) { + if (d->desc == desc) + if (!d->parseddesc.md) + break; + d = d->hashlink; + } + + assert(d); + + md = (methoddesc *) pool->descriptors_next; + pool->descriptors_next += sizeof(methoddesc) - sizeof(typedesc); + + utf_ptr = desc->text + 1; /* skip '(' */ + end_pos = UTF_END(desc); + + td = md->paramtypes; + + /* count the `this' pointer */ + + if ((mflags != ACC_UNDEF) && !(mflags & ACC_STATIC)) { + td->type = TYPE_ADR; + td->primitivetype = TYPE_ADR; + td->arraydim = 0; + td->classref = thisclass; + + td++; + pool->descriptors_next += sizeof(typedesc); + paramcount++; + paramslots++; + } + + while (*utf_ptr != ')') { + /* parse a parameter type */ + + if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, &utf_ptr, td)) + return NULL; + + if (IS_2_WORD_TYPE(td->type)) + paramslots++; + + td++; + pool->descriptors_next += sizeof(typedesc); + paramcount++; + paramslots++; + } + utf_ptr++; /* skip ')' */ + + /* Skip possible `this' pointer in paramtypes array to allow a possible */ + /* memory move later in parse. */ + /* We store the thisclass reference, so we can later correctly fill in */ + /* the parameter slot of the 'this' argument. */ + + if (mflags == ACC_UNDEF) { + td->classref = thisclass; + td++; + pool->descriptors_next += sizeof(typedesc); + } + + /* parse return type */ + + if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, NULL, + &(md->returntype))) + return NULL; + + md->paramcount = paramcount; + md->paramslots = paramslots; + + /* If mflags != ACC_UNDEF we parse a real loaded method, so do + param prealloc. Otherwise we do this in stack analysis. */ + + if (mflags != ACC_UNDEF) { + if (md->paramcount > 0) { + /* allocate memory for params */ + + md->params = MNEW(paramdesc, md->paramcount); + } + else { + md->params = METHODDESC_NOPARAMS; + } + + /* fill the paramdesc */ + /* md_param_alloc has to be called if md->paramcount == 0, + too, so it can make the reservation for the Linkage Area, + Return Register... */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) +# endif + { + /* As builtin-functions are native functions, we have + to pre-allocate for the native ABI. */ + + if (mflags & ACC_METHOD_BUILTIN) + md_param_alloc_native(md); + else + md_param_alloc(md); + } +#endif + } + else { + /* params will be allocated later by + descriptor_params_from_paramtypes if necessary */ + + md->params = NULL; + } + + *(pool->descriptor_kind_next++) = 'm'; + + d->parseddesc.md = md; + + return md; +} + +/* descriptor_params_from_paramtypes ******************************************* + + Create the paramdescs for a method descriptor. This function is called + when we know whether the method is static or not. This function may only + be called once for each methoddesc, and only if md->params == NULL. + + IN: + md...............the parsed method descriptor + md->params MUST be NULL. + mflags...........the ACC_* access flags of the method. Only the + ACC_STATIC bit is checked. + The value ACC_UNDEF is NOT allowed. + + RETURN VALUE: + true.............the paramdescs were created successfully + false............an exception has been thrown + + POSTCONDITION: + md->parms != NULL + +*******************************************************************************/ + +bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags) +{ + typedesc *td; + + assert(md); + assert(md->params == NULL); + assert(mflags != ACC_UNDEF); + + td = md->paramtypes; + + /* check for `this' pointer */ + + if (!(mflags & ACC_STATIC)) { + constant_classref *thisclass; + + /* fetch class reference from reserved param slot */ + thisclass = td[md->paramcount].classref; + assert(thisclass); + + if (md->paramcount > 0) { + /* shift param types by 1 argument */ + MMOVE(td + 1, td, typedesc, md->paramcount); + } + + /* fill in first argument `this' */ + + td->type = TYPE_ADR; + td->primitivetype = TYPE_ADR; + td->arraydim = 0; + td->classref = thisclass; + + md->paramcount++; + md->paramslots++; + } + + /* if the method has params, process them */ + + if (md->paramcount > 0) { + /* allocate memory for params */ + + md->params = MNEW(paramdesc, md->paramcount); + + } else { + md->params = METHODDESC_NOPARAMS; + } + + /* fill the paramdesc */ + /* md_param_alloc has to be called if md->paramcount == 0, too, so + it can make the reservation for the Linkage Area, Return + Register.. */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) +# endif + { + /* As builtin-functions are native functions, we have to + pre-allocate for the native ABI. */ + + if (mflags & ACC_METHOD_BUILTIN) + md_param_alloc_native(md); + else + md_param_alloc(md); + } +#endif + + return true; +} + + +/* descriptor_pool_get_parsed_descriptors ************************************** + + Return a pointer to the block of parsed descriptors + + IN: + pool.............the descriptor_pool + + OUT: + *size............if size is non-NULL, this is set to the size of the + parsed descriptor block (in u1) + + RETURN VALUE: + a pointer to the block of parsed descriptors + + NOTE: + descriptor_pool_alloc_parsed_descriptors must be called (once) + before this function is used. + +*******************************************************************************/ + +void * +descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size) +{ + assert(pool); + assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors); + + if (size) + *size = pool->descriptorsize; + + return pool->descriptors; +} + + +/* descriptor_pool_get_sizes *************************************************** + + Get the sizes of the class reference table and the parsed descriptors + + IN: + pool.............the descriptor_pool + + OUT: + *classrefsize....set to size of the class reference table + *descsize........set to size of the parsed descriptors + + NOTE: + This function may only be called after both + descriptor_pool_create_classrefs, and + descriptor_pool_alloc_parsed_descriptors + have been called. + +*******************************************************************************/ + +void +descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize, u4 *descsize) +{ + assert(pool); + assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors); + assert(pool->classrefs); + assert(classrefsize); + assert(descsize); + + *classrefsize = pool->classrefhash.entries * sizeof(constant_classref); + *descsize = pool->descriptorsize; +} + + +/****************************************************************************/ +/* DEBUG HELPERS */ +/****************************************************************************/ + +#ifndef NDEBUG +/* descriptor_debug_print_typedesc ********************************************* + + Print the given typedesc to the given stream + + IN: + file.............stream to print to + d................the parsed descriptor + +*******************************************************************************/ + +void +descriptor_debug_print_typedesc(FILE *file,typedesc *d) +{ + int ch; + + if (!d) { + fprintf(file,"(typedesc *)NULL"); + return; + } + + if (d->type == TYPE_ADR) { + if (d->classref) + utf_fprint_printable_ascii(file,d->classref->name); + else + fprintf(file,""); + } + else { + switch (d->primitivetype) { + case PRIMITIVETYPE_INT : ch='I'; break; + case PRIMITIVETYPE_CHAR : ch='C'; break; + case PRIMITIVETYPE_BYTE : ch='B'; break; + case PRIMITIVETYPE_SHORT : ch='S'; break; + case PRIMITIVETYPE_BOOLEAN: ch='Z'; break; + case PRIMITIVETYPE_LONG : ch='J'; break; + case PRIMITIVETYPE_FLOAT : ch='F'; break; + case PRIMITIVETYPE_DOUBLE : ch='D'; break; + case PRIMITIVETYPE_VOID : ch='V'; break; + default : ch='!'; + } + fputc(ch,file); + } + if (d->arraydim) + fprintf(file,"[%d]",d->arraydim); +} + +/* descriptor_debug_print_paramdesc ******************************************** + + Print the given paramdesc to the given stream + + IN: + file.............stream to print to + d................the parameter descriptor + +*******************************************************************************/ + +void +descriptor_debug_print_paramdesc(FILE *file,paramdesc *d) +{ + if (!d) { + fprintf(file,"(paramdesc *)NULL"); + return; + } + + if (d->inmemory) { + fprintf(file,"",d->regoff); + } + else { + fprintf(file,"",d->regoff); + } +} + +/* descriptor_debug_print_methoddesc ******************************************* + + Print the given methoddesc to the given stream + + IN: + file.............stream to print to + d................the parsed descriptor + +*******************************************************************************/ + +void +descriptor_debug_print_methoddesc(FILE *file,methoddesc *d) +{ + int i; + + if (!d) { + fprintf(file,"(methoddesc *)NULL"); + return; + } + + fputc('(',file); + for (i=0; iparamcount; ++i) { + if (i) + fputc(',',file); + descriptor_debug_print_typedesc(file,d->paramtypes + i); + if (d->params) { + descriptor_debug_print_paramdesc(file,d->params + i); + } + } + if (d->params == METHODDESC_NOPARAMS) + fputs("",file); + fputc(')',file); + descriptor_debug_print_typedesc(file,&(d->returntype)); +} + +/* descriptor_pool_debug_dump ************************************************** + + Print the state of the descriptor_pool to the given stream + + IN: + pool.............the descriptor_pool + file.............stream to print to + +*******************************************************************************/ + +void +descriptor_pool_debug_dump(descriptor_pool *pool,FILE *file) +{ + u4 slot; + u1 *pos; + u1 *kind; + u4 size; + + fprintf(file,"======[descriptor_pool for "); + utf_fprint_printable_ascii(file,pool->referer->name); + fprintf(file,"]======\n"); + + fprintf(file,"fieldcount: %d\n",pool->fieldcount); + fprintf(file,"methodcount: %d\n",pool->methodcount); + fprintf(file,"paramcount: %d\n",pool->paramcount); + fprintf(file,"classrefcount: %d\n",pool->classrefhash.entries); + fprintf(file,"descriptorsize: %d bytes\n",pool->descriptorsize); + fprintf(file,"classrefsize: %d bytes\n", + (int)(pool->classrefhash.entries * sizeof(constant_classref))); + + fprintf(file,"class references:\n"); + for (slot=0; slotclassrefhash.size; ++slot) { + classref_hash_entry *c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; + while (c) { + fprintf(file," %4d: ",c->index); + utf_fprint_printable_ascii(file,c->name); + fprintf(file,"\n"); + c = c->hashlink; + } + } + + fprintf(file,"hashed descriptors:\n"); + for (slot=0; slotdescriptorhash.size; ++slot) { + descriptor_hash_entry *c = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; + while (c) { + fprintf(file," %p: ",c->parseddesc.any); + utf_fprint_printable_ascii(file,c->desc); + fprintf(file,"\n"); + c = c->hashlink; + } + } + + fprintf(file,"descriptors:\n"); + if (pool->descriptors) { + pos = pool->descriptors; + size = pool->descriptors_next - pool->descriptors; + fprintf(file," size: %d bytes\n",size); + + if (pool->descriptor_kind) { + kind = pool->descriptor_kind; + + while (pos < (pool->descriptors + size)) { + fprintf(file," %p: ",pos); + switch (*kind++) { + case 'f': + descriptor_debug_print_typedesc(file,(typedesc*)pos); + pos += sizeof(typedesc); + break; + case 'm': + descriptor_debug_print_methoddesc(file,(methoddesc*)pos); + pos += ((methoddesc*)pos)->paramcount * sizeof(typedesc); + pos += sizeof(methoddesc) - sizeof(typedesc); + break; + default: + fprintf(file,"INVALID KIND"); + } + fputc('\n',file); + } + } + else { + while (size >= sizeof(void*)) { + fprintf(file," %p\n",*((void**)pos)); + pos += sizeof(void*); + size -= sizeof(void*); + } + } + } + + fprintf(file,"==========================================================\n"); +} +#endif /* !defined(NDEBUG) */ + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ + diff --git a/src/vm/descriptor.h b/src/vm/descriptor.h new file mode 100644 index 000000000..87fb9c7fe --- /dev/null +++ b/src/vm/descriptor.h @@ -0,0 +1,208 @@ +/* src/vm/descriptor.h - checking and parsing of field / method descriptors + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _DESCRIPTOR_H +#define _DESCRIPTOR_H + +/* forward typedefs ***********************************************************/ + +typedef struct descriptor_pool descriptor_pool; +typedef struct typedesc typedesc; +typedef struct paramdesc paramdesc; +typedef struct methoddesc methoddesc; + + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "toolbox/hashtable.h" + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/method.h" +#include "vm/references.h" +#include "vm/utf8.h" + +#include "arch.h" /* needed for HAS_ADDRESS_REGISTER_FILE */ + + +/* data structures ************************************************************/ + +/*----------------------------------------------------------------------------*/ +/* Descriptor Pools */ +/* */ +/* A descriptor_pool is a temporary data structure used during loading of */ +/* a class. The descriptor_pool is used to allocate the table of */ +/* constant_classrefs the class uses, and for parsing the field and method */ +/* descriptors which occurr within the class. The inner workings of */ +/* descriptor_pool are not important for outside code. */ +/* */ +/* You use a descriptor_pool as follows: */ +/* */ +/* 1. create one with descriptor_pool_new */ +/* 2. add all explicit class references with descriptor_pool_add_class */ +/* 3. add all field/method descriptors with descriptor_pool_add */ +/* 4. call descriptor_pool_create_classrefs */ +/* You can now lookup classrefs with descriptor_pool_lookup_classref */ +/* 5. call descriptor_pool_alloc_parsed_descriptors */ +/* 6. for each field descriptor call descriptor_pool_parse_field_descriptor */ +/* for each method descriptor call descriptor_pool_parse_method_descriptor */ +/* 7. call descriptor_pool_get_parsed_descriptors */ +/* */ +/* IMPORTANT: The descriptor_pool functions use DNEW and DMNEW for allocating */ +/* memory which can be thrown away when the steps above have been */ +/* done. */ +/*----------------------------------------------------------------------------*/ + +struct descriptor_pool { + classinfo *referer; + u4 fieldcount; + u4 methodcount; + u4 paramcount; + u4 descriptorsize; + u1 *descriptors; + u1 *descriptors_next; + hashtable descriptorhash; + constant_classref *classrefs; + hashtable classrefhash; + u1 *descriptor_kind; /* useful for debugging */ + u1 *descriptor_kind_next; /* useful for debugging */ +}; + + +/* data structures for parsed field/method descriptors ************************/ + +struct typedesc { + constant_classref *classref; /* class reference for TYPE_ADR types */ + u1 type; /* TYPE_??? constant [1] */ + u1 primitivetype; /* (PRIMITIVE)TYPE_??? constant [2] */ + u1 arraydim; /* array dimension (0 if no array) */ +}; + +/* [1]...the type field contains the basic type used within the VM. So ints, */ +/* shorts, chars, bytes, booleans all have TYPE_INT. */ +/* [2]...the primitivetype field contains the declared type. */ +/* So short is PRIMITIVETYPE_SHORT, char is PRIMITIVETYPE_CHAR. */ +/* For non-primitive types primitivetype is TYPE_ADR. */ + +struct paramdesc { +#if defined(__MIPS__) + u1 type; /* TYPE_??? of the register allocated */ +#endif + bool inmemory; /* argument in register or on stack */ + uint32_t index; /* index into argument register array */ + uint32_t regoff; /* register index or stack offset */ +}; + +struct methoddesc { + s2 paramcount; /* number of parameters */ + s2 paramslots; /* like above but LONG,DOUBLE count twice */ + s4 argintreguse; /* number of used integer argument registers */ + s4 argfltreguse; /* number of used float argument registers */ +#if defined(HAS_ADDRESS_REGISTER_FILE) + s4 argadrreguse; /* number of used address registers */ +#endif + s4 memuse; /* number of stack slots used */ + paramdesc *params; /* allocated parameter descriptions [3] */ + typedesc returntype; /* parsed descriptor of the return type */ + typedesc paramtypes[1]; /* parameter types, variable length! */ +}; + +/* [3]...If params is NULL, the parameter descriptions have not yet been */ +/* allocated. In this case ___the possible 'this' pointer of the method */ +/* is NOT counted in paramcount/paramslots and it is NOT included in */ +/* the paramtypes array___. */ +/* If params != NULL, the parameter descriptions have been */ +/* allocated, and the 'this' pointer of the method, if any, IS included.*/ +/* In case the method has no parameters at all, the special value */ +/* METHODDESC_NO_PARAMS is used (see below). */ + +/* METHODDESC_NO_PARAMS is a special value for the methoddesc.params field */ +/* indicating that the method is a static method without any parameters. */ +/* This special value must be != NULL and it may only be set if */ +/* md->paramcount == 0. */ + +#define METHODDESC_NOPARAMS ((paramdesc*)1) + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +descriptor_pool * descriptor_pool_new(classinfo *referer); + +bool descriptor_pool_add_class(descriptor_pool *pool,utf *name); +bool descriptor_pool_add(descriptor_pool *pool,utf *desc,int *paramslots); + +int descriptor_to_basic_type(utf *desc); +int descriptor_typesize(typedesc *td); + +constant_classref * descriptor_pool_create_classrefs(descriptor_pool *pool, + s4 *count); +constant_classref * descriptor_pool_lookup_classref(descriptor_pool *pool,utf *classname); + +void descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool); + +typedesc *descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc); +methoddesc *descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc, s4 mflags, + constant_classref *thisclass); + +bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags); + +void *descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size); +void descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize, + u4 *descsize); + +#ifndef NDEBUG +void descriptor_debug_print_typedesc(FILE *file,typedesc *d); +void descriptor_debug_print_methoddesc(FILE *file,methoddesc *d); +void descriptor_debug_print_paramdesc(FILE *file,paramdesc *d); +void descriptor_pool_debug_dump(descriptor_pool *pool, FILE *file); +#endif /* !defined(NDEBUG) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _DESCRIPTOR_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/exceptions.c b/src/vm/exceptions.c deleted file mode 100644 index d258329c1..000000000 --- a/src/vm/exceptions.c +++ /dev/null @@ -1,2105 +0,0 @@ -/* src/vm/exceptions.c - exception related functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "vm/types.h" - -#include "md-abi.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/native.h" - -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Thread.h" -#include "native/include/java_lang_Throwable.h" - -#include "threads/lock-common.h" -#include "threads/thread.h" - -#include "toolbox/util.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" -#include "vm/jit/methodheader.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/show.h" -#include "vm/jit/stacktrace.h" -#include "vm/jit/trace.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/system.h" - -#if defined(ENABLE_VMLOG) -#include -#endif - - -/* for raising exceptions from native methods *********************************/ - -#if !defined(ENABLE_THREADS) -java_object_t *_no_threads_exceptionptr = NULL; -#endif - - -/* exceptions_get_exception **************************************************** - - Returns the current exception pointer of the current thread. - -*******************************************************************************/ - -java_handle_t *exceptions_get_exception(void) -{ - java_object_t *o; - java_handle_t *e; -#if defined(ENABLE_THREADS) - threadobject *t; - - t = THREADOBJECT; -#endif - - /* Get the exception. */ - - LLNI_CRITICAL_START; - -#if defined(ENABLE_THREADS) - o = t->_exceptionptr; -#else - o = _no_threads_exceptionptr; -#endif - - e = LLNI_WRAP(o); - - LLNI_CRITICAL_END; - - /* Return the exception. */ - - return e; -} - - -/* exceptions_set_exception **************************************************** - - Sets the exception pointer of the current thread. - -*******************************************************************************/ - -void exceptions_set_exception(java_handle_t *e) -{ - threadobject *t; - java_object_t *o; - -#if defined(ENABLE_THREADS) - t = THREADOBJECT; -#else - t = NULL; -#endif - - /* Set the exception. */ - - LLNI_CRITICAL_START; - - o = LLNI_UNWRAP(e); - -#if !defined(NDEBUG) - if (opt_DebugExceptions) { - printf("[exceptions_set_exception : t=%p, o=%p, class=", - (void *) t, (void *) o); - class_print(o->vftbl->clazz); - printf("]\n"); - } -#endif - -#if defined(ENABLE_THREADS) - t->_exceptionptr = o; -#else - _no_threads_exceptionptr = o; -#endif - - LLNI_CRITICAL_END; -} - - -/* exceptions_clear_exception ************************************************** - - Clears the current exception pointer of the current thread. - -*******************************************************************************/ - -void exceptions_clear_exception(void) -{ - threadobject *t; - -#if defined(ENABLE_THREADS) - t = THREADOBJECT; -#else - t = NULL; -#endif - - /* Set the exception. */ - -#if !defined(NDEBUG) - if (opt_DebugExceptions) { - printf("[exceptions_clear_exception: t=%p]\n", (void *) t); - } -#endif - -#if defined(ENABLE_THREADS) - t->_exceptionptr = NULL; -#else - _no_threads_exceptionptr = NULL; -#endif -} - - -/* exceptions_get_and_clear_exception ****************************************** - - Gets the exception pointer of the current thread and clears it. - This function may return NULL. - -*******************************************************************************/ - -java_handle_t *exceptions_get_and_clear_exception(void) -{ - java_handle_t *o; - - /* Get the exception... */ - - o = exceptions_get_exception(); - - /* ...and clear the exception if it is set. */ - - if (o != NULL) - exceptions_clear_exception(); - - /* return the exception */ - - return o; -} - - -/* exceptions_abort ************************************************************ - - Prints exception to be thrown and aborts. - - IN: - classname....class name - message......exception message - -*******************************************************************************/ - -static void exceptions_abort(utf *classname, utf *message) -{ - log_println("exception thrown while VM is initializing: "); - - log_start(); - utf_display_printable_ascii_classname(classname); - - if (message != NULL) { - log_print(": "); - utf_display_printable_ascii_classname(message); - } - - log_finish(); - - vm_abort("Aborting..."); -} - - -/* exceptions_new_class_utf **************************************************** - - Creates an exception object with the given class and initalizes it - with the given utf message. - - IN: - c ......... exception class - message ... the message as an utf * - - RETURN VALUE: - an exception pointer (in any case -- either it is the newly - created exception, or an exception thrown while trying to create - it). - -*******************************************************************************/ - -static java_handle_t *exceptions_new_class_utf(classinfo *c, utf *message) -{ - java_handle_t *s; - java_handle_t *o; - - if (vm_initializing) { - /* This can happen when global class variables are used which - are not initialized yet. */ - - if (c == NULL) - exceptions_abort(NULL, message); - else - exceptions_abort(c->name, message); - } - - s = javastring_new(message); - - if (s == NULL) - return exceptions_get_exception(); - - o = native_new_and_init_string(c, s); - - if (o == NULL) - return exceptions_get_exception(); - - return o; -} - - -/* exceptions_new_utf ********************************************************** - - Creates an exception object with the given name and initalizes it. - - IN: - classname....class name in UTF-8 - -*******************************************************************************/ - -static java_handle_t *exceptions_new_utf(utf *classname) -{ - classinfo *c; - java_handle_t *o; - - if (vm_initializing) - exceptions_abort(classname, NULL); - - c = load_class_bootstrap(classname); - - if (c == NULL) - return exceptions_get_exception(); - - o = native_new_and_init(c); - - if (o == NULL) - return exceptions_get_exception(); - - return o; -} - - -/* exceptions_new_utf_javastring *********************************************** - - Creates an exception object with the given name and initalizes it - with the given java/lang/String message. - - IN: - classname....class name in UTF-8 - message......the message as a java.lang.String - - RETURN VALUE: - an exception pointer (in any case -- either it is the newly created - exception, or an exception thrown while trying to create it). - -*******************************************************************************/ - -static java_handle_t *exceptions_new_utf_javastring(utf *classname, - java_handle_t *message) -{ - java_handle_t *o; - classinfo *c; - - if (vm_initializing) - exceptions_abort(classname, NULL); - - c = load_class_bootstrap(classname); - - if (c == NULL) - return exceptions_get_exception(); - - o = native_new_and_init_string(c, message); - - if (o == NULL) - return exceptions_get_exception(); - - return o; -} - - -/* exceptions_new_utf_utf ****************************************************** - - Creates an exception object with the given name and initalizes it - with the given utf message. - - IN: - classname....class name in UTF-8 - message......the message as an utf * - - RETURN VALUE: - an exception pointer (in any case -- either it is the newly created - exception, or an exception thrown while trying to create it). - -*******************************************************************************/ - -static java_handle_t *exceptions_new_utf_utf(utf *classname, utf *message) -{ - classinfo *c; - java_handle_t *o; - - if (vm_initializing) - exceptions_abort(classname, message); - - c = load_class_bootstrap(classname); - - if (c == NULL) - return exceptions_get_exception(); - - o = exceptions_new_class_utf(c, message); - - return o; -} - - -/* exceptions_throw_class_utf ************************************************** - - Creates an exception object with the given class, initalizes and - throws it with the given utf message. - - IN: - c ......... exception class - message ... the message as an utf * - -*******************************************************************************/ - -static void exceptions_throw_class_utf(classinfo *c, utf *message) -{ - java_handle_t *o; - - o = exceptions_new_class_utf(c, message); - - exceptions_set_exception(o); -} - - -/* exceptions_throw_utf ******************************************************** - - Creates an exception object with the given name, initalizes and - throws it. - - IN: - classname....class name in UTF-8 - -*******************************************************************************/ - -static void exceptions_throw_utf(utf *classname) -{ - java_handle_t *o; - - o = exceptions_new_utf(classname); - - if (o == NULL) - return; - - exceptions_set_exception(o); -} - - -/* exceptions_throw_utf_throwable ********************************************** - - Creates an exception object with the given name and initalizes it - with the given java/lang/Throwable exception. - - IN: - classname....class name in UTF-8 - cause........the given Throwable - -*******************************************************************************/ - -static void exceptions_throw_utf_throwable(utf *classname, - java_handle_t *cause) -{ - classinfo *c; - java_handle_t *o; - methodinfo *m; - java_lang_Throwable *object; - - if (vm_initializing) - exceptions_abort(classname, NULL); - - object = (java_lang_Throwable *) cause; - - c = load_class_bootstrap(classname); - - if (c == NULL) - return; - - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return; - - /* call initializer */ - - m = class_resolveclassmethod(c, - utf_init, - utf_java_lang_Throwable__void, - NULL, - true); - - if (m == NULL) - return; - - (void) vm_call_method(m, o, cause); - - exceptions_set_exception(o); -} - - -/* exceptions_throw_utf_exception ********************************************** - - Creates an exception object with the given name and initalizes it - with the given java/lang/Exception exception. - - IN: - classname....class name in UTF-8 - exception....the given Exception - -*******************************************************************************/ - -static void exceptions_throw_utf_exception(utf *classname, - java_handle_t *exception) -{ - classinfo *c; - java_handle_t *o; - methodinfo *m; - - if (vm_initializing) - exceptions_abort(classname, NULL); - - c = load_class_bootstrap(classname); - - if (c == NULL) - return; - - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return; - - /* call initializer */ - - m = class_resolveclassmethod(c, - utf_init, - utf_java_lang_Exception__V, - NULL, - true); - - if (m == NULL) - return; - - (void) vm_call_method(m, o, exception); - - exceptions_set_exception(o); -} - - -/* exceptions_throw_utf_cause ************************************************** - - Creates an exception object with the given name and initalizes it - with the given java/lang/Throwable exception with initCause. - - IN: - classname....class name in UTF-8 - cause........the given Throwable - -*******************************************************************************/ - -static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause) -{ - classinfo *c; - java_handle_t *o; - methodinfo *m; - java_lang_String *s; - java_lang_Throwable *object; - - if (vm_initializing) - exceptions_abort(classname, NULL); - - object = (java_lang_Throwable *) cause; - - c = load_class_bootstrap(classname); - - if (c == NULL) - return; - - /* create object */ - - o = builtin_new(c); - - if (o == NULL) - return; - - /* call initializer */ - - m = class_resolveclassmethod(c, - utf_init, - utf_java_lang_String__void, - NULL, - true); - - if (m == NULL) - return; - - LLNI_field_get_ref(object, detailMessage, s); - - (void) vm_call_method(m, o, s); - - /* call initCause */ - - m = class_resolveclassmethod(c, - utf_initCause, - utf_java_lang_Throwable__java_lang_Throwable, - NULL, - true); - - if (m == NULL) - return; - - (void) vm_call_method(m, o, cause); - - exceptions_set_exception(o); -} - - -/* exceptions_throw_utf_utf **************************************************** - - Creates an exception object with the given name, initalizes and - throws it with the given utf message. - - IN: - classname....class name in UTF-8 - message......the message as an utf * - -*******************************************************************************/ - -static void exceptions_throw_utf_utf(utf *classname, utf *message) -{ - java_handle_t *o; - - o = exceptions_new_utf_utf(classname, message); - - exceptions_set_exception(o); -} - - -/* exceptions_new_abstractmethoderror **************************************** - - Generates a java.lang.AbstractMethodError for the VM. - -*******************************************************************************/ - -java_handle_t *exceptions_new_abstractmethoderror(void) -{ - java_handle_t *o; - - o = exceptions_new_utf(utf_java_lang_AbstractMethodError); - - return o; -} - - -/* exceptions_new_error ******************************************************** - - Generates a java.lang.Error for the VM. - -*******************************************************************************/ - -#if defined(ENABLE_JAVAME_CLDC1_1) -static java_handle_t *exceptions_new_error(utf *message) -{ - java_handle_t *o; - - o = exceptions_new_utf_utf(utf_java_lang_Error, message); - - return o; -} -#endif - - -/* exceptions_asm_new_abstractmethoderror ************************************** - - Generates a java.lang.AbstractMethodError for - asm_abstractmethoderror. - -*******************************************************************************/ - -java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra) -{ - stackframeinfo_t sfi; - java_handle_t *e; - java_object_t *o; - - /* Fill and add a stackframeinfo (XPC is equal to RA). */ - - stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra); - - /* create the exception */ - -#if defined(ENABLE_JAVASE) - e = exceptions_new_abstractmethoderror(); -#else - e = exceptions_new_error(utf_java_lang_AbstractMethodError); -#endif - - /* Remove the stackframeinfo. */ - - stacktrace_stackframeinfo_remove(&sfi); - - /* unwrap the exception */ - /* ATTENTION: do the this _after_ the stackframeinfo was removed */ - - o = LLNI_UNWRAP(e); - - return o; -} - - -/* exceptions_new_arraystoreexception ****************************************** - - Generates a java.lang.ArrayStoreException for the VM. - -*******************************************************************************/ - -java_handle_t *exceptions_new_arraystoreexception(void) -{ - java_handle_t *o; - - o = exceptions_new_utf(utf_java_lang_ArrayStoreException); - - return o; -} - - -/* exceptions_throw_abstractmethoderror **************************************** - - Generates and throws a java.lang.AbstractMethodError for the VM. - -*******************************************************************************/ - -void exceptions_throw_abstractmethoderror(void) -{ - exceptions_throw_utf(utf_java_lang_AbstractMethodError); -} - - -/* exceptions_throw_classcircularityerror ************************************** - - Generates and throws a java.lang.ClassCircularityError for the - classloader. - - IN: - c....the class in which the error was found - -*******************************************************************************/ - -void exceptions_throw_classcircularityerror(classinfo *c) -{ - exceptions_throw_utf_utf(utf_java_lang_ClassCircularityError, c->name); -} - - -/* exceptions_throw_classformaterror ******************************************* - - Generates and throws a java.lang.ClassFormatError for the VM. - - IN: - c............the class in which the error was found - message......UTF-8 format string - -*******************************************************************************/ - -void exceptions_throw_classformaterror(classinfo *c, const char *message, ...) -{ - char *msg; - s4 msglen; - va_list ap; - utf *u; - - /* calculate message length */ - - msglen = 0; - - if (c != NULL) - msglen += utf_bytes(c->name) + strlen(" ("); - - va_start(ap, message); - msglen += get_variable_message_length(message, ap); - va_end(ap); - - if (c != NULL) - msglen += strlen(")"); - - msglen += strlen("0"); - - /* allocate a buffer */ - - msg = MNEW(char, msglen); - - /* print message into allocated buffer */ - - if (c != NULL) { - utf_copy_classname(msg, c->name); - strcat(msg, " ("); - } - - va_start(ap, message); - vsprintf(msg + strlen(msg), message, ap); - va_end(ap); - - if (c != NULL) - strcat(msg, ")"); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - /* throw exception */ - - exceptions_throw_utf_utf(utf_java_lang_ClassFormatError, u); -} - - -/* exceptions_throw_classnotfoundexception ************************************* - - Generates and throws a java.lang.ClassNotFoundException for the - VM. - - IN: - name.........name of the class not found as a utf * - -*******************************************************************************/ - -void exceptions_throw_classnotfoundexception(utf *name) -{ - exceptions_throw_class_utf(class_java_lang_ClassNotFoundException, name); -} - - -/* exceptions_throw_noclassdeffounderror *************************************** - - Generates and throws a java.lang.NoClassDefFoundError. - - IN: - name.........name of the class not found as a utf * - -*******************************************************************************/ - -void exceptions_throw_noclassdeffounderror(utf *name) -{ - exceptions_throw_utf_utf(utf_java_lang_NoClassDefFoundError, name); -} - - -/* exceptions_throw_noclassdeffounderror_cause ********************************* - - Generates and throws a java.lang.NoClassDefFoundError with the - given cause. - -*******************************************************************************/ - -void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause) -{ - exceptions_throw_utf_cause(utf_java_lang_NoClassDefFoundError, cause); -} - - -/* exceptions_throw_noclassdeffounderror_wrong_name **************************** - - Generates and throws a java.lang.NoClassDefFoundError with a - specific message: - - IN: - name.........name of the class not found as a utf * - -*******************************************************************************/ - -void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name) -{ - char *msg; - s4 msglen; - utf *u; - - msglen = utf_bytes(c->name) + strlen(" (wrong name: ") + - utf_bytes(name) + strlen(")") + strlen("0"); - - msg = MNEW(char, msglen); - - utf_copy_classname(msg, c->name); - strcat(msg, " (wrong name: "); - utf_cat_classname(msg, name); - strcat(msg, ")"); - - u = utf_new_char(msg); - - MFREE(msg, char, msglen); - - exceptions_throw_noclassdeffounderror(u); -} - - -/* exceptions_throw_exceptionininitializererror ******************************** - - Generates and throws a java.lang.ExceptionInInitializerError for - the VM. - - IN: - cause......cause exception object - -*******************************************************************************/ - -void exceptions_throw_exceptionininitializererror(java_handle_t *cause) -{ - exceptions_throw_utf_throwable(utf_java_lang_ExceptionInInitializerError, - cause); -} - - -/* exceptions_throw_incompatibleclasschangeerror ******************************* - - Generates and throws a java.lang.IncompatibleClassChangeError for - the VM. - - IN: - message......UTF-8 message format string - -*******************************************************************************/ - -void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message) -{ - char *msg; - s4 msglen; - utf *u; - - /* calculate exception message length */ - - msglen = utf_bytes(c->name) + strlen(message) + strlen("0"); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - utf_copy_classname(msg, c->name); - strcat(msg, message); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - /* throw exception */ - - exceptions_throw_utf_utf(utf_java_lang_IncompatibleClassChangeError, u); -} - - -/* exceptions_throw_instantiationerror ***************************************** - - Generates and throws a java.lang.InstantiationError for the VM. - -*******************************************************************************/ - -void exceptions_throw_instantiationerror(classinfo *c) -{ - exceptions_throw_utf_utf(utf_java_lang_InstantiationError, c->name); -} - - -/* exceptions_throw_internalerror ********************************************** - - Generates and throws a java.lang.InternalError for the VM. - - IN: - message......UTF-8 message format string - -*******************************************************************************/ - -void exceptions_throw_internalerror(const char *message, ...) -{ - va_list ap; - char *msg; - s4 msglen; - utf *u; - - /* calculate exception message length */ - - va_start(ap, message); - msglen = get_variable_message_length(message, ap); - va_end(ap); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - /* generate message */ - - va_start(ap, message); - vsprintf(msg, message, ap); - va_end(ap); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - /* throw exception */ - - exceptions_throw_utf_utf(utf_java_lang_InternalError, u); -} - - -/* exceptions_throw_linkageerror *********************************************** - - Generates and throws java.lang.LinkageError with an error message. - - IN: - message......UTF-8 message - c............class related to the error. If this is != NULL - the name of c is appended to the error message. - -*******************************************************************************/ - -void exceptions_throw_linkageerror(const char *message, classinfo *c) -{ - utf *u; - char *msg; - int len; - - /* calculate exception message length */ - - len = strlen(message) + 1; - - if (c != NULL) - len += utf_bytes(c->name); - - /* allocate memory */ - - msg = MNEW(char, len); - - /* generate message */ - - strcpy(msg, message); - - if (c != NULL) - utf_cat_classname(msg, c->name); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, len); - - exceptions_throw_utf_utf(utf_java_lang_LinkageError, u); -} - - -/* exceptions_throw_nosuchfielderror ******************************************* - - Generates and throws a java.lang.NoSuchFieldError with an error - message. - - IN: - c............class in which the field was not found - name.........name of the field - -*******************************************************************************/ - -void exceptions_throw_nosuchfielderror(classinfo *c, utf *name) -{ - char *msg; - s4 msglen; - utf *u; - - /* calculate exception message length */ - - msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) + strlen("0"); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - /* generate message */ - - utf_copy_classname(msg, c->name); - strcat(msg, "."); - utf_cat(msg, name); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - exceptions_throw_utf_utf(utf_java_lang_NoSuchFieldError, u); -} - - -/* exceptions_throw_nosuchmethoderror ****************************************** - - Generates and throws a java.lang.NoSuchMethodError with an error - message. - - IN: - c............class in which the method was not found - name.........name of the method - desc.........descriptor of the method - -*******************************************************************************/ - -void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc) -{ - char *msg; - s4 msglen; - utf *u; - - /* calculate exception message length */ - - msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) + - utf_bytes(desc) + strlen("0"); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - /* generate message */ - - utf_copy_classname(msg, c->name); - strcat(msg, "."); - utf_cat(msg, name); - utf_cat(msg, desc); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - -#if defined(ENABLE_JAVASE) - exceptions_throw_utf_utf(utf_java_lang_NoSuchMethodError, u); -#else - exceptions_throw_utf_utf(utf_java_lang_Error, u); -#endif -} - - -/* exceptions_throw_outofmemoryerror ******************************************* - - Generates and throws an java.lang.OutOfMemoryError for the VM. - -*******************************************************************************/ - -void exceptions_throw_outofmemoryerror(void) -{ - exceptions_throw_utf(utf_java_lang_OutOfMemoryError); -} - - -/* exceptions_throw_unsatisfiedlinkerror *************************************** - - Generates and throws a java.lang.UnsatisfiedLinkError for the - classloader. - - IN: - name......UTF-8 name string - -*******************************************************************************/ - -void exceptions_throw_unsatisfiedlinkerror(utf *name) -{ -#if defined(ENABLE_JAVASE) - exceptions_throw_utf_utf(utf_java_lang_UnsatisfiedLinkError, name); -#else - exceptions_throw_utf_utf(utf_java_lang_Error, name); -#endif -} - - -/* exceptions_throw_unsupportedclassversionerror ******************************* - - Generates and throws a java.lang.UnsupportedClassVersionError for - the classloader. - - IN: - c............class in which the method was not found - message......UTF-8 format string - -*******************************************************************************/ - -void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi) -{ - char *msg; - s4 msglen; - utf *u; - - /* calculate exception message length */ - - msglen = - utf_bytes(c->name) + - strlen(" (Unsupported major.minor version 00.0)") + - strlen("0"); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - /* generate message */ - - utf_copy_classname(msg, c->name); - sprintf(msg + strlen(msg), " (Unsupported major.minor version %d.%d)", - ma, mi); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - /* throw exception */ - - exceptions_throw_utf_utf(utf_java_lang_UnsupportedClassVersionError, u); -} - - -/* exceptions_throw_verifyerror ************************************************ - - Generates and throws a java.lang.VerifyError for the JIT compiler. - - IN: - m............method in which the error was found - message......UTF-8 format string - -*******************************************************************************/ - -void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...) -{ - va_list ap; - char *msg; - s4 msglen; - utf *u; - - /* calculate exception message length */ - - msglen = 0; - - if (m != NULL) - msglen = - strlen("(class: ") + utf_bytes(m->clazz->name) + - strlen(", method: ") + utf_bytes(m->name) + - strlen(" signature: ") + utf_bytes(m->descriptor) + - strlen(") ") + strlen("0"); - - va_start(ap, message); - msglen += get_variable_message_length(message, ap); - va_end(ap); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - /* generate message */ - - if (m != NULL) { - strcpy(msg, "(class: "); - utf_cat_classname(msg, m->clazz->name); - strcat(msg, ", method: "); - utf_cat(msg, m->name); - strcat(msg, " signature: "); - utf_cat(msg, m->descriptor); - strcat(msg, ") "); - } - - va_start(ap, message); - vsprintf(msg + strlen(msg), message, ap); - va_end(ap); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - /* throw exception */ - - exceptions_throw_utf_utf(utf_java_lang_VerifyError, u); -} - - -/* exceptions_throw_verifyerror_for_stack ************************************** - - throws a java.lang.VerifyError for an invalid stack slot type - - IN: - m............method in which the error was found - type.........the expected type - - RETURN VALUE: - an exception pointer (in any case -- either it is the newly created - exception, or an exception thrown while trying to create it). - -*******************************************************************************/ - -void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type) -{ - char *msg; - s4 msglen; - char *typename; - utf *u; - - /* calculate exception message length */ - - msglen = 0; - - if (m != NULL) - msglen = strlen("(class: ") + utf_bytes(m->clazz->name) + - strlen(", method: ") + utf_bytes(m->name) + - strlen(" signature: ") + utf_bytes(m->descriptor) + - strlen(") Expecting to find longest-------typename on stack") - + strlen("0"); - - /* allocate memory */ - - msg = MNEW(char, msglen); - - /* generate message */ - - if (m != NULL) { - strcpy(msg, "(class: "); - utf_cat_classname(msg, m->clazz->name); - strcat(msg, ", method: "); - utf_cat(msg, m->name); - strcat(msg, " signature: "); - utf_cat(msg, m->descriptor); - strcat(msg, ") "); - } - else { - msg[0] = 0; - } - - strcat(msg, "Expecting to find "); - - switch (type) { - case TYPE_INT: typename = "integer"; break; - case TYPE_LNG: typename = "long"; break; - case TYPE_FLT: typename = "float"; break; - case TYPE_DBL: typename = "double"; break; - case TYPE_ADR: typename = "object/array"; break; - case TYPE_RET: typename = "returnAddress"; break; - default: typename = ""; assert(0); break; - } - - strcat(msg, typename); - strcat(msg, " on stack"); - - u = utf_new_char(msg); - - /* free memory */ - - MFREE(msg, char, msglen); - - /* throw exception */ - - exceptions_throw_utf_utf(utf_java_lang_VerifyError, u); -} - - -/* exceptions_new_arithmeticexception ****************************************** - - Generates a java.lang.ArithmeticException for the JIT compiler. - -*******************************************************************************/ - -java_handle_t *exceptions_new_arithmeticexception(void) -{ - java_handle_t *o; - - o = exceptions_new_utf_utf(utf_java_lang_ArithmeticException, - utf_division_by_zero); - - return o; -} - - -/* exceptions_new_arrayindexoutofboundsexception ******************************* - - Generates a java.lang.ArrayIndexOutOfBoundsException for the VM - system. - -*******************************************************************************/ - -java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index) -{ - java_handle_t *o; - methodinfo *m; - java_handle_t *s; - - /* convert the index into a String, like Sun does */ - - m = class_resolveclassmethod(class_java_lang_String, - utf_new_char("valueOf"), - utf_new_char("(I)Ljava/lang/String;"), - class_java_lang_Object, - true); - - if (m == NULL) - return exceptions_get_exception(); - - s = vm_call_method(m, NULL, index); - - if (s == NULL) - return exceptions_get_exception(); - - o = exceptions_new_utf_javastring(utf_java_lang_ArrayIndexOutOfBoundsException, - s); - - if (o == NULL) - return exceptions_get_exception(); - - return o; -} - - -/* exceptions_throw_arrayindexoutofboundsexception ***************************** - - Generates and throws a java.lang.ArrayIndexOutOfBoundsException for - the VM. - -*******************************************************************************/ - -void exceptions_throw_arrayindexoutofboundsexception(void) -{ - exceptions_throw_utf(utf_java_lang_ArrayIndexOutOfBoundsException); -} - - -/* exceptions_throw_arraystoreexception **************************************** - - Generates and throws a java.lang.ArrayStoreException for the VM. - -*******************************************************************************/ - -void exceptions_throw_arraystoreexception(void) -{ - exceptions_throw_utf(utf_java_lang_ArrayStoreException); -} - - -/* exceptions_new_classcastexception ******************************************* - - Generates a java.lang.ClassCastException for the JIT compiler. - -*******************************************************************************/ - -java_handle_t *exceptions_new_classcastexception(java_handle_t *o) -{ - java_handle_t *e; - classinfo *c; - utf *classname; - - LLNI_class_get(o, c); - - classname = c->name; - - e = exceptions_new_utf_utf(utf_java_lang_ClassCastException, classname); - - return e; -} - - -/* exceptions_throw_clonenotsupportedexception ********************************* - - Generates and throws a java.lang.CloneNotSupportedException for the - VM. - -*******************************************************************************/ - -void exceptions_throw_clonenotsupportedexception(void) -{ - exceptions_throw_utf(utf_java_lang_CloneNotSupportedException); -} - - -/* exceptions_throw_illegalaccessexception ************************************* - - Generates and throws a java.lang.IllegalAccessException for the VM. - -*******************************************************************************/ - -void exceptions_throw_illegalaccessexception(utf *message) -{ - exceptions_throw_utf_utf(utf_java_lang_IllegalAccessException, message); -} - - -/* exceptions_throw_illegalargumentexception *********************************** - - Generates and throws a java.lang.IllegalArgumentException for the - VM. - -*******************************************************************************/ - -void exceptions_throw_illegalargumentexception(void) -{ - exceptions_throw_utf(utf_java_lang_IllegalArgumentException); -} - - -/* exceptions_throw_illegalmonitorstateexception ******************************* - - Generates and throws a java.lang.IllegalMonitorStateException for - the VM. - -*******************************************************************************/ - -void exceptions_throw_illegalmonitorstateexception(void) -{ - exceptions_throw_utf(utf_java_lang_IllegalMonitorStateException); -} - - -/* exceptions_throw_instantiationexception ************************************* - - Generates and throws a java.lang.InstantiationException for the VM. - -*******************************************************************************/ - -void exceptions_throw_instantiationexception(classinfo *c) -{ - exceptions_throw_utf_utf(utf_java_lang_InstantiationException, c->name); -} - - -/* exceptions_throw_interruptedexception *************************************** - - Generates and throws a java.lang.InterruptedException for the VM. - -*******************************************************************************/ - -void exceptions_throw_interruptedexception(void) -{ - exceptions_throw_utf(utf_java_lang_InterruptedException); -} - - -/* exceptions_throw_invocationtargetexception ********************************** - - Generates and throws a java.lang.reflect.InvocationTargetException - for the VM. - - IN: - cause......cause exception object - -*******************************************************************************/ - -void exceptions_throw_invocationtargetexception(java_handle_t *cause) -{ - exceptions_throw_utf_throwable(utf_java_lang_reflect_InvocationTargetException, - cause); -} - - -/* exceptions_throw_negativearraysizeexception ********************************* - - Generates and throws a java.lang.NegativeArraySizeException for the - VM. - -*******************************************************************************/ - -void exceptions_throw_negativearraysizeexception(void) -{ - exceptions_throw_utf(utf_java_lang_NegativeArraySizeException); -} - - -/* exceptions_new_nullpointerexception ***************************************** - - Generates a java.lang.NullPointerException for the VM system. - -*******************************************************************************/ - -java_handle_t *exceptions_new_nullpointerexception(void) -{ - java_handle_t *o; - - o = exceptions_new_utf(utf_java_lang_NullPointerException); - - return o; -} - - -/* exceptions_throw_nullpointerexception *************************************** - - Generates a java.lang.NullPointerException for the VM system and - throw it in the VM system. - -*******************************************************************************/ - -void exceptions_throw_nullpointerexception(void) -{ - exceptions_throw_utf(utf_java_lang_NullPointerException); -} - - -/* exceptions_throw_privilegedactionexception ********************************** - - Generates and throws a java.security.PrivilegedActionException. - -*******************************************************************************/ - -void exceptions_throw_privilegedactionexception(java_handle_t *exception) -{ - exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException, - exception); -} - - -/* exceptions_throw_stringindexoutofboundsexception **************************** - - Generates and throws a java.lang.StringIndexOutOfBoundsException - for the VM. - -*******************************************************************************/ - -void exceptions_throw_stringindexoutofboundsexception(void) -{ - exceptions_throw_utf(utf_java_lang_StringIndexOutOfBoundsException); -} - - -/* exceptions_fillinstacktrace ************************************************* - - Calls the fillInStackTrace-method of the currently thrown - exception. - -*******************************************************************************/ - -java_handle_t *exceptions_fillinstacktrace(void) -{ - java_handle_t *o; - classinfo *c; - methodinfo *m; - - /* get exception */ - - o = exceptions_get_and_clear_exception(); - - assert(o); - - /* resolve methodinfo pointer from exception object */ - - LLNI_class_get(o, c); - -#if defined(ENABLE_JAVASE) - m = class_resolvemethod(c, - utf_fillInStackTrace, - utf_void__java_lang_Throwable); -#elif defined(ENABLE_JAVAME_CLDC1_1) - m = class_resolvemethod(c, - utf_fillInStackTrace, - utf_void__void); -#else -#error IMPLEMENT ME! -#endif - - /* call function */ - - (void) vm_call_method(m, o); - - /* return exception object */ - - return o; -} - - -/* exceptions_handle_exception ************************************************* - - Try to find an exception handler for the given exception and return it. - If no handler is found, exit the monitor of the method (if any) - and return NULL. - - IN: - xptr.........the exception object - xpc..........PC of where the exception was thrown - pv...........Procedure Value of the current method - sp...........current stack pointer - - RETURN VALUE: - the address of the first matching exception handler, or - NULL if no handler was found - -*******************************************************************************/ - -#if defined(ENABLE_JIT) -void *exceptions_handle_exception(java_object_t *xptro, void *xpc, void *pv, void *sp) -{ - stackframeinfo_t sfi; - java_handle_t *xptr; - methodinfo *m; - codeinfo *code; - exceptiontable_t *et; - exceptiontable_entry_t *ete; - s4 i; - classref_or_classinfo cr; - classinfo *c; -#if defined(ENABLE_THREADS) - java_object_t *o; -#endif - void *result; - -#ifdef __S390__ - /* Addresses are 31 bit integers */ -# define ADDR_MASK(x) (void *) ((uintptr_t) (x) & 0x7FFFFFFF) -#else -# define ADDR_MASK(x) (x) -#endif - - xptr = LLNI_WRAP(xptro); - xpc = ADDR_MASK(xpc); - - /* Fill and add a stackframeinfo (XPC is equal to RA). */ - - stacktrace_stackframeinfo_add(&sfi, pv, sp, xpc, xpc); - - result = NULL; - - /* Get the codeinfo for the current method. */ - - code = code_get_codeinfo_for_pv(pv); - - /* Get the methodinfo pointer from the codeinfo pointer. For - asm_vm_call_method the codeinfo pointer is NULL and we simply - can return the proper exception handler. */ - - if (code == NULL) { - result = (void *) (uintptr_t) &asm_vm_call_method_exception_handler; - goto exceptions_handle_exception_return; - } - - m = code->m; - -#if !defined(NDEBUG) - /* print exception trace */ - - if (opt_TraceExceptions) - trace_exception(LLNI_DIRECT(xptr), m, xpc); - -# if defined(ENABLE_VMLOG) - vmlog_cacao_throw(xptr); -# endif -#endif - - /* Get the exception table. */ - - et = code->exceptiontable; - - if (et != NULL) { - /* Iterate over all exception table entries. */ - - ete = et->entries; - - for (i = 0; i < et->length; i++, ete++) { - /* is the xpc is the current catch range */ - - if ((ADDR_MASK(ete->startpc) <= xpc) && (xpc < ADDR_MASK(ete->endpc))) { - cr = ete->catchtype; - - /* NULL catches everything */ - - if (cr.any == NULL) { -#if !defined(NDEBUG) - /* Print stacktrace of exception when caught. */ - -# if defined(ENABLE_VMLOG) - vmlog_cacao_catch(xptr); -# endif - - if (opt_TraceExceptions) { - exceptions_print_exception(xptr); - stacktrace_print_exception(xptr); - } -#endif - - result = ete->handlerpc; - goto exceptions_handle_exception_return; - } - - /* resolve or load/link the exception class */ - - if (IS_CLASSREF(cr)) { - /* The exception class reference is unresolved. */ - /* We have to do _eager_ resolving here. While the - class of the exception object is guaranteed to be - loaded, it may well have been loaded by a different - loader than the defining loader of m's class, which - is the one we must use to resolve the catch - class. Thus lazy resolving might fail, even if the - result of the resolution would be an already loaded - class. */ - - c = resolve_classref_eager(cr.ref); - - if (c == NULL) { - /* Exception resolving the exception class, argh! */ - goto exceptions_handle_exception_return; - } - - /* Ok, we resolved it. Enter it in the table, so we - don't have to do this again. */ - /* XXX this write should be atomic. Is it? */ - - ete->catchtype.cls = c; - } - else { - c = cr.cls; - - /* XXX I don't think this case can ever happen. -Edwin */ - if (!(c->state & CLASS_LOADED)) - /* use the methods' classloader */ - if (!load_class_from_classloader(c->name, - m->clazz->classloader)) - goto exceptions_handle_exception_return; - - /* XXX I think, if it is not linked, we can be sure - that the exception object is no (indirect) instance - of it, no? -Edwin */ - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - goto exceptions_handle_exception_return; - } - - /* is the thrown exception an instance of the catch class? */ - - if (builtin_instanceof(xptr, c)) { -#if !defined(NDEBUG) - /* Print stacktrace of exception when caught. */ - -# if defined(ENABLE_VMLOG) - vmlog_cacao_catch(xptr); -# endif - - if (opt_TraceExceptions) { - exceptions_print_exception(xptr); - stacktrace_print_exception(xptr); - } -#endif - - result = ete->handlerpc; - goto exceptions_handle_exception_return; - } - } - } - } - -#if defined(ENABLE_THREADS) - /* Is this method realization synchronized? */ - - if (code_is_synchronized(code)) { - /* Get synchronization object. */ - - o = *((java_object_t **) (((uintptr_t) sp) + code->synchronizedoffset)); - - assert(o != NULL); - - lock_monitor_exit(LLNI_QUICKWRAP(o)); - } -#endif - - /* none of the exceptions catch this one */ - -#if !defined(NDEBUG) -# if defined(ENABLE_VMLOG) - vmlog_cacao_unwnd_method(m); -# endif - -# if defined(ENABLE_DEBUG_FILTER) - if (show_filters_test_verbosecall_exit(m)) { -# endif - - /* outdent the log message */ - - if (opt_verbosecall) { - if (TRACEJAVACALLINDENT) - TRACEJAVACALLINDENT--; - else - log_text("exceptions_handle_exception: WARNING: unmatched unindent"); - } - -# if defined(ENABLE_DEBUG_FILTER) - } -# endif -#endif /* !defined(NDEBUG) */ - - result = NULL; - -exceptions_handle_exception_return: - - /* Remove the stackframeinfo. */ - - stacktrace_stackframeinfo_remove(&sfi); - - return result; -} -#endif /* defined(ENABLE_JIT) */ - - -/* exceptions_print_exception ************************************************** - - Prints an exception, the detail message and the cause, if - available, with CACAO internal functions to stdout. - -*******************************************************************************/ - -void exceptions_print_exception(java_handle_t *xptr) -{ - java_lang_Throwable *t; -#if defined(ENABLE_JAVASE) - java_lang_Throwable *cause; -#endif - java_lang_String *s; - classinfo *c; - utf *u; - - t = (java_lang_Throwable *) xptr; - - if (t == NULL) { - puts("NULL\n"); - return; - } - -#if defined(ENABLE_JAVASE) - LLNI_field_get_ref(t, cause, cause); -#endif - - /* print the root exception */ - - LLNI_class_get(t, c); - utf_display_printable_ascii_classname(c->name); - - LLNI_field_get_ref(t, detailMessage, s); - - if (s != NULL) { - u = javastring_toutf((java_handle_t *) s, false); - - printf(": "); - utf_display_printable_ascii(u); - } - - putc('\n', stdout); - -#if defined(ENABLE_JAVASE) - /* print the cause if available */ - - if ((cause != NULL) && (cause != t)) { - printf("Caused by: "); - - LLNI_class_get(cause, c); - utf_display_printable_ascii_classname(c->name); - - LLNI_field_get_ref(cause, detailMessage, s); - - if (s != NULL) { - u = javastring_toutf((java_handle_t *) s, false); - - printf(": "); - utf_display_printable_ascii(u); - } - - putc('\n', stdout); - } -#endif -} - - -/* exceptions_print_current_exception ****************************************** - - Prints the current pending exception, the detail message and the - cause, if available, with CACAO internal functions to stdout. - -*******************************************************************************/ - -void exceptions_print_current_exception(void) -{ - java_handle_t *o; - - o = exceptions_get_exception(); - - exceptions_print_exception(o); -} - - -/* exceptions_print_stacktrace ************************************************* - - Prints a pending exception with Throwable.printStackTrace(). If - there happens an exception during printStackTrace(), we print the - thrown exception and the original one. - - NOTE: This function calls Java code. - -*******************************************************************************/ - -void exceptions_print_stacktrace(void) -{ - java_handle_t *e; - java_handle_t *ne; - classinfo *c; - methodinfo *m; - -#if defined(ENABLE_THREADS) - threadobject *t; - java_lang_Thread *to; -#endif - - /* Get and clear exception because we are calling Java code - again. */ - - e = exceptions_get_and_clear_exception(); - - if (e == NULL) - return; - -#if 0 - /* FIXME Enable me. */ - if (builtin_instanceof(e, class_java_lang_ThreadDeath)) { - /* Don't print anything if we are being killed. */ - } - else -#endif - { - /* Get the exception class. */ - - LLNI_class_get(e, c); - - /* Find the printStackTrace() method. */ - - m = class_resolveclassmethod(c, - utf_printStackTrace, - utf_void__void, - class_java_lang_Object, - false); - - if (m == NULL) - vm_abort("exceptions_print_stacktrace: printStackTrace()V not found"); - - /* Print message. */ - - fprintf(stderr, "Exception "); - -#if defined(ENABLE_THREADS) - /* Print thread name. We get the thread here explicitly as we - need it afterwards. */ - - t = thread_get_current(); - to = (java_lang_Thread *) thread_get_object(t); - - if (to != NULL) { - fprintf(stderr, "in thread \""); - thread_fprint_name(t, stderr); - fprintf(stderr, "\" "); - } -#endif - - /* Print the stacktrace. */ - - if (builtin_instanceof(e, class_java_lang_Throwable)) { - (void) vm_call_method(m, e); - - /* If this happens we are EXTREMLY out of memory or have a - serious problem while printStackTrace. But may be - another exception, so print it. */ - - ne = exceptions_get_exception(); - - if (ne != NULL) { - fprintf(stderr, "Exception while printStackTrace(): "); - - /* Print the current exception. */ - - exceptions_print_exception(ne); - stacktrace_print_exception(ne); - - /* Now print the original exception. */ - - fprintf(stderr, "Original exception was: "); - exceptions_print_exception(e); - stacktrace_print_exception(e); - } - } - else { - fprintf(stderr, ". Uncaught exception of type "); -#if !defined(NDEBUG) - /* FIXME This prints to stdout. */ - class_print(c); -#else - fprintf(stderr, "UNKNOWN"); -#endif - fprintf(stderr, "."); - } - - fflush(stderr); - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/exceptions.cpp b/src/vm/exceptions.cpp new file mode 100644 index 000000000..c318e6e97 --- /dev/null +++ b/src/vm/exceptions.cpp @@ -0,0 +1,2090 @@ +/* src/vm/exceptions.cpp - exception related functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "vm/types.h" + +#include "md-abi.h" + +#include "mm/memory.h" + +#include "native/llni.h" +#include "native/native.h" + +#include "threads/lock-common.h" +#include "threads/thread.hpp" + +#include "toolbox/util.h" + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/asmpart.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/methodheader.h" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/show.h" +#include "vm/jit/stacktrace.hpp" +#include "vm/jit/trace.hpp" + +#if defined(ENABLE_VMLOG) +#include +#endif + + +// FIXME +extern "C" { + +/* for raising exceptions from native methods *********************************/ + +#if !defined(ENABLE_THREADS) +java_object_t *_no_threads_exceptionptr = NULL; +#endif + + +/* exceptions_get_exception **************************************************** + + Returns the current exception pointer of the current thread. + +*******************************************************************************/ + +java_handle_t *exceptions_get_exception(void) +{ + java_object_t *o; + java_handle_t *e; +#if defined(ENABLE_THREADS) + threadobject *t; + + t = THREADOBJECT; +#endif + + /* Get the exception. */ + + LLNI_CRITICAL_START; + +#if defined(ENABLE_THREADS) + o = t->_exceptionptr; +#else + o = _no_threads_exceptionptr; +#endif + + e = LLNI_WRAP(o); + + LLNI_CRITICAL_END; + + /* Return the exception. */ + + return e; +} + + +/* exceptions_set_exception **************************************************** + + Sets the exception pointer of the current thread. + +*******************************************************************************/ + +void exceptions_set_exception(java_handle_t *e) +{ + threadobject *t; + java_object_t *o; + +#if defined(ENABLE_THREADS) + t = THREADOBJECT; +#else + t = NULL; +#endif + + /* Set the exception. */ + + LLNI_CRITICAL_START; + + o = LLNI_UNWRAP(e); + +#if !defined(NDEBUG) + if (opt_DebugExceptions) { + printf("[exceptions_set_exception : t=%p, o=%p, class=", + (void *) t, (void *) o); + class_print(o->vftbl->clazz); + printf("]\n"); + } +#endif + +#if defined(ENABLE_THREADS) + t->_exceptionptr = o; +#else + _no_threads_exceptionptr = o; +#endif + + LLNI_CRITICAL_END; +} + + +/* exceptions_clear_exception ************************************************** + + Clears the current exception pointer of the current thread. + +*******************************************************************************/ + +void exceptions_clear_exception(void) +{ + threadobject *t; + +#if defined(ENABLE_THREADS) + t = THREADOBJECT; +#else + t = NULL; +#endif + + /* Set the exception. */ + +#if !defined(NDEBUG) + if (opt_DebugExceptions) { + printf("[exceptions_clear_exception: t=%p]\n", (void *) t); + } +#endif + +#if defined(ENABLE_THREADS) + t->_exceptionptr = NULL; +#else + _no_threads_exceptionptr = NULL; +#endif +} + + +/* exceptions_get_and_clear_exception ****************************************** + + Gets the exception pointer of the current thread and clears it. + This function may return NULL. + +*******************************************************************************/ + +java_handle_t *exceptions_get_and_clear_exception(void) +{ + java_handle_t *o; + + /* Get the exception... */ + + o = exceptions_get_exception(); + + /* ...and clear the exception if it is set. */ + + if (o != NULL) + exceptions_clear_exception(); + + /* return the exception */ + + return o; +} + + +/* exceptions_abort ************************************************************ + + Prints exception to be thrown and aborts. + + IN: + classname....class name + message......exception message + +*******************************************************************************/ + +static void exceptions_abort(utf *classname, utf *message) +{ + log_println("exception thrown while VM is initializing: "); + + log_start(); + utf_display_printable_ascii_classname(classname); + + if (message != NULL) { + log_print(": "); + utf_display_printable_ascii_classname(message); + } + + log_finish(); + + VM::get_current()->abort("Aborting..."); +} + + +/* exceptions_new_class_utf **************************************************** + + Creates an exception object with the given class and initalizes it + with the given utf message. + + IN: + c ......... exception class + message ... the message as an utf * + + RETURN VALUE: + an exception pointer (in any case -- either it is the newly + created exception, or an exception thrown while trying to create + it). + +*******************************************************************************/ + +static java_handle_t *exceptions_new_class_utf(classinfo *c, utf *message) +{ + java_handle_t *s; + java_handle_t *o; + + if (VM::get_current()->is_initializing()) { + /* This can happen when global class variables are used which + are not initialized yet. */ + + if (c == NULL) + exceptions_abort(NULL, message); + else + exceptions_abort(c->name, message); + } + + s = javastring_new(message); + + if (s == NULL) + return exceptions_get_exception(); + + o = native_new_and_init_string(c, s); + + if (o == NULL) + return exceptions_get_exception(); + + return o; +} + + +/* exceptions_new_utf ********************************************************** + + Creates an exception object with the given name and initalizes it. + + IN: + classname....class name in UTF-8 + +*******************************************************************************/ + +static java_handle_t *exceptions_new_utf(utf *classname) +{ + classinfo *c; + java_handle_t *o; + + if (VM::get_current()->is_initializing()) + exceptions_abort(classname, NULL); + + c = load_class_bootstrap(classname); + + if (c == NULL) + return exceptions_get_exception(); + + o = native_new_and_init(c); + + if (o == NULL) + return exceptions_get_exception(); + + return o; +} + + +/* exceptions_new_utf_javastring *********************************************** + + Creates an exception object with the given name and initalizes it + with the given java/lang/String message. + + IN: + classname....class name in UTF-8 + message......the message as a java.lang.String + + RETURN VALUE: + an exception pointer (in any case -- either it is the newly created + exception, or an exception thrown while trying to create it). + +*******************************************************************************/ + +static java_handle_t *exceptions_new_utf_javastring(utf *classname, + java_handle_t *message) +{ + java_handle_t *o; + classinfo *c; + + if (VM::get_current()->is_initializing()) + exceptions_abort(classname, NULL); + + c = load_class_bootstrap(classname); + + if (c == NULL) + return exceptions_get_exception(); + + o = native_new_and_init_string(c, message); + + if (o == NULL) + return exceptions_get_exception(); + + return o; +} + + +/* exceptions_new_utf_utf ****************************************************** + + Creates an exception object with the given name and initalizes it + with the given utf message. + + IN: + classname....class name in UTF-8 + message......the message as an utf * + + RETURN VALUE: + an exception pointer (in any case -- either it is the newly created + exception, or an exception thrown while trying to create it). + +*******************************************************************************/ + +static java_handle_t *exceptions_new_utf_utf(utf *classname, utf *message) +{ + classinfo *c; + java_handle_t *o; + + if (VM::get_current()->is_initializing()) + exceptions_abort(classname, message); + + c = load_class_bootstrap(classname); + + if (c == NULL) + return exceptions_get_exception(); + + o = exceptions_new_class_utf(c, message); + + return o; +} + + +/* exceptions_throw_class_utf ************************************************** + + Creates an exception object with the given class, initalizes and + throws it with the given utf message. + + IN: + c ......... exception class + message ... the message as an utf * + +*******************************************************************************/ + +static void exceptions_throw_class_utf(classinfo *c, utf *message) +{ + java_handle_t *o; + + o = exceptions_new_class_utf(c, message); + + exceptions_set_exception(o); +} + + +/* exceptions_throw_utf ******************************************************** + + Creates an exception object with the given name, initalizes and + throws it. + + IN: + classname....class name in UTF-8 + +*******************************************************************************/ + +static void exceptions_throw_utf(utf *classname) +{ + java_handle_t *o; + + o = exceptions_new_utf(classname); + + if (o == NULL) + return; + + exceptions_set_exception(o); +} + + +/* exceptions_throw_utf_throwable ********************************************** + + Creates an exception object with the given name and initalizes it + with the given java/lang/Throwable exception. + + IN: + classname....class name in UTF-8 + cause........the given Throwable + +*******************************************************************************/ + +static void exceptions_throw_utf_throwable(utf *classname, + java_handle_t *cause) +{ + classinfo *c; + methodinfo *m; + + if (VM::get_current()->is_initializing()) + exceptions_abort(classname, NULL); + + java_lang_Throwable jlt(cause); + + c = load_class_bootstrap(classname); + + if (c == NULL) + return; + + /* create object */ + + java_handle_t* h = builtin_new(c); + + if (h == NULL) + return; + + /* call initializer */ + + m = class_resolveclassmethod(c, + utf_init, + utf_java_lang_Throwable__void, + NULL, + true); + + if (m == NULL) + return; + + (void) vm_call_method(m, h, jlt.get_handle()); + + exceptions_set_exception(h); +} + + +/* exceptions_throw_utf_exception ********************************************** + + Creates an exception object with the given name and initalizes it + with the given java/lang/Exception exception. + + IN: + classname....class name in UTF-8 + exception....the given Exception + +*******************************************************************************/ + +static void exceptions_throw_utf_exception(utf *classname, + java_handle_t *exception) +{ + classinfo *c; + java_handle_t *o; + methodinfo *m; + + if (VM::get_current()->is_initializing()) + exceptions_abort(classname, NULL); + + c = load_class_bootstrap(classname); + + if (c == NULL) + return; + + /* create object */ + + o = builtin_new(c); + + if (o == NULL) + return; + + /* call initializer */ + + m = class_resolveclassmethod(c, + utf_init, + utf_java_lang_Exception__V, + NULL, + true); + + if (m == NULL) + return; + + (void) vm_call_method(m, o, exception); + + exceptions_set_exception(o); +} + + +/* exceptions_throw_utf_cause ************************************************** + + Creates an exception object with the given name and initalizes it + with the given java/lang/Throwable exception with initCause. + + IN: + classname....class name in UTF-8 + cause........the given Throwable + +*******************************************************************************/ + +static void exceptions_throw_utf_cause(utf *classname, java_handle_t *cause) +{ + if (VM::get_current()->is_initializing()) + exceptions_abort(classname, NULL); + + java_lang_Throwable jltcause(cause); + + classinfo* c = load_class_bootstrap(classname); + + if (c == NULL) + return; + + /* create object */ + + java_handle_t* h = builtin_new(c); + + if (h == NULL) + return; + + /* call initializer */ + + methodinfo* m = class_resolveclassmethod(c, + utf_init, + utf_java_lang_String__void, + NULL, + true); + + if (m == NULL) + return; + + (void) vm_call_method(m, h, jltcause.get_detailMessage()); + + /* call initCause */ + + m = class_resolveclassmethod(c, + utf_initCause, + utf_java_lang_Throwable__java_lang_Throwable, + NULL, + true); + + if (m == NULL) + return; + + (void) vm_call_method(m, h, jltcause.get_handle()); + + exceptions_set_exception(h); +} + + +/* exceptions_throw_utf_utf **************************************************** + + Creates an exception object with the given name, initalizes and + throws it with the given utf message. + + IN: + classname....class name in UTF-8 + message......the message as an utf * + +*******************************************************************************/ + +static void exceptions_throw_utf_utf(utf *classname, utf *message) +{ + java_handle_t *o; + + o = exceptions_new_utf_utf(classname, message); + + exceptions_set_exception(o); +} + + +/* exceptions_new_abstractmethoderror **************************************** + + Generates a java.lang.AbstractMethodError for the VM. + +*******************************************************************************/ + +java_handle_t *exceptions_new_abstractmethoderror(void) +{ + java_handle_t *o; + + o = exceptions_new_utf(utf_java_lang_AbstractMethodError); + + return o; +} + + +/* exceptions_new_error ******************************************************** + + Generates a java.lang.Error for the VM. + +*******************************************************************************/ + +#if defined(ENABLE_JAVAME_CLDC1_1) +static java_handle_t *exceptions_new_error(utf *message) +{ + java_handle_t *o; + + o = exceptions_new_utf_utf(utf_java_lang_Error, message); + + return o; +} +#endif + + +/* exceptions_asm_new_abstractmethoderror ************************************** + + Generates a java.lang.AbstractMethodError for + asm_abstractmethoderror. + +*******************************************************************************/ + +java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra) +{ + stackframeinfo_t sfi; + java_handle_t *e; + java_object_t *o; + + /* Fill and add a stackframeinfo (XPC is equal to RA). */ + + stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra); + + /* create the exception */ + +#if defined(ENABLE_JAVASE) + e = exceptions_new_abstractmethoderror(); +#else + e = exceptions_new_error(utf_java_lang_AbstractMethodError); +#endif + + /* Remove the stackframeinfo. */ + + stacktrace_stackframeinfo_remove(&sfi); + + /* unwrap the exception */ + /* ATTENTION: do the this _after_ the stackframeinfo was removed */ + + o = LLNI_UNWRAP(e); + + return o; +} + + +/* exceptions_new_arraystoreexception ****************************************** + + Generates a java.lang.ArrayStoreException for the VM. + +*******************************************************************************/ + +java_handle_t *exceptions_new_arraystoreexception(void) +{ + java_handle_t *o; + + o = exceptions_new_utf(utf_java_lang_ArrayStoreException); + + return o; +} + + +/* exceptions_throw_abstractmethoderror **************************************** + + Generates and throws a java.lang.AbstractMethodError for the VM. + +*******************************************************************************/ + +void exceptions_throw_abstractmethoderror(void) +{ + exceptions_throw_utf(utf_java_lang_AbstractMethodError); +} + + +/* exceptions_throw_classcircularityerror ************************************** + + Generates and throws a java.lang.ClassCircularityError for the + classloader. + + IN: + c....the class in which the error was found + +*******************************************************************************/ + +void exceptions_throw_classcircularityerror(classinfo *c) +{ + exceptions_throw_utf_utf(utf_java_lang_ClassCircularityError, c->name); +} + + +/* exceptions_throw_classformaterror ******************************************* + + Generates and throws a java.lang.ClassFormatError for the VM. + + IN: + c............the class in which the error was found + message......UTF-8 format string + +*******************************************************************************/ + +void exceptions_throw_classformaterror(classinfo *c, const char *message, ...) +{ + char *msg; + s4 msglen; + va_list ap; + utf *u; + + /* calculate message length */ + + msglen = 0; + + if (c != NULL) + msglen += utf_bytes(c->name) + strlen(" ("); + + va_start(ap, message); + msglen += get_variable_message_length(message, ap); + va_end(ap); + + if (c != NULL) + msglen += strlen(")"); + + msglen += strlen("0"); + + /* allocate a buffer */ + + msg = MNEW(char, msglen); + + /* print message into allocated buffer */ + + if (c != NULL) { + utf_copy_classname(msg, c->name); + strcat(msg, " ("); + } + + va_start(ap, message); + vsprintf(msg + strlen(msg), message, ap); + va_end(ap); + + if (c != NULL) + strcat(msg, ")"); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + /* throw exception */ + + exceptions_throw_utf_utf(utf_java_lang_ClassFormatError, u); +} + + +/* exceptions_throw_classnotfoundexception ************************************* + + Generates and throws a java.lang.ClassNotFoundException for the + VM. + + IN: + name.........name of the class not found as a utf * + +*******************************************************************************/ + +void exceptions_throw_classnotfoundexception(utf *name) +{ + exceptions_throw_class_utf(class_java_lang_ClassNotFoundException, name); +} + + +/* exceptions_throw_noclassdeffounderror *************************************** + + Generates and throws a java.lang.NoClassDefFoundError. + + IN: + name.........name of the class not found as a utf * + +*******************************************************************************/ + +void exceptions_throw_noclassdeffounderror(utf *name) +{ + exceptions_throw_utf_utf(utf_java_lang_NoClassDefFoundError, name); +} + + +/* exceptions_throw_noclassdeffounderror_cause ********************************* + + Generates and throws a java.lang.NoClassDefFoundError with the + given cause. + +*******************************************************************************/ + +void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause) +{ + exceptions_throw_utf_cause(utf_java_lang_NoClassDefFoundError, cause); +} + + +/* exceptions_throw_noclassdeffounderror_wrong_name **************************** + + Generates and throws a java.lang.NoClassDefFoundError with a + specific message: + + IN: + name.........name of the class not found as a utf * + +*******************************************************************************/ + +void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name) +{ + char *msg; + s4 msglen; + utf *u; + + msglen = utf_bytes(c->name) + strlen(" (wrong name: ") + + utf_bytes(name) + strlen(")") + strlen("0"); + + msg = MNEW(char, msglen); + + utf_copy_classname(msg, c->name); + strcat(msg, " (wrong name: "); + utf_cat_classname(msg, name); + strcat(msg, ")"); + + u = utf_new_char(msg); + + MFREE(msg, char, msglen); + + exceptions_throw_noclassdeffounderror(u); +} + + +/* exceptions_throw_exceptionininitializererror ******************************** + + Generates and throws a java.lang.ExceptionInInitializerError for + the VM. + + IN: + cause......cause exception object + +*******************************************************************************/ + +void exceptions_throw_exceptionininitializererror(java_handle_t *cause) +{ + exceptions_throw_utf_throwable(utf_java_lang_ExceptionInInitializerError, + cause); +} + + +/* exceptions_throw_incompatibleclasschangeerror ******************************* + + Generates and throws a java.lang.IncompatibleClassChangeError for + the VM. + + IN: + message......UTF-8 message format string + +*******************************************************************************/ + +void exceptions_throw_incompatibleclasschangeerror(classinfo *c, const char *message) +{ + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + msglen = utf_bytes(c->name) + strlen(message) + strlen("0"); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + utf_copy_classname(msg, c->name); + strcat(msg, message); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + /* throw exception */ + + exceptions_throw_utf_utf(utf_java_lang_IncompatibleClassChangeError, u); +} + + +/* exceptions_throw_instantiationerror ***************************************** + + Generates and throws a java.lang.InstantiationError for the VM. + +*******************************************************************************/ + +void exceptions_throw_instantiationerror(classinfo *c) +{ + exceptions_throw_utf_utf(utf_java_lang_InstantiationError, c->name); +} + + +/* exceptions_throw_internalerror ********************************************** + + Generates and throws a java.lang.InternalError for the VM. + + IN: + message......UTF-8 message format string + +*******************************************************************************/ + +void exceptions_throw_internalerror(const char *message, ...) +{ + va_list ap; + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + va_start(ap, message); + msglen = get_variable_message_length(message, ap); + va_end(ap); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + /* generate message */ + + va_start(ap, message); + vsprintf(msg, message, ap); + va_end(ap); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + /* throw exception */ + + exceptions_throw_utf_utf(utf_java_lang_InternalError, u); +} + + +/* exceptions_throw_linkageerror *********************************************** + + Generates and throws java.lang.LinkageError with an error message. + + IN: + message......UTF-8 message + c............class related to the error. If this is != NULL + the name of c is appended to the error message. + +*******************************************************************************/ + +void exceptions_throw_linkageerror(const char *message, classinfo *c) +{ + utf *u; + char *msg; + int len; + + /* calculate exception message length */ + + len = strlen(message) + 1; + + if (c != NULL) + len += utf_bytes(c->name); + + /* allocate memory */ + + msg = MNEW(char, len); + + /* generate message */ + + strcpy(msg, message); + + if (c != NULL) + utf_cat_classname(msg, c->name); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, len); + + exceptions_throw_utf_utf(utf_java_lang_LinkageError, u); +} + + +/* exceptions_throw_nosuchfielderror ******************************************* + + Generates and throws a java.lang.NoSuchFieldError with an error + message. + + IN: + c............class in which the field was not found + name.........name of the field + +*******************************************************************************/ + +void exceptions_throw_nosuchfielderror(classinfo *c, utf *name) +{ + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) + strlen("0"); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + /* generate message */ + + utf_copy_classname(msg, c->name); + strcat(msg, "."); + utf_cat(msg, name); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + exceptions_throw_utf_utf(utf_java_lang_NoSuchFieldError, u); +} + + +/* exceptions_throw_nosuchmethoderror ****************************************** + + Generates and throws a java.lang.NoSuchMethodError with an error + message. + + IN: + c............class in which the method was not found + name.........name of the method + desc.........descriptor of the method + +*******************************************************************************/ + +void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc) +{ + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + msglen = utf_bytes(c->name) + strlen(".") + utf_bytes(name) + + utf_bytes(desc) + strlen("0"); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + /* generate message */ + + utf_copy_classname(msg, c->name); + strcat(msg, "."); + utf_cat(msg, name); + utf_cat(msg, desc); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + +#if defined(ENABLE_JAVASE) + exceptions_throw_utf_utf(utf_java_lang_NoSuchMethodError, u); +#else + exceptions_throw_utf_utf(utf_java_lang_Error, u); +#endif +} + + +/* exceptions_throw_outofmemoryerror ******************************************* + + Generates and throws an java.lang.OutOfMemoryError for the VM. + +*******************************************************************************/ + +void exceptions_throw_outofmemoryerror(void) +{ + exceptions_throw_utf(utf_java_lang_OutOfMemoryError); +} + + +/* exceptions_throw_unsatisfiedlinkerror *************************************** + + Generates and throws a java.lang.UnsatisfiedLinkError for the + classloader. + + IN: + name......UTF-8 name string + +*******************************************************************************/ + +void exceptions_throw_unsatisfiedlinkerror(utf *name) +{ +#if defined(ENABLE_JAVASE) + exceptions_throw_utf_utf(utf_java_lang_UnsatisfiedLinkError, name); +#else + exceptions_throw_utf_utf(utf_java_lang_Error, name); +#endif +} + + +/* exceptions_throw_unsupportedclassversionerror ******************************* + + Generates and throws a java.lang.UnsupportedClassVersionError for + the classloader. + + IN: + c............class in which the method was not found + message......UTF-8 format string + +*******************************************************************************/ + +void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi) +{ + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + msglen = + utf_bytes(c->name) + + strlen(" (Unsupported major.minor version 00.0)") + + strlen("0"); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + /* generate message */ + + utf_copy_classname(msg, c->name); + sprintf(msg + strlen(msg), " (Unsupported major.minor version %d.%d)", + ma, mi); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + /* throw exception */ + + exceptions_throw_utf_utf(utf_java_lang_UnsupportedClassVersionError, u); +} + + +/* exceptions_throw_verifyerror ************************************************ + + Generates and throws a java.lang.VerifyError for the JIT compiler. + + IN: + m............method in which the error was found + message......UTF-8 format string + +*******************************************************************************/ + +void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...) +{ + va_list ap; + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + msglen = 0; + + if (m != NULL) + msglen = + strlen("(class: ") + utf_bytes(m->clazz->name) + + strlen(", method: ") + utf_bytes(m->name) + + strlen(" signature: ") + utf_bytes(m->descriptor) + + strlen(") ") + strlen("0"); + + va_start(ap, message); + msglen += get_variable_message_length(message, ap); + va_end(ap); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + /* generate message */ + + if (m != NULL) { + strcpy(msg, "(class: "); + utf_cat_classname(msg, m->clazz->name); + strcat(msg, ", method: "); + utf_cat(msg, m->name); + strcat(msg, " signature: "); + utf_cat(msg, m->descriptor); + strcat(msg, ") "); + } + + va_start(ap, message); + vsprintf(msg + strlen(msg), message, ap); + va_end(ap); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + /* throw exception */ + + exceptions_throw_utf_utf(utf_java_lang_VerifyError, u); +} + + +/* exceptions_throw_verifyerror_for_stack ************************************** + + throws a java.lang.VerifyError for an invalid stack slot type + + IN: + m............method in which the error was found + type.........the expected type + + RETURN VALUE: + an exception pointer (in any case -- either it is the newly created + exception, or an exception thrown while trying to create it). + +*******************************************************************************/ + +void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type) +{ + char *msg; + s4 msglen; + utf *u; + + /* calculate exception message length */ + + msglen = 0; + + if (m != NULL) + msglen = strlen("(class: ") + utf_bytes(m->clazz->name) + + strlen(", method: ") + utf_bytes(m->name) + + strlen(" signature: ") + utf_bytes(m->descriptor) + + strlen(") Expecting to find longest-------typename on stack") + + strlen("0"); + + /* allocate memory */ + + msg = MNEW(char, msglen); + + /* generate message */ + + if (m != NULL) { + strcpy(msg, "(class: "); + utf_cat_classname(msg, m->clazz->name); + strcat(msg, ", method: "); + utf_cat(msg, m->name); + strcat(msg, " signature: "); + utf_cat(msg, m->descriptor); + strcat(msg, ") "); + } + else { + msg[0] = 0; + } + + strcat(msg, "Expecting to find "); + + const char *name; + + switch (type) { + case TYPE_INT: name = "integer"; break; + case TYPE_LNG: name = "long"; break; + case TYPE_FLT: name = "float"; break; + case TYPE_DBL: name = "double"; break; + case TYPE_ADR: name = "object/array"; break; + case TYPE_RET: name = "returnAddress"; break; + default: name = ""; assert(0); break; + } + + strcat(msg, name); + strcat(msg, " on stack"); + + u = utf_new_char(msg); + + /* free memory */ + + MFREE(msg, char, msglen); + + /* throw exception */ + + exceptions_throw_utf_utf(utf_java_lang_VerifyError, u); +} + + +/* exceptions_new_arithmeticexception ****************************************** + + Generates a java.lang.ArithmeticException for the JIT compiler. + +*******************************************************************************/ + +java_handle_t *exceptions_new_arithmeticexception(void) +{ + java_handle_t *o; + + o = exceptions_new_utf_utf(utf_java_lang_ArithmeticException, + utf_division_by_zero); + + return o; +} + + +/* exceptions_new_arrayindexoutofboundsexception ******************************* + + Generates a java.lang.ArrayIndexOutOfBoundsException for the VM + system. + +*******************************************************************************/ + +java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index) +{ + java_handle_t *o; + methodinfo *m; + java_handle_t *s; + + /* convert the index into a String, like Sun does */ + + m = class_resolveclassmethod(class_java_lang_String, + utf_new_char("valueOf"), + utf_new_char("(I)Ljava/lang/String;"), + class_java_lang_Object, + true); + + if (m == NULL) + return exceptions_get_exception(); + + s = vm_call_method(m, NULL, index); + + if (s == NULL) + return exceptions_get_exception(); + + o = exceptions_new_utf_javastring(utf_java_lang_ArrayIndexOutOfBoundsException, + s); + + if (o == NULL) + return exceptions_get_exception(); + + return o; +} + + +/* exceptions_throw_arrayindexoutofboundsexception ***************************** + + Generates and throws a java.lang.ArrayIndexOutOfBoundsException for + the VM. + +*******************************************************************************/ + +void exceptions_throw_arrayindexoutofboundsexception(void) +{ + exceptions_throw_utf(utf_java_lang_ArrayIndexOutOfBoundsException); +} + + +/* exceptions_throw_arraystoreexception **************************************** + + Generates and throws a java.lang.ArrayStoreException for the VM. + +*******************************************************************************/ + +void exceptions_throw_arraystoreexception(void) +{ + exceptions_throw_utf(utf_java_lang_ArrayStoreException); +} + + +/* exceptions_new_classcastexception ******************************************* + + Generates a java.lang.ClassCastException for the JIT compiler. + +*******************************************************************************/ + +java_handle_t *exceptions_new_classcastexception(java_handle_t *o) +{ + java_handle_t *e; + classinfo *c; + utf *classname; + + LLNI_class_get(o, c); + + classname = c->name; + + e = exceptions_new_utf_utf(utf_java_lang_ClassCastException, classname); + + return e; +} + + +/* exceptions_throw_clonenotsupportedexception ********************************* + + Generates and throws a java.lang.CloneNotSupportedException for the + VM. + +*******************************************************************************/ + +void exceptions_throw_clonenotsupportedexception(void) +{ + exceptions_throw_utf(utf_java_lang_CloneNotSupportedException); +} + + +/* exceptions_throw_illegalaccessexception ************************************* + + Generates and throws a java.lang.IllegalAccessException for the VM. + +*******************************************************************************/ + +void exceptions_throw_illegalaccessexception(utf *message) +{ + exceptions_throw_utf_utf(utf_java_lang_IllegalAccessException, message); +} + + +/* exceptions_throw_illegalargumentexception *********************************** + + Generates and throws a java.lang.IllegalArgumentException for the + VM. + +*******************************************************************************/ + +void exceptions_throw_illegalargumentexception(void) +{ + exceptions_throw_utf(utf_java_lang_IllegalArgumentException); +} + + +/* exceptions_throw_illegalmonitorstateexception ******************************* + + Generates and throws a java.lang.IllegalMonitorStateException for + the VM. + +*******************************************************************************/ + +void exceptions_throw_illegalmonitorstateexception(void) +{ + exceptions_throw_utf(utf_java_lang_IllegalMonitorStateException); +} + + +/* exceptions_throw_instantiationexception ************************************* + + Generates and throws a java.lang.InstantiationException for the VM. + +*******************************************************************************/ + +void exceptions_throw_instantiationexception(classinfo *c) +{ + exceptions_throw_utf_utf(utf_java_lang_InstantiationException, c->name); +} + + +/* exceptions_throw_interruptedexception *************************************** + + Generates and throws a java.lang.InterruptedException for the VM. + +*******************************************************************************/ + +void exceptions_throw_interruptedexception(void) +{ + exceptions_throw_utf(utf_java_lang_InterruptedException); +} + + +/* exceptions_throw_invocationtargetexception ********************************** + + Generates and throws a java.lang.reflect.InvocationTargetException + for the VM. + + IN: + cause......cause exception object + +*******************************************************************************/ + +void exceptions_throw_invocationtargetexception(java_handle_t *cause) +{ + exceptions_throw_utf_throwable(utf_java_lang_reflect_InvocationTargetException, + cause); +} + + +/* exceptions_throw_negativearraysizeexception ********************************* + + Generates and throws a java.lang.NegativeArraySizeException for the + VM. + +*******************************************************************************/ + +void exceptions_throw_negativearraysizeexception(void) +{ + exceptions_throw_utf(utf_java_lang_NegativeArraySizeException); +} + + +/* exceptions_new_nullpointerexception ***************************************** + + Generates a java.lang.NullPointerException for the VM system. + +*******************************************************************************/ + +java_handle_t *exceptions_new_nullpointerexception(void) +{ + java_handle_t *o; + + o = exceptions_new_utf(utf_java_lang_NullPointerException); + + return o; +} + + +/* exceptions_throw_nullpointerexception *************************************** + + Generates a java.lang.NullPointerException for the VM system and + throw it in the VM system. + +*******************************************************************************/ + +void exceptions_throw_nullpointerexception(void) +{ + exceptions_throw_utf(utf_java_lang_NullPointerException); +} + + +/* exceptions_throw_privilegedactionexception ********************************** + + Generates and throws a java.security.PrivilegedActionException. + +*******************************************************************************/ + +void exceptions_throw_privilegedactionexception(java_handle_t *exception) +{ + exceptions_throw_utf_exception(utf_java_security_PrivilegedActionException, + exception); +} + + +/* exceptions_throw_stringindexoutofboundsexception **************************** + + Generates and throws a java.lang.StringIndexOutOfBoundsException + for the VM. + +*******************************************************************************/ + +void exceptions_throw_stringindexoutofboundsexception(void) +{ + exceptions_throw_utf(utf_java_lang_StringIndexOutOfBoundsException); +} + + +/* exceptions_fillinstacktrace ************************************************* + + Calls the fillInStackTrace-method of the currently thrown + exception. + +*******************************************************************************/ + +java_handle_t *exceptions_fillinstacktrace(void) +{ + java_handle_t *o; + classinfo *c; + methodinfo *m; + + /* get exception */ + + o = exceptions_get_and_clear_exception(); + + assert(o); + + /* resolve methodinfo pointer from exception object */ + + LLNI_class_get(o, c); + +#if defined(ENABLE_JAVASE) + m = class_resolvemethod(c, + utf_fillInStackTrace, + utf_void__java_lang_Throwable); +#elif defined(ENABLE_JAVAME_CLDC1_1) + m = class_resolvemethod(c, + utf_fillInStackTrace, + utf_void__void); +#else +#error IMPLEMENT ME! +#endif + + /* call function */ + + (void) vm_call_method(m, o); + + /* return exception object */ + + return o; +} + + +/* exceptions_handle_exception ************************************************* + + Try to find an exception handler for the given exception and return it. + If no handler is found, exit the monitor of the method (if any) + and return NULL. + + IN: + xptr.........the exception object + xpc..........PC of where the exception was thrown + pv...........Procedure Value of the current method + sp...........current stack pointer + + RETURN VALUE: + the address of the first matching exception handler, or + NULL if no handler was found + +*******************************************************************************/ + +#if defined(ENABLE_JIT) +void *exceptions_handle_exception(java_object_t *xptro, void *xpc, void *pv, void *sp) +{ + stackframeinfo_t sfi; + java_handle_t *xptr; + methodinfo *m; + codeinfo *code; + exceptiontable_t *et; + exceptiontable_entry_t *ete; + s4 i; + classref_or_classinfo cr; + classinfo *c; +#if defined(ENABLE_THREADS) + java_object_t *o; +#endif + void *result; + +#ifdef __S390__ + /* Addresses are 31 bit integers */ +# define ADDR_MASK(x) (void *) ((uintptr_t) (x) & 0x7FFFFFFF) +#else +# define ADDR_MASK(x) (x) +#endif + + xptr = LLNI_WRAP(xptro); + xpc = ADDR_MASK(xpc); + + /* Fill and add a stackframeinfo (XPC is equal to RA). */ + + stacktrace_stackframeinfo_add(&sfi, pv, sp, xpc, xpc); + + result = NULL; + + /* Get the codeinfo for the current method. */ + + code = code_get_codeinfo_for_pv(pv); + + /* Get the methodinfo pointer from the codeinfo pointer. For + asm_vm_call_method the codeinfo pointer is NULL and we simply + can return the proper exception handler. */ + + if (code == NULL) { + result = (void *) (uintptr_t) &asm_vm_call_method_exception_handler; + goto exceptions_handle_exception_return; + } + + m = code->m; + +#if !defined(NDEBUG) + /* print exception trace */ + + if (opt_TraceExceptions) + trace_exception(LLNI_DIRECT(xptr), m, xpc); + +# if defined(ENABLE_VMLOG) + vmlog_cacao_throw(xptr); +# endif +#endif + + /* Get the exception table. */ + + et = code->exceptiontable; + + if (et != NULL) { + /* Iterate over all exception table entries. */ + + ete = et->entries; + + for (i = 0; i < et->length; i++, ete++) { + /* is the xpc is the current catch range */ + + if ((ADDR_MASK(ete->startpc) <= xpc) && (xpc < ADDR_MASK(ete->endpc))) { + cr = ete->catchtype; + + /* NULL catches everything */ + + if (cr.any == NULL) { +#if !defined(NDEBUG) + /* Print stacktrace of exception when caught. */ + +# if defined(ENABLE_VMLOG) + vmlog_cacao_catch(xptr); +# endif + + if (opt_TraceExceptions) { + exceptions_print_exception(xptr); + stacktrace_print_exception(xptr); + } +#endif + + result = ete->handlerpc; + goto exceptions_handle_exception_return; + } + + /* resolve or load/link the exception class */ + + if (IS_CLASSREF(cr)) { + /* The exception class reference is unresolved. */ + /* We have to do _eager_ resolving here. While the + class of the exception object is guaranteed to be + loaded, it may well have been loaded by a different + loader than the defining loader of m's class, which + is the one we must use to resolve the catch + class. Thus lazy resolving might fail, even if the + result of the resolution would be an already loaded + class. */ + + c = resolve_classref_eager(cr.ref); + + if (c == NULL) { + /* Exception resolving the exception class, argh! */ + goto exceptions_handle_exception_return; + } + + /* Ok, we resolved it. Enter it in the table, so we + don't have to do this again. */ + /* XXX this write should be atomic. Is it? */ + + ete->catchtype.cls = c; + } + else { + c = cr.cls; + + /* XXX I don't think this case can ever happen. -Edwin */ + if (!(c->state & CLASS_LOADED)) + /* use the methods' classloader */ + if (!load_class_from_classloader(c->name, + m->clazz->classloader)) + goto exceptions_handle_exception_return; + + /* XXX I think, if it is not linked, we can be sure + that the exception object is no (indirect) instance + of it, no? -Edwin */ + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + goto exceptions_handle_exception_return; + } + + /* is the thrown exception an instance of the catch class? */ + + if (builtin_instanceof(xptr, c)) { +#if !defined(NDEBUG) + /* Print stacktrace of exception when caught. */ + +# if defined(ENABLE_VMLOG) + vmlog_cacao_catch(xptr); +# endif + + if (opt_TraceExceptions) { + exceptions_print_exception(xptr); + stacktrace_print_exception(xptr); + } +#endif + + result = ete->handlerpc; + goto exceptions_handle_exception_return; + } + } + } + } + +#if defined(ENABLE_THREADS) + /* Is this method realization synchronized? */ + + if (code_is_synchronized(code)) { + /* Get synchronization object. */ + + o = *((java_object_t **) (((uintptr_t) sp) + code->synchronizedoffset)); + + assert(o != NULL); + + lock_monitor_exit(LLNI_QUICKWRAP(o)); + } +#endif + + /* none of the exceptions catch this one */ + +#if !defined(NDEBUG) +# if defined(ENABLE_VMLOG) + vmlog_cacao_unwnd_method(m); +# endif + +# if defined(ENABLE_DEBUG_FILTER) + if (show_filters_test_verbosecall_exit(m)) { +# endif + + /* outdent the log message */ + + if (opt_verbosecall) { + if (TRACEJAVACALLINDENT) + TRACEJAVACALLINDENT--; + else + log_text("exceptions_handle_exception: WARNING: unmatched unindent"); + } + +# if defined(ENABLE_DEBUG_FILTER) + } +# endif +#endif /* !defined(NDEBUG) */ + + result = NULL; + +exceptions_handle_exception_return: + + /* Remove the stackframeinfo. */ + + stacktrace_stackframeinfo_remove(&sfi); + + return result; +} +#endif /* defined(ENABLE_JIT) */ + + +/* exceptions_print_exception ************************************************** + + Prints an exception, the detail message and the cause, if + available, with CACAO internal functions to stdout. + +*******************************************************************************/ + +void exceptions_print_exception(java_handle_t *xptr) +{ + java_lang_Throwable jlt(xptr); + + if (jlt.is_null()) { + puts("NULL\n"); + return; + } + +#if defined(ENABLE_JAVASE) + java_lang_Throwable jltcause(jlt.get_cause()); +#endif + + /* print the root exception */ + + classinfo* c = jlt.get_Class(); + utf_display_printable_ascii_classname(c->name); + + java_lang_String jls(jlt.get_detailMessage()); + + if (!jls.is_null()) { + utf* u = javastring_toutf(jls.get_handle(), false); + + printf(": "); + utf_display_printable_ascii(u); + } + + putc('\n', stdout); + +#if defined(ENABLE_JAVASE) + /* print the cause if available */ + + // FIXME cause != t compare with operator override. + if ((!jltcause.is_null()) && (jltcause.get_handle() != jlt.get_handle())) { + printf("Caused by: "); + + c = jltcause.get_Class(); + utf_display_printable_ascii_classname(c->name); + + java_lang_String jlscause(jlt.get_detailMessage()); + + if (jlscause.get_handle() != NULL) { + utf* u = javastring_toutf(jlscause.get_handle(), false); + + printf(": "); + utf_display_printable_ascii(u); + } + + putc('\n', stdout); + } +#endif +} + + +/* exceptions_print_current_exception ****************************************** + + Prints the current pending exception, the detail message and the + cause, if available, with CACAO internal functions to stdout. + +*******************************************************************************/ + +void exceptions_print_current_exception(void) +{ + java_handle_t *o; + + o = exceptions_get_exception(); + + exceptions_print_exception(o); +} + + +/* exceptions_print_stacktrace ************************************************* + + Prints a pending exception with Throwable.printStackTrace(). If + there happens an exception during printStackTrace(), we print the + thrown exception and the original one. + + NOTE: This function calls Java code. + +*******************************************************************************/ + +void exceptions_print_stacktrace(void) +{ + java_handle_t *e; + java_handle_t *ne; + classinfo *c; + methodinfo *m; + +#if defined(ENABLE_THREADS) + threadobject *t; + java_lang_Thread *to; +#endif + + /* Get and clear exception because we are calling Java code + again. */ + + e = exceptions_get_and_clear_exception(); + + if (e == NULL) + return; + +#if 0 + /* FIXME Enable me. */ + if (builtin_instanceof(e, class_java_lang_ThreadDeath)) { + /* Don't print anything if we are being killed. */ + } + else +#endif + { + /* Get the exception class. */ + + LLNI_class_get(e, c); + + /* Find the printStackTrace() method. */ + + m = class_resolveclassmethod(c, + utf_printStackTrace, + utf_void__void, + class_java_lang_Object, + false); + + if (m == NULL) + VM::get_current()->abort("exceptions_print_stacktrace: printStackTrace()V not found"); + + /* Print message. */ + + fprintf(stderr, "Exception "); + +#if defined(ENABLE_THREADS) + /* Print thread name. We get the thread here explicitly as we + need it afterwards. */ + + t = thread_get_current(); + to = (java_lang_Thread *) thread_get_object(t); + + if (to != NULL) { + fprintf(stderr, "in thread \""); + thread_fprint_name(t, stderr); + fprintf(stderr, "\" "); + } +#endif + + /* Print the stacktrace. */ + + if (builtin_instanceof(e, class_java_lang_Throwable)) { + (void) vm_call_method(m, e); + + /* If this happens we are EXTREMLY out of memory or have a + serious problem while printStackTrace. But may be + another exception, so print it. */ + + ne = exceptions_get_exception(); + + if (ne != NULL) { + fprintf(stderr, "Exception while printStackTrace(): "); + + /* Print the current exception. */ + + exceptions_print_exception(ne); + stacktrace_print_exception(ne); + + /* Now print the original exception. */ + + fprintf(stderr, "Original exception was: "); + exceptions_print_exception(e); + stacktrace_print_exception(e); + } + } + else { + fprintf(stderr, ". Uncaught exception of type "); +#if !defined(NDEBUG) + /* FIXME This prints to stdout. */ + class_print(c); +#else + fprintf(stderr, "UNKNOWN"); +#endif + fprintf(stderr, "."); + } + + fflush(stderr); + } +} + +} // extern "C" + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/exceptions.h b/src/vm/exceptions.h deleted file mode 100644 index 1aea66040..000000000 --- a/src/vm/exceptions.h +++ /dev/null @@ -1,116 +0,0 @@ -/* src/vm/exceptions.h - exception related functions prototypes - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _EXCEPTIONS_H -#define _EXCEPTIONS_H - -#include "config.h" -#include "vm/types.h" - -#include "vm/global.h" - -#include "vmcore/references.h" -#include "vmcore/method.h" - - -/* function prototypes ********************************************************/ - -java_handle_t *exceptions_get_exception(void); -void exceptions_set_exception(java_handle_t *o); -void exceptions_clear_exception(void); -java_handle_t *exceptions_get_and_clear_exception(void); - - -/* functions to generate compiler exceptions */ - -java_handle_t *exceptions_new_abstractmethoderror(void); -java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra); -java_handle_t *exceptions_new_arraystoreexception(void); - -void exceptions_throw_abstractmethoderror(void); -void exceptions_throw_classcircularityerror(classinfo *c); -void exceptions_throw_classformaterror(classinfo *c, const char *message, ...); -void exceptions_throw_classnotfoundexception(utf *name); -void exceptions_throw_noclassdeffounderror(utf *name); -void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause); -void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name); -void exceptions_throw_linkageerror(const char *message, classinfo *c); -void exceptions_throw_nosuchfielderror(classinfo *c, utf *name); -void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc); -void exceptions_throw_exceptionininitializererror(java_handle_t *cause); -void exceptions_throw_incompatibleclasschangeerror(classinfo *c, - const char *message); -void exceptions_throw_instantiationerror(classinfo *c); -void exceptions_throw_internalerror(const char *message, ...); -void exceptions_throw_outofmemoryerror(void); -void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...); -void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type); -void exceptions_throw_unsatisfiedlinkerror(utf *name); -void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi); - -java_handle_t *exceptions_new_arithmeticexception(void); - -java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index); -void exceptions_throw_arrayindexoutofboundsexception(void); -void exceptions_throw_arraystoreexception(void); - -java_handle_t *exceptions_new_classcastexception(java_handle_t *o); - -void exceptions_throw_clonenotsupportedexception(void); -void exceptions_throw_illegalaccessexception(utf *message); -void exceptions_throw_illegalargumentexception(void); -void exceptions_throw_illegalmonitorstateexception(void); -void exceptions_throw_interruptedexception(void); -void exceptions_throw_instantiationexception(classinfo *c); -void exceptions_throw_invocationtargetexception(java_handle_t *cause); -void exceptions_throw_negativearraysizeexception(void); - -java_handle_t *exceptions_new_nullpointerexception(void); -void exceptions_throw_nullpointerexception(void); -void exceptions_throw_privilegedactionexception(java_handle_t *cause); -void exceptions_throw_stringindexoutofboundsexception(void); - -java_handle_t *exceptions_fillinstacktrace(void); - -void exceptions_print_exception(java_handle_t *xptr); -void exceptions_print_current_exception(void); -void exceptions_print_stacktrace(void); - -#endif /* _EXCEPTIONS_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/exceptions.hpp b/src/vm/exceptions.hpp new file mode 100644 index 000000000..924679b7d --- /dev/null +++ b/src/vm/exceptions.hpp @@ -0,0 +1,123 @@ +/* src/vm/exceptions.hpp - exception related functions prototypes + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _EXCEPTIONS_HPP +#define _EXCEPTIONS_HPP + +#include "config.h" +#include "vm/types.h" + +#include "vm/global.h" +#include "vm/references.h" +#include "vm/method.h" + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +java_handle_t *exceptions_get_exception(void); +void exceptions_set_exception(java_handle_t *o); +void exceptions_clear_exception(void); +java_handle_t *exceptions_get_and_clear_exception(void); + + +/* functions to generate compiler exceptions */ + +java_handle_t *exceptions_new_abstractmethoderror(void); +java_object_t *exceptions_asm_new_abstractmethoderror(u1 *sp, u1 *ra); +java_handle_t *exceptions_new_arraystoreexception(void); + +void exceptions_throw_abstractmethoderror(void); +void exceptions_throw_classcircularityerror(classinfo *c); +void exceptions_throw_classformaterror(classinfo *c, const char *message, ...); +void exceptions_throw_classnotfoundexception(utf *name); +void exceptions_throw_noclassdeffounderror(utf *name); +void exceptions_throw_noclassdeffounderror_cause(java_handle_t *cause); +void exceptions_throw_noclassdeffounderror_wrong_name(classinfo *c, utf *name); +void exceptions_throw_linkageerror(const char *message, classinfo *c); +void exceptions_throw_nosuchfielderror(classinfo *c, utf *name); +void exceptions_throw_nosuchmethoderror(classinfo *c, utf *name, utf *desc); +void exceptions_throw_exceptionininitializererror(java_handle_t *cause); +void exceptions_throw_incompatibleclasschangeerror(classinfo *c, + const char *message); +void exceptions_throw_instantiationerror(classinfo *c); +void exceptions_throw_internalerror(const char *message, ...); +void exceptions_throw_outofmemoryerror(void); +void exceptions_throw_verifyerror(methodinfo *m, const char *message, ...); +void exceptions_throw_verifyerror_for_stack(methodinfo *m, int type); +void exceptions_throw_unsatisfiedlinkerror(utf *name); +void exceptions_throw_unsupportedclassversionerror(classinfo *c, u4 ma, u4 mi); + +java_handle_t *exceptions_new_arithmeticexception(void); + +java_handle_t *exceptions_new_arrayindexoutofboundsexception(s4 index); +void exceptions_throw_arrayindexoutofboundsexception(void); +void exceptions_throw_arraystoreexception(void); + +java_handle_t *exceptions_new_classcastexception(java_handle_t *o); + +void exceptions_throw_clonenotsupportedexception(void); +void exceptions_throw_illegalaccessexception(utf *message); +void exceptions_throw_illegalargumentexception(void); +void exceptions_throw_illegalmonitorstateexception(void); +void exceptions_throw_interruptedexception(void); +void exceptions_throw_instantiationexception(classinfo *c); +void exceptions_throw_invocationtargetexception(java_handle_t *cause); +void exceptions_throw_negativearraysizeexception(void); + +java_handle_t *exceptions_new_nullpointerexception(void); +void exceptions_throw_nullpointerexception(void); +void exceptions_throw_privilegedactionexception(java_handle_t *cause); +void exceptions_throw_stringindexoutofboundsexception(void); + +java_handle_t *exceptions_fillinstacktrace(void); + +void exceptions_print_exception(java_handle_t *xptr); +void exceptions_print_current_exception(void); +void exceptions_print_stacktrace(void); + +#ifdef __cplusplus +} +#endif + +#endif // _EXCEPTIONS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/field.cpp b/src/vm/field.cpp new file mode 100644 index 000000000..881cd148b --- /dev/null +++ b/src/vm/field.cpp @@ -0,0 +1,561 @@ +/* src/vm/field.cpp - field functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "vm/types.h" + +#include "vm/annotation.h" +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/descriptor.h" +#include "vm/exceptions.hpp" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/references.h" +#include "vm/string.hpp" +#include "vm/suck.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +/* field_load ****************************************************************** + + Load everything about a class field from the class file and fill a + fieldinfo structure. + +*******************************************************************************/ + +#define field_load_NOVALUE 0xffffffff /* must be bigger than any u2 value! */ + +bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) +{ + classinfo *c; + u4 attrnum, i; + u4 pindex = field_load_NOVALUE; /* constantvalue_index */ + utf *u; + + /* Get class. */ + + c = cb->clazz; + + f->clazz = c; + + /* Get access flags. */ + + if (!suck_check_classbuffer_size(cb, 2 + 2 + 2)) + return false; + + f->flags = suck_u2(cb); + + /* Get name. */ + + if (!(u = (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) + return false; + + f->name = u; + + /* Get descriptor. */ + + if (!(u = (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) + return false; + + f->descriptor = u; + f->parseddesc = NULL; + + if (!descriptor_pool_add(descpool, u, NULL)) + return false; + + /* descriptor_pool_add accepts method descriptors, so we have to + check against them here before the call of + descriptor_to_basic_type below. */ + + if (u->text[0] == '(') { + exceptions_throw_classformaterror(c, "Method descriptor used for field"); + return false; + } + +#ifdef ENABLE_VERIFIER + if (opt_verify) { + /* check name */ + if (!is_valid_name_utf(f->name) || f->name->text[0] == '<') { + exceptions_throw_classformaterror(c, + "Illegal Field name \"%s\"", + f->name->text); + return false; + } + + /* check flag consistency */ + i = f->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED); + + if ((i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) || + ((f->flags & (ACC_FINAL | ACC_VOLATILE)) == (ACC_FINAL | ACC_VOLATILE))) { + exceptions_throw_classformaterror(c, + "Illegal field modifiers: 0x%X", + f->flags); + return false; + } + + if (c->flags & ACC_INTERFACE) { + if (((f->flags & (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) + != (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) || + f->flags & ACC_TRANSIENT) { + exceptions_throw_classformaterror(c, + "Illegal field modifiers: 0x%X", + f->flags); + return false; + } + } + } +#endif /* ENABLE_VERIFIER */ + + /* data type */ + + f->type = descriptor_to_basic_type(f->descriptor); + + /* For static-fields allocate memory for the value and set the + value to 0. */ + + if (f->flags & ACC_STATIC) { + switch (f->type) { + case TYPE_INT: + case TYPE_LNG: + case TYPE_FLT: + case TYPE_DBL: + f->value = NEW(imm_union); + break; + + case TYPE_ADR: +#if !defined(ENABLE_GC_BOEHM) + f->value = NEW(imm_union); +#else + f->value = GCNEW_UNCOLLECTABLE(imm_union, 1); +#endif + break; + + default: + vm_abort("field_load: invalid field type %d", f->type); + } + + /* Set the field to zero, for float and double fields set the + correct 0.0 value. */ + + switch (f->type) { + case TYPE_INT: + case TYPE_LNG: + case TYPE_ADR: + f->value->l = 0; + break; + + case TYPE_FLT: + f->value->f = 0.0; + break; + + case TYPE_DBL: + f->value->d = 0.0; + break; + } + } + else { + /* For instance-fields set the offset to 0. */ + + f->offset = 0; + + /* For final fields, which are not static, we need a value + structure. */ + + if (f->flags & ACC_FINAL) { + f->value = NEW(imm_union); + /* XXX hack */ + f->value->l = 0; + } + + switch (f->type) { + case TYPE_ADR: + c->flags |= ACC_CLASS_HAS_POINTERS; + break; + } + } + + /* read attributes */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + attrnum = suck_u2(cb); + + for (i = 0; i < attrnum; i++) { + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + if (!(u = (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) + return false; + + if (u == utf_ConstantValue) { + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* check attribute length */ + + if (suck_u4(cb) != 2) { + exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); + return false; + } + + /* constant value attribute */ + + if (pindex != field_load_NOVALUE) { + exceptions_throw_classformaterror(c, "Multiple ConstantValue attributes"); + return false; + } + + /* index of value in constantpool */ + + pindex = suck_u2(cb); + + /* initialize field with value from constantpool */ + + switch (f->type) { + case TYPE_INT: { + constant_integer *ci; + + if (!(ci = (constant_integer*) class_getconstant(c, pindex, CONSTANT_Integer))) + return false; + + f->value->i = ci->value; + } + break; + + case TYPE_LNG: { + constant_long *cl; + + if (!(cl = (constant_long*) class_getconstant(c, pindex, CONSTANT_Long))) + return false; + + f->value->l = cl->value; + } + break; + + case TYPE_FLT: { + constant_float *cf; + + if (!(cf = (constant_float*) class_getconstant(c, pindex, CONSTANT_Float))) + return false; + + f->value->f = cf->value; + } + break; + + case TYPE_DBL: { + constant_double *cd; + + if (!(cd = (constant_double*) class_getconstant(c, pindex, CONSTANT_Double))) + return false; + + f->value->d = cd->value; + } + break; + + case TYPE_ADR: + if (!(u = (utf*) class_getconstant(c, pindex, CONSTANT_String))) + return false; + + /* Create Java-string from compressed UTF8-string. */ + + f->value->a = literalstring_new(u); + break; + + default: + vm_abort("field_load: invalid field type %d", f->type); + } + } +#if defined(ENABLE_JAVASE) + else if (u == utf_Signature) { + /* Signature */ + + if (!loader_load_attribute_signature(cb, &(f->signature))) + return false; + } + +#if defined(ENABLE_ANNOTATIONS) + else if (u == utf_RuntimeVisibleAnnotations) { + /* RuntimeVisibleAnnotations */ + if (!annotation_load_field_attribute_runtimevisibleannotations(cb, f)) + return false; + } + else if (u == utf_RuntimeInvisibleAnnotations) { + /* RuntimeInvisibleAnnotations */ + if (!annotation_load_field_attribute_runtimeinvisibleannotations(cb, f)) + return false; + } +#endif +#endif + else { + /* unknown attribute */ + + if (!loader_skip_attribute_body(cb)) + return false; + } + } + + /* everything was ok */ + + return true; +} + + +/* field_get_type ************************************************************** + + Returns the type of the field as class. + +*******************************************************************************/ + +classinfo *field_get_type(fieldinfo *f) +{ + typedesc *td; + utf *u; + classinfo *c; + + td = f->parseddesc; + + if (td->type == TYPE_ADR) { + assert(td->classref); + + u = td->classref->name; + + /* load the class of the field-type with the field's + classloader */ + + c = load_class_from_classloader(u, f->clazz->classloader); + } + else { + c = Primitive::get_class_by_type(td->primitivetype); + } + + return c; +} + + +/* field_free ****************************************************************** + + Frees a fields' resources. + +*******************************************************************************/ + +void field_free(fieldinfo *f) +{ + /* free memory for fields which have a value */ + + if (f->value) +#if defined(ENABLE_GC_BOEHM) + if (f->type != TYPE_ADR) +#endif + FREE(f->value, imm_union); +} + + +/* field_get_annotations ****************************************************** + + Get a fields' unparsed annotations in a byte array. + + IN: + f........the field of which the annotations should be returned + + RETURN VALUE: + The unparsed annotations in a byte array (or NULL if there aren't any). + +*******************************************************************************/ + +java_handle_bytearray_t *field_get_annotations(fieldinfo *f) +{ +#if defined(ENABLE_ANNOTATIONS) + classinfo *c; /* declaring class */ + int slot; /* slot of this field */ + java_handle_bytearray_t *annotations; /* unparsed annotations */ + java_handle_t *field_annotations; /* array of unparsed */ + /* annotations of all fields of the declaring class */ + + c = f->clazz; + slot = f - c->fields; + annotations = NULL; + + LLNI_classinfo_field_get(c, field_annotations, field_annotations); + + /* the field_annotations array might be shorter then the field + * count if the fields above a certain index have no annotations. + */ + if (field_annotations != NULL && + array_length_get(field_annotations) > slot) { + annotations = (java_handle_bytearray_t*)array_objectarray_element_get( + (java_handle_objectarray_t*)field_annotations, slot); + } + + return annotations; +#else + return NULL; +#endif +} + + +/* field_printflags ************************************************************ + + (debugging only) + +*******************************************************************************/ + +#if !defined(NDEBUG) +void field_printflags(fieldinfo *f) +{ + if (f == NULL) { + printf("NULL"); + return; + } + + if (f->flags & ACC_PUBLIC) printf(" PUBLIC"); + if (f->flags & ACC_PRIVATE) printf(" PRIVATE"); + if (f->flags & ACC_PROTECTED) printf(" PROTECTED"); + if (f->flags & ACC_STATIC) printf(" STATIC"); + if (f->flags & ACC_FINAL) printf(" FINAL"); + if (f->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED"); + if (f->flags & ACC_VOLATILE) printf(" VOLATILE"); + if (f->flags & ACC_TRANSIENT) printf(" TRANSIENT"); + if (f->flags & ACC_NATIVE) printf(" NATIVE"); + if (f->flags & ACC_INTERFACE) printf(" INTERFACE"); + if (f->flags & ACC_ABSTRACT) printf(" ABSTRACT"); +} +#endif + + +/* field_print ***************************************************************** + + (debugging only) + +*******************************************************************************/ + +#if !defined(NDEBUG) +void field_print(fieldinfo *f) +{ + if (f == NULL) { + printf("(fieldinfo*)NULL"); + return; + } + + utf_display_printable_ascii_classname(f->clazz->name); + printf("."); + utf_display_printable_ascii(f->name); + printf(" "); + utf_display_printable_ascii(f->descriptor); + + field_printflags(f); + + if (!(f->flags & ACC_STATIC)) { + printf(", offset: %d", f->offset); + } +} +#endif + + +/* field_println *************************************************************** + + (debugging only) + +*******************************************************************************/ + +#if !defined(NDEBUG) +void field_println(fieldinfo *f) +{ + field_print(f); + printf("\n"); +} +#endif + +/* field_fieldref_print ******************************************************** + + (debugging only) + +*******************************************************************************/ + +#if !defined(NDEBUG) +void field_fieldref_print(constant_FMIref *fr) +{ + if (fr == NULL) { + printf("(constant_FMIref *)NULL"); + return; + } + + if (IS_FMIREF_RESOLVED(fr)) { + printf(" "); + field_print(fr->p.field); + } + else { + printf(" "); + utf_display_printable_ascii_classname(fr->p.classref->name); + printf("."); + utf_display_printable_ascii(fr->name); + printf(" "); + utf_display_printable_ascii(fr->descriptor); + } +} +#endif + +/* field_fieldref_println ****************************************************** + + (debugging only) + +*******************************************************************************/ + +#if !defined(NDEBUG) +void field_fieldref_println(constant_FMIref *fr) +{ + field_fieldref_print(fr); + printf("\n"); +} +#endif + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/field.hpp b/src/vm/field.hpp new file mode 100644 index 000000000..52c33ebbd --- /dev/null +++ b/src/vm/field.hpp @@ -0,0 +1,107 @@ +/* src/vm/field.hpp - field functions header + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _FIELD_HPP +#define _FIELD_HPP + +/* forward typedefs ***********************************************************/ + +typedef struct fieldinfo fieldinfo; + + +#include "config.h" +#include "vm/types.h" + +#include "vm/descriptor.h" +#include "vm/class.h" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/references.h" +#include "vm/utf8.h" + + +/* fieldinfo ******************************************************************/ + +struct fieldinfo { /* field of a class */ + + /* CAUTION: The first field must be a pointer that is never the same */ + /* value as CLASSREF_PSEUDO_VFTBL! This is used to check whether */ + /* a constant_FMIref has been resolved. */ + + classinfo *clazz; /* needed by typechecker. Could be optimized */ + /* away by using constant_FMIref instead of */ + /* fieldinfo throughout the compiler. */ + + s4 flags; /* ACC flags */ + s4 type; /* basic data type */ + utf *name; /* name of field */ + utf *descriptor;/* JavaVM descriptor string of field */ + utf *signature; /* Signature attribute string */ + typedesc *parseddesc;/* parsed descriptor */ + + int32_t offset; /* offset from start of object (instance variables) */ + imm_union *value; /* storage for static values (class variables) */ +}; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool); +classinfo *field_get_type(fieldinfo *f); +void field_free(fieldinfo *f); + +java_handle_bytearray_t *field_get_annotations(fieldinfo *f); + +#if !defined(NDEBUG) +void field_printflags(fieldinfo *f); +void field_print(fieldinfo *f); +void field_println(fieldinfo *f); +void field_fieldref_print(constant_FMIref *fr); +void field_fieldref_println(constant_FMIref *fr); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _FIELD_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/finalizer.c b/src/vm/finalizer.c index 833efbfb1..ea331ec96 100644 --- a/src/vm/finalizer.c +++ b/src/vm/finalizer.c @@ -31,24 +31,24 @@ #include "mm/memory.h" -#include "threads/lock-common.h" -#include "threads/thread.h" +#include "threads/condition.hpp" +#include "threads/mutex.hpp" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vmcore/options.h" - /* global variables ***********************************************************/ #if defined(ENABLE_THREADS) -static java_object_t *lock_thread_finalizer; +static Mutex *finalizer_thread_mutex; +static Condition *finalizer_thread_cond; #endif @@ -63,9 +63,8 @@ bool finalizer_init(void) TRACESUBSYSTEMINITIALIZATION("finalizer_init"); #if defined(ENABLE_THREADS) - lock_thread_finalizer = NEW(java_object_t); - - LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer); + finalizer_thread_mutex = Mutex_new(); + finalizer_thread_cond = Condition_new(); #endif /* everything's ok */ @@ -86,17 +85,17 @@ bool finalizer_init(void) static void finalizer_thread(void) { while (true) { - /* get the lock on the finalizer lock object, so we can call wait */ + /* get the lock on the finalizer mutex, so we can call wait */ - LOCK_MONITOR_ENTER(lock_thread_finalizer); + Mutex_lock(finalizer_thread_mutex); - /* wait forever on that object till we are signaled */ + /* wait forever on that condition till we are signaled */ - LOCK_WAIT_FOREVER(lock_thread_finalizer); + Condition_wait(finalizer_thread_cond, finalizer_thread_mutex); /* leave the lock */ - LOCK_MONITOR_EXIT(lock_thread_finalizer); + Mutex_unlock(finalizer_thread_mutex); #if !defined(NDEBUG) if (opt_DebugFinalizer) @@ -156,15 +155,15 @@ void finalizer_notify(void) #if defined(ENABLE_THREADS) /* get the lock on the finalizer lock object, so we can call wait */ - LOCK_MONITOR_ENTER(lock_thread_finalizer); + Mutex_lock(finalizer_thread_mutex); /* signal the finalizer thread */ - - LOCK_NOTIFY(lock_thread_finalizer); + + Condition_signal(finalizer_thread_cond); /* leave the lock */ - LOCK_MONITOR_EXIT(lock_thread_finalizer); + Mutex_unlock(finalizer_thread_mutex); #else /* if we don't have threads, just run the finalizers */ diff --git a/src/vm/finalizer.h b/src/vm/finalizer.h index ca3682735..04abf9ed0 100644 --- a/src/vm/finalizer.h +++ b/src/vm/finalizer.h @@ -1,9 +1,7 @@ /* src/vm/finalizer.h - finalizer linked list and thread header - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -35,6 +27,11 @@ #define _FINALIZER_H #include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/types.h" #include "vm/global.h" @@ -47,6 +44,10 @@ bool finalizer_start_thread(void); void finalizer_notify(void); void finalizer_run(void *o, void *p); +#ifdef __cplusplus +} +#endif + #endif /* _FINALIZER_H */ diff --git a/src/vm/global.h b/src/vm/global.h index 125eb3ff1..a9ec8c8f9 100644 --- a/src/vm/global.h +++ b/src/vm/global.h @@ -28,6 +28,7 @@ #include "config.h" +#include #include #include "vm/types.h" @@ -35,15 +36,9 @@ /* additional data types ******************************************************/ -typedef void *voidptr; /* generic pointer */ typedef void (*functionptr) (void); /* generic function pointer */ typedef u1* methodptr; -typedef unsigned int bool; /* boolean data type */ - -#define true 1 -#define false 0 - #if defined(ENABLE_SSA) /* immediate to get an addidional target Local Var Index */ /* for IINC in Combination with SSA */ @@ -211,6 +206,10 @@ typedef struct java_objectarray_t java_objectarray_t; #define ACC_METHOD_IMPLEMENTED 0x00020000 /* there is an implementation */ #define ACC_METHOD_MONOMORPHIC 0x00040000 /* currently monomorphic method */ #define ACC_METHOD_EA 0x00080000 /* method being escape analyzed */ +#define ACC_METHOD_MONOMORPHY_USED \ + 0x00100000 +#define ACC_METHOD_PARENT_MONOMORPHY_USED \ + 0x00200000 /* data structures of the runtime system **************************************/ diff --git a/src/vm/globals.cpp b/src/vm/globals.cpp new file mode 100644 index 000000000..cb7217603 --- /dev/null +++ b/src/vm/globals.cpp @@ -0,0 +1,124 @@ +/* src/vm/globals.cpp - global variables + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "vm/class.h" + + +// Classes. + +/* Important system classes. */ + +classinfo *class_java_lang_Object; +classinfo *class_java_lang_Class; +classinfo *class_java_lang_ClassLoader; +classinfo *class_java_lang_Cloneable; +classinfo *class_java_lang_SecurityManager; +classinfo *class_java_lang_String; +classinfo *class_java_lang_System; +classinfo *class_java_lang_Thread; +classinfo *class_java_lang_ThreadGroup; +classinfo *class_java_lang_Throwable; +classinfo *class_java_io_Serializable; + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +classinfo *class_java_lang_VMSystem; +classinfo *class_java_lang_VMThread; +classinfo *class_java_lang_VMThrowable; +#endif + +/* Important system exceptions. */ + +classinfo *class_java_lang_Exception; +classinfo *class_java_lang_ClassNotFoundException; +classinfo *class_java_lang_RuntimeException; + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) +classinfo *class_sun_misc_Signal; +classinfo *class_sun_reflect_MagicAccessorImpl; +#endif + +#if defined(ENABLE_JAVASE) +classinfo *class_java_lang_Void; +#endif +classinfo *class_java_lang_Boolean; +classinfo *class_java_lang_Byte; +classinfo *class_java_lang_Character; +classinfo *class_java_lang_Short; +classinfo *class_java_lang_Integer; +classinfo *class_java_lang_Long; +classinfo *class_java_lang_Float; +classinfo *class_java_lang_Double; + +/* some classes which may be used more often */ + +#if defined(ENABLE_JAVASE) +classinfo *class_java_lang_StackTraceElement; +classinfo *class_java_lang_reflect_Constructor; +classinfo *class_java_lang_reflect_Field; +classinfo *class_java_lang_reflect_Method; +classinfo *class_java_security_PrivilegedAction; +classinfo *class_java_util_Vector; +classinfo *class_java_util_HashMap; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +classinfo *class_java_lang_reflect_VMConstructor; +classinfo *class_java_lang_reflect_VMField; +classinfo *class_java_lang_reflect_VMMethod; +# endif + +classinfo *arrayclass_java_lang_Object; + +# if defined(ENABLE_ANNOTATIONS) +classinfo *class_sun_reflect_ConstantPool; +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +classinfo *class_sun_reflect_annotation_AnnotationParser; +# endif +# endif +#endif + +/* pseudo classes for the typechecker */ + +classinfo *pseudo_class_Arraystub; +classinfo *pseudo_class_Null; +classinfo *pseudo_class_New; + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/globals.hpp b/src/vm/globals.hpp new file mode 100644 index 000000000..edd04ddb7 --- /dev/null +++ b/src/vm/globals.hpp @@ -0,0 +1,160 @@ +/* src/vm/globals.hpp - global variables + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _GLOBALS_HPP +#define _GLOBALS_HPP + +#include "config.h" + +#include + +#include "vm/class.h" + + +// FIXME For now we export them a C symbols. +#ifdef __cplusplus +extern "C" { +#endif + +// Classes. + +/* Important system classes. */ + +extern classinfo *class_java_lang_Object; +extern classinfo *class_java_lang_Class; +extern classinfo *class_java_lang_ClassLoader; +extern classinfo *class_java_lang_Cloneable; +extern classinfo *class_java_lang_SecurityManager; +extern classinfo *class_java_lang_String; +extern classinfo *class_java_lang_System; +extern classinfo *class_java_lang_Thread; +extern classinfo *class_java_lang_ThreadGroup; +extern classinfo *class_java_lang_Throwable; +extern classinfo *class_java_io_Serializable; + +/* Important system exceptions. */ + +extern classinfo *class_java_lang_Exception; +extern classinfo *class_java_lang_ClassNotFoundException; +extern classinfo *class_java_lang_RuntimeException; + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +extern classinfo *class_java_lang_VMSystem; +extern classinfo *class_java_lang_VMThread; +extern classinfo *class_java_lang_VMThrowable; +#endif + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) +extern classinfo *class_sun_misc_Signal; +extern classinfo *class_sun_reflect_MagicAccessorImpl; +#endif + +#if defined(ENABLE_JAVASE) +extern classinfo *class_java_lang_Void; +#endif + +extern classinfo *class_java_lang_Boolean; +extern classinfo *class_java_lang_Byte; +extern classinfo *class_java_lang_Character; +extern classinfo *class_java_lang_Short; +extern classinfo *class_java_lang_Integer; +extern classinfo *class_java_lang_Long; +extern classinfo *class_java_lang_Float; +extern classinfo *class_java_lang_Double; + +/* some classes which may be used more often */ + +#if defined(ENABLE_JAVASE) +extern classinfo *class_java_lang_StackTraceElement; +extern classinfo *class_java_lang_reflect_Constructor; +extern classinfo *class_java_lang_reflect_Field; +extern classinfo *class_java_lang_reflect_Method; +extern classinfo *class_java_security_PrivilegedAction; +extern classinfo *class_java_util_Vector; +extern classinfo *class_java_util_HashMap; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +extern classinfo *class_java_lang_reflect_VMConstructor; +extern classinfo *class_java_lang_reflect_VMField; +extern classinfo *class_java_lang_reflect_VMMethod; +# endif + +extern classinfo *arrayclass_java_lang_Object; + +# if defined(ENABLE_ANNOTATIONS) +extern classinfo *class_sun_reflect_ConstantPool; +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +extern classinfo *class_sun_reflect_annotation_AnnotationParser; +# endif +# endif +#endif + + +/* pseudo classes for the type checker ****************************************/ + +/* + * pseudo_class_Arraystub + * (extends Object implements Cloneable, java.io.Serializable) + * + * If two arrays of incompatible component types are merged, + * the resulting reference has no accessible components. + * The result does, however, implement the interfaces Cloneable + * and java.io.Serializable. This pseudo class is used internally + * to represent such results. (They are *not* considered arrays!) + * + * pseudo_class_Null + * + * This pseudo class is used internally to represent the + * null type. + * + * pseudo_class_New + * + * This pseudo class is used internally to represent the + * the 'uninitialized object' type. + */ + +extern classinfo *pseudo_class_Arraystub; +extern classinfo *pseudo_class_Null; +extern classinfo *pseudo_class_New; + +#ifdef __cplusplus +} +#endif + +#endif // _GLOBALS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/initialize.c b/src/vm/initialize.c index 6e0c10838..a9e0b9b0e 100644 --- a/src/vm/initialize.c +++ b/src/vm/initialize.c @@ -31,23 +31,22 @@ #include "threads/lock-common.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" #include "vm/global.h" +#include "vm/globals.hpp" #include "vm/initialize.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" #if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" +# include "vm/statistics.h" #endif +#include "vm/jit/asmpart.h" + /* private functions **********************************************************/ diff --git a/src/vm/initialize.h b/src/vm/initialize.h index 431c1c8d8..88a7ff554 100644 --- a/src/vm/initialize.h +++ b/src/vm/initialize.h @@ -28,9 +28,12 @@ #include "config.h" -#include "vm/global.h" +#ifdef __cplusplus +extern "C" { +#endif -#include "vmcore/class.h" +#include "vm/class.h" +#include "vm/global.h" /* function prototypes ********************************************************/ @@ -38,6 +41,10 @@ void initialize_init(void); bool initialize_class(classinfo *c); +#ifdef __cplusplus +} +#endif + #endif /* _INITIALIZE_H */ diff --git a/src/vm/javaobjects.cpp b/src/vm/javaobjects.cpp new file mode 100644 index 000000000..cc82bdc6e --- /dev/null +++ b/src/vm/javaobjects.cpp @@ -0,0 +1,146 @@ +/* src/vm/javaobjects.cpp - functions to create and access Java objects + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "native/vm/reflection.hpp" + +#include "vm/access.h" +#include "vm/jit/builtin.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/javaobjects.hpp" + + +#if defined(ENABLE_JAVASE) + +/** + * Constructs a Java object with the given + * java.lang.reflect.Constructor. + * + * @param args Constructor arguments. + * + * @return Handle to Java object. + */ +java_handle_t* java_lang_reflect_Constructor::new_instance(java_handle_objectarray_t* args) +{ + methodinfo* m = get_method(); + + // Should we bypass security the checks (AccessibleObject)? + if (get_override() == false) { + /* This method is always called like this: + [0] java.lang.reflect.Constructor.constructNative (Native Method) + [1] java.lang.reflect.Constructor.newInstance + [2] + */ + + if (!access_check_method(m, 2)) + return NULL; + } + + // Create a Java object. + java_handle_t* h = builtin_new(m->clazz); + + if (h == NULL) + return NULL; + + // Call initializer. + (void) Reflection::invoke(m, h, args); + + return h; +} + + +/** + * Invokes the given method. + * + * @param args Method arguments. + * + * @return return value of the method + */ +java_handle_t* java_lang_reflect_Method::invoke(java_handle_t* o, java_handle_objectarray_t* args) +{ + methodinfo* m = get_method(); + + // Should we bypass security the checks (AccessibleObject)? + if (get_override() == false) { +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + /* This method is always called like this: + [0] java.lang.reflect.Method.invokeNative (Native Method) + [1] java.lang.reflect.Method.invoke (Method.java:329) + [2] + */ + + if (!access_check_method(m, 2)) + return NULL; +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + /* We only pass 1 here as stacktrace_get_caller_class, which + is called from access_check_method, skips + java.lang.reflect.Method.invoke(). */ + + if (!access_check_method(m, 1)) + return NULL; +#else +# error unknown classpath configuration +#endif + } + + // Check if method class is initialized. + if (!(m->clazz->state & CLASS_INITIALIZED)) + if (!initialize_class(m->clazz)) + return NULL; + + // Call the Java method. + java_handle_t* result = Reflection::invoke(m, o, args); + + return result; +} + + +// Legacy C interface. + +extern "C" { + java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m) { return java_lang_reflect_Constructor(m).get_handle(); } + java_handle_t* java_lang_reflect_Field_create(fieldinfo* f) { return java_lang_reflect_Field(f).get_handle(); } + java_handle_t* java_lang_reflect_Method_create(methodinfo* m) { return java_lang_reflect_Method(m).get_handle(); } +} + +#endif // ENABLE_JAVASE + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/javaobjects.hpp b/src/vm/javaobjects.hpp new file mode 100644 index 000000000..4ecd9dd49 --- /dev/null +++ b/src/vm/javaobjects.hpp @@ -0,0 +1,2940 @@ +/* src/vm/javaobjects.hpp - functions to create and access Java objects + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _JAVAOBJECTS_HPP +#define _JAVAOBJECTS_HPP + +#include "config.h" + +#include + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "vm/class.h" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/method.h" + + +#ifdef __cplusplus + +/** + * This class provides low-level functions to access Java object + * instance fields. + * + * These functions do NOT take care about the GC critical section! + * Please use FieldAccess wherever possible. + */ +class RawFieldAccess { +protected: + template static inline T raw_get(void* address, const off_t offset); + template static inline void raw_set(void* address, const off_t offset, T value); +}; + + +template inline T RawFieldAccess::raw_get(void* address, const off_t offset) +{ + T* p = (T*) (((uintptr_t) address) + offset); + return *p; +} + + +template inline void RawFieldAccess::raw_set(void* address, const off_t offset, T value) +{ + T* p = (T*) (((uintptr_t) address) + offset); + *p = value; +} + + +/** + * This classes provides functions to access Java object instance + * fields. These functions enter a critical GC section before + * accessing the Java object throught the handle and leave it + * afterwards. + */ +class FieldAccess : private RawFieldAccess { +protected: + template static inline T get(java_handle_t* h, const off_t offset); + template static inline void set(java_handle_t* h, const off_t offset, T value); +}; + +template inline T FieldAccess::get(java_handle_t* h, const off_t offset) +{ + java_object_t* o; + T result; + + GC::critical_enter(); + + // XXX This should be _handle->get_object(); + o = LLNI_UNWRAP(h); + + result = raw_get(o, offset); + + GC::critical_leave(); + + return result; +} + +template<> inline java_handle_t* FieldAccess::get(java_handle_t* h, const off_t offset) +{ + java_object_t* o; + java_object_t* result; + java_handle_t* hresult; + + GC::critical_enter(); + + // XXX This should be _handle->get_object(); + o = LLNI_UNWRAP(h); + + result = raw_get(o, offset); + + hresult = LLNI_WRAP(result); + + GC::critical_leave(); + + return hresult; +} + + +template inline void FieldAccess::set(java_handle_t* h, const off_t offset, T value) +{ + java_object_t* o; + + GC::critical_enter(); + + // XXX This should be h->get_object(); + o = LLNI_UNWRAP(h); + + raw_set(o, offset, value); + + GC::critical_leave(); +} + +template<> inline void FieldAccess::set(java_handle_t* h, const off_t offset, java_handle_t* value) +{ + java_object_t* o; + java_object_t* ovalue; + + GC::critical_enter(); + + // XXX This should be h->get_object(); + o = LLNI_UNWRAP(h); + ovalue = LLNI_UNWRAP(value); + + raw_set(o, offset, ovalue); + + GC::critical_leave(); +} + + +/** + * java/lang/Object + * + * Object layout: + * + * 0. object header + */ +class java_lang_Object { +protected: + // Handle of Java object. + java_handle_t* _handle; + +public: + java_lang_Object() : _handle(NULL) {} + java_lang_Object(java_handle_t* h) : _handle(h) {} + java_lang_Object(jobject h) : _handle((java_handle_t*) h) {} + virtual ~java_lang_Object() {} + + // Getters. + virtual inline java_handle_t* get_handle () const { return _handle; } + inline vftbl_t* get_vftbl () const; + inline classinfo* get_Class () const; + inline int32_t get_hashcode() const; + + inline bool is_null () const; + inline bool is_non_null() const; +}; + + +inline vftbl_t* java_lang_Object::get_vftbl() const +{ + GC::critical_enter(); + + // XXX This should be h->get_object(); + java_object_t* o = LLNI_UNWRAP(_handle); + vftbl_t* vftbl = o->vftbl; + + GC::critical_leave(); + + return vftbl; +} + +inline classinfo* java_lang_Object::get_Class() const +{ + return get_vftbl()->clazz; +} + +inline int32_t java_lang_Object::get_hashcode() const +{ +#if defined(ENABLE_GC_CACAO) + return heap_get_hashcode(_handle); +#else + java_object_t* o; + int32_t hashcode; + + GC::critical_enter(); + + // XXX This should be h->get_object(); + o = LLNI_UNWRAP(_handle); + + hashcode = (int32_t)(intptr_t) o; + + GC::critical_leave(); + + return hashcode; +#endif +} + + +inline bool java_lang_Object::is_null() const +{ + return (_handle == NULL); +} + +inline bool java_lang_Object::is_non_null() const +{ + return (_handle != NULL); +} + + +/** + * java/lang/Boolean + * + * Object layout: + * + * 0. object header + * 1. boolean value; + */ +class java_lang_Boolean : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + +public: + java_lang_Boolean(java_handle_t* h) : java_lang_Object(h) {} + + inline uint8_t get_value(); + inline void set_value(uint8_t value); +}; + +inline uint8_t java_lang_Boolean::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Boolean::set_value(uint8_t value) +{ + set(_handle, offset_value, (uint32_t) value); +} + + +/** + * java/lang/Byte + * + * Object layout: + * + * 0. object header + * 1. byte value; + */ +class java_lang_Byte : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + +public: + java_lang_Byte(java_handle_t* h) : java_lang_Object(h) {} + + inline int8_t get_value(); + inline void set_value(int8_t value); +}; + +inline int8_t java_lang_Byte::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Byte::set_value(int8_t value) +{ + set(_handle, offset_value, (int32_t) value); +} + + +/** + * java/lang/Character + * + * Object layout: + * + * 0. object header + * 1. char value; + */ +class java_lang_Character : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + +public: + java_lang_Character(java_handle_t* h) : java_lang_Object(h) {} + + inline uint16_t get_value(); + inline void set_value(uint16_t value); +}; + +inline uint16_t java_lang_Character::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Character::set_value(uint16_t value) +{ + set(_handle, offset_value, (uint32_t) value); +} + + +/** + * java/lang/Short + * + * Object layout: + * + * 0. object header + * 1. short value; + */ +class java_lang_Short : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + +public: + java_lang_Short(java_handle_t* h) : java_lang_Object(h) {} + + inline int16_t get_value(); + inline void set_value(int16_t value); +}; + +inline int16_t java_lang_Short::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Short::set_value(int16_t value) +{ + set(_handle, offset_value, (int32_t) value); +} + + +/** + * java/lang/Integer + * + * Object layout: + * + * 0. object header + * 1. int value; + */ +class java_lang_Integer : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + +public: + java_lang_Integer(java_handle_t* h) : java_lang_Object(h) {} + + inline int32_t get_value(); + inline void set_value(int32_t value); +}; + +inline int32_t java_lang_Integer::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Integer::set_value(int32_t value) +{ + set(_handle, offset_value, value); +} + + +/** + * java/lang/Long + * + * Object layout: + * + * 0. object header + * 1. long value; + */ +class java_lang_Long : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t)); + +public: + java_lang_Long(java_handle_t* h) : java_lang_Object(h) {} + + inline int64_t get_value(); + inline void set_value(int64_t value); +}; + +inline int64_t java_lang_Long::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Long::set_value(int64_t value) +{ + set(_handle, offset_value, value); +} + + +/** + * java/lang/Float + * + * Object layout: + * + * 0. object header + * 1. float value; + */ +class java_lang_Float : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(float)); + +public: + java_lang_Float(java_handle_t* h) : java_lang_Object(h) {} + + inline float get_value(); + inline void set_value(float value); +}; + +inline float java_lang_Float::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Float::set_value(float value) +{ + set(_handle, offset_value, value); +} + + +/** + * java/lang/Double + * + * Object layout: + * + * 0. object header + * 1. double value; + */ +class java_lang_Double : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), sizeof(double)); + +public: + java_lang_Double(java_handle_t* h) : java_lang_Object(h) {} + + inline double get_value(); + inline void set_value(double value); +}; + +inline double java_lang_Double::get_value() +{ + return get(_handle, offset_value); +} + +inline void java_lang_Double::set_value(double value) +{ + set(_handle, offset_value, value); +} + + +#if defined(ENABLE_JAVASE) + +# if defined(ENABLE_ANNOTATIONS) +/** + * OpenJDK sun/reflect/ConstantPool + * + * Object layout: + * + * 0. object header + * 1. java.lang.Object constantPoolOop; + */ +class sun_reflect_ConstantPool : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_constantPoolOop = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + +public: + sun_reflect_ConstantPool(java_handle_t* h) : java_lang_Object(h) {} + sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop); + + // Setters. + inline void set_constantPoolOop(classinfo* value); + inline void set_constantPoolOop(jclass value); +}; + + +inline sun_reflect_ConstantPool::sun_reflect_ConstantPool(java_handle_t* h, jclass constantPoolOop) : java_lang_Object(h) +{ + set_constantPoolOop(constantPoolOop); +} + + +inline void sun_reflect_ConstantPool::set_constantPoolOop(classinfo* value) +{ + set(_handle, offset_constantPoolOop, value); +} + +inline void sun_reflect_ConstantPool::set_constantPoolOop(jclass value) +{ + // XXX jclass is a boxed object. + set_constantPoolOop(LLNI_classinfo_unwrap(value)); +} +# endif // ENABLE_ANNOTATIONS + +#endif // ENABLE_JAVASE + + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + +/** + * GNU Classpath java/lang/Class + * + * Object layout: + * + * 0. object header + * 1. java.lang.Object[] signers; + * 2. java.security.ProtectionDomain pd; + * 3. java.lang.Object vmdata; + * 4. java.lang.reflect.Constructor constructor; + */ +class java_lang_Class : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_signers = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_pd = MEMORY_ALIGN(offset_signers + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_vmdata = MEMORY_ALIGN(offset_pd + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_constructor = MEMORY_ALIGN(offset_vmdata + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_Class(java_handle_t* h) : java_lang_Object(h) {} + + // Setters. + inline void set_pd(java_handle_t* value); + inline void set_pd(jobject value); +}; + +inline void java_lang_Class::set_pd(java_handle_t* value) +{ + set(_handle, offset_pd, value); +} + +inline void java_lang_Class::set_pd(jobject value) +{ + set_pd((java_handle_t*) value); +} + + +/** + * GNU Classpath java/lang/StackTraceElement + * + * Object layout: + * + * 0. object header + * 1. java.lang.String fileName; + * 2. int lineNumber; + * 3. java.lang.String declaringClass; + * 4. java.lang.String methodName; + * 5. boolean isNative; + */ +class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_fileName = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_declaringClass = MEMORY_ALIGN(offset_lineNumber + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_isNative = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {} + java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative); +}; + +inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* h, java_handle_t* fileName, int32_t lineNumber, java_handle_t* declaringClass, java_handle_t* methodName, uint8_t isNative) : java_lang_Object(h) +{ + java_lang_StackTraceElement((java_handle_t*) h); + + set(_handle, offset_fileName, fileName); + set(_handle, offset_lineNumber, lineNumber); + set(_handle, offset_declaringClass, declaringClass); + set(_handle, offset_methodName, methodName); + set(_handle, offset_isNative, isNative); +} + + +/** + * GNU Classpath java/lang/String + * + * Object layout: + * + * 0. object header + * 1. char[] value; + * 2. int count; + * 3. int cachedHashCode; + * 4. int offset; + */ +class java_lang_String : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_count = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_cachedHashCode = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_offset = MEMORY_ALIGN(offset_cachedHashCode + sizeof(int32_t), sizeof(int32_t)); + +public: + java_lang_String(java_handle_t* h) : java_lang_Object(h) {} + java_lang_String(jstring h); + java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0); + + // Getters. + inline java_handle_chararray_t* get_value () const; + inline int32_t get_count () const; + inline int32_t get_offset() const; + + // Setters. + inline void set_value (java_handle_chararray_t* value); + inline void set_count (int32_t value); + inline void set_offset(int32_t value); +}; + +inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h) +{ + java_lang_String((java_handle_t*) h); +} + +inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h) +{ + set_value(value); + set_count(count); + set_offset(offset); +} + +inline java_handle_chararray_t* java_lang_String::get_value() const +{ + return get(_handle, offset_value); +} + +inline int32_t java_lang_String::get_count() const +{ + return get(_handle, offset_count); +} + +inline int32_t java_lang_String::get_offset() const +{ + return get(_handle, offset_offset); +} + +inline void java_lang_String::set_value(java_handle_chararray_t* value) +{ + set(_handle, offset_value, value); +} + +inline void java_lang_String::set_count(int32_t value) +{ + set(_handle, offset_count, value); +} + +inline void java_lang_String::set_offset(int32_t value) +{ + set(_handle, offset_offset, value); +} + + +/** + * GNU Classpath java/lang/Thread + * + * Object layout: + * + * 0. object header + * 1. java.lang.VMThread vmThread; + * 2. java.lang.ThreadGroup group; + * 3. java.lang.Runnable runnable; + * 4. java.lang.String name; + * 5. boolean daemon; + * 6. int priority; + * 7. long stacksize; + * 8. java.lang.Throwable stillborn; + * 9. java.lang.ClassLoader contextClassLoader; + * 10. boolean contextClassLoaderIsSystemClassLoader; + * 11. long threadId; + * 12. java.lang.Object parkBlocker; + * 13. gnu.java.util.WeakIdentityHashMap locals; + * 14. java_lang_Thread_UncaughtExceptionHandler exceptionHandler; + */ +class java_lang_Thread : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_vmThread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_group = MEMORY_ALIGN(offset_vmThread + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_runnable = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_name = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_daemon = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_priority = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_stacksize = MEMORY_ALIGN(offset_priority + sizeof(int32_t), sizeof(int64_t)); + static const off_t offset_stillborn = MEMORY_ALIGN(offset_stacksize + sizeof(int64_t), SIZEOF_VOID_P); + static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_stillborn + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_contextClassLoaderIsSystemClassLoader = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_threadId = MEMORY_ALIGN(offset_contextClassLoaderIsSystemClassLoader + sizeof(int32_t), sizeof(int64_t)); + static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadId + sizeof(int64_t), SIZEOF_VOID_P); + static const off_t offset_locals = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_exceptionHandler = MEMORY_ALIGN(offset_locals + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {} +// java_lang_Thread(threadobject* t); + + // Getters. + inline java_handle_t* get_vmThread () const; + inline java_handle_t* get_group () const; + inline java_handle_t* get_name () const; + inline int32_t get_daemon () const; + inline int32_t get_priority () const; + inline java_handle_t* get_exceptionHandler() const; + + // Setters. + inline void set_group(java_handle_t* value); +}; + + +// inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h) +// { +// java_lang_Thread(thread_get_object(t)); +// } + + +inline java_handle_t* java_lang_Thread::get_vmThread() const +{ + return get(_handle, offset_vmThread); +} + +inline java_handle_t* java_lang_Thread::get_group() const +{ + return get(_handle, offset_group); +} + +inline java_handle_t* java_lang_Thread::get_name() const +{ + return get(_handle, offset_name); +} + +inline int32_t java_lang_Thread::get_daemon() const +{ + return get(_handle, offset_daemon); +} + +inline int32_t java_lang_Thread::get_priority() const +{ + return get(_handle, offset_priority); +} + +inline java_handle_t* java_lang_Thread::get_exceptionHandler() const +{ + return get(_handle, offset_exceptionHandler); +} + + +inline void java_lang_Thread::set_group(java_handle_t* value) +{ + set(_handle, offset_group, value); +} + + +/** + * GNU Classpath java/lang/VMThread + * + * Object layout: + * + * 0. object header + * 1. java.lang.Thread thread; + * 2. boolean running; + * 3. java.lang.VMThread vmdata; + */ +class java_lang_VMThread : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_thread = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_running = MEMORY_ALIGN(offset_thread + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_vmdata = MEMORY_ALIGN(offset_running + sizeof(int32_t), SIZEOF_VOID_P); + +public: + java_lang_VMThread(java_handle_t* h) : java_lang_Object(h) {} + java_lang_VMThread(jobject h); + java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata); + + // Getters. + inline java_handle_t* get_thread() const; + inline threadobject* get_vmdata() const; + + // Setters. + inline void set_thread(java_handle_t* value); + inline void set_vmdata(threadobject* value); +}; + + +inline java_lang_VMThread::java_lang_VMThread(jobject h) : java_lang_Object(h) +{ + java_lang_VMThread((java_handle_t*) h); +} + +inline java_lang_VMThread::java_lang_VMThread(java_handle_t* h, java_handle_t* thread, threadobject* vmdata) : java_lang_Object(h) +{ + set_thread(thread); + set_vmdata(vmdata); +} + + +inline java_handle_t* java_lang_VMThread::get_thread() const +{ + return get(_handle, offset_thread); +} + +inline threadobject* java_lang_VMThread::get_vmdata() const +{ + return get(_handle, offset_vmdata); +} + + +inline void java_lang_VMThread::set_thread(java_handle_t* value) +{ + set(_handle, offset_thread, value); +} + +inline void java_lang_VMThread::set_vmdata(threadobject* value) +{ + set(_handle, offset_vmdata, value); +} + + +/** + * GNU Classpath java/lang/Throwable + * + * Object layout: + * + * 0. object header + * 1. java.lang.String detailMessage; + * 2. java.lang.Throwable cause; + * 3. java.lang.StackTraceElement[] stackTrace; + * 4. java.lang.VMThrowable vmState; + */ +class java_lang_Throwable : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_vmState = MEMORY_ALIGN(offset_stackTrace + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {} + + // Getters. + inline java_handle_t* get_detailMessage() const; + inline java_handle_t* get_cause () const; + inline java_handle_t* get_vmState () const; +}; + + +inline java_handle_t* java_lang_Throwable::get_detailMessage() const +{ + return get(_handle, offset_detailMessage); +} + +inline java_handle_t* java_lang_Throwable::get_cause() const +{ + return get(_handle, offset_cause); +} + +inline java_handle_t* java_lang_Throwable::get_vmState() const +{ + return get(_handle, offset_vmState); +} + + +/** + * GNU Classpath java/lang/VMThrowable + * + * Object layout: + * + * 0. object header + * 1. java.lang.Object vmdata; + */ +class java_lang_VMThrowable : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_vmdata = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + +public: + java_lang_VMThrowable(java_handle_t* h) : java_lang_Object(h) {} + java_lang_VMThrowable(jobject h); + + inline java_handle_bytearray_t* get_vmdata() const; + inline void set_vmdata(java_handle_bytearray_t* value); +}; + +inline java_lang_VMThrowable::java_lang_VMThrowable(jobject h) : java_lang_Object(h) +{ + java_lang_VMThrowable((java_handle_t*) h); +} + +inline java_handle_bytearray_t* java_lang_VMThrowable::get_vmdata() const +{ + return get(_handle, offset_vmdata); +} + +inline void java_lang_VMThrowable::set_vmdata(java_handle_bytearray_t* value) +{ + set(_handle, offset_vmdata, value); +} + + +/** + * GNU Classpath java/lang/reflect/VMConstructor + * + * Object layout: + * + * 0. object header + * 1. java.lang.Class clazz; + * 2. int slot; + * 3. byte[] annotations; + * 4. byte[] parameterAnnotations; + * 5. java.util.Map declaredAnnotations; + * 6. java.lang.reflect.Constructor cons; + */ +class java_lang_reflect_VMConstructor : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_cons = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_VMConstructor(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_VMConstructor(jobject h); + java_lang_reflect_VMConstructor(methodinfo* m); + + // Getters. + inline classinfo* get_clazz () const; + inline int32_t get_slot () const; + inline java_handle_bytearray_t* get_annotations () const; + inline java_handle_bytearray_t* get_parameterAnnotations() const; + inline java_handle_t* get_declaredAnnotations () const; + inline java_handle_t* get_cons () const; + + // Setters. + inline void set_clazz (classinfo* value); + inline void set_slot (int32_t value); + inline void set_annotations (java_handle_bytearray_t* value); + inline void set_parameterAnnotations(java_handle_bytearray_t* value); + inline void set_declaredAnnotations (java_handle_t* value); + inline void set_cons (java_handle_t* value); + + // Convenience functions. + inline methodinfo* get_method(); +}; + + +inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_VMConstructor((java_handle_t*) h); +} + +inline java_lang_reflect_VMConstructor::java_lang_reflect_VMConstructor(methodinfo* m) +{ + _handle = builtin_new(class_java_lang_reflect_VMConstructor); + + if (is_null()) + return; + + int slot = m - m->clazz->methods; + java_handle_bytearray_t* annotations = method_get_annotations(m); + java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m); + + set_clazz(m->clazz); + set_slot(slot); + set_annotations(annotations); + set_parameterAnnotations(parameterAnnotations); +} + + +inline classinfo* java_lang_reflect_VMConstructor::get_clazz() const +{ + return get(_handle, offset_clazz); +} + +inline int32_t java_lang_reflect_VMConstructor::get_slot() const +{ + return get(_handle, offset_slot); +} + +inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_annotations() const +{ + return get(_handle, offset_annotations); +} + +inline java_handle_bytearray_t* java_lang_reflect_VMConstructor::get_parameterAnnotations() const +{ + return get(_handle, offset_parameterAnnotations); +} + +inline java_handle_t* java_lang_reflect_VMConstructor::get_declaredAnnotations() const +{ + return get(_handle, offset_declaredAnnotations); +} + +inline java_handle_t* java_lang_reflect_VMConstructor::get_cons() const +{ + return get(_handle, offset_cons); +} + +inline void java_lang_reflect_VMConstructor::set_clazz(classinfo* value) +{ + set(_handle, offset_clazz, value); +} + +inline void java_lang_reflect_VMConstructor::set_slot(int32_t value) +{ + set(_handle, offset_slot, value); +} + +inline void java_lang_reflect_VMConstructor::set_annotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_annotations, value); +} + +inline void java_lang_reflect_VMConstructor::set_parameterAnnotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_parameterAnnotations, value); +} + +inline void java_lang_reflect_VMConstructor::set_declaredAnnotations(java_handle_t* value) +{ + set(_handle, offset_declaredAnnotations, value); +} + +inline void java_lang_reflect_VMConstructor::set_cons(java_handle_t* value) +{ + set(_handle, offset_cons, value); +} + +inline methodinfo* java_lang_reflect_VMConstructor::get_method() +{ + classinfo* c = get_clazz(); + int32_t slot = get_slot(); + methodinfo* m = &(c->methods[slot]); + return m; +} + + +/** + * GNU Classpath java/lang/reflect/Constructor + * + * Object layout: + * + * 0. object header + * 1. boolean flag; + * 2. gnu.java.lang.reflect.MethodSignatureParser p; + * 3. java.lang.reflect.VMConstructor cons; + */ +class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_cons = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_Constructor(jobject h); + java_lang_reflect_Constructor(methodinfo* m); + + java_handle_t* new_instance(java_handle_objectarray_t* args); + + // Getters. + inline int32_t get_flag() const; + inline java_handle_t* get_cons() const; + + // Setters. + inline void set_cons(java_handle_t* value); + + // Convenience functions. + inline methodinfo* get_method () const; + inline int32_t get_override() const; +}; + + +inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_Constructor((java_handle_t*) h); +} + +inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m) +{ + java_lang_reflect_VMConstructor jlrvmc(m); + + if (jlrvmc.is_null()) + return; + + _handle = builtin_new(class_java_lang_reflect_Constructor); + + if (is_null()) + return; + + // Link the two Java objects. + set_cons(jlrvmc.get_handle()); + jlrvmc.set_cons(get_handle()); +} + + +inline int32_t java_lang_reflect_Constructor::get_flag() const +{ + return get(_handle, offset_flag); +} + +inline java_handle_t* java_lang_reflect_Constructor::get_cons() const +{ + return get(_handle, offset_cons); +} + + +inline void java_lang_reflect_Constructor::set_cons(java_handle_t* value) +{ + set(_handle, offset_cons, value); +} + + +inline methodinfo* java_lang_reflect_Constructor::get_method() const +{ + java_lang_reflect_VMConstructor jlrvmc(get_cons()); + return jlrvmc.get_method(); +} + +inline int32_t java_lang_reflect_Constructor::get_override() const +{ + return get_flag(); +} + + +/** + * GNU Classpath java/lang/reflect/VMField + * + * Object layout: + * + * 0. object header + * 1. java.lang.Class clazz; + * 2. java.lang.String name; + * 3. int slot; + * 4. byte[] annotations; + * 5. java.lang.Map declaredAnnotations; + * 6. java.lang.reflect.Field f; + */ +class java_lang_reflect_VMField : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_f = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_VMField(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_VMField(jobject h); + java_lang_reflect_VMField(fieldinfo* f); + + // Getters. + inline classinfo* get_clazz () const; + inline int32_t get_slot () const; + inline java_handle_bytearray_t* get_annotations () const; + inline java_handle_t* get_declaredAnnotations() const; + inline java_handle_t* get_f () const; + + // Setters. + inline void set_clazz (classinfo* value); + inline void set_name (java_handle_t* value); + inline void set_slot (int32_t value); + inline void set_annotations (java_handle_bytearray_t* value); + inline void set_declaredAnnotations(java_handle_t* value); + inline void set_f (java_handle_t* value); + + // Convenience functions. + inline fieldinfo* get_field() const; +}; + + +inline java_lang_reflect_VMField::java_lang_reflect_VMField(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_VMField((java_handle_t*) h); +} + +inline java_lang_reflect_VMField::java_lang_reflect_VMField(fieldinfo* f) +{ + _handle = builtin_new(class_java_lang_reflect_VMField); + + if (is_null()) + return; + + java_handle_t* name = javastring_intern(javastring_new(f->name)); + int slot = f - f->clazz->fields; + java_handle_bytearray_t* annotations = field_get_annotations(f); + + set_clazz(f->clazz); + set_name(name); + set_slot(slot); + set_annotations(annotations); +} + + +inline classinfo* java_lang_reflect_VMField::get_clazz() const +{ + return get(_handle, offset_clazz); +} + +inline int32_t java_lang_reflect_VMField::get_slot() const +{ + return get(_handle, offset_slot); +} + +inline java_handle_bytearray_t* java_lang_reflect_VMField::get_annotations() const +{ + return get(_handle, offset_annotations); +} + +inline java_handle_t* java_lang_reflect_VMField::get_declaredAnnotations() const +{ + return get(_handle, offset_declaredAnnotations); +} + +inline java_handle_t* java_lang_reflect_VMField::get_f() const +{ + return get(_handle, offset_f); +} + + +inline void java_lang_reflect_VMField::set_clazz(classinfo* value) +{ + set(_handle, offset_clazz, value); +} + +inline void java_lang_reflect_VMField::set_name(java_handle_t* value) +{ + set(_handle, offset_name, value); +} + +inline void java_lang_reflect_VMField::set_slot(int32_t value) +{ + set(_handle, offset_slot, value); +} + +inline void java_lang_reflect_VMField::set_annotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_annotations, value); +} + +inline void java_lang_reflect_VMField::set_declaredAnnotations(java_handle_t* value) +{ + set(_handle, offset_declaredAnnotations, value); +} + +inline void java_lang_reflect_VMField::set_f(java_handle_t* value) +{ + set(_handle, offset_f, value); +} + +inline fieldinfo* java_lang_reflect_VMField::get_field() const +{ + classinfo* c = get_clazz(); + int32_t slot = get_slot(); + fieldinfo* f = &(c->fields[slot]); + return f; +} + + +/** + * GNU Classpath java/lang/reflect/Field + * + * Object layout: + * + * 0. object header + * 1. boolean flag; + * 2. gnu.java.lang.reflect.FieldSignatureParser p; + * 3. java.lang.reflect.VMField f; + */ +class java_lang_reflect_Field : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_f = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_Field(jobject h); + java_lang_reflect_Field(fieldinfo* f); + + // Getters. + inline int32_t get_flag() const; + inline java_handle_t* get_f() const; + + // Setters. + inline void set_f(java_handle_t* value); + + // Convenience functions. + inline fieldinfo* get_field() const; +}; + + +inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_Field((java_handle_t*) h); +} + +inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f) +{ + java_lang_reflect_VMField jlrvmf(f); + + if (jlrvmf.is_null()) + return; + + _handle = builtin_new(class_java_lang_reflect_Field); + + if (is_null()) + return; + + // Link the two Java objects. + set_f(jlrvmf.get_handle()); + jlrvmf.set_f(get_handle()); +} + + +inline int32_t java_lang_reflect_Field::get_flag() const +{ + return get(_handle, offset_flag); +} + +inline java_handle_t* java_lang_reflect_Field::get_f() const +{ + return get(_handle, offset_f); +} + + +inline void java_lang_reflect_Field::set_f(java_handle_t* value) +{ + set(_handle, offset_f, value); +} + + +inline fieldinfo* java_lang_reflect_Field::get_field() const +{ + java_lang_reflect_VMField jlrvmf(get_f()); + return jlrvmf.get_field(); +} + + +/** + * GNU Classpath java/lang/reflect/VMMethod + * + * Object layout: + * + * 0. object header + * 1. java.lang.Class clazz; + * 2. java.lang.String name; + * 3. int slot; + * 4. byte[] annotations; + * 5. byte[] parameterAnnotations; + * 6. byte[] annotationDefault; + * 7. java.lang.Map declaredAnnotations; + * 8. java.lang.reflect.Method m; + */ +class java_lang_reflect_VMMethod : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_clazz = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_name = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_slot = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_annotations = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_m = MEMORY_ALIGN(offset_declaredAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_VMMethod(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_VMMethod(jobject h); + java_lang_reflect_VMMethod(methodinfo* m); + + // Getters. + inline classinfo* get_clazz () const; + inline int32_t get_slot () const; + inline java_handle_bytearray_t* get_annotations () const; + inline java_handle_bytearray_t* get_parameterAnnotations() const; + inline java_handle_bytearray_t* get_annotationDefault () const; + inline java_handle_t* get_declaredAnnotations () const; + inline java_handle_t* get_m () const; + + // Setters. + inline void set_clazz (classinfo* value); + inline void set_name (java_handle_t* value); + inline void set_slot (int32_t value); + inline void set_annotations (java_handle_bytearray_t* value); + inline void set_parameterAnnotations(java_handle_bytearray_t* value); + inline void set_annotationDefault (java_handle_bytearray_t* value); + inline void set_declaredAnnotations (java_handle_t* value); + inline void set_m (java_handle_t* value); + + // Convenience functions. + inline methodinfo* get_method() const; +}; + +inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_VMMethod((java_handle_t*) h); +} + +inline java_lang_reflect_VMMethod::java_lang_reflect_VMMethod(methodinfo* m) +{ + _handle = builtin_new(class_java_lang_reflect_VMMethod); + + if (is_null()) + return; + + java_handle_t* name = javastring_intern(javastring_new(m->name)); + int slot = m - m->clazz->methods; + java_handle_bytearray_t* annotations = method_get_annotations(m); + java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m); + java_handle_bytearray_t* annotationDefault = method_get_annotationdefault(m); + + set_clazz(m->clazz); + set_name(name); + set_slot(slot); + set_annotations(annotations); + set_parameterAnnotations(parameterAnnotations); + set_annotationDefault(annotationDefault); +} + +inline classinfo* java_lang_reflect_VMMethod::get_clazz() const +{ + return get(_handle, offset_clazz); +} + +inline int32_t java_lang_reflect_VMMethod::get_slot() const +{ + return get(_handle, offset_slot); +} + +inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotations() const +{ + return get(_handle, offset_annotations); +} + +inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_parameterAnnotations() const +{ + return get(_handle, offset_parameterAnnotations); +} + +inline java_handle_bytearray_t* java_lang_reflect_VMMethod::get_annotationDefault() const +{ + return get(_handle, offset_annotationDefault); +} + +inline java_handle_t* java_lang_reflect_VMMethod::get_declaredAnnotations() const +{ + return get(_handle, offset_declaredAnnotations); +} + +inline java_handle_t* java_lang_reflect_VMMethod::get_m() const +{ + return get(_handle, offset_m); +} + +inline void java_lang_reflect_VMMethod::set_clazz(classinfo* value) +{ + set(_handle, offset_clazz, value); +} + +inline void java_lang_reflect_VMMethod::set_name(java_handle_t* value) +{ + set(_handle, offset_name, value); +} + +inline void java_lang_reflect_VMMethod::set_slot(int32_t value) +{ + set(_handle, offset_slot, value); +} + +inline void java_lang_reflect_VMMethod::set_annotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_annotations, value); +} + +inline void java_lang_reflect_VMMethod::set_parameterAnnotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_parameterAnnotations, value); +} + +inline void java_lang_reflect_VMMethod::set_annotationDefault(java_handle_bytearray_t* value) +{ + set(_handle, offset_annotationDefault, value); +} + +inline void java_lang_reflect_VMMethod::set_declaredAnnotations(java_handle_t* value) +{ + set(_handle, offset_declaredAnnotations, value); +} + +inline void java_lang_reflect_VMMethod::set_m(java_handle_t* value) +{ + set(_handle, offset_m, value); +} + +inline methodinfo* java_lang_reflect_VMMethod::get_method() const +{ + classinfo* c = get_clazz(); + int32_t slot = get_slot(); + methodinfo* m = &(c->methods[slot]); + return m; +} + + +/** + * GNU Classpath java/lang/reflect/Method + * + * Object layout: + * + * 0. object header + * 1. boolean flag; + * 2. gnu.java.lang.reflect.MethodSignatureParser p; + * 3. java.lang.reflect.VMMethod m; + */ +class java_lang_reflect_Method : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_flag = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_p = MEMORY_ALIGN(offset_flag + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_m = MEMORY_ALIGN(offset_p + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_Method(jobject h); + java_lang_reflect_Method(methodinfo* m); + + java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args); + + // Getters. + inline int32_t get_flag() const; + inline java_handle_t* get_m() const; + + // Setters. + inline void set_m(java_handle_t* value); + + // Convenience functions. + inline methodinfo* get_method () const; + inline int32_t get_override() const; +}; + + +inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_Method((java_handle_t*) h); +} + +inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m) +{ + java_lang_reflect_VMMethod jlrvmm(m); + + if (jlrvmm.is_null()) + return; + + _handle = builtin_new(class_java_lang_reflect_Method); + + if (is_null()) + return; + + // Link the two Java objects. + set_m(jlrvmm.get_handle()); + jlrvmm.set_m(get_handle()); +} + + +inline int32_t java_lang_reflect_Method::get_flag() const +{ + return get(_handle, offset_flag); +} + +inline java_handle_t* java_lang_reflect_Method::get_m() const +{ + return get(_handle, offset_m); +} + + +inline void java_lang_reflect_Method::set_m(java_handle_t* value) +{ + set(_handle, offset_m, value); +} + + +inline methodinfo* java_lang_reflect_Method::get_method() const +{ + java_lang_reflect_VMMethod jlrvmm(get_m()); + return jlrvmm.get_method(); +} + +inline int32_t java_lang_reflect_Method::get_override() const +{ + return get_flag(); +} + + +/** + * GNU Classpath java/nio/Buffer + * + * Object layout: + * + * 0. object header + * 1. int cap; + * 2. int limit; + * 3. int pos; + * 4. int mark; + * 5. gnu.classpath.Pointer address; + */ +class java_nio_Buffer : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P); + +public: + java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {} + + // Getters. + inline int32_t get_cap() const; +}; + +inline int32_t java_nio_Buffer::get_cap() const +{ + return get(_handle, offset_cap); +} + + +/** + * GNU Classpath java/nio/DirectByteBufferImpl + * + * Object layout: + * + * 0. object header + * 1. int cap; + * 2. int limit; + * 3. int pos; + * 4. int mark; + * 5. gnu.classpath.Pointer address; + * 6. java.nio.ByteOrder endian; + * 7. byte[] backing_buffer; + * 8. int array_offset; + * 9. java.lang.Object owner; + */ +class java_nio_DirectByteBufferImpl : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_cap = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_limit = MEMORY_ALIGN(offset_cap + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_pos = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_mark = MEMORY_ALIGN(offset_pos + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_address = MEMORY_ALIGN(offset_mark + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_endian = MEMORY_ALIGN(offset_address + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_backing_buffer = MEMORY_ALIGN(offset_endian + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_array_offset = MEMORY_ALIGN(offset_backing_buffer + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_owner = MEMORY_ALIGN(offset_array_offset + sizeof(int32_t), SIZEOF_VOID_P); + +public: + java_nio_DirectByteBufferImpl(java_handle_t* h) : java_lang_Object(h) {} + java_nio_DirectByteBufferImpl(jobject h); + + // Getters. + inline java_handle_t* get_address() const; +}; + +inline java_nio_DirectByteBufferImpl::java_nio_DirectByteBufferImpl(jobject h) : java_lang_Object(h) +{ + java_nio_DirectByteBufferImpl((java_handle_t*) h); +} + +inline java_handle_t* java_nio_DirectByteBufferImpl::get_address() const +{ + return get(_handle, offset_address); +} + + +/** + * GNU Classpath gnu/classpath/Pointer + * + * Actually there are two classes, gnu.classpath.Pointer32 and + * gnu.classpath.Pointer64, but we only define the abstract super + * class and use the int/long field as void* type. + * + * Object layout: + * + * 0. object header + * 1. int/long data; + */ +class gnu_classpath_Pointer : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_data = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + +public: + gnu_classpath_Pointer(java_handle_t* h) : java_lang_Object(h) {} + gnu_classpath_Pointer(java_handle_t* h, void* data); + + // Setters. + inline void* get_data() const; + + // Setters. + inline void set_data(void* value); +}; + +inline gnu_classpath_Pointer::gnu_classpath_Pointer(java_handle_t* h, void* data) : java_lang_Object(h) +{ + set_data(data); +} + +inline void* gnu_classpath_Pointer::get_data() const +{ + return get(_handle, offset_data); +} + +inline void gnu_classpath_Pointer::set_data(void* value) +{ + set(_handle, offset_data, value); +} + +#endif // WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH + + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + +/** + * OpenJDK java/lang/AssertionStatusDirectives + * + * Object layout: + * + * 0. object header + * 1. java.lang.String[] classes; + * 2. boolean[] classEnabled; + * 3. java.lang.String[] packages; + * 4. boolean[] packageEnabled; + * 5. boolean deflt; + */ +class java_lang_AssertionStatusDirectives : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_classes = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_classEnabled = MEMORY_ALIGN(offset_classes + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_packages = MEMORY_ALIGN(offset_classEnabled + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_packageEnabled = MEMORY_ALIGN(offset_packages + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_deflt = MEMORY_ALIGN(offset_packageEnabled + SIZEOF_VOID_P, sizeof(int32_t)); + +public: + java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled); +}; + +inline java_lang_AssertionStatusDirectives::java_lang_AssertionStatusDirectives(java_handle_objectarray_t* classes, java_handle_booleanarray_t* classEnabled, java_handle_objectarray_t* packages, java_handle_booleanarray_t* packageEnabled) +{ + classinfo* c = load_class_bootstrap(utf_new_char("java/lang/AssertionStatusDirectives")); + + // FIXME Load the class at VM startup. + if (c == NULL) + return; + + _handle = builtin_new(c); + + if (is_null()) + return; + + set(_handle, offset_classes, classes); + set(_handle, offset_classEnabled, classEnabled); + set(_handle, offset_packages, packages); + set(_handle, offset_packageEnabled, packageEnabled); +} + + +/** + * OpenJDK java/lang/StackTraceElement + * + * Object layout: + * + * 0. object header + * 1. java.lang.String declaringClass; + * 2. java.lang.String methodName; + * 3. java.lang.String fileName; + * 4. int lineNumber; + */ +class java_lang_StackTraceElement : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_declaringClass = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_methodName = MEMORY_ALIGN(offset_declaringClass + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_fileName = MEMORY_ALIGN(offset_methodName + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_lineNumber = MEMORY_ALIGN(offset_fileName + SIZEOF_VOID_P, sizeof(int32_t)); + +public: + java_lang_StackTraceElement(java_handle_t* h) : java_lang_Object(h) {} + java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber); +}; + +inline java_lang_StackTraceElement::java_lang_StackTraceElement(java_handle_t* declaringClass, java_handle_t* methodName, java_handle_t* fileName, int32_t lineNumber) +{ + _handle = builtin_new(class_java_lang_StackTraceElement); + + if (is_null()) + return; + + set(_handle, offset_declaringClass, declaringClass); + set(_handle, offset_methodName, methodName); + set(_handle, offset_fileName, fileName); + set(_handle, offset_lineNumber, lineNumber); +} + + +/** + * OpenJDK java/lang/String + * + * Object layout: + * + * 0. object header + * 1. char[] value; + * 2. int offset; + * 3. int count; + * 4. int hash; + */ +class java_lang_String : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_hash = MEMORY_ALIGN(offset_count + sizeof(int32_t), sizeof(int32_t)); + +public: + java_lang_String(java_handle_t* h) : java_lang_Object(h) {} + java_lang_String(jstring h); + java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0); + + // Getters. + inline java_handle_chararray_t* get_value () const; + inline int32_t get_offset() const; + inline int32_t get_count () const; + + // Setters. + inline void set_value (java_handle_chararray_t* value); + inline void set_offset(int32_t value); + inline void set_count (int32_t value); +}; + +inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h) +{ + java_lang_String((java_handle_t*) h); +} + +inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h) +{ + set_value(value); + set_offset(offset); + set_count(count); +} + +inline java_handle_chararray_t* java_lang_String::get_value() const +{ + return get(_handle, offset_value); +} + +inline int32_t java_lang_String::get_offset() const +{ + return get(_handle, offset_offset); +} + +inline int32_t java_lang_String::get_count() const +{ + return get(_handle, offset_count); +} + +inline void java_lang_String::set_value(java_handle_chararray_t* value) +{ + set(_handle, offset_value, value); +} + +inline void java_lang_String::set_offset(int32_t value) +{ + set(_handle, offset_offset, value); +} + +inline void java_lang_String::set_count(int32_t value) +{ + set(_handle, offset_count, value); +} + + +/** + * OpenJDK java/lang/Thread + * + * Object layout: + * + * 0. object header + * 1. char[] name; + * 2. int priority; + * 3. java_lang_Thread threadQ; + * 4. long eetop; + * 5. boolean single_step; + * 6. boolean daemon; + * 7. boolean stillborn; + * 8. java_lang_Runnable target; + * 9. java_lang_ThreadGroup group; + * 10. java_lang_ClassLoader contextClassLoader; + * 11. java_security_AccessControlContext inheritedAccessControlContext; + * 12. java_lang_ThreadLocal_ThreadLocalMap threadLocals; + * 13. java_lang_ThreadLocal_ThreadLocalMap inheritableThreadLocals; + * 14. long stackSize; + * 15. long nativeParkEventPointer; + * 16. long tid; + * 17. int threadStatus; + * 18. java_lang_Object parkBlocker; + * 19. sun_nio_ch_Interruptible blocker; + * 20. java_lang_Object blockerLock; + * 21. boolean stopBeforeStart; + * 22. java_lang_Throwable throwableFromStop; + * 23. java.lang.Thread.UncaughtExceptionHandler uncaughtExceptionHandler; + */ +class java_lang_Thread : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_name = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_priority = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_threadQ = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_eetop = MEMORY_ALIGN(offset_threadQ + SIZEOF_VOID_P, sizeof(int64_t)); + static const off_t offset_single_step = MEMORY_ALIGN(offset_eetop + sizeof(int64_t), sizeof(int32_t)); + static const off_t offset_daemon = MEMORY_ALIGN(offset_single_step + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_stillborn = MEMORY_ALIGN(offset_daemon + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_target = MEMORY_ALIGN(offset_stillborn + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_group = MEMORY_ALIGN(offset_target + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_contextClassLoader = MEMORY_ALIGN(offset_group + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_inheritedAccessControlContext = MEMORY_ALIGN(offset_contextClassLoader + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_threadLocals = MEMORY_ALIGN(offset_inheritedAccessControlContext + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_inheritableThreadLocals = MEMORY_ALIGN(offset_threadLocals + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_stackSize = MEMORY_ALIGN(offset_inheritableThreadLocals + SIZEOF_VOID_P, sizeof(int64_t)); + static const off_t offset_nativeParkEventPointer = MEMORY_ALIGN(offset_stackSize + sizeof(int64_t), sizeof(int64_t)); + static const off_t offset_tid = MEMORY_ALIGN(offset_nativeParkEventPointer + sizeof(int64_t), sizeof(int64_t)); + static const off_t offset_threadStatus = MEMORY_ALIGN(offset_tid + sizeof(int64_t), sizeof(int32_t)); + static const off_t offset_parkBlocker = MEMORY_ALIGN(offset_threadStatus + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_blocker = MEMORY_ALIGN(offset_parkBlocker + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_blockerLock = MEMORY_ALIGN(offset_blocker + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_stopBeforeStart = MEMORY_ALIGN(offset_blockerLock + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_throwableFromStop = MEMORY_ALIGN(offset_stopBeforeStart + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_uncaughtExceptionHandler = MEMORY_ALIGN(offset_throwableFromStop + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {} +// java_lang_Thread(threadobject* t); + + // Getters. + inline int32_t get_priority () const; + inline int32_t get_daemon () const; + inline java_handle_t* get_group () const; + inline java_handle_t* get_uncaughtExceptionHandler() const; + + // Setters. + inline void set_priority(int32_t value); + inline void set_group (java_handle_t* value); +}; + + +inline int32_t java_lang_Thread::get_priority() const +{ + return get(_handle, offset_priority); +} + +inline int32_t java_lang_Thread::get_daemon() const +{ + return get(_handle, offset_daemon); +} + +inline java_handle_t* java_lang_Thread::get_group() const +{ + return get(_handle, offset_group); +} + +inline java_handle_t* java_lang_Thread::get_uncaughtExceptionHandler() const +{ + return get(_handle, offset_uncaughtExceptionHandler); +} + + +inline void java_lang_Thread::set_priority(int32_t value) +{ + set(_handle, offset_priority, value); +} + +inline void java_lang_Thread::set_group(java_handle_t* value) +{ + set(_handle, offset_group, value); +} + + + +/** + * OpenJDK java/lang/Throwable + * + * Object layout: + * + * 0. object header + * 1. java.lang.Object backtrace; + * 2. java.lang.String detailMessage; + * 3. java.lang.Throwable cause; + * 4. java.lang.StackTraceElement[] stackTrace; + */ +class java_lang_Throwable : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_backtrace = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_detailMessage = MEMORY_ALIGN(offset_backtrace + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_cause = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_stackTrace = MEMORY_ALIGN(offset_cause + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {} + java_lang_Throwable(jobject h); + java_lang_Throwable(jobject h, java_handle_bytearray_t* backtrace); + + // Getters. + inline java_handle_bytearray_t* get_backtrace () const; + inline java_handle_t* get_detailMessage() const; + inline java_handle_t* get_cause () const; + + // Setters. + inline void set_backtrace(java_handle_bytearray_t* value); +}; + + +inline java_lang_Throwable::java_lang_Throwable(jobject h) : java_lang_Object(h) +{ + java_lang_Throwable((java_handle_t*) h); +} + +inline java_lang_Throwable::java_lang_Throwable(jobject h, java_handle_bytearray_t* backtrace) : java_lang_Object(h) +{ + java_lang_Throwable((java_handle_t*) h); + set_backtrace(backtrace); +} + + +inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const +{ + return get(_handle, offset_backtrace); +} + +inline java_handle_t* java_lang_Throwable::get_detailMessage() const +{ + return get(_handle, offset_detailMessage); +} + +inline java_handle_t* java_lang_Throwable::get_cause() const +{ + return get(_handle, offset_cause); +} + + +inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value) +{ + set(_handle, offset_backtrace, value); +} + + +/** + * OpenJDK java/lang/reflect/Constructor + * + * Object layout: + * + * 0. object header + * 1. boolean override; + * 2. java.lang.Class clazz; + * 3. int slot; + * 4. java.lang.Class[] parameterTypes; + * 5. java.lang.Class[] exceptionTypes; + * 6. int modifiers; + * 7. java.lang.String signature; + * 8. sun.reflect.generics.repository.ConstructorRepository genericInfo; + * 9. byte[] annotations; + * 10. byte[] parameterAnnotations; + * 11. java.lang.Class securityCheckCache; + * 12. sun.reflect.ConstructorAccessor constructorAccessor; + * 13. java.lang.reflect.Constructor root; + * 14. java.util.Map declaredAnnotations; + */ +class java_lang_reflect_Constructor : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_constructorAccessor = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_root = MEMORY_ALIGN(offset_constructorAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_Constructor(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_Constructor(jobject h); + java_lang_reflect_Constructor(methodinfo* m); + + java_handle_t* new_instance(java_handle_objectarray_t* args); + + // Getters. + inline int32_t get_override () const; + inline classinfo* get_clazz () const; + inline int32_t get_slot () const; + inline java_handle_bytearray_t* get_annotations() const; + + // Setters. + inline void set_clazz (classinfo* value); + inline void set_slot (int32_t value); + inline void set_parameterTypes (java_handle_objectarray_t* value); + inline void set_exceptionTypes (java_handle_objectarray_t* value); + inline void set_modifiers (int32_t value); + inline void set_signature (java_handle_t* value); + inline void set_annotations (java_handle_bytearray_t* value); + inline void set_parameterAnnotations(java_handle_bytearray_t* value); + + // Convenience functions. + inline methodinfo* get_method(); +}; + + +inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_Constructor((java_handle_t*) h); +} + +inline java_lang_reflect_Constructor::java_lang_reflect_Constructor(methodinfo* m) +{ + _handle = builtin_new(class_java_lang_reflect_Constructor); + + if (is_null()) + return; + + int slot = m - m->clazz->methods; + java_handle_objectarray_t* parameterTypes = method_get_parametertypearray(m); + java_handle_objectarray_t* exceptionTypes = method_get_exceptionarray(m); + java_handle_bytearray_t* annotations = method_get_annotations(m); + java_handle_bytearray_t* parameterAnnotations = method_get_parameterannotations(m); + + set_clazz(m->clazz); + set_slot(slot); + set_parameterTypes(parameterTypes); + set_exceptionTypes(exceptionTypes); + set_modifiers(m->flags & ACC_CLASS_REFLECT_MASK); + set_signature(m->signature ? javastring_new(m->signature) : NULL); + set_annotations(annotations); + set_parameterAnnotations(parameterAnnotations); +} + + +inline int32_t java_lang_reflect_Constructor::get_override() const +{ + return get(_handle, offset_override); +} + +inline classinfo* java_lang_reflect_Constructor::get_clazz() const +{ + return get(_handle, offset_clazz); +} + +inline int32_t java_lang_reflect_Constructor::get_slot() const +{ + return get(_handle, offset_slot); +} + +inline java_handle_bytearray_t* java_lang_reflect_Constructor::get_annotations() const +{ + return get(_handle, offset_annotations); +} + + +inline void java_lang_reflect_Constructor::set_clazz(classinfo* value) +{ + set(_handle, offset_clazz, value); +} + +inline void java_lang_reflect_Constructor::set_slot(int32_t value) +{ + set(_handle, offset_slot, value); +} + +inline void java_lang_reflect_Constructor::set_parameterTypes(java_handle_objectarray_t* value) +{ + set(_handle, offset_parameterTypes, value); +} + +inline void java_lang_reflect_Constructor::set_exceptionTypes(java_handle_objectarray_t* value) +{ + set(_handle, offset_exceptionTypes, value); +} + +inline void java_lang_reflect_Constructor::set_modifiers(int32_t value) +{ + set(_handle, offset_modifiers, value); +} + +inline void java_lang_reflect_Constructor::set_signature(java_handle_t* value) +{ + set(_handle, offset_signature, value); +} + +inline void java_lang_reflect_Constructor::set_annotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_annotations, value); +} + +inline void java_lang_reflect_Constructor::set_parameterAnnotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_parameterAnnotations, value); +} + + +inline methodinfo* java_lang_reflect_Constructor::get_method() +{ + classinfo* c = get_clazz(); + int32_t slot = get_slot(); + methodinfo* m = &(c->methods[slot]); + return m; +} + + +/** + * OpenJDK java/lang/reflect/Field + * + * Object layout: + * + * 0. object header + * 1. boolean override; + * 2. java.lang.Class clazz; + * 3. int slot; + * 4. java.lang.String name; + * 5. java.lang.Class type; + * 6. int modifiers; + * 7. java.lang.String signature; + * 8. sun.reflect.generics.repository.FieldRepository genericInfo; + * 9. byte[] annotations; + * 10. sun.reflect.FieldAccessor fieldAccessor; + * 11. sun.reflect.FieldAccessor overrideFieldAccessor; + * 12. java.lang.reflect.Field root; + * 13. java.lang.Class securityCheckCache; + * 14. java.lang.Class securityCheckTargetClassCache; + * 15. java.util.Map declaredAnnotations; + */ +class java_lang_reflect_Field : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_type = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_modifiers = MEMORY_ALIGN(offset_type + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_fieldAccessor = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_overrideFieldAccessor = MEMORY_ALIGN(offset_fieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_root = MEMORY_ALIGN(offset_overrideFieldAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_Field(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_Field(jobject h); + java_lang_reflect_Field(fieldinfo* f); + + // Getters. + inline int32_t get_override () const; + inline classinfo* get_clazz () const; + inline int32_t get_slot () const; + inline java_handle_bytearray_t* get_annotations() const; + + // Setters. + inline void set_clazz (classinfo* value); + inline void set_slot (int32_t value); + inline void set_name (java_handle_t* value); + inline void set_type (classinfo* value); + inline void set_modifiers (int32_t value); + inline void set_signature (java_handle_t* value); + inline void set_annotations(java_handle_bytearray_t* value); + + // Convenience functions. + inline fieldinfo* get_field() const; +}; + + +inline java_lang_reflect_Field::java_lang_reflect_Field(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_Field((java_handle_t*) h); +} + +inline java_lang_reflect_Field::java_lang_reflect_Field(fieldinfo* f) +{ + _handle = builtin_new(class_java_lang_reflect_Field); + + // OOME. + if (is_null()) + return; + + set_clazz(f->clazz); + set_slot(f - f->clazz->fields); + set_name(javastring_intern(javastring_new(f->name))); + set_type(field_get_type(f)); + set_modifiers(f->flags); + set_signature(f->signature ? javastring_new(f->signature) : NULL); + set_annotations(field_get_annotations(f)); +} + + +inline int32_t java_lang_reflect_Field::get_override() const +{ + return get(_handle, offset_override); +} + +inline classinfo* java_lang_reflect_Field::get_clazz() const +{ + return get(_handle, offset_clazz); +} + +inline int32_t java_lang_reflect_Field::get_slot() const +{ + return get(_handle, offset_slot); +} + +inline java_handle_bytearray_t* java_lang_reflect_Field::get_annotations() const +{ + return get(_handle, offset_annotations); +} + + +inline void java_lang_reflect_Field::set_clazz(classinfo* value) +{ + set(_handle, offset_clazz, value); +} + +inline void java_lang_reflect_Field::set_slot(int32_t value) +{ + set(_handle, offset_slot, value); +} + +inline void java_lang_reflect_Field::set_name(java_handle_t* value) +{ + set(_handle, offset_name, value); +} + +inline void java_lang_reflect_Field::set_type(classinfo* value) +{ + set(_handle, offset_type, value); +} + +inline void java_lang_reflect_Field::set_modifiers(int32_t value) +{ + set(_handle, offset_modifiers, value); +} + +inline void java_lang_reflect_Field::set_signature(java_handle_t* value) +{ + set(_handle, offset_signature, value); +} + +inline void java_lang_reflect_Field::set_annotations(java_handle_bytearray_t* value) +{ + set(_handle, offset_annotations, value); +} + + +inline fieldinfo* java_lang_reflect_Field::get_field() const +{ + classinfo* c = get_clazz(); + int32_t slot = get_slot(); + fieldinfo* f = &(c->fields[slot]); + return f; +} + + +/** + * OpenJDK java/lang/reflect/Method + * + * Object layout: + * + * 0. object header + * 1. boolean override; + * 2. java.lang.Class clazz; + * 3. int slot; + * 4. java.lang.String name; + * 5. java.lang.Class returnType; + * 6. java.lang.Class[] parameterTypes; + * 7. java.lang.Class[] exceptionTypes; + * 8. int modifiers; + * 9. java.lang.String signature; + * 10 sun.reflect.generics.repository.ConstructorRepository genericInfo; + * 11. byte[] annotations; + * 12. byte[] parameterAnnotations; + * 13. byte[] annotationDefault; + * 14. sun.reflect.MethodAccessor methodAccessor; + * 15. java.lang.reflect.Method root; + * 16. java.lang.Class securityCheckCache; + * 17. java.lang.Class securityCheckTargetClassCache; + * 18. java.util.Map declaredAnnotations; + */ +class java_lang_reflect_Method : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_override = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_clazz = MEMORY_ALIGN(offset_override + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_slot = MEMORY_ALIGN(offset_clazz + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_name = MEMORY_ALIGN(offset_slot + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_returnType = MEMORY_ALIGN(offset_name + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_parameterTypes = MEMORY_ALIGN(offset_returnType + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_exceptionTypes = MEMORY_ALIGN(offset_parameterTypes + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_modifiers = MEMORY_ALIGN(offset_exceptionTypes + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_signature = MEMORY_ALIGN(offset_modifiers + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_genericInfo = MEMORY_ALIGN(offset_signature + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_annotations = MEMORY_ALIGN(offset_genericInfo + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_parameterAnnotations = MEMORY_ALIGN(offset_annotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_annotationDefault = MEMORY_ALIGN(offset_parameterAnnotations + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_methodAccessor = MEMORY_ALIGN(offset_annotationDefault + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_root = MEMORY_ALIGN(offset_methodAccessor + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_securityCheckCache = MEMORY_ALIGN(offset_root + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_securityCheckTargetClassCache = MEMORY_ALIGN(offset_securityCheckCache + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_declaredAnnotations = MEMORY_ALIGN(offset_securityCheckTargetClassCache + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_reflect_Method(java_handle_t* h) : java_lang_Object(h) {} + java_lang_reflect_Method(jobject h); + java_lang_reflect_Method(methodinfo* m); + + java_handle_t* invoke(java_handle_t* o, java_handle_objectarray_t* args); + + // Getters. + inline int32_t get_override () const; + inline classinfo* get_clazz () const; + inline int32_t get_slot () const; + inline java_handle_bytearray_t* get_annotations () const; + inline java_handle_bytearray_t* get_parameterAnnotations() const; + inline java_handle_bytearray_t* get_annotationDefault () const; + + // Setters. + + // Convenience functions. + inline methodinfo* get_method() const; +}; + + +inline java_lang_reflect_Method::java_lang_reflect_Method(jobject h) : java_lang_Object(h) +{ + java_lang_reflect_Method((java_handle_t*) h); +} + +inline java_lang_reflect_Method::java_lang_reflect_Method(methodinfo* m) +{ + _handle = builtin_new(class_java_lang_reflect_Method); + + if (is_null()) + return; + + set(_handle, offset_clazz, m->clazz); + set(_handle, offset_slot, (int32_t) (m - m->clazz->methods)); // This cast is important (see PR100). + set(_handle, offset_name, javastring_intern(javastring_new(m->name))); + set(_handle, offset_returnType, method_returntype_get(m)); + set(_handle, offset_parameterTypes, method_get_parametertypearray(m)); + set(_handle, offset_exceptionTypes, method_get_exceptionarray(m)); + set(_handle, offset_modifiers, (int32_t) (m->flags & ACC_CLASS_REFLECT_MASK)); + set(_handle, offset_signature, m->signature ? javastring_new(m->signature) : NULL); + set(_handle, offset_annotations, method_get_annotations(m)); + set(_handle, offset_parameterAnnotations, method_get_parameterannotations(m)); + set(_handle, offset_annotationDefault, method_get_annotationdefault(m)); +} + + +inline int32_t java_lang_reflect_Method::get_override() const +{ + return get(_handle, offset_override); +} + +inline classinfo* java_lang_reflect_Method::get_clazz() const +{ + return get(_handle, offset_clazz); +} + +inline int32_t java_lang_reflect_Method::get_slot() const +{ + return get(_handle, offset_slot); +} + +inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotations() const +{ + return get(_handle, offset_annotations); +} + +inline java_handle_bytearray_t* java_lang_reflect_Method::get_parameterAnnotations() const +{ + return get(_handle, offset_parameterAnnotations); +} + +inline java_handle_bytearray_t* java_lang_reflect_Method::get_annotationDefault() const +{ + return get(_handle, offset_annotationDefault); +} + + +inline methodinfo* java_lang_reflect_Method::get_method() const +{ + classinfo* c = get_clazz(); + int32_t slot = get_slot(); + methodinfo* m = &(c->methods[slot]); + return m; +} + + +/** + * OpenJDK java/nio/Buffer + * + * Object layout: + * + * 0. object header + * 1. int mark; + * 2. int position; + * 3. int limit; + * 4. int capacity; + * 5. long address; + */ +class java_nio_Buffer : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_mark = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_position = MEMORY_ALIGN(offset_mark + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_limit = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_capacity = MEMORY_ALIGN(offset_limit + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_address = MEMORY_ALIGN(offset_capacity + sizeof(int32_t), sizeof(int64_t)); + +public: + java_nio_Buffer(java_handle_t* h) : java_lang_Object(h) {} + java_nio_Buffer(jobject h) : java_lang_Object(h) {} + + // Getters. + inline void* get_address() const; +}; + + +inline void* java_nio_Buffer::get_address() const +{ + return get(_handle, offset_address); +} + +#endif // WITH_JAVA_RUNTIME_LIBRARY_OPENJDK + + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + +/** + * CLDC 1.1 com/sun/cldchi/jvm/FileDescriptor + * + * Object layout: + * + * 0. object header + * 1. long pointer; + * 2. int position; + * 3. int length; + */ +class com_sun_cldchi_jvm_FileDescriptor : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_pointer = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int64_t)); + static const off_t offset_position = MEMORY_ALIGN(offset_pointer + sizeof(int64_t), sizeof(int32_t)); + static const off_t offset_length = MEMORY_ALIGN(offset_position + sizeof(int32_t), sizeof(int32_t)); + +public: + com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h) : java_lang_Object(h) {} + com_sun_cldchi_jvm_FileDescriptor(jobject h); + com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length); + com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd); + + // Getters. + inline int64_t get_pointer () const; + inline int32_t get_position() const; + inline int32_t get_length () const; + + // Setters. + inline void set_pointer (int64_t value); + inline void set_position(int32_t value); + inline void set_length (int32_t value); +}; + + +inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(jobject h) : java_lang_Object(h) +{ + com_sun_cldchi_jvm_FileDescriptor((java_handle_t*) h); +} + +inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, int64_t pointer, int32_t position, int32_t length) : java_lang_Object(h) +{ + set_pointer(pointer); + set_position(position); + set_length(length); +} + +inline com_sun_cldchi_jvm_FileDescriptor::com_sun_cldchi_jvm_FileDescriptor(java_handle_t* h, com_sun_cldchi_jvm_FileDescriptor& fd) : java_lang_Object(h) +{ + com_sun_cldchi_jvm_FileDescriptor(h, fd.get_pointer(), fd.get_position(), fd.get_length()); +} + + +inline int64_t com_sun_cldchi_jvm_FileDescriptor::get_pointer() const +{ + return get(_handle, offset_pointer); +} + +inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_position() const +{ + return get(_handle, offset_position); +} + +inline int32_t com_sun_cldchi_jvm_FileDescriptor::get_length() const +{ + return get(_handle, offset_length); +} + + +inline void com_sun_cldchi_jvm_FileDescriptor::set_pointer(int64_t value) +{ + set(_handle, offset_pointer, value); +} + +inline void com_sun_cldchi_jvm_FileDescriptor::set_position(int32_t value) +{ + set(_handle, offset_position, value); +} + +inline void com_sun_cldchi_jvm_FileDescriptor::set_length(int32_t value) +{ + set(_handle, offset_length, value); +} + + +/** + * CLDC 1.1 java/lang/String + * + * Object layout: + * + * 0. object header + * 1. char[] value; + * 2. int offset; + * 3. int count; + */ +class java_lang_String : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_value = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_offset = MEMORY_ALIGN(offset_value + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_count = MEMORY_ALIGN(offset_offset + sizeof(int32_t), sizeof(int32_t)); + +public: + java_lang_String(java_handle_t* h) : java_lang_Object(h) {} + java_lang_String(jstring h); + java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset = 0); + + // Getters. + inline java_handle_chararray_t* get_value () const; + inline int32_t get_offset() const; + inline int32_t get_count () const; + + // Setters. + inline void set_value (java_handle_chararray_t* value); + inline void set_offset(int32_t value); + inline void set_count (int32_t value); +}; + +inline java_lang_String::java_lang_String(jstring h) : java_lang_Object(h) +{ + java_lang_String((java_handle_t*) h); +} + +inline java_lang_String::java_lang_String(java_handle_t* h, java_handle_chararray_t* value, int32_t count, int32_t offset) : java_lang_Object(h) +{ + set_value(value); + set_offset(offset); + set_count(count); +} + +inline java_handle_chararray_t* java_lang_String::get_value() const +{ + return get(_handle, offset_value); +} + +inline int32_t java_lang_String::get_offset() const +{ + return get(_handle, offset_offset); +} + +inline int32_t java_lang_String::get_count() const +{ + return get(_handle, offset_count); +} + +inline void java_lang_String::set_value(java_handle_chararray_t* value) +{ + set(_handle, offset_value, value); +} + +inline void java_lang_String::set_offset(int32_t value) +{ + set(_handle, offset_offset, value); +} + +inline void java_lang_String::set_count(int32_t value) +{ + set(_handle, offset_count, value); +} + + +/** + * CLDC 1.1 java/lang/Thread + * + * Object layout: + * + * 0. object header + * 1. int priority; + * 2. java.lang.Runnable runnable; + * 3. java.lang.Object vm_thread; + * 4. int is_terminated; + * 5. int is_stillborn; + * 6. char[] name; + */ +class java_lang_Thread : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_priority = MEMORY_ALIGN(sizeof(java_object_t), sizeof(int32_t)); + static const off_t offset_runnable = MEMORY_ALIGN(offset_priority + sizeof(int32_t), SIZEOF_VOID_P); + static const off_t offset_vm_thread = MEMORY_ALIGN(offset_runnable + SIZEOF_VOID_P, SIZEOF_VOID_P); + static const off_t offset_is_terminated = MEMORY_ALIGN(offset_vm_thread + SIZEOF_VOID_P, sizeof(int32_t)); + static const off_t offset_is_stillborn = MEMORY_ALIGN(offset_is_terminated + sizeof(int32_t), sizeof(int32_t)); + static const off_t offset_name = MEMORY_ALIGN(offset_is_stillborn + sizeof(int32_t), SIZEOF_VOID_P); + +public: + java_lang_Thread(java_handle_t* h) : java_lang_Object(h) {} + java_lang_Thread(jobject h); +// java_lang_Thread(threadobject* t); + + // Getters. + inline int32_t get_priority () const; + inline threadobject* get_vm_thread() const; + inline java_handle_chararray_t* get_name () const; + + // Setters. + inline void set_vm_thread(threadobject* value); +}; + + +inline java_lang_Thread::java_lang_Thread(jobject h) : java_lang_Object(h) +{ + java_lang_Thread((java_handle_t*) h); +} + +// inline java_lang_Thread::java_lang_Thread(threadobject* t) : java_lang_Object(h) +// { +// java_lang_Thread(thread_get_object(t)); +// } + + +inline int32_t java_lang_Thread::get_priority() const +{ + return get(_handle, offset_priority); +} + +inline threadobject* java_lang_Thread::get_vm_thread() const +{ + return get(_handle, offset_vm_thread); +} + +inline java_handle_chararray_t* java_lang_Thread::get_name() const +{ + return get(_handle, offset_name); +} + + +inline void java_lang_Thread::set_vm_thread(threadobject* value) +{ + set(_handle, offset_vm_thread, value); +} + + +/** + * CLDC 1.1 java/lang/Throwable + * + * Object layout: + * + * 0. object header + * 1. java.lang.String detailMessage; + * 2. java.lang.Object backtrace; + */ +class java_lang_Throwable : public java_lang_Object, private FieldAccess { +private: + // Static offsets of the object's instance fields. + // TODO These offsets need to be checked on VM startup. + static const off_t offset_detailMessage = MEMORY_ALIGN(sizeof(java_object_t), SIZEOF_VOID_P); + static const off_t offset_backtrace = MEMORY_ALIGN(offset_detailMessage + SIZEOF_VOID_P, SIZEOF_VOID_P); + +public: + java_lang_Throwable(java_handle_t* h) : java_lang_Object(h) {} + java_lang_Throwable(jobject h); + + // Getters. + inline java_handle_t* get_detailMessage() const; + inline java_handle_bytearray_t* get_backtrace () const; + + // Setters. + inline void set_backtrace(java_handle_bytearray_t* value); +}; + + +inline java_lang_Throwable::java_lang_Throwable(jobject h) : java_lang_Object(h) +{ + java_lang_Throwable((java_handle_t*) h); +} + + +inline java_handle_t* java_lang_Throwable::get_detailMessage() const +{ + return get(_handle, offset_detailMessage); +} + +inline java_handle_bytearray_t* java_lang_Throwable::get_backtrace() const +{ + return get(_handle, offset_backtrace); +} + + +inline void java_lang_Throwable::set_backtrace(java_handle_bytearray_t* value) +{ + set(_handle, offset_backtrace, value); +} + +#endif // WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1 + +#else + +// Legacy C interface. +java_handle_t* java_lang_reflect_Constructor_create(methodinfo* m); +java_handle_t* java_lang_reflect_Field_create(fieldinfo* f); +java_handle_t* java_lang_reflect_Method_create(methodinfo* m); + +#endif + +#endif // _JAVAOBJECTS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/Makefile.am b/src/vm/jit/Makefile.am index 015a917ce..e6eab136d 100644 --- a/src/vm/jit/Makefile.am +++ b/src/vm/jit/Makefile.am @@ -103,7 +103,7 @@ REG_SOURCES = \ reg.h REPLACE_SOURCES += \ - replace.h + replace.hpp STACK_SOURCES = \ stack.c \ @@ -116,7 +116,7 @@ endif if ENABLE_REPLACEMENT REPLACE_SOURCES += \ - replace.c + replace.cpp endif if ENABLE_VERIFIER @@ -127,6 +127,13 @@ VERIFIER_LIB = \ verify/libverify.la endif +if ENABLE_OPAGENT +OPAGENT_SOURCES = \ + oprofile-agent.cpp \ + oprofile-agent.hpp + +endif + if WITH_BINUTILS_DISASSEMBLER DISASS_SOURCES = disass-common.c endif @@ -143,42 +150,47 @@ noinst_LTLIBRARIES = \ libjit_la_SOURCES = \ argument.c \ argument.h \ - code.c \ - code.h \ - codegen-common.c \ - codegen-common.h \ + builtin.cpp \ + builtin.hpp \ + builtintable.inc \ + code.cpp \ + code.hpp \ + codegen-common.cpp \ + codegen-common.hpp \ disass.h \ $(DISASS_SOURCES) \ dseg.c \ dseg.h \ - emit-common.c \ - emit-common.h \ + emit-common.cpp \ + emit-common.hpp \ exceptiontable.c \ exceptiontable.h \ executionstate.c \ executionstate.h \ - icmdtable.inc \ - jit.c \ - jit.h \ + jit.cpp \ + jit.hpp \ linenumbertable.c \ linenumbertable.h \ methodtree.c \ methodtree.h \ parse.c \ parse.h \ - patcher-common.c \ - patcher-common.h \ + patcher-common.cpp \ + patcher-common.hpp \ $(RECOMPILE_SOURCES) \ $(REG_SOURCES) \ $(REPLACE_SOURCES) \ show.c \ show.h \ $(STACK_SOURCES) \ - stacktrace.c \ - stacktrace.h \ - trace.c \ - trace.h \ - $(TRAP_SOURCES) + stacktrace.cpp \ + stacktrace.hpp \ + stubs.cpp \ + stubs.hpp \ + trace.cpp \ + trace.hpp \ + $(TRAP_SOURCES) \ + $(OPAGENT_SOURCES) libjit_la_SOURCES += \ cfg.c \ diff --git a/src/vm/jit/abi.h b/src/vm/jit/abi.h index 6a84ade40..2bd0e8b8b 100644 --- a/src/vm/jit/abi.h +++ b/src/vm/jit/abi.h @@ -32,7 +32,7 @@ #include "arch.h" #include "vm/jit/abi-asm.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/stack.h" @@ -64,6 +64,10 @@ extern const s4 abi_registers_float_temporary[]; /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + /* machine dependent descriptor function */ void md_param_alloc(methoddesc *md); void md_param_alloc_native(methoddesc *md); @@ -71,6 +75,10 @@ void md_param_alloc_native(methoddesc *md); /* machine dependent return value handling function */ void md_return_alloc(jitdata *jd, stackelement_t *stackslot); +#ifdef __cplusplus +} +#endif + #endif /* _ABI_H */ diff --git a/src/vm/jit/allocator/liveness.c b/src/vm/jit/allocator/liveness.c index 5a0e1da95..7ceaea228 100644 --- a/src/vm/jit/allocator/liveness.c +++ b/src/vm/jit/allocator/liveness.c @@ -35,13 +35,13 @@ #include "toolbox/logging.h" #include "toolbox/worklist.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" #include "vm/method.h" #include "vm/resolve.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/allocator/lsra.h" #include "vm/jit/allocator/liveness.h" diff --git a/src/vm/jit/allocator/lsra.c b/src/vm/jit/allocator/lsra.c index 0ac20d24b..83b64c81c 100644 --- a/src/vm/jit/allocator/lsra.c +++ b/src/vm/jit/allocator/lsra.c @@ -36,15 +36,18 @@ #include "vm/types.h" #include "mm/memory.h" + #include "toolbox/logging.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/resolve.h" #include "vm/options.h" #include "vm/statistics.h" -#include "vm/stringlocal.h" + #include "vm/jit/abi.h" #include "vm/jit/reg.h" + #include "vm/jit/allocator/liveness.h" #include "vm/jit/allocator/lsra.h" diff --git a/src/vm/jit/allocator/simplereg.c b/src/vm/jit/allocator/simplereg.c index f8cbcab9d..ba7b565d4 100644 --- a/src/vm/jit/allocator/simplereg.c +++ b/src/vm/jit/allocator/simplereg.c @@ -35,19 +35,18 @@ #include "mm/memory.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/method.h" +#include "vm/options.h" #include "vm/resolve.h" -#include "vm/stringlocal.h" +#include "vm/string.hpp" #include "vm/jit/abi.h" #include "vm/jit/reg.h" #include "vm/jit/show.h" #include "vm/jit/allocator/simplereg.h" -#include "vmcore/method.h" -#include "vmcore/options.h" - #if 0 # define LOG(args) printf args diff --git a/src/vm/jit/allocator/simplereg.h b/src/vm/jit/allocator/simplereg.h index e7f2c44e7..9ca4373a6 100644 --- a/src/vm/jit/allocator/simplereg.h +++ b/src/vm/jit/allocator/simplereg.h @@ -1,9 +1,7 @@ /* src/vm/jit/allocator/simplereg.h - register allocator header - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: Christian Ullrich - */ @@ -39,19 +31,27 @@ #include "arch.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/inline/inline.h" /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool regalloc(jitdata *jd); #if defined(ENABLE_STATISTICS) void simplereg_make_statistics(jitdata *jd); #endif +#ifdef __cplusplus +} +#endif + #endif /* _SIMPLE_REG_H */ diff --git a/src/vm/jit/alpha/Makefile.am b/src/vm/jit/alpha/Makefile.am index cd4e0f470..1424fc47a 100644 --- a/src/vm/jit/alpha/Makefile.am +++ b/src/vm/jit/alpha/Makefile.am @@ -34,9 +34,9 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h \ \ - md-asm.h + md-asm.h \ + md-atomic.hpp noinst_LTLIBRARIES = libarch.la @@ -55,6 +55,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/alpha/asmpart.S b/src/vm/jit/alpha/asmpart.S index b05a8afcd..11fa64576 100644 --- a/src/vm/jit/alpha/asmpart.S +++ b/src/vm/jit/alpha/asmpart.S @@ -54,9 +54,6 @@ .globl asm_abstractmethoderror - .globl asm_compare_and_swap - .globl asm_memory_barrier - .globl asm_md_init .globl asm_cacheflush @@ -339,52 +336,6 @@ asm_abstractmethoderror: .end asm_abstractmethoderror -/* asm_compare_and_swap ******************************************************** - - Does an atomic compare and swap. Required for the lock - implementation. - - Atomically do the following: Check if the location still contains - `oldval`. If so, replace it by `newval` and return `oldval`. - - RETURN VALUE: - the old value at *p - - long compare_and_swap(volatile long *p, long oldval, long newval); - -*******************************************************************************/ - - .ent asm_compare_and_swap - -asm_compare_and_swap: -1: - ldq_l v0,0(a0) - cmpeq v0,a1,t0 - beq t0,2f - mov a2,t0 - stq_c t0,0(a0) - beq t0,1b -2: - jmp zero,(ra) - - .end asm_compare_and_swap - - -/* asm_memory_barrier ********************************************************** - - A memory barrier for the Java Memory Model. - -*******************************************************************************/ - - .ent asm_memory_barrier - -asm_memory_barrier: - mb - jmp zero,(ra) - - .end asm_memory_barrier - - /* asm_md_init ***************************************************************** Initialize machine dependent stuff. diff --git a/src/vm/jit/alpha/codegen.c b/src/vm/jit/alpha/codegen.c index caa783431..e52bb2c97 100644 --- a/src/vm/jit/alpha/codegen.c +++ b/src/vm/jit/alpha/codegen.c @@ -38,29 +38,30 @@ #include "mm/memory.h" -#include "native/jni.h" #include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" #if defined(ENABLE_SSA) @@ -70,9 +71,6 @@ # include "vm/jit/allocator/lsra.h" #endif -#include "vmcore/loader.h" -#include "vmcore/options.h" - /* codegen_emit **************************************************************** @@ -3285,7 +3283,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - disp = dseg_add_address(cd, _Jv_env); + disp = dseg_add_address(cd, VM_get_jnienv()); M_ALD(REG_A0, REG_PV, disp); } diff --git a/src/vm/jit/alpha/codegen.h b/src/vm/jit/alpha/codegen.h index c43ba7b6d..17953240b 100644 --- a/src/vm/jit/alpha/codegen.h +++ b/src/vm/jit/alpha/codegen.h @@ -1,9 +1,8 @@ /* src/vm/jit/alpha/codegen.h - code generation macros and definitions for Alpha - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. This file is part of CACAO. @@ -31,7 +30,7 @@ #include "config.h" #include "vm/types.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* additional functions and macros to generate code ***************************/ @@ -106,11 +105,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 1 * 4 - - /* macros to create code ******************************************************/ /* M_MEM - memory instruction format ******************************************* @@ -169,6 +163,8 @@ cd->mcodeptr += 4; \ } while (0) +#define M_OP3_GET_Opcode(x) ( (((x) >> 26) & 0x3f )) + /* 3-address-floating-point-operation: M_FOP3 op .... opcode @@ -441,7 +437,7 @@ #define M_FBEQZ(fa,disp) M_BRA (0x31,fa,disp) /* br a == 0.0*/ -/* macros for special commands (see an Alpha-manual for description) **********/ +/* macros for special commands (see an Alpha-manual for description) **********/ #define M_TRAPB M_MEM (0x18,0,0,0x0000) /* trap barrier*/ @@ -539,6 +535,10 @@ #define M_CMOVLE_IMM(a,b,c) M_OP3 (0x11,0x64, a,b,c,1) /* a<=0 ? c=b */ #define M_CMOVGT_IMM(a,b,c) M_OP3 (0x11,0x66, a,b,c,1) /* a> 0 ? c=b */ +// 0x04 seems to be the first undefined instruction which does not +// call PALcode. +#define M_UNDEFINED M_OP3(0x04, 0, 0, 0, 0, 0) + /* macros for unused commands (see an Alpha-manual for description) ***********/ #define M_ANDNOT(a,b,c,const) M_OP3 (0x11,0x08, a,b,c,const) /* c = a &~ b */ diff --git a/src/vm/jit/alpha/emit.c b/src/vm/jit/alpha/emit.c index f0d1b7c89..d39158e61 100644 --- a/src/vm/jit/alpha/emit.c +++ b/src/vm/jit/alpha/emit.c @@ -37,19 +37,19 @@ #include "threads/lock-common.h" +#include "vm/options.h" + #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#include "vm/jit/trace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" - /* emit_load ******************************************************************* @@ -446,11 +446,10 @@ uint32_t emit_trap(codegendata *cd) /* Get machine code which is patched back in later. The trap is 1 instruction word long. */ - mcode = *((uint32_t *) cd->mcodeptr); + mcode = *((uint32_t*) cd->mcodeptr); - /* Destination register must not be REG_ZERO, because then no - SIGSEGV is thrown. */ - M_ALD_INTERN(REG_RESULT, REG_ZERO, TRAP_PATCHER); + // Generate a SIGILL. + M_UNDEFINED; return mcode; } diff --git a/src/vm/jit/alpha/freebsd/md-os.c b/src/vm/jit/alpha/freebsd/md-os.c index 10deba916..e60626f3f 100644 --- a/src/vm/jit/alpha/freebsd/md-os.c +++ b/src/vm/jit/alpha/freebsd/md-os.c @@ -1,9 +1,7 @@ -/* src/vm/jit/alpha/freebsd/md.c - machine dependent Alpha FreeBSD functions +/* src/vm/jit/alpha/freebsd/md-os.c - machine dependent Alpha FreeBSD functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -42,10 +34,8 @@ #include "vm/jit/alpha/md-abi.h" -#include "vm/exceptions.h" #include "vm/global.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" @@ -95,22 +85,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *_uc) -{ - mcontext_t *_mc; - void *critical; - - _mc = &_uc->uc_mcontext; - - critical = critical_find_restart_point((void *) _mc->mc_regs[R_PC]); - - if (critical) - _mc->mc_regs[R_PC] = (ptrint) critical; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/alpha/linux/md-os.c b/src/vm/jit/alpha/linux/md-os.c index afe391d11..bb5d17bbe 100644 --- a/src/vm/jit/alpha/linux/md-os.c +++ b/src/vm/jit/alpha/linux/md-os.c @@ -2,6 +2,7 @@ Copyright (C) 1996-2005, 2006, 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. This file is part of CACAO. @@ -35,18 +36,17 @@ #include "vm/jit/alpha/md.h" #include "vm/jit/alpha/md-abi.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "vm/signallocal.h" +#include "vm/os.hpp" #include "vm/jit/asmpart.h" +#include "vm/jit/disass.h" #include "vm/jit/executionstate.h" -#include "vm/jit/stacktrace.h" #include "vm/jit/trap.h" -#include "vmcore/system.h" - /* md_signal_handler_sigsegv *************************************************** @@ -140,12 +140,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) /* fall-through */ - case TRAP_PATCHER: - if (p == NULL) - break; - - /* fall-through */ - default: _mc->sc_regs[REG_ITMP1_XPTR] = (uintptr_t) p; _mc->sc_regs[REG_ITMP2_XPC] = (uintptr_t) xpc; @@ -154,6 +148,61 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } +/* md_signal_handler_sigill **************************************************** + + Illegal Instruction signal handler for hardware exception checks. + +*******************************************************************************/ + +void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t* _uc = (ucontext_t*) _p; + mcontext_t* _mc = &_uc->uc_mcontext; + + void* pv = (u1 *) _mc->sc_regs[REG_PV]; + void* sp = (u1 *) _mc->sc_regs[REG_SP]; + void* ra = (u1 *) _mc->sc_regs[REG_RA]; // RA is correct for leaf methods. + void* xpc = (u1 *) _mc->sc_pc; + + // The PC points to the instruction after the illegal instruction. + xpc = (void*) (((uintptr_t) xpc) - 4); + + // Get the exception-throwing instruction. + uint32_t mcode = *((uint32_t*) xpc); + + int opcode = M_OP3_GET_Opcode(mcode); + + // Check for undefined instruction we use. + // TODO Check the whole instruction. + if (opcode != 0x4) { + log_println("md_signal_handler_sigill: Unknown illegal instruction %x at %p", mcode, xpc); +#if defined(ENABLE_DISASSEMBLER) + (void) disassinstr(xpc); +#endif + vm_abort("Aborting..."); + } + + // This signal is always a patcher. + int type = TRAP_PATCHER; + intptr_t val = 0; + + // Handle the trap. + void* p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + // Set registers if we have an exception, continue execution + // otherwise. + if (p != NULL) { + _mc->sc_regs[REG_ITMP1_XPTR] = (uintptr_t) p; + _mc->sc_regs[REG_ITMP2_XPC] = (uintptr_t) xpc; + _mc->sc_pc = (uintptr_t) asm_handle_exception; + } + else { + // We need to set the PC because we adjusted it above. + _mc->sc_pc = (uintptr_t) xpc; + } +} + + /* md_signal_handler_sigusr1 *************************************************** Signal handler for suspending threads. @@ -237,7 +286,7 @@ void md_executionstate_read(executionstate_t *es, void *context) * the _mc->sc_fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs)); - system_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs)); + os_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs)); } @@ -265,7 +314,7 @@ void md_executionstate_write(executionstate_t *es, void *context) * the _mc->sc_fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs)); - system_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs)); + os_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs)); /* write special registers */ _mc->sc_pc = (ptrint) es->pc; @@ -275,32 +324,6 @@ void md_executionstate_write(executionstate_t *es, void *context) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - u1 *npc; - - _mc = &_uc->uc_mcontext; - - pc = (u1 *) _mc->sc_pc; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) - _mc->sc_pc = (ptrint) npc; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/alpha/machine-instr.h b/src/vm/jit/alpha/machine-instr.h deleted file mode 100644 index 3d054e195..000000000 --- a/src/vm/jit/alpha/machine-instr.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long -__attribute__ ((unused)) -compare_and_swap (volatile long *p, long oldval, long newval) -{ - long ret, temp; - - __asm__ __volatile__ ( - "1:\t" - "ldq_l %0,%5\n\t" - "cmpeq %0,%3,%2\n\t" - "beq %2,2f\n\t" - "mov %4,%2\n\t" - "stq_c %2,%1\n\t" - "beq %2,1b\n\t" - "2:\t" - : "=&r"(ret), "=m"(*p), "=&r"(temp) - : "r"(oldval), "r"(newval), "m"(*p)); - - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("wmb" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("mb" : : : "memory"); -#define MEMORY_BARRIER() __asm__ __volatile__ ( \ - "mb" : : : "memory" ); - -#endif diff --git a/src/vm/jit/alpha/md-abi.c b/src/vm/jit/alpha/md-abi.c index 90189e17a..496834761 100644 --- a/src/vm/jit/alpha/md-abi.c +++ b/src/vm/jit/alpha/md-abi.c @@ -28,12 +28,11 @@ #include "vm/jit/alpha/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" -#include "vmcore/descriptor.h" - /* register descripton array **************************************************/ diff --git a/src/vm/jit/alpha/md-atomic.hpp b/src/vm/jit/alpha/md-atomic.hpp new file mode 100644 index 000000000..962852a55 --- /dev/null +++ b/src/vm/jit/alpha/md-atomic.hpp @@ -0,0 +1,152 @@ +/* src/vm/jit/alpha/atomic.hpp - Alpha atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t temp; + uint32_t result; + + __asm__ __volatile__ ( + "1: \n" + " ldl_l %0,%5 \n" + " cmpeq %0,%3,%2 \n" + " beq %2,2f \n" + " mov %4,%2 \n" + " stl_c %2,%1 \n" + " beq %2,1b \n" + "2: \n" + : "=&r" (result), "=m" (*p), "=&r" (temp) + : "r" (oldval), "r" (newval), "m" (*p)); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + uint64_t temp; + uint64_t result; + + __asm__ __volatile__ ( + "1: \n" + " ldq_l %0,%5 \n" + " cmpeq %0,%3,%2 \n" + " beq %2,2f \n" + " mov %4,%2 \n" + " stq_c %2,%1 \n" + " beq %2,1b \n" + "2: \n" + : "=&r" (result), "=m" (*p), "=&r" (temp) + : "r" (oldval), "r" (newval), "m" (*p)); + + return result; +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("mb" : : : "memory"); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("wmb" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("mb" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/alpha/md-stubs.hpp b/src/vm/jit/alpha/md-stubs.hpp new file mode 100644 index 000000000..8ff379fcb --- /dev/null +++ b/src/vm/jit/alpha/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/alpha/md-stubs.hpp - Alpha JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on an Alpha architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 1 * 4; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/alpha/md-trap.h b/src/vm/jit/alpha/md-trap.h index c932579dc..e6947d80e 100644 --- a/src/vm/jit/alpha/md-trap.h +++ b/src/vm/jit/alpha/md-trap.h @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/alpha/md.c b/src/vm/jit/alpha/md.c index 2958813c4..9ad99b747 100644 --- a/src/vm/jit/alpha/md.c +++ b/src/vm/jit/alpha/md.c @@ -39,7 +39,7 @@ extern void ieee_set_fp_control(unsigned long fp_control); #include "vm/jit/alpha/md.h" #include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/trap.h" diff --git a/src/vm/jit/alpha/md.h b/src/vm/jit/alpha/md.h index 4899d8f9f..e939d3803 100644 --- a/src/vm/jit/alpha/md.h +++ b/src/vm/jit/alpha/md.h @@ -1,9 +1,7 @@ /* src/vm/jit/alpha/md.h - machine dependent Alpha functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -36,10 +34,10 @@ #include "vm/jit/alpha/codegen.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" /* global variables ***********************************************************/ diff --git a/src/vm/jit/alpha/patcher.c b/src/vm/jit/alpha/patcher.c index f990bbe99..1f3a93422 100644 --- a/src/vm/jit/alpha/patcher.c +++ b/src/vm/jit/alpha/patcher.c @@ -35,20 +35,17 @@ #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" +#include "vm/options.h" +#include "vm/references.h" +#include "vm/resolve.h" #include "vm/jit/asmpart.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/methodheader.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" -#include "vm/resolve.h" #define PATCH_BACK_ORIGINAL_MCODE \ @@ -256,11 +253,6 @@ bool patcher_get_putfield(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - /* patch the field's offset into the instruction */ *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff); @@ -336,11 +328,6 @@ bool patcher_invokevirtual(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - /* patch vftbl index */ *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) + @@ -382,11 +369,6 @@ bool patcher_invokeinterface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - /* patch interfacetable index */ *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) - @@ -434,11 +416,6 @@ bool patcher_checkcast_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - /* patch super class index */ *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); @@ -483,11 +460,6 @@ bool patcher_instanceof_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - /* patch super class index */ *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); diff --git a/src/vm/jit/argument.c b/src/vm/jit/argument.c index 8705e6be1..dbee5fa95 100644 --- a/src/vm/jit/argument.c +++ b/src/vm/jit/argument.c @@ -1,9 +1,7 @@ /* src/vm/jit/argument.c - argument passing from and to JIT methods - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -37,16 +35,15 @@ #include "native/llni.h" #include "vm/array.h" +#include "vm/descriptor.h" #include "vm/global.h" -#include "vm/primitive.h" +#include "vm/method.h" +#include "vm/primitive.hpp" #include "vm/resolve.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/abi-asm.h" -#include "vmcore/descriptor.h" -#include "vmcore/method.h" - /* argument_jitarray_load ****************************************************** @@ -500,7 +497,7 @@ uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o, } for (j = 0; i < md->paramcount; i++, j++, pd++, td++) { - switch (td->decltype) { + switch (td->primitivetype) { case TYPE_INT: argument_vmarray_store_int(array, pd, args[j].i); break; @@ -599,9 +596,9 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, /* convert the value according to its declared type */ LLNI_class_get(param, c); - type = primitive_type_get_by_wrapperclass(c); + type = Primitive_get_type_by_wrapperclass(c); - switch (td->decltype) { + switch (td->primitivetype) { case PRIMITIVETYPE_BOOLEAN: switch (type) { case PRIMITIVETYPE_BOOLEAN: @@ -657,10 +654,10 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, default: vm_abort("argument_vmarray_from_objectarray: invalid type %d", - td->decltype); + td->primitivetype); } - value = primitive_unbox(param); + value = Primitive_unbox(param); argument_vmarray_store_int(array, pd, value.i); break; @@ -669,9 +666,9 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, return NULL; LLNI_class_get(param, c); - type = primitive_type_get_by_wrapperclass(c); + type = Primitive_get_type_by_wrapperclass(c); - assert(td->decltype == PRIMITIVETYPE_LONG); + assert(td->primitivetype == PRIMITIVETYPE_LONG); switch (type) { case PRIMITIVETYPE_BYTE: @@ -684,7 +681,7 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, return NULL; } - value = primitive_unbox(param); + value = Primitive_unbox(param); argument_vmarray_store_lng(array, pd, value.l); break; @@ -693,9 +690,9 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, return NULL; LLNI_class_get(param, c); - type = primitive_type_get_by_wrapperclass(c); + type = Primitive_get_type_by_wrapperclass(c); - assert(td->decltype == PRIMITIVETYPE_FLOAT); + assert(td->primitivetype == PRIMITIVETYPE_FLOAT); switch (type) { case PRIMITIVETYPE_FLOAT: @@ -705,7 +702,7 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, return NULL; } - value = primitive_unbox(param); + value = Primitive_unbox(param); argument_vmarray_store_flt(array, pd, value.l); break; @@ -714,9 +711,9 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, return NULL; LLNI_class_get(param, c); - type = primitive_type_get_by_wrapperclass(c); + type = Primitive_get_type_by_wrapperclass(c); - assert(td->decltype == PRIMITIVETYPE_DOUBLE); + assert(td->primitivetype == PRIMITIVETYPE_DOUBLE); switch (type) { case PRIMITIVETYPE_FLOAT: @@ -727,7 +724,7 @@ uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, return NULL; } - value = primitive_unbox(param); + value = Primitive_unbox(param); argument_vmarray_store_dbl(array, pd, value.l); break; diff --git a/src/vm/jit/argument.h b/src/vm/jit/argument.h index 3c1c53c27..fe6ef25fa 100644 --- a/src/vm/jit/argument.h +++ b/src/vm/jit/argument.h @@ -1,9 +1,7 @@ /* src/vm/jit/argument.h - argument passing from and to JIT methods - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -32,6 +30,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/global.h" @@ -54,6 +56,10 @@ uint64_t *argument_vmarray_from_jvalue(methodinfo *m, java_handle_t *o, uint64_t *argument_vmarray_from_objectarray(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params); +#ifdef __cplusplus +} +#endif + #endif /* _VM_JIT_ARGUMENT_H */ diff --git a/src/vm/jit/arm/Makefile.am b/src/vm/jit/arm/Makefile.am index 5955ff12e..169c28ad9 100644 --- a/src/vm/jit/arm/Makefile.am +++ b/src/vm/jit/arm/Makefile.am @@ -31,8 +31,8 @@ AM_CCASFLAGS = $(AM_CPPFLAGS) noinst_HEADERS = \ arch.h \ - machine-instr.h \ - md-asm.h + md-asm.h \ + md-atomic.hpp noinst_LTLIBRARIES = libarch.la @@ -51,6 +51,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/arm/asmpart.S b/src/vm/jit/arm/asmpart.S index 88dfc8f74..d3f4b93fd 100644 --- a/src/vm/jit/arm/asmpart.S +++ b/src/vm/jit/arm/asmpart.S @@ -78,8 +78,8 @@ asm_vm_call_method: asm_vm_call_method_int: asm_vm_call_method_long: -/* asm_vm_call_method_float: -asm_vm_call_method_double: */ +asm_vm_call_method_float: +asm_vm_call_method_double: SAVE_SCRATCH_REGISTERS /* save our personal scratch regs */ stmfd sp!, {v1} /* V1 is used to remember SP */ str a0, [sp, #-4]! /* store methods entrypoint */ @@ -134,13 +134,6 @@ asm_vm_call_method_exception_handler: ldmfd sp!, {v1} RESTORE_SCRATCH_REGS_AND_RETURN /* return to caller, restore regs */ -asm_vm_call_method_float: - mov a0,#0x51 - b asm_debug -asm_vm_call_method_double: - mov a0,#0x52 - b asm_debug - asm_vm_call_method_end: diff --git a/src/vm/jit/arm/codegen.c b/src/vm/jit/arm/codegen.c index 00a37a242..5c30df214 100644 --- a/src/vm/jit/arm/codegen.c +++ b/src/vm/jit/arm/codegen.c @@ -42,30 +42,29 @@ #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/methodheader.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" #if defined(ENABLE_LSRA) #include "vm/jit/allocator/lsra.h" #endif -#include "vmcore/loader.h" -#include "vmcore/options.h" - /* codegen_emit **************************************************************** @@ -2402,9 +2401,6 @@ bool codegen_emit(jitdata *jd) superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -2508,16 +2504,12 @@ bool codegen_emit(jitdata *jd) M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_DSEG_LOAD(REG_ITMP3, disp); - CODEGEN_CRITICAL_SECTION_START; - M_LDR_INTERN(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_LDR_INTERN(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval)); M_SUB(REG_ITMP2, REG_ITMP2, REG_ITMP3); M_DSEG_LOAD(REG_ITMP3, disp); M_LDR_INTERN(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_CMP(REG_ITMP2, REG_ITMP3); emit_classcast_check(cd, iptr, BRANCH_UGT, 0, s1); @@ -2582,9 +2574,6 @@ bool codegen_emit(jitdata *jd) superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); @@ -2707,14 +2696,10 @@ bool codegen_emit(jitdata *jd) M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_DSEG_LOAD(REG_ITMP2, disp); - CODEGEN_CRITICAL_SECTION_START; - M_LDR_INTERN(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_LDR_INTERN(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_LDR_INTERN(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_SUB(REG_ITMP1, REG_ITMP1, REG_ITMP3); M_CMP(REG_ITMP1, REG_ITMP2); /* If d == REG_ITMP2, then it's destroyed */ @@ -3001,7 +2986,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - disp = dseg_add_address(cd, _Jv_env); + disp = dseg_add_address(cd, VM_get_jnienv()); M_DSEG_LOAD(REG_A0, disp); } diff --git a/src/vm/jit/arm/codegen.h b/src/vm/jit/arm/codegen.h index fc7dee7e3..448f99476 100644 --- a/src/vm/jit/arm/codegen.h +++ b/src/vm/jit/arm/codegen.h @@ -1,9 +1,7 @@ /* src/vm/jit/arm/codegen.h - code generation macros and definitions for ARM - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -116,11 +114,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 2 * 4 - - /* lazy debugger **************************************************************/ #if !defined(NDEBUG) @@ -1103,15 +1096,22 @@ do { \ /* M_RECOMPUTE_PV: used to recompute our PV (we use the IP for this) out of the current PC ATTENTION: if you change this, you have to look at other functions as well! - Following things depend on it: asm_call_jit_compiler(); codegen_findmethod(); + Following things depend on it: md_codegen_get_pv_from_pc(); */ #define M_RECOMPUTE_PV(disp) \ disp += 8; /* we use PC relative addr. */ \ assert((disp & 0x03) == 0); \ assert(disp >= 0 && disp <= 0x03ffffff); \ - M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 2, 1)); \ - if (disp > 0x000003ff) M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 10, 5)); \ - if (disp > 0x0003ffff) M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 18, 9)); \ + if (disp > 0x0003ffff) { \ + M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 18, 9)); \ + M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 10, 5)); \ + M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 2, 1)); \ + } else if (disp > 0x000003ff) { \ + M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 10, 5)); \ + M_SUB_IMM(REG_PV, REG_PV, IMM_ROTL(disp >> 2, 1)); \ + } else { \ + M_SUB_IMM(REG_PV, REG_PC, IMM_ROTL(disp >> 2, 1)); \ + } /* M_INTMOVE: generates an integer-move from register a to b. diff --git a/src/vm/jit/arm/emit.c b/src/vm/jit/arm/emit.c index 293731cfc..26393f68a 100644 --- a/src/vm/jit/arm/emit.c +++ b/src/vm/jit/arm/emit.c @@ -38,16 +38,15 @@ #include "threads/lock-common.h" -#include "vm/exceptions.h" #include "vm/global.h" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#include "vm/jit/trace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" #include "toolbox/logging.h" /* XXX for debugging only */ diff --git a/src/vm/jit/arm/linux/md-os.c b/src/vm/jit/arm/linux/md-os.c index 37aaabcdc..051ae1825 100644 --- a/src/vm/jit/arm/linux/md-os.c +++ b/src/vm/jit/arm/linux/md-os.c @@ -2,6 +2,7 @@ Copyright (C) 1996-2005, 2006, 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. This file is part of CACAO. @@ -49,16 +50,15 @@ typedef struct ucontext { #define scontext_t struct sigcontext -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/exceptions.h" +#include "vm/os.hpp" #include "vm/signallocal.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" #include "vm/jit/executionstate.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/trap.h" @@ -126,52 +126,46 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) { - ucontext_t *_uc; - scontext_t *_sc; - u1 *pv; - u1 *sp; - u1 *ra; - u1 *xpc; - u4 mcode; - int type; - intptr_t val; - void *p; - - _uc = (ucontext_t*) _p; - _sc = &_uc->uc_mcontext; + ucontext_t* _uc = (ucontext_t*) _p; + scontext_t* _sc = &_uc->uc_mcontext; /* ATTENTION: glibc included messed up kernel headers we needed a workaround for the ucontext structure. */ - pv = (u1 *) _sc->arm_ip; - sp = (u1 *) _sc->arm_sp; - ra = (u1 *) _sc->arm_lr; /* this is correct for leafs */ - xpc = (u1 *) _sc->arm_pc; - - /* get exception-throwing instruction */ - - mcode = *((u4 *) xpc); - - /* check for undefined instruction we use */ - - if ((mcode & 0x0ff000f0) != 0x07f000f0) { - log_println("md_signal_handler_sigill: unknown illegal instruction: inst=%x", mcode); + void* pv = (void*) _sc->arm_ip; + void* sp = (void*) _sc->arm_sp; + void* ra = (void*) _sc->arm_lr; // The RA is correct for leaf methods. + void* xpc = (void*) _sc->arm_pc; + + // Get the exception-throwing instruction. + uint32_t mcode = *((uint32_t*) xpc); + + // Check if the trap instruction is valid. + // TODO Move this into patcher_handler. + if (patcher_is_valid_trap_instruction_at(xpc) == false) { + // Check if the PC has been patched during our way to this + // signal handler (see PR85). + // NOTE: ARM uses SIGILL for other traps too, but it's OK to + // do this check anyway because it will fail. + if (patcher_is_patched_at(xpc) == true) + return; + + // We have a problem... + log_println("md_signal_handler_sigill: Unknown illegal instruction 0x%x at 0x%x", mcode, xpc); #if defined(ENABLE_DISASSEMBLER) - DISASSINSTR(xpc); + (void) disassinstr(xpc); #endif vm_abort("Aborting..."); } - type = (mcode >> 8) & 0x0fff; - val = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f)); + int type = (mcode >> 8) & 0x0fff; + intptr_t val = *((int32_t*) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f)); - /* Handle the trap. */ - - p = trap_handle(type, val, pv, sp, ra, xpc, _p); - - /* set registers if we have an exception, continue execution - otherwise (this is needed for patchers to work) */ + // Handle the trap. + void* p = trap_handle(type, val, pv, sp, ra, xpc, _p); + // Set registers if we have an exception, continue execution + // otherwise. if (p != NULL) { _sc->arm_r10 = (uintptr_t) p; _sc->arm_fp = (uintptr_t) xpc; @@ -266,7 +260,7 @@ void md_executionstate_read(executionstate_t *es, void *context) * the _mc->sc_fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs)); - system_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs)); + os_memcpy(&es->fltregs, &_mc->sc_fpregs, sizeof(_mc->sc_fpregs)); #endif } @@ -298,7 +292,7 @@ void md_executionstate_write(executionstate_t *es, void *context) * the _mc->sc_fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->sc_fpregs) == sizeof(es->fltregs)); - system_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs)); + os_memcpy(&_mc->sc_fpregs, &es->fltregs, sizeof(_mc->sc_fpregs)); /* write special registers */ _mc->sc_pc = (ptrint) es->pc; @@ -309,32 +303,6 @@ void md_executionstate_write(executionstate_t *es, void *context) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - scontext_t *_sc; - u1 *pc; - u1 *npc; - - _sc = &_uc->uc_mcontext; - - pc = (u1 *) _sc->arm_pc; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) - _sc->arm_pc = (ptrint) npc; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/arm/machine-instr.h b/src/vm/jit/arm/machine-instr.h deleted file mode 100644 index 82fba2952..000000000 --- a/src/vm/jit/arm/machine-instr.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long compare_and_swap(long *p, long oldval, long newval) -{ - long ret, temp; - /*dolog("compare_and_swap(%p [%d], %d, %d)", p, *p, oldval, newval);*/ - - /* TODO: improve this one! */ - __asm__ __volatile__ ( - "1:\t" - "ldr %0,[%2]\n\t" - "cmp %0,%4\n\t" - "bne 2f\n\t" - "swp %1,%3,[%2]\n\t" - "cmp %1,%0\n\t" - "swpne %0,%1,[%2]\n\t" - "bne 1b\n\t" - "2:" - : "=&r" (ret), "=&r" (temp) - : "r" (p), "r" (newval), "r" (oldval) - : "cc", "memory" - ); - - /*dolog("compare_and_swap() return=%d mem=%d", ret, *p);*/ - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER() __asm__ __volatile__ ("" : : : "memory" ); - -#endif diff --git a/src/vm/jit/arm/md-abi.c b/src/vm/jit/arm/md-abi.c index b10d45665..bdf6a14f9 100644 --- a/src/vm/jit/arm/md-abi.c +++ b/src/vm/jit/arm/md-abi.c @@ -28,12 +28,11 @@ #include "vm/jit/arm/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" -#include "vmcore/descriptor.h" - /* register descripton array **************************************************/ diff --git a/src/vm/jit/arm/md-atomic.hpp b/src/vm/jit/arm/md-atomic.hpp new file mode 100644 index 000000000..81f0a3926 --- /dev/null +++ b/src/vm/jit/arm/md-atomic.hpp @@ -0,0 +1,141 @@ +/* src/vm/jit/arm/atomic.hpp - ARM atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t result; + uint32_t temp; + + /* TODO: improve this one! */ + __asm__ __volatile__ ( + "1:\t" + "ldr %0,[%2]\n\t" + "cmp %0,%4\n\t" + "bne 2f\n\t" + "swp %1,%3,[%2]\n\t" + "cmp %1,%0\n\t" + "swpne %0,%1,[%2]\n\t" + "bne 1b\n\t" + "2:" + : "=&r" (result), "=&r" (temp) + : "r" (p), "r" (newval), "r" (oldval) + : "cc", "memory" + ); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + return generic_compare_and_swap(p, oldval, newval); +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/arm/md-stubs.hpp b/src/vm/jit/arm/md-stubs.hpp new file mode 100644 index 000000000..1fb11474a --- /dev/null +++ b/src/vm/jit/arm/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/arm/md-stubs.hpp - ARM JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on an ARM architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 2 * 4; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/arm/md-trap.h b/src/vm/jit/arm/md-trap.h index 7992441b2..c94a8f73c 100644 --- a/src/vm/jit/arm/md-trap.h +++ b/src/vm/jit/arm/md-trap.h @@ -50,7 +50,8 @@ enum { TRAP_ClassCastException = 5, TRAP_CHECK_EXCEPTION = 6, TRAP_PATCHER = 7, - TRAP_COMPILER = 8 + TRAP_COMPILER = 8, + TRAP_COUNTDOWN = 9 }; #endif /* _MD_TRAP_H */ diff --git a/src/vm/jit/arm/md.c b/src/vm/jit/arm/md.c index d37b3a710..b150f1a14 100644 --- a/src/vm/jit/arm/md.c +++ b/src/vm/jit/arm/md.c @@ -1,9 +1,7 @@ -/* src/vm/jit/arm/md.c - machine dependent Arm functions +/* src/vm/jit/arm/md.c - machine dependent ARM functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -138,6 +136,17 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr) } +/** + * Patch the given replacement point. + */ +#if defined(ENABLE_REPLACEMENT) +void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert) +{ + vm_abort("md_patch_replacement_point: IMPLEMENT ME!"); +} +#endif + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/arm/md.h b/src/vm/jit/arm/md.h index 04774df4e..9ce156470 100644 --- a/src/vm/jit/arm/md.h +++ b/src/vm/jit/arm/md.h @@ -1,9 +1,7 @@ /* src/vm/jit/arm/md.h - machine dependent Arm functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -36,7 +34,7 @@ #include "vm/types.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" /* md_stacktrace_get_returnaddress ********************************************* @@ -66,32 +64,42 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe *******************************************************************************/ -inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) +inline static void* md_codegen_get_pv_from_pc(void* ra) { - u1 *pv; - u4 mcode1, mcode2, mcode3; + uint32_t* pc; + uintptr_t pv; + uint32_t mcode; + int mcode_idx; - pv = ra; + pc = (uint32_t*) ra; + pv = (uintptr_t) ra; /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */ - mcode1 = *((u4*) ra); - if ((mcode1 & 0xffffff00) == 0xe24fcf00 /*sub ip,pc,#__*/) - pv -= (s4) ((mcode1 & 0x000000ff) << 2); - else if ((mcode1 & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/) - pv -= (s4) (mcode1 & 0x000000ff); + mcode_idx = 0; + mcode = pc[0]; + + /* if this was shifted by 18 bits, we have to load additional instructions */ + if ((mcode & 0xfff0ff00) == 0xe240c700 /*sub ip,??,#__*/) { + pv -= (uintptr_t) ((mcode & 0x000000ff) << 18); + mcode = pc[++mcode_idx]; + } + + /* if this was shifted by 10 bits, we have to load additional instructions */ + if ((mcode & 0xfff0ff00) == 0xe240cb00 /*sub ip,??,#__*/) { + pv -= (uintptr_t) ((mcode & 0x000000ff) << 10); + mcode = pc[++mcode_idx]; + } + + /* this is the default path with just one instruction, shifted by 2 or no bits */ + if ((mcode & 0xfff0ff00) == 0xe240cf00 /*sub ip,??,#__*/) + pv -= (uintptr_t) ((mcode & 0x000000ff) << 2); + else if ((mcode & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/) + pv -= (uintptr_t) (mcode & 0x000000ff); else { /* if this happens, we got an unexpected instruction at (*ra) */ - vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1); + vm_abort("Unable to find method: %p (instr=%x)", ra, mcode); } - /* if we have a RECOMPUTE_IP there can be more than one instruction */ - mcode2 = *((u4*) (ra + 4)); - mcode3 = *((u4*) (ra + 8)); - if ((mcode2 & 0xffffff00) == 0xe24ccb00 /*sub ip,ip,#__*/) - pv -= (s4) ((mcode2 & 0x000000ff) << 10); - if ((mcode3 & 0xffffff00) == 0xe24cc700 /*sub ip,ip,#__*/) - pv -= (s4) ((mcode3 & 0x000000ff) << 18); - /* we used PC-relative adressing; but now it is LR-relative */ pv += 8; @@ -99,7 +107,7 @@ inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) /* we check this by looking up the IsLeaf field, which has to be boolean */ /* assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false ); */ - return pv; + return (void*) pv; } diff --git a/src/vm/jit/arm/patcher.c b/src/vm/jit/arm/patcher.c index 84e8287c5..7115d4f5d 100644 --- a/src/vm/jit/arm/patcher.c +++ b/src/vm/jit/arm/patcher.c @@ -2,6 +2,7 @@ Copyright (C) 1996-2005, 2006, 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. This file is part of CACAO. @@ -36,22 +37,17 @@ #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" - -#include "vm/jit/asmpart.h" -#include "vm/jit/patcher-common.h" - -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" +#include "vm/options.h" +#include "vm/references.h" #include "vm/resolve.h" +#include "vm/jit/asmpart.h" +#include "vm/jit/patcher-common.hpp" -#define PATCH_BACK_ORIGINAL_MCODE \ - *((u4 *) pr->mpc) = (u4) pr->mcode; \ - md_icacheflush((u1 *) pr->mpc, 1 * 4); #define gen_resolveload(inst,offset) \ assert((offset) >= -0x0fff && (offset) <= 0x0fff); \ @@ -73,7 +69,28 @@ void patcher_patch_code(patchref_t *pr) { - PATCH_BACK_ORIGINAL_MCODE; + *((uint32_t*) pr->mpc) = (uint32_t) pr->mcode; + md_icacheflush((void*) pr->mpc, 1 * 4); +} + + +/** + * Check if the trap instruction at the given PC is valid. + * + * @param pc Program counter. + * + * @return true if valid, false otherwise. + */ +bool patcher_is_valid_trap_instruction_at(void* pc) +{ + uint32_t mcode = *((uint32_t*) pc); + + // Check for the undefined instruction we use. + if ((mcode & 0x0ff000f0) != 0x07f000f0) { + return false; + } + + return true; } @@ -88,31 +105,25 @@ void patcher_patch_code(patchref_t *pr) bool patcher_get_putstatic(patchref_t *pr) { - unresolved_field *uf; - u1 *datap; - fieldinfo *fi; - - /* get stuff from the stack */ - - uf = (unresolved_field *) pr->ref; - datap = (u1 *) pr->datap; + unresolved_field* uf = (unresolved_field *) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - /* get the fieldinfo */ + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - /* check if the field's class is initialized */ - + // Check if the field's class is initialized. if (!(fi->clazz->state & CLASS_INITIALIZED)) if (!initialize_class(fi->clazz)) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch the field value's address */ + // Patch the field value's address. + *datap = (uintptr_t) fi->value; - *((intptr_t *) datap) = (intptr_t) fi->value; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -129,29 +140,16 @@ bool patcher_get_putstatic(patchref_t *pr) bool patcher_get_putfield(patchref_t *pr) { - u1 *ra; - u4 mcode; - unresolved_field *uf; - fieldinfo *fi; - - /* get stuff from the stack */ - ra = (u1*) pr->mpc; - mcode = pr->mcode; - uf = (unresolved_field*) pr->ref; + uint32_t* pc = (uint32_t*) pr->mpc; + unresolved_field* uf = (unresolved_field*) pr->ref; - /* get the fieldinfo */ + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 1 * 4; - - /* patch the field's offset into the instruction */ + // Patch the field's offset into the instruction. switch(fi->type) { case TYPE_ADR: @@ -160,7 +158,7 @@ bool patcher_get_putfield(patchref_t *pr) case TYPE_FLT: #endif assert(fi->offset <= 0x0fff); - *((u4 *) (ra + 0 * 4)) |= (fi->offset & 0x0fff); + pr->mcode |= (fi->offset & 0x0fff); break; case TYPE_LNG: @@ -168,23 +166,25 @@ bool patcher_get_putfield(patchref_t *pr) case TYPE_DBL: #endif assert((fi->offset + 4) <= 0x0fff); - *((u4 *) (ra + 0 * 4)) |= ((fi->offset + 0) & 0x0fff); - *((u4 *) (ra + 1 * 4)) &= 0xfffff000; - *((u4 *) (ra + 1 * 4)) |= ((fi->offset + 4) & 0x0fff); + pr->mcode |= ((fi->offset + 0) & 0x0fff); + pc[1] &= 0xfffff000; + pc[1] |= ((fi->offset + 4) & 0x0fff); break; #if !defined(ENABLE_SOFTFLOAT) case TYPE_FLT: case TYPE_DBL: assert(fi->offset <= 0x03ff); - *((u4 *) (ra + 0 * 4)) |= ((fi->offset >> 2) & 0x00ff); + pr->mcode |= ((fi->offset >> 2) & 0x00ff); break; #endif } - /* synchronize instruction cache */ + // Synchronize instruction cache. + md_icacheflush(pc, 2 * 4); - md_icacheflush(ra, 2 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -217,25 +217,20 @@ bool patcher_get_putfield(patchref_t *pr) bool patcher_resolve_classref_to_classinfo(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; + constant_classref* cr = (constant_classref *) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - /* get stuff from the stack */ + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; - - /* get the classinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch the classinfo pointer */ + // Patch the classinfo pointer. + *datap = (uintptr_t) c; - *((ptrint *) datap) = (ptrint) c; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -254,25 +249,20 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr) bool patcher_invokestatic_special(patchref_t *pr) { - unresolved_method *um; - u1 *datap; - methodinfo *m; + unresolved_method* um = (unresolved_method*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - /* get stuff from the stack */ + // Reolve the method. + methodinfo* m = resolve_method_eager(um); - um = (unresolved_method*) pr->ref; - datap = (u1 *) pr->datap; - - /* get the methodinfo */ - - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch stubroutine */ + // Patch stubroutine. + *datap = (uintptr_t) m->stubroutine; - *((ptrint *) datap) = (ptrint) m->stubroutine; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -292,34 +282,23 @@ bool patcher_invokestatic_special(patchref_t *pr) bool patcher_invokevirtual(patchref_t *pr) { - u1 *ra; - unresolved_method *um; - methodinfo *m; + uint32_t* pc = (uint32_t*) pr->mpc; + unresolved_method* um = (unresolved_method *) pr->ref; - /* get stuff from the stack */ + // Resolve the method. + methodinfo* m = resolve_method_eager(um); - ra = (u1 *) pr->mpc; - um = (unresolved_method *) pr->ref; - - /* get the methodinfo */ - - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop */ + // Patch vftbl index. + gen_resolveload(pc[1], (int32_t) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex)); - if (opt_shownops) - ra = ra + 1 * 4; + // Synchronize instruction cache. + md_icacheflush(pc + 1, 1 * 4); - /* patch vftbl index */ - - gen_resolveload(*((s4 *) (ra + 1 * 4)), (s4) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex)); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 1 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -341,38 +320,26 @@ bool patcher_invokevirtual(patchref_t *pr) bool patcher_invokeinterface(patchref_t *pr) { - u1 *ra; - unresolved_method *um; - methodinfo *m; + uint32_t* pc = (uint32_t*) pr->mpc; + unresolved_method* um = (unresolved_method *) pr->ref; - /* get stuff from the stack */ + // Resolve the method. + methodinfo* m = resolve_method_eager(um); - ra = (u1 *) pr->mpc; - um = (unresolved_method *) pr->ref; - - /* get the methodinfo */ - - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop */ + // Patch interfacetable index. + gen_resolveload(pc[1], (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index)); - if (opt_shownops) - ra = ra + 1 * 4; + // Patch method offset. + gen_resolveload(pc[2], (int32_t) (sizeof(methodptr) * (m - m->clazz->methods))); - /* patch interfacetable index */ + // Synchronize instruction cache. + md_icacheflush(pc + 1, 2 * 4); - gen_resolveload(*((s4 *) (ra + 1 * 4)), (s4) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index)); - - /* patch method offset */ - - gen_resolveload(*((s4 *) (ra + 2 * 4)), (s4) (sizeof(methodptr) * (m - m->clazz->methods))); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 2 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -388,25 +355,20 @@ bool patcher_invokeinterface(patchref_t *pr) bool patcher_resolve_classref_to_flags(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; - - /* get stuff from the stack */ - - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; + constant_classref* cr = (constant_classref*) pr->ref; + int32_t* datap = (int32_t*) pr->datap; - /* get the classinfo */ + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch class flags. + *datap = (int32_t) c->flags; - /* patch class flags */ - - *((s4 *) datap) = (s4) c->flags; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -422,25 +384,20 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr) bool patcher_resolve_classref_to_index(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; - - /* get stuff from the stack */ - - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; + constant_classref* cr = (constant_classref*) pr->ref; + int32_t* datap = (int32_t*) pr->datap; - /* get the classinfo */ + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch super class index. + *datap = (int32_t) c->index; - /* patch super class index */ - - *((s4 *) datap) = (s4) c->index; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -456,25 +413,21 @@ bool patcher_resolve_classref_to_index(patchref_t *pr) bool patcher_resolve_classref_to_vftbl(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; - - /* get stuff from the stack */ + constant_classref* cr = (constant_classref*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; + // Resolve the class. - /* get the classinfo */ + classinfo* c = resolve_classref_eager(cr); - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch super class' vftbl */ + // Patch super class' vftbl. + *datap = (uintptr_t) c->vftbl; - *((ptrint *) datap) = (ptrint) c->vftbl; + // Patch back the original code. + patcher_patch_code(pr); return true; } diff --git a/src/vm/jit/asmpart.h b/src/vm/jit/asmpart.h index 8dea3aacc..9ea6f4da5 100644 --- a/src/vm/jit/asmpart.h +++ b/src/vm/jit/asmpart.h @@ -1,9 +1,7 @@ /* src/vm/jit/asmpart.h - prototypes for machine specfic functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -34,18 +32,16 @@ #include "vm/types.h" -#if defined(ENABLE_THREADS) -# include "threads/critical.h" -#endif - #include "vm/global.h" -#include "vm/vm.h" - -#include "vmcore/linker.h" +#include "vm/vm.hpp" /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + /* machine dependent initialization */ s4 asm_md_init(void); @@ -103,11 +99,8 @@ void intrp_asm_abstractmethoderror(void); /* wrapper for code patching functions */ void asm_patcher_wrapper(void); -long asm_compare_and_swap(volatile long *p, long oldval, long newval); -void asm_memory_barrier(void); - /* cache flush function */ -void asm_cacheflush(u1 *addr, s4 nbytes); +void asm_cacheflush(void* addr, int nbytes); u8 asm_get_cycle_count(void); @@ -117,6 +110,10 @@ void *md_asm_codegen_get_pv_from_pc(void *ra); void asm_escape_check(java_object_t *obj); #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* _ASMPART_H */ diff --git a/src/vm/jit/builtin.cpp b/src/vm/jit/builtin.cpp new file mode 100644 index 000000000..cd53c03dd --- /dev/null +++ b/src/vm/jit/builtin.cpp @@ -0,0 +1,2418 @@ +/* src/vm/jit/builtin.cpp - functions for unsupported operations + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Contains C functions for JavaVM Instructions that cannot be + translated to machine language directly. Consequently, the + generated machine code for these instructions contains function + calls instead of machine instructions, using the C calling + convention. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "vm/types.h" + +#include "arch.h" +#include "md-abi.h" + +#include "fdlibm/fdlibm.h" +#if defined(__CYGWIN__) && defined(Bias) +# undef Bias +#endif + +#include "mm/gc.hpp" +#include "mm/memory.h" + +#include "native/llni.h" + +#include "threads/lock-common.h" +#include "threads/mutex.hpp" +#include "threads/thread.hpp" + +#include "toolbox/logging.h" +#include "toolbox/util.h" + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/cycles-stats.h" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/rt-timing.h" +#include "vm/string.hpp" + +#include "vm/jit/asmpart.h" +#include "vm/jit/stubs.hpp" +#include "vm/jit/trace.hpp" + +#if defined(ENABLE_VMLOG) +#include +#endif + + +/* include builtin tables *****************************************************/ + +#include "vm/jit/builtintable.inc" + + +CYCLES_STATS_DECLARE(builtin_new ,100,5) +CYCLES_STATS_DECLARE(builtin_overhead , 80,1) + + +/*============================================================================*/ +/* BUILTIN TABLE MANAGEMENT FUNCTIONS */ +/*============================================================================*/ + +/* builtintable_init *********************************************************** + + Parse the descriptors of builtin functions and create the parsed + descriptors. + +*******************************************************************************/ + +static bool builtintable_init(void) +{ + descriptor_pool *descpool; + builtintable_entry *bte; + methodinfo *m; + + // Create new dump memory area. + DumpMemoryArea dma; + + /* create a new descriptor pool */ + + descpool = descriptor_pool_new(class_java_lang_Object); + + /* add some entries we need */ + + if (!descriptor_pool_add_class(descpool, utf_java_lang_Object)) + return false; + + if (!descriptor_pool_add_class(descpool, utf_java_lang_Class)) + return false; + + /* first add all descriptors to the pool */ + + for (bte = builtintable_internal; bte->fp != NULL; bte++) { + bte->name = utf_new_char(bte->cname); + bte->descriptor = utf_new_char(bte->cdescriptor); + + if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) + return false; + } + + for (bte = builtintable_automatic; bte->fp != NULL; bte++) { + bte->descriptor = utf_new_char(bte->cdescriptor); + + if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) + return false; + } + + for (bte = builtintable_function; bte->fp != NULL; bte++) { + bte->classname = utf_new_char(bte->cclassname); + bte->name = utf_new_char(bte->cname); + bte->descriptor = utf_new_char(bte->cdescriptor); + + if (!descriptor_pool_add(descpool, bte->descriptor, NULL)) + return false; + } + + /* create the class reference table */ + + (void) descriptor_pool_create_classrefs(descpool, NULL); + + /* allocate space for the parsed descriptors */ + + descriptor_pool_alloc_parsed_descriptors(descpool); + + /* Now parse all descriptors. NOTE: builtin-functions are treated + like static methods (no `this' pointer). */ + + for (bte = builtintable_internal; bte->fp != NULL; bte++) { + bte->md = + descriptor_pool_parse_method_descriptor(descpool, + bte->descriptor, + ACC_STATIC | ACC_METHOD_BUILTIN, + NULL); + + /* generate a builtin stub if we need one */ + + if (bte->flags & BUILTINTABLE_FLAG_STUB) { + m = method_new_builtin(bte); + BuiltinStub::generate(m, bte); + } + } + + for (bte = builtintable_automatic; bte->fp != NULL; bte++) { + bte->md = + descriptor_pool_parse_method_descriptor(descpool, + bte->descriptor, + ACC_STATIC | ACC_METHOD_BUILTIN, + NULL); + + /* no stubs should be needed for this table */ + + assert(!bte->flags & BUILTINTABLE_FLAG_STUB); + } + + for (bte = builtintable_function; bte->fp != NULL; bte++) { + bte->md = + descriptor_pool_parse_method_descriptor(descpool, + bte->descriptor, + ACC_STATIC | ACC_METHOD_BUILTIN, + NULL); + + /* generate a builtin stub if we need one */ + + if (bte->flags & BUILTINTABLE_FLAG_STUB) { + m = method_new_builtin(bte); + BuiltinStub::generate(m, bte); + } + } + + return true; +} + + +/* builtintable_comparator ***************************************************** + + qsort comparator for the automatic builtin table. + +*******************************************************************************/ + +static int builtintable_comparator(const void *a, const void *b) +{ + builtintable_entry *bte1; + builtintable_entry *bte2; + + bte1 = (builtintable_entry *) a; + bte2 = (builtintable_entry *) b; + + return (bte1->opcode < bte2->opcode) ? -1 : (bte1->opcode > bte2->opcode); +} + + +/* builtintable_sort_automatic ************************************************* + + Sorts the automatic builtin table. + +*******************************************************************************/ + +static void builtintable_sort_automatic(void) +{ + s4 entries; + + /* calculate table size statically (`- 1' comment see builtintable.inc) */ + + entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1; + + qsort(builtintable_automatic, entries, sizeof(builtintable_entry), + builtintable_comparator); +} + + +/* builtin_init **************************************************************** + + Initialize the global table of builtin functions. + +*******************************************************************************/ + +bool builtin_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("builtin_init"); + + /* initialize the builtin tables */ + + if (!builtintable_init()) + return false; + + /* sort builtin tables */ + + builtintable_sort_automatic(); + + return true; +} + + +/* builtintable_get_internal *************************************************** + + Finds an entry in the builtintable for internal functions and + returns the a pointer to the structure. + +*******************************************************************************/ + +builtintable_entry *builtintable_get_internal(functionptr fp) +{ + builtintable_entry *bte; + + for (bte = builtintable_internal; bte->fp != NULL; bte++) { + if (bte->fp == fp) + return bte; + } + + return NULL; +} + + +/* builtintable_get_automatic ************************************************** + + Finds an entry in the builtintable for functions which are replaced + automatically and returns the a pointer to the structure. + +*******************************************************************************/ + +builtintable_entry *builtintable_get_automatic(s4 opcode) +{ + builtintable_entry *first; + builtintable_entry *last; + builtintable_entry *middle; + s4 half; + s4 entries; + + /* calculate table size statically (`- 1' comment see builtintable.inc) */ + + entries = sizeof(builtintable_automatic) / sizeof(builtintable_entry) - 1; + + first = builtintable_automatic; + last = builtintable_automatic + entries; + + while (entries > 0) { + half = entries / 2; + middle = first + half; + + if (middle->opcode < opcode) { + first = middle + 1; + entries -= half + 1; + } + else + entries = half; + } + + return (first != last ? first : NULL); +} + + +/* builtintable_replace_function *********************************************** + + XXX + +*******************************************************************************/ + +#if defined(ENABLE_JIT) +bool builtintable_replace_function(void *iptr_) +{ + constant_FMIref *mr; + builtintable_entry *bte; + instruction *iptr; + + iptr = (instruction *) iptr_; /* twisti will kill me ;) */ + + /* get name and descriptor of the function */ + + switch (iptr->opc) { + case ICMD_INVOKESTATIC: + /* The instruction MUST be resolved, otherwise we run into + lazy loading troubles. Anyway, we should/can only replace + very VM-close functions. */ + + if (INSTRUCTION_IS_UNRESOLVED(iptr)) + return false; + + mr = iptr->sx.s23.s3.fmiref; + break; + + default: + return false; + } + + /* search the function table */ + + for (bte = builtintable_function; bte->fp != NULL; bte++) { + if ((METHODREF_CLASSNAME(mr) == bte->classname) && + (mr->name == bte->name) && + (mr->descriptor == bte->descriptor)) { + + /* set the values in the instruction */ + + iptr->opc = bte->opcode; + iptr->sx.s23.s3.bte = bte; + + if (bte->flags & BUILTINTABLE_FLAG_EXCEPTION) + iptr->flags.bits |= INS_FLAG_CHECK; + else + iptr->flags.bits &= ~INS_FLAG_CHECK; + + return true; + } + } + + return false; +} +#endif /* defined(ENABLE_JIT) */ + + +/*============================================================================*/ +/* INTERNAL BUILTIN FUNCTIONS */ +/*============================================================================*/ + +/* builtin_instanceof ********************************************************** + + Checks if an object is an instance of some given class (or subclass + of that class). If class is an interface, checks if the interface + is implemented. + + RETURN VALUE: + 1......o is an instance of class or implements the interface + 0......otherwise or if o == NULL + + NOTE: This builtin can be called from NATIVE code only. + +*******************************************************************************/ + +bool builtin_instanceof(java_handle_t *o, classinfo *c) +{ + classinfo *oc; + + if (o == NULL) + return 0; + + LLNI_class_get(o, oc); + + return class_isanysubclass(oc, c); +} + + + +/* builtin_checkcast *********************************************************** + + The same as builtin_instanceof but with the exception + that 1 is returned when (o == NULL). + + NOTE: This builtin can be called from NATIVE code only. + +*******************************************************************************/ + +bool builtin_checkcast(java_handle_t *o, classinfo *c) +{ + classinfo *oc; + + if (o == NULL) + return 1; + + LLNI_class_get(o, oc); + + if (class_isanysubclass(oc, c)) + return 1; + + return 0; +} + + +/* builtin_descriptorscompatible *********************************************** + + Checks if two array type descriptors are assignment compatible. + + RETURN VALUE: + 1......target = desc is possible + 0......otherwise + +*******************************************************************************/ + +static bool builtin_descriptorscompatible(arraydescriptor *desc, arraydescriptor *target) +{ + if (desc == target) + return 1; + + if (desc->arraytype != target->arraytype) + return 0; + + if (desc->arraytype != ARRAYTYPE_OBJECT) + return 1; + + /* {both arrays are arrays of references} */ + + if (desc->dimension == target->dimension) { + if (!desc->elementvftbl) + return 0; + /* an array which contains elements of interface types is + allowed to be casted to Object (JOWENN)*/ + + if ((desc->elementvftbl->baseval < 0) && + (target->elementvftbl->baseval == 1)) + return 1; + + return class_isanysubclass(desc->elementvftbl->clazz, + target->elementvftbl->clazz); + } + + if (desc->dimension < target->dimension) + return 0; + + /* {desc has higher dimension than target} */ + + return class_isanysubclass(pseudo_class_Arraystub, + target->elementvftbl->clazz); +} + + +/* builtin_arraycheckcast ****************************************************** + + Checks if an object is really a subtype of the requested array + type. The object has to be an array to begin with. For simple + arrays (int, short, double, etc.) the types have to match exactly. + For arrays of objects, the type of elements in the array has to be + a subtype (or the same type) of the requested element type. For + arrays of arrays (which in turn can again be arrays of arrays), the + types at the lowest level have to satisfy the corresponding sub + class relation. + + NOTE: This is a FAST builtin and can be called from JIT code only. + +*******************************************************************************/ + +bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass) +{ + arraydescriptor *desc; + + if (o == NULL) + return 1; + + desc = o->vftbl->arraydesc; + + if (desc == NULL) + return 0; + + return builtin_descriptorscompatible(desc, targetclass->vftbl->arraydesc); +} + + +/* builtin_fast_arrayinstanceof ************************************************ + + NOTE: This is a FAST builtin and can be called from JIT code only. + +*******************************************************************************/ + +bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass) +{ + if (o == NULL) + return 0; + + return builtin_fast_arraycheckcast(o, targetclass); +} + + +/* builtin_arrayinstanceof ***************************************************** + + NOTE: This builtin can be called from NATIVE code only. + +*******************************************************************************/ + +bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass) +{ + bool result; + + LLNI_CRITICAL_START; + + result = builtin_fast_arrayinstanceof(LLNI_UNWRAP(h), targetclass); + + LLNI_CRITICAL_END; + + return result; +} + + +/* builtin_throw_exception ***************************************************** + + Sets the exception pointer with the thrown exception and prints some + debugging information. + + NOTE: This is a FAST builtin and can be called from JIT code, + or from asm_vm_call_method. + +*******************************************************************************/ + +void *builtin_throw_exception(java_object_t *xptr) +{ +#if !defined(NDEBUG) + /* print exception trace */ + + if (opt_TraceExceptions) + trace_exception_builtin(xptr); +#endif /* !defined(NDEBUG) */ + + /* actually set the exception */ + + exceptions_set_exception(LLNI_QUICKWRAP(xptr)); + + /* Return a NULL pointer. This is required for vm_call_method to + check for an exception. This is for convenience. */ + + return NULL; +} + + +/* builtin_retrieve_exception ************************************************** + + Gets and clears the exception pointer of the current thread. + + RETURN VALUE: + the exception object, or NULL if no exception was thrown. + + NOTE: This is a FAST builtin and can be called from JIT code, + or from the signal handlers. + +*******************************************************************************/ + +java_object_t *builtin_retrieve_exception(void) +{ + java_handle_t *h; + java_object_t *o; + + /* actually get and clear the exception */ + + h = exceptions_get_and_clear_exception(); + o = LLNI_UNWRAP(h); + + return o; +} + + +/* builtin_canstore ************************************************************ + + Checks, if an object can be stored in an array. + + RETURN VALUE: + 1......possible + 0......otherwise (throws an ArrayStoreException) + + NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. + +*******************************************************************************/ + +bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o) +{ + bool result; + + LLNI_CRITICAL_START; + + result = builtin_fast_canstore(LLNI_DIRECT(oa), LLNI_UNWRAP(o)); + + LLNI_CRITICAL_END; + + /* if not possible, throw an exception */ + + if (result == 0) + exceptions_throw_arraystoreexception(); + + return result; +} + + +/* builtin_fast_canstore ******************************************************* + + Checks, if an object can be stored in an array. + + RETURN VALUE: + 1......possible + 0......otherwise (no exception thrown!) + + NOTE: This is a FAST builtin and can be called from JIT code only. + +*******************************************************************************/ + +bool fast_subtype_check(struct _vftbl *s, struct _vftbl *t) +{ + if (s->subtype_display[t->subtype_depth] == t) + return true; + if (t->subtype_offset != OFFSET(vftbl_t, subtype_display[DISPLAY_SIZE])) + return false; + return s->subtype_depth >= t->subtype_depth && s->subtype_overflow[t->subtype_depth - DISPLAY_SIZE] == t; +} + +bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o) +{ + arraydescriptor *desc; + arraydescriptor *valuedesc; + vftbl_t *componentvftbl; + vftbl_t *valuevftbl; + int32_t baseval; + uint32_t diffval; + bool result; + + if (o == NULL) + return 1; + + /* The following is guaranteed (by verifier checks): + * + * *) oa->...vftbl->arraydesc != NULL + * *) oa->...vftbl->arraydesc->componentvftbl != NULL + * *) o->vftbl is not an interface vftbl + */ + + desc = oa->header.objheader.vftbl->arraydesc; + componentvftbl = desc->componentvftbl; + valuevftbl = o->vftbl; + valuedesc = valuevftbl->arraydesc; + + if ((desc->dimension - 1) == 0) { + /* {oa is a one-dimensional array} */ + /* {oa is an array of references} */ + + if (valuevftbl == componentvftbl) + return 1; + + baseval = componentvftbl->baseval; + + if (baseval <= 0) { + /* an array of interface references */ + + result = ((valuevftbl->interfacetablelength > -baseval) && + (valuevftbl->interfacetable[baseval] != NULL)); + } + else { + result = fast_subtype_check(valuevftbl, componentvftbl); + } + } + else if (valuedesc == NULL) { + /* {oa has dimension > 1} */ + /* {componentvftbl->arraydesc != NULL} */ + + /* check if o is an array */ + + return 0; + } + else { + /* {o is an array} */ + + result = builtin_descriptorscompatible(valuedesc, componentvftbl->arraydesc); + } + + /* return result */ + + return result; +} + + +/* This is an optimized version where a is guaranteed to be one-dimensional */ +bool builtin_fast_canstore_onedim(java_objectarray_t *a, java_object_t *o) +{ + arraydescriptor *desc; + vftbl_t *elementvftbl; + vftbl_t *valuevftbl; + int32_t baseval; + uint32_t diffval; + bool result; + + if (o == NULL) + return 1; + + /* The following is guaranteed (by verifier checks): + * + * *) a->...vftbl->arraydesc != NULL + * *) a->...vftbl->arraydesc->elementvftbl != NULL + * *) a->...vftbl->arraydesc->dimension == 1 + * *) o->vftbl is not an interface vftbl + */ + + desc = a->header.objheader.vftbl->arraydesc; + elementvftbl = desc->elementvftbl; + valuevftbl = o->vftbl; + + /* {a is a one-dimensional array} */ + + if (valuevftbl == elementvftbl) + return 1; + + baseval = elementvftbl->baseval; + + if (baseval <= 0) { + /* an array of interface references */ + result = ((valuevftbl->interfacetablelength > -baseval) && + (valuevftbl->interfacetable[baseval] != NULL)); + } + else { + result = fast_subtype_check(valuevftbl, elementvftbl); + } + + return result; +} + + +/* This is an optimized version where a is guaranteed to be a + * one-dimensional array of a class type */ +bool builtin_fast_canstore_onedim_class(java_objectarray_t *a, java_object_t *o) +{ + vftbl_t *elementvftbl; + vftbl_t *valuevftbl; + uint32_t diffval; + bool result; + + if (o == NULL) + return 1; + + /* The following is guaranteed (by verifier checks): + * + * *) a->...vftbl->arraydesc != NULL + * *) a->...vftbl->arraydesc->elementvftbl != NULL + * *) a->...vftbl->arraydesc->elementvftbl is not an interface vftbl + * *) a->...vftbl->arraydesc->dimension == 1 + * *) o->vftbl is not an interface vftbl + */ + + elementvftbl = a->header.objheader.vftbl->arraydesc->elementvftbl; + valuevftbl = o->vftbl; + + /* {a is a one-dimensional array} */ + + if (valuevftbl == elementvftbl) + return 1; + + result = fast_subtype_check(valuevftbl, elementvftbl); + + return result; +} + + +/* builtin_new ***************************************************************** + + Creates a new instance of class c on the heap. + + RETURN VALUE: + pointer to the object, or NULL if no memory is available + + NOTE: This builtin can be called from NATIVE code only. + +*******************************************************************************/ + +java_handle_t *builtin_new(classinfo *c) +{ + java_handle_t *o; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +#endif +#if defined(ENABLE_CYCLES_STATS) + u8 cycles_start, cycles_end; +#endif + + RT_TIMING_GET_TIME(time_start); + CYCLES_STATS_GET(cycles_start); + + /* is the class loaded */ + + assert(c->state & CLASS_LOADED); + + /* check if we can instantiate this class */ + + if (c->flags & ACC_ABSTRACT) { + exceptions_throw_instantiationerror(c); + return NULL; + } + + /* is the class linked */ + + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + return NULL; + + if (!(c->state & CLASS_INITIALIZED)) { +#if !defined(NDEBUG) + if (initverbose) + log_message_class("Initialize class (from builtin_new): ", c); +#endif + + if (!initialize_class(c)) + return NULL; + } + + o = (java_handle_t*) heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS, + c->finalizer, true); + + if (!o) + return NULL; + +#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) + /* XXX this is only a dirty hack to make Boehm work with handles */ + + o = LLNI_WRAP((java_object_t *) o); +#endif + + LLNI_vftbl_direct(o) = c->vftbl; + +#if defined(ENABLE_THREADS) + lock_init_object_lock(LLNI_DIRECT(o)); +#endif + + CYCLES_STATS_GET(cycles_end); + RT_TIMING_GET_TIME(time_end); + + CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start); + RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT); + + return o; +} + +#if defined(ENABLE_ESCAPE_REASON) +java_handle_t *builtin_escape_reason_new(classinfo *c) { + print_escape_reasons(); + return builtin_java_new(c); +} +#endif + +#if defined(ENABLE_TLH) +java_handle_t *builtin_tlh_new(classinfo *c) +{ + java_handle_t *o; +# if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +# endif +# if defined(ENABLE_CYCLES_STATS) + u8 cycles_start, cycles_end; +# endif + + RT_TIMING_GET_TIME(time_start); + CYCLES_STATS_GET(cycles_start); + + /* is the class loaded */ + + assert(c->state & CLASS_LOADED); + + /* check if we can instantiate this class */ + + if (c->flags & ACC_ABSTRACT) { + exceptions_throw_instantiationerror(c); + return NULL; + } + + /* is the class linked */ + + if (!(c->state & CLASS_LINKED)) + if (!link_class(c)) + return NULL; + + if (!(c->state & CLASS_INITIALIZED)) { +# if !defined(NDEBUG) + if (initverbose) + log_message_class("Initialize class (from builtin_new): ", c); +# endif + + if (!initialize_class(c)) + return NULL; + } + + /* + o = tlh_alloc(&(THREADOBJECT->tlh), c->instancesize); + */ + o = NULL; + + if (o == NULL) { + o = (java_handle_t*) heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS, + c->finalizer, true); + } + + if (!o) + return NULL; + +# if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) + /* XXX this is only a dirty hack to make Boehm work with handles */ + + o = LLNI_WRAP((java_object_t *) o); +# endif + + LLNI_vftbl_direct(o) = c->vftbl; + +# if defined(ENABLE_THREADS) + lock_init_object_lock(LLNI_DIRECT(o)); +# endif + + CYCLES_STATS_GET(cycles_end); + RT_TIMING_GET_TIME(time_end); + +/* + CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start); + RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT); +*/ + + return o; +} +#endif + + +/* builtin_java_new ************************************************************ + + NOTE: This is a SLOW builtin and can be called from JIT code only. + +*******************************************************************************/ + +java_handle_t *builtin_java_new(java_handle_t *clazz) +{ + return builtin_new(LLNI_classinfo_unwrap(clazz)); +} + + +/* builtin_fast_new ************************************************************ + + Creates a new instance of class c on the heap. + + RETURN VALUE: + pointer to the object, or NULL if no fast return + is possible for any reason. + + NOTE: This is a FAST builtin and can be called from JIT code only. + +*******************************************************************************/ + +java_object_t *builtin_fast_new(classinfo *c) +{ + java_object_t *o; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +#endif +#if defined(ENABLE_CYCLES_STATS) + u8 cycles_start, cycles_end; +#endif + + RT_TIMING_GET_TIME(time_start); + CYCLES_STATS_GET(cycles_start); + + /* is the class loaded */ + + assert(c->state & CLASS_LOADED); + + /* check if we can instantiate this class */ + + if (c->flags & ACC_ABSTRACT) + return NULL; + + /* is the class linked */ + + if (!(c->state & CLASS_LINKED)) + return NULL; + + if (!(c->state & CLASS_INITIALIZED)) + return NULL; + + o = (java_handle_t*) heap_alloc(c->instancesize, c->flags & ACC_CLASS_HAS_POINTERS, + c->finalizer, false); + + if (!o) + return NULL; + + o->vftbl = c->vftbl; + +#if defined(ENABLE_THREADS) + lock_init_object_lock(o); +#endif + + CYCLES_STATS_GET(cycles_end); + RT_TIMING_GET_TIME(time_end); + + CYCLES_STATS_COUNT(builtin_new,cycles_end - cycles_start); + RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_OBJECT); + + return o; +} + + +/* builtin_newarray ************************************************************ + + Creates an array with the given vftbl on the heap. This function + takes as class argument an array class. + + RETURN VALUE: + pointer to the array or NULL if no memory is available + + NOTE: This builtin can be called from NATIVE code only. + +*******************************************************************************/ + +java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass) +{ + arraydescriptor *desc; + s4 dataoffset; + s4 componentsize; + s4 actualsize; + java_handle_t *a; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +#endif + + RT_TIMING_GET_TIME(time_start); + + desc = arrayclass->vftbl->arraydesc; + dataoffset = desc->dataoffset; + componentsize = desc->componentsize; + + if (size < 0) { + exceptions_throw_negativearraysizeexception(); + return NULL; + } + + actualsize = dataoffset + size * componentsize; + + /* check for overflow */ + + if (((u4) actualsize) < ((u4) size)) { + exceptions_throw_outofmemoryerror(); + return NULL; + } + + a = (java_handle_t*) heap_alloc(actualsize, (desc->arraytype == ARRAYTYPE_OBJECT), NULL, true); + + if (a == NULL) + return NULL; + +#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) + /* XXX this is only a dirty hack to make Boehm work with handles */ + + a = LLNI_WRAP((java_object_t *) a); +#endif + + LLNI_vftbl_direct(a) = arrayclass->vftbl; + +#if defined(ENABLE_THREADS) + lock_init_object_lock(LLNI_DIRECT(a)); +#endif + + LLNI_array_size(a) = size; + + RT_TIMING_GET_TIME(time_end); + RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_NEW_ARRAY); + + return a; +} + + +/* builtin_java_newarray ******************************************************* + + NOTE: This is a SLOW builtin and can be called from JIT code only. + +*******************************************************************************/ + +java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclazz) +{ + return builtin_newarray(size, LLNI_classinfo_unwrap(arrayclazz)); +} + + +/* builtin_anewarray *********************************************************** + + Creates an array of references to the given class type on the heap. + + RETURN VALUE: + pointer to the array or NULL if no memory is + available + + NOTE: This builtin can be called from NATIVE code only. + +*******************************************************************************/ + +java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass) +{ + classinfo *arrayclass; + + /* is class loaded */ + + assert(componentclass->state & CLASS_LOADED); + + /* is class linked */ + + if (!(componentclass->state & CLASS_LINKED)) + if (!link_class(componentclass)) + return NULL; + + arrayclass = class_array_of(componentclass, true); + + if (!arrayclass) + return NULL; + + return (java_handle_objectarray_t *) builtin_newarray(size, arrayclass); +} + + +/* builtin_newarray_type **************************************************** + + Creates an array of [type]s on the heap. + + RETURN VALUE: + pointer to the array or NULL if no memory is available + + NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. + +*******************************************************************************/ + +#define BUILTIN_NEWARRAY_TYPE(type, arraytype) \ +java_handle_##type##array_t *builtin_newarray_##type(int32_t size) \ +{ \ + return (java_handle_##type##array_t *) \ + builtin_newarray(size, primitivetype_table[arraytype].arrayclass); \ +} + +BUILTIN_NEWARRAY_TYPE(boolean, ARRAYTYPE_BOOLEAN) +BUILTIN_NEWARRAY_TYPE(byte, ARRAYTYPE_BYTE) +BUILTIN_NEWARRAY_TYPE(char, ARRAYTYPE_CHAR) +BUILTIN_NEWARRAY_TYPE(short, ARRAYTYPE_SHORT) +BUILTIN_NEWARRAY_TYPE(int, ARRAYTYPE_INT) +BUILTIN_NEWARRAY_TYPE(long, ARRAYTYPE_LONG) +BUILTIN_NEWARRAY_TYPE(float, ARRAYTYPE_FLOAT) +BUILTIN_NEWARRAY_TYPE(double, ARRAYTYPE_DOUBLE) + + +/* builtin_multianewarray_intern *********************************************** + + Creates a multi-dimensional array on the heap. The dimensions are + passed in an array of longs. + + ARGUMENTS: + n.............number of dimensions to create + arrayclass....the array class + dims..........array containing the size of each dimension to create + + RETURN VALUE: + pointer to the array or NULL if no memory is available + +******************************************************************************/ + +static java_handle_t *builtin_multianewarray_intern(int n, + classinfo *arrayclass, + long *dims) +{ + s4 size; + java_handle_t *a; + classinfo *componentclass; + s4 i; + + /* create this dimension */ + + size = (s4) dims[0]; + a = builtin_newarray(size, arrayclass); + + if (!a) + return NULL; + + /* if this is the last dimension return */ + + if (!--n) + return a; + + /* get the class of the components to create */ + + componentclass = arrayclass->vftbl->arraydesc->componentvftbl->clazz; + + /* The verifier guarantees that the dimension count is in the range. */ + + /* create the component arrays */ + + for (i = 0; i < size; i++) { + java_handle_t *ea = +#if defined(__MIPS__) && (SIZEOF_VOID_P == 4) + /* we save an s4 to a s8 slot, 8-byte aligned */ + + builtin_multianewarray_intern(n, componentclass, dims + 2); +#else + builtin_multianewarray_intern(n, componentclass, dims + 1); +#endif + + if (!ea) + return NULL; + + array_objectarray_element_set((java_handle_objectarray_t *) a, i, ea); + } + + return a; +} + + +/* builtin_multianewarray ****************************************************** + + Wrapper for builtin_multianewarray_intern which checks all + dimensions before we start allocating. + + NOTE: This is a SLOW builtin and can be called from JIT code only. + +******************************************************************************/ + +java_handle_objectarray_t *builtin_multianewarray(int n, + java_handle_t *arrayclazz, + long *dims) +{ + classinfo *c; + s4 i; + s4 size; + + /* check all dimensions before doing anything */ + + for (i = 0; i < n; i++) { +#if defined(__MIPS__) && (SIZEOF_VOID_P == 4) + /* we save an s4 to a s8 slot, 8-byte aligned */ + size = (s4) dims[i * 2]; +#else + size = (s4) dims[i]; +#endif + + if (size < 0) { + exceptions_throw_negativearraysizeexception(); + return NULL; + } + } + + c = LLNI_classinfo_unwrap(arrayclazz); + + /* now call the real function */ + + return (java_handle_objectarray_t *) + builtin_multianewarray_intern(n, c, dims); +} + + +/* builtin_verbosecall_enter *************************************************** + + Print method call with arguments for -verbose:call. + + XXX: Remove mew once all archs use the new tracer! + +*******************************************************************************/ + +#if !defined(NDEBUG) +#ifdef TRACE_ARGS_NUM +void builtin_verbosecall_enter(s8 a0, s8 a1, +# if TRACE_ARGS_NUM >= 4 + s8 a2, s8 a3, +# endif +# if TRACE_ARGS_NUM >= 6 + s8 a4, s8 a5, +# endif +# if TRACE_ARGS_NUM == 8 + s8 a6, s8 a7, +# endif + methodinfo *m) +{ + log_text("builtin_verbosecall_enter: Do not call me anymore!"); +} +#endif +#endif /* !defined(NDEBUG) */ + + +/* builtin_verbosecall_exit **************************************************** + + Print method exit for -verbose:call. + + XXX: Remove mew once all archs use the new tracer! + +*******************************************************************************/ + +#if !defined(NDEBUG) +void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m) +{ + log_text("builtin_verbosecall_exit: Do not call me anymore!"); +} +#endif /* !defined(NDEBUG) */ + + +/*============================================================================*/ +/* MISCELLANEOUS MATHEMATICAL HELPER FUNCTIONS */ +/*============================================================================*/ + +/*********** Functions for integer divisions ***************************** + + On some systems (eg. DEC ALPHA), integer division is not supported by the + CPU. These helper functions implement the missing functionality. + +******************************************************************************/ + +#if !SUPPORT_DIVISION || defined(DISABLE_GC) +s4 builtin_idiv(s4 a, s4 b) +{ + s4 c; + + c = a / b; + + return c; +} + +s4 builtin_irem(s4 a, s4 b) +{ + s4 c; + + c = a % b; + + return c; +} +#endif /* !SUPPORT_DIVISION || defined(DISABLE_GC) */ + + +/* functions for long arithmetics ********************************************** + + On systems where 64 bit Integers are not supported by the CPU, + these functions are needed. + +******************************************************************************/ + +#if !(SUPPORT_LONG && SUPPORT_LONG_ADD) +s8 builtin_ladd(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a + b; +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lsub(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a - b; +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lneg(s8 a) +{ + s8 c; + +#if U8_AVAILABLE + c = -a; +#else + c = builtin_i2l(0); +#endif + + return c; +} +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */ + + +#if !(SUPPORT_LONG && SUPPORT_LONG_MUL) +s8 builtin_lmul(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a * b; +#else + c = builtin_i2l(0); +#endif + + return c; +} +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_MUL) */ + + +#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined (DISABLE_GC) +s8 builtin_ldiv(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a / b; +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lrem(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a % b; +#else + c = builtin_i2l(0); +#endif + + return c; +} +#endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */ + + +#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) +s8 builtin_lshl(s8 a, s4 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a << (b & 63); +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lshr(s8 a, s4 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a >> (b & 63); +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lushr(s8 a, s4 b) +{ + s8 c; + +#if U8_AVAILABLE + c = ((u8) a) >> (b & 63); +#else + c = builtin_i2l(0); +#endif + + return c; +} +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */ + + +#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) +s8 builtin_land(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a & b; +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lor(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a | b; +#else + c = builtin_i2l(0); +#endif + + return c; +} + +s8 builtin_lxor(s8 a, s8 b) +{ + s8 c; + +#if U8_AVAILABLE + c = a ^ b; +#else + c = builtin_i2l(0); +#endif + + return c; +} +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */ + + +#if !(SUPPORT_LONG && SUPPORT_LONG_CMP) +s4 builtin_lcmp(s8 a, s8 b) +{ +#if U8_AVAILABLE + if (a < b) + return -1; + + if (a > b) + return 1; + + return 0; +#else + return 0; +#endif +} +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_CMP) */ + + +/* functions for unsupported floating instructions ****************************/ + +/* used to convert FLT_xxx defines into float values */ + +static inline float intBitsToFloat(s4 i) +{ + imm_union imb; + + imb.i = i; + return imb.f; +} + + +/* used to convert DBL_xxx defines into double values */ + +static inline float longBitsToDouble(s8 l) +{ + imm_union imb; + + imb.l = l; + return imb.d; +} + + +#if !SUPPORT_FLOAT +float builtin_fadd(float a, float b) +{ + if (isnanf(a)) return intBitsToFloat(FLT_NAN); + if (isnanf(b)) return intBitsToFloat(FLT_NAN); + if (finitef(a)) { + if (finitef(b)) + return a + b; + else + return b; + } + else { + if (finitef(b)) + return a; + else { + if (copysignf(1.0, a) == copysignf(1.0, b)) + return a; + else + return intBitsToFloat(FLT_NAN); + } + } +} + + +float builtin_fsub(float a, float b) +{ + return builtin_fadd(a, builtin_fneg(b)); +} + + +float builtin_fmul(float a, float b) +{ + if (isnanf(a)) return intBitsToFloat(FLT_NAN); + if (isnanf(b)) return intBitsToFloat(FLT_NAN); + if (finitef(a)) { + if (finitef(b)) return a * b; + else { + if (a == 0) return intBitsToFloat(FLT_NAN); + else return copysignf(b, copysignf(1.0, b)*a); + } + } + else { + if (finitef(b)) { + if (b == 0) return intBitsToFloat(FLT_NAN); + else return copysignf(a, copysignf(1.0, a)*b); + } + else { + return copysignf(a, copysignf(1.0, a)*copysignf(1.0, b)); + } + } +} + + +/* builtin_ddiv **************************************************************** + + Implementation as described in VM Spec. + +*******************************************************************************/ + +float builtin_fdiv(float a, float b) +{ + if (finitef(a)) { + if (finitef(b)) { + /* If neither value1' nor value2' is NaN, the sign of the result */ + /* is positive if both values have the same sign, negative if the */ + /* values have different signs. */ + + return a / b; + + } else { + if (isnanf(b)) { + /* If either value1' or value2' is NaN, the result is NaN. */ + + return intBitsToFloat(FLT_NAN); + + } else { + /* Division of a finite value by an infinity results in a */ + /* signed zero, with the sign-producing rule just given. */ + + /* is sign equal? */ + + if (copysignf(1.0, a) == copysignf(1.0, b)) + return 0.0; + else + return -0.0; + } + } + + } else { + if (isnanf(a)) { + /* If either value1' or value2' is NaN, the result is NaN. */ + + return intBitsToFloat(FLT_NAN); + + } else if (finitef(b)) { + /* Division of an infinity by a finite value results in a signed */ + /* infinity, with the sign-producing rule just given. */ + + /* is sign equal? */ + + if (copysignf(1.0, a) == copysignf(1.0, b)) + return intBitsToFloat(FLT_POSINF); + else + return intBitsToFloat(FLT_NEGINF); + + } else { + /* Division of an infinity by an infinity results in NaN. */ + + return intBitsToFloat(FLT_NAN); + } + } +} + + +float builtin_fneg(float a) +{ + if (isnanf(a)) return a; + else { + if (finitef(a)) return -a; + else return copysignf(a, -copysignf(1.0, a)); + } +} +#endif /* !SUPPORT_FLOAT */ + + +#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP) +s4 builtin_fcmpl(float a, float b) +{ + if (isnanf(a)) + return -1; + + if (isnanf(b)) + return -1; + + if (!finitef(a) || !finitef(b)) { + a = finitef(a) ? 0 : copysignf(1.0, a); + b = finitef(b) ? 0 : copysignf(1.0, b); + } + + if (a > b) + return 1; + + if (a == b) + return 0; + + return -1; +} + + +s4 builtin_fcmpg(float a, float b) +{ + if (isnanf(a)) return 1; + if (isnanf(b)) return 1; + if (!finitef(a) || !finitef(b)) { + a = finitef(a) ? 0 : copysignf(1.0, a); + b = finitef(b) ? 0 : copysignf(1.0, b); + } + if (a > b) return 1; + if (a == b) return 0; + return -1; +} +#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP || defined(ENABLE_INTRP) */ + + +float builtin_frem(float a, float b) +{ + return fmodf(a, b); +} + + +/* functions for unsupported double instructions ******************************/ + +#if !SUPPORT_DOUBLE +double builtin_dadd(double a, double b) +{ + if (isnan(a)) return longBitsToDouble(DBL_NAN); + if (isnan(b)) return longBitsToDouble(DBL_NAN); + if (finite(a)) { + if (finite(b)) return a + b; + else return b; + } + else { + if (finite(b)) return a; + else { + if (copysign(1.0, a)==copysign(1.0, b)) return a; + else return longBitsToDouble(DBL_NAN); + } + } +} + + +double builtin_dsub(double a, double b) +{ + return builtin_dadd(a, builtin_dneg(b)); +} + + +double builtin_dmul(double a, double b) +{ + if (isnan(a)) return longBitsToDouble(DBL_NAN); + if (isnan(b)) return longBitsToDouble(DBL_NAN); + if (finite(a)) { + if (finite(b)) return a * b; + else { + if (a == 0) return longBitsToDouble(DBL_NAN); + else return copysign(b, copysign(1.0, b) * a); + } + } + else { + if (finite(b)) { + if (b == 0) return longBitsToDouble(DBL_NAN); + else return copysign(a, copysign(1.0, a) * b); + } + else { + return copysign(a, copysign(1.0, a) * copysign(1.0, b)); + } + } +} + + +/* builtin_ddiv **************************************************************** + + Implementation as described in VM Spec. + +*******************************************************************************/ + +double builtin_ddiv(double a, double b) +{ + if (finite(a)) { + if (finite(b)) { + /* If neither value1' nor value2' is NaN, the sign of the result */ + /* is positive if both values have the same sign, negative if the */ + /* values have different signs. */ + + return a / b; + + } else { + if (isnan(b)) { + /* If either value1' or value2' is NaN, the result is NaN. */ + + return longBitsToDouble(DBL_NAN); + + } else { + /* Division of a finite value by an infinity results in a */ + /* signed zero, with the sign-producing rule just given. */ + + /* is sign equal? */ + + if (copysign(1.0, a) == copysign(1.0, b)) + return 0.0; + else + return -0.0; + } + } + + } else { + if (isnan(a)) { + /* If either value1' or value2' is NaN, the result is NaN. */ + + return longBitsToDouble(DBL_NAN); + + } else if (finite(b)) { + /* Division of an infinity by a finite value results in a signed */ + /* infinity, with the sign-producing rule just given. */ + + /* is sign equal? */ + + if (copysign(1.0, a) == copysign(1.0, b)) + return longBitsToDouble(DBL_POSINF); + else + return longBitsToDouble(DBL_NEGINF); + + } else { + /* Division of an infinity by an infinity results in NaN. */ + + return longBitsToDouble(DBL_NAN); + } + } +} + + +/* builtin_dneg **************************************************************** + + Implemented as described in VM Spec. + +*******************************************************************************/ + +double builtin_dneg(double a) +{ + if (isnan(a)) { + /* If the operand is NaN, the result is NaN (recall that NaN has no */ + /* sign). */ + + return a; + + } else { + if (finite(a)) { + /* If the operand is a zero, the result is the zero of opposite */ + /* sign. */ + + return -a; + + } else { + /* If the operand is an infinity, the result is the infinity of */ + /* opposite sign. */ + + return copysign(a, -copysign(1.0, a)); + } + } +} +#endif /* !SUPPORT_DOUBLE */ + + +#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP) +s4 builtin_dcmpl(double a, double b) +{ + if (isnan(a)) + return -1; + + if (isnan(b)) + return -1; + + if (!finite(a) || !finite(b)) { + a = finite(a) ? 0 : copysign(1.0, a); + b = finite(b) ? 0 : copysign(1.0, b); + } + + if (a > b) + return 1; + + if (a == b) + return 0; + + return -1; +} + + +s4 builtin_dcmpg(double a, double b) +{ + if (isnan(a)) + return 1; + + if (isnan(b)) + return 1; + + if (!finite(a) || !finite(b)) { + a = finite(a) ? 0 : copysign(1.0, a); + b = finite(b) ? 0 : copysign(1.0, b); + } + + if (a > b) + return 1; + + if (a == b) + return 0; + + return -1; +} +#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP || defined(ENABLE_INTRP) */ + + +double builtin_drem(double a, double b) +{ + return fmod(a, b); +} + + +/* conversion operations ******************************************************/ + +#if 0 +s8 builtin_i2l(s4 i) +{ +#if U8_AVAILABLE + return i; +#else + s8 v; + v.high = 0; + v.low = i; + return v; +#endif +} + +s4 builtin_l2i(s8 l) +{ +#if U8_AVAILABLE + return (s4) l; +#else + return l.low; +#endif +} +#endif + + +#if !(SUPPORT_FLOAT && SUPPORT_I2F) +float builtin_i2f(s4 a) +{ + float f = (float) a; + return f; +} +#endif /* !(SUPPORT_FLOAT && SUPPORT_I2F) */ + + +#if !(SUPPORT_DOUBLE && SUPPORT_I2D) +double builtin_i2d(s4 a) +{ + double d = (double) a; + return d; +} +#endif /* !(SUPPORT_DOUBLE && SUPPORT_I2D) */ + + +#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) +float builtin_l2f(s8 a) +{ +#if U8_AVAILABLE + float f = (float) a; + return f; +#else + return 0.0; +#endif +} +#endif /* !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) */ + + +#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) +double builtin_l2d(s8 a) +{ +#if U8_AVAILABLE + double d = (double) a; + return d; +#else + return 0.0; +#endif +} +#endif /* !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) */ + + +#if !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) +s4 builtin_f2i(float a) +{ + s4 i; + + i = builtin_d2i((double) a); + + return i; + + /* float f; + + if (isnanf(a)) + return 0; + if (finitef(a)) { + if (a > 2147483647) + return 2147483647; + if (a < (-2147483648)) + return (-2147483648); + return (s4) a; + } + f = copysignf((float) 1.0, a); + if (f > 0) + return 2147483647; + return (-2147483648); */ +} +#endif /* !(SUPPORT_FLOAT && SUPPORT_F2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */ + + +#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) || defined(DISABLE_GC) +s8 builtin_f2l(float a) +{ + s8 l; + + l = builtin_d2l((double) a); + + return l; + + /* float f; + + if (finitef(a)) { + if (a > 9223372036854775807L) + return 9223372036854775807L; + if (a < (-9223372036854775808L)) + return (-9223372036854775808L); + return (s8) a; + } + if (isnanf(a)) + return 0; + f = copysignf((float) 1.0, a); + if (f > 0) + return 9223372036854775807L; + return (-9223372036854775808L); */ +} +#endif /* !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) */ + + +#if !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) +s4 builtin_d2i(double a) +{ + double d; + + if (finite(a)) { + if (a >= 2147483647) + return 2147483647; + if (a <= (-2147483647-1)) + return (-2147483647-1); + return (s4) a; + } + if (isnan(a)) + return 0; + d = copysign(1.0, a); + if (d > 0) + return 2147483647; + return (-2147483647-1); +} +#endif /* !(SUPPORT_DOUBLE && SUPPORT_D2I) || defined(ENABLE_INTRP) || defined(DISABLE_GC) */ + + +#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) || defined(DISABLE_GC) +s8 builtin_d2l(double a) +{ + double d; + + if (finite(a)) { + if (a >= 9223372036854775807LL) + return 9223372036854775807LL; + if (a <= (-9223372036854775807LL-1)) + return (-9223372036854775807LL-1); + return (s8) a; + } + if (isnan(a)) + return 0; + d = copysign(1.0, a); + if (d > 0) + return 9223372036854775807LL; + return (-9223372036854775807LL-1); +} +#endif /* !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) */ + + +#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE) +double builtin_f2d(float a) +{ + if (finitef(a)) return (double) a; + else { + if (isnanf(a)) + return longBitsToDouble(DBL_NAN); + else + return copysign(longBitsToDouble(DBL_POSINF), (double) copysignf(1.0, a) ); + } +} + +float builtin_d2f(double a) +{ + if (finite(a)) + return (float) a; + else { + if (isnan(a)) + return intBitsToFloat(FLT_NAN); + else + return copysignf(intBitsToFloat(FLT_POSINF), (float) copysign(1.0, a)); + } +} +#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */ + + +/*============================================================================*/ +/* AUTOMATICALLY REPLACED FUNCTIONS */ +/*============================================================================*/ + +/* builtin_arraycopy *********************************************************** + + Builtin for java.lang.System.arraycopy. + + NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. + +*******************************************************************************/ + +void builtin_arraycopy(java_handle_t *src, s4 srcStart, + java_handle_t *dest, s4 destStart, s4 len) +{ + arraydescriptor *sdesc; + arraydescriptor *ddesc; + s4 i; + + if ((src == NULL) || (dest == NULL)) { + exceptions_throw_nullpointerexception(); + return; + } + + sdesc = LLNI_vftbl_direct(src)->arraydesc; + ddesc = LLNI_vftbl_direct(dest)->arraydesc; + + if (!sdesc || !ddesc || (sdesc->arraytype != ddesc->arraytype)) { + exceptions_throw_arraystoreexception(); + return; + } + + // Check if offsets and length are positive. + if ((srcStart < 0) || (destStart < 0) || (len < 0)) { + exceptions_throw_arrayindexoutofboundsexception(); + return; + } + + // Check if ranges are valid. + if ((((uint32_t) srcStart + (uint32_t) len) > (uint32_t) LLNI_array_size(src)) || + (((uint32_t) destStart + (uint32_t) len) > (uint32_t) LLNI_array_size(dest))) { + exceptions_throw_arrayindexoutofboundsexception(); + return; + } + + // Special case. + if (len == 0) { + return; + } + + if (sdesc->componentvftbl == ddesc->componentvftbl) { + /* We copy primitive values or references of exactly the same type */ + + s4 dataoffset = sdesc->dataoffset; + s4 componentsize = sdesc->componentsize; + + LLNI_CRITICAL_START; + + MMOVE(((u1 *) LLNI_DIRECT(dest)) + dataoffset + componentsize * destStart, + ((u1 *) LLNI_DIRECT(src)) + dataoffset + componentsize * srcStart, + u1, (size_t) len * componentsize); + + LLNI_CRITICAL_END; + } + else { + /* We copy references of different type */ + + java_handle_objectarray_t *oas = (java_handle_objectarray_t *) src; + java_handle_objectarray_t *oad = (java_handle_objectarray_t *) dest; + + if (destStart <= srcStart) { + for (i = 0; i < len; i++) { + java_handle_t *o; + + o = array_objectarray_element_get(oas, srcStart + i); + + if (!builtin_canstore(oad, o)) + return; + + array_objectarray_element_set(oad, destStart + i, o); + } + } + else { + /* XXX this does not completely obey the specification! + If an exception is thrown only the elements above the + current index have been copied. The specification + requires that only the elements *below* the current + index have been copied before the throw. */ + + for (i = len - 1; i >= 0; i--) { + java_handle_t *o; + + o = array_objectarray_element_get(oas, srcStart + i); + + if (!builtin_canstore(oad, o)) + return; + + array_objectarray_element_set(oad, destStart + i, o); + } + } + } +} + + +/* builtin_nanotime ************************************************************ + + Return the current time in nanoseconds. + +*******************************************************************************/ + +s8 builtin_nanotime(void) +{ + struct timeval tv; + s8 usecs; + + if (gettimeofday(&tv, NULL) == -1) + vm_abort("gettimeofday failed: %s", strerror(errno)); + + usecs = (s8) tv.tv_sec * (1000 * 1000) + (s8) tv.tv_usec; + + return usecs * 1000; +} + + +/* builtin_currenttimemillis *************************************************** + + Return the current time in milliseconds. + +*******************************************************************************/ + +s8 builtin_currenttimemillis(void) +{ + s8 msecs; + + msecs = builtin_nanotime() / 1000 / 1000; + + return msecs; +} + + +/* builtin_clone *************************************************************** + + Function for cloning objects or arrays. + + NOTE: This is a SLOW builtin and can be called from JIT & NATIVE code. + +*******************************************************************************/ + +java_handle_t *builtin_clone(void *env, java_handle_t *o) +{ + arraydescriptor *ad; + u4 size; + classinfo *c; + java_handle_t *co; /* cloned object header */ + + /* get the array descriptor */ + + ad = LLNI_vftbl_direct(o)->arraydesc; + + /* we are cloning an array */ + + if (ad != NULL) { + size = ad->dataoffset + ad->componentsize * LLNI_array_size(o); + + co = (java_handle_t*) heap_alloc(size, (ad->arraytype == ARRAYTYPE_OBJECT), NULL, true); + + if (co == NULL) + return NULL; + +#if !defined(ENABLE_GC_CACAO) && defined(ENABLE_HANDLES) + /* XXX this is only a dirty hack to make Boehm work with handles */ + + co = LLNI_WRAP((java_object_t *) co); +#endif + + LLNI_CRITICAL_START; + + MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, size); + +#if defined(ENABLE_GC_CACAO) + heap_init_objectheader(LLNI_DIRECT(co), size); +#endif + +#if defined(ENABLE_THREADS) + lock_init_object_lock(LLNI_DIRECT(co)); +#endif + + LLNI_CRITICAL_END; + + return co; + } + + /* we are cloning a non-array */ + + if (!builtin_instanceof(o, class_java_lang_Cloneable)) { + exceptions_throw_clonenotsupportedexception(); + return NULL; + } + + /* get the class of the object */ + + LLNI_class_get(o, c); + + /* create new object */ + + co = builtin_new(c); + + if (co == NULL) + return NULL; + + LLNI_CRITICAL_START; + + MCOPY(LLNI_DIRECT(co), LLNI_DIRECT(o), u1, c->instancesize); + +#if defined(ENABLE_GC_CACAO) + heap_init_objectheader(LLNI_DIRECT(co), c->instancesize); +#endif + +#if defined(ENABLE_THREADS) + lock_init_object_lock(LLNI_DIRECT(co)); +#endif + + LLNI_CRITICAL_END; + + return co; +} + + +#if defined(ENABLE_CYCLES_STATS) +void builtin_print_cycles_stats(FILE *file) +{ + fprintf(file,"builtin cylce count statistics:\n"); + + CYCLES_STATS_PRINT_OVERHEAD(builtin_overhead,file); + CYCLES_STATS_PRINT(builtin_new ,file); + + fprintf(file,"\n"); +} +#endif /* defined(ENABLE_CYCLES_STATS) */ + + +#if defined(ENABLE_VMLOG) +#define NDEBUG +#include +#endif + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/builtin.hpp b/src/vm/jit/builtin.hpp new file mode 100644 index 000000000..2f94b09fd --- /dev/null +++ b/src/vm/jit/builtin.hpp @@ -0,0 +1,356 @@ +/* src/vm/jit/builtin.hpp - prototypes of builtin functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _BUILTIN_HPP +#define _BUILTIN_HPP + +/* forward typedefs ***********************************************************/ + +typedef struct builtintable_entry builtintable_entry; + +#include "config.h" +#include "vm/types.h" + +#include "arch.h" +#include "md-abi.h" + +#include "toolbox/logging.h" + +#include "vm/descriptor.h" +#include "vm/utf8.h" + + +/* define infinity for floating point numbers */ + +#define FLT_NAN 0x7fc00000 +#define FLT_POSINF 0x7f800000 +#define FLT_NEGINF 0xff800000 + +/* define infinity for double floating point numbers */ + +#define DBL_NAN 0x7ff8000000000000LL +#define DBL_POSINF 0x7ff0000000000000LL +#define DBL_NEGINF 0xfff0000000000000LL + + +/* float versions are not defined in GNU classpath's fdlibm */ + +#define copysignf copysign +#define finitef finite +#define fmodf fmod +#define isnanf isnan + + +/* builtin functions table ****************************************************/ + +struct builtintable_entry { + s4 opcode; /* opcode which is replaced */ + u4 flags; /* e.g. check for exception */ + functionptr fp; /* function pointer of builtin */ + u1 *stub; /* pointer to builtin stub code */ + const char* cclassname; /* char name of the class */ + const char* cname; /* char name of the function */ + const char* cdescriptor; /* char name of the descriptor */ + utf *classname; /* class of the function */ + utf *name; /* name of the function */ + utf *descriptor; /* descriptor of the function */ + methoddesc *md; +}; + + +/* builtin table flag defines *************************************************/ + +#define BUILTINTABLE_FLAG_STUB 0x0001 /* builtin needs a stub */ +#define BUILTINTABLE_FLAG_EXCEPTION 0x0002 /* check for excepion on return */ + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +bool builtin_init(void); + +builtintable_entry *builtintable_get_internal(functionptr fp); +builtintable_entry *builtintable_get_automatic(s4 opcode); + +bool builtintable_replace_function(void *iptr); + + +/**********************************************************************/ +/* BUILTIN FUNCTIONS */ +/**********************************************************************/ + +/* NOTE: Builtin functions which are used in the BUILTIN* opcodes must + * have a BUILTIN_... macro defined as seen below. In code dealing + * with the BUILTIN* opcodes the functions may only be addressed by + * these macros, never by their actual name! (This helps to make this + * code more portable.) + * + * C and assembler code which does not deal with the BUILTIN* opcodes, + * can use the builtin functions normally (like all other functions). + * + * IMPORTANT: + * For each builtin function which is used in a BUILTIN* opcode there + * must be an entry in the builtin_desc table in jit/jit.c. + * + * Below each prototype is either the BUILTIN_ macro definition or a + * comment specifiying that this function is not used in BUILTIN* + * opcodes. + * + * (The BUILTIN* opcodes are ICMD_BUILTIN1, ICMD_BUILTIN2 and + * ICMD_BUILTIN3.) + */ + +bool fast_subtype_check(struct _vftbl *, struct _vftbl *); + +bool builtin_instanceof(java_handle_t *obj, classinfo *c); +/* NOT AN OP */ +bool builtin_checkcast(java_handle_t *obj, classinfo *c); +/* NOT AN OP */ +bool builtin_arrayinstanceof(java_handle_t *h, classinfo *targetclass); +/* NOT AN OP */ +bool builtin_fast_arrayinstanceof(java_object_t *o, classinfo *targetclass); +#define BUILTIN_arrayinstanceof (functionptr) builtin_fast_arrayinstanceof +bool builtin_fast_arraycheckcast(java_object_t *o, classinfo *targetclass); +#define BUILTIN_arraycheckcast (functionptr) builtin_fast_arraycheckcast + +bool builtin_canstore(java_handle_objectarray_t *oa, java_handle_t *o); +/* NOT AN OP */ +bool builtin_fast_canstore(java_objectarray_t *oa, java_object_t *o); +#define BUILTIN_FAST_canstore (functionptr) builtin_fast_canstore + +void *builtin_throw_exception(java_object_t *exception); +/* NOT AN OP */ +java_object_t *builtin_retrieve_exception(void); +/* NOT AN OP */ + +java_handle_t *builtin_new(classinfo *c); +/* NOT AN OP */ +java_handle_t *builtin_java_new(java_handle_t *c); +#define BUILTIN_new (functionptr) builtin_java_new + +#if defined(ENABLE_TLH) +#define BUILTIN_tlh_new (functionptr) builtin_tlh_new +java_handle_t *builtin_tlh_new(classinfo *c); +#endif + +#if defined(ENABLE_ESCAPE_REASON) +#define BUILTIN_escape_reason_new (functionptr)builtin_escape_reason_new +java_handle_t *builtin_escape_reason_new(classinfo *c); +#endif + +java_object_t *builtin_fast_new(classinfo *c); +#define BUILTIN_FAST_new (functionptr) builtin_fast_new + +java_handle_t *builtin_newarray(int32_t size, classinfo *arrayclass); +/* NOT AN OP */ +java_handle_t *builtin_java_newarray(int32_t size, java_handle_t *arrayclass); +#define BUILTIN_newarray (functionptr) builtin_java_newarray + +java_handle_objectarray_t *builtin_anewarray(int32_t size, classinfo *componentclass); +/* NOT AN OP */ + +java_handle_booleanarray_t *builtin_newarray_boolean(int32_t size); +#define BUILTIN_newarray_boolean (functionptr) builtin_newarray_boolean +java_handle_chararray_t *builtin_newarray_char(int32_t size); +#define BUILTIN_newarray_char (functionptr) builtin_newarray_char +java_handle_floatarray_t *builtin_newarray_float(int32_t size); +#define BUILTIN_newarray_float (functionptr) builtin_newarray_float +java_handle_doublearray_t *builtin_newarray_double(int32_t size); +#define BUILTIN_newarray_double (functionptr) builtin_newarray_double +java_handle_bytearray_t *builtin_newarray_byte(int32_t size); +#define BUILTIN_newarray_byte (functionptr) builtin_newarray_byte +java_handle_shortarray_t *builtin_newarray_short(int32_t size); +#define BUILTIN_newarray_short (functionptr) builtin_newarray_short +java_handle_intarray_t *builtin_newarray_int(int32_t size); +#define BUILTIN_newarray_int (functionptr) builtin_newarray_int +java_handle_longarray_t *builtin_newarray_long(int32_t size); +#define BUILTIN_newarray_long (functionptr) builtin_newarray_long + +java_handle_objectarray_t *builtin_multianewarray(int n, + java_handle_t *arrayclass, + long *dims); +#define BUILTIN_multianewarray (functionptr) builtin_multianewarray + +#if defined(TRACE_ARGS_NUM) +void builtin_verbosecall_enter(s8 a0, s8 a1, +# if TRACE_ARGS_NUM >= 4 + s8 a2, s8 a3, +# endif +# if TRACE_ARGS_NUM >= 6 + s8 a4, s8 a5, +# endif +# if TRACE_ARGS_NUM == 8 + s8 a6, s8 a7, +# endif + methodinfo *m); +/* NOT AN OP */ +#endif /* defined(TRACE_ARGS_NUM) */ + +void builtin_verbosecall_exit(s8 l, double d, float f, methodinfo *m); +/* NOT AN OP */ + +s4 builtin_idiv(s4 a, s4 b); +#define BUILTIN_idiv (functionptr) builtin_idiv +s4 builtin_irem(s4 a, s4 b); +#define BUILTIN_irem (functionptr) builtin_irem + +s8 builtin_ladd(s8 a, s8 b); +#define BUILTIN_ladd (functionptr) builtin_ladd +s8 builtin_lsub(s8 a, s8 b); +#define BUILTIN_lsub (functionptr) builtin_lsub +s8 builtin_lmul(s8 a, s8 b); +#define BUILTIN_lmul (functionptr) builtin_lmul + +s8 builtin_ldiv(s8 a, s8 b); +#define BUILTIN_ldiv (functionptr) builtin_ldiv +s8 builtin_lrem(s8 a, s8 b); +#define BUILTIN_lrem (functionptr) builtin_lrem + +s8 builtin_lshl(s8 a, s4 b); +#define BUILTIN_lshl (functionptr) builtin_lshl +s8 builtin_lshr(s8 a, s4 b); +#define BUILTIN_lshr (functionptr) builtin_lshr +s8 builtin_lushr(s8 a, s4 b); +#define BUILTIN_lushr (functionptr) builtin_lushr +s8 builtin_land(s8 a, s8 b); +#define BUILTIN_land (functionptr) builtin_land +s8 builtin_lor(s8 a, s8 b); +#define BUILTIN_lor (functionptr) builtin_lor +s8 builtin_lxor(s8 a, s8 b); +#define BUILTIN_lxor (functionptr) builtin_lxor +s8 builtin_lneg(s8 a); +#define BUILTIN_lneg (functionptr) builtin_lneg +s4 builtin_lcmp(s8 a, s8 b); +#define BUILTIN_lcmp (functionptr) builtin_lcmp + +float builtin_fadd(float a, float b); +#define BUILTIN_fadd (functionptr) builtin_fadd +float builtin_fsub(float a, float b); +#define BUILTIN_fsub (functionptr) builtin_fsub +float builtin_fmul(float a, float b); +#define BUILTIN_fmul (functionptr) builtin_fmul +float builtin_fdiv(float a, float b); +#define BUILTIN_fdiv (functionptr) builtin_fdiv +float builtin_fneg(float a); +#define BUILTIN_fneg (functionptr) builtin_fneg +s4 builtin_fcmpl(float a, float b); +#define BUILTIN_fcmpl (functionptr) builtin_fcmpl +s4 builtin_fcmpg(float a, float b); +#define BUILTIN_fcmpg (functionptr) builtin_fcmpg +float builtin_frem(float a, float b); +#define BUILTIN_frem (functionptr) builtin_frem + +double builtin_dadd(double a, double b); +#define BUILTIN_dadd (functionptr) builtin_dadd +double builtin_dsub(double a, double b); +#define BUILTIN_dsub (functionptr) builtin_dsub +double builtin_dmul(double a, double b); +#define BUILTIN_dmul (functionptr) builtin_dmul +double builtin_ddiv(double a, double b); +#define BUILTIN_ddiv (functionptr) builtin_ddiv +double builtin_dneg(double a); +#define BUILTIN_dneg (functionptr) builtin_dneg +s4 builtin_dcmpl(double a, double b); +#define BUILTIN_dcmpl (functionptr) builtin_dcmpl +s4 builtin_dcmpg(double a, double b); +#define BUILTIN_dcmpg (functionptr) builtin_dcmpg +double builtin_drem(double a, double b); +#define BUILTIN_drem (functionptr) builtin_drem + +s8 builtin_i2l(s4 i); +/* NOT AN OP */ +float builtin_i2f(s4 i); +#define BUILTIN_i2f (functionptr) builtin_i2f +double builtin_i2d(s4 i); +#define BUILTIN_i2d (functionptr) builtin_i2d +s4 builtin_l2i(s8 l); +/* NOT AN OP */ +float builtin_l2f(s8 l); +#define BUILTIN_l2f (functionptr) builtin_l2f +double builtin_l2d(s8 l); +#define BUILTIN_l2d (functionptr) builtin_l2d + +s4 builtin_f2i(float a); +#define BUILTIN_f2i (functionptr) builtin_f2i +s4 asm_builtin_f2i(float a); +/* NOT AN OP */ +s8 builtin_f2l(float a); +#define BUILTIN_f2l (functionptr) builtin_f2l +s8 asm_builtin_f2l(float a); +/* NOT AN OP */ + +double builtin_f2d(float a); +#define BUILTIN_f2d (functionptr) builtin_f2d + +s4 builtin_d2i(double a); +#define BUILTIN_d2i (functionptr) builtin_d2i +s4 asm_builtin_d2i(double a); +/* NOT AN OP */ +s8 builtin_d2l(double a); +#define BUILTIN_d2l (functionptr) builtin_d2l +s8 asm_builtin_d2l(double a); +/* NOT AN OP */ + +float builtin_d2f(double a); +#define BUILTIN_d2f (functionptr) builtin_d2f + +java_handle_t *builtin_clone(void *env, java_handle_t *o); +#define BUILTIN_clone (functionptr) builtin_clone + +void builtin_arraycopy(java_handle_t *src, s4 srcStart, + java_handle_t *dest, s4 destStart, s4 len); +#define BUILTIN_arraycopy (functionptr) builtin_arraycopy + +s8 builtin_nanotime(void); +s8 builtin_currenttimemillis(void); +#define BUILTIN_currenttimemillis (functionptr) builtin_currenttimemillis + +#if defined(ENABLE_CYCLES_STATS) +void builtin_print_cycles_stats(FILE *file); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // _BUILTIN_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/builtintable.inc b/src/vm/jit/builtintable.inc new file mode 100644 index 000000000..28d692160 --- /dev/null +++ b/src/vm/jit/builtintable.inc @@ -0,0 +1,1108 @@ +/* src/vm/jit/builtintable.inc - tables of builtin functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include "arch.h" + +#include "threads/lock-common.h" + +#include "vm/jit/builtin.hpp" +#include "vm/jit/jit.hpp" + + +/* internal and not automatically replaced functions **************************/ + +static builtintable_entry builtintable_internal[] = { + +#if defined(__ALPHA__) || defined(DISABLE_GC) + { + ICMD_F2L, + 0, + BUILTIN_f2l, + NULL, + NULL, + "f2l", + "(F)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_D2L, + 0, + BUILTIN_d2l, + NULL, + NULL, + "d2l", + "(D)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_F2I, + 0, + BUILTIN_f2i, + NULL, + NULL, + "f2i", + "(F)I", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_D2I, + 0, + BUILTIN_d2i, + NULL, + NULL, + "d2i", + "(D)I", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !SUPPORT_DIVISION || defined(DISABLE_GC) + { + ICMD_IDIV, + 0, + BUILTIN_idiv, + NULL, + NULL, + "idiv", + "(II)I", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_IREM, + 0, + BUILTIN_irem, + NULL, + NULL, + "irem", + "(II)I", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined(DISABLE_GC) + { + ICMD_LDIV, + 0, + BUILTIN_ldiv, + NULL, + NULL, + "ldiv", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LREM, + 0, + BUILTIN_lrem, + NULL, + NULL, + "lrem", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, +#endif + + { + ICMD_FREM, + 0, + BUILTIN_frem, + NULL, + NULL, + "frem", + "(FF)F", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_DREM, + 0, + BUILTIN_drem, + NULL, + NULL, + "drem", + "(DD)D", + NULL, + NULL, + NULL, + NULL + }, + + + /* internal functions *****************************************************/ + + { + ICMD_NEW, + BUILTINTABLE_FLAG_STUB, + BUILTIN_new, + NULL, + NULL, + "new", + "(Ljava/lang/Class;)Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, + +#if defined(ENABLE_TLH) + { + ICMD_NEW, + BUILTINTABLE_FLAG_STUB, + BUILTIN_tlh_new, + NULL, + NULL, + "tlh_new", + "(Ljava/lang/Class;)Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if defined(ENABLE_ESCAPE_REASON) + { + ICMD_NEW, + BUILTINTABLE_FLAG_STUB, + BUILTIN_escape_reason_new, + NULL, + NULL, + "escape_reason_new", + "(Ljava/lang/Class;)Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, +#endif + + { + ICMD_NEW, + 0, + BUILTIN_FAST_new, + NULL, + NULL, + "fast-new", + "(Ljava/lang/Class;)Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_ANEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray, + NULL, + NULL, + "newarray", + "(ILjava/lang/Class;)[Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_boolean, + NULL, + NULL, + "newarray_boolean", + "(I)[Z", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_byte, + NULL, + NULL, + "newarray_byte", + "(I)[B", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_char, + NULL, + NULL, + "newarray_char", + "(I)[C", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_short, + NULL, + NULL, + "newarray_short", + "(I)[S", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_int, + NULL, + NULL, + "newarray_int", + "(I)[I", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_long, + NULL, + NULL, + "newarray_long", + "(I)[J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_float, + NULL, + NULL, + "newarray_float", + "(I)[F", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_NEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_newarray_double, + NULL, + NULL, + "newarray_double", + "(I)[D", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_MULTIANEWARRAY, + BUILTINTABLE_FLAG_STUB, + BUILTIN_multianewarray, + NULL, + NULL, + "multianewarray", + /* XXX it should be: "(ILjava/lang/Class;[I)[Ljava/lang/Object;", */ + "(ILjava/lang/Class;I)[Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_CHECKCAST, + 0, + BUILTIN_arraycheckcast, + NULL, + NULL, + "arraycheckcast", + "([Ljava/lang/Object;[Ljava/lang/Object;)[Ljava/lang/Object;", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_INSTANCEOF, + 0, + BUILTIN_arrayinstanceof, + NULL, + NULL, + "arrayinstanceof", + "([Ljava/lang/Object;[Ljava/lang/Object;)I", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_AASTORE, + 0, + BUILTIN_FAST_canstore, + NULL, + NULL, + "fast-canstore", + "([Ljava/lang/Object;Ljava/lang/Object;)I", + NULL, + NULL, + NULL, + NULL + }, + +#if defined(ENABLE_THREADS) + { + ICMD_MONITORENTER, + BUILTINTABLE_FLAG_STUB, + LOCK_monitor_enter, + NULL, + NULL, + "monitorenter", + "(Ljava/lang/Object;)V", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_MONITOREXIT, + BUILTINTABLE_FLAG_STUB, + LOCK_monitor_exit, + NULL, + NULL, + "monitorexit", + "(Ljava/lang/Object;)V", + NULL, + NULL, + NULL, + NULL + }, +#endif + + + /* stop entry */ + + { + 255, + 0, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL + }, +}; + + +/* automatically replaced functions *******************************************/ + +static builtintable_entry builtintable_automatic[] = { + +#if !(SUPPORT_LONG && SUPPORT_LONG_CMP) + { + ICMD_LCMP, + 0, + BUILTIN_lcmp, + NULL, + NULL, + "lcmp", + "(JJ)I", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) + { + ICMD_LAND, + 0, + BUILTIN_land, + NULL, + NULL, + "land", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LOR, + 0, + BUILTIN_lor, + NULL, + NULL, + "lor", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LXOR, + 0, + BUILTIN_lxor, + NULL, + NULL, + "lxor", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_LOGICAL) */ + +#if !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) + { + ICMD_LSHL, + 0, + BUILTIN_lshl, + NULL, + NULL, + "lshl", + "(JI)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LSHR, + 0, + BUILTIN_lshr, + NULL, + NULL, + "lshr", + "(JI)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LUSHR, + 0, + BUILTIN_lushr, + NULL, + NULL, + "lushr", + "(JI)J", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_SHIFT) */ + +#if !(SUPPORT_LONG && SUPPORT_LONG_ADD) + { + ICMD_LADD, + 0, + BUILTIN_ladd, + NULL, + NULL, + "ladd", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LSUB, + 0, + BUILTIN_lsub, + NULL, + NULL, + "lsub", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_LNEG, + 0, + BUILTIN_lneg, + NULL, + NULL, + "lneg", + "(J)J", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !(SUPPORT_LONG && SUPPORT_LONG_ADD) */ + +#if !(SUPPORT_LONG && SUPPORT_LONG_MUL) + { + ICMD_LMUL, + 0, + BUILTIN_lmul, + NULL, + NULL, + "lmul", + "(JJ)J", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_FLOAT && SUPPORT_I2F) + { + ICMD_I2F, + 0, + BUILTIN_i2f, + NULL, + NULL, + "i2f", + "(I)F", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_DOUBLE && SUPPORT_I2D) + { + ICMD_I2D, + 0, + BUILTIN_i2d, + NULL, + NULL, + "i2d", + "(I)D", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_L2F) + { + ICMD_L2F, + 0, + BUILTIN_l2f, + NULL, + NULL, + "l2f", + "(J)F", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_L2D) + { + ICMD_L2D, + 0, + BUILTIN_l2d, + NULL, + NULL, + "l2d", + "(J)D", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_FLOAT && SUPPORT_F2I) + { + ICMD_F2I, + 0, + BUILTIN_f2i, + NULL, + NULL, + "f2i", + "(F)I", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_F2L) + { + ICMD_F2L, + 0, + BUILTIN_f2l, + NULL, + NULL, + "f2l", + "(F)J", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_DOUBLE && SUPPORT_D2I) + { + ICMD_D2I, + 0, + BUILTIN_d2i, + NULL, + NULL, + "d2i", + "(D)I", + NULL, + NULL, + NULL, + NULL + }, +#endif + +#if !(SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_D2L) + { + ICMD_D2L, + 0, + BUILTIN_d2l, + NULL, + NULL, + "d2l", + "(D)J", + NULL, + NULL, + NULL, + NULL + }, +#endif + + + /* float functions ********************************************************/ + +#if !SUPPORT_FLOAT + { + ICMD_FADD, + 0, + BUILTIN_fadd, + NULL, + NULL, + "fadd", + "(FF)F", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_FSUB, + 0, + BUILTIN_fsub, + NULL, + NULL, + "fsub", + "(FF)F", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_FMUL, + 0, + BUILTIN_fmul, + NULL, + NULL, + "fmul", + "(FF)F", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_FDIV, + 0, + BUILTIN_fdiv, + NULL, + NULL, + "fdiv", + "(FF)F", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_FNEG, + 0, + BUILTIN_fneg, + NULL, + NULL, + "fneg", + "(F)F", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !SUPPORT_FLOAT */ + +#if !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP + { + ICMD_FCMPL, + 0, + BUILTIN_fcmpl, + NULL, + NULL, + "fcmpl", + "(FF)I", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_FCMPG, + 0, + BUILTIN_fcmpg, + NULL, + NULL, + "fcmpg", + "(FF)I", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !SUPPORT_FLOAT || !SUPPORT_FLOAT_CMP */ + + + /* double functions *******************************************************/ + +#if !SUPPORT_DOUBLE + { + ICMD_DADD, + 0, + BUILTIN_dadd, + NULL, + NULL, + "dadd", + "(DD)D", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_DSUB, + 0, + BUILTIN_dsub, + NULL, + NULL, + "dsub", + "(DD)D", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_DMUL, + 0, + BUILTIN_dmul, + NULL, + NULL, + "dmul", + "(DD)D", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_DDIV, + 0, + BUILTIN_ddiv, + NULL, + NULL, + "ddiv", + "(DD)D", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_DNEG, + 0, + BUILTIN_dneg, + NULL, + NULL, + "dneg", + "(D)D", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !SUPPORT_DOUBLE */ + +#if !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP + { + ICMD_DCMPL, + 0, + BUILTIN_dcmpl, + NULL, + NULL, + "dcmpl", + "(DD)I", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_DCMPG, + 0, + BUILTIN_dcmpg, + NULL, + NULL, + "dcmpg", + "(DD)I", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !SUPPORT_DOUBLE || !SUPPORT_DOUBLE_CMP */ + + + /* float/double functions *************************************************/ + +#if !(SUPPORT_FLOAT && SUPPORT_DOUBLE) + { + ICMD_F2D, + 0, + BUILTIN_f2d, + NULL, + NULL, + "f2d", + "(F)D", + NULL, + NULL, + NULL, + NULL + }, + { + ICMD_D2F, + 0, + BUILTIN_d2f, + NULL, + NULL, + "d2f", + "(D)F", + NULL, + NULL, + NULL, + NULL + }, +#endif /* !(SUPPORT_FLOAT && SUPPORT_DOUBLE) */ + + + /* prevent a compiler warning if everything is supported (e.g. i386) */ + + { + 255, + 0, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL + }, +}; + + +/* automatically replaced functions *******************************************/ + +static builtintable_entry builtintable_function[] = { +#if defined(ENABLE_JIT) + + /* java.lang.VMSystem.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V STATIC NATIVE */ + + { + ICMD_BUILTIN, + BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION, + BUILTIN_arraycopy, + NULL, + "java/lang/VMSystem", + "arraycopy", + "(Ljava/lang/Object;ILjava/lang/Object;II)V", + NULL, + NULL, + NULL, + NULL + }, + + /* java.lang.System.arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V PUBLIC STATIC */ + +#if 0 + /* We disable this one until we have a fix for the stacktrace + issue. */ + + { + ICMD_BUILTIN, + BUILTINTABLE_FLAG_STUB | BUILTINTABLE_FLAG_EXCEPTION, + BUILTIN_arraycopy, + NULL, + "java/lang/System", + "arraycopy", + "(Ljava/lang/Object;ILjava/lang/Object;II)V", + NULL, + NULL, + NULL, + NULL + }, +#endif + + /* java.lang.VMSystem.currentTimeMillis()J PUBLIC STATIC */ + + { + ICMD_BUILTIN, + 0, + BUILTIN_currenttimemillis, + NULL, + "java/lang/VMSystem", + "currentTimeMillis", + "()J", + NULL, + NULL, + NULL, + NULL + }, + + /* java.lang.System.currentTimeMillis()J PUBLIC STATIC */ + + { + ICMD_BUILTIN, + 0, + BUILTIN_currenttimemillis, + NULL, + "java/lang/System", + "currentTimeMillis", + "()J", + NULL, + NULL, + NULL, + NULL + }, + +#endif /* defined(ENABLE_JIT) */ + + /* stop entry */ + + { + 255, + 0, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL + }, +}; + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/cfg.c b/src/vm/jit/cfg.c index 652e20097..4772b95f2 100644 --- a/src/vm/jit/cfg.c +++ b/src/vm/jit/cfg.c @@ -34,7 +34,7 @@ #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/stack.h" @@ -501,6 +501,21 @@ void cfg_add_root(jitdata *jd) { } } +void cfg_remove_root(jitdata *jd) { + basicblock *root, *zero, *it; + + root = jd->basicblocks; + zero = root->next; + + zero->predecessorcount -= 1; + + jd->basicblocks = zero; + + for (it = zero; it; it = it->next) { + it->nr -= 1; + } +} + #if defined(ENABLE_SSA) static void cfg_eliminate_edges_to_unreachable(jitdata *jd); diff --git a/src/vm/jit/cfg.h b/src/vm/jit/cfg.h index a82b75ad7..a9d787a11 100644 --- a/src/vm/jit/cfg.h +++ b/src/vm/jit/cfg.h @@ -1,9 +1,7 @@ /* src/vm/jit/cfg.h - build a control-flow graph - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -32,7 +30,7 @@ #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* defines ********************************************************************/ @@ -42,10 +40,18 @@ /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool cfg_build(jitdata *jd); void cfg_add_root(jitdata *jd); +#ifdef __cplusplus +} +#endif + #endif /* _CFG_H */ diff --git a/src/vm/jit/code.c b/src/vm/jit/code.c deleted file mode 100644 index 3bdc4678f..000000000 --- a/src/vm/jit/code.c +++ /dev/null @@ -1,296 +0,0 @@ -/* src/vm/jit/code.c - codeinfo struct for representing compiled code - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "arch.h" - -#include "mm/memory.h" - -#include "vm/vm.h" - -#include "vm/jit/code.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/methodtree.h" - -#include "vmcore/options.h" - - -/* code_init ******************************************************************* - - Initialize the code-subsystem. - -*******************************************************************************/ - -void code_init(void) -{ - /* Check if offset of codeinfo.m == 0 (see comment in code.h). */ - - if (OFFSET(codeinfo, m) != 0) - vm_abort("code_init: offset of codeinfo.m != 0: %d != 0", OFFSET(codeinfo, m)); -} - - -/* code_codeinfo_new *********************************************************** - - Create a new codeinfo for the given method. - - IN: - m................method to create a new codeinfo for - - The following fields are set in codeinfo: - m - patchers - - RETURN VALUE: - a new, initialized codeinfo, or - NULL if an exception occurred. - -*******************************************************************************/ - -codeinfo *code_codeinfo_new(methodinfo *m) -{ - codeinfo *code; - - code = NEW(codeinfo); - - code->m = m; - - patcher_list_create(code); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_codeinfo += sizeof(codeinfo); -#endif - - return code; -} - - -/* code_find_codeinfo_for_pc *************************************************** - - Return the codeinfo for the compilation unit that contains the - given PC. - - ARGUMENTS: - pc...............machine code position - - RETURN VALUE: - the codeinfo * for the given PC - -*******************************************************************************/ - -codeinfo *code_find_codeinfo_for_pc(void *pc) -{ - void *pv; - - pv = methodtree_find(pc); - - return code_get_codeinfo_for_pv(pv); -} - - -/* code_find_codeinfo_for_pc *************************************************** - - Return the codeinfo for the compilation unit that contains the - given PC. This method does not check the return value and is used - by the GC. - - IN: - pc...............machine code position - - RETURN VALUE: - the codeinfo * for the given PC, or NULL - -*******************************************************************************/ - -codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc) -{ - void *pv; - - pv = methodtree_find_nocheck(pc); - - if (pv == NULL) - return NULL; - - return code_get_codeinfo_for_pv(pv); -} - - -/* code_get_methodinfo_for_pv ************************************************** - - Return the methodinfo for the given PV. - - IN: - pv...............PV - - RETURN VALUE: - the methodinfo * - -*******************************************************************************/ - -methodinfo *code_get_methodinfo_for_pv(void *pv) -{ - codeinfo *code; - - code = code_get_codeinfo_for_pv(pv); - - /* This is the case for asm_vm_call_method. */ - - if (code == NULL) - return NULL; - - return code->m; -} - - -/* code_get_sync_slot_count **************************************************** - - Return the number of stack slots used for storing the synchronized object - (and the return value around lock_monitor_exit calls) by the given code. - - IN: - code.............the codeinfo of the code in question - (must be != NULL) - - RETURN VALUE: - the number of stack slots used for synchronization - -*******************************************************************************/ - -#if defined(ENABLE_REPLACEMENT) -int code_get_sync_slot_count(codeinfo *code) -{ -#ifdef ENABLE_THREADS - int count; - - assert(code); - - if (!checksync) - return 0; - - if (!code_is_synchronized(code)) - return 0; - - count = 1; - -#ifdef HAS_4BYTE_STACKSLOT - /* long and double need 2 4-byte slots */ - if (IS_2_WORD_TYPE(code->m->parseddesc->returntype.type)) - count++; -#endif - -#if defined(__POWERPC__) - /* powerpc needs an extra slot */ - count++; -#endif - - return count; - -#else /* !ENABLE_THREADS */ - - return 0; - -#endif /* ENABLE_THREADS */ -} -#endif /* defined(ENABLE_REPLACEMENT) */ - - -/* code_codeinfo_free ********************************************************** - - Free the memory used by a codeinfo. - - IN: - code.............the codeinfo to free - -*******************************************************************************/ - -void code_codeinfo_free(codeinfo *code) -{ - if (code == NULL) - return; - - if (code->mcode != NULL) - CFREE((void *) (ptrint) code->mcode, code->mcodelength); - - patcher_list_free(code); - -#if defined(ENABLE_REPLACEMENT) - replace_free_replacement_points(code); -#endif - - FREE(code, codeinfo); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_codeinfo -= sizeof(codeinfo); -#endif -} - - -/* code_free_code_of_method **************************************************** - - Free all codeinfos of the given method - - IN: - m................the method of which the codeinfos are to be freed - -*******************************************************************************/ - -void code_free_code_of_method(methodinfo *m) -{ - codeinfo *nextcode; - codeinfo *code; - - if (!m) - return; - - nextcode = m->code; - while (nextcode) { - code = nextcode; - nextcode = code->prev; - code_codeinfo_free(code); - } - - m->code = NULL; -} - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/code.cpp b/src/vm/jit/code.cpp new file mode 100644 index 000000000..e5aac486d --- /dev/null +++ b/src/vm/jit/code.cpp @@ -0,0 +1,295 @@ +/* src/vm/jit/code.cpp - codeinfo struct for representing compiled code + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "arch.h" + +#include "mm/memory.h" + +#include "vm/options.h" +#include "vm/vm.hpp" + +#include "vm/jit/code.hpp" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/methodtree.h" + + +/* code_init ******************************************************************* + + Initialize the code-subsystem. + +*******************************************************************************/ + +void code_init(void) +{ + /* Check if offset of codeinfo.m == 0 (see comment in code.h). */ + + if (OFFSET(codeinfo, m) != 0) + vm_abort("code_init: offset of codeinfo.m != 0: %d != 0", OFFSET(codeinfo, m)); +} + + +/* code_codeinfo_new *********************************************************** + + Create a new codeinfo for the given method. + + IN: + m................method to create a new codeinfo for + + The following fields are set in codeinfo: + m + patchers + + RETURN VALUE: + a new, initialized codeinfo, or + NULL if an exception occurred. + +*******************************************************************************/ + +codeinfo *code_codeinfo_new(methodinfo *m) +{ + codeinfo *code; + + code = NEW(codeinfo); + + code->m = m; + + patcher_list_create(code); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_codeinfo += sizeof(codeinfo); +#endif + + return code; +} + + +/* code_find_codeinfo_for_pc *************************************************** + + Return the codeinfo for the compilation unit that contains the + given PC. + + ARGUMENTS: + pc...............machine code position + + RETURN VALUE: + the codeinfo * for the given PC + +*******************************************************************************/ + +codeinfo *code_find_codeinfo_for_pc(void *pc) +{ + void *pv; + + pv = methodtree_find(pc); + + return code_get_codeinfo_for_pv(pv); +} + + +/* code_find_codeinfo_for_pc *************************************************** + + Return the codeinfo for the compilation unit that contains the + given PC. This method does not check the return value and is used + by the GC. + + IN: + pc...............machine code position + + RETURN VALUE: + the codeinfo * for the given PC, or NULL + +*******************************************************************************/ + +codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc) +{ + void *pv; + + pv = methodtree_find_nocheck(pc); + + if (pv == NULL) + return NULL; + + return code_get_codeinfo_for_pv(pv); +} + + +/* code_get_methodinfo_for_pv ************************************************** + + Return the methodinfo for the given PV. + + IN: + pv...............PV + + RETURN VALUE: + the methodinfo * + +*******************************************************************************/ + +methodinfo *code_get_methodinfo_for_pv(void *pv) +{ + codeinfo *code; + + code = code_get_codeinfo_for_pv(pv); + + /* This is the case for asm_vm_call_method. */ + + if (code == NULL) + return NULL; + + return code->m; +} + + +/* code_get_sync_slot_count **************************************************** + + Return the number of stack slots used for storing the synchronized object + (and the return value around lock_monitor_exit calls) by the given code. + + IN: + code.............the codeinfo of the code in question + (must be != NULL) + + RETURN VALUE: + the number of stack slots used for synchronization + +*******************************************************************************/ + +#if defined(ENABLE_REPLACEMENT) +int code_get_sync_slot_count(codeinfo *code) +{ +#ifdef ENABLE_THREADS + int count; + + assert(code); + + if (!checksync) + return 0; + + if (!code_is_synchronized(code)) + return 0; + + count = 1; + +#ifdef HAS_4BYTE_STACKSLOT + /* long and double need 2 4-byte slots */ + if (IS_2_WORD_TYPE(code->m->parseddesc->returntype.type)) + count++; +#endif + +#if defined(__POWERPC__) + /* powerpc needs an extra slot */ + count++; +#endif + + return count; + +#else /* !ENABLE_THREADS */ + + return 0; + +#endif /* ENABLE_THREADS */ +} +#endif /* defined(ENABLE_REPLACEMENT) */ + + +/* code_codeinfo_free ********************************************************** + + Free the memory used by a codeinfo. + + IN: + code.............the codeinfo to free + +*******************************************************************************/ + +void code_codeinfo_free(codeinfo *code) +{ + if (code == NULL) + return; + + if (code->mcode != NULL) + CFREE((void *) (ptrint) code->mcode, code->mcodelength); + + patcher_list_free(code); + +#if defined(ENABLE_REPLACEMENT) + replace_free_replacement_points(code); +#endif + + FREE(code, codeinfo); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_codeinfo -= sizeof(codeinfo); +#endif +} + + +/* code_free_code_of_method **************************************************** + + Free all codeinfos of the given method + + IN: + m................the method of which the codeinfos are to be freed + +*******************************************************************************/ + +void code_free_code_of_method(methodinfo *m) +{ + codeinfo *nextcode; + codeinfo *code; + + if (!m) + return; + + nextcode = m->code; + while (nextcode) { + code = nextcode; + nextcode = code->prev; + code_codeinfo_free(code); + } + + m->code = NULL; +} + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/code.h b/src/vm/jit/code.h deleted file mode 100644 index adff257fe..000000000 --- a/src/vm/jit/code.h +++ /dev/null @@ -1,239 +0,0 @@ -/* src/vm/jit/code.h - codeinfo struct for representing compiled code - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _CODE_H -#define _CODE_H - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "toolbox/list.h" - -#include "vm/global.h" - -#include "vm/jit/exceptiontable.h" -#include "vm/jit/linenumbertable.h" -#include "vm/jit/methodheader.h" -#include "vm/jit/replace.h" - -#include "vmcore/method.h" - - -/* constants ******************************************************************/ - -#define CODE_FLAG_INVALID 0x0001 -#define CODE_FLAG_LEAFMETHOD 0x0002 -#define CODE_FLAG_SYNCHRONIZED 0x0004 - - -/* codeinfo ******************************************************************* - - A codeinfo represents a particular realization of a method in - machine code. - - ATTENTION: The methodinfo entry in the code-structure MUST have the - offset 0, otherwise we have a problem in our compiler stub. This is - checked with an assert in code_init(). - -*******************************************************************************/ - -struct codeinfo { - methodinfo *m; /* method this is a realization of */ - codeinfo *prev; /* previous codeinfo of this method */ - - uint32_t flags; /* OR of CODE_FLAG_ constants */ - - u1 optlevel; /* optimization level of this code */ - s4 basicblockcount; /* number of basic blocks */ - - int32_t synchronizedoffset; /* stack offset of synchronized obj. */ - - /* machine code */ - u1 *mcode; /* pointer to machine code */ - u1 *entrypoint; /* machine code entry point */ - s4 mcodelength; /* length of generated machine code */ - - exceptiontable_t *exceptiontable; - linenumbertable_t *linenumbertable; - - /* patcher list */ - list_t *patchers; - - /* replacement */ - s4 stackframesize; /* size of the stackframe in slots */ - -#if defined(ENABLE_REPLACEMENT) - rplpoint *rplpoints; /* replacement points */ - rplalloc *regalloc; /* register allocation info */ - s4 rplpointcount; /* number of replacement points */ - s4 globalcount; /* number of global allocations */ - s4 regalloccount; /* number of total allocations */ - s4 memuse; /* number of arg + local slots */ - u1 savedintcount; /* number of callee saved int regs */ - u1 savedfltcount; /* number of callee saved flt regs */ -# if defined(HAS_ADDRESS_REGISTER_FILE) - u1 savedadrcount; /* number of callee saved adr regs */ -# endif - u1 *savedmcode; /* saved code under patches */ -#endif - -#if defined(ENABLE_PROFILING) - u4 frequency; /* number of method invocations */ - u4 *bbfrequency; - s8 cycles; /* number of cpu cycles */ -#endif -}; - - -/* inline functions ***********************************************************/ - -/* code_xxx_invalid ************************************************************ - - Functions for CODE_FLAG_INVALID. - -*******************************************************************************/ - -inline static int code_is_invalid(codeinfo *code) -{ - return (code->flags & CODE_FLAG_INVALID); -} - -inline static void code_flag_invalid(codeinfo *code) -{ - code->flags |= CODE_FLAG_INVALID; -} - -inline static void code_unflag_invalid(codeinfo *code) -{ - code->flags &= ~CODE_FLAG_INVALID; -} - - -/* code_xxx_leafmethod ********************************************************* - - Functions for CODE_FLAG_LEAFMETHOD. - -*******************************************************************************/ - -inline static int code_is_leafmethod(codeinfo *code) -{ - return (code->flags & CODE_FLAG_LEAFMETHOD); -} - -inline static void code_flag_leafmethod(codeinfo *code) -{ - code->flags |= CODE_FLAG_LEAFMETHOD; -} - -inline static void code_unflag_leafmethod(codeinfo *code) -{ - code->flags &= ~CODE_FLAG_LEAFMETHOD; -} - - -/* code_xxx_synchronized ******************************************************* - - Functions for CODE_FLAG_SYNCHRONIZED. - -*******************************************************************************/ - -inline static int code_is_synchronized(codeinfo *code) -{ - return (code->flags & CODE_FLAG_SYNCHRONIZED); -} - -inline static void code_flag_synchronized(codeinfo *code) -{ - code->flags |= CODE_FLAG_SYNCHRONIZED; -} - -inline static void code_unflag_synchronized(codeinfo *code) -{ - code->flags &= ~CODE_FLAG_SYNCHRONIZED; -} - - -/* code_get_codeinfo_for_pv **************************************************** - - Return the codeinfo for the given PV. - - IN: - pv...............PV - - RETURN VALUE: - the codeinfo * - -*******************************************************************************/ - -inline static codeinfo *code_get_codeinfo_for_pv(void *pv) -{ - codeinfo *code; - - assert(pv != NULL); - - code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer)); - - return code; -} - - -/* function prototypes ********************************************************/ - -void code_init(void); - -codeinfo *code_codeinfo_new(methodinfo *m); -void code_codeinfo_free(codeinfo *code); - -codeinfo *code_find_codeinfo_for_pc(void *pc); -codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc); - -methodinfo *code_get_methodinfo_for_pv(void *pv); - -#if defined(ENABLE_REPLACEMENT) -int code_get_sync_slot_count(codeinfo *code); -#endif /* defined(ENABLE_REPLACEMENT) */ - -void code_free_code_of_method(methodinfo *m); - -#endif /* _CODE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/code.hpp b/src/vm/jit/code.hpp new file mode 100644 index 000000000..deac0e15e --- /dev/null +++ b/src/vm/jit/code.hpp @@ -0,0 +1,247 @@ +/* src/vm/jit/code.hpp - codeinfo struct for representing compiled code + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _CODE_HPP +#define _CODE_HPP + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "toolbox/list.h" + +#include "vm/global.h" +#include "vm/method.h" + +#include "vm/jit/exceptiontable.h" +#include "vm/jit/linenumbertable.h" +#include "vm/jit/methodheader.h" +#include "vm/jit/replace.hpp" + + +/* constants ******************************************************************/ + +#define CODE_FLAG_INVALID 0x0001 +#define CODE_FLAG_LEAFMETHOD 0x0002 +#define CODE_FLAG_SYNCHRONIZED 0x0004 +#define CODE_FLAG_TLH 0x0008 + + +/* codeinfo ******************************************************************* + + A codeinfo represents a particular realization of a method in + machine code. + + ATTENTION: The methodinfo entry in the code-structure MUST have the + offset 0, otherwise we have a problem in our compiler stub. This is + checked with an assert in code_init(). + +*******************************************************************************/ + +struct codeinfo { + methodinfo *m; /* method this is a realization of */ + codeinfo *prev; /* previous codeinfo of this method */ + + uint32_t flags; /* OR of CODE_FLAG_ constants */ + + u1 optlevel; /* optimization level of this code */ + s4 basicblockcount; /* number of basic blocks */ + + int32_t synchronizedoffset; /* stack offset of synchronized obj. */ + + /* machine code */ + u1 *mcode; /* pointer to machine code */ + u1 *entrypoint; /* machine code entry point */ + s4 mcodelength; /* length of generated machine code */ + + exceptiontable_t *exceptiontable; + linenumbertable_t *linenumbertable; + + /* patcher list */ + list_t *patchers; + + /* replacement */ + s4 stackframesize; /* size of the stackframe in slots */ + +#if defined(ENABLE_REPLACEMENT) + rplpoint *rplpoints; /* replacement points */ + rplalloc *regalloc; /* register allocation info */ + s4 rplpointcount; /* number of replacement points */ + s4 globalcount; /* number of global allocations */ + s4 regalloccount; /* number of total allocations */ + s4 memuse; /* number of arg + local slots */ + u1 savedintcount; /* number of callee saved int regs */ + u1 savedfltcount; /* number of callee saved flt regs */ +# if defined(HAS_ADDRESS_REGISTER_FILE) + u1 savedadrcount; /* number of callee saved adr regs */ +# endif + u1 *savedmcode; /* saved code under patches */ +#endif + +#if defined(ENABLE_PROFILING) + u4 frequency; /* number of method invocations */ + u4 *bbfrequency; + s8 cycles; /* number of cpu cycles */ +#endif +}; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* inline functions ***********************************************************/ + +/* code_xxx_invalid ************************************************************ + + Functions for CODE_FLAG_INVALID. + +*******************************************************************************/ + +inline static int code_is_invalid(codeinfo *code) +{ + return (code->flags & CODE_FLAG_INVALID); +} + +inline static void code_flag_invalid(codeinfo *code) +{ + code->flags |= CODE_FLAG_INVALID; +} + +inline static void code_unflag_invalid(codeinfo *code) +{ + code->flags &= ~CODE_FLAG_INVALID; +} + + +/* code_xxx_leafmethod ********************************************************* + + Functions for CODE_FLAG_LEAFMETHOD. + +*******************************************************************************/ + +inline static int code_is_leafmethod(codeinfo *code) +{ + return (code->flags & CODE_FLAG_LEAFMETHOD); +} + +inline static void code_flag_leafmethod(codeinfo *code) +{ + code->flags |= CODE_FLAG_LEAFMETHOD; +} + +inline static void code_unflag_leafmethod(codeinfo *code) +{ + code->flags &= ~CODE_FLAG_LEAFMETHOD; +} + + +/* code_xxx_synchronized ******************************************************* + + Functions for CODE_FLAG_SYNCHRONIZED. + +*******************************************************************************/ + +inline static int code_is_synchronized(codeinfo *code) +{ + return (code->flags & CODE_FLAG_SYNCHRONIZED); +} + +inline static void code_flag_synchronized(codeinfo *code) +{ + code->flags |= CODE_FLAG_SYNCHRONIZED; +} + +inline static void code_unflag_synchronized(codeinfo *code) +{ + code->flags &= ~CODE_FLAG_SYNCHRONIZED; +} + + +/* code_get_codeinfo_for_pv **************************************************** + + Return the codeinfo for the given PV. + + IN: + pv...............PV + + RETURN VALUE: + the codeinfo * + +*******************************************************************************/ + +inline static codeinfo *code_get_codeinfo_for_pv(void *pv) +{ + codeinfo *code; + + assert(pv != NULL); + + code = *((codeinfo **) (((uintptr_t) pv) + CodeinfoPointer)); + + return code; +} + + +/* function prototypes ********************************************************/ + +void code_init(void); + +codeinfo *code_codeinfo_new(methodinfo *m); +void code_codeinfo_free(codeinfo *code); + +codeinfo *code_find_codeinfo_for_pc(void *pc); +codeinfo *code_find_codeinfo_for_pc_nocheck(void *pc); + +methodinfo *code_get_methodinfo_for_pv(void *pv); + +#if defined(ENABLE_REPLACEMENT) +int code_get_sync_slot_count(codeinfo *code); +#endif /* defined(ENABLE_REPLACEMENT) */ + +void code_free_code_of_method(methodinfo *m); + +#ifdef __cplusplus +} +#endif + +#endif // _CODE_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c deleted file mode 100644 index 045a44c86..000000000 --- a/src/vm/jit/codegen-common.c +++ /dev/null @@ -1,1657 +0,0 @@ -/* src/vm/jit/codegen-common.c - architecture independent code generator stuff - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - All functions assume the following code area / data area layout: - - +-----------+ - | | - | code area | code area grows to higher addresses - | | - +-----------+ <-- start of procedure - | | - | data area | data area grows to lower addresses - | | - +-----------+ - - The functions first write into a temporary code/data area allocated by - "codegen_init". "codegen_finish" copies the code and data area into permanent - memory. All functions writing values into the data area return the offset - relative the begin of the code area (start of procedure). - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "codegen.h" -#include "md.h" -#include "md-abi.h" - -#include "mm/memory.h" - -#include "toolbox/avl.h" -#include "toolbox/list.h" -#include "toolbox/logging.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/localref.h" -#include "native/native.h" - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -# include "native/include/java_lang_Object.h" -# include "native/include/java_lang_String.h" /* required by j.l.CL */ -# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -# include "native/include/java_lang_ClassLoader.h" -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) -# include "native/include/java_lang_String.h" -#endif - -#include "native/include/java_lang_Class.h" - -#include "threads/thread.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" - -#include "vm/jit/abi.h" -#include "vm/jit/asmpart.h" -#include "vm/jit/code.h" -#include "vm/jit/codegen-common.h" - -#if defined(ENABLE_DISASSEMBLER) -# include "vm/jit/disass.h" -#endif - -#include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/linenumbertable.h" -#include "vm/jit/methodheader.h" -#include "vm/jit/methodtree.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#if defined(ENABLE_SSA) -# include "vm/jit/optimizing/lsra.h" -# include "vm/jit/optimizing/ssa.h" -#endif -#include "vm/jit/stacktrace.h" -#include "vm/jit/trace.h" - -#if defined(ENABLE_INTRP) -#include "vm/jit/intrp/intrp.h" -#endif - -#include "vmcore/method.h" -#include "vmcore/options.h" - -# include "vmcore/statistics.h" - -#if defined(ENABLE_VMLOG) -#include -#endif - -#include "show.h" - - -/* codegen_init **************************************************************** - - TODO - -*******************************************************************************/ - -void codegen_init(void) -{ -} - - -/* codegen_setup *************************************************************** - - Allocates and initialises code area, data area and references. - -*******************************************************************************/ - -void codegen_setup(jitdata *jd) -{ - methodinfo *m; - codegendata *cd; - - /* get required compiler data */ - - m = jd->m; - cd = jd->cd; - - /* initialize members */ - - cd->flags = 0; - - cd->mcodebase = DMNEW(u1, MCODEINITSIZE); - cd->mcodeend = cd->mcodebase + MCODEINITSIZE; - cd->mcodesize = MCODEINITSIZE; - - /* initialize mcode variables */ - - cd->mcodeptr = cd->mcodebase; - cd->lastmcodeptr = cd->mcodebase; - -#if defined(ENABLE_INTRP) - /* native dynamic superinstructions variables */ - - if (opt_intrp) { - cd->ncodebase = DMNEW(u1, NCODEINITSIZE); - cd->ncodesize = NCODEINITSIZE; - - /* initialize ncode variables */ - - cd->ncodeptr = cd->ncodebase; - - cd->lastinstwithoutdispatch = ~0; /* no inst without dispatch */ - cd->superstarts = NULL; - } -#endif - - cd->dseg = NULL; - cd->dseglen = 0; - - cd->jumpreferences = NULL; - -#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) - cd->datareferences = NULL; -#endif - - cd->brancheslabel = list_create_dump(OFFSET(branch_label_ref_t, linkage)); - cd->listcritical = list_create_dump(OFFSET(critical_section_ref_t, linkage)); - cd->linenumbers = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage)); -} - - -/* codegen_reset *************************************************************** - - Resets the codegen data structure so we can recompile the method. - -*******************************************************************************/ - -static void codegen_reset(jitdata *jd) -{ - codeinfo *code; - codegendata *cd; - basicblock *bptr; - - /* get required compiler data */ - - code = jd->code; - cd = jd->cd; - - /* reset error flag */ - - cd->flags &= ~CODEGENDATA_FLAG_ERROR; - - /* reset some members, we reuse the code memory already allocated - as this should have almost the correct size */ - - cd->mcodeptr = cd->mcodebase; - cd->lastmcodeptr = cd->mcodebase; - - cd->dseg = NULL; - cd->dseglen = 0; - - cd->jumpreferences = NULL; - -#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) - cd->datareferences = NULL; -#endif - - cd->brancheslabel = list_create_dump(OFFSET(branch_label_ref_t, linkage)); - cd->listcritical = list_create_dump(OFFSET(critical_section_ref_t, linkage)); - cd->linenumbers = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage)); - - /* We need to clear the mpc and the branch references from all - basic blocks as they will definitely change. */ - - for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) { - bptr->mpc = -1; - bptr->branchrefs = NULL; - } - - /* We need to clear all the patcher references from the codeinfo - since they all will be regenerated */ - - patcher_list_reset(code); - -#if defined(ENABLE_REPLACEMENT) - code->rplpoints = NULL; - code->rplpointcount = 0; - code->regalloc = NULL; - code->regalloccount = 0; - code->globalcount = 0; -#endif -} - - -/* codegen_generate ************************************************************ - - Generates the code for the currently compiled method. - -*******************************************************************************/ - -bool codegen_generate(jitdata *jd) -{ - codegendata *cd; - - /* get required compiler data */ - - cd = jd->cd; - - /* call the machine-dependent code generation function */ - - if (!codegen_emit(jd)) - return false; - - /* check for an error */ - - if (CODEGENDATA_HAS_FLAG_ERROR(cd)) { - /* check for long-branches flag, if it is set we recompile the - method */ - -#if !defined(NDEBUG) - if (compileverbose) - log_message_method("Re-generating code: ", jd->m); -#endif - - /* XXX maybe we should tag long-branches-methods for recompilation */ - - if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) { - /* we have to reset the codegendata structure first */ - - codegen_reset(jd); - - /* and restart the compiler run */ - - if (!codegen_emit(jd)) - return false; - } - else { - vm_abort("codegen_generate: unknown error occurred during codegen_emit: flags=%x\n", cd->flags); - } - -#if !defined(NDEBUG) - if (compileverbose) - log_message_method("Re-generating code done: ", jd->m); -#endif - } - - /* reallocate the memory and finish the code generation */ - - codegen_finish(jd); - - /* everything's ok */ - - return true; -} - - -/* codegen_close *************************************************************** - - TODO - -*******************************************************************************/ - -void codegen_close(void) -{ - /* TODO: release avl tree on i386 and x86_64 */ -} - - -/* codegen_increase ************************************************************ - - Doubles code area. - -*******************************************************************************/ - -void codegen_increase(codegendata *cd) -{ - u1 *oldmcodebase; - - /* save old mcodebase pointer */ - - oldmcodebase = cd->mcodebase; - - /* reallocate to new, doubled memory */ - - cd->mcodebase = DMREALLOC(cd->mcodebase, - u1, - cd->mcodesize, - cd->mcodesize * 2); - cd->mcodesize *= 2; - cd->mcodeend = cd->mcodebase + cd->mcodesize; - - /* set new mcodeptr */ - - cd->mcodeptr = cd->mcodebase + (cd->mcodeptr - oldmcodebase); - -#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(__M68K__) || defined(ENABLE_INTRP) \ - || defined(__SPARC_64__) - /* adjust the pointer to the last patcher position */ - - if (cd->lastmcodeptr != NULL) - cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase); -#endif -} - - -/* codegen_ncode_increase ****************************************************** - - Doubles code area. - -*******************************************************************************/ - -#if defined(ENABLE_INTRP) -u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr) -{ - u1 *oldncodebase; - - /* save old ncodebase pointer */ - - oldncodebase = cd->ncodebase; - - /* reallocate to new, doubled memory */ - - cd->ncodebase = DMREALLOC(cd->ncodebase, - u1, - cd->ncodesize, - cd->ncodesize * 2); - cd->ncodesize *= 2; - - /* return the new ncodeptr */ - - return (cd->ncodebase + (ncodeptr - oldncodebase)); -} -#endif - - -/* codegen_add_branch_ref ****************************************************** - - Prepends an branch to the list. - -*******************************************************************************/ - -void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options) -{ - branchref *br; - s4 branchmpc; - - STATISTICS(count_branches_unresolved++); - - /* calculate the mpc of the branch instruction */ - - branchmpc = cd->mcodeptr - cd->mcodebase; - - br = DNEW(branchref); - - br->branchmpc = branchmpc; - br->condition = condition; - br->reg = reg; - br->options = options; - br->next = target->branchrefs; - - target->branchrefs = br; -} - - -/* codegen_resolve_branchrefs ************************************************** - - Resolves and patches the branch references of a given basic block. - -*******************************************************************************/ - -void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr) -{ - branchref *br; - u1 *mcodeptr; - - /* Save the mcodeptr because in the branch emitting functions - we generate code somewhere inside already generated code, - but we're still in the actual code generation phase. */ - - mcodeptr = cd->mcodeptr; - - /* just to make sure */ - - assert(bptr->mpc >= 0); - - for (br = bptr->branchrefs; br != NULL; br = br->next) { - /* temporary set the mcodeptr */ - - cd->mcodeptr = cd->mcodebase + br->branchmpc; - - /* emit_bccz and emit_branch emit the correct code, even if we - pass condition == BRANCH_UNCONDITIONAL or reg == -1. */ - - emit_bccz(cd, bptr, br->condition, br->reg, br->options); - } - - /* restore mcodeptr */ - - cd->mcodeptr = mcodeptr; -} - - -/* codegen_branch_label_add **************************************************** - - Append an branch to the label-branch list. - -*******************************************************************************/ - -void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options) -{ - list_t *l; - branch_label_ref_t *br; - s4 mpc; - - /* Get the label list. */ - - l = cd->brancheslabel; - - /* calculate the current mpc */ - - mpc = cd->mcodeptr - cd->mcodebase; - - br = DNEW(branch_label_ref_t); - - br->mpc = mpc; - br->label = label; - br->condition = condition; - br->reg = reg; - br->options = options; - - /* Add the branch to the list. */ - - list_add_last(l, br); -} - - -/* codegen_critical_section_new ************************************************ - - Allocates a new critical-section reference and adds it to the - critical-section list. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void codegen_critical_section_new(codegendata *cd) -{ - list_t *l; - critical_section_ref_t *csr; - s4 mpc; - - /* Get the critical section list. */ - - l = cd->listcritical; - - /* calculate the current mpc */ - - mpc = cd->mcodeptr - cd->mcodebase; - - csr = DNEW(critical_section_ref_t); - - /* We only can set restart right now, as start and end are set by - the following, corresponding functions. */ - - csr->start = -1; - csr->end = -1; - csr->restart = mpc; - - /* Add the branch to the list. */ - - list_add_last(l, csr); -} -#endif - - -/* codegen_critical_section_start ********************************************** - - Set the start-point of the current critical section (which is the - last element of the list). - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void codegen_critical_section_start(codegendata *cd) -{ - list_t *l; - critical_section_ref_t *csr; - s4 mpc; - - /* Get the critical section list. */ - - l = cd->listcritical; - - /* calculate the current mpc */ - - mpc = cd->mcodeptr - cd->mcodebase; - - /* Get the current critical section. */ - - csr = list_last(l); - - /* set the start point */ - - assert(csr->start == -1); - - csr->start = mpc; -} -#endif - - -/* codegen_critical_section_end ************************************************ - - Set the end-point of the current critical section (which is the - last element of the list). - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void codegen_critical_section_end(codegendata *cd) -{ - list_t *l; - critical_section_ref_t *csr; - s4 mpc; - - /* Get the critical section list. */ - - l = cd->listcritical; - - /* calculate the current mpc */ - - mpc = cd->mcodeptr - cd->mcodebase; - - /* Get the current critical section. */ - - csr = list_last(l); - - /* set the end point */ - - assert(csr->end == -1); - - csr->end = mpc; -} -#endif - - -/* codegen_critical_section_finish ********************************************* - - Finish the critical sections, create the critical section nodes for - the AVL tree and insert them into the tree. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -static void codegen_critical_section_finish(jitdata *jd) -{ - codeinfo *code; - codegendata *cd; - list_t *l; - critical_section_ref_t *csr; - critical_section_node_t *csn; - - /* get required compiler data */ - - code = jd->code; - cd = jd->cd; - - /* Get the critical section list. */ - - l = cd->listcritical; - - /* iterate over all critical sections */ - - for (csr = list_first(l); csr != NULL; csr = list_next(l, csr)) { - /* check if all points are set */ - - assert(csr->start != -1); - assert(csr->end != -1); - assert(csr->restart != -1); - - /* allocate tree node */ - - csn = NEW(critical_section_node_t); - - csn->start = code->entrypoint + csr->start; - csn->end = code->entrypoint + csr->end; - csn->restart = code->entrypoint + csr->restart; - - /* insert into the tree */ - - critical_section_register(csn); - } -} -#endif - - -/* codegen_set_replacement_point_notrap **************************************** - - Record the position of a non-trappable replacement point. - -*******************************************************************************/ - -#if defined(ENABLE_REPLACEMENT) -#if !defined(NDEBUG) -void codegen_set_replacement_point_notrap(codegendata *cd, s4 type) -#else -void codegen_set_replacement_point_notrap(codegendata *cd) -#endif -{ - assert(cd->replacementpoint); - assert(cd->replacementpoint->type == type); - assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP); - - cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase); - - cd->replacementpoint++; -} -#endif /* defined(ENABLE_REPLACEMENT) */ - - -/* codegen_set_replacement_point *********************************************** - - Record the position of a trappable replacement point. - -*******************************************************************************/ - -#if defined(ENABLE_REPLACEMENT) -#if !defined(NDEBUG) -void codegen_set_replacement_point(codegendata *cd, s4 type) -#else -void codegen_set_replacement_point(codegendata *cd) -#endif -{ - assert(cd->replacementpoint); - assert(cd->replacementpoint->type == type); - assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP)); - - cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase); - - cd->replacementpoint++; - -#if !defined(NDEBUG) - /* XXX actually we should use an own REPLACEMENT_NOPS here! */ - if (opt_TestReplacement) - PATCHER_NOPS; -#endif - - /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */ - - cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE; -} -#endif /* defined(ENABLE_REPLACEMENT) */ - - -/* codegen_finish ************************************************************** - - Finishes the code generation. A new memory, large enough for both - data and code, is allocated and data and code are copied together - to their final layout, unresolved jumps are resolved, ... - -*******************************************************************************/ - -void codegen_finish(jitdata *jd) -{ - codeinfo *code; - codegendata *cd; - s4 mcodelen; -#if defined(ENABLE_INTRP) - s4 ncodelen; -#endif - s4 alignedmcodelen; - jumpref *jr; - u1 *epoint; - s4 alignedlen; - - /* get required compiler data */ - - code = jd->code; - cd = jd->cd; - - /* prevent compiler warning */ - -#if defined(ENABLE_INTRP) - ncodelen = 0; -#endif - - /* calculate the code length */ - - mcodelen = (s4) (cd->mcodeptr - cd->mcodebase); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) { - count_code_len += mcodelen; - count_data_len += cd->dseglen; - } -#endif - - alignedmcodelen = MEMORY_ALIGN(mcodelen, MAX_ALIGN); - -#if defined(ENABLE_INTRP) - if (opt_intrp) - ncodelen = cd->ncodeptr - cd->ncodebase; - else { - ncodelen = 0; /* avoid compiler warning */ - } -#endif - - cd->dseglen = MEMORY_ALIGN(cd->dseglen, MAX_ALIGN); - alignedlen = alignedmcodelen + cd->dseglen; - -#if defined(ENABLE_INTRP) - if (opt_intrp) { - alignedlen += ncodelen; - } -#endif - - /* allocate new memory */ - - code->mcodelength = mcodelen + cd->dseglen; - code->mcode = CNEW(u1, alignedlen); - - /* set the entrypoint of the method */ - - assert(code->entrypoint == NULL); - code->entrypoint = epoint = (code->mcode + cd->dseglen); - - /* fill the data segment (code->entrypoint must already be set!) */ - - dseg_finish(jd); - - /* copy code to the new location */ - - MCOPY((void *) code->entrypoint, cd->mcodebase, u1, mcodelen); - -#if defined(ENABLE_INTRP) - /* relocate native dynamic superinstruction code (if any) */ - - if (opt_intrp) { - cd->mcodebase = code->entrypoint; - - if (ncodelen > 0) { - u1 *ncodebase = code->mcode + cd->dseglen + alignedmcodelen; - - MCOPY((void *) ncodebase, cd->ncodebase, u1, ncodelen); - - /* flush the instruction and data caches */ - - md_cacheflush(ncodebase, ncodelen); - - /* set some cd variables for dynamic_super_rerwite */ - - cd->ncodebase = ncodebase; - - } else { - cd->ncodebase = NULL; - } - - dynamic_super_rewrite(cd); - } -#endif - - /* Create the exception table. */ - - exceptiontable_create(jd); - - /* Create the linenumber table. */ - - linenumbertable_create(jd); - - /* jump table resolving */ - - for (jr = cd->jumpreferences; jr != NULL; jr = jr->next) - *((functionptr *) ((ptrint) epoint + jr->tablepos)) = - (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc); - - /* patcher resolving */ - - patcher_resolve(jd); - -#if defined(ENABLE_REPLACEMENT) - /* replacement point resolving */ - { - int i; - rplpoint *rp; - - rp = code->rplpoints; - for (i=0; irplpointcount; ++i, ++rp) { - rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc); - } - } -#endif /* defined(ENABLE_REPLACEMENT) */ - - /* Insert method into methodtree to find the entrypoint. */ - - methodtree_insert(code->entrypoint, code->entrypoint + mcodelen); - -#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) - /* resolve data segment references */ - - dseg_resolve_datareferences(jd); -#endif - -#if defined(ENABLE_THREADS) - /* create cirtical sections */ - - codegen_critical_section_finish(jd); -#endif - - /* flush the instruction and data caches */ - - md_cacheflush(code->mcode, code->mcodelength); -} - - -/* codegen_generate_stub_compiler ********************************************** - - Wrapper for codegen_emit_stub_compiler. - - Returns: - pointer to the compiler stub code. - -*******************************************************************************/ - -u1 *codegen_generate_stub_compiler(methodinfo *m) -{ - jitdata *jd; - codegendata *cd; - ptrint *d; /* pointer to data memory */ - u1 *c; /* pointer to code memory */ - int32_t dumpmarker; - - /* mark dump memory */ - - DMARKER; - - /* allocate required data structures */ - - jd = DNEW(jitdata); - - jd->m = m; - jd->cd = DNEW(codegendata); - jd->flags = 0; - - /* get required compiler data */ - - cd = jd->cd; - -#if !defined(JIT_COMPILER_VIA_SIGNAL) - /* allocate code memory */ - - c = CNEW(u1, 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE); - - /* set pointers correctly */ - - d = (ptrint *) c; - - cd->mcodebase = c; - - c = c + 3 * SIZEOF_VOID_P; - cd->mcodeptr = c; - - /* NOTE: The codeinfo pointer is actually a pointer to the - methodinfo (this fakes a codeinfo structure). */ - - d[0] = (ptrint) asm_call_jit_compiler; - d[1] = (ptrint) m; - d[2] = (ptrint) &d[1]; /* fake code->m */ - - /* call the emit function */ - - codegen_emit_stub_compiler(jd); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_cstub_len += 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE; -#endif - - /* flush caches */ - - md_cacheflush(cd->mcodebase, 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE); -#else - /* Allocate code memory. */ - - c = CNEW(uint8_t, 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE); - - /* Set pointers correctly. */ - - d = (ptrint *) c; - - cd->mcodebase = c; - - c = c + 2 * SIZEOF_VOID_P; - cd->mcodeptr = c; - - /* NOTE: The codeinfo pointer is actually a pointer to the - methodinfo (this fakes a codeinfo structure). */ - - d[0] = (ptrint) m; - d[1] = (ptrint) &d[0]; /* fake code->m */ - - /* Emit the trap instruction. */ - - emit_trap_compiler(cd); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_cstub_len += 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE; -#endif - - /* Flush caches. */ - - md_cacheflush(cd->mcodebase, 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE); -#endif - - /* release dump memory */ - - DRELEASE; - - /* return native stub code */ - - return c; -} - - -/* codegen_generate_stub_builtin *********************************************** - - Wrapper for codegen_emit_stub_native. - -*******************************************************************************/ - -void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte) -{ - jitdata *jd; - codeinfo *code; - int skipparams; - int32_t dumpmarker; - - /* mark dump memory */ - - DMARKER; - - /* Create JIT data structure. */ - - jd = jit_jitdata_new(m); - - /* Get required compiler data. */ - - code = jd->code; - - /* Stubs are non-leaf methods. */ - - code_unflag_leafmethod(code); - - /* setup code generation stuff */ - - codegen_setup(jd); - - /* Set the number of native arguments we need to skip. */ - - skipparams = 0; - - /* generate the code */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) { -# endif - assert(bte->fp != NULL); - codegen_emit_stub_native(jd, bte->md, bte->fp, skipparams); -# if defined(ENABLE_INTRP) - } -# endif -#endif - - /* reallocate the memory and finish the code generation */ - - codegen_finish(jd); - - /* set the stub entry point in the builtin table */ - - bte->stub = code->entrypoint; - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_stub_native += code->mcodelength; -#endif - -#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) - /* disassemble native stub */ - - if (opt_DisassembleStubs) { - codegen_disassemble_stub(m, - (u1 *) (ptrint) code->entrypoint, - (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen)); - - /* show data segment */ - - if (opt_showddatasegment) - dseg_display(jd); - } -#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */ - - /* release memory */ - - DRELEASE; -} - - -/* codegen_generate_stub_native ************************************************ - - Wrapper for codegen_emit_stub_native. - - Returns: - the codeinfo representing the stub code. - -*******************************************************************************/ - -codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f) -{ - jitdata *jd; - codeinfo *code; - methoddesc *md; - methoddesc *nmd; - int skipparams; - int32_t dumpmarker; - - /* mark dump memory */ - - DMARKER; - - /* Create JIT data structure. */ - - jd = jit_jitdata_new(m); - - /* Get required compiler data. */ - - code = jd->code; - - /* Stubs are non-leaf methods. */ - - code_unflag_leafmethod(code); - - /* set the flags for the current JIT run */ - -#if defined(ENABLE_PROFILING) - if (opt_prof) - jd->flags |= JITDATA_FLAG_INSTRUMENT; -#endif - - if (opt_verbosecall) - jd->flags |= JITDATA_FLAG_VERBOSECALL; - - /* setup code generation stuff */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) -# endif - reg_setup(jd); -#endif - - codegen_setup(jd); - - /* create new method descriptor with additional native parameters */ - - md = m->parseddesc; - - /* Set the number of native arguments we need to skip. */ - - if (m->flags & ACC_STATIC) - skipparams = 2; - else - skipparams = 1; - - nmd = (methoddesc *) DMNEW(u1, sizeof(methoddesc) - sizeof(typedesc) + - md->paramcount * sizeof(typedesc) + - skipparams * sizeof(typedesc)); - - nmd->paramcount = md->paramcount + skipparams; - - nmd->params = DMNEW(paramdesc, nmd->paramcount); - - nmd->paramtypes[0].type = TYPE_ADR; /* add environment pointer */ - - if (m->flags & ACC_STATIC) - nmd->paramtypes[1].type = TYPE_ADR; /* add class pointer */ - - MCOPY(nmd->paramtypes + skipparams, md->paramtypes, typedesc, - md->paramcount); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) -# endif - /* pre-allocate the arguments for the native ABI */ - - md_param_alloc_native(nmd); -#endif - - /* generate the code */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - intrp_createnativestub(f, jd, nmd); - else -# endif - codegen_emit_stub_native(jd, nmd, f, skipparams); -#else - intrp_createnativestub(f, jd, nmd); -#endif - - /* reallocate the memory and finish the code generation */ - - codegen_finish(jd); - -#if defined(ENABLE_STATISTICS) - /* must be done after codegen_finish() */ - - if (opt_stat) - size_stub_native += code->mcodelength; -#endif - -#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) - /* disassemble native stub */ - - if (opt_DisassembleStubs) { -# if defined(ENABLE_DEBUG_FILTER) - if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD) -# endif - { - codegen_disassemble_stub(m, - (u1 *) (ptrint) code->entrypoint, - (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen)); - - /* show data segment */ - - if (opt_showddatasegment) - dseg_display(jd); - } - } -#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */ - - /* release memory */ - - DRELEASE; - - /* return native stub code */ - - return code; -} - - -/* codegen_disassemble_nativestub ********************************************** - - Disassembles the generated builtin or native stub. - -*******************************************************************************/ - -#if defined(ENABLE_DISASSEMBLER) -void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end) -{ - printf("Stub code: "); - if (m->clazz != NULL) - utf_fprint_printable_ascii_classname(stdout, m->clazz->name); - else - printf("NULL"); - printf("."); - utf_fprint_printable_ascii(stdout, m->name); - utf_fprint_printable_ascii(stdout, m->descriptor); - printf("\nLength: %d\n\n", (s4) (end - start)); - - DISASSEMBLE(start, end); -} -#endif - - -/* codegen_start_native_call *************************************************** - - Prepares the stuff required for a native (JNI) function call: - - - adds a stackframe info structure to the chain, for stacktraces - - prepares the local references table on the stack - - The layout of the native stub stackframe should look like this: - - +---------------------------+ <- java SP (of parent Java function) - | return address | - +---------------------------+ <- data SP - | | - | stackframe info structure | - | | - +---------------------------+ - | | - | local references table | - | | - +---------------------------+ - | | - | saved registers (if any) | - | | - +---------------------------+ - | | - | arguments (if any) | - | | - +---------------------------+ <- current SP (native stub) - -*******************************************************************************/ - -java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv) -{ - stackframeinfo_t *sfi; - localref_table *lrt; - methodinfo *m; - int32_t framesize; - - uint8_t *datasp; - uint8_t *javasp; - uint64_t *arg_regs; - uint64_t *arg_stack; - - STATISTICS(count_calls_java_to_native++); - - /* Get the methodinfo. */ - - m = code_get_methodinfo_for_pv(pv); - - assert(m); - - framesize = *((int32_t *) (pv + FrameSize)); - - assert(framesize >= sizeof(stackframeinfo_t) + sizeof(localref_table)); - - /* calculate needed values */ - -#if defined(__ALPHA__) || defined(__ARM__) - datasp = sp + framesize - SIZEOF_VOID_P; - javasp = sp + framesize; - arg_regs = (uint64_t *) sp; - arg_stack = (uint64_t *) javasp; -#elif defined(__MIPS__) - /* MIPS always uses 8 bytes to store the RA */ - datasp = sp + framesize - 8; - javasp = sp + framesize; -#elif defined(__S390__) - datasp = sp + framesize - 8; - javasp = sp + framesize; - arg_regs = (uint64_t *) (sp + 96); - arg_stack = (uint64_t *) javasp; -#elif defined(__I386__) || defined(__M68K__) || defined(__X86_64__) - datasp = sp + framesize; - javasp = sp + framesize + SIZEOF_VOID_P; - arg_regs = (uint64_t *) sp; - arg_stack = (uint64_t *) javasp; -#elif defined(__POWERPC__) - datasp = sp + framesize; - javasp = sp + framesize; - arg_regs = (uint64_t *) (sp + LA_SIZE + 4 * SIZEOF_VOID_P); - arg_stack = (uint64_t *) javasp; -#elif defined(__POWERPC64__) - datasp = sp + framesize; - javasp = sp + framesize; - arg_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 4 * SIZEOF_VOID_P); - arg_stack = (uint64_t *) javasp; -#else - /* XXX is was unable to do this port for SPARC64, sorry. (-michi) */ - /* XXX maybe we need to pass the RA as argument there */ - vm_abort("codegen_start_native_call: unsupported architecture"); -#endif - - /* get data structures from stack */ - - sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t)); - lrt = (localref_table *) (datasp - sizeof(stackframeinfo_t) - - sizeof(localref_table)); - -#if defined(ENABLE_JNI) - /* add current JNI local references table to this thread */ - - localref_table_add(lrt); -#endif - -#if !defined(NDEBUG) -# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) - /* print the call-trace if necesarry */ - /* BEFORE: filling the local reference table */ - - if (opt_TraceJavaCalls) - trace_java_call_enter(m, arg_regs, arg_stack); -# endif -#endif - -#if defined(ENABLE_HANDLES) - /* place all references into the local reference table */ - /* BEFORE: creating stackframeinfo */ - - localref_native_enter(m, arg_regs, arg_stack); -#endif - - /* Add a stackframeinfo for this native method. We don't have RA - and XPC here. These are determined in - stacktrace_stackframeinfo_add. */ - - stacktrace_stackframeinfo_add(sfi, pv, sp, NULL, NULL); - - /* Return a wrapped classinfo for static methods. */ - - if (m->flags & ACC_STATIC) - return (java_handle_t *) LLNI_classinfo_wrap(m->clazz); - else - return NULL; -} - - -/* codegen_finish_native_call ************************************************** - - Removes the stuff required for a native (JNI) function call. - Additionally it checks for an exceptions and in case, get the - exception object and clear the pointer. - -*******************************************************************************/ - -java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv) -{ - stackframeinfo_t *sfi; - java_handle_t *e; - java_object_t *o; - codeinfo *code; - methodinfo *m; - int32_t framesize; - - uint8_t *datasp; - uint64_t *ret_regs; - - /* get information from method header */ - - code = code_get_codeinfo_for_pv(pv); - - framesize = *((int32_t *) (pv + FrameSize)); - - assert(code); - - /* get the methodinfo */ - - m = code->m; - assert(m); - - /* calculate needed values */ - -#if defined(__ALPHA__) || defined(__ARM__) - datasp = sp + framesize - SIZEOF_VOID_P; - ret_regs = (uint64_t *) sp; -#elif defined(__MIPS__) - /* MIPS always uses 8 bytes to store the RA */ - datasp = sp + framesize - 8; -#elif defined(__S390__) - datasp = sp + framesize - 8; - ret_regs = (uint64_t *) (sp + 96); -#elif defined(__I386__) - datasp = sp + framesize; - ret_regs = (uint64_t *) (sp + 2 * SIZEOF_VOID_P); -#elif defined(__M68K__) - datasp = sp + framesize; - ret_regs = (uint64_t *) (sp + 2 * 8); -#elif defined(__X86_64__) - datasp = sp + framesize; - ret_regs = (uint64_t *) sp; -#elif defined(__POWERPC__) - datasp = sp + framesize; - ret_regs = (uint64_t *) (sp + LA_SIZE + 2 * SIZEOF_VOID_P); -#elif defined(__POWERPC64__) - datasp = sp + framesize; - ret_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 2 * SIZEOF_VOID_P); -#else - vm_abort("codegen_finish_native_call: unsupported architecture"); -#endif - - /* get data structures from stack */ - - sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t)); - - /* Remove current stackframeinfo from chain. */ - - stacktrace_stackframeinfo_remove(sfi); - -#if defined(ENABLE_HANDLES) - /* unwrap the return value from the local reference table */ - /* AFTER: removing the stackframeinfo */ - /* BEFORE: releasing the local reference table */ - - localref_native_exit(m, ret_regs); -#endif - - /* get and unwrap the exception */ - /* AFTER: removing the stackframe info */ - /* BEFORE: releasing the local reference table */ - - e = exceptions_get_and_clear_exception(); - o = LLNI_UNWRAP(e); - -#if defined(ENABLE_JNI) - /* release JNI local references table for this thread */ - - localref_frame_pop_all(); - localref_table_remove(); -#endif - -#if !defined(NDEBUG) -# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) - /* print the call-trace if necesarry */ - /* AFTER: unwrapping the return value */ - - if (opt_TraceJavaCalls) - trace_java_call_exit(m, ret_regs); -# endif -#endif - - return o; -} - - -/* removecompilerstub ********************************************************** - - Deletes a compilerstub from memory (simply by freeing it). - -*******************************************************************************/ - -void removecompilerstub(u1 *stub) -{ - /* pass size 1 to keep the intern function happy */ - - CFREE((void *) stub, 1); -} - - -/* removenativestub ************************************************************ - - Removes a previously created native-stub from memory. - -*******************************************************************************/ - -void removenativestub(u1 *stub) -{ - /* pass size 1 to keep the intern function happy */ - - CFREE((void *) stub, 1); -} - - -/* codegen_reg_of_var ********************************************************** - - This function determines a register, to which the result of an - operation should go, when it is ultimatively intended to store the - result in pseudoregister v. If v is assigned to an actual - register, this register will be returned. Otherwise (when v is - spilled) this function returns tempregnum. If not already done, - regoff and flags are set in the stack location. - -*******************************************************************************/ - -s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum) -{ - if (!(v->flags & INMEMORY)) - return v->vv.regoff; - - return tempregnum; -} - - -/* codegen_reg_of_dst ********************************************************** - - This function determines a register, to which the result of an - operation should go, when it is ultimatively intended to store the - result in iptr->dst.var. If dst.var is assigned to an actual - register, this register will be returned. Otherwise (when it is - spilled) this function returns tempregnum. If not already done, - regoff and flags are set in the stack location. - -*******************************************************************************/ - -s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum) -{ - return codegen_reg_of_var(iptr->opc, VAROP(iptr->dst), tempregnum); -} - - -/* codegen_emit_phi_moves **************************************************** - - Emits phi moves at the end of the basicblock. - -*******************************************************************************/ - -#if defined(ENABLE_SSA) -void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr) -{ - int lt_d,lt_s,i; - lsradata *ls; - codegendata *cd; - varinfo *s, *d; - instruction tmp_i; - - cd = jd->cd; - ls = jd->ls; - - MCODECHECK(512); - - /* Moves from phi functions with highest indices have to be */ - /* inserted first, since this is the order as is used for */ - /* conflict resolution */ - - for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) { - lt_d = ls->phi_moves[bptr->nr][i][0]; - lt_s = ls->phi_moves[bptr->nr][i][1]; -#if defined(SSA_DEBUG_VERBOSE) - if (compileverbose) - printf("BB %3i Move %3i <- %3i ", bptr->nr, lt_d, lt_s); -#endif - if (lt_s == UNUSED) { -#if defined(SSA_DEBUG_VERBOSE) - if (compileverbose) - printf(" ... not processed \n"); -#endif - continue; - } - - d = VAR(ls->lifetime[lt_d].v_index); - s = VAR(ls->lifetime[lt_s].v_index); - - - if (d->type == -1) { -#if defined(SSA_DEBUG_VERBOSE) - if (compileverbose) - printf("...returning - phi lifetimes where joined\n"); -#endif - continue; - } - - if (s->type == -1) { -#if defined(SSA_DEBUG_VERBOSE) - if (compileverbose) - printf("...returning - phi lifetimes where joined\n"); -#endif - continue; - } - - tmp_i.opc = 0; - tmp_i.s1.varindex = ls->lifetime[lt_s].v_index; - tmp_i.dst.varindex = ls->lifetime[lt_d].v_index; - emit_copy(jd, &tmp_i); - -#if defined(SSA_DEBUG_VERBOSE) - if (compileverbose) { - if (IS_INMEMORY(d->flags) && IS_INMEMORY(s->flags)) { - /* mem -> mem */ - printf("M%3i <- M%3i",d->vv.regoff,s->vv.regoff); - } - else if (IS_INMEMORY(s->flags)) { - /* mem -> reg */ - printf("R%3i <- M%3i",d->vv.regoff,s->vv.regoff); - } - else if (IS_INMEMORY(d->flags)) { - /* reg -> mem */ - printf("M%3i <- R%3i",d->vv.regoff,s->vv.regoff); - } - else { - /* reg -> reg */ - printf("R%3i <- R%3i",d->vv.regoff,s->vv.regoff); - } - printf("\n"); - } -#endif /* defined(SSA_DEBUG_VERBOSE) */ - } -} -#endif /* defined(ENABLE_SSA) */ - - -/* REMOVEME When we have exception handling in C. */ - -void *md_asm_codegen_get_pv_from_pc(void *ra) -{ - return md_codegen_get_pv_from_pc(ra); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/codegen-common.cpp b/src/vm/jit/codegen-common.cpp new file mode 100644 index 000000000..0efaad8af --- /dev/null +++ b/src/vm/jit/codegen-common.cpp @@ -0,0 +1,1085 @@ +/* src/vm/jit/codegen-common.cpp - architecture independent code generator stuff + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + All functions assume the following code area / data area layout: + + +-----------+ + | | + | code area | code area grows to higher addresses + | | + +-----------+ <-- start of procedure + | | + | data area | data area grows to lower addresses + | | + +-----------+ + + The functions first write into a temporary code/data area allocated by + "codegen_init". "codegen_finish" copies the code and data area into permanent + memory. All functions writing values into the data area return the offset + relative the begin of the code area (start of procedure). + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "codegen.h" +#include "md.h" +#include "md-abi.h" + +#include "mm/memory.h" + +#include "toolbox/avl.h" +#include "toolbox/list.h" +#include "toolbox/logging.h" + +#include "native/llni.h" +#include "native/localref.h" +#include "native/native.h" + +#include "threads/thread.hpp" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/string.hpp" + +# include "vm/statistics.h" + + +#include "vm/jit/abi.h" +#include "vm/jit/asmpart.h" +#include "vm/jit/code.hpp" +#include "vm/jit/codegen-common.hpp" + +#if defined(ENABLE_DISASSEMBLER) +# include "vm/jit/disass.h" +#endif + +#include "vm/jit/dseg.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/linenumbertable.h" +#include "vm/jit/methodheader.h" +#include "vm/jit/methodtree.h" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#if defined(ENABLE_SSA) +# include "vm/jit/optimizing/lsra.h" +# include "vm/jit/optimizing/ssa.h" +#endif +#include "vm/jit/stacktrace.hpp" +#include "vm/jit/trace.hpp" + +#if defined(ENABLE_INTRP) +#include "vm/jit/intrp/intrp.h" +#endif + +#if defined(ENABLE_VMLOG) +#include +#endif + +#include "show.h" + + +/* codegen_init **************************************************************** + + TODO + +*******************************************************************************/ + +void codegen_init(void) +{ +} + + +/* codegen_setup *************************************************************** + + Allocates and initialises code area, data area and references. + +*******************************************************************************/ + +void codegen_setup(jitdata *jd) +{ + methodinfo *m; + codegendata *cd; + + /* get required compiler data */ + + m = jd->m; + cd = jd->cd; + + /* initialize members */ + + cd->flags = 0; + + cd->mcodebase = (u1*) DumpMemory::allocate(MCODEINITSIZE); + cd->mcodeend = cd->mcodebase + MCODEINITSIZE; + cd->mcodesize = MCODEINITSIZE; + + /* initialize mcode variables */ + + cd->mcodeptr = cd->mcodebase; + cd->lastmcodeptr = cd->mcodebase; + +#if defined(ENABLE_INTRP) + /* native dynamic superinstructions variables */ + + if (opt_intrp) { + cd->ncodebase = (u1*) DumpMemory::allocate(NCODEINITSIZE); + cd->ncodesize = NCODEINITSIZE; + + /* initialize ncode variables */ + + cd->ncodeptr = cd->ncodebase; + + cd->lastinstwithoutdispatch = ~0; /* no inst without dispatch */ + cd->superstarts = NULL; + } +#endif + + cd->dseg = NULL; + cd->dseglen = 0; + + cd->jumpreferences = NULL; + +#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) + cd->datareferences = NULL; +#endif + + cd->brancheslabel = list_create_dump(OFFSET(branch_label_ref_t, linkage)); + cd->linenumbers = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage)); +} + + +/* codegen_reset *************************************************************** + + Resets the codegen data structure so we can recompile the method. + +*******************************************************************************/ + +static void codegen_reset(jitdata *jd) +{ + codeinfo *code; + codegendata *cd; + basicblock *bptr; + + /* get required compiler data */ + + code = jd->code; + cd = jd->cd; + + /* reset error flag */ + + cd->flags &= ~CODEGENDATA_FLAG_ERROR; + + /* reset some members, we reuse the code memory already allocated + as this should have almost the correct size */ + + cd->mcodeptr = cd->mcodebase; + cd->lastmcodeptr = cd->mcodebase; + + cd->dseg = NULL; + cd->dseglen = 0; + + cd->jumpreferences = NULL; + +#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) + cd->datareferences = NULL; +#endif + + cd->brancheslabel = list_create_dump(OFFSET(branch_label_ref_t, linkage)); + cd->linenumbers = list_create_dump(OFFSET(linenumbertable_list_entry_t, linkage)); + + /* We need to clear the mpc and the branch references from all + basic blocks as they will definitely change. */ + + for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) { + bptr->mpc = -1; + bptr->branchrefs = NULL; + } + + /* We need to clear all the patcher references from the codeinfo + since they all will be regenerated */ + + patcher_list_reset(code); + +#if defined(ENABLE_REPLACEMENT) + code->rplpoints = NULL; + code->rplpointcount = 0; + code->regalloc = NULL; + code->regalloccount = 0; + code->globalcount = 0; +#endif +} + + +/* codegen_generate ************************************************************ + + Generates the code for the currently compiled method. + +*******************************************************************************/ + +bool codegen_generate(jitdata *jd) +{ + codegendata *cd; + + /* get required compiler data */ + + cd = jd->cd; + + /* call the machine-dependent code generation function */ + + if (!codegen_emit(jd)) + return false; + + /* check for an error */ + + if (CODEGENDATA_HAS_FLAG_ERROR(cd)) { + /* check for long-branches flag, if it is set we recompile the + method */ + +#if !defined(NDEBUG) + if (compileverbose) + log_message_method("Re-generating code: ", jd->m); +#endif + + /* XXX maybe we should tag long-branches-methods for recompilation */ + + if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) { + /* we have to reset the codegendata structure first */ + + codegen_reset(jd); + + /* and restart the compiler run */ + + if (!codegen_emit(jd)) + return false; + } + else { + vm_abort("codegen_generate: unknown error occurred during codegen_emit: flags=%x\n", cd->flags); + } + +#if !defined(NDEBUG) + if (compileverbose) + log_message_method("Re-generating code done: ", jd->m); +#endif + } + + /* reallocate the memory and finish the code generation */ + + codegen_finish(jd); + + /* everything's ok */ + + return true; +} + + +/* codegen_close *************************************************************** + + TODO + +*******************************************************************************/ + +void codegen_close(void) +{ + /* TODO: release avl tree on i386 and x86_64 */ +} + + +/* codegen_increase ************************************************************ + + Doubles code area. + +*******************************************************************************/ + +void codegen_increase(codegendata *cd) +{ + u1 *oldmcodebase; + + /* save old mcodebase pointer */ + + oldmcodebase = cd->mcodebase; + + /* reallocate to new, doubled memory */ + + cd->mcodebase = (u1*) DumpMemory::reallocate(cd->mcodebase, + cd->mcodesize, + cd->mcodesize * 2); + cd->mcodesize *= 2; + cd->mcodeend = cd->mcodebase + cd->mcodesize; + + /* set new mcodeptr */ + + cd->mcodeptr = cd->mcodebase + (cd->mcodeptr - oldmcodebase); + +#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(__M68K__) || defined(ENABLE_INTRP) \ + || defined(__SPARC_64__) + /* adjust the pointer to the last patcher position */ + + if (cd->lastmcodeptr != NULL) + cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase); +#endif +} + + +/* codegen_ncode_increase ****************************************************** + + Doubles code area. + +*******************************************************************************/ + +#if defined(ENABLE_INTRP) +u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr) +{ + u1 *oldncodebase; + + /* save old ncodebase pointer */ + + oldncodebase = cd->ncodebase; + + /* reallocate to new, doubled memory */ + + cd->ncodebase = DMREALLOC(cd->ncodebase, + u1, + cd->ncodesize, + cd->ncodesize * 2); + cd->ncodesize *= 2; + + /* return the new ncodeptr */ + + return (cd->ncodebase + (ncodeptr - oldncodebase)); +} +#endif + + +/* codegen_add_branch_ref ****************************************************** + + Prepends an branch to the list. + +*******************************************************************************/ + +void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options) +{ + branchref *br; + s4 branchmpc; + + STATISTICS(count_branches_unresolved++); + + /* calculate the mpc of the branch instruction */ + + branchmpc = cd->mcodeptr - cd->mcodebase; + + br = (branchref*) DumpMemory::allocate(sizeof(branchref)); + + br->branchmpc = branchmpc; + br->condition = condition; + br->reg = reg; + br->options = options; + br->next = target->branchrefs; + + target->branchrefs = br; +} + + +/* codegen_resolve_branchrefs ************************************************** + + Resolves and patches the branch references of a given basic block. + +*******************************************************************************/ + +void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr) +{ + branchref *br; + u1 *mcodeptr; + + /* Save the mcodeptr because in the branch emitting functions + we generate code somewhere inside already generated code, + but we're still in the actual code generation phase. */ + + mcodeptr = cd->mcodeptr; + + /* just to make sure */ + + assert(bptr->mpc >= 0); + + for (br = bptr->branchrefs; br != NULL; br = br->next) { + /* temporary set the mcodeptr */ + + cd->mcodeptr = cd->mcodebase + br->branchmpc; + + /* emit_bccz and emit_branch emit the correct code, even if we + pass condition == BRANCH_UNCONDITIONAL or reg == -1. */ + + emit_bccz(cd, bptr, br->condition, br->reg, br->options); + } + + /* restore mcodeptr */ + + cd->mcodeptr = mcodeptr; +} + + +/* codegen_branch_label_add **************************************************** + + Append an branch to the label-branch list. + +*******************************************************************************/ + +void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options) +{ + list_t *l; + branch_label_ref_t *br; + s4 mpc; + + /* Get the label list. */ + + l = cd->brancheslabel; + + /* calculate the current mpc */ + + mpc = cd->mcodeptr - cd->mcodebase; + + br = (branch_label_ref_t*) DumpMemory::allocate(sizeof(branch_label_ref_t)); + + br->mpc = mpc; + br->label = label; + br->condition = condition; + br->reg = reg; + br->options = options; + + /* Add the branch to the list. */ + + list_add_last(l, br); +} + + +/* codegen_set_replacement_point_notrap **************************************** + + Record the position of a non-trappable replacement point. + +*******************************************************************************/ + +#if defined(ENABLE_REPLACEMENT) +#if !defined(NDEBUG) +void codegen_set_replacement_point_notrap(codegendata *cd, s4 type) +#else +void codegen_set_replacement_point_notrap(codegendata *cd) +#endif +{ + assert(cd->replacementpoint); + assert(cd->replacementpoint->type == type); + assert(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP); + + cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase); + + cd->replacementpoint++; +} +#endif /* defined(ENABLE_REPLACEMENT) */ + + +/* codegen_set_replacement_point *********************************************** + + Record the position of a trappable replacement point. + +*******************************************************************************/ + +#if defined(ENABLE_REPLACEMENT) +#if !defined(NDEBUG) +void codegen_set_replacement_point(codegendata *cd, s4 type) +#else +void codegen_set_replacement_point(codegendata *cd) +#endif +{ + assert(cd->replacementpoint); + assert(cd->replacementpoint->type == type); + assert(!(cd->replacementpoint->flags & RPLPOINT_FLAG_NOTRAP)); + + cd->replacementpoint->pc = (u1*) (ptrint) (cd->mcodeptr - cd->mcodebase); + + cd->replacementpoint++; + +#if !defined(NDEBUG) + /* XXX actually we should use an own REPLACEMENT_NOPS here! */ + if (opt_TestReplacement) + PATCHER_NOPS; +#endif + + /* XXX assert(cd->lastmcodeptr <= cd->mcodeptr); */ + + cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE; +} +#endif /* defined(ENABLE_REPLACEMENT) */ + + +/* codegen_finish ************************************************************** + + Finishes the code generation. A new memory, large enough for both + data and code, is allocated and data and code are copied together + to their final layout, unresolved jumps are resolved, ... + +*******************************************************************************/ + +void codegen_finish(jitdata *jd) +{ + codeinfo *code; + codegendata *cd; + s4 mcodelen; +#if defined(ENABLE_INTRP) + s4 ncodelen; +#endif + s4 alignedmcodelen; + jumpref *jr; + u1 *epoint; + s4 alignedlen; + + /* get required compiler data */ + + code = jd->code; + cd = jd->cd; + + /* prevent compiler warning */ + +#if defined(ENABLE_INTRP) + ncodelen = 0; +#endif + + /* calculate the code length */ + + mcodelen = (s4) (cd->mcodeptr - cd->mcodebase); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + count_code_len += mcodelen; + count_data_len += cd->dseglen; + } +#endif + + alignedmcodelen = MEMORY_ALIGN(mcodelen, MAX_ALIGN); + +#if defined(ENABLE_INTRP) + if (opt_intrp) + ncodelen = cd->ncodeptr - cd->ncodebase; + else { + ncodelen = 0; /* avoid compiler warning */ + } +#endif + + cd->dseglen = MEMORY_ALIGN(cd->dseglen, MAX_ALIGN); + alignedlen = alignedmcodelen + cd->dseglen; + +#if defined(ENABLE_INTRP) + if (opt_intrp) { + alignedlen += ncodelen; + } +#endif + + /* allocate new memory */ + + code->mcodelength = mcodelen + cd->dseglen; + code->mcode = CNEW(u1, alignedlen); + + /* set the entrypoint of the method */ + + assert(code->entrypoint == NULL); + code->entrypoint = epoint = (code->mcode + cd->dseglen); + + /* fill the data segment (code->entrypoint must already be set!) */ + + dseg_finish(jd); + + /* copy code to the new location */ + + MCOPY((void *) code->entrypoint, cd->mcodebase, u1, mcodelen); + +#if defined(ENABLE_INTRP) + /* relocate native dynamic superinstruction code (if any) */ + + if (opt_intrp) { + cd->mcodebase = code->entrypoint; + + if (ncodelen > 0) { + u1 *ncodebase = code->mcode + cd->dseglen + alignedmcodelen; + + MCOPY((void *) ncodebase, cd->ncodebase, u1, ncodelen); + + /* flush the instruction and data caches */ + + md_cacheflush(ncodebase, ncodelen); + + /* set some cd variables for dynamic_super_rerwite */ + + cd->ncodebase = ncodebase; + + } else { + cd->ncodebase = NULL; + } + + dynamic_super_rewrite(cd); + } +#endif + + /* Create the exception table. */ + + exceptiontable_create(jd); + + /* Create the linenumber table. */ + + linenumbertable_create(jd); + + /* jump table resolving */ + + for (jr = cd->jumpreferences; jr != NULL; jr = jr->next) + *((functionptr *) ((ptrint) epoint + jr->tablepos)) = + (functionptr) ((ptrint) epoint + (ptrint) jr->target->mpc); + + /* patcher resolving */ + + patcher_resolve(jd); + +#if defined(ENABLE_REPLACEMENT) + /* replacement point resolving */ + { + int i; + rplpoint *rp; + + rp = code->rplpoints; + for (i=0; irplpointcount; ++i, ++rp) { + rp->pc = (u1*) ((ptrint) epoint + (ptrint) rp->pc); + } + } +#endif /* defined(ENABLE_REPLACEMENT) */ + + /* Insert method into methodtree to find the entrypoint. */ + + methodtree_insert(code->entrypoint, code->entrypoint + mcodelen); + +#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) + /* resolve data segment references */ + + dseg_resolve_datareferences(jd); +#endif + + /* flush the instruction and data caches */ + + md_cacheflush(code->mcode, code->mcodelength); +} + + +/* codegen_start_native_call *************************************************** + + Prepares the stuff required for a native (JNI) function call: + + - adds a stackframe info structure to the chain, for stacktraces + - prepares the local references table on the stack + + The layout of the native stub stackframe should look like this: + + +---------------------------+ <- java SP (of parent Java function) + | return address | + +---------------------------+ <- data SP + | | + | stackframe info structure | + | | + +---------------------------+ + | | + | local references table | + | | + +---------------------------+ + | | + | saved registers (if any) | + | | + +---------------------------+ + | | + | arguments (if any) | + | | + +---------------------------+ <- current SP (native stub) + +*******************************************************************************/ + +java_handle_t *codegen_start_native_call(u1 *sp, u1 *pv) +{ + stackframeinfo_t *sfi; + localref_table *lrt; + methodinfo *m; + int32_t framesize; + + uint8_t *datasp; + uint8_t *javasp; + uint64_t *arg_regs; + uint64_t *arg_stack; + + STATISTICS(count_calls_java_to_native++); + + /* Get the methodinfo. */ + + m = code_get_methodinfo_for_pv(pv); + + assert(m); + + framesize = *((int32_t *) (pv + FrameSize)); + + assert(framesize >= (int32_t) (sizeof(stackframeinfo_t) + sizeof(localref_table))); + + /* calculate needed values */ + +#if defined(__ALPHA__) || defined(__ARM__) + datasp = sp + framesize - SIZEOF_VOID_P; + javasp = sp + framesize; + arg_regs = (uint64_t *) sp; + arg_stack = (uint64_t *) javasp; +#elif defined(__MIPS__) + /* MIPS always uses 8 bytes to store the RA */ + datasp = sp + framesize - 8; + javasp = sp + framesize; +#elif defined(__S390__) + datasp = sp + framesize - 8; + javasp = sp + framesize; + arg_regs = (uint64_t *) (sp + 96); + arg_stack = (uint64_t *) javasp; +#elif defined(__I386__) || defined(__M68K__) || defined(__X86_64__) + datasp = sp + framesize; + javasp = sp + framesize + SIZEOF_VOID_P; + arg_regs = (uint64_t *) sp; + arg_stack = (uint64_t *) javasp; +#elif defined(__POWERPC__) + datasp = sp + framesize; + javasp = sp + framesize; + arg_regs = (uint64_t *) (sp + LA_SIZE + 4 * SIZEOF_VOID_P); + arg_stack = (uint64_t *) javasp; +#elif defined(__POWERPC64__) + datasp = sp + framesize; + javasp = sp + framesize; + arg_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 4 * SIZEOF_VOID_P); + arg_stack = (uint64_t *) javasp; +#else + /* XXX is was unable to do this port for SPARC64, sorry. (-michi) */ + /* XXX maybe we need to pass the RA as argument there */ + vm_abort("codegen_start_native_call: unsupported architecture"); +#endif + + /* get data structures from stack */ + + sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t)); + lrt = (localref_table *) (datasp - sizeof(stackframeinfo_t) - + sizeof(localref_table)); + +#if defined(ENABLE_JNI) + /* add current JNI local references table to this thread */ + + localref_table_add(lrt); +#endif + +#if !defined(NDEBUG) +# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) + /* print the call-trace if necesarry */ + /* BEFORE: filling the local reference table */ + + if (opt_TraceJavaCalls) + trace_java_call_enter(m, arg_regs, arg_stack); +# endif +#endif + +#if defined(ENABLE_HANDLES) + /* place all references into the local reference table */ + /* BEFORE: creating stackframeinfo */ + + localref_native_enter(m, arg_regs, arg_stack); +#endif + + /* Add a stackframeinfo for this native method. We don't have RA + and XPC here. These are determined in + stacktrace_stackframeinfo_add. */ + + stacktrace_stackframeinfo_add(sfi, pv, sp, NULL, NULL); + + /* Return a wrapped classinfo for static methods. */ + + if (m->flags & ACC_STATIC) + return (java_handle_t *) LLNI_classinfo_wrap(m->clazz); + else + return NULL; +} + + +/* codegen_finish_native_call ************************************************** + + Removes the stuff required for a native (JNI) function call. + Additionally it checks for an exceptions and in case, get the + exception object and clear the pointer. + +*******************************************************************************/ + +java_object_t *codegen_finish_native_call(u1 *sp, u1 *pv) +{ + stackframeinfo_t *sfi; + java_handle_t *e; + java_object_t *o; + codeinfo *code; + methodinfo *m; + int32_t framesize; + + uint8_t *datasp; + uint64_t *ret_regs; + + /* get information from method header */ + + code = code_get_codeinfo_for_pv(pv); + + framesize = *((int32_t *) (pv + FrameSize)); + + assert(code); + + /* get the methodinfo */ + + m = code->m; + assert(m); + + /* calculate needed values */ + +#if defined(__ALPHA__) || defined(__ARM__) + datasp = sp + framesize - SIZEOF_VOID_P; + ret_regs = (uint64_t *) sp; +#elif defined(__MIPS__) + /* MIPS always uses 8 bytes to store the RA */ + datasp = sp + framesize - 8; +#elif defined(__S390__) + datasp = sp + framesize - 8; + ret_regs = (uint64_t *) (sp + 96); +#elif defined(__I386__) + datasp = sp + framesize; + ret_regs = (uint64_t *) (sp + 2 * SIZEOF_VOID_P); +#elif defined(__M68K__) + datasp = sp + framesize; + ret_regs = (uint64_t *) (sp + 2 * 8); +#elif defined(__X86_64__) + datasp = sp + framesize; + ret_regs = (uint64_t *) sp; +#elif defined(__POWERPC__) + datasp = sp + framesize; + ret_regs = (uint64_t *) (sp + LA_SIZE + 2 * SIZEOF_VOID_P); +#elif defined(__POWERPC64__) + datasp = sp + framesize; + ret_regs = (uint64_t *) (sp + PA_SIZE + LA_SIZE + 2 * SIZEOF_VOID_P); +#else + vm_abort("codegen_finish_native_call: unsupported architecture"); +#endif + + /* get data structures from stack */ + + sfi = (stackframeinfo_t *) (datasp - sizeof(stackframeinfo_t)); + + /* Remove current stackframeinfo from chain. */ + + stacktrace_stackframeinfo_remove(sfi); + +#if defined(ENABLE_HANDLES) + /* unwrap the return value from the local reference table */ + /* AFTER: removing the stackframeinfo */ + /* BEFORE: releasing the local reference table */ + + localref_native_exit(m, ret_regs); +#endif + + /* get and unwrap the exception */ + /* AFTER: removing the stackframe info */ + /* BEFORE: releasing the local reference table */ + + e = exceptions_get_and_clear_exception(); + o = LLNI_UNWRAP(e); + +#if defined(ENABLE_JNI) + /* release JNI local references table for this thread */ + + localref_frame_pop_all(); + localref_table_remove(); +#endif + +#if !defined(NDEBUG) +# if defined(__ALPHA__) || defined(__I386__) || defined(__M68K__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) + /* print the call-trace if necesarry */ + /* AFTER: unwrapping the return value */ + + if (opt_TraceJavaCalls) + trace_java_call_exit(m, ret_regs); +# endif +#endif + + return o; +} + + +/* codegen_reg_of_var ********************************************************** + + This function determines a register, to which the result of an + operation should go, when it is ultimatively intended to store the + result in pseudoregister v. If v is assigned to an actual + register, this register will be returned. Otherwise (when v is + spilled) this function returns tempregnum. If not already done, + regoff and flags are set in the stack location. + +*******************************************************************************/ + +s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum) +{ + if (!(v->flags & INMEMORY)) + return v->vv.regoff; + + return tempregnum; +} + + +/* codegen_reg_of_dst ********************************************************** + + This function determines a register, to which the result of an + operation should go, when it is ultimatively intended to store the + result in iptr->dst.var. If dst.var is assigned to an actual + register, this register will be returned. Otherwise (when it is + spilled) this function returns tempregnum. If not already done, + regoff and flags are set in the stack location. + +*******************************************************************************/ + +s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum) +{ + return codegen_reg_of_var(iptr->opc, VAROP(iptr->dst), tempregnum); +} + + +/* codegen_emit_phi_moves **************************************************** + + Emits phi moves at the end of the basicblock. + +*******************************************************************************/ + +#if defined(ENABLE_SSA) +void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr) +{ + int lt_d,lt_s,i; + lsradata *ls; + codegendata *cd; + varinfo *s, *d; + instruction tmp_i; + + cd = jd->cd; + ls = jd->ls; + + MCODECHECK(512); + + /* Moves from phi functions with highest indices have to be */ + /* inserted first, since this is the order as is used for */ + /* conflict resolution */ + + for(i = ls->num_phi_moves[bptr->nr] - 1; i >= 0 ; i--) { + lt_d = ls->phi_moves[bptr->nr][i][0]; + lt_s = ls->phi_moves[bptr->nr][i][1]; +#if defined(SSA_DEBUG_VERBOSE) + if (compileverbose) + printf("BB %3i Move %3i <- %3i ", bptr->nr, lt_d, lt_s); +#endif + if (lt_s == UNUSED) { +#if defined(SSA_DEBUG_VERBOSE) + if (compileverbose) + printf(" ... not processed \n"); +#endif + continue; + } + + d = VAR(ls->lifetime[lt_d].v_index); + s = VAR(ls->lifetime[lt_s].v_index); + + + if (d->type == -1) { +#if defined(SSA_DEBUG_VERBOSE) + if (compileverbose) + printf("...returning - phi lifetimes where joined\n"); +#endif + continue; + } + + if (s->type == -1) { +#if defined(SSA_DEBUG_VERBOSE) + if (compileverbose) + printf("...returning - phi lifetimes where joined\n"); +#endif + continue; + } + + tmp_i.opc = 0; + tmp_i.s1.varindex = ls->lifetime[lt_s].v_index; + tmp_i.dst.varindex = ls->lifetime[lt_d].v_index; + emit_copy(jd, &tmp_i); + +#if defined(SSA_DEBUG_VERBOSE) + if (compileverbose) { + if (IS_INMEMORY(d->flags) && IS_INMEMORY(s->flags)) { + /* mem -> mem */ + printf("M%3i <- M%3i",d->vv.regoff,s->vv.regoff); + } + else if (IS_INMEMORY(s->flags)) { + /* mem -> reg */ + printf("R%3i <- M%3i",d->vv.regoff,s->vv.regoff); + } + else if (IS_INMEMORY(d->flags)) { + /* reg -> mem */ + printf("M%3i <- R%3i",d->vv.regoff,s->vv.regoff); + } + else { + /* reg -> reg */ + printf("R%3i <- R%3i",d->vv.regoff,s->vv.regoff); + } + printf("\n"); + } +#endif /* defined(SSA_DEBUG_VERBOSE) */ + } +} +#endif /* defined(ENABLE_SSA) */ + + +/* REMOVEME When we have exception handling in C. */ + +void *md_asm_codegen_get_pv_from_pc(void *ra) +{ + return md_codegen_get_pv_from_pc(ra); +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/codegen-common.h b/src/vm/jit/codegen-common.h deleted file mode 100644 index cf1ad7d77..000000000 --- a/src/vm/jit/codegen-common.h +++ /dev/null @@ -1,327 +0,0 @@ -/* src/vm/jit/codegen-common.h - architecture independent code generator stuff - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _CODEGEN_COMMON_H -#define _CODEGEN_COMMON_H - -/* forward typedefs ***********************************************************/ - -typedef struct codegendata codegendata; -typedef struct branchref branchref; -typedef struct branch_label_ref_t branch_label_ref_t; -typedef struct critical_section_ref_t critical_section_ref_t; -typedef struct jumpref jumpref; -typedef struct dataref dataref; -typedef struct exceptionref exceptionref; -typedef struct linenumberref linenumberref; - - -#include "config.h" -#include "vm/types.h" - -#include "vm/builtin.h" -#include "vm/global.h" - -#include "vm/jit/dseg.h" -#include "vm/jit/jit.h" -#include "vm/jit/reg.h" -#include "vm/jit/code.h" -#include "vm/jit/replace.h" - -#include "vmcore/descriptor.h" -#include "vmcore/method.h" -#include "vmcore/references.h" - - -#define MCODEINITSIZE (1<<15) /* 32 Kbyte code area initialization size */ -#define DSEGINITSIZE (1<<12) /* 4 Kbyte data area initialization size */ - -#define NCODEINITSIZE (1<<15) /* 32 Kbyte code area initialization size */ - - -/* Register Pack/Unpack Macros ************************************************/ - -/* ATTENTION: Don't change the order where low and high bits are - stored! At least mips32 relies in one case on that order. */ - -#define PACK_REGS(low,high) \ - ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) ) - -#define GET_LOW_REG(a) ((a) & 0x0000ffff) -#define GET_HIGH_REG(a) (((a) & 0xffff0000) >> 16) - - -/* branch conditions **********************************************************/ - -#define BRANCH_UNCONDITIONAL -1 - -#define BRANCH_EQ (ICMD_IFEQ - ICMD_IFEQ) -#define BRANCH_NE (ICMD_IFNE - ICMD_IFEQ) -#define BRANCH_LT (ICMD_IFLT - ICMD_IFEQ) -#define BRANCH_GE (ICMD_IFGE - ICMD_IFEQ) -#define BRANCH_GT (ICMD_IFGT - ICMD_IFEQ) -#define BRANCH_LE (ICMD_IFLE - ICMD_IFEQ) - -#define BRANCH_ULT 256 -#define BRANCH_ULE 257 -#define BRANCH_UGE 258 -#define BRANCH_UGT 259 - -#define BRANCH_NAN 260 - - -/* common branch options ******************************************************/ - -#define BRANCH_OPT_NONE 0 - - -/* codegendata ****************************************************************/ - -struct codegendata { - u4 flags; /* code generator flags */ - u1 *mcodebase; /* base pointer of code area */ - u1 *mcodeend; /* pointer to end of code area */ - s4 mcodesize; /* complete size of code area (bytes) */ - u1 *mcodeptr; /* code generation pointer */ - u1 *lastmcodeptr; /* last patcher position of basic block */ - -#if defined(ENABLE_INTRP) - u1 *ncodebase; /* base pointer of native code area */ - s4 ncodesize; /* complete size of native code area */ - u1 *ncodeptr; /* native code generation pointer */ - - u4 lastinstwithoutdispatch; /* ~0 if there was a dispatch */ - - s4 lastpatcheroffset; /* -1 if current super has no patcher */ - s4 dynsuperm; /* offsets of start of current dynamic ...*/ - s4 dynsupern; /* ... superinstruction starts */ - struct superstart *superstarts; /* list of supers without patchers */ -#endif - - dsegentry *dseg; /* chain of data segment entries */ - s4 dseglen; /* used size of data area (bytes) */ - /* data area grows from top to bottom */ - - jumpref *jumpreferences; /* list of jumptable target addresses */ - -#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) || defined(__S390__) - dataref *datareferences; /* list of data segment references */ -#endif - - list_t *brancheslabel; - list_t *listcritical; /* list of critical sections */ - list_t *linenumbers; /* list of line numbers */ - - methodinfo *method; - - s4 stackframesize; /* stackframe size of this method */ - -#if defined(ENABLE_REPLACEMENT) - rplpoint *replacementpoint; /* current replacement point */ -#endif -}; - - -#define CODEGENDATA_FLAG_ERROR 0x00000001 -#define CODEGENDATA_FLAG_LONGBRANCHES 0x00000002 - - -#define CODEGENDATA_HAS_FLAG_ERROR(cd) \ - ((cd)->flags & CODEGENDATA_FLAG_ERROR) - -#define CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) \ - ((cd)->flags & CODEGENDATA_FLAG_LONGBRANCHES) - - -/* branchref *****************************************************************/ - -struct branchref { - s4 branchmpc; /* patching position in code segment */ - s4 condition; /* conditional branch condition */ - s4 reg; /* register number to check */ - u4 options; /* branch options */ - branchref *next; /* next element in branchref list */ -}; - - -/* branch_label_ref_t *********************************************************/ - -struct branch_label_ref_t { - s4 mpc; /* position in code segment */ - s4 label; /* label number */ - s4 condition; /* conditional branch condition */ - s4 reg; /* register number to check */ - u4 options; /* branch options */ - listnode_t linkage; -}; - - -/* critical_section_ref_t *****************************************************/ - -struct critical_section_ref_t { - s4 start; /* relative offset to method entry-point */ - s4 end; - s4 restart; - listnode_t linkage; -}; - - -/* jumpref ********************************************************************/ - -struct jumpref { - s4 tablepos; /* patching position in data segment */ - basicblock *target; /* target basic block */ - jumpref *next; /* next element in jumpref list */ -}; - - -/* dataref ********************************************************************/ - -struct dataref { - s4 datapos; /* patching position in generated code */ - dataref *next; /* next element in dataref list */ -}; - - -/* linenumberref **************************************************************/ - -struct linenumberref { - s4 tablepos; /* patching position in data segment */ - s4 linenumber; /* line number, used for inserting into the */ - /* table and for validity checking */ - /* -1......start of inlined body */ - /* -2......end of inlined body */ - /* <= -3...special entry with methodinfo * */ - /* (see doc/inlining_stacktrace.txt) */ - ptrint targetmpc; /* machine code program counter of first */ - /* instruction for given line */ - /* NOTE: for linenumber <= -3 this is a the */ - /* (methodinfo *) of the inlined method */ - linenumberref *next; /* next element in linenumberref list */ -}; - - -/* function prototypes ********************************************************/ - -void codegen_init(void); -void codegen_setup(jitdata *jd); - -bool codegen_generate(jitdata *jd); -bool codegen_emit(jitdata *jd); - -#if defined(ENABLE_INTRP) -bool intrp_codegen(jitdata *jd); -#endif - -void codegen_close(void); - -void codegen_increase(codegendata *cd); - -#if defined(ENABLE_INTRP) -u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr); -#endif - -void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options); -void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr); - -void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options); - -#if defined(ENABLE_REPLACEMENT) -#if !defined(NDEBUG) -void codegen_set_replacement_point_notrap(codegendata *cd, s4 type); -void codegen_set_replacement_point(codegendata *cd, s4 type); -#else -void codegen_set_replacement_point_notrap(codegendata *cd); -void codegen_set_replacement_point(codegendata *cd); -#endif -#endif /* defined(ENABLE_REPLACEMENT) */ - -void codegen_finish(jitdata *jd); - -#if defined(ENABLE_DISASSEMBLER) -void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end); -#endif - -/* stub functions */ - -u1 *codegen_generate_stub_compiler(methodinfo *m); -void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte); -codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f); - -#if !defined(JIT_COMPILER_VIA_SIGNAL) -void codegen_emit_stub_compiler(jitdata *jd); -#endif -void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams); - -#if defined(ENABLE_INTRP) -u1 *intrp_createcompilerstub(methodinfo *m); -u1 *intrp_createnativestub(functionptr f, jitdata *jd, methoddesc *md); -#endif - -void removecompilerstub(u1 *stub); -void removenativestub(u1 *stub); - -java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv); -java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv); - -s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum); -s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum); - -#if defined(ENABLE_THREADS) -void codegen_critical_section_new(codegendata *cd); -void codegen_critical_section_start(codegendata *cd); -void codegen_critical_section_end(codegendata *cd); - -# define CODEGEN_CRITICAL_SECTION_NEW codegen_critical_section_new(cd) -# define CODEGEN_CRITICAL_SECTION_START codegen_critical_section_start(cd) -# define CODEGEN_CRITICAL_SECTION_END codegen_critical_section_end(cd) -#else -# define CODEGEN_CRITICAL_SECTION_NEW /* no-op */ -# define CODEGEN_CRITICAL_SECTION_START /* no-op */ -# define CODEGEN_CRITICAL_SECTION_END /* no-op */ -#endif - -#if defined(ENABLE_SSA) -void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr); -#endif - -#endif /* _CODEGEN_COMMON_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/codegen-common.hpp b/src/vm/jit/codegen-common.hpp new file mode 100644 index 000000000..a9b3bd43b --- /dev/null +++ b/src/vm/jit/codegen-common.hpp @@ -0,0 +1,287 @@ +/* src/vm/jit/codegen-common.h - architecture independent code generator stuff + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _CODEGEN_COMMON_HPP +#define _CODEGEN_COMMON_HPP + +/* forward typedefs ***********************************************************/ + +typedef struct codegendata codegendata; +typedef struct branchref branchref; +typedef struct branch_label_ref_t branch_label_ref_t; +typedef struct jumpref jumpref; +typedef struct dataref dataref; +typedef struct exceptionref exceptionref; +typedef struct linenumberref linenumberref; + + +#include "config.h" +#include "vm/types.h" + +#include "vm/jit/builtin.hpp" +#include "vm/descriptor.h" +#include "vm/global.h" +#include "vm/method.h" +#include "vm/references.h" + +#include "vm/jit/dseg.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/reg.h" +#include "vm/jit/code.hpp" +#include "vm/jit/replace.hpp" + + +#define MCODEINITSIZE (1<<15) /* 32 Kbyte code area initialization size */ +#define DSEGINITSIZE (1<<12) /* 4 Kbyte data area initialization size */ + +#define NCODEINITSIZE (1<<15) /* 32 Kbyte code area initialization size */ + + +/* Register Pack/Unpack Macros ************************************************/ + +/* ATTENTION: Don't change the order where low and high bits are + stored! At least mips32 relies in one case on that order. */ + +#define PACK_REGS(low,high) \ + ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) ) + +#define GET_LOW_REG(a) ((a) & 0x0000ffff) +#define GET_HIGH_REG(a) (((a) & 0xffff0000) >> 16) + + +/* branch conditions **********************************************************/ + +#define BRANCH_UNCONDITIONAL -1 + +#define BRANCH_EQ (ICMD_IFEQ - ICMD_IFEQ) +#define BRANCH_NE (ICMD_IFNE - ICMD_IFEQ) +#define BRANCH_LT (ICMD_IFLT - ICMD_IFEQ) +#define BRANCH_GE (ICMD_IFGE - ICMD_IFEQ) +#define BRANCH_GT (ICMD_IFGT - ICMD_IFEQ) +#define BRANCH_LE (ICMD_IFLE - ICMD_IFEQ) + +#define BRANCH_ULT 256 +#define BRANCH_ULE 257 +#define BRANCH_UGE 258 +#define BRANCH_UGT 259 + +#define BRANCH_NAN 260 + + +/* common branch options ******************************************************/ + +#define BRANCH_OPT_NONE 0 + + +/* codegendata ****************************************************************/ + +struct codegendata { + u4 flags; /* code generator flags */ + u1 *mcodebase; /* base pointer of code area */ + u1 *mcodeend; /* pointer to end of code area */ + s4 mcodesize; /* complete size of code area (bytes) */ + u1 *mcodeptr; /* code generation pointer */ + u1 *lastmcodeptr; /* last patcher position of basic block */ + +#if defined(ENABLE_INTRP) + u1 *ncodebase; /* base pointer of native code area */ + s4 ncodesize; /* complete size of native code area */ + u1 *ncodeptr; /* native code generation pointer */ + + u4 lastinstwithoutdispatch; /* ~0 if there was a dispatch */ + + s4 lastpatcheroffset; /* -1 if current super has no patcher */ + s4 dynsuperm; /* offsets of start of current dynamic ...*/ + s4 dynsupern; /* ... superinstruction starts */ + struct superstart *superstarts; /* list of supers without patchers */ +#endif + + dsegentry *dseg; /* chain of data segment entries */ + s4 dseglen; /* used size of data area (bytes) */ + /* data area grows from top to bottom */ + + jumpref *jumpreferences; /* list of jumptable target addresses */ + +#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP) || defined(__S390__) + dataref *datareferences; /* list of data segment references */ +#endif + + list_t *brancheslabel; + list_t *linenumbers; /* list of line numbers */ + + methodinfo *method; + + s4 stackframesize; /* stackframe size of this method */ + +#if defined(ENABLE_REPLACEMENT) + rplpoint *replacementpoint; /* current replacement point */ +#endif +}; + + +#define CODEGENDATA_FLAG_ERROR 0x00000001 +#define CODEGENDATA_FLAG_LONGBRANCHES 0x00000002 + + +#define CODEGENDATA_HAS_FLAG_ERROR(cd) \ + ((cd)->flags & CODEGENDATA_FLAG_ERROR) + +#define CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) \ + ((cd)->flags & CODEGENDATA_FLAG_LONGBRANCHES) + + +/* branchref *****************************************************************/ + +struct branchref { + s4 branchmpc; /* patching position in code segment */ + s4 condition; /* conditional branch condition */ + s4 reg; /* register number to check */ + u4 options; /* branch options */ + branchref *next; /* next element in branchref list */ +}; + + +/* branch_label_ref_t *********************************************************/ + +struct branch_label_ref_t { + s4 mpc; /* position in code segment */ + s4 label; /* label number */ + s4 condition; /* conditional branch condition */ + s4 reg; /* register number to check */ + u4 options; /* branch options */ + listnode_t linkage; +}; + + +/* jumpref ********************************************************************/ + +struct jumpref { + s4 tablepos; /* patching position in data segment */ + basicblock *target; /* target basic block */ + jumpref *next; /* next element in jumpref list */ +}; + + +/* dataref ********************************************************************/ + +struct dataref { + s4 datapos; /* patching position in generated code */ + dataref *next; /* next element in dataref list */ +}; + + +/* linenumberref **************************************************************/ + +struct linenumberref { + s4 tablepos; /* patching position in data segment */ + s4 linenumber; /* line number, used for inserting into the */ + /* table and for validity checking */ + /* -1......start of inlined body */ + /* -2......end of inlined body */ + /* <= -3...special entry with methodinfo * */ + /* (see doc/inlining_stacktrace.txt) */ + ptrint targetmpc; /* machine code program counter of first */ + /* instruction for given line */ + /* NOTE: for linenumber <= -3 this is a the */ + /* (methodinfo *) of the inlined method */ + linenumberref *next; /* next element in linenumberref list */ +}; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +void codegen_init(void); +void codegen_setup(jitdata *jd); + +bool codegen_generate(jitdata *jd); +bool codegen_emit(jitdata *jd); + +#if defined(ENABLE_INTRP) +bool intrp_codegen(jitdata *jd); +#endif + +void codegen_close(void); + +void codegen_increase(codegendata *cd); + +#if defined(ENABLE_INTRP) +u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr); +#endif + +void codegen_add_branch_ref(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options); +void codegen_resolve_branchrefs(codegendata *cd, basicblock *bptr); + +void codegen_branch_label_add(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options); + +#if defined(ENABLE_REPLACEMENT) +#if !defined(NDEBUG) +void codegen_set_replacement_point_notrap(codegendata *cd, s4 type); +void codegen_set_replacement_point(codegendata *cd, s4 type); +#else +void codegen_set_replacement_point_notrap(codegendata *cd); +void codegen_set_replacement_point(codegendata *cd); +#endif +#endif /* defined(ENABLE_REPLACEMENT) */ + +void codegen_finish(jitdata *jd); + +java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv); +java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv); + +s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum); +s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum); + +#if defined(ENABLE_SSA) +void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr); +#endif + +// REMOVEME +void codegen_emit_stub_compiler(jitdata *jd); +void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams); + +#ifdef __cplusplus +} +#endif + +#endif // _CODEGEN_COMMON_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/disass.h b/src/vm/jit/disass.h index 3b2280a9f..39bb0d23c 100644 --- a/src/vm/jit/disass.h +++ b/src/vm/jit/disass.h @@ -1,9 +1,7 @@ /* src/vm/jit/disass.h - disassembler header - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -96,6 +94,10 @@ extern s4 disass_len; /* function prototypes *******************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + #if defined(ENABLE_JIT) void disassemble(u1 *start, u1 *end); #endif @@ -119,7 +121,11 @@ void intrp_disassemble(u1 *start, u1 *end); #endif /* defined(ENABLE_DISASSEMBLER) */ -#endif /* _DISASS_H */ +#ifdef __cplusplus +} +#endif + +#endif // _DISASS_H /* diff --git a/src/vm/jit/dseg.c b/src/vm/jit/dseg.c index 7d80a965f..b66da4bd4 100644 --- a/src/vm/jit/dseg.c +++ b/src/vm/jit/dseg.c @@ -1,9 +1,7 @@ /* src/vm/jit/dseg.c - data segment handling stuff - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,10 +31,10 @@ #include "mm/memory.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/methodheader.h" +#include "vm/options.h" -#include "vmcore/options.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/methodheader.h" /* dseg_finish ***************************************************************** diff --git a/src/vm/jit/dseg.h b/src/vm/jit/dseg.h index 68c1564ae..d2a097c37 100644 --- a/src/vm/jit/dseg.h +++ b/src/vm/jit/dseg.h @@ -1,9 +1,7 @@ /* src/vm/jit/dseg.c - data segment handling stuff - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -38,10 +36,10 @@ typedef struct dsegentry dsegentry; #include "toolbox/list.h" -#include "vm/jit/jit.h" -#include "vm/jit/codegen-common.h" +#include "vm/references.h" -#include "vmcore/references.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/codegen-common.hpp" /* convenience macros *********************************************************/ @@ -66,6 +64,10 @@ struct dsegentry { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + void dseg_finish(jitdata *jd); s4 dseg_add_unique_s4(codegendata *cd, s4 value); @@ -92,6 +94,10 @@ void dseg_resolve_datareferences(jitdata *jd); void dseg_display(jitdata *jd); #endif +#ifdef __cplusplus +} +#endif + #endif /* _DSEG_H */ diff --git a/src/vm/jit/emit-common.c b/src/vm/jit/emit-common.c deleted file mode 100644 index 6acf886db..000000000 --- a/src/vm/jit/emit-common.c +++ /dev/null @@ -1,736 +0,0 @@ -/* src/vm/jit/emit-common.c - common code emitter functions - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "arch.h" -#include "codegen.h" - -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" - -#include "vmcore/options.h" -#include "vmcore/statistics.h" - - -/* emit_load_s1 **************************************************************** - - Emits a possible load of the first source operand. - -*******************************************************************************/ - -s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->s1); - - reg = emit_load(jd, iptr, src, tempreg); - - return reg; -} - - -/* emit_load_s2 **************************************************************** - - Emits a possible load of the second source operand. - -*******************************************************************************/ - -s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->sx.s23.s2); - - reg = emit_load(jd, iptr, src, tempreg); - - return reg; -} - - -/* emit_load_s3 **************************************************************** - - Emits a possible load of the third source operand. - -*******************************************************************************/ - -s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->sx.s23.s3); - - reg = emit_load(jd, iptr, src, tempreg); - - return reg; -} - - -/* emit_load_s1_low ************************************************************ - - Emits a possible load of the low 32-bits of the first long source - operand. - -*******************************************************************************/ - -#if SIZEOF_VOID_P == 4 -s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->s1); - - reg = emit_load_low(jd, iptr, src, tempreg); - - return reg; -} -#endif - - -/* emit_load_s2_low ************************************************************ - - Emits a possible load of the low 32-bits of the second long source - operand. - -*******************************************************************************/ - -#if SIZEOF_VOID_P == 4 -s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->sx.s23.s2); - - reg = emit_load_low(jd, iptr, src, tempreg); - - return reg; -} -#endif - - -/* emit_load_s3_low ************************************************************ - - Emits a possible load of the low 32-bits of the third long source - operand. - -*******************************************************************************/ - -#if SIZEOF_VOID_P == 4 -s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->sx.s23.s3); - - reg = emit_load_low(jd, iptr, src, tempreg); - - return reg; -} -#endif - - -/* emit_load_s1_high *********************************************************** - - Emits a possible load of the high 32-bits of the first long source - operand. - -*******************************************************************************/ - -#if SIZEOF_VOID_P == 4 -s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->s1); - - reg = emit_load_high(jd, iptr, src, tempreg); - - return reg; -} -#endif - - -/* emit_load_s2_high *********************************************************** - - Emits a possible load of the high 32-bits of the second long source - operand. - -*******************************************************************************/ - -#if SIZEOF_VOID_P == 4 -s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->sx.s23.s2); - - reg = emit_load_high(jd, iptr, src, tempreg); - - return reg; -} -#endif - - -/* emit_load_s3_high *********************************************************** - - Emits a possible load of the high 32-bits of the third long source - operand. - -*******************************************************************************/ - -#if SIZEOF_VOID_P == 4 -s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg) -{ - varinfo *src; - s4 reg; - - src = VAROP(iptr->sx.s23.s3); - - reg = emit_load_high(jd, iptr, src, tempreg); - - return reg; -} -#endif - - -/* emit_store_dst ************************************************************** - - This function generates the code to store the result of an - operation back into a spilled pseudo-variable. If the - pseudo-variable has not been spilled in the first place, this - function will generate nothing. - -*******************************************************************************/ - -void emit_store_dst(jitdata *jd, instruction *iptr, s4 d) -{ - emit_store(jd, iptr, VAROP(iptr->dst), d); -} - - -/* emit_patcher_traps ********************************************************** - - Generates the code for the patcher traps. - -*******************************************************************************/ - -void emit_patcher_traps(jitdata *jd) -{ - codegendata *cd; - codeinfo *code; - patchref_t *pr; - u1 *savedmcodeptr; - u1 *tmpmcodeptr; - uint32_t mcode; - - /* get required compiler data */ - - cd = jd->cd; - code = jd->code; - - /* generate patcher traps code */ - - for (pr = list_first(code->patchers); pr != NULL; pr = list_next(code->patchers, pr)) { - - /* Calculate the patch position where the original machine - code is located and the trap should be placed. */ - - tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc); - - /* Patch in the trap to call the signal handler (done at - compile time). */ - - savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ - cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ - - mcode = emit_trap(cd); - - cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ - - /* Remember the original machine code which is patched - back in later (done at runtime). */ - - pr->mcode = mcode; - } -} - - -/* emit_bccz ******************************************************************* - - Emit conditional and unconditional branch instructions on integer - regiseters. - -*******************************************************************************/ - -void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options) -{ - s4 branchmpc; - s4 disp; - - /* Target basic block already has an PC, so we can generate the - branch immediately. */ - - if ((target->mpc >= 0)) { - STATISTICS(count_branches_resolved++); - - /* calculate the mpc of the branch instruction */ - - branchmpc = cd->mcodeptr - cd->mcodebase; - disp = target->mpc - branchmpc; - -#if defined(ENABLE_STATISTICS) - count_emit_branch++; - if ((int8_t)disp == disp) count_emit_branch_8bit++; - else if ((int16_t)disp == disp) count_emit_branch_16bit++; - else if ((int32_t)disp == disp) count_emit_branch_32bit++; -# if SIZEOF_VOID_P == 8 - else if ((int64_t)disp == disp) count_emit_branch_64bit++; -# endif -#endif - - emit_branch(cd, disp, condition, reg, options); - } - else { - /* current mcodeptr is the correct position, - afterwards emit the NOPs */ - - codegen_add_branch_ref(cd, target, condition, reg, options); - - /* generate NOPs as placeholder for branch code */ - - BRANCH_NOPS; - } -} - - -/* emit_bcc ******************************************************************** - - Emit conditional and unconditional branch instructions on condition - codes. - -*******************************************************************************/ - -void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options) -{ - emit_bccz(cd, target, condition, -1, options); -} - - -/* emit_br ********************************************************************* - - Wrapper for unconditional branches. - -*******************************************************************************/ - -void emit_br(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE); -} - - -/* emit_bxxz ******************************************************************* - - Wrappers for branches on one integer register. - -*******************************************************************************/ - -#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER - -void emit_beqz(codegendata *cd, basicblock *target, s4 reg) -{ - emit_bccz(cd, target, BRANCH_EQ, reg, BRANCH_OPT_NONE); -} - -void emit_bnez(codegendata *cd, basicblock *target, s4 reg) -{ - emit_bccz(cd, target, BRANCH_NE, reg, BRANCH_OPT_NONE); -} - -void emit_bltz(codegendata *cd, basicblock *target, s4 reg) -{ - emit_bccz(cd, target, BRANCH_LT, reg, BRANCH_OPT_NONE); -} - -void emit_bgez(codegendata *cd, basicblock *target, s4 reg) -{ - emit_bccz(cd, target, BRANCH_GE, reg, BRANCH_OPT_NONE); -} - -void emit_bgtz(codegendata *cd, basicblock *target, s4 reg) -{ - emit_bccz(cd, target, BRANCH_GT, reg, BRANCH_OPT_NONE); -} - -void emit_blez(codegendata *cd, basicblock *target, s4 reg) -{ - emit_bccz(cd, target, BRANCH_LE, reg, BRANCH_OPT_NONE); -} - -#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */ - - -/* emit_bxx ******************************************************************** - - Wrappers for branches on two integer registers. - - We use PACK_REGS here, so we don't have to change the branchref - data structure and the emit_bccz function. - -*******************************************************************************/ - -#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS - -void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2) -{ - emit_bccz(cd, target, BRANCH_EQ, PACK_REGS(s1, s2), BRANCH_OPT_NONE); -} - -void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2) -{ - emit_bccz(cd, target, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE); -} - -#endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */ - - -/* emit_bxx ******************************************************************** - - Wrappers for branches on condition codes. - -*******************************************************************************/ - -#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER - -void emit_beq(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_EQ, BRANCH_OPT_NONE); -} - -void emit_bne(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_NE, BRANCH_OPT_NONE); -} - -void emit_blt(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_LT, BRANCH_OPT_NONE); -} - -void emit_bge(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_GE, BRANCH_OPT_NONE); -} - -void emit_bgt(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_GT, BRANCH_OPT_NONE); -} - -void emit_ble(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_LE, BRANCH_OPT_NONE); -} - -#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS -void emit_bult(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_ULT, BRANCH_OPT_NONE); -} - -void emit_bule(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_ULE, BRANCH_OPT_NONE); -} - -void emit_buge(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_UGE, BRANCH_OPT_NONE); -} - -void emit_bugt(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_UGT, BRANCH_OPT_NONE); -} -#endif - -#if defined(__POWERPC__) || defined(__POWERPC64__) -void emit_bnan(codegendata *cd, basicblock *target) -{ - emit_bcc(cd, target, BRANCH_NAN, BRANCH_OPT_NONE); -} -#endif - -#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */ - - -/* emit_label_bccz ************************************************************* - - Emit a branch to a label. Possibly emit the branch, if it is a - backward branch. - -*******************************************************************************/ - -void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options) -{ - list_t *list; - branch_label_ref_t *br; - s4 mpc; - s4 disp; - - /* get the label list */ - - list = cd->brancheslabel; - - /* search if the label is already in the list */ - - for (br = list_first(list); br != NULL; br = list_next(list, br)) { - /* is this entry the correct label? */ - - if (br->label == label) - break; - } - - if (br == NULL) { - /* current mcodeptr is the correct position, - afterwards emit the NOPs */ - - codegen_branch_label_add(cd, label, condition, reg, options); - - /* generate NOPs as placeholder for branch code */ - - BRANCH_NOPS; - return; - } - - /* Branch reference was found. */ - - /* calculate the mpc of the branch instruction */ - - mpc = cd->mcodeptr - cd->mcodebase; - disp = br->mpc - mpc; - -#if defined(ENABLE_STATISTICS) - count_emit_branch++; - if ((int8_t)disp == disp) count_emit_branch_8bit++; - else if ((int16_t)disp == disp) count_emit_branch_16bit++; - else if ((int32_t)disp == disp) count_emit_branch_32bit++; -# if SIZEOF_VOID_P == 8 - else if ((int64_t)disp == disp) count_emit_branch_64bit++; -# endif -#endif - - emit_branch(cd, disp, condition, reg, options); - - /* now remove the branch reference */ - - list_remove(list, br); -} - - -/* emit_label ****************************************************************** - - Emit a label for a branch. Possibly emit the branch, if it is a - forward branch. - -*******************************************************************************/ - -void emit_label(codegendata *cd, s4 label) -{ - list_t *list; - branch_label_ref_t *br; - s4 mpc; - s4 disp; - u1 *mcodeptr; - - /* get the label list */ - - list = cd->brancheslabel; - - /* search if the label is already in the list */ - - for (br = list_first(list); br != NULL; br = list_next(list, br)) { - /* is this entry the correct label? */ - - if (br->label == label) - break; - } - - if (br == NULL) { - /* No branch reference found, add the label to the list (use - invalid values for condition and register). */ - - codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE ); - return; - } - - /* Branch reference was found. */ - - /* calculate the mpc of the branch instruction */ - - mpc = cd->mcodeptr - cd->mcodebase; - disp = mpc - br->mpc; - - /* temporary set the mcodeptr */ - - mcodeptr = cd->mcodeptr; - cd->mcodeptr = cd->mcodebase + br->mpc; - -#if defined(ENABLE_STATISTICS) - count_emit_branch++; - if ((int8_t)disp == disp) count_emit_branch_8bit++; - else if ((int16_t)disp == disp) count_emit_branch_16bit++; - else if ((int32_t)disp == disp) count_emit_branch_32bit++; -# if SIZEOF_VOID_P == 8 - else if ((int64_t)disp == disp) count_emit_branch_64bit++; -# endif -#endif - - emit_branch(cd, disp, br->condition, br->reg, br->options); - - /* restore mcodeptr */ - - cd->mcodeptr = mcodeptr; - - /* now remove the branch reference */ - - list_remove(list, br); -} - - -/* emit_label_bcc ************************************************************** - - Emit conditional and unconditional label-branch instructions on - condition codes. - -*******************************************************************************/ - -void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options) -{ - emit_label_bccz(cd, label, condition, -1, options); -} - - -/* emit_label_br *************************************************************** - - Wrapper for unconditional label-branches. - -*******************************************************************************/ - -void emit_label_br(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE); -} - - -/* emit_label_bxxz ************************************************************* - - Wrappers for label-branches on one integer register. - -*******************************************************************************/ - -#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER - -void emit_label_beqz(codegendata *cd, s4 label, s4 reg) -{ - emit_label_bccz(cd, label, BRANCH_EQ, reg, BRANCH_OPT_NONE); -} - -void emit_label_bnez(codegendata *cd, s4 label, s4 reg) -{ - emit_label_bccz(cd, label, BRANCH_NE, reg, BRANCH_OPT_NONE); -} - -#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */ - - -/* emit_label_bxx ************************************************************** - - Wrappers for label-branches on condition codes. - -*******************************************************************************/ - -#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER - -void emit_label_beq(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_EQ, BRANCH_OPT_NONE); -} - -void emit_label_bne(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_NE, BRANCH_OPT_NONE); -} - -void emit_label_blt(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_LT, BRANCH_OPT_NONE); -} - -void emit_label_bge(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_GE, BRANCH_OPT_NONE); -} - -void emit_label_bgt(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_GT, BRANCH_OPT_NONE); -} - -void emit_label_ble(codegendata *cd, s4 label) -{ - emit_label_bcc(cd, label, BRANCH_LE, BRANCH_OPT_NONE); -} - -#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/emit-common.cpp b/src/vm/jit/emit-common.cpp new file mode 100644 index 000000000..f6cb5d5ac --- /dev/null +++ b/src/vm/jit/emit-common.cpp @@ -0,0 +1,736 @@ +/* src/vm/jit/emit-common.cpp - common code emitter functions + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "arch.h" +#include "codegen.h" + +#include "vm/options.h" +#include "vm/statistics.h" + +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" + + +/* emit_load_s1 **************************************************************** + + Emits a possible load of the first source operand. + +*******************************************************************************/ + +s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->s1); + + reg = emit_load(jd, iptr, src, tempreg); + + return reg; +} + + +/* emit_load_s2 **************************************************************** + + Emits a possible load of the second source operand. + +*******************************************************************************/ + +s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->sx.s23.s2); + + reg = emit_load(jd, iptr, src, tempreg); + + return reg; +} + + +/* emit_load_s3 **************************************************************** + + Emits a possible load of the third source operand. + +*******************************************************************************/ + +s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->sx.s23.s3); + + reg = emit_load(jd, iptr, src, tempreg); + + return reg; +} + + +/* emit_load_s1_low ************************************************************ + + Emits a possible load of the low 32-bits of the first long source + operand. + +*******************************************************************************/ + +#if SIZEOF_VOID_P == 4 +s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->s1); + + reg = emit_load_low(jd, iptr, src, tempreg); + + return reg; +} +#endif + + +/* emit_load_s2_low ************************************************************ + + Emits a possible load of the low 32-bits of the second long source + operand. + +*******************************************************************************/ + +#if SIZEOF_VOID_P == 4 +s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->sx.s23.s2); + + reg = emit_load_low(jd, iptr, src, tempreg); + + return reg; +} +#endif + + +/* emit_load_s3_low ************************************************************ + + Emits a possible load of the low 32-bits of the third long source + operand. + +*******************************************************************************/ + +#if SIZEOF_VOID_P == 4 +s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->sx.s23.s3); + + reg = emit_load_low(jd, iptr, src, tempreg); + + return reg; +} +#endif + + +/* emit_load_s1_high *********************************************************** + + Emits a possible load of the high 32-bits of the first long source + operand. + +*******************************************************************************/ + +#if SIZEOF_VOID_P == 4 +s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->s1); + + reg = emit_load_high(jd, iptr, src, tempreg); + + return reg; +} +#endif + + +/* emit_load_s2_high *********************************************************** + + Emits a possible load of the high 32-bits of the second long source + operand. + +*******************************************************************************/ + +#if SIZEOF_VOID_P == 4 +s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->sx.s23.s2); + + reg = emit_load_high(jd, iptr, src, tempreg); + + return reg; +} +#endif + + +/* emit_load_s3_high *********************************************************** + + Emits a possible load of the high 32-bits of the third long source + operand. + +*******************************************************************************/ + +#if SIZEOF_VOID_P == 4 +s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg) +{ + varinfo *src; + s4 reg; + + src = VAROP(iptr->sx.s23.s3); + + reg = emit_load_high(jd, iptr, src, tempreg); + + return reg; +} +#endif + + +/* emit_store_dst ************************************************************** + + This function generates the code to store the result of an + operation back into a spilled pseudo-variable. If the + pseudo-variable has not been spilled in the first place, this + function will generate nothing. + +*******************************************************************************/ + +void emit_store_dst(jitdata *jd, instruction *iptr, s4 d) +{ + emit_store(jd, iptr, VAROP(iptr->dst), d); +} + + +/* emit_patcher_traps ********************************************************** + + Generates the code for the patcher traps. + +*******************************************************************************/ + +void emit_patcher_traps(jitdata *jd) +{ + codegendata *cd; + codeinfo *code; + patchref_t *pr; + u1 *savedmcodeptr; + u1 *tmpmcodeptr; + uint32_t mcode; + + /* get required compiler data */ + + cd = jd->cd; + code = jd->code; + + /* generate patcher traps code */ + + for (pr = (patchref_t*) list_first(code->patchers); pr != NULL; pr = (patchref_t*) list_next(code->patchers, pr)) { + + /* Calculate the patch position where the original machine + code is located and the trap should be placed. */ + + tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc); + + /* Patch in the trap to call the signal handler (done at + compile time). */ + + savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */ + cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */ + + mcode = emit_trap(cd); + + cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */ + + /* Remember the original machine code which is patched + back in later (done at runtime). */ + + pr->mcode = mcode; + } +} + + +/* emit_bccz ******************************************************************* + + Emit conditional and unconditional branch instructions on integer + regiseters. + +*******************************************************************************/ + +void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options) +{ + s4 branchmpc; + s4 disp; + + /* Target basic block already has an PC, so we can generate the + branch immediately. */ + + if ((target->mpc >= 0)) { + STATISTICS(count_branches_resolved++); + + /* calculate the mpc of the branch instruction */ + + branchmpc = cd->mcodeptr - cd->mcodebase; + disp = target->mpc - branchmpc; + +#if defined(ENABLE_STATISTICS) + count_emit_branch++; + if ((int8_t)disp == disp) count_emit_branch_8bit++; + else if ((int16_t)disp == disp) count_emit_branch_16bit++; + else if ((int32_t)disp == disp) count_emit_branch_32bit++; +# if SIZEOF_VOID_P == 8 + else if ((int64_t)disp == disp) count_emit_branch_64bit++; +# endif +#endif + + emit_branch(cd, disp, condition, reg, options); + } + else { + /* current mcodeptr is the correct position, + afterwards emit the NOPs */ + + codegen_add_branch_ref(cd, target, condition, reg, options); + + /* generate NOPs as placeholder for branch code */ + + BRANCH_NOPS; + } +} + + +/* emit_bcc ******************************************************************** + + Emit conditional and unconditional branch instructions on condition + codes. + +*******************************************************************************/ + +void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options) +{ + emit_bccz(cd, target, condition, -1, options); +} + + +/* emit_br ********************************************************************* + + Wrapper for unconditional branches. + +*******************************************************************************/ + +void emit_br(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE); +} + + +/* emit_bxxz ******************************************************************* + + Wrappers for branches on one integer register. + +*******************************************************************************/ + +#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER + +void emit_beqz(codegendata *cd, basicblock *target, s4 reg) +{ + emit_bccz(cd, target, BRANCH_EQ, reg, BRANCH_OPT_NONE); +} + +void emit_bnez(codegendata *cd, basicblock *target, s4 reg) +{ + emit_bccz(cd, target, BRANCH_NE, reg, BRANCH_OPT_NONE); +} + +void emit_bltz(codegendata *cd, basicblock *target, s4 reg) +{ + emit_bccz(cd, target, BRANCH_LT, reg, BRANCH_OPT_NONE); +} + +void emit_bgez(codegendata *cd, basicblock *target, s4 reg) +{ + emit_bccz(cd, target, BRANCH_GE, reg, BRANCH_OPT_NONE); +} + +void emit_bgtz(codegendata *cd, basicblock *target, s4 reg) +{ + emit_bccz(cd, target, BRANCH_GT, reg, BRANCH_OPT_NONE); +} + +void emit_blez(codegendata *cd, basicblock *target, s4 reg) +{ + emit_bccz(cd, target, BRANCH_LE, reg, BRANCH_OPT_NONE); +} + +#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */ + + +/* emit_bxx ******************************************************************** + + Wrappers for branches on two integer registers. + + We use PACK_REGS here, so we don't have to change the branchref + data structure and the emit_bccz function. + +*******************************************************************************/ + +#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS + +void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2) +{ + emit_bccz(cd, target, BRANCH_EQ, PACK_REGS(s1, s2), BRANCH_OPT_NONE); +} + +void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2) +{ + emit_bccz(cd, target, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE); +} + +#endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */ + + +/* emit_bxx ******************************************************************** + + Wrappers for branches on condition codes. + +*******************************************************************************/ + +#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER + +void emit_beq(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_EQ, BRANCH_OPT_NONE); +} + +void emit_bne(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_NE, BRANCH_OPT_NONE); +} + +void emit_blt(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_LT, BRANCH_OPT_NONE); +} + +void emit_bge(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_GE, BRANCH_OPT_NONE); +} + +void emit_bgt(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_GT, BRANCH_OPT_NONE); +} + +void emit_ble(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_LE, BRANCH_OPT_NONE); +} + +#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS +void emit_bult(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_ULT, BRANCH_OPT_NONE); +} + +void emit_bule(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_ULE, BRANCH_OPT_NONE); +} + +void emit_buge(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_UGE, BRANCH_OPT_NONE); +} + +void emit_bugt(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_UGT, BRANCH_OPT_NONE); +} +#endif + +#if defined(__POWERPC__) || defined(__POWERPC64__) +void emit_bnan(codegendata *cd, basicblock *target) +{ + emit_bcc(cd, target, BRANCH_NAN, BRANCH_OPT_NONE); +} +#endif + +#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */ + + +/* emit_label_bccz ************************************************************* + + Emit a branch to a label. Possibly emit the branch, if it is a + backward branch. + +*******************************************************************************/ + +void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options) +{ + list_t *list; + branch_label_ref_t *br; + s4 mpc; + s4 disp; + + /* get the label list */ + + list = cd->brancheslabel; + + /* search if the label is already in the list */ + + for (br = (branch_label_ref_t*) list_first(list); br != NULL; br = (branch_label_ref_t*) list_next(list, br)) { + /* is this entry the correct label? */ + + if (br->label == label) + break; + } + + if (br == NULL) { + /* current mcodeptr is the correct position, + afterwards emit the NOPs */ + + codegen_branch_label_add(cd, label, condition, reg, options); + + /* generate NOPs as placeholder for branch code */ + + BRANCH_NOPS; + return; + } + + /* Branch reference was found. */ + + /* calculate the mpc of the branch instruction */ + + mpc = cd->mcodeptr - cd->mcodebase; + disp = br->mpc - mpc; + +#if defined(ENABLE_STATISTICS) + count_emit_branch++; + if ((int8_t)disp == disp) count_emit_branch_8bit++; + else if ((int16_t)disp == disp) count_emit_branch_16bit++; + else if ((int32_t)disp == disp) count_emit_branch_32bit++; +# if SIZEOF_VOID_P == 8 + else if ((int64_t)disp == disp) count_emit_branch_64bit++; +# endif +#endif + + emit_branch(cd, disp, condition, reg, options); + + /* now remove the branch reference */ + + list_remove(list, br); +} + + +/* emit_label ****************************************************************** + + Emit a label for a branch. Possibly emit the branch, if it is a + forward branch. + +*******************************************************************************/ + +void emit_label(codegendata *cd, s4 label) +{ + list_t *list; + branch_label_ref_t *br; + s4 mpc; + s4 disp; + u1 *mcodeptr; + + /* get the label list */ + + list = cd->brancheslabel; + + /* search if the label is already in the list */ + + for (br = (branch_label_ref_t*) list_first(list); br != NULL; br = (branch_label_ref_t*) list_next(list, br)) { + /* is this entry the correct label? */ + + if (br->label == label) + break; + } + + if (br == NULL) { + /* No branch reference found, add the label to the list (use + invalid values for condition and register). */ + + codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE ); + return; + } + + /* Branch reference was found. */ + + /* calculate the mpc of the branch instruction */ + + mpc = cd->mcodeptr - cd->mcodebase; + disp = mpc - br->mpc; + + /* temporary set the mcodeptr */ + + mcodeptr = cd->mcodeptr; + cd->mcodeptr = cd->mcodebase + br->mpc; + +#if defined(ENABLE_STATISTICS) + count_emit_branch++; + if ((int8_t)disp == disp) count_emit_branch_8bit++; + else if ((int16_t)disp == disp) count_emit_branch_16bit++; + else if ((int32_t)disp == disp) count_emit_branch_32bit++; +# if SIZEOF_VOID_P == 8 + else if ((int64_t)disp == disp) count_emit_branch_64bit++; +# endif +#endif + + emit_branch(cd, disp, br->condition, br->reg, br->options); + + /* restore mcodeptr */ + + cd->mcodeptr = mcodeptr; + + /* now remove the branch reference */ + + list_remove(list, br); +} + + +/* emit_label_bcc ************************************************************** + + Emit conditional and unconditional label-branch instructions on + condition codes. + +*******************************************************************************/ + +void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options) +{ + emit_label_bccz(cd, label, condition, -1, options); +} + + +/* emit_label_br *************************************************************** + + Wrapper for unconditional label-branches. + +*******************************************************************************/ + +void emit_label_br(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE); +} + + +/* emit_label_bxxz ************************************************************* + + Wrappers for label-branches on one integer register. + +*******************************************************************************/ + +#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER + +void emit_label_beqz(codegendata *cd, s4 label, s4 reg) +{ + emit_label_bccz(cd, label, BRANCH_EQ, reg, BRANCH_OPT_NONE); +} + +void emit_label_bnez(codegendata *cd, s4 label, s4 reg) +{ + emit_label_bccz(cd, label, BRANCH_NE, reg, BRANCH_OPT_NONE); +} + +#endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */ + + +/* emit_label_bxx ************************************************************** + + Wrappers for label-branches on condition codes. + +*******************************************************************************/ + +#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER + +void emit_label_beq(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_EQ, BRANCH_OPT_NONE); +} + +void emit_label_bne(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_NE, BRANCH_OPT_NONE); +} + +void emit_label_blt(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_LT, BRANCH_OPT_NONE); +} + +void emit_label_bge(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_GE, BRANCH_OPT_NONE); +} + +void emit_label_bgt(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_GT, BRANCH_OPT_NONE); +} + +void emit_label_ble(codegendata *cd, s4 label) +{ + emit_label_bcc(cd, label, BRANCH_LE, BRANCH_OPT_NONE); +} + +#endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/emit-common.h b/src/vm/jit/emit-common.h deleted file mode 100644 index f99969ce2..000000000 --- a/src/vm/jit/emit-common.h +++ /dev/null @@ -1,208 +0,0 @@ -/* src/vm/jit/emit-common.h - common code emitter functions - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _EMIT_COMMON_H -#define _EMIT_COMMON_H - -#include "config.h" -#include "vm/types.h" - -#include "arch.h" - -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" - - -/* branch labels **************************************************************/ - -#define BRANCH_LABEL_1 1 -#define BRANCH_LABEL_2 2 -#define BRANCH_LABEL_3 3 -#define BRANCH_LABEL_4 4 -#define BRANCH_LABEL_5 5 -#define BRANCH_LABEL_6 6 -#define BRANCH_LABEL_7 7 -#define BRANCH_LABEL_8 8 -#define BRANCH_LABEL_9 9 -#define BRANCH_LABEL_10 10 - - -/* constant range macros ******************************************************/ - -#if SIZEOF_VOID_P == 8 - -# define IS_IMM8(c) \ - (((s8) (c) >= -128) && ((s8) (c) <= 127)) - -# define IS_IMM32(c) \ - (((s8) (c) >= (-2147483647-1)) && ((s8) (c) <= 2147483647)) - -#else - -# define IS_IMM8(c) \ - (((s4) (c) >= -128) && ((s4) (c) <= 127)) - -# define IS_IMM16(c) \ - (((s4) (c) >= -32768) && ((s4) (c) <= 32767)) - -#endif - - -/* code generation functions **************************************************/ - -s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg); -s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg); -s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg); -s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg); - -#if SIZEOF_VOID_P == 4 -s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg); -s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg); -s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg); -s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg); - -s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg); -s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg); -s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg); -s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg); -#endif - -void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d); -void emit_store_dst(jitdata *jd, instruction *iptr, s4 d); - -#if SIZEOF_VOID_P == 4 -void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d); -void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d); -#endif - -void emit_copy(jitdata *jd, instruction *iptr); - -void emit_iconst(codegendata *cd, s4 d, s4 value); -void emit_lconst(codegendata *cd, s4 d, s8 value); - -/* branch-emitting functions */ -void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options); -void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options); - -/* wrapper for unconditional branches */ -void emit_br(codegendata *cd, basicblock *target); - -/* wrappers for branches on one integer register */ - -#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER -void emit_beqz(codegendata *cd, basicblock *target, s4 reg); -void emit_bnez(codegendata *cd, basicblock *target, s4 reg); -void emit_bltz(codegendata *cd, basicblock *target, s4 reg); -void emit_bgez(codegendata *cd, basicblock *target, s4 reg); -void emit_bgtz(codegendata *cd, basicblock *target, s4 reg); -void emit_blez(codegendata *cd, basicblock *target, s4 reg); -#endif - -/* wrappers for branches on two integer registers */ - -#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS -void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2); -void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2); -#endif - -/* wrappers for branches on condition codes */ - -#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER -void emit_beq(codegendata *cd, basicblock *target); -void emit_bne(codegendata *cd, basicblock *target); -void emit_blt(codegendata *cd, basicblock *target); -void emit_bge(codegendata *cd, basicblock *target); -void emit_bgt(codegendata *cd, basicblock *target); -void emit_ble(codegendata *cd, basicblock *target); -#endif - -#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS -void emit_bult(codegendata *cd, basicblock *target); -void emit_bule(codegendata *cd, basicblock *target); -void emit_buge(codegendata *cd, basicblock *target); -void emit_bugt(codegendata *cd, basicblock *target); -#endif - -#if defined(__POWERPC__) || defined(__POWERPC64__) -void emit_bnan(codegendata *cd, basicblock *target); -#endif - -/* label-branches */ -void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options); -void emit_label(codegendata *cd, s4 label); -void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options); - -void emit_label_br(codegendata *cd, s4 label); - -#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER -void emit_label_beqz(codegendata *cd, s4 label, s4 reg); -void emit_label_bnez(codegendata *cd, s4 label, s4 reg); -#endif - -#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER -void emit_label_beq(codegendata *cd, s4 label); -void emit_label_bne(codegendata *cd, s4 label); -void emit_label_blt(codegendata *cd, s4 label); -void emit_label_bge(codegendata *cd, s4 label); -void emit_label_bgt(codegendata *cd, s4 label); -void emit_label_ble(codegendata *cd, s4 label); -#endif - -/* machine dependent branch-emitting function */ -void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 options); - -void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg); -void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2); -void emit_arraystore_check(codegendata *cd, instruction *iptr); -void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1); -void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg); -void emit_exception_check(codegendata *cd, instruction *iptr); - -void emit_trap_compiler(codegendata *cd); -uint32_t emit_trap(codegendata *cd); - -void emit_patcher_traps(jitdata *jd); - -void emit_verbosecall_enter(jitdata *jd); -void emit_verbosecall_exit(jitdata *jd); - -#endif /* _EMIT_COMMON_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/emit-common.hpp b/src/vm/jit/emit-common.hpp new file mode 100644 index 000000000..b96bc08ea --- /dev/null +++ b/src/vm/jit/emit-common.hpp @@ -0,0 +1,217 @@ +/* src/vm/jit/emit-common.hpp - common code emitter functions + + Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, + R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, + C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, + Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _EMIT_COMMON_H +#define _EMIT_COMMON_H + +#include "config.h" +#include "vm/types.h" + +#include "arch.h" + +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" + + +/* branch labels **************************************************************/ + +#define BRANCH_LABEL_1 1 +#define BRANCH_LABEL_2 2 +#define BRANCH_LABEL_3 3 +#define BRANCH_LABEL_4 4 +#define BRANCH_LABEL_5 5 +#define BRANCH_LABEL_6 6 +#define BRANCH_LABEL_7 7 +#define BRANCH_LABEL_8 8 +#define BRANCH_LABEL_9 9 +#define BRANCH_LABEL_10 10 + + +/* constant range macros ******************************************************/ + +#if SIZEOF_VOID_P == 8 + +# define IS_IMM8(c) \ + (((s8) (c) >= -128) && ((s8) (c) <= 127)) + +# define IS_IMM32(c) \ + (((s8) (c) >= (-2147483647-1)) && ((s8) (c) <= 2147483647)) + +#else + +# define IS_IMM8(c) \ + (((s4) (c) >= -128) && ((s4) (c) <= 127)) + +# define IS_IMM16(c) \ + (((s4) (c) >= -32768) && ((s4) (c) <= 32767)) + +#endif + + +/* code generation functions **************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg); +s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg); +s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg); +s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg); + +#if SIZEOF_VOID_P == 4 +s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg); +s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg); +s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg); +s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg); + +s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg); +s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg); +s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg); +s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg); +#endif + +void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d); +void emit_store_dst(jitdata *jd, instruction *iptr, s4 d); + +#if SIZEOF_VOID_P == 4 +void emit_store_low(jitdata *jd, instruction *iptr, varinfo *dst, s4 d); +void emit_store_high(jitdata *jd, instruction *iptr, varinfo *dst, s4 d); +#endif + +void emit_copy(jitdata *jd, instruction *iptr); + +void emit_iconst(codegendata *cd, s4 d, s4 value); +void emit_lconst(codegendata *cd, s4 d, s8 value); + +/* branch-emitting functions */ +void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options); +void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options); + +/* wrapper for unconditional branches */ +void emit_br(codegendata *cd, basicblock *target); + +/* wrappers for branches on one integer register */ + +#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER +void emit_beqz(codegendata *cd, basicblock *target, s4 reg); +void emit_bnez(codegendata *cd, basicblock *target, s4 reg); +void emit_bltz(codegendata *cd, basicblock *target, s4 reg); +void emit_bgez(codegendata *cd, basicblock *target, s4 reg); +void emit_bgtz(codegendata *cd, basicblock *target, s4 reg); +void emit_blez(codegendata *cd, basicblock *target, s4 reg); +#endif + +/* wrappers for branches on two integer registers */ + +#if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS +void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2); +void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2); +#endif + +/* wrappers for branches on condition codes */ + +#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER +void emit_beq(codegendata *cd, basicblock *target); +void emit_bne(codegendata *cd, basicblock *target); +void emit_blt(codegendata *cd, basicblock *target); +void emit_bge(codegendata *cd, basicblock *target); +void emit_bgt(codegendata *cd, basicblock *target); +void emit_ble(codegendata *cd, basicblock *target); +#endif + +#if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS +void emit_bult(codegendata *cd, basicblock *target); +void emit_bule(codegendata *cd, basicblock *target); +void emit_buge(codegendata *cd, basicblock *target); +void emit_bugt(codegendata *cd, basicblock *target); +#endif + +#if defined(__POWERPC__) || defined(__POWERPC64__) +void emit_bnan(codegendata *cd, basicblock *target); +#endif + +/* label-branches */ +void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options); +void emit_label(codegendata *cd, s4 label); +void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options); + +void emit_label_br(codegendata *cd, s4 label); + +#if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER +void emit_label_beqz(codegendata *cd, s4 label, s4 reg); +void emit_label_bnez(codegendata *cd, s4 label, s4 reg); +#endif + +#if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER +void emit_label_beq(codegendata *cd, s4 label); +void emit_label_bne(codegendata *cd, s4 label); +void emit_label_blt(codegendata *cd, s4 label); +void emit_label_bge(codegendata *cd, s4 label); +void emit_label_bgt(codegendata *cd, s4 label); +void emit_label_ble(codegendata *cd, s4 label); +#endif + +/* machine dependent branch-emitting function */ +void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 options); + +void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg); +void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2); +void emit_arraystore_check(codegendata *cd, instruction *iptr); +void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1); +void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg); +void emit_exception_check(codegendata *cd, instruction *iptr); + +void emit_trap_compiler(codegendata *cd); +void emit_trap_countdown(codegendata *cd, s4 *counter); +uint32_t emit_trap(codegendata *cd); + +void emit_patcher_traps(jitdata *jd); + +void emit_verbosecall_enter(jitdata *jd); +void emit_verbosecall_exit(jitdata *jd); + +#ifdef __cplusplus +} +#endif + +#endif /* _EMIT_COMMON_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/exceptiontable.c b/src/vm/jit/exceptiontable.c index 102f45514..9130543d2 100644 --- a/src/vm/jit/exceptiontable.c +++ b/src/vm/jit/exceptiontable.c @@ -30,9 +30,9 @@ #include "mm/memory.h" -#include "vm/jit/code.h" +#include "vm/jit/code.hpp" #include "vm/jit/exceptiontable.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* exceptiontable_create ******************************************************* diff --git a/src/vm/jit/exceptiontable.h b/src/vm/jit/exceptiontable.h index 903b250f2..d4733aefb 100644 --- a/src/vm/jit/exceptiontable.h +++ b/src/vm/jit/exceptiontable.h @@ -36,8 +36,8 @@ typedef struct exceptiontable_entry_t exceptiontable_entry_t; #include -#include "vm/jit/code.h" -#include "vm/jit/jit.h" +#include "vm/jit/code.hpp" +#include "vm/jit/jit.hpp" /* exceptiontable_t ***********************************************************/ @@ -60,6 +60,10 @@ struct exceptiontable_entry_t { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + void exceptiontable_create(jitdata *jd); void exceptiontable_free(codeinfo *code); @@ -67,6 +71,10 @@ void exceptiontable_free(codeinfo *code); void exceptiontable_print(codeinfo *code); #endif +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* _EXCEPTIONTABLE_H */ diff --git a/src/vm/jit/executionstate.c b/src/vm/jit/executionstate.c index 34153a630..722922ce4 100644 --- a/src/vm/jit/executionstate.c +++ b/src/vm/jit/executionstate.c @@ -30,12 +30,12 @@ #include "md-abi.h" +#include "vm/descriptor.h" +#include "vm/os.hpp" + #include "vm/jit/abi.h" #include "vm/jit/executionstate.h" -#include "vmcore/descriptor.h" -#include "vmcore/system.h" - /* executionstate_sanity_check ************************************************* @@ -66,13 +66,13 @@ void executionstate_sanity_check(void *context) /* keep a copy of (a prefix of) the context for reference */ - system_memcpy(&reference, context, MINIMUM_CONTEXT_SIZE); + os_memcpy(&reference, context, MINIMUM_CONTEXT_SIZE); /* different poisons */ - system_memset(&es1, 0xc9, sizeof(executionstate_t)); - system_memset(&es2, 0xb5, sizeof(executionstate_t)); - system_memset(&es3, 0x6f, sizeof(executionstate_t)); + os_memset(&es1, 0xc9, sizeof(executionstate_t)); + os_memset(&es2, 0xb5, sizeof(executionstate_t)); + os_memset(&es3, 0x6f, sizeof(executionstate_t)); md_executionstate_read(&es1, context); diff --git a/src/vm/jit/executionstate.h b/src/vm/jit/executionstate.h index 46211e722..59e14ea4b 100644 --- a/src/vm/jit/executionstate.h +++ b/src/vm/jit/executionstate.h @@ -38,7 +38,7 @@ typedef struct executionstate_t executionstate_t; #include "arch.h" #include "md-abi.h" -#include "vm/jit/code.h" +#include "vm/jit/code.hpp" /* executionstate_t ************************************************************ @@ -68,6 +68,10 @@ struct executionstate_t { /* prototypes *****************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + #if !defined(NDEBUG) void executionstate_sanity_check(void *context); void executionstate_println(executionstate_t *es); @@ -78,6 +82,10 @@ void executionstate_println(executionstate_t *es); void md_executionstate_read(executionstate_t *es, void *ucontext); void md_executionstate_write(executionstate_t *es, void *ucontext); +#ifdef __cplusplus +} +#endif + #endif /* _EXECUTIONSTATE_H */ diff --git a/src/vm/jit/i386/Makefile.am b/src/vm/jit/i386/Makefile.am index 0adf03128..044070caf 100644 --- a/src/vm/jit/i386/Makefile.am +++ b/src/vm/jit/i386/Makefile.am @@ -25,7 +25,8 @@ DIST_SUBDIRS = \ cygwin \ darwin \ freebsd \ - linux + linux \ + solaris SUBDIRS = $(OS_DIR) @@ -36,7 +37,7 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h + md-atomic.hpp noinst_LTLIBRARIES = \ libarch.la @@ -57,6 +58,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/i386/codegen.c b/src/vm/jit/i386/codegen.c index 707ccb226..a5f09828d 100644 --- a/src/vm/jit/i386/codegen.c +++ b/src/vm/jit/i386/codegen.c @@ -37,31 +37,33 @@ #include "vm/jit/i386/emit.h" #include "mm/memory.h" -#include "native/jni.h" + #include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" #if defined(ENABLE_SSA) @@ -71,10 +73,6 @@ # include "vm/jit/allocator/lsra.h" #endif -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/utf8.h" - /* codegen_emit **************************************************************** @@ -408,9 +406,7 @@ bool codegen_emit(jitdata *jd) if (bptr->bitflags & BBFLAG_REPLACEMENT) { if (cd->replacementpoint[-1].flags & RPLPOINT_FLAG_COUNTDOWN) { MCODECHECK(32); - disp = (s4) &(m->hitcountdown); - M_ISUB_IMM_MEMABS(1, disp); - M_BS(0); + emit_trap_countdown(cd, &(m->hitcountdown)); } } #endif @@ -2225,7 +2221,7 @@ bool codegen_emit(jitdata *jd) break; case ICMD_PUTSTATIC: /* ..., value ==> ... */ - + if (INSTRUCTION_IS_UNRESOLVED(iptr)) { uf = iptr->sx.s23.s3.uf; fieldtype = uf->fieldref->parseddesc.fd->type; @@ -2891,6 +2887,21 @@ nowperformreturn: bte = iptr->sx.s23.s3.bte; md = bte->md; + +#if defined(ENABLE_ESCAPE_REASON) + if (bte->fp == BUILTIN_escape_reason_new) { + void set_escape_reasons(void *); + M_ASUB_IMM(8, REG_SP); + M_MOV_IMM(iptr->escape_reasons, REG_ITMP1); + M_AST(EDX, REG_SP, 4); + M_AST(REG_ITMP1, REG_SP, 0); + M_MOV_IMM(set_escape_reasons, REG_ITMP1); + M_CALL(REG_ITMP1); + M_ALD(EDX, REG_SP, 4); + M_AADD_IMM(8, REG_SP); + } +#endif + goto gen_method; case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ... */ @@ -3658,7 +3669,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument */ - M_AST_IMM(_Jv_env, REG_SP, 0 * 4); + M_AST_IMM(VM_get_jnienv(), REG_SP, 0 * 4); } /* Call the native function. */ @@ -3674,7 +3685,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s switch (md->returntype.type) { case TYPE_INT: case TYPE_ADR: - switch (md->returntype.decltype) { + switch (md->returntype.primitivetype) { case PRIMITIVETYPE_BOOLEAN: M_BZEXT(REG_RESULT, REG_RESULT); break; diff --git a/src/vm/jit/i386/codegen.h b/src/vm/jit/i386/codegen.h index 6ee339cfd..ef28c2465 100644 --- a/src/vm/jit/i386/codegen.h +++ b/src/vm/jit/i386/codegen.h @@ -1,9 +1,7 @@ /* src/vm/jit/i386/codegen.h - code generation macros and definitions for i386 - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,7 +31,7 @@ #include "vm/jit/i386/emit.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #if defined(ENABLE_LSRA) @@ -157,11 +155,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 6 - - /* macros to create code ******************************************************/ #define M_BYTE1(a) \ diff --git a/src/vm/jit/i386/cygwin/md-os.c b/src/vm/jit/i386/cygwin/md-os.c index bd96c8bdd..e35e6f6a1 100644 --- a/src/vm/jit/i386/cygwin/md-os.c +++ b/src/vm/jit/i386/cygwin/md-os.c @@ -1,9 +1,7 @@ /* src/vm/jit/i386/cygwin/md-os.c - machine dependent i386 Windows functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Michael Starzinger - - Changes: - */ @@ -40,11 +32,8 @@ #include "vm/types.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" /* md_signal_handler_sigsegv *************************************************** @@ -73,14 +62,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) } -#if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *uc) -{ - assert(0); -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/i386/darwin/md-os.c b/src/vm/jit/i386/darwin/md-os.c index 9ad6dc681..89514f4b8 100644 --- a/src/vm/jit/i386/darwin/md-os.c +++ b/src/vm/jit/i386/darwin/md-os.c @@ -35,16 +35,15 @@ #include "vm/jit/i386/codegen.h" #include "vm/jit/i386/md.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "vm/global.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" #include "vm/jit/executionstate.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" #include "vm/jit/i386/codegen.h" @@ -65,50 +64,50 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) u1 *sp; u1 *ra; u1 *xpc; - u1 opc; - u1 mod; - u1 rm; - int d; - int32_t disp; + u1 opc; + u1 mod; + u1 rm; + int d; + int32_t disp; intptr_t val; - int type; - void *p; + int type; + void *p; java_object_t *o; _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; - _ss = &_mc->ss; + _ss = &_mc->__ss; - pv = NULL; /* is resolved during stackframeinfo creation */ - sp = (u1 *) _ss->esp; - xpc = (u1 *) _ss->eip; - ra = xpc; /* return address is equal to XPC */ + pv = NULL; /* is resolved during stackframeinfo creation */ + sp = (u1 *) _ss->__esp; + xpc = (u1 *) _ss->__eip; + ra = xpc; /* return address is equal to XPC */ - /* get exception-throwing instruction */ + /* get exception-throwing instruction */ - opc = M_ALD_MEM_GET_OPC(xpc); - mod = M_ALD_MEM_GET_MOD(xpc); - rm = M_ALD_MEM_GET_RM(xpc); + opc = M_ALD_MEM_GET_OPC(xpc); + mod = M_ALD_MEM_GET_MOD(xpc); + rm = M_ALD_MEM_GET_RM(xpc); - /* for values see emit_mov_mem_reg and emit_mem */ + /* for values see emit_mov_mem_reg and emit_mem */ - if ((opc == 0x8b) && (mod == 0) && (rm == 5)) { - /* this was a hardware-exception */ + if ((opc == 0x8b) && (mod == 0) && (rm == 5)) { + /* this was a hardware-exception */ - d = M_ALD_MEM_GET_REG(xpc); - disp = M_ALD_MEM_GET_DISP(xpc); + d = M_ALD_MEM_GET_REG(xpc); + disp = M_ALD_MEM_GET_DISP(xpc); - /* we use the exception type as load displacement */ + /* we use the exception type as load displacement */ - type = disp; + type = disp; - val = (d == 0) ? _ss->eax : - ((d == 1) ? _ss->ecx : - ((d == 2) ? _ss->edx : - ((d == 3) ? _ss->ebx : - ((d == 4) ? _ss->esp : - ((d == 5) ? _ss->ebp : - ((d == 6) ? _ss->esi : _ss->edi)))))); + val = (d == 0) ? _ss->__eax : + ((d == 1) ? _ss->__ecx : + ((d == 2) ? _ss->__edx : + ((d == 3) ? _ss->__ebx : + ((d == 4) ? _ss->__esp : + ((d == 5) ? _ss->__ebp : + ((d == 6) ? _ss->__esi : _ss->__edi)))))); if (type == TRAP_COMPILER) { /* The PV from the compiler stub is equal to the XPC. */ @@ -129,12 +128,12 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) xpc = ra - 2; } - } - else { - /* this was a normal NPE */ + } + else { + /* this was a normal NPE */ - type = TRAP_NullPointerException; - } + type = TRAP_NullPointerException; + } /* Handle the trap. */ @@ -146,20 +145,20 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) if (p == NULL) { o = builtin_retrieve_exception(); - _ss->esp = (uintptr_t) sp; /* Remove RA from stack. */ + _ss->__esp = (uintptr_t) sp; /* Remove RA from stack. */ - _ss->eax = (uintptr_t) o; - _ss->ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ - _ss->eip = (uintptr_t) asm_handle_exception; + _ss->__eax = (uintptr_t) o; + _ss->__ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _ss->__eip = (uintptr_t) asm_handle_exception; } else { - _ss->eip = (uintptr_t) p; + _ss->__eip = (uintptr_t) p; } } else { - _ss->eax = (uintptr_t) p; - _ss->ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ - _ss->eip = (uintptr_t) asm_handle_exception; + _ss->__eax = (uintptr_t) p; + _ss->__ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _ss->__eip = (uintptr_t) asm_handle_exception; } } @@ -175,29 +174,29 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) { ucontext_t *_uc; mcontext_t _mc; - u1 *pv; + u1 *pv; i386_thread_state_t *_ss; u1 *sp; u1 *ra; u1 *xpc; - int type; - intptr_t val; - void *p; + int type; + intptr_t val; + void *p; _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; - _ss = &_mc->ss; + _ss = &_mc->__ss; - pv = NULL; /* is resolved during stackframeinfo creation */ - sp = (u1 *) _ss->esp; - xpc = (u1 *) _ss->eip; + pv = NULL; /* is resolved during stackframeinfo creation */ + sp = (u1 *) _ss->__esp; + xpc = (u1 *) _ss->__eip; ra = xpc; /* return address is equal to xpc */ - /* This is an ArithmeticException */ + /* This is an ArithmeticException */ - type = TRAP_ArithmeticException; - val = 0; + type = TRAP_ArithmeticException; + val = 0; /* Handle the trap. */ @@ -205,9 +204,9 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) /* Set registers. */ - _ss->eax = (uintptr_t) p; - _ss->ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ - _ss->eip = (uintptr_t) asm_handle_exception; + _ss->__eax = (uintptr_t) p; + _ss->__ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _ss->__eip = (uintptr_t) asm_handle_exception; } @@ -229,9 +228,9 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; - _ss = &_mc->ss; + _ss = &_mc->__ss; - pc = (u1 *) _ss->eip; + pc = (u1 *) _ss->__eip; t->pc = pc; } @@ -259,11 +258,11 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) _uc = (ucontext_t *) _p; _mc = _uc->uc_mcontext; - _ss = &_mc->ss; + _ss = &_mc->__ss; pv = NULL; /* is resolved during stackframeinfo creation */ - sp = (u1 *) _ss->esp; - xpc = (u1 *) _ss->eip; + sp = (u1 *) _ss->__esp; + xpc = (u1 *) _ss->__eip; ra = xpc; /* return address is equal to xpc */ type = TRAP_PATCHER; @@ -276,9 +275,9 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) /* Set registers. */ if (p != NULL) { - _ss->eax = (uintptr_t) p; - _ss->ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ - _ss->eip = (uintptr_t) asm_handle_exception; + _ss->__eax = (uintptr_t) p; + _ss->__ecx = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _ss->__eip = (uintptr_t) asm_handle_exception; } } @@ -297,22 +296,22 @@ void md_executionstate_read(executionstate_t *es, void *context) _uc = (ucontext_t *) context; _mc = _uc->uc_mcontext; - _ss = &_mc->ss; + _ss = &_mc->__ss; /* read special registers */ - es->pc = (u1 *) _ss->eip; - es->sp = (u1 *) _ss->esp; + es->pc = (u1 *) _ss->__eip; + es->sp = (u1 *) _ss->__esp; es->pv = NULL; /* pv must be looked up via AVL tree */ /* read integer registers */ for (i = 0; i < INT_REG_CNT; i++) - es->intregs[i] = (i == 0) ? _ss->eax : - ((i == 1) ? _ss->ecx : - ((i == 2) ? _ss->edx : - ((i == 3) ? _ss->ebx : - ((i == 4) ? _ss->esp : - ((i == 5) ? _ss->ebp : - ((i == 6) ? _ss->esi : _ss->edi)))))); + es->intregs[i] = (i == 0) ? _ss->__eax : + ((i == 1) ? _ss->__ecx : + ((i == 2) ? _ss->__edx : + ((i == 3) ? _ss->__ebx : + ((i == 4) ? _ss->__esp : + ((i == 5) ? _ss->__ebp : + ((i == 6) ? _ss->__esi : _ss->__edi)))))); /* read float registers */ for (i = 0; i < FLT_REG_CNT; i++) @@ -335,50 +334,22 @@ void md_executionstate_write(executionstate_t *es, void *context) _uc = (ucontext_t *) context; _mc = _uc->uc_mcontext; - _ss = &_mc->ss; + _ss = &_mc->__ss; /* write integer registers */ for (i = 0; i < INT_REG_CNT; i++) - *((i == 0) ? &_ss->eax : - ((i == 1) ? &_ss->ecx : - ((i == 2) ? &_ss->edx : - ((i == 3) ? &_ss->ebx : - ((i == 4) ? &_ss->esp : - ((i == 5) ? &_ss->ebp : - ((i == 6) ? &_ss->esi : &_ss->edi))))))) = es->intregs[i]; + *((i == 0) ? &_ss->__eax : + ((i == 1) ? &_ss->__ecx : + ((i == 2) ? &_ss->__edx : + ((i == 3) ? &_ss->__ebx : + ((i == 4) ? &_ss->__esp : + ((i == 5) ? &_ss->__ebp : + ((i == 6) ? &_ss->__esi : &_ss->__edi))))))) = es->intregs[i]; /* write special registers */ - _ss->eip = (ptrint) es->pc; - _ss->esp = (ptrint) es->sp; -} - - -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *_uc) -{ - mcontext_t _mc; - i386_thread_state_t *_ss; - u1 *pc; - void *rpc; - - _mc = _uc->uc_mcontext; - _ss = &_mc->ss; - - pc = (u1 *) _ss->eip; - - rpc = critical_find_restart_point(pc); - - if (rpc != NULL) - _ss->eip = (ptrint) rpc; + _ss->__eip = (ptrint) es->pc; + _ss->__esp = (ptrint) es->sp; } -#endif /* diff --git a/src/vm/jit/i386/emit.c b/src/vm/jit/i386/emit.c index 0abf598a8..66fba15ff 100644 --- a/src/vm/jit/i386/emit.c +++ b/src/vm/jit/i386/emit.c @@ -37,21 +37,19 @@ #include "threads/lock-common.h" -#include "vm/exceptions.h" +#include "vm/options.h" +#include "vm/statistics.h" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#include "vm/jit/trace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" - /* emit_load ****************************************************************** @@ -523,6 +521,20 @@ void emit_trap_compiler(codegendata *cd) M_ALD_MEM(REG_METHODPTR, TRAP_COMPILER); } +/* emit_trap_countdown ********************************************************* + + Emit a countdown trap. + + counter....absolute address of the counter variable + +*******************************************************************************/ + +void emit_trap_countdown(codegendata *cd, s4 *counter) +{ + M_ISUB_IMM_MEMABS(1, (s4) counter); + M_BNS(6); + M_ALD_MEM(REG_METHODPTR, TRAP_COUNTDOWN); +} /* emit_trap ******************************************************************* diff --git a/src/vm/jit/i386/emit.h b/src/vm/jit/i386/emit.h index a7c0d0c88..a99eaeeb3 100644 --- a/src/vm/jit/i386/emit.h +++ b/src/vm/jit/i386/emit.h @@ -36,7 +36,7 @@ #include "vm/types.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #define REG_AL 0 diff --git a/src/vm/jit/i386/freebsd/md-os.c b/src/vm/jit/i386/freebsd/md-os.c index 4eebf6987..b3ec691f2 100644 --- a/src/vm/jit/i386/freebsd/md-os.c +++ b/src/vm/jit/i386/freebsd/md-os.c @@ -1,9 +1,7 @@ /* src/vm/jit/i386/freebsd/md-os.c - machine dependent i386 FreeBSD functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -37,10 +29,9 @@ #include "vm/jit/i386/md-abi.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" /* md_signal_handler_sigsegv *************************************************** @@ -103,19 +94,6 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) } -#if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *uc) -{ - void *critical; - - critical = critical_find_restart_point((void *) uc->uc_mcontext.mc_eip); - - if (critical) - uc->uc_mcontext.mc_eip = (ptrint) critical; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/i386/linux/md-os.c b/src/vm/jit/i386/linux/md-os.c index 17630b051..deac6bc69 100644 --- a/src/vm/jit/i386/linux/md-os.c +++ b/src/vm/jit/i386/linux/md-os.c @@ -35,15 +35,14 @@ #include "vm/jit/i386/codegen.h" #include "vm/jit/i386/md.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" #include "vm/jit/executionstate.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" @@ -151,6 +150,11 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) _mc->gregs[REG_EIP] = (uintptr_t) p; } } +#if defined(ENABLE_REPLACEMENT) + else if (type == TRAP_COUNTDOWN) { + /* context has been written by md_replace_executionstate_write */ + } +#endif else { _mc->gregs[REG_EAX] = (uintptr_t) p; _mc->gregs[REG_ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ @@ -354,32 +358,6 @@ void md_executionstate_write(executionstate_t *es, void *context) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - u1 *npc; - - _mc = &_uc->uc_mcontext; - - pc = (u1 *) _mc->gregs[REG_EIP]; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) - _mc->gregs[REG_EIP] = (ptrint) npc; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/i386/machine-instr.h b/src/vm/jit/i386/machine-instr.h deleted file mode 100644 index 1499e961f..000000000 --- a/src/vm/jit/i386/machine-instr.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long -__attribute__ ((unused)) -compare_and_swap (volatile long *p, long oldval, long newval) -{ - long ret; - - __asm__ __volatile__ ("lock; cmpxchgl %2, %1" - : "=a" (ret), "=m" (*p) - : "r" (newval), "m" (*p), "0" (oldval)); - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() /* nothing */ -#define MEMORY_BARRIER() __asm__ __volatile__ ( \ - "lock; add $0, 0(%%esp)" : : : "memory" ); - -#endif diff --git a/src/vm/jit/i386/md-abi.c b/src/vm/jit/i386/md-abi.c index f4d9f4c66..dbaf089b8 100644 --- a/src/vm/jit/i386/md-abi.c +++ b/src/vm/jit/i386/md-abi.c @@ -28,12 +28,11 @@ #include "vm/jit/i386/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" -#include "vmcore/descriptor.h" - /* register descripton - array ************************************************/ diff --git a/src/vm/jit/i386/md-atomic.hpp b/src/vm/jit/i386/md-atomic.hpp new file mode 100644 index 000000000..d6ea3d777 --- /dev/null +++ b/src/vm/jit/i386/md-atomic.hpp @@ -0,0 +1,129 @@ +/* src/vm/jit/i386/atomic.hpp - i386 atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t result; + + __asm__ __volatile__ ("lock; cmpxchgl %2, %1" + : "=a" (result), "=m" (*p) + : "r" (newval), "m" (*p), "0" (oldval)); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ +#warning Should we use cmpxchg8b or a generic version? + return generic_compare_and_swap(p, oldval, newval); +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("lock; add $0, 0(%%esp)" : : : "memory" ); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + // Nothing. +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/i386/md-stubs.hpp b/src/vm/jit/i386/md-stubs.hpp new file mode 100644 index 000000000..c5ccf437e --- /dev/null +++ b/src/vm/jit/i386/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/i386/md-stubs.hpp - i386 JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on an i386 architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 6; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/i386/md-trap.h b/src/vm/jit/i386/md-trap.h index 0c3965096..52e6a0067 100644 --- a/src/vm/jit/i386/md-trap.h +++ b/src/vm/jit/i386/md-trap.h @@ -1,4 +1,4 @@ -/* src/vm/jit/x86_64/md-trap.h - i386 hardware traps +/* src/vm/jit/i386/md-trap.h - i386 hardware traps Copyright (C) 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/i386/md.c b/src/vm/jit/i386/md.c index 48664ef1f..191cddabd 100644 --- a/src/vm/jit/i386/md.c +++ b/src/vm/jit/i386/md.c @@ -1,9 +1,7 @@ /* src/vm/jit/i386/md.c - machine dependent i386 functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,10 +31,10 @@ #include "vm/types.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* md_init ********************************************************************* diff --git a/src/vm/jit/i386/md.h b/src/vm/jit/i386/md.h index 568f8e934..562736be4 100644 --- a/src/vm/jit/i386/md.h +++ b/src/vm/jit/i386/md.h @@ -31,7 +31,7 @@ #include #include -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/methodtree.h" @@ -85,7 +85,8 @@ inline static void *md_codegen_get_pv_from_pc(void *ra) inline static void md_cacheflush(void *addr, int nbytes) { - /* do nothing */ + // Compiler optimization barrier (see PR97). + __asm__ __volatile__ ("" : : : "memory"); } @@ -97,7 +98,8 @@ inline static void md_cacheflush(void *addr, int nbytes) inline static void md_icacheflush(void *addr, int nbytes) { - /* do nothing */ + // Compiler optimization barrier (see PR97). + __asm__ __volatile__ ("" : : : "memory"); } @@ -109,7 +111,8 @@ inline static void md_icacheflush(void *addr, int nbytes) inline static void md_dcacheflush(void *addr, int nbytes) { - /* do nothing */ + // Compiler optimization barrier (see PR97). + __asm__ __volatile__ ("" : : : "memory"); } #endif /* _VM_JIT_I386_MD_H */ diff --git a/src/vm/jit/i386/patcher.c b/src/vm/jit/i386/patcher.c index 13506172d..034ca21ef 100644 --- a/src/vm/jit/i386/patcher.c +++ b/src/vm/jit/i386/patcher.c @@ -30,26 +30,28 @@ #include "vm/types.h" #include "vm/jit/i386/codegen.h" +#include "vm/jit/i386/md.h" #include "mm/memory.h" #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" - -#include "vm/jit/patcher-common.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" +#include "vm/options.h" +#include "vm/references.h" #include "vm/resolve.h" -#include "vmcore/references.h" + +#include "vm/jit/patcher-common.hpp" -#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) pr->mpc) = (u2) pr->mcode +#define PATCH_BACK_ORIGINAL_MCODE \ + do { \ + *((uint16_t*) pr->mpc) = (uint16_t) pr->mcode; \ + md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE); \ + } while (0) /* patcher_patch_code ********************************************************** @@ -97,11 +99,6 @@ bool patcher_get_putstatic(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the field value's address */ *((intptr_t *) (ra + 1)) = (intptr_t) fi->value; @@ -137,11 +134,6 @@ bool patcher_getfield(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the field's offset */ *((u4 *) (ra + 2)) = (u4) (fi->offset); @@ -182,11 +174,6 @@ bool patcher_putfield(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the field's offset */ if (fi->type != TYPE_LNG) { @@ -234,11 +221,6 @@ bool patcher_putfieldconst(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the field's offset */ if (!IS_2_WORD_TYPE(fi->type)) { @@ -287,11 +269,6 @@ bool patcher_aconst(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the classinfo pointer */ *((ptrint *) (ra + 1)) = (ptrint) c; @@ -333,11 +310,6 @@ bool patcher_builtin_multianewarray(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the classinfo pointer */ *((ptrint *) (ra + 7 + 4)) = (ptrint) c; @@ -375,11 +347,6 @@ bool patcher_builtin_arraycheckcast(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch the classinfo pointer */ *((ptrint *) (ra + 4)) = (ptrint) c; @@ -420,11 +387,6 @@ bool patcher_invokestatic_special(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch stubroutine */ *((ptrint *) (ra + 1)) = (ptrint) m->stubroutine; @@ -462,11 +424,6 @@ bool patcher_invokevirtual(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch vftbl index */ *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, table[0]) + @@ -506,11 +463,6 @@ bool patcher_invokeinterface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch interfacetable index */ *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) - @@ -552,11 +504,6 @@ bool patcher_checkcast_instanceof_flags(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch class flags */ *((s4 *) (ra + 1)) = (s4) c->flags; @@ -597,11 +544,6 @@ bool patcher_checkcast_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch super class index */ *((s4 *) (ra + 6 + 2)) = (s4) c->index; @@ -645,11 +587,6 @@ bool patcher_instanceof_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch super class index */ *((s4 *) (ra + 6 + 2)) = (s4) c->index; @@ -693,11 +630,6 @@ bool patcher_checkcast_class(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch super class' vftbl */ *((ptrint *) (ra + 1)) = (ptrint) c->vftbl; @@ -736,11 +668,6 @@ bool patcher_instanceof_class(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch super class' vftbl */ *((ptrint *) (ra + 1)) = (ptrint) c->vftbl; diff --git a/src/vm/jit/i386/solaris/Makefile.am b/src/vm/jit/i386/solaris/Makefile.am new file mode 100644 index 000000000..aa9595b77 --- /dev/null +++ b/src/vm/jit/i386/solaris/Makefile.am @@ -0,0 +1,44 @@ +## src/vm/jit/i386/solaris/Makefile.am +## +## Copyright (C) 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +## +## This file is part of CACAO. +## +## This program is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + + +AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_builddir)/src + +LIBS = + +noinst_HEADERS = \ + md-asm.h + +noinst_LTLIBRARIES = \ + libmd.la + +libmd_la_SOURCES = \ + md-os.c + + +## Local variables: +## mode: Makefile +## indent-tabs-mode: t +## c-basic-offset: 4 +## tab-width: 8 +## compile-command: "automake --add-missing" +## End: diff --git a/src/vm/jit/i386/solaris/md-asm.h b/src/vm/jit/i386/solaris/md-asm.h new file mode 100644 index 000000000..8a2a5fe9f --- /dev/null +++ b/src/vm/jit/i386/solaris/md-asm.h @@ -0,0 +1,82 @@ +/* src/vm/jit/i386/solaris/md-asm.h - assembler defines for i386 ABI + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ASM_H +#define _MD_ASM_H + +/* register defines ***********************************************************/ + +#define v0 %eax +#define itmp1 v0 + +#define itmp2 %ecx +#define itmp3 %edx + +#define t0 %ebx + +#define sp %esp +#define s0 %ebp +#define s1 %esi +#define s2 %edi + +#define bp s0 + +#define itmp1b %al + +#define xptr itmp1 +#define xpc itmp2 +#define mptr itmp2 + + +/* save and restore macros ****************************************************/ + +#define SAVE_ARGUMENT_REGISTERS(off) \ + /* no argument registers */ + +#define SAVE_TEMPORARY_REGISTERS(off) \ + mov t0,(0+(off))*4(sp) ; + + +#define RESTORE_ARGUMENT_REGISTERS(off) \ + /* no argument registers */ + +#define RESTORE_TEMPORARY_REGISTERS(off) \ + mov (0+(off))*4(sp),t0 ; + +#endif /* _MD_ASM_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/i386/solaris/md-os.c b/src/vm/jit/i386/solaris/md-os.c new file mode 100644 index 000000000..7e9e0e40e --- /dev/null +++ b/src/vm/jit/i386/solaris/md-os.c @@ -0,0 +1,365 @@ +/* src/vm/jit/i386/solaris/md-os.c - machine dependent i386 Solaris functions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "vm/jit/i386/codegen.h" +#include "vm/jit/i386/md.h" + +#include "threads/thread.hpp" + +#include "vm/jit/builtin.hpp" +#include "vm/signallocal.h" + +#include "vm/jit/asmpart.h" +#include "vm/jit/executionstate.h" +#include "vm/jit/stacktrace.hpp" +#include "vm/jit/trap.h" + + +/* md_signal_handler_sigsegv *************************************************** + + Signal handler for hardware exceptions. + +*******************************************************************************/ + +void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u1 opc; + u1 mod; + u1 rm; + s4 d; + s4 disp; + ptrint val; + s4 type; + void *p; + java_object_t *o; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + pv = NULL; /* is resolved during stackframeinfo creation */ + sp = (u1 *) _mc->gregs[ESP]; + xpc = (u1 *) _mc->gregs[EIP]; + ra = xpc; /* return address is equal to XPC */ + + /* get exception-throwing instruction */ + + opc = M_ALD_MEM_GET_OPC(xpc); + mod = M_ALD_MEM_GET_MOD(xpc); + rm = M_ALD_MEM_GET_RM(xpc); + + /* for values see emit_mov_mem_reg and emit_mem */ + + if ((opc == 0x8b) && (mod == 0) && (rm == 5)) { + /* this was a hardware-exception */ + + d = M_ALD_MEM_GET_REG(xpc); + disp = M_ALD_MEM_GET_DISP(xpc); + + /* we use the exception type as load displacement */ + + type = disp; + + /* ATTENTION: The _mc->gregs layout is completely crazy! The + registers are reversed starting with number 4 for REG_EDI + (see /usr/include/sys/ucontext.h). We have to convert that + here. */ + + val = _mc->gregs[EAX - d]; + + if (type == TRAP_COMPILER) { + /* The PV from the compiler stub is equal to the XPC. */ + + pv = xpc; + + /* We use a framesize of zero here because the call pushed + the return addres onto the stack. */ + + ra = md_stacktrace_get_returnaddress(sp, 0); + + /* Skip the RA on the stack. */ + + sp = sp + 1 * SIZEOF_VOID_P; + + /* The XPC is the RA minus 2, because the RA points to the + instruction after the call. */ + + xpc = ra - 2; + } + } + else { + /* this was a normal NPE */ + + type = TRAP_NullPointerException; + val = 0; + } + + /* Handle the trap. */ + + p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + /* Set registers. */ + + if (type == TRAP_COMPILER) { + if (p == NULL) { + o = builtin_retrieve_exception(); + + _mc->gregs[ESP] = (uintptr_t) sp; /* Remove RA from stack. */ + + _mc->gregs[EAX] = (uintptr_t) o; + _mc->gregs[ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[EIP] = (uintptr_t) asm_handle_exception; + } + else { + _mc->gregs[EIP] = (uintptr_t) p; + } + } + else { + _mc->gregs[EAX] = (uintptr_t) p; + _mc->gregs[ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[EIP] = (uintptr_t) asm_handle_exception; + } +} + + +/* md_signal_handler_sigfpe **************************************************** + + ArithmeticException signal handler for hardware divide by zero + check. + +*******************************************************************************/ + +void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + s4 type; + ptrint val; + void *p; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + pv = NULL; /* is resolved during stackframeinfo creation */ + sp = (u1 *) _mc->gregs[ESP]; + xpc = (u1 *) _mc->gregs[EIP]; + ra = xpc; /* return address is equal to xpc */ + + /* This is an ArithmeticException. */ + + type = TRAP_ArithmeticException; + val = 0; + + /* Handle the trap. */ + + p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + /* Set registers. */ + + _mc->gregs[EAX] = (uintptr_t) p; + _mc->gregs[ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[EIP] = (uintptr_t) asm_handle_exception; +} + + +/* md_signal_handler_sigill **************************************************** + + Signal handler for hardware patcher traps (ud2). + +*******************************************************************************/ + +void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + s4 type; + ptrint val; + void *p; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + pv = NULL; /* is resolved during stackframeinfo creation */ + sp = (u1 *) _mc->gregs[ESP]; + xpc = (u1 *) _mc->gregs[EIP]; + ra = xpc; /* return address is equal to xpc */ + + type = TRAP_PATCHER; + val = 0; + + /* Handle the trap. */ + + p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + /* Set registers. */ + + if (p != NULL) { + _mc->gregs[EAX] = (uintptr_t) p; + _mc->gregs[ECX] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[EIP] = (uintptr_t) asm_handle_exception; + } +} + + +/* md_signal_handler_sigusr1 *************************************************** + + Signal handler for suspending threads. + +*******************************************************************************/ + +#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) +void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pc; + u1 *sp; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + /* get the PC and SP for this thread */ + pc = (u1 *) _mc->gregs[EIP]; + sp = (u1 *) _mc->gregs[ESP]; + + /* now suspend the current thread */ + threads_suspend_ack(pc, sp); +} +#endif + + +/* md_signal_handler_sigusr2 *************************************************** + + Signal handler for profiling sampling. + +*******************************************************************************/ + +#if defined(ENABLE_THREADS) +void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) +{ + threadobject *t; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pc; + + t = THREADOBJECT; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + pc = (u1 *) _mc->gregs[EIP]; + + t->pc = pc; +} +#endif + + +/* md_executionstate_read ****************************************************** + + Read the given context into an executionstate for Replacement. + +*******************************************************************************/ + +void md_executionstate_read(executionstate_t *es, void *context) +{ + ucontext_t *_uc; + mcontext_t *_mc; + s4 i; + + _uc = (ucontext_t *) context; + _mc = &_uc->uc_mcontext; + + /* read special registers */ + es->pc = (u1 *) _mc->gregs[EIP]; + es->sp = (u1 *) _mc->gregs[ESP]; + es->pv = NULL; /* pv must be looked up via AVL tree */ + + /* read integer registers */ + for (i = 0; i < INT_REG_CNT; i++) + es->intregs[i] = _mc->gregs[EAX - i]; + + /* read float registers */ + for (i = 0; i < FLT_REG_CNT; i++) + es->fltregs[i] = 0xdeadbeefdeadbeefULL; +} + + +/* md_executionstate_write ***************************************************** + + Write the given executionstate back to the context for Replacement. + +*******************************************************************************/ + +void md_executionstate_write(executionstate_t *es, void *context) +{ + ucontext_t *_uc; + mcontext_t *_mc; + s4 i; + + _uc = (ucontext_t *) context; + _mc = &_uc->uc_mcontext; + + /* write integer registers */ + for (i = 0; i < INT_REG_CNT; i++) + _mc->gregs[EAX - i] = es->intregs[i]; + + /* write special registers */ + _mc->gregs[EIP] = (ptrint) es->pc; + _mc->gregs[ESP] = (ptrint) es->sp; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/icmdtable.inc b/src/vm/jit/icmdtable.inc deleted file mode 100644 index 4b0639cdc..000000000 --- a/src/vm/jit/icmdtable.inc +++ /dev/null @@ -1,310 +0,0 @@ -/*** The ICMD Table ***/ - -/* IMPORTANT: This file must be in a fixed format, as it is both included in */ -/* src/vm/jit/jit.c, and parsed by src/vm/jit/verify/generate.pl! */ -/* */ -/* The comments at the start of the line and inside the braces are */ -/* significant. If you want to add a comment to an ICMD, do that after the */ -/* comma, or brace, at the end of the line. */ -/* */ -/* The format is as follows (slashes reversed for obvious reasons): */ -/* */ -/* \*#*\ { N( name ) data-flow, control-flow, flags \* stage (action) *\ } */ -/* */ -/* ^^^ */ -/* opcode */ -/* */ -/* where */ -/* opcode...........is the opcode number (decimal) */ -/* name.............is the quoted name without the ICMD_ prefix */ -/* data-flow........is one of the DF_ constants (see jit.h) */ -/* control-flow.....is one of the CF_ constants (see jit.h) */ -/* flags............is 0 or a |-combination of */ -/* PEI........may throw an exception */ -/* CALLS......needs saved registers (calls out) */ -/* *_CALLS....see jit.h for architecture specific */ -/* constants to put here */ -/* */ -/* stage............is either empty, or one of */ -/* -- ICMD is not used anywhere after parse */ -/* -S ICMD is eliminated by stack_analyse */ -/* S+ ICMD is introduced by stack_analyse */ -/* */ -/* action...........is the stack action of the ICMD in the notation */ -/* instack--outstack, TOS being rightmost. */ -/* */ -/* Valid type characters are */ -/* I, L, F, D, and A the basic types */ -/* 1 a category 1 type */ -/* 2 a category 2 type */ -/* . variable number of slots */ -/* */ -/* Whitespace is not allowed within the action. */ -/* */ -/* Some ICMDs may have several variants. In this case */ -/* the action is build by joining the individual */ -/* actions of the variants with |. */ -/* */ -/* */ -/* CAUTION: Do not use preprocessor directives in this file! They will */ -/* confuse the generator. */ -/* */ - - -/* 0*/ {N("NOP ") DF_0_TO_0 , CF_NORMAL, 0 /* (--) */}, -/* 1*/ {N("ACONST ") DF_0_TO_1 , CF_NORMAL, PEI /* (--A) */}, -/* 2*/ {N("CHECKNULL ") DF_1_TO_1 , CF_NORMAL, PEI /* (A--A) */}, -/* 3*/ {N("ICONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--I) */}, -/* 4*/ {N("UNDEF4 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 5*/ {N("IDIVPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 6*/ {N("LDIVPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 7*/ {N("UNDEF7 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 8*/ {N("UNDEF8 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 9*/ {N("LCONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--L) */}, -/* 10*/ {N("LCMPCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--I) */}, -/* 11*/ {N("FCONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--F) */}, -/* 12*/ {N("UNDEF12 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 13*/ {N("UNDEF13 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 14*/ {N("DCONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--D) */}, -/* 15*/ {N("COPY ") DF_COPY , CF_NORMAL, 0 /* S+ (1--1) */}, -/* 16*/ {N("MOVE ") DF_MOVE , CF_NORMAL, 0 /* S+ (1--1) */}, -/* 17*/ {N("UNDEF17 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 18*/ {N("UNDEF18 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 19*/ {N("UNDEF19 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 20*/ {N("UNDEF20 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 21*/ {N("ILOAD ") DF_LOAD , CF_NORMAL, 0 /* (--I) */}, -/* 22*/ {N("LLOAD ") DF_LOAD , CF_NORMAL, 0 /* (--L) */}, -/* 23*/ {N("FLOAD ") DF_LOAD , CF_NORMAL, 0 /* (--F) */}, -/* 24*/ {N("DLOAD ") DF_LOAD , CF_NORMAL, 0 /* (--D) */}, -/* 25*/ {N("ALOAD ") DF_LOAD , CF_NORMAL, 0 /* (--A) */}, -/* 26*/ {N("IADDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 27*/ {N("ISUBCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 28*/ {N("IMULCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 29*/ {N("IANDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 30*/ {N("IORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 31*/ {N("IXORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 32*/ {N("ISHLCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 33*/ {N("ISHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 34*/ {N("IUSHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 35*/ {N("IREMPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/* 36*/ {N("LADDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 37*/ {N("LSUBCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 38*/ {N("LMULCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 39*/ {N("LANDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 40*/ {N("LORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 41*/ {N("LXORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 42*/ {N("LSHLCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 43*/ {N("LSHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 44*/ {N("LUSHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 45*/ {N("LREMPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/* 46*/ {N("IALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, -/* 47*/ {N("LALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--L) */}, -/* 48*/ {N("FALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--F) */}, -/* 49*/ {N("DALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--D) */}, -/* 50*/ {N("AALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--A) */}, -/* 51*/ {N("BALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, -/* 52*/ {N("CALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, -/* 53*/ {N("SALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, -/* 54*/ {N("ISTORE ") DF_STORE , CF_NORMAL, 0 /* (I--) */}, -/* 55*/ {N("LSTORE ") DF_STORE , CF_NORMAL, 0 /* (L--) */}, -/* 56*/ {N("FSTORE ") DF_STORE , CF_NORMAL, 0 /* (F--) */}, -/* 57*/ {N("DSTORE ") DF_STORE , CF_NORMAL, 0 /* (D--) */}, -/* 58*/ {N("ASTORE ") DF_STORE , CF_NORMAL, 0 /* (A--|R--) */}, -/* 59*/ {N("IF_LEQ ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, -/* 60*/ {N("IF_LNE ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, -/* 61*/ {N("IF_LLT ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, -/* 62*/ {N("IF_LGE ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, -/* 63*/ {N("IF_LGT ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, -/* 64*/ {N("IF_LLE ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, -/* 65*/ {N("IF_LCMPEQ ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, -/* 66*/ {N("IF_LCMPNE ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, -/* 67*/ {N("IF_LCMPLT ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, -/* 68*/ {N("IF_LCMPGE ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, -/* 69*/ {N("IF_LCMPGT ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, -/* 70*/ {N("IF_LCMPLE ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, -/* 71*/ {N("UNDEF71 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 72*/ {N("UNDEF72 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 73*/ {N("UNDEF73 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 74*/ {N("UNDEF74 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 75*/ {N("UNDEF75 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 76*/ {N("UNDEF76 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 77*/ {N("UNDEF77 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 78*/ {N("UNDEF78 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/* 79*/ {N("IASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, -/* 80*/ {N("LASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AIL--) */}, -/* 81*/ {N("FASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AIF--) */}, -/* 82*/ {N("DASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AID--) */}, -/* 83*/ {N("AASTORE ") DF_3_TO_0 , CF_NORMAL, PEI|CALLS /* (AIA--) */}, -/* 84*/ {N("BASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, -/* 85*/ {N("CASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, -/* 86*/ {N("SASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, -/* 87*/ {N("POP ") DF_POP , CF_NORMAL, 0 /* (1--) */}, -/* 88*/ {N("POP2 ") DF_POP2 , CF_NORMAL, 0 /* (11--|2--) */}, -/* 89*/ {N("DUP ") DF_DUP , CF_NORMAL, 0 /* -S (1--11) */}, -/* 90*/ {N("DUP_X1 ") DF_DUP_X1 , CF_NORMAL, 0 /* -S (11--111) */}, -/* 91*/ {N("DUP_X2 ") DF_DUP_X2 , CF_NORMAL, 0 /* -S (111--1111|21--121) */}, -/* 92*/ {N("DUP2 ") DF_DUP2 , CF_NORMAL, 0 /* -S (11--1111|2--22) */}, -/* 93*/ {N("DUP2_X1 ") DF_DUP2_X1, CF_NORMAL, 0 /* -S (111--11111|12--212) */}, -/* 94*/ {N("DUP2_X2 ") DF_DUP2_X2, CF_NORMAL, 0 /* -S (1111--111111|112--2112|22--222|211--11211) */}, -/* 95*/ {N("SWAP ") DF_SWAP , CF_NORMAL, 0 /* -S (11--11) */}, -/* 96*/ {N("IADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/* 97*/ {N("LADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, -/* 98*/ {N("FADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, -/* 99*/ {N("DADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, -/*100*/ {N("ISUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*101*/ {N("LSUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, -/*102*/ {N("FSUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, -/*103*/ {N("DSUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, -/*104*/ {N("IMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*105*/ {N("LMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, -/*106*/ {N("FMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, -/*107*/ {N("DMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, -/*108*/ {N("IDIV ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /* (II--I) */}, -/*109*/ {N("LDIV ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /* (LL--L) */}, -/*110*/ {N("FDIV ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, -/*111*/ {N("DDIV ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, -/*112*/ {N("IREM ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /* (II--I) */}, -/*113*/ {N("LREM ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /* (LL--L) */}, -/*114*/ {N("FREM ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, -/*115*/ {N("DREM ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, -/*116*/ {N("INEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, -/*117*/ {N("LNEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--L) */}, -/*118*/ {N("FNEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--F) */}, -/*119*/ {N("DNEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--D) */}, -/*120*/ {N("ISHL ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*121*/ {N("LSHL ") DF_2_TO_1 , CF_NORMAL, 0 /* (LI--L) */}, -/*122*/ {N("ISHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*123*/ {N("LSHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LI--L) */}, -/*124*/ {N("IUSHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*125*/ {N("LUSHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LI--L) */}, -/*126*/ {N("IAND ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*127*/ {N("LAND ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, -/*128*/ {N("IOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*129*/ {N("LOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, -/*130*/ {N("IXOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, -/*131*/ {N("LXOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, -/*132*/ {N("IINC ") DF_IINC , CF_NORMAL, 0 /* (--) */}, -/*133*/ {N("I2L ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--L) */}, -/*134*/ {N("I2F ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--F) */}, -/*135*/ {N("I2D ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--D) */}, -/*136*/ {N("L2I ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--I) */}, -/*137*/ {N("L2F ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--F) */}, -/*138*/ {N("L2D ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--D) */}, -/*139*/ {N("F2I ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--I) */}, -/*140*/ {N("F2L ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--L) */}, -/*141*/ {N("F2D ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--D) */}, -/*142*/ {N("D2I ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--I) */}, -/*143*/ {N("D2L ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--L) */}, -/*144*/ {N("D2F ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--F) */}, -/*145*/ {N("INT2BYTE ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, -/*146*/ {N("INT2CHAR ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, -/*147*/ {N("INT2SHORT ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, -/*148*/ {N("LCMP ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--I) */}, -/*149*/ {N("FCMPL ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--I) */}, -/*150*/ {N("FCMPG ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--I) */}, -/*151*/ {N("DCMPL ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--I) */}, -/*152*/ {N("DCMPG ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--I) */}, -/*153*/ {N("IFEQ ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, -/*154*/ {N("IFNE ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, -/*155*/ {N("IFLT ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, -/*156*/ {N("IFGE ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, -/*157*/ {N("IFGT ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, -/*158*/ {N("IFLE ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, -/*159*/ {N("IF_ICMPEQ ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, -/*160*/ {N("IF_ICMPNE ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, -/*161*/ {N("IF_ICMPLT ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, -/*162*/ {N("IF_ICMPGE ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, -/*163*/ {N("IF_ICMPGT ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, -/*164*/ {N("IF_ICMPLE ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, -/*165*/ {N("IF_ACMPEQ ") DF_2_TO_0 , CF_IF , 0 /* (AA--) */}, -/*166*/ {N("IF_ACMPNE ") DF_2_TO_0 , CF_IF , 0 /* (AA--) */}, -/*167*/ {N("GOTO ") DF_0_TO_0 , CF_GOTO , 0 /* (--) */}, -/*168*/ {N("JSR ") DF_0_TO_1 , CF_JSR , 0 /* (--R) */}, -/*169*/ {N("RET ") DF_0_TO_0 , CF_RET , 0 /* (--) */}, -/*170*/ {N("TABLESWITCH ") DF_1_TO_0 , CF_TABLE , 0 /* (I--) */}, -/*171*/ {N("LOOKUPSWITCH ") DF_1_TO_0 , CF_LOOKUP, 0 /* (I--) */}, -/*172*/ {N("IRETURN ") DF_1_TO_0 , CF_END , 0 /* (I--) */}, -/*173*/ {N("LRETURN ") DF_1_TO_0 , CF_END , 0 /* (L--) */}, -/*174*/ {N("FRETURN ") DF_1_TO_0 , CF_END , 0 /* (F--) */}, -/*175*/ {N("DRETURN ") DF_1_TO_0 , CF_END , 0 /* (D--) */}, -/*176*/ {N("ARETURN ") DF_1_TO_0 , CF_END , PEI /* (A--) */}, -/*177*/ {N("RETURN ") DF_0_TO_0 , CF_END , 0 /* (--) */}, -/*178*/ {N("GETSTATIC ") DF_0_TO_1 , CF_NORMAL, PEI /* (--1|--2) */}, -/*179*/ {N("PUTSTATIC ") DF_1_TO_0 , CF_NORMAL, PEI /* (1--|2--) */}, -/*180*/ {N("GETFIELD ") DF_1_TO_1 , CF_NORMAL, PEI /* (A--1|A--2) */}, -/*181*/ {N("PUTFIELD ") DF_2_TO_0 , CF_NORMAL, PEI /* (A1--|A2--) */}, -/*182*/ {N("INVOKEVIRTUAL ") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, -/*183*/ {N("INVOKESPECIAL ") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, -/*184*/ {N("INVOKESTATIC ") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, -/*185*/ {N("INVOKEINTERFACE") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, -/*186*/ {N("UNDEF186 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*187*/ {N("NEW ") DF_0_TO_1 , CF_NORMAL, PEI /* -- (--A) */}, -/*188*/ {N("NEWARRAY ") DF_0_TO_1 , CF_NORMAL, PEI /* -- (--A) */}, -/*189*/ {N("ANEWARRAY ") DF_0_TO_1 , CF_NORMAL, PEI /* -- (--A) */}, -/*190*/ {N("ARRAYLENGTH ") DF_1_TO_1 , CF_NORMAL, PEI /* (A--I) */}, -/*191*/ {N("ATHROW ") DF_1_TO_0 , CF_END , PEI /* (A--) */}, -/*192*/ {N("CHECKCAST ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS /* (A--A) */}, -/*193*/ {N("INSTANCEOF ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS /* (A--I) */}, -/*194*/ {N("MONITORENTER ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS /* -- (A--) */}, -/*195*/ {N("MONITOREXIT ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS /* -- (A--) */}, -/*196*/ {N("UNDEF196 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*197*/ {N("MULTIANEWARRAY ") DF_N_TO_1 , CF_NORMAL, PEI|CALLS /* (.--A) */}, -/*198*/ {N("IFNULL ") DF_1_TO_0 , CF_IF , 0 /* (A--) */}, -/*199*/ {N("IFNONNULL ") DF_1_TO_0 , CF_IF , 0 /* (A--) */}, -/*200*/ {N("UNDEF200 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*201*/ {N("UNDEF201 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*202*/ {N("UNDEF202 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*203*/ {N("UNDEF203 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*204*/ {N("IASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*205*/ {N("LASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*206*/ {N("FASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*207*/ {N("DASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*208*/ {N("AASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*209*/ {N("BASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*210*/ {N("CASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*211*/ {N("SASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, -/*212*/ {N("PUTSTATICCONST ") DF_0_TO_0 , CF_NORMAL, PEI /* S+ (--) */}, -/*213*/ {N("PUTFIELDCONST ") DF_1_TO_0 , CF_NORMAL, PEI /* S+ (A--) */}, -/*214*/ {N("IMULPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, -/*215*/ {N("LMULPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, -/*216*/ {N("IF_FCMPEQ ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*217*/ {N("IF_FCMPNE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*218*/ {N("IF_FCMPL_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*219*/ {N("IF_FCMPL_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*220*/ {N("IF_FCMPL_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*221*/ {N("IF_FCMPL_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*222*/ {N("IF_FCMPG_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*223*/ {N("IF_FCMPG_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*224*/ {N("IF_FCMPG_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*225*/ {N("IF_FCMPG_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*226*/ {N("IF_DCMPEQ ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*227*/ {N("IF_DCMPNE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*228*/ {N("IF_DCMPL_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*229*/ {N("IF_DCMPL_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*230*/ {N("IF_DCMPL_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*231*/ {N("IF_DCMPL_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*232*/ {N("IF_DCMPG_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*233*/ {N("IF_DCMPG_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*234*/ {N("IF_DCMPG_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*235*/ {N("IF_DCMPG_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, -/*236*/ {N("UNDEF236 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*237*/ {N("UNDEF237 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*238*/ {N("UNDEF238 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*239*/ {N("UNDEF239 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*240*/ {N("UNDEF240 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*241*/ {N("UNDEF241 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*242*/ {N("UNDEF242 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*243*/ {N("UNDEF243 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*244*/ {N("UNDEF244 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*245*/ {N("UNDEF245 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*246*/ {N("UNDEF246 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*247*/ {N("UNDEF247 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*248*/ {N("UNDEF248 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*249*/ {N("GETEXCEPTION ") DF_0_TO_1 , CF_NORMAL, 0 /* -- () */}, -/*250*/ {N("PHI ") DF_N_TO_1 , CF_NORMAL, 0 /* -- () */}, -/*251*/ {N("INLINE_START ") DF_0_TO_0 , CF_NORMAL, 0 /* S+ (--) */}, -/*252*/ {N("INLINE_END ") DF_0_TO_0 , CF_NORMAL, 0 /* S+ (--) */}, -/*253*/ {N("INLINE_BODY ") DF_0_TO_0 , CF_NORMAL, 0 /* S+ (--) */}, -/*254*/ {N("UNDEF254 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, -/*255*/ {N("BUILTIN ") DF_BUILTIN, CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */} - diff --git a/src/vm/jit/inline/inline.c b/src/vm/jit/inline/inline.c index 210d94599..dd439a56e 100644 --- a/src/vm/jit/inline/inline.c +++ b/src/vm/jit/inline/inline.c @@ -35,15 +35,20 @@ #include "mm/memory.h" #include "threads/lock-common.h" -#include "threads/thread.h" +#include "threads/mutex.hpp" +#include "threads/thread.hpp" #include "toolbox/logging.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" #include "vm/global.h" #include "vm/initialize.h" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/statistics.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/parse.h" #include "vm/jit/reg.h" #include "vm/jit/show.h" @@ -54,11 +59,6 @@ #include "vm/jit/verify/typecheck.h" -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" - /* algorithm tuning constants *************************************************/ @@ -338,7 +338,7 @@ static bool inline_jit_compile(inline_node *iln) /* enter a monitor on the method */ - LOCK_MONITOR_ENTER(m); + Mutex_lock(m->mutex); /* allocate jitdata structure and fill it */ @@ -381,7 +381,7 @@ static bool inline_jit_compile(inline_node *iln) /* leave the monitor */ - LOCK_MONITOR_EXIT(m); + Mutex_unlock(m->mutex); return r; } diff --git a/src/vm/jit/inline/inline.h b/src/vm/jit/inline/inline.h index cdd41ee4d..629f649a9 100644 --- a/src/vm/jit/inline/inline.h +++ b/src/vm/jit/inline/inline.h @@ -1,9 +1,7 @@ /* src/vm/jit/inline/inline.h - code inliner - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -30,15 +28,23 @@ #include "config.h" -#include "vm/global.h" +#include -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool inline_inline(jitdata *jd); +#ifdef __cplusplus +} +#endif + #endif /* _INLINE_H */ /* diff --git a/src/vm/jit/intrp/Makefile.am b/src/vm/jit/intrp/Makefile.am index d0d7fd910..62b3651ae 100644 --- a/src/vm/jit/intrp/Makefile.am +++ b/src/vm/jit/intrp/Makefile.am @@ -30,9 +30,7 @@ EXTRA_DIST = \ java.vmg \ gray.fs \ prims2x.fs \ - vmgenx \ - \ - $(BUILT_SOURCES) + vmgenx noinst_HEADERS = \ engine.c diff --git a/src/vm/jit/intrp/asmpart.c b/src/vm/jit/intrp/asmpart.c index 6bba262c8..a81b6b073 100644 --- a/src/vm/jit/intrp/asmpart.c +++ b/src/vm/jit/intrp/asmpart.c @@ -31,10 +31,13 @@ #include "arch.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/options.h" #include "vm/jit/asmpart.h" #include "vm/jit/methodheader.h" @@ -43,11 +46,6 @@ #include "vm/jit/intrp/intrp.h" -#include "vmcore/class.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - #if defined(ENABLE_VMLOG) #include #endif diff --git a/src/vm/jit/intrp/codegen.c b/src/vm/jit/intrp/codegen.c index 6fe3cc727..b732399e1 100644 --- a/src/vm/jit/intrp/codegen.c +++ b/src/vm/jit/intrp/codegen.c @@ -47,23 +47,21 @@ #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/parse.h" #include "vm/jit/patcher.h" #include "vm/jit/stack.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/options.h" +#include "vm/jit/stacktrace.hpp" #define gen_branch(_inst) { \ @@ -2085,7 +2083,7 @@ Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1 assert(false); } - av_ptr(alist, _Jv_JNIEnv *, _Jv_env); + av_ptr(alist, _Jv_JNIEnv *, VM_get_jnienv()); if (m->flags & ACC_STATIC) av_ptr(alist, classinfo *, m->clazz); @@ -2150,7 +2148,7 @@ Cell *nativecall(functionptr f, methodinfo *m, Cell *sp, Inst *ra, Cell *fp, u1 /* pass env pointer */ - penv = (_Jv_JNIEnv *) _Jv_env; + penv = (_Jv_JNIEnv *) VM_get_jnienv(); *pvalues++ = &penv; /* for static methods, pass class pointer */ diff --git a/src/vm/jit/intrp/dynamic-super.c b/src/vm/jit/intrp/dynamic-super.c index d735aa3c6..dcf7d9e44 100644 --- a/src/vm/jit/intrp/dynamic-super.c +++ b/src/vm/jit/intrp/dynamic-super.c @@ -3,10 +3,8 @@ Copyright (C) 1995,1996,1997,1998,2000,2003,2004 Free Software Foundation, Inc. Taken from Gforth. - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -24,6 +22,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ @@ -44,11 +43,11 @@ #include "toolbox/hashtable.h" #include "toolbox/logging.h" +#include "vm/options.h" + #include "vm/jit/disass.h" #include "vm/jit/intrp/intrp.h" -#include "vmcore/options.h" - s4 no_super=0; /* option: just use replication, but no dynamic superinsts */ diff --git a/src/vm/jit/intrp/engine.c b/src/vm/jit/intrp/engine.c index 1e98d1e8b..a09239243 100644 --- a/src/vm/jit/intrp/engine.c +++ b/src/vm/jit/intrp/engine.c @@ -39,25 +39,19 @@ #include "mm/memory.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" #include "vm/jit/methodheader.h" #include "vm/jit/patcher.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" +#include "vm/jit/stacktrace.hpp" #if defined(ENABLE_THREADS) -# ifndef USE_FAKE_ATOMIC_INSTRUCTIONS -# include "machine-instr.h" -# else -# include "threads/posix/generic-primitives.h" -# endif +# include "threads/atomic.hpp" #endif #if !defined(STORE_ORDER_BARRIER) && !defined(ENABLE_THREADS) diff --git a/src/vm/jit/intrp/intrp.h b/src/vm/jit/intrp/intrp.h index c4e988201..8b1e0da6e 100644 --- a/src/vm/jit/intrp/intrp.h +++ b/src/vm/jit/intrp/intrp.h @@ -1,9 +1,7 @@ /* src/vm/jit/intrp/intrp.h - definitions for Interpreter - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -46,15 +44,14 @@ typedef s8 Cell; typedef s4 Cell; #endif +#include "vm/class.h" #include "vm/global.h" - -#include "vm/jit/codegen-common.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/references.h" +#include "vm/linker.h" +#include "vm/method.h" +#include "vm/references.h" #include "vm/resolve.h" -#include "vmcore/linker.h" + +#include "vm/jit/codegen-common.hpp" typedef void *Label; diff --git a/src/vm/jit/intrp/patcher.c b/src/vm/jit/intrp/patcher.c index a8f7107b2..289958828 100644 --- a/src/vm/jit/intrp/patcher.c +++ b/src/vm/jit/intrp/patcher.c @@ -30,18 +30,17 @@ #include "native/native.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" +#include "vm/options.h" +#include "vm/references.h" +#include "vm/resolve.h" #include "vm/jit/asmpart.h" #include "vm/jit/patcher.h" -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vm/resolve.h" -#include "vmcore/references.h" - /* patcher_get_putstatic ******************************************************* diff --git a/src/vm/jit/intrp/peephole.c b/src/vm/jit/intrp/peephole.c index a190f3504..a22bc3403 100644 --- a/src/vm/jit/intrp/peephole.c +++ b/src/vm/jit/intrp/peephole.c @@ -27,7 +27,7 @@ #include "vm/jit/intrp/intrp.h" -#include "vmcore/options.h" +#include "vm/options.h" /* the numbers in this struct are primitive indices */ diff --git a/src/vm/jit/ir/Makefile.am b/src/vm/jit/ir/Makefile.am index 4417c43b6..ecfdab365 100644 --- a/src/vm/jit/ir/Makefile.am +++ b/src/vm/jit/ir/Makefile.am @@ -1,6 +1,6 @@ ## src/vm/jit/ir/Makefile.am ## -## Copyright (C) 2007 +## Copyright (C) 2007, 2008 ## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO ## ## This file is part of CACAO. @@ -20,7 +20,6 @@ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ## 02110-1301, USA. -## Process this file with automake to produce Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) @@ -31,7 +30,12 @@ noinst_LTLIBRARIES = \ libir_la_SOURCES = \ bytecode.c \ - bytecode.h + bytecode.h \ + icmd.cpp \ + icmd.hpp \ + icmdtable.inc \ + instruction.cpp \ + instruction.hpp ## Local variables: diff --git a/src/vm/jit/ir/icmd.cpp b/src/vm/jit/ir/icmd.cpp new file mode 100644 index 000000000..d0c5057cc --- /dev/null +++ b/src/vm/jit/ir/icmd.cpp @@ -0,0 +1,79 @@ +/* src/vm/jit/ir/icmd.cpp - Intermediate Commands + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "vm/jit/ir/icmd.hpp" + + +/* the ICMD table ************************************************************/ + +#if !defined(NDEBUG) +#define N(name) name, +#else +#define N(name) +#endif + +/* abbreviations for flags */ + +#define PEI ICMDTABLE_PEI +#define CALLS ICMDTABLE_CALLS + +/* some machine dependent values */ + +#if SUPPORT_DIVISION +#define IDIV_CALLS 0 +#else +#define IDIV_CALLS ICMDTABLE_CALLS +#endif + +#if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) +#define LDIV_CALLS 0 +#else +#define LDIV_CALLS ICMDTABLE_CALLS +#endif + +/* include the actual table */ + +icmdtable_entry_t icmd_table[256] = { +#include "vm/jit/ir/icmdtable.inc" +}; + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/ir/icmd.hpp b/src/vm/jit/ir/icmd.hpp new file mode 100644 index 000000000..34557be37 --- /dev/null +++ b/src/vm/jit/ir/icmd.hpp @@ -0,0 +1,418 @@ +/* src/vm/jit/ir/icmd.hpp - Intermediate Commands + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _ICMD_HPP +#define _ICMD_HPP + +#include "config.h" + +#include + +#include "vm/jit/ir/bytecode.h" + + +// JavaVM operation codes (sorted). +enum { + ICMD_NOP = BC_nop, + + ICMD_ACONST = BC_aconst_null, + + ICMD_CHECKNULL = 2, + + ICMD_ICONST = BC_iconst_0, + + /* 3 */ + /* 4 */ + + ICMD_IDIVPOW2 = 5, + ICMD_LDIVPOW2 = 6, + + /* 7 */ + /* 8 */ + + ICMD_LCONST = BC_lconst_0, + + ICMD_LCMPCONST = 10, + + ICMD_FCONST = BC_fconst_0, + + /* 12 */ + /* 13 */ + + ICMD_DCONST = BC_dconst_0, + + ICMD_COPY = 15, + ICMD_MOVE = 16, + + /* 17 */ + /* 18 */ + /* 19 */ + /* 20 */ + + /* Order of LOAD instructions must be equal to order of TYPE_* + defines. */ + + ICMD_ILOAD = BC_iload, + ICMD_LLOAD = BC_lload, + ICMD_FLOAD = BC_fload, + ICMD_DLOAD = BC_dload, + ICMD_ALOAD = BC_aload, + + ICMD_IADDCONST = 26, + ICMD_ISUBCONST = 27, + ICMD_IMULCONST = 28, + ICMD_IANDCONST = 29, + ICMD_IORCONST = 30, + ICMD_IXORCONST = 31, + + ICMD_ISHLCONST = 32, + ICMD_ISHRCONST = 33, + ICMD_IUSHRCONST = 34, + + ICMD_IREMPOW2 = 35, + + ICMD_LADDCONST = 36, + ICMD_LSUBCONST = 37, + ICMD_LMULCONST = 38, + ICMD_LANDCONST = 39, + ICMD_LORCONST = 40, + ICMD_LXORCONST = 41, + + ICMD_LSHLCONST = 42, + ICMD_LSHRCONST = 43, + ICMD_LUSHRCONST = 44, + + ICMD_LREMPOW2 = 45, + + ICMD_IALOAD = BC_iaload, + ICMD_LALOAD = BC_laload, + ICMD_FALOAD = BC_faload, + ICMD_DALOAD = BC_daload, + ICMD_AALOAD = BC_aaload, + ICMD_BALOAD = BC_baload, + ICMD_CALOAD = BC_caload, + ICMD_SALOAD = BC_saload, + + /* Order of STORE instructions must be equal to order of TYPE_* + defines. */ + + ICMD_ISTORE = BC_istore, + ICMD_LSTORE = BC_lstore, + ICMD_FSTORE = BC_fstore, + ICMD_DSTORE = BC_dstore, + ICMD_ASTORE = BC_astore, + + ICMD_IF_LEQ = 59, + ICMD_IF_LNE = 60, + ICMD_IF_LLT = 61, + ICMD_IF_LGE = 62, + ICMD_IF_LGT = 63, + ICMD_IF_LLE = 64, + + ICMD_IF_LCMPEQ = 65, + ICMD_IF_LCMPNE = 66, + ICMD_IF_LCMPLT = 67, + ICMD_IF_LCMPGE = 68, + ICMD_IF_LCMPGT = 69, + ICMD_IF_LCMPLE = 70, + + /* 71 */ + /* 72 */ + /* 73 */ + /* 74 */ + /* 75 */ + /* 76 */ + /* 77 */ + /* 78 */ + + ICMD_IASTORE = BC_iastore, + ICMD_LASTORE = BC_lastore, + ICMD_FASTORE = BC_fastore, + ICMD_DASTORE = BC_dastore, + ICMD_AASTORE = BC_aastore, + ICMD_BASTORE = BC_bastore, + ICMD_CASTORE = BC_castore, + ICMD_SASTORE = BC_sastore, + + ICMD_POP = BC_pop, + ICMD_POP2 = BC_pop2, + ICMD_DUP = BC_dup, + ICMD_DUP_X1 = BC_dup_x1, + ICMD_DUP_X2 = BC_dup_x2, + ICMD_DUP2 = BC_dup2, + ICMD_DUP2_X1 = BC_dup2_x1, + ICMD_DUP2_X2 = BC_dup2_x2, + ICMD_SWAP = BC_swap, + + ICMD_IADD = BC_iadd, + ICMD_LADD = BC_ladd, + ICMD_FADD = BC_fadd, + ICMD_DADD = BC_dadd, + + ICMD_ISUB = BC_isub, + ICMD_LSUB = BC_lsub, + ICMD_FSUB = BC_fsub, + ICMD_DSUB = BC_dsub, + + ICMD_IMUL = BC_imul, + ICMD_LMUL = BC_lmul, + ICMD_FMUL = BC_fmul, + ICMD_DMUL = BC_dmul, + + ICMD_IDIV = BC_idiv, + ICMD_LDIV = BC_ldiv, + ICMD_FDIV = BC_fdiv, + ICMD_DDIV = BC_ddiv, + + ICMD_IREM = BC_irem, + ICMD_LREM = BC_lrem, + ICMD_FREM = BC_frem, + ICMD_DREM = BC_drem, + + ICMD_INEG = BC_ineg, + ICMD_LNEG = BC_lneg, + ICMD_FNEG = BC_fneg, + ICMD_DNEG = BC_dneg, + + ICMD_ISHL = BC_ishl, + ICMD_LSHL = BC_lshl, + ICMD_ISHR = BC_ishr, + ICMD_LSHR = BC_lshr, + ICMD_IUSHR = BC_iushr, + ICMD_LUSHR = BC_lushr, + + ICMD_IAND = BC_iand, + ICMD_LAND = BC_land, + ICMD_IOR = BC_ior, + ICMD_LOR = BC_lor, + ICMD_IXOR = BC_ixor, + ICMD_LXOR = BC_lxor, + + ICMD_IINC = BC_iinc, + + ICMD_I2L = BC_i2l, + ICMD_I2F = BC_i2f, + ICMD_I2D = BC_i2d, + ICMD_L2I = BC_l2i, + ICMD_L2F = BC_l2f, + ICMD_L2D = BC_l2d, + ICMD_F2I = BC_f2i, + ICMD_F2L = BC_f2l, + ICMD_F2D = BC_f2d, + ICMD_D2I = BC_d2i, + ICMD_D2L = BC_d2l, + ICMD_D2F = BC_d2f, + + ICMD_INT2BYTE = BC_int2byte, + ICMD_INT2CHAR = BC_int2char, + ICMD_INT2SHORT = BC_int2short, + + ICMD_LCMP = BC_lcmp, + ICMD_FCMPL = BC_fcmpl, + ICMD_FCMPG = BC_fcmpg, + ICMD_DCMPL = BC_dcmpl, + ICMD_DCMPG = BC_dcmpg, + + ICMD_IFEQ = BC_ifeq, + ICMD_IFNE = BC_ifne, + ICMD_IFLT = BC_iflt, + ICMD_IFGE = BC_ifge, + ICMD_IFGT = BC_ifgt, + ICMD_IFLE = BC_ifle, + + ICMD_IF_ICMPEQ = BC_if_icmpeq, + ICMD_IF_ICMPNE = BC_if_icmpne, + ICMD_IF_ICMPLT = BC_if_icmplt, + ICMD_IF_ICMPGE = BC_if_icmpge, + ICMD_IF_ICMPGT = BC_if_icmpgt, + ICMD_IF_ICMPLE = BC_if_icmple, + ICMD_IF_ACMPEQ = BC_if_acmpeq, + ICMD_IF_ACMPNE = BC_if_acmpne, + + ICMD_GOTO = BC_goto, + ICMD_JSR = BC_jsr, + ICMD_RET = BC_ret, + + ICMD_TABLESWITCH = BC_tableswitch, + ICMD_LOOKUPSWITCH = BC_lookupswitch, + + ICMD_IRETURN = BC_ireturn, + ICMD_LRETURN = BC_lreturn, + ICMD_FRETURN = BC_freturn, + ICMD_DRETURN = BC_dreturn, + ICMD_ARETURN = BC_areturn, + ICMD_RETURN = BC_return, + + ICMD_GETSTATIC = BC_getstatic, + ICMD_PUTSTATIC = BC_putstatic, + ICMD_GETFIELD = BC_getfield, + ICMD_PUTFIELD = BC_putfield, + + ICMD_INVOKEVIRTUAL = BC_invokevirtual, + ICMD_INVOKESPECIAL = BC_invokespecial, + ICMD_INVOKESTATIC = BC_invokestatic, + ICMD_INVOKEINTERFACE = BC_invokeinterface, + + /* 186 */ + + ICMD_NEW = BC_new, + ICMD_NEWARRAY = BC_newarray, + ICMD_ANEWARRAY = BC_anewarray, + + ICMD_ARRAYLENGTH = BC_arraylength, + + ICMD_ATHROW = BC_athrow, + + ICMD_CHECKCAST = BC_checkcast, + ICMD_INSTANCEOF = BC_instanceof, + + ICMD_MONITORENTER = BC_monitorenter, + ICMD_MONITOREXIT = BC_monitorexit, + + /* 196 */ + + ICMD_MULTIANEWARRAY = BC_multianewarray, + + ICMD_IFNULL = BC_ifnull, + ICMD_IFNONNULL = BC_ifnonnull, + + /* 200 */ + /* 201 */ + /* 202 */ + + ICMD_IASTORECONST = 204, + ICMD_LASTORECONST = 205, + ICMD_FASTORECONST = 206, + ICMD_DASTORECONST = 207, + ICMD_AASTORECONST = 208, + ICMD_BASTORECONST = 209, + ICMD_CASTORECONST = 210, + ICMD_SASTORECONST = 211, + + ICMD_PUTSTATICCONST = 212, + ICMD_PUTFIELDCONST = 213, + + ICMD_IMULPOW2 = 214, + ICMD_LMULPOW2 = 215, + + ICMD_GETEXCEPTION = 249, + ICMD_PHI = 250, + + ICMD_INLINE_START = 251, /* instruction before inlined method */ + ICMD_INLINE_END = 252, /* instruction after inlined method */ + ICMD_INLINE_BODY = 253, /* start of inlined body */ + + ICMD_BUILTIN = 255 /* internal opcode */ +}; + + +/* data-flow constants for the ICMD table ************************************/ + +#define DF_0_TO_0 0 +#define DF_1_TO_0 1 +#define DF_2_TO_0 2 +#define DF_3_TO_0 3 + +#define DF_DST_BASE 4 /* from this value on, iptr->dst is a variable */ + +#define DF_0_TO_1 (DF_DST_BASE + 0) +#define DF_1_TO_1 (DF_DST_BASE + 1) +#define DF_2_TO_1 (DF_DST_BASE + 2) +#define DF_3_TO_1 (DF_DST_BASE + 3) +#define DF_N_TO_1 (DF_DST_BASE + 4) + +#define DF_INVOKE (DF_DST_BASE + 5) +#define DF_BUILTIN (DF_DST_BASE + 6) + +#define DF_COPY (DF_DST_BASE + 7) +#define DF_MOVE (DF_DST_BASE + 8) + +#define DF_DUP -1 +#define DF_DUP_X1 -1 +#define DF_DUP_X2 -1 +#define DF_DUP2 -1 +#define DF_DUP2_X1 -1 +#define DF_DUP2_X2 -1 +#define DF_SWAP -1 + +/* special data-flow recognized by verify/generate.pl: */ +#define DF_LOAD DF_COPY +#define DF_STORE DF_MOVE +#define DF_IINC DF_1_TO_1 +#define DF_POP DF_1_TO_0 +#define DF_POP2 DF_2_TO_0 + + +// Control-flow constants for the ICMD table. +#define CF_NORMAL 0 +#define CF_IF 1 + +#define CF_END_BASE 2 /* from here on, they mark the end of a superblock */ + +#define CF_END (CF_END_BASE + 0) +#define CF_GOTO (CF_END_BASE + 1) +#define CF_TABLE (CF_END_BASE + 2) +#define CF_LOOKUP (CF_END_BASE + 3) +#define CF_JSR (CF_END_BASE + 4) +#define CF_RET (CF_END_BASE + 5) + + +// Flag constants for the ICMD table. +#define ICMDTABLE_PEI 0x0001 /* ICMD may throw an exception */ +#define ICMDTABLE_CALLS 0x0002 /* needs registers to be saved, may call */ + + +// ICMD table entry. +typedef struct icmdtable_entry_t icmdtable_entry_t; + +struct icmdtable_entry_t { +#if !defined(NDEBUG) + const char* name; /* name, without ICMD_ prefix */ +#endif + int32_t dataflow; /* a DF_ constant, see above */ + int32_t controlflow; /* a CF_ constant, see above */ + int32_t flags; /* a combination of ICMDTABLE_ flags */ +}; + + +// The ICMD table. +extern icmdtable_entry_t icmd_table[256]; + +#endif // _ICMD_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/ir/icmdtable.inc b/src/vm/jit/ir/icmdtable.inc new file mode 100644 index 000000000..4b0639cdc --- /dev/null +++ b/src/vm/jit/ir/icmdtable.inc @@ -0,0 +1,310 @@ +/*** The ICMD Table ***/ + +/* IMPORTANT: This file must be in a fixed format, as it is both included in */ +/* src/vm/jit/jit.c, and parsed by src/vm/jit/verify/generate.pl! */ +/* */ +/* The comments at the start of the line and inside the braces are */ +/* significant. If you want to add a comment to an ICMD, do that after the */ +/* comma, or brace, at the end of the line. */ +/* */ +/* The format is as follows (slashes reversed for obvious reasons): */ +/* */ +/* \*#*\ { N( name ) data-flow, control-flow, flags \* stage (action) *\ } */ +/* */ +/* ^^^ */ +/* opcode */ +/* */ +/* where */ +/* opcode...........is the opcode number (decimal) */ +/* name.............is the quoted name without the ICMD_ prefix */ +/* data-flow........is one of the DF_ constants (see jit.h) */ +/* control-flow.....is one of the CF_ constants (see jit.h) */ +/* flags............is 0 or a |-combination of */ +/* PEI........may throw an exception */ +/* CALLS......needs saved registers (calls out) */ +/* *_CALLS....see jit.h for architecture specific */ +/* constants to put here */ +/* */ +/* stage............is either empty, or one of */ +/* -- ICMD is not used anywhere after parse */ +/* -S ICMD is eliminated by stack_analyse */ +/* S+ ICMD is introduced by stack_analyse */ +/* */ +/* action...........is the stack action of the ICMD in the notation */ +/* instack--outstack, TOS being rightmost. */ +/* */ +/* Valid type characters are */ +/* I, L, F, D, and A the basic types */ +/* 1 a category 1 type */ +/* 2 a category 2 type */ +/* . variable number of slots */ +/* */ +/* Whitespace is not allowed within the action. */ +/* */ +/* Some ICMDs may have several variants. In this case */ +/* the action is build by joining the individual */ +/* actions of the variants with |. */ +/* */ +/* */ +/* CAUTION: Do not use preprocessor directives in this file! They will */ +/* confuse the generator. */ +/* */ + + +/* 0*/ {N("NOP ") DF_0_TO_0 , CF_NORMAL, 0 /* (--) */}, +/* 1*/ {N("ACONST ") DF_0_TO_1 , CF_NORMAL, PEI /* (--A) */}, +/* 2*/ {N("CHECKNULL ") DF_1_TO_1 , CF_NORMAL, PEI /* (A--A) */}, +/* 3*/ {N("ICONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--I) */}, +/* 4*/ {N("UNDEF4 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 5*/ {N("IDIVPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 6*/ {N("LDIVPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 7*/ {N("UNDEF7 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 8*/ {N("UNDEF8 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 9*/ {N("LCONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--L) */}, +/* 10*/ {N("LCMPCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--I) */}, +/* 11*/ {N("FCONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--F) */}, +/* 12*/ {N("UNDEF12 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 13*/ {N("UNDEF13 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 14*/ {N("DCONST ") DF_0_TO_1 , CF_NORMAL, 0 /* (--D) */}, +/* 15*/ {N("COPY ") DF_COPY , CF_NORMAL, 0 /* S+ (1--1) */}, +/* 16*/ {N("MOVE ") DF_MOVE , CF_NORMAL, 0 /* S+ (1--1) */}, +/* 17*/ {N("UNDEF17 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 18*/ {N("UNDEF18 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 19*/ {N("UNDEF19 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 20*/ {N("UNDEF20 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 21*/ {N("ILOAD ") DF_LOAD , CF_NORMAL, 0 /* (--I) */}, +/* 22*/ {N("LLOAD ") DF_LOAD , CF_NORMAL, 0 /* (--L) */}, +/* 23*/ {N("FLOAD ") DF_LOAD , CF_NORMAL, 0 /* (--F) */}, +/* 24*/ {N("DLOAD ") DF_LOAD , CF_NORMAL, 0 /* (--D) */}, +/* 25*/ {N("ALOAD ") DF_LOAD , CF_NORMAL, 0 /* (--A) */}, +/* 26*/ {N("IADDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 27*/ {N("ISUBCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 28*/ {N("IMULCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 29*/ {N("IANDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 30*/ {N("IORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 31*/ {N("IXORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 32*/ {N("ISHLCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 33*/ {N("ISHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 34*/ {N("IUSHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 35*/ {N("IREMPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/* 36*/ {N("LADDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 37*/ {N("LSUBCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 38*/ {N("LMULCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 39*/ {N("LANDCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 40*/ {N("LORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 41*/ {N("LXORCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 42*/ {N("LSHLCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 43*/ {N("LSHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 44*/ {N("LUSHRCONST ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 45*/ {N("LREMPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/* 46*/ {N("IALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, +/* 47*/ {N("LALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--L) */}, +/* 48*/ {N("FALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--F) */}, +/* 49*/ {N("DALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--D) */}, +/* 50*/ {N("AALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--A) */}, +/* 51*/ {N("BALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, +/* 52*/ {N("CALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, +/* 53*/ {N("SALOAD ") DF_2_TO_1 , CF_NORMAL, PEI /* (AI--I) */}, +/* 54*/ {N("ISTORE ") DF_STORE , CF_NORMAL, 0 /* (I--) */}, +/* 55*/ {N("LSTORE ") DF_STORE , CF_NORMAL, 0 /* (L--) */}, +/* 56*/ {N("FSTORE ") DF_STORE , CF_NORMAL, 0 /* (F--) */}, +/* 57*/ {N("DSTORE ") DF_STORE , CF_NORMAL, 0 /* (D--) */}, +/* 58*/ {N("ASTORE ") DF_STORE , CF_NORMAL, 0 /* (A--|R--) */}, +/* 59*/ {N("IF_LEQ ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, +/* 60*/ {N("IF_LNE ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, +/* 61*/ {N("IF_LLT ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, +/* 62*/ {N("IF_LGE ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, +/* 63*/ {N("IF_LGT ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, +/* 64*/ {N("IF_LLE ") DF_1_TO_0 , CF_IF , 0 /* S+ (L--) */}, +/* 65*/ {N("IF_LCMPEQ ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, +/* 66*/ {N("IF_LCMPNE ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, +/* 67*/ {N("IF_LCMPLT ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, +/* 68*/ {N("IF_LCMPGE ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, +/* 69*/ {N("IF_LCMPGT ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, +/* 70*/ {N("IF_LCMPLE ") DF_2_TO_0 , CF_IF , 0 /* S+ (LL--) */}, +/* 71*/ {N("UNDEF71 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 72*/ {N("UNDEF72 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 73*/ {N("UNDEF73 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 74*/ {N("UNDEF74 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 75*/ {N("UNDEF75 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 76*/ {N("UNDEF76 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 77*/ {N("UNDEF77 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 78*/ {N("UNDEF78 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/* 79*/ {N("IASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, +/* 80*/ {N("LASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AIL--) */}, +/* 81*/ {N("FASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AIF--) */}, +/* 82*/ {N("DASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AID--) */}, +/* 83*/ {N("AASTORE ") DF_3_TO_0 , CF_NORMAL, PEI|CALLS /* (AIA--) */}, +/* 84*/ {N("BASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, +/* 85*/ {N("CASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, +/* 86*/ {N("SASTORE ") DF_3_TO_0 , CF_NORMAL, PEI /* (AII--) */}, +/* 87*/ {N("POP ") DF_POP , CF_NORMAL, 0 /* (1--) */}, +/* 88*/ {N("POP2 ") DF_POP2 , CF_NORMAL, 0 /* (11--|2--) */}, +/* 89*/ {N("DUP ") DF_DUP , CF_NORMAL, 0 /* -S (1--11) */}, +/* 90*/ {N("DUP_X1 ") DF_DUP_X1 , CF_NORMAL, 0 /* -S (11--111) */}, +/* 91*/ {N("DUP_X2 ") DF_DUP_X2 , CF_NORMAL, 0 /* -S (111--1111|21--121) */}, +/* 92*/ {N("DUP2 ") DF_DUP2 , CF_NORMAL, 0 /* -S (11--1111|2--22) */}, +/* 93*/ {N("DUP2_X1 ") DF_DUP2_X1, CF_NORMAL, 0 /* -S (111--11111|12--212) */}, +/* 94*/ {N("DUP2_X2 ") DF_DUP2_X2, CF_NORMAL, 0 /* -S (1111--111111|112--2112|22--222|211--11211) */}, +/* 95*/ {N("SWAP ") DF_SWAP , CF_NORMAL, 0 /* -S (11--11) */}, +/* 96*/ {N("IADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/* 97*/ {N("LADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, +/* 98*/ {N("FADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, +/* 99*/ {N("DADD ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, +/*100*/ {N("ISUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*101*/ {N("LSUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, +/*102*/ {N("FSUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, +/*103*/ {N("DSUB ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, +/*104*/ {N("IMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*105*/ {N("LMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, +/*106*/ {N("FMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, +/*107*/ {N("DMUL ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, +/*108*/ {N("IDIV ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /* (II--I) */}, +/*109*/ {N("LDIV ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /* (LL--L) */}, +/*110*/ {N("FDIV ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, +/*111*/ {N("DDIV ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, +/*112*/ {N("IREM ") DF_2_TO_1 , CF_NORMAL, PEI|IDIV_CALLS /* (II--I) */}, +/*113*/ {N("LREM ") DF_2_TO_1 , CF_NORMAL, PEI|LDIV_CALLS /* (LL--L) */}, +/*114*/ {N("FREM ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--F) */}, +/*115*/ {N("DREM ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--D) */}, +/*116*/ {N("INEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, +/*117*/ {N("LNEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--L) */}, +/*118*/ {N("FNEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--F) */}, +/*119*/ {N("DNEG ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--D) */}, +/*120*/ {N("ISHL ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*121*/ {N("LSHL ") DF_2_TO_1 , CF_NORMAL, 0 /* (LI--L) */}, +/*122*/ {N("ISHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*123*/ {N("LSHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LI--L) */}, +/*124*/ {N("IUSHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*125*/ {N("LUSHR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LI--L) */}, +/*126*/ {N("IAND ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*127*/ {N("LAND ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, +/*128*/ {N("IOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*129*/ {N("LOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, +/*130*/ {N("IXOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (II--I) */}, +/*131*/ {N("LXOR ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--L) */}, +/*132*/ {N("IINC ") DF_IINC , CF_NORMAL, 0 /* (--) */}, +/*133*/ {N("I2L ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--L) */}, +/*134*/ {N("I2F ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--F) */}, +/*135*/ {N("I2D ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--D) */}, +/*136*/ {N("L2I ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--I) */}, +/*137*/ {N("L2F ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--F) */}, +/*138*/ {N("L2D ") DF_1_TO_1 , CF_NORMAL, 0 /* (L--D) */}, +/*139*/ {N("F2I ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--I) */}, +/*140*/ {N("F2L ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--L) */}, +/*141*/ {N("F2D ") DF_1_TO_1 , CF_NORMAL, 0 /* (F--D) */}, +/*142*/ {N("D2I ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--I) */}, +/*143*/ {N("D2L ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--L) */}, +/*144*/ {N("D2F ") DF_1_TO_1 , CF_NORMAL, 0 /* (D--F) */}, +/*145*/ {N("INT2BYTE ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, +/*146*/ {N("INT2CHAR ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, +/*147*/ {N("INT2SHORT ") DF_1_TO_1 , CF_NORMAL, 0 /* (I--I) */}, +/*148*/ {N("LCMP ") DF_2_TO_1 , CF_NORMAL, 0 /* (LL--I) */}, +/*149*/ {N("FCMPL ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--I) */}, +/*150*/ {N("FCMPG ") DF_2_TO_1 , CF_NORMAL, 0 /* (FF--I) */}, +/*151*/ {N("DCMPL ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--I) */}, +/*152*/ {N("DCMPG ") DF_2_TO_1 , CF_NORMAL, 0 /* (DD--I) */}, +/*153*/ {N("IFEQ ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, +/*154*/ {N("IFNE ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, +/*155*/ {N("IFLT ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, +/*156*/ {N("IFGE ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, +/*157*/ {N("IFGT ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, +/*158*/ {N("IFLE ") DF_1_TO_0 , CF_IF , 0 /* (I--) */}, +/*159*/ {N("IF_ICMPEQ ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, +/*160*/ {N("IF_ICMPNE ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, +/*161*/ {N("IF_ICMPLT ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, +/*162*/ {N("IF_ICMPGE ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, +/*163*/ {N("IF_ICMPGT ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, +/*164*/ {N("IF_ICMPLE ") DF_2_TO_0 , CF_IF , 0 /* (II--) */}, +/*165*/ {N("IF_ACMPEQ ") DF_2_TO_0 , CF_IF , 0 /* (AA--) */}, +/*166*/ {N("IF_ACMPNE ") DF_2_TO_0 , CF_IF , 0 /* (AA--) */}, +/*167*/ {N("GOTO ") DF_0_TO_0 , CF_GOTO , 0 /* (--) */}, +/*168*/ {N("JSR ") DF_0_TO_1 , CF_JSR , 0 /* (--R) */}, +/*169*/ {N("RET ") DF_0_TO_0 , CF_RET , 0 /* (--) */}, +/*170*/ {N("TABLESWITCH ") DF_1_TO_0 , CF_TABLE , 0 /* (I--) */}, +/*171*/ {N("LOOKUPSWITCH ") DF_1_TO_0 , CF_LOOKUP, 0 /* (I--) */}, +/*172*/ {N("IRETURN ") DF_1_TO_0 , CF_END , 0 /* (I--) */}, +/*173*/ {N("LRETURN ") DF_1_TO_0 , CF_END , 0 /* (L--) */}, +/*174*/ {N("FRETURN ") DF_1_TO_0 , CF_END , 0 /* (F--) */}, +/*175*/ {N("DRETURN ") DF_1_TO_0 , CF_END , 0 /* (D--) */}, +/*176*/ {N("ARETURN ") DF_1_TO_0 , CF_END , PEI /* (A--) */}, +/*177*/ {N("RETURN ") DF_0_TO_0 , CF_END , 0 /* (--) */}, +/*178*/ {N("GETSTATIC ") DF_0_TO_1 , CF_NORMAL, PEI /* (--1|--2) */}, +/*179*/ {N("PUTSTATIC ") DF_1_TO_0 , CF_NORMAL, PEI /* (1--|2--) */}, +/*180*/ {N("GETFIELD ") DF_1_TO_1 , CF_NORMAL, PEI /* (A--1|A--2) */}, +/*181*/ {N("PUTFIELD ") DF_2_TO_0 , CF_NORMAL, PEI /* (A1--|A2--) */}, +/*182*/ {N("INVOKEVIRTUAL ") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, +/*183*/ {N("INVOKESPECIAL ") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, +/*184*/ {N("INVOKESTATIC ") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, +/*185*/ {N("INVOKEINTERFACE") DF_INVOKE , CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */}, +/*186*/ {N("UNDEF186 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*187*/ {N("NEW ") DF_0_TO_1 , CF_NORMAL, PEI /* -- (--A) */}, +/*188*/ {N("NEWARRAY ") DF_0_TO_1 , CF_NORMAL, PEI /* -- (--A) */}, +/*189*/ {N("ANEWARRAY ") DF_0_TO_1 , CF_NORMAL, PEI /* -- (--A) */}, +/*190*/ {N("ARRAYLENGTH ") DF_1_TO_1 , CF_NORMAL, PEI /* (A--I) */}, +/*191*/ {N("ATHROW ") DF_1_TO_0 , CF_END , PEI /* (A--) */}, +/*192*/ {N("CHECKCAST ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS /* (A--A) */}, +/*193*/ {N("INSTANCEOF ") DF_1_TO_1 , CF_NORMAL, PEI|CALLS /* (A--I) */}, +/*194*/ {N("MONITORENTER ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS /* -- (A--) */}, +/*195*/ {N("MONITOREXIT ") DF_1_TO_0 , CF_NORMAL, PEI|CALLS /* -- (A--) */}, +/*196*/ {N("UNDEF196 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*197*/ {N("MULTIANEWARRAY ") DF_N_TO_1 , CF_NORMAL, PEI|CALLS /* (.--A) */}, +/*198*/ {N("IFNULL ") DF_1_TO_0 , CF_IF , 0 /* (A--) */}, +/*199*/ {N("IFNONNULL ") DF_1_TO_0 , CF_IF , 0 /* (A--) */}, +/*200*/ {N("UNDEF200 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*201*/ {N("UNDEF201 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*202*/ {N("UNDEF202 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*203*/ {N("UNDEF203 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*204*/ {N("IASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*205*/ {N("LASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*206*/ {N("FASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*207*/ {N("DASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*208*/ {N("AASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*209*/ {N("BASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*210*/ {N("CASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*211*/ {N("SASTORECONST ") DF_2_TO_0 , CF_NORMAL, PEI /* S+ (AI--) */}, +/*212*/ {N("PUTSTATICCONST ") DF_0_TO_0 , CF_NORMAL, PEI /* S+ (--) */}, +/*213*/ {N("PUTFIELDCONST ") DF_1_TO_0 , CF_NORMAL, PEI /* S+ (A--) */}, +/*214*/ {N("IMULPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (I--I) */}, +/*215*/ {N("LMULPOW2 ") DF_1_TO_1 , CF_NORMAL, 0 /* S+ (L--L) */}, +/*216*/ {N("IF_FCMPEQ ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*217*/ {N("IF_FCMPNE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*218*/ {N("IF_FCMPL_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*219*/ {N("IF_FCMPL_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*220*/ {N("IF_FCMPL_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*221*/ {N("IF_FCMPL_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*222*/ {N("IF_FCMPG_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*223*/ {N("IF_FCMPG_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*224*/ {N("IF_FCMPG_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*225*/ {N("IF_FCMPG_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*226*/ {N("IF_DCMPEQ ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*227*/ {N("IF_DCMPNE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*228*/ {N("IF_DCMPL_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*229*/ {N("IF_DCMPL_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*230*/ {N("IF_DCMPL_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*231*/ {N("IF_DCMPL_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*232*/ {N("IF_DCMPG_LT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*233*/ {N("IF_DCMPG_GE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*234*/ {N("IF_DCMPG_GT ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*235*/ {N("IF_DCMPG_LE ") DF_0_TO_0 , CF_IF , 0 /* -- () */}, +/*236*/ {N("UNDEF236 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*237*/ {N("UNDEF237 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*238*/ {N("UNDEF238 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*239*/ {N("UNDEF239 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*240*/ {N("UNDEF240 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*241*/ {N("UNDEF241 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*242*/ {N("UNDEF242 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*243*/ {N("UNDEF243 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*244*/ {N("UNDEF244 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*245*/ {N("UNDEF245 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*246*/ {N("UNDEF246 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*247*/ {N("UNDEF247 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*248*/ {N("UNDEF248 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*249*/ {N("GETEXCEPTION ") DF_0_TO_1 , CF_NORMAL, 0 /* -- () */}, +/*250*/ {N("PHI ") DF_N_TO_1 , CF_NORMAL, 0 /* -- () */}, +/*251*/ {N("INLINE_START ") DF_0_TO_0 , CF_NORMAL, 0 /* S+ (--) */}, +/*252*/ {N("INLINE_END ") DF_0_TO_0 , CF_NORMAL, 0 /* S+ (--) */}, +/*253*/ {N("INLINE_BODY ") DF_0_TO_0 , CF_NORMAL, 0 /* S+ (--) */}, +/*254*/ {N("UNDEF254 ") DF_0_TO_0 , CF_NORMAL, 0 /* -- () */}, +/*255*/ {N("BUILTIN ") DF_BUILTIN, CF_NORMAL, PEI|CALLS /* (.--1|.--2|.--) */} + diff --git a/src/vm/jit/ir/instruction.cpp b/src/vm/jit/ir/instruction.cpp new file mode 100644 index 000000000..9be1a6fdf --- /dev/null +++ b/src/vm/jit/ir/instruction.cpp @@ -0,0 +1,66 @@ +/* src/vm/jit/ir/instruction.cpp - IR instruction + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "vm/descriptor.h" + +#include "vm/jit/ir/instruction.hpp" + + +// REMOVEME +extern "C" { + +methoddesc* instruction_call_site(const instruction* iptr) +{ + if (iptr->opc == ICMD_BUILTIN) { + return iptr->sx.s23.s3.bte->md; + } + else if (INSTRUCTION_IS_UNRESOLVED(iptr)) { + return iptr->sx.s23.s3.um->methodref->parseddesc.md; + } + else { + return iptr->sx.s23.s3.fmiref->p.method->parseddesc; + } +} + +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/ir/instruction.hpp b/src/vm/jit/ir/instruction.hpp new file mode 100644 index 000000000..c9f3e3075 --- /dev/null +++ b/src/vm/jit/ir/instruction.hpp @@ -0,0 +1,277 @@ +/* src/vm/jit/ir/instruction.hpp - IR instruction + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _INSTRUCTION_HPP +#define _INSTRUCTION_HPP + +// Forward typedefs. +typedef struct instruction instruction; +typedef struct insinfo_inline insinfo_inline; + + +#include "config.h" + +#include + +#include "vm/descriptor.h" + +#include "vm/jit/jit.hpp" +#include "vm/jit/replace.hpp" + +#include "vm/jit/ir/icmd.hpp" + + +#ifdef __cplusplus +extern "C" { +#endif + +// Instruction structure. + +/* branch_target_t: used in TABLESWITCH tables */ + +typedef union { + int32_t insindex; /* used in parse */ + basicblock *block; /* valid after parse */ +} branch_target_t; + +/* lookup_target_t: used in LOOKUPSWITCH tables */ + +typedef struct { + int32_t value; /* case value */ + branch_target_t target; /* branch target, see above */ +} lookup_target_t; + +/*** s1 operand ***/ + +typedef union { + int32_t varindex; + int32_t argcount; +} s1_operand_t; + +/*** s2 operand ***/ + +typedef union { + int32_t varindex; + int32_t *args; + classref_or_classinfo c; + unresolved_class *uc; + uintptr_t constval; /* for PUT*CONST */ + int32_t tablelow; /* for TABLESWITCH */ + uint32_t lookupcount; /* for LOOKUPSWITCH */ + int32_t retaddrnr; /* for ASTORE */ + instruction **iargs; /* for PHI */ +} s2_operand_t; + +/*** s3 operand ***/ + +typedef union { + int32_t varindex; + uintptr_t constval; + classref_or_classinfo c; + constant_FMIref *fmiref; + unresolved_method *um; + unresolved_field *uf; + insinfo_inline *inlineinfo; /* for INLINE_START/END */ + int32_t tablehigh; /* for TABLESWITCH */ + branch_target_t lookupdefault; /* for LOOKUPSWITCH */ + branch_target_t jsrtarget; /* for JSR */ + int32_t javaindex; /* for *STORE */ + struct builtintable_entry *bte; +} s3_operand_t; + +/*** val operand ***/ + +typedef union { + int32_t i; + int64_t l; + float f; + double d; + void *anyptr; + java_handle_t *stringconst; /* for ACONST with string */ + classref_or_classinfo c; /* for ACONST with class */ +} val_operand_t; + +/*** dst operand ***/ + +typedef union { + int32_t varindex; + basicblock *block; /* valid after parse */ + branch_target_t *table; /* for TABLESWITCH */ + lookup_target_t *lookup; /* for LOOKUPSWITCH */ + int32_t insindex; /* used in parse */ +} dst_operand_t; + +/*** flags (32 bits) ***/ + +#define INS_FLAG_BASICBLOCK 0x01 /* marks a basic block start */ +#define INS_FLAG_UNRESOLVED 0x02 /* contains unresolved field/meth/class*/ +#define INS_FLAG_CLASS 0x04 /* for ACONST, PUT*CONST with class */ +#define INS_FLAG_ARRAY 0x08 /* for CHECKCAST/INSTANCEOF with array */ +#define INS_FLAG_CHECK 0x10 /* for *ALOAD|*ASTORE: check index */ + /* for BUILTIN: check exception */ +#define INS_FLAG_KILL_PREV 0x04 /* for *STORE, invalidate prev local */ +#define INS_FLAG_KILL_NEXT 0x08 /* for *STORE, invalidate next local */ +#define INS_FLAG_RETADDR 0x10 /* for ASTORE: op is a returnAddress */ + +#define INS_FLAG_ID_SHIFT 5 +#define INS_FLAG_ID_MASK (~0 << INS_FLAG_ID_SHIFT) + +typedef union { + u4 bits; +} flags_operand_t; + + +// Instruction. + +/* The instruction format for the intermediate representation: */ + +struct instruction { + u2 opc; /* opcode */ + u2 line; /* line number */ +#if SIZEOF_VOID_P == 8 + flags_operand_t flags; /* 4 bytes */ +#endif + s1_operand_t s1; /* pointer-size */ + union { + struct { + s2_operand_t s2; /* pointer-size */ + s3_operand_t s3; /* pointer-size */ + } s23; /* XOR */ + val_operand_t val; /* long-size */ + } sx; + dst_operand_t dst; /* pointer-size */ +#if SIZEOF_VOID_P == 4 + flags_operand_t flags; /* 4 bytes */ +#endif +#if defined(ENABLE_ESCAPE_REASON) + void *escape_reasons; +#endif +}; + + +#define INSTRUCTION_STARTS_BASICBLOCK(iptr) \ + ((iptr)->flags.bits & INS_FLAG_BASICBLOCK) + +#define INSTRUCTION_IS_RESOLVED(iptr) \ + (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED)) + +#define INSTRUCTION_IS_UNRESOLVED(iptr) \ + ((iptr)->flags.bits & INS_FLAG_UNRESOLVED) + +#define INSTRUCTION_MUST_CHECK(iptr) \ + ((iptr)->flags.bits & INS_FLAG_CHECK) + +#define INSTRUCTION_GET_FIELDREF(iptr,fref) \ + do { \ + if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \ + fref = iptr->sx.s23.s3.uf->fieldref; \ + else \ + fref = iptr->sx.s23.s3.fmiref; \ + } while (0) + +#define INSTRUCTION_GET_METHODREF(iptr,mref) \ + do { \ + if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \ + mref = iptr->sx.s23.s3.um->methodref; \ + else \ + mref = iptr->sx.s23.s3.fmiref; \ + } while (0) + +#define INSTRUCTION_GET_METHODDESC(iptr, md) \ + do { \ + if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \ + md = iptr->sx.s23.s3.um->methodref->parseddesc.md; \ + else \ + md = iptr->sx.s23.s3.fmiref->parseddesc.md; \ + } while (0) + + +/* additional info structs for special instructions ***************************/ + +/* for ICMD_INLINE_START and ICMD_INLINE_END */ + +struct insinfo_inline { + /* fields copied from the inlining tree ----------------------------------*/ + insinfo_inline *parent; /* insinfo of the surrounding inlining, if any*/ + methodinfo *method; /* the inlined method starting/ending here */ + methodinfo *outer; /* the outer method suspended/resumed here */ + int32_t synclocal; /* local index used for synchronization */ + bool synchronize; /* true if synchronization is needed */ + int32_t throughcount; /* total # of pass-through variables */ + int32_t paramcount; /* number of parameters of original call */ + int32_t stackvarscount; /* source stackdepth at INLINE_START */ + int32_t *stackvars; /* stack vars at INLINE_START */ + + /* fields set by inlining ------------------------------------------------*/ + int32_t *javalocals_start; /* javalocals at start of inlined body */ + int32_t *javalocals_end; /* javalocals after inlined body */ + + /* fields set by replacement point creation ------------------------------*/ +#if defined(ENABLE_REPLACEMENT) + rplpoint *rp; /* replacement point at INLINE_START */ +#endif + + /* fields set by the codegen ---------------------------------------------*/ + int32_t startmpc; /* machine code offset of start of inlining */ +}; + + +/* Additional instruction accessors */ + +methoddesc* instruction_call_site(const instruction* iptr); + +static inline bool instruction_has_dst(const instruction* iptr) +{ + if ( + (icmd_table[iptr->opc].dataflow == DF_INVOKE) || + (icmd_table[iptr->opc].dataflow == DF_BUILTIN) + ) { + return instruction_call_site(iptr)->returntype.type != TYPE_VOID; + } + else { + return icmd_table[iptr->opc].dataflow >= DF_DST_BASE; + } +} + +#ifdef __cplusplus +} +#endif + +#endif // _INSTRUCTION_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/jit.c b/src/vm/jit/jit.c deleted file mode 100644 index e6f17c2d8..000000000 --- a/src/vm/jit/jit.c +++ /dev/null @@ -1,1215 +0,0 @@ -/* src/vm/jit/jit.c - calls the code generation functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "md.h" - -#include "mm/memory.h" - -#include "native/native.h" - -#include "toolbox/logging.h" - -#include "threads/lock-common.h" - -#include "vm/global.h" -#include "vm/initialize.h" - -#include "vm/jit/asmpart.h" - -#include "vm/jit/cfg.h" - -#include "vm/jit/codegen-common.h" -#include "vm/jit/disass.h" -#include "vm/jit/dseg.h" -#include "vm/jit/jit.h" -#include "vm/jit/parse.h" -#include "vm/jit/reg.h" - -#include "vm/jit/show.h" -#include "vm/jit/stack.h" - -#include "vm/jit/allocator/simplereg.h" -#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA) -# include "vm/jit/allocator/lsra.h" -#endif - -#if defined(ENABLE_SSA) -# include "vm/jit/optimizing/lsra.h" -# include "vm/jit/optimizing/ssa.h" -#endif - -#if defined(ENABLE_INLINING) -# include "vm/jit/inline/inline.h" -#endif - -#include "vm/jit/ir/bytecode.h" - -#include "vm/jit/loop/analyze.h" -#include "vm/jit/loop/graph.h" -#include "vm/jit/loop/loop.h" - -#if defined(ENABLE_IFCONV) -# include "vm/jit/optimizing/ifconv.h" -#endif - -#include "vm/jit/optimizing/reorder.h" - -#if defined(ENABLE_PYTHON) -# include "vm/jit/python.h" -#endif - -#include "vm/jit/verify/typecheck.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/rt-timing.h" -#include "vmcore/statistics.h" - - -/* debug macros ***************************************************************/ - -#if !defined(NDEBUG) -#define DEBUG_JIT_COMPILEVERBOSE(x) \ - do { \ - if (compileverbose) { \ - log_message_method(x, m); \ - } \ - } while (0) -#else -#define DEBUG_JIT_COMPILEVERBOSE(x) /* nothing */ -#endif - -#if !defined(NDEBUG) -# define TRACECOMPILERCALLS() \ - do { \ - if (opt_TraceCompilerCalls) { \ - log_start(); \ - log_print("[JIT compiler started: method="); \ - method_print(m); \ - log_print("]"); \ - log_finish(); \ - } \ - } while (0) -#else -# define TRACECOMPILERCALLS() -#endif - - -/* the ICMD table ************************************************************/ - -#if !defined(NDEBUG) -#define N(name) name, -#else -#define N(name) -#endif - -/* abbreviations for flags */ - -#define PEI ICMDTABLE_PEI -#define CALLS ICMDTABLE_CALLS - -/* some machine dependent values */ - -#if SUPPORT_DIVISION -#define IDIV_CALLS 0 -#else -#define IDIV_CALLS ICMDTABLE_CALLS -#endif - -#if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) -#define LDIV_CALLS 0 -#else -#define LDIV_CALLS ICMDTABLE_CALLS -#endif - -/* include the actual table */ - -icmdtable_entry_t icmd_table[256] = { -#include -}; - -#undef N -#undef PEI -#undef CALLS - -/* XXX hack until the old "PEI" definition is removed */ -#define PEI 1 - - -/* jit_init ******************************************************************** - - Initializes the JIT subsystem. - -*******************************************************************************/ - -void jit_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("jit_init"); - -#if defined(ENABLE_JIT) - /* initialize stack analysis subsystem */ - - (void) stack_init(); -#endif - - /* initialize show subsystem */ - -#if !defined(NDEBUG) - (void) show_init(); -#endif - - /* initialize codegen subsystem */ - - codegen_init(); - - /* initialize code subsystem */ - - (void) code_init(); - - /* Machine dependent initialization. */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - intrp_md_init(); - else -# endif - md_init(); -#else - intrp_md_init(); -#endif -} - - -/* jit_close ******************************************************************* - - Close the JIT subsystem. - -*******************************************************************************/ - -void jit_close(void) -{ - /* do nothing */ -} - - -/* dummy function, used when there is no JavaVM code available */ - -static u1 *do_nothing_function(void) -{ - return NULL; -} - - -/* jit_jitdata_new ************************************************************* - - Allocates and initalizes a new jitdata structure. - -*******************************************************************************/ - -jitdata *jit_jitdata_new(methodinfo *m) -{ - jitdata *jd; - codeinfo *code; - - /* allocate jitdata structure and fill it */ - - jd = DNEW(jitdata); - - jd->m = m; - jd->cd = DNEW(codegendata); - jd->rd = DNEW(registerdata); -#if defined(ENABLE_LOOP) - jd->ld = DNEW(loopdata); -#endif - - /* Allocate codeinfo memory from the heap as we need to keep them. */ - - code = code_codeinfo_new(m); - - /* Set codeinfo flags. */ - -#if defined(ENABLE_THREADS) - if (checksync && (m->flags & ACC_SYNCHRONIZED)) - code_flag_synchronized(code); - - if (checksync && (m->flags & ACC_SYNCHRONIZED)) - code_unflag_leafmethod(code); - else -#endif - code_flag_leafmethod(code); - - /* initialize variables */ - - jd->code = code; - jd->flags = 0; - jd->exceptiontable = NULL; - jd->exceptiontablelength = 0; - jd->returncount = 0; - jd->branchtoentry = false; - jd->branchtoend = false; - jd->returncount = 0; - jd->returnblock = NULL; - jd->maxlocals = m->maxlocals; - - return jd; -} - - -/* jit_compile ***************************************************************** - - Translates one method to machine code. - -*******************************************************************************/ - -static u1 *jit_compile_intern(jitdata *jd); - -u1 *jit_compile(methodinfo *m) -{ - u1 *r; - jitdata *jd; - int32_t dumpmarker; - - STATISTICS(count_jit_calls++); - - /* Initialize the static function's class. */ - - /* ATTENTION: This MUST be done before the method lock is aquired, - otherwise we could run into a deadlock with 's that - call static methods of it's own class. */ - - if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) { -#if !defined(NDEBUG) - if (initverbose) - log_message_class("Initialize class ", m->clazz); -#endif - - if (!initialize_class(m->clazz)) - return NULL; - - /* check if the method has been compiled during initialization */ - - if ((m->code != NULL) && (m->code->entrypoint != NULL)) - return m->code->entrypoint; - } - - /* enter a monitor on the method */ - - LOCK_MONITOR_ENTER(m); - - /* if method has been already compiled return immediately */ - - if (m->code != NULL) { - LOCK_MONITOR_EXIT(m); - - assert(m->code->entrypoint); - return m->code->entrypoint; - } - - TRACECOMPILERCALLS(); - - STATISTICS(count_methods++); - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getcompilingtime) - compilingtime_start(); -#endif - - /* mark start of dump memory area */ - - DMARKER; - - /* create jitdata structure */ - - jd = jit_jitdata_new(m); - - /* set the flags for the current JIT run */ - - jd->flags = JITDATA_FLAG_PARSE; - -#if defined(ENABLE_VERIFIER) - if (opt_verify) - jd->flags |= JITDATA_FLAG_VERIFY; -#endif - -#if defined(ENABLE_PROFILING) - if (opt_prof) - jd->flags |= JITDATA_FLAG_INSTRUMENT; -#endif - -#if defined(ENABLE_IFCONV) - if (opt_ifconv) - jd->flags |= JITDATA_FLAG_IFCONV; -#endif - -#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG) - if (opt_Inline && opt_InlineAll) - jd->flags |= JITDATA_FLAG_INLINE; -#endif - - if (opt_showintermediate) - jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE; - - if (opt_showdisassemble) - jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE; - - if (opt_verbosecall) - jd->flags |= JITDATA_FLAG_VERBOSECALL; - -#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING) - if (opt_Inline) - jd->flags |= JITDATA_FLAG_COUNTDOWN; -#endif - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) -# endif - /* initialize the register allocator */ - { - reg_setup(jd); - } -#endif - - /* setup the codegendata memory */ - - codegen_setup(jd); - - /* now call internal compile function */ - - r = jit_compile_intern(jd); - - if (r == NULL) { - /* We had an exception! Finish stuff here if necessary. */ - - /* release codeinfo */ - - code_codeinfo_free(jd->code); - -#if defined(ENABLE_PROFILING) - /* Release memory for basic block profiling information. */ - - if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) - if (jd->code->bbfrequency != NULL) - MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount); -#endif - } - else { - DEBUG_JIT_COMPILEVERBOSE("Running: "); - } - - /* release dump area */ - - DRELEASE; - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getcompilingtime) - compilingtime_stop(); -#endif - - /* leave the monitor */ - - LOCK_MONITOR_EXIT(m); - - /* return pointer to the methods entry point */ - - return r; -} - - -/* jit_recompile *************************************************************** - - Recompiles a Java method. - -*******************************************************************************/ - -u1 *jit_recompile(methodinfo *m) -{ - u1 *r; - jitdata *jd; - u1 optlevel; - int32_t dumpmarker; - - /* check for max. optimization level */ - - optlevel = (m->code) ? m->code->optlevel : 0; - -#if 0 - if (optlevel == 1) { -/* log_message_method("not recompiling: ", m); */ - return NULL; - } -#endif - - DEBUG_JIT_COMPILEVERBOSE("Recompiling start: "); - - STATISTICS(count_jit_calls++); - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getcompilingtime) - compilingtime_start(); -#endif - - /* mark start of dump memory area */ - - DMARKER; - - /* create jitdata structure */ - - jd = jit_jitdata_new(m); - - /* set the current optimization level to the previous one plus 1 */ - - jd->code->optlevel = optlevel + 1; - - /* get the optimization flags for the current JIT run */ - -#if defined(ENABLE_VERIFIER) - jd->flags |= JITDATA_FLAG_VERIFY; -#endif - - /* jd->flags |= JITDATA_FLAG_REORDER; */ - if (opt_showintermediate) - jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE; - if (opt_showdisassemble) - jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE; - if (opt_verbosecall) - jd->flags |= JITDATA_FLAG_VERBOSECALL; - -#if defined(ENABLE_INLINING) - if (opt_Inline) - jd->flags |= JITDATA_FLAG_INLINE; -#endif - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) -# endif - /* initialize the register allocator */ - - reg_setup(jd); -#endif - - /* setup the codegendata memory */ - - codegen_setup(jd); - - /* now call internal compile function */ - - r = jit_compile_intern(jd); - - if (r == NULL) { - /* We had an exception! Finish stuff here if necessary. */ - - /* release codeinfo */ - - code_codeinfo_free(jd->code); - } - - /* release dump area */ - - DRELEASE; - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getcompilingtime) - compilingtime_stop(); -#endif - - DEBUG_JIT_COMPILEVERBOSE("Recompiling done: "); - - /* return pointer to the methods entry point */ - - return r; -} - -#if defined(ENABLE_PM_HACKS) -#include "vm/jit/jit_pm_1.inc" -#endif - -/* jit_compile_intern ********************************************************** - - Static internal function which does the actual compilation. - -*******************************************************************************/ - -static u1 *jit_compile_intern(jitdata *jd) -{ - methodinfo *m; - codegendata *cd; - codeinfo *code; - -#if defined(ENABLE_RT_TIMING) - struct timespec time_start,time_checks,time_parse,time_stack, - time_typecheck,time_loop,time_ifconv,time_alloc, - time_codegen; -#endif - - RT_TIMING_GET_TIME(time_start); - - /* get required compiler data */ - -#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) - jd->ls = NULL; -#endif - m = jd->m; - code = jd->code; - cd = jd->cd; - -#if defined(ENABLE_DEBUG_FILTER) - show_filters_apply(jd->m); -#endif - - /* Handle native methods and create a native stub. */ - - if (m->flags & ACC_NATIVE) { - functionptr f; - - f = native_method_resolve(m); - - if (f == NULL) - return NULL; - - code = codegen_generate_stub_native(m, f); - - /* Native methods are never recompiled. */ - - assert(!m->code); - - m->code = code; - - return code->entrypoint; - } - - /* if there is no javacode, print error message and return empty method */ - - if (m->jcode == NULL) { - DEBUG_JIT_COMPILEVERBOSE("No code given for: "); - - code->entrypoint = (u1 *) (ptrint) do_nothing_function; - m->code = code; - - return code->entrypoint; /* return empty method */ - } - -#if defined(ENABLE_STATISTICS) - if (opt_stat) { - count_javacodesize += m->jcodelength + 18; - count_tryblocks += jd->exceptiontablelength; - count_javaexcsize += jd->exceptiontablelength * SIZEOF_VOID_P; - } -#endif - - RT_TIMING_GET_TIME(time_checks); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - /* Code for Sun's OpenJDK (see - hotspot/src/share/vm/classfile/verifier.cpp - (Verifier::is_eligible_for_verification)): Don't verify - dynamically-generated bytecodes. */ - -# if defined(ENABLE_VERIFIER) - if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl)) - jd->flags &= ~JITDATA_FLAG_VERIFY; -# endif -#endif - - /* call the compiler passes ***********************************************/ - - DEBUG_JIT_COMPILEVERBOSE("Parsing: "); - - /* call parse pass */ - - if (!parse(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: "); - - return NULL; - } - RT_TIMING_GET_TIME(time_parse); - - DEBUG_JIT_COMPILEVERBOSE("Parsing done: "); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) { -# endif - DEBUG_JIT_COMPILEVERBOSE("Analysing: "); - - /* call stack analysis pass */ - - if (!stack_analyse(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: "); - - return NULL; - } - RT_TIMING_GET_TIME(time_stack); - - DEBUG_JIT_COMPILEVERBOSE("Analysing done: "); - -#ifdef ENABLE_VERIFIER - if (JITDATA_HAS_FLAG_VERIFY(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Typechecking: "); - - /* call typecheck pass */ - if (!typecheck(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: "); - - return NULL; - } - - DEBUG_JIT_COMPILEVERBOSE("Typechecking done: "); - } -#endif - RT_TIMING_GET_TIME(time_typecheck); - -#if defined(ENABLE_SSA) - if (opt_lsra) { - fix_exception_handlers(jd); - } -#endif - - /* Build the CFG. This has to be done after stack_analyse, as - there happens the JSR elimination. */ - - if (!cfg_build(jd)) - return NULL; - -#if defined(ENABLE_LOOP) - if (opt_loops) { - depthFirst(jd); - analyseGraph(jd); - optimize_loops(jd); - jit_renumber_basicblocks(jd); - } -#endif - RT_TIMING_GET_TIME(time_loop); - -#if defined(ENABLE_IFCONV) - if (JITDATA_HAS_FLAG_IFCONV(jd)) { - if (!ifconv_static(jd)) - return NULL; - jit_renumber_basicblocks(jd); - } -#endif - RT_TIMING_GET_TIME(time_ifconv); - - /* inlining */ - -#if defined(ENABLE_INLINING) - if (JITDATA_HAS_FLAG_INLINE(jd)) { - if (!inline_inline(jd)) - return NULL; - } -#endif - -#if defined(ENABLE_PROFILING) - /* Basic block reordering. I think this should be done after - if-conversion, as we could lose the ability to do the - if-conversion. */ - - if (JITDATA_HAS_FLAG_REORDER(jd)) { - if (!reorder(jd)) - return NULL; - jit_renumber_basicblocks(jd); - } -#endif - -#if defined(ENABLE_PM_HACKS) -#include "vm/jit/jit_pm_2.inc" -#endif - DEBUG_JIT_COMPILEVERBOSE("Allocating registers: "); - -#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA) - /* allocate registers */ - if (opt_lsra) { - if (!lsra(jd)) - return NULL; - - STATISTICS(count_methods_allocated_by_lsra++); - - } else -# endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */ -#if defined(ENABLE_SSA) - /* allocate registers */ - if ( - (opt_lsra) - /*&& strncmp(jd->m->name->text, "banana", 6) == 0*/ - /*&& jd->exceptiontablelength == 0*/ - ) { - /* printf("=== %s ===\n", jd->m->name->text); */ - jd->ls = DNEW(lsradata); - jd->ls = NULL; - ssa(jd); - /*lsra(jd);*/ regalloc(jd); - eliminate_subbasicblocks(jd); - STATISTICS(count_methods_allocated_by_lsra++); - - } else -# endif /* defined(ENABLE_SSA) */ - { - STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals)); - - regalloc(jd); - } - - STATISTICS(simplereg_make_statistics(jd)); - - DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: "); -# if defined(ENABLE_INTRP) - } -# endif -#endif /* defined(ENABLE_JIT) */ - RT_TIMING_GET_TIME(time_alloc); - -#if defined(ENABLE_PROFILING) - /* Allocate memory for basic block profiling information. This - _must_ be done after loop optimization and register allocation, - since they can change the basic block count. */ - - if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) - code->bbfrequency = MNEW(u4, jd->basicblockcount); -#endif - - DEBUG_JIT_COMPILEVERBOSE("Generating code: "); - - /* now generate the machine code */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) { -#if defined(ENABLE_VERIFIER) - if (opt_verify) { - DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): "); - - if (!typecheck_stackbased(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): "); - return NULL; - } - } -#endif - if (!intrp_codegen(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: "); - - return NULL; - } - } else -# endif - { - if (!codegen_generate(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: "); - - return NULL; - } - } -#else - if (!intrp_codegen(jd)) { - DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: "); - - return NULL; - } -#endif - RT_TIMING_GET_TIME(time_codegen); - - DEBUG_JIT_COMPILEVERBOSE("Generating code done: "); - -#if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT) - /* activate replacement points inside newly created code */ - - if (opt_TestReplacement) - replace_activate_replacement_points(code, false); -#endif - -#if !defined(NDEBUG) -#if defined(ENABLE_DEBUG_FILTER) - if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD) -#endif - { - /* intermediate and assembly code listings */ - - if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) { - show_method(jd, SHOW_CODE); - } - else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) { -# if defined(ENABLE_DISASSEMBLER) - DISASSEMBLE(code->entrypoint, - code->entrypoint + (code->mcodelength - cd->dseglen)); -# endif - } - - if (opt_showddatasegment) - dseg_display(jd); - } -#endif - - /* switch to the newly generated code */ - - assert(code); - assert(code->entrypoint); - - /* add the current compile version to the methodinfo */ - - code->prev = m->code; - m->code = code; - - RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS); - RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE); - RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK); - RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK); - RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP); - RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC); - RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN); - RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL); - - /* return pointer to the methods entry point */ - - return code->entrypoint; -} - - -/* jit_invalidate_code ********************************************************* - - Mark the compiled code of the given method as invalid and take care that - it is replaced if necessary. - - XXX Not fully implemented, yet. - -*******************************************************************************/ - -void jit_invalidate_code(methodinfo *m) -{ - codeinfo *code; - - code = m->code; - - if (code == NULL || code_is_invalid(code)) - return; - - code_flag_invalid(code); - - /* activate mappable replacement points */ - -#if defined(ENABLE_REPLACEMENT) - replace_activate_replacement_points(code, true); -#else - vm_abort("invalidating code only works with ENABLE_REPLACEMENT"); -#endif -} - - -/* jit_request_optimization **************************************************** - - Request optimization of the given method. If the code of the method is - unoptimized, it will be invalidated, so the next jit_get_current_code(m) - triggers an optimized recompilation. - If the method is already optimized, this function does nothing. - - IN: - m................the method - -*******************************************************************************/ - -void jit_request_optimization(methodinfo *m) -{ - codeinfo *code; - - code = m->code; - - if (code && code->optlevel == 0) - jit_invalidate_code(m); -} - - -/* jit_get_current_code ******************************************************** - - Get the currently valid code for the given method. If there is no valid - code, (re)compile the method. - - IN: - m................the method - - RETURN VALUE: - the codeinfo* for the current code, or - NULL if an exception has been thrown during recompilation. - -*******************************************************************************/ - -codeinfo *jit_get_current_code(methodinfo *m) -{ - assert(m); - - /* if we have valid code, return it */ - - if (m->code && !code_is_invalid(m->code)) - return m->code; - - /* otherwise: recompile */ - - if (!jit_recompile(m)) - return NULL; - - assert(m->code); - - return m->code; -} - - -/* jit_asm_compile ************************************************************* - - This method is called from asm_vm_call_method and does: - - - create stackframe info for exceptions - - compile the method - - patch the entrypoint of the method into the calculated address in - the JIT code - - flushes the instruction cache. - -*******************************************************************************/ - -#if defined(ENABLE_JIT) -#if !defined(JIT_COMPILER_VIA_SIGNAL) -u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra) -{ - stackframeinfo_t sfi; - u1 *entrypoint; - u1 *pa; - ptrint *p; - - /* create the stackframeinfo (subtract 1 from RA as it points to the */ - /* instruction after the call) */ - - stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1); - - /* actually compile the method */ - - entrypoint = jit_compile(m); - - /* remove the stackframeinfo */ - - stacktrace_stackframeinfo_remove(&sfi); - - /* there was a problem during compilation */ - - if (entrypoint == NULL) - return NULL; - - /* get the method patch address */ - - pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr); - - /* patch the method entry point */ - - p = (ptrint *) pa; - - *p = (ptrint) entrypoint; - - /* flush the instruction cache */ - - md_icacheflush(pa, SIZEOF_VOID_P); - - return entrypoint; -} -#endif - -/* jit_compile_handle ********************************************************** - - This method is called from the appropriate signal handler which - handles compiler-traps and does the following: - - - compile the method - - patch the entrypoint of the method into the calculated address in - the JIT code - - flush the instruction cache - -*******************************************************************************/ - -void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr) -{ - void *newpv; /* new compiled method PV */ - void *pa; /* patch address */ - uintptr_t *p; /* convenience pointer */ - - /* Compile the method. */ - - newpv = jit_compile(m); - - /* There was a problem during compilation. */ - - if (newpv == NULL) - return NULL; - - /* Get the method patch address. */ - - pa = md_jit_method_patch_address(pv, ra, mptr); - - /* Patch the method entry point. */ - - p = (uintptr_t *) pa; - - *p = (uintptr_t) newpv; - - /* Flush both caches. */ - - md_cacheflush(pa, SIZEOF_VOID_P); - - return newpv; -} -#endif /* defined(ENABLE_JIT) */ - - -/* jit_complement_condition **************************************************** - - Returns the complement of the passed conditional instruction. - - We use the order of the different conditions, e.g.: - - ICMD_IFEQ 153 - ICMD_IFNE 154 - - If the passed opcode is odd, we simply add 1 to get the complement. - If the opcode is even, we subtract 1. - - Exception: - - ICMD_IFNULL 198 - ICMD_IFNONNULL 199 - -*******************************************************************************/ - -s4 jit_complement_condition(s4 opcode) -{ - switch (opcode) { - case ICMD_IFNULL: - return ICMD_IFNONNULL; - - case ICMD_IFNONNULL: - return ICMD_IFNULL; - - default: - /* check if opcode is odd */ - - if (opcode & 0x1) - return opcode + 1; - else - return opcode - 1; - } -} - - -/* jit_renumber_basicblocks **************************************************** - - Set the ->nr of all blocks so it increases when traversing ->next. - - IN: - jitdata..........the current jitdata - -*******************************************************************************/ - -void jit_renumber_basicblocks(jitdata *jd) -{ - s4 nr; - basicblock *bptr; - - nr = 0; - for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) { - bptr->nr = nr++; - } - - /* we have one block more than jd->basicblockcount (the end marker) */ - - assert(nr == jd->basicblockcount + 1); -} - - -/* jit_check_basicblock_numbers ************************************************ - - Assert that the ->nr of the first block is zero and increases by 1 each - time ->next is traversed. - This function should be called before any analysis that relies on - the basicblock numbers. - - IN: - jitdata..........the current jitdata - - NOTE: Aborts with an assertion if the condition is not met! - -*******************************************************************************/ - -#if !defined(NDEBUG) -void jit_check_basicblock_numbers(jitdata *jd) -{ - s4 nr; - basicblock *bptr; - - nr = 0; - for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) { - assert(bptr->nr == nr); - nr++; - } - - /* we have one block more than jd->basicblockcount (the end marker) */ - - assert(nr == jd->basicblockcount + 1); -} -#endif /* !defined(NDEBUG) */ - -methoddesc *instruction_call_site(const instruction *iptr) { - if (iptr->opc == ICMD_BUILTIN) { - return iptr->sx.s23.s3.bte->md; - } else if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - return iptr->sx.s23.s3.um->methodref->parseddesc.md; - } else { - return iptr->sx.s23.s3.fmiref->p.method->parseddesc; - } -} - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/jit.cpp b/src/vm/jit/jit.cpp new file mode 100644 index 000000000..baada57fe --- /dev/null +++ b/src/vm/jit/jit.cpp @@ -0,0 +1,1180 @@ +/* src/vm/jit/jit.cpp - Just-In-Time compiler + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "md.h" + +#include "mm/memory.h" + +#include "native/native.h" + +#include "toolbox/logging.h" + +#include "threads/mutex.hpp" + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/rt-timing.h" +#include "vm/statistics.h" + +#include "vm/jit/asmpart.h" + +#include "vm/jit/cfg.h" + +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/disass.h" +#include "vm/jit/dseg.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/parse.h" +#include "vm/jit/reg.h" + +#include "vm/jit/show.h" +#include "vm/jit/stack.h" +#include "vm/jit/stubs.hpp" + +#if defined(ENABLE_OPAGENT) +#include "vm/jit/oprofile-agent.hpp" +#endif + +#include "vm/jit/allocator/simplereg.h" +#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA) +# include "vm/jit/allocator/lsra.h" +#endif + +#if defined(ENABLE_SSA) +# include "vm/jit/optimizing/lsra.h" +# include "vm/jit/optimizing/ssa.h" +#endif + +#if defined(ENABLE_INLINING) +# include "vm/jit/inline/inline.h" +#endif + +#include "vm/jit/ir/bytecode.h" + +#include "vm/jit/loop/analyze.h" +#include "vm/jit/loop/graph.h" +#include "vm/jit/loop/loop.h" + +#if defined(ENABLE_IFCONV) +# include "vm/jit/optimizing/ifconv.h" +#endif + +#include "vm/jit/optimizing/reorder.h" + +#if defined(ENABLE_PYTHON) +# include "vm/jit/python.h" +#endif + +#include "vm/jit/verify/typecheck.h" + + +/* debug macros ***************************************************************/ + +#if !defined(NDEBUG) +#define DEBUG_JIT_COMPILEVERBOSE(x) \ + do { \ + if (compileverbose) { \ + log_message_method(x, m); \ + } \ + } while (0) +#else +#define DEBUG_JIT_COMPILEVERBOSE(x) /* nothing */ +#endif + +#if !defined(NDEBUG) +# define TRACECOMPILERCALLS() \ + do { \ + if (opt_TraceCompilerCalls) { \ + log_start(); \ + log_print("[JIT compiler started: method="); \ + method_print(m); \ + log_print("]"); \ + log_finish(); \ + } \ + } while (0) +#else +# define TRACECOMPILERCALLS() +#endif + + +/* jit_init ******************************************************************** + + Initializes the JIT subsystem. + +*******************************************************************************/ + +void jit_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("jit_init"); + +#if defined(ENABLE_JIT) + /* initialize stack analysis subsystem */ + + (void) stack_init(); +#endif + + /* initialize show subsystem */ + +#if !defined(NDEBUG) + (void) show_init(); +#endif + + /* initialize codegen subsystem */ + + codegen_init(); + + /* initialize code subsystem */ + + (void) code_init(); + + /* Machine dependent initialization. */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) + intrp_md_init(); + else +# endif + md_init(); +#else + intrp_md_init(); +#endif + +#if defined(ENABLE_OPAGENT) + if (opt_EnableOpagent) + OprofileAgent_initialize(); +#endif +} + + +/* jit_close ******************************************************************* + + Close the JIT subsystem. + +*******************************************************************************/ + +void jit_close(void) +{ +#if defined(ENABLE_OPAGENT) + if (opt_EnableOpagent) + OprofileAgent_close(); +#endif +} + + +/* dummy function, used when there is no JavaVM code available */ + +static u1 *do_nothing_function(void) +{ + return NULL; +} + + +/* jit_jitdata_new ************************************************************* + + Allocates and initalizes a new jitdata structure. + +*******************************************************************************/ + +jitdata *jit_jitdata_new(methodinfo *m) +{ + jitdata *jd; + codeinfo *code; + + /* allocate jitdata structure and fill it */ + + jd = (jitdata*) DumpMemory::allocate(sizeof(jitdata)); + + jd->m = m; + jd->cd = (codegendata*) DumpMemory::allocate(sizeof(codegendata)); + jd->rd = (registerdata*) DumpMemory::allocate(sizeof(registerdata)); +#if defined(ENABLE_LOOP) + jd->ld = (loopdata*) DumpMemory::allocate(sizeof(loopdata)); +#endif + + /* Allocate codeinfo memory from the heap as we need to keep them. */ + + code = code_codeinfo_new(m); + + /* Set codeinfo flags. */ + +#if defined(ENABLE_THREADS) + if (checksync && (m->flags & ACC_SYNCHRONIZED)) + code_flag_synchronized(code); + + if (checksync && (m->flags & ACC_SYNCHRONIZED)) + code_unflag_leafmethod(code); + else +#endif + code_flag_leafmethod(code); + + /* initialize variables */ + + jd->code = code; + jd->flags = 0; + jd->exceptiontable = NULL; + jd->exceptiontablelength = 0; + jd->returncount = 0; + jd->branchtoentry = false; + jd->branchtoend = false; + jd->returncount = 0; + jd->returnblock = NULL; + jd->maxlocals = m->maxlocals; + + return jd; +} + + +/* jit_compile ***************************************************************** + + Translates one method to machine code. + +*******************************************************************************/ + +static u1 *jit_compile_intern(jitdata *jd); + +u1 *jit_compile(methodinfo *m) +{ + u1 *r; + jitdata *jd; + + STATISTICS(count_jit_calls++); + + /* Initialize the static function's class. */ + + /* ATTENTION: This MUST be done before the method lock is aquired, + otherwise we could run into a deadlock with 's that + call static methods of it's own class. */ + + if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) { +#if !defined(NDEBUG) + if (initverbose) + log_message_class("Initialize class ", m->clazz); +#endif + + if (!initialize_class(m->clazz)) + return NULL; + + /* check if the method has been compiled during initialization */ + + if ((m->code != NULL) && (m->code->entrypoint != NULL)) + return m->code->entrypoint; + } + + /* enter a monitor on the method */ + + m->mutex->lock(); + + /* if method has been already compiled return immediately */ + + if (m->code != NULL) { + m->mutex->unlock(); + + assert(m->code->entrypoint); + return m->code->entrypoint; + } + + TRACECOMPILERCALLS(); + + STATISTICS(count_methods++); + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getcompilingtime) + compilingtime_start(); +#endif + + // Create new dump memory area. + DumpMemoryArea dma; + + /* create jitdata structure */ + + jd = jit_jitdata_new(m); + + /* set the flags for the current JIT run */ + + jd->flags = JITDATA_FLAG_PARSE; + +#if defined(ENABLE_VERIFIER) + if (opt_verify) + jd->flags |= JITDATA_FLAG_VERIFY; +#endif + +#if defined(ENABLE_PROFILING) + if (opt_prof) + jd->flags |= JITDATA_FLAG_INSTRUMENT; +#endif + +#if defined(ENABLE_IFCONV) + if (opt_ifconv) + jd->flags |= JITDATA_FLAG_IFCONV; +#endif + +#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG) + if (opt_Inline && opt_InlineAll) + jd->flags |= JITDATA_FLAG_INLINE; +#endif + + if (opt_showintermediate) + jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE; + + if (opt_showdisassemble) + jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE; + + if (opt_verbosecall) + jd->flags |= JITDATA_FLAG_VERBOSECALL; + +#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING) + if (opt_Inline && (jd->m->hitcountdown > 0) && (jd->code->optlevel == 0)) { + jd->flags |= JITDATA_FLAG_COUNTDOWN; + } +#endif + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) +# endif + /* initialize the register allocator */ + { + reg_setup(jd); + } +#endif + + /* setup the codegendata memory */ + + codegen_setup(jd); + + /* now call internal compile function */ + + r = jit_compile_intern(jd); + + if (r == NULL) { + /* We had an exception! Finish stuff here if necessary. */ + + /* release codeinfo */ + + code_codeinfo_free(jd->code); + +#if defined(ENABLE_PROFILING) + /* Release memory for basic block profiling information. */ + + if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) + if (jd->code->bbfrequency != NULL) + MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount); +#endif + } + else { + DEBUG_JIT_COMPILEVERBOSE("Running: "); + } + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getcompilingtime) + compilingtime_stop(); +#endif + +#if defined(ENABLE_OPAGENT) + if (opt_EnableOpagent) + OprofileAgent_newmethod(m); +#endif + + /* leave the monitor */ + + m->mutex->unlock(); + + /* return pointer to the methods entry point */ + + return r; +} + + +/* jit_recompile *************************************************************** + + Recompiles a Java method. + +*******************************************************************************/ + +u1 *jit_recompile(methodinfo *m) +{ + u1 *r; + jitdata *jd; + u1 optlevel; + + /* check for max. optimization level */ + + optlevel = (m->code) ? m->code->optlevel : 0; + +#if 0 + if (optlevel == 1) { +/* log_message_method("not recompiling: ", m); */ + return NULL; + } +#endif + + DEBUG_JIT_COMPILEVERBOSE("Recompiling start: "); + + STATISTICS(count_jit_calls++); + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getcompilingtime) + compilingtime_start(); +#endif + + // Create new dump memory area. + DumpMemoryArea dma; + + /* create jitdata structure */ + + jd = jit_jitdata_new(m); + + /* set the current optimization level to the previous one plus 1 */ + + jd->code->optlevel = optlevel + 1; + + /* get the optimization flags for the current JIT run */ + +#if defined(ENABLE_VERIFIER) + jd->flags |= JITDATA_FLAG_VERIFY; +#endif + + /* jd->flags |= JITDATA_FLAG_REORDER; */ + if (opt_showintermediate) + jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE; + if (opt_showdisassemble) + jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE; + if (opt_verbosecall) + jd->flags |= JITDATA_FLAG_VERBOSECALL; + +#if defined(ENABLE_INLINING) + if (opt_Inline) + jd->flags |= JITDATA_FLAG_INLINE; +#endif + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) +# endif + /* initialize the register allocator */ + + reg_setup(jd); +#endif + + /* setup the codegendata memory */ + + codegen_setup(jd); + + /* now call internal compile function */ + + r = jit_compile_intern(jd); + + if (r == NULL) { + /* We had an exception! Finish stuff here if necessary. */ + + /* release codeinfo */ + + code_codeinfo_free(jd->code); + } + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getcompilingtime) + compilingtime_stop(); +#endif + +#if defined(ENABLE_OPAGENT) + if (opt_EnableOpagent) + OprofileAgent_newmethod(m); +#endif + + DEBUG_JIT_COMPILEVERBOSE("Recompiling done: "); + + /* return pointer to the methods entry point */ + + return r; +} + +#if defined(ENABLE_PM_HACKS) +#include "vm/jit/jit_pm_1.inc" +#endif + +/* jit_compile_intern ********************************************************** + + Static internal function which does the actual compilation. + +*******************************************************************************/ + +static u1 *jit_compile_intern(jitdata *jd) +{ + methodinfo *m; + codegendata *cd; + codeinfo *code; + +#if defined(ENABLE_RT_TIMING) + struct timespec time_start,time_checks,time_parse,time_stack, + time_typecheck,time_loop,time_ifconv,time_alloc, + time_codegen; +#endif + + RT_TIMING_GET_TIME(time_start); + + /* get required compiler data */ + +#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) + jd->ls = NULL; +#endif + m = jd->m; + code = jd->code; + cd = jd->cd; + +#if defined(ENABLE_DEBUG_FILTER) + show_filters_apply(jd->m); +#endif + + /* Handle native methods and create a native stub. */ + + if (m->flags & ACC_NATIVE) { + functionptr f; + + f = native_method_resolve(m); + + if (f == NULL) + return NULL; + + code = NativeStub::generate(m, f); + + /* Native methods are never recompiled. */ + + assert(!m->code); + + m->code = code; + + return code->entrypoint; + } + + /* if there is no javacode, print error message and return empty method */ + + if (m->jcode == NULL) { + DEBUG_JIT_COMPILEVERBOSE("No code given for: "); + + code->entrypoint = (u1 *) (ptrint) do_nothing_function; + m->code = code; + + return code->entrypoint; /* return empty method */ + } + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + count_javacodesize += m->jcodelength + 18; + count_tryblocks += jd->exceptiontablelength; + count_javaexcsize += jd->exceptiontablelength * SIZEOF_VOID_P; + } +#endif + + RT_TIMING_GET_TIME(time_checks); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + /* Code for Sun's OpenJDK (see + hotspot/src/share/vm/classfile/verifier.cpp + (Verifier::is_eligible_for_verification)): Don't verify + dynamically-generated bytecodes. */ + +# if defined(ENABLE_VERIFIER) + if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl)) + jd->flags &= ~JITDATA_FLAG_VERIFY; +# endif +#endif + + /* call the compiler passes ***********************************************/ + + DEBUG_JIT_COMPILEVERBOSE("Parsing: "); + + /* call parse pass */ + + if (!parse(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: "); + + return NULL; + } + RT_TIMING_GET_TIME(time_parse); + + DEBUG_JIT_COMPILEVERBOSE("Parsing done: "); + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) { +# endif + DEBUG_JIT_COMPILEVERBOSE("Analysing: "); + + /* call stack analysis pass */ + + if (!stack_analyse(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: "); + + return NULL; + } + RT_TIMING_GET_TIME(time_stack); + + DEBUG_JIT_COMPILEVERBOSE("Analysing done: "); + +#ifdef ENABLE_VERIFIER + if (JITDATA_HAS_FLAG_VERIFY(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Typechecking: "); + + /* call typecheck pass */ + if (!typecheck(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: "); + + return NULL; + } + + DEBUG_JIT_COMPILEVERBOSE("Typechecking done: "); + } +#endif + RT_TIMING_GET_TIME(time_typecheck); + +#if defined(ENABLE_LOOP) + if (opt_loops) { + depthFirst(jd); + analyseGraph(jd); + optimize_loops(jd); + jit_renumber_basicblocks(jd); + } +#endif + RT_TIMING_GET_TIME(time_loop); + +#if defined(ENABLE_IFCONV) + if (JITDATA_HAS_FLAG_IFCONV(jd)) { + if (!ifconv_static(jd)) + return NULL; + jit_renumber_basicblocks(jd); + } +#endif + RT_TIMING_GET_TIME(time_ifconv); + + /* inlining */ + +#if defined(ENABLE_INLINING) && (!defined(ENABLE_ESCAPE) || 1) + if (JITDATA_HAS_FLAG_INLINE(jd)) { + if (!inline_inline(jd)) + return NULL; + } +#endif + +#if defined(ENABLE_SSA) + if (opt_lsra) { + fix_exception_handlers(jd); + } +#endif + + /* Build the CFG. This has to be done after stack_analyse, as + there happens the JSR elimination. */ + + if (!cfg_build(jd)) + return NULL; + +#if defined(ENABLE_PROFILING) + /* Basic block reordering. I think this should be done after + if-conversion, as we could lose the ability to do the + if-conversion. */ + + if (JITDATA_HAS_FLAG_REORDER(jd)) { + if (!reorder(jd)) + return NULL; + jit_renumber_basicblocks(jd); + } +#endif + +#if defined(ENABLE_PM_HACKS) +#include "vm/jit/jit_pm_2.inc" +#endif + DEBUG_JIT_COMPILEVERBOSE("Allocating registers: "); + +#if defined(ENABLE_LSRA) && !defined(ENABLE_SSA) + /* allocate registers */ + if (opt_lsra) { + if (!lsra(jd)) + return NULL; + + STATISTICS(count_methods_allocated_by_lsra++); + + } else +# endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */ +#if defined(ENABLE_SSA) + /* allocate registers */ + if ( + (opt_lsra && + jd->code->optlevel > 0) + /* strncmp(jd->m->name->text, "hottie", 6) == 0*/ + /*&& jd->exceptiontablelength == 0*/ + ) { + /*printf("=== %s ===\n", jd->m->name->text);*/ + jd->ls = (lsradata*) DumpMemory::allocate(sizeof(lsradata)); + jd->ls = NULL; + ssa(jd); + /*lsra(jd);*/ regalloc(jd); + /*eliminate_subbasicblocks(jd);*/ + STATISTICS(count_methods_allocated_by_lsra++); + + } else +# endif /* defined(ENABLE_SSA) */ + { + STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals)); + + regalloc(jd); + } + + STATISTICS(simplereg_make_statistics(jd)); + + DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: "); +# if defined(ENABLE_INTRP) + } +# endif +#endif /* defined(ENABLE_JIT) */ + RT_TIMING_GET_TIME(time_alloc); + +#if defined(ENABLE_PROFILING) + /* Allocate memory for basic block profiling information. This + _must_ be done after loop optimization and register allocation, + since they can change the basic block count. */ + + if (JITDATA_HAS_FLAG_INSTRUMENT(jd)) + code->bbfrequency = MNEW(u4, jd->basicblockcount); +#endif + + DEBUG_JIT_COMPILEVERBOSE("Generating code: "); + + /* now generate the machine code */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) { +#if defined(ENABLE_VERIFIER) + if (opt_verify) { + DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): "); + + if (!typecheck_stackbased(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): "); + return NULL; + } + } +#endif + if (!intrp_codegen(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: "); + + return NULL; + } + } else +# endif + { + if (!codegen_generate(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: "); + + return NULL; + } + } +#else + if (!intrp_codegen(jd)) { + DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: "); + + return NULL; + } +#endif + RT_TIMING_GET_TIME(time_codegen); + + DEBUG_JIT_COMPILEVERBOSE("Generating code done: "); + +#if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT) + /* activate replacement points inside newly created code */ + + if (opt_TestReplacement) + replace_activate_replacement_points(code, false); +#endif + +#if !defined(NDEBUG) +#if defined(ENABLE_DEBUG_FILTER) + if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD) +#endif + { + /* intermediate and assembly code listings */ + + if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) { + show_method(jd, SHOW_CODE); + } + else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) { +# if defined(ENABLE_DISASSEMBLER) + DISASSEMBLE(code->entrypoint, + code->entrypoint + (code->mcodelength - cd->dseglen)); +# endif + } + + if (opt_showddatasegment) + dseg_display(jd); + } +#endif + + /* switch to the newly generated code */ + + assert(code); + assert(code->entrypoint); + + /* add the current compile version to the methodinfo */ + + code->prev = m->code; + m->code = code; + + RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS); + RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE); + RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK); + RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK); + RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP); + RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC); + RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN); + RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL); + + /* return pointer to the methods entry point */ + + return code->entrypoint; +} + + +/* jit_invalidate_code ********************************************************* + + Mark the compiled code of the given method as invalid and take care that + it is replaced if necessary. + + XXX Not fully implemented, yet. + +*******************************************************************************/ + +void jit_invalidate_code(methodinfo *m) +{ + codeinfo *code; + + code = m->code; + + if (code == NULL || code_is_invalid(code)) + return; + + code_flag_invalid(code); + + /* activate mappable replacement points */ + +#if defined(ENABLE_REPLACEMENT) + replace_activate_replacement_points(code, true); +#else + vm_abort("invalidating code only works with ENABLE_REPLACEMENT"); +#endif +} + + +/* jit_request_optimization **************************************************** + + Request optimization of the given method. If the code of the method is + unoptimized, it will be invalidated, so the next jit_get_current_code(m) + triggers an optimized recompilation. + If the method is already optimized, this function does nothing. + + IN: + m................the method + +*******************************************************************************/ + +void jit_request_optimization(methodinfo *m) +{ + codeinfo *code; + + code = m->code; + + if (code && code->optlevel == 0) + jit_invalidate_code(m); +} + + +/* jit_get_current_code ******************************************************** + + Get the currently valid code for the given method. If there is no valid + code, (re)compile the method. + + IN: + m................the method + + RETURN VALUE: + the codeinfo* for the current code, or + NULL if an exception has been thrown during recompilation. + +*******************************************************************************/ + +codeinfo *jit_get_current_code(methodinfo *m) +{ + assert(m); + + /* if we have valid code, return it */ + + if (m->code && !code_is_invalid(m->code)) + return m->code; + + /* otherwise: recompile */ + + if (!jit_recompile(m)) + return NULL; + + assert(m->code); + + return m->code; +} + + +/* jit_asm_compile ************************************************************* + + This method is called from asm_vm_call_method and does: + + - create stackframe info for exceptions + - compile the method + - patch the entrypoint of the method into the calculated address in + the JIT code + - flushes the instruction cache. + +*******************************************************************************/ + +#if defined(ENABLE_JIT) +#if !defined(JIT_COMPILER_VIA_SIGNAL) +extern "C" { +void* jit_asm_compile(methodinfo *m, void* mptr, void* sp, void* ra) +{ + stackframeinfo_t sfi; + void *entrypoint; + void *pa; + uintptr_t *p; + + /* create the stackframeinfo (subtract 1 from RA as it points to the */ + /* instruction after the call) */ + + stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ((uint8_t*) ra) - 1); + + /* actually compile the method */ + + entrypoint = jit_compile(m); + + /* remove the stackframeinfo */ + + stacktrace_stackframeinfo_remove(&sfi); + + /* there was a problem during compilation */ + + if (entrypoint == NULL) + return NULL; + + /* get the method patch address */ + + pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr); + + /* patch the method entry point */ + + p = (uintptr_t*) pa; + + *p = (uintptr_t) entrypoint; + + /* flush the instruction cache */ + + md_icacheflush(pa, SIZEOF_VOID_P); + + return entrypoint; +} +} +#endif + +/* jit_compile_handle ********************************************************** + + This method is called from the appropriate signal handler which + handles compiler-traps and does the following: + + - compile the method + - patch the entrypoint of the method into the calculated address in + the JIT code + - flush the instruction cache + +*******************************************************************************/ + +void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr) +{ + void *newpv; /* new compiled method PV */ + void *pa; /* patch address */ + uintptr_t *p; /* convenience pointer */ + + /* Compile the method. */ + + newpv = jit_compile(m); + + /* There was a problem during compilation. */ + + if (newpv == NULL) + return NULL; + + /* Get the method patch address. */ + + pa = md_jit_method_patch_address(pv, ra, mptr); + + /* Patch the method entry point. */ + + p = (uintptr_t *) pa; + + *p = (uintptr_t) newpv; + + /* Flush both caches. */ + + md_cacheflush(pa, SIZEOF_VOID_P); + + return newpv; +} +#endif /* defined(ENABLE_JIT) */ + + +/* jit_complement_condition **************************************************** + + Returns the complement of the passed conditional instruction. + + We use the order of the different conditions, e.g.: + + ICMD_IFEQ 153 + ICMD_IFNE 154 + + If the passed opcode is odd, we simply add 1 to get the complement. + If the opcode is even, we subtract 1. + + Exception: + + ICMD_IFNULL 198 + ICMD_IFNONNULL 199 + +*******************************************************************************/ + +s4 jit_complement_condition(s4 opcode) +{ + switch (opcode) { + case ICMD_IFNULL: + return ICMD_IFNONNULL; + + case ICMD_IFNONNULL: + return ICMD_IFNULL; + + default: + /* check if opcode is odd */ + + if (opcode & 0x1) + return opcode + 1; + else + return opcode - 1; + } +} + + +/* jit_renumber_basicblocks **************************************************** + + Set the ->nr of all blocks so it increases when traversing ->next. + + IN: + jitdata..........the current jitdata + +*******************************************************************************/ + +void jit_renumber_basicblocks(jitdata *jd) +{ + s4 nr; + basicblock *bptr; + + nr = 0; + for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) { + bptr->nr = nr++; + } + + /* we have one block more than jd->basicblockcount (the end marker) */ + + assert(nr == jd->basicblockcount + 1); +} + + +/* jit_check_basicblock_numbers ************************************************ + + Assert that the ->nr of the first block is zero and increases by 1 each + time ->next is traversed. + This function should be called before any analysis that relies on + the basicblock numbers. + + IN: + jitdata..........the current jitdata + + NOTE: Aborts with an assertion if the condition is not met! + +*******************************************************************************/ + +#if !defined(NDEBUG) +void jit_check_basicblock_numbers(jitdata *jd) +{ + s4 nr; + basicblock *bptr; + + nr = 0; + for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) { + assert(bptr->nr == nr); + nr++; + } + + /* we have one block more than jd->basicblockcount (the end marker) */ + + assert(nr == jd->basicblockcount + 1); +} +#endif /* !defined(NDEBUG) */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/jit.h b/src/vm/jit/jit.h deleted file mode 100644 index 448f0cc53..000000000 --- a/src/vm/jit/jit.h +++ /dev/null @@ -1,1059 +0,0 @@ -/* src/vm/jit/jit.h - code generation header - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _JIT_H -#define _JIT_H - -/* forward typedefs ***********************************************************/ - -typedef struct jitdata jitdata; -typedef struct basicblock basicblock; -typedef struct instruction instruction; -typedef struct insinfo_inline insinfo_inline; -typedef struct exception_entry exception_entry; - - -#include "config.h" -#include "vm/types.h" - -#include "toolbox/chain.h" - -#include "vm/global.h" -#include "vm/resolve.h" - -#include "vm/jit/codegen-common.h" -#include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stack.h" -#include "vm/jit/stacktrace.h" - -#if defined(ENABLE_INLINING) -# include "vm/jit/inline/inline.h" -#endif - -#include "vm/jit/ir/bytecode.h" - -#if defined(ENABLE_LOOP) -# include "vm/jit/loop/loop.h" -#endif -#if defined(ENABLE_SSA) -# include "vm/jit/optimizing/lsra.h" -#endif -#if defined(ENABLE_LSRA) -# include "vm/jit/allocator/lsra.h" -#endif - -#include "vm/jit/verify/typeinfo.h" - -#include "vmcore/method.h" -#include "vmcore/references.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - - -/* common jit/codegen macros **************************************************/ - -#if defined(ENABLE_STATISTICS) -# define COUNT(x) (x)++ -# define COUNT_SPILLS /* use COUNT_(READ|WRITE)_SPILLS instead */ -# define COUNT_READ_SPILLS(var) \ - switch(var->type) { \ - case TYPE_FLT: count_spills_read_flt++; break; \ - case TYPE_DBL: count_spills_read_dbl++; break; \ - default: count_spills_read_ila++; break; \ - } - -# define COUNT_WRITE_SPILLS(var) \ - switch(var->type) { \ - case TYPE_FLT: count_spills_write_flt++; break; \ - case TYPE_DBL: count_spills_write_dbl++; break; \ - default: count_spills_write_ila++; break; \ - } - -#else -# define COUNT(x) /* nothing */ -# define COUNT_SPILLS /* nothing */ -# define COUNT_READ_SPILLS(x) /* nothing */ -# define COUNT_WRITE_SPILLS(x) /* nothing */ -#endif - -typedef struct interface_info interface_info; - -struct interface_info { - s4 flags; - s4 regoff; -}; - - -/* jitdata ********************************************************************/ - -struct jitdata { - methodinfo *m; /* methodinfo of the method compiled */ - codeinfo *code; - codegendata *cd; - registerdata *rd; -#if defined(ENABLE_LOOP) - loopdata *ld; -#endif -#if defined(ENABLE_SSA) || defined(ENABLE_LSRA) - lsradata *ls; -#endif - - u4 flags; /* contains JIT compiler flags */ - - instruction *instructions; /* ICMDs, valid between parse and stack */ - basicblock *basicblocks; /* start of basic block list */ - stackelement_t *stack; /* XXX should become stack.c internal */ - s4 instructioncount;/* XXX remove this? */ - s4 basicblockcount; /* number of basic blocks */ - s4 stackcount; /* number of stackelements to allocate */ - /* (passed from parse to stack) */ - - varinfo *var; /* array of variables */ - s4 vartop; /* next free index in var array */ - - s4 varcount; /* number of variables in var array */ - s4 localcount; /* number of locals at start of var ar. */ - s4 *local_map; /* map for renaming (de-coallescing) */ - /* locals and keeping the coalescing info for simplereg. */ - /* local_map[javaindex * 5 + type] = */ - /* >= 0......index into jd->var, or */ - /* UNUSED....this (javaindex,type) pair is not used */ - - s4 *reverselocalmap; /* map from CACAO varindex to javaindex */ - /* (varindex must be < localcount) */ - - s4 maxlocals; /* max. number of javalocals */ - - interface_info *interface_map; /* interface variables (for simplereg) */ - s4 maxinterfaces; /* max. number of interface variables */ - - s4 exceptiontablelength; /* exceptiontable length */ - exception_entry *exceptiontable; /* the exceptiontable */ - - basicblock *returnblock; /* block containing the *RETURN */ - /* (only use if returncount==1) */ - s4 returncount; /* number of return instructions */ - bool branchtoentry; /* true if first block is a target */ - bool branchtoend; /* true if end dummy is a target */ -}; - -#define FOR_EACH_BASICBLOCK(jd, it) \ - for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next) - -#define UNUSED -1 - -#define JITDATA_FLAG_PARSE 0x00000001 -#define JITDATA_FLAG_VERIFY 0x00000002 - -#define JITDATA_FLAG_INSTRUMENT 0x00000004 - -#define JITDATA_FLAG_IFCONV 0x00000008 -#define JITDATA_FLAG_REORDER 0x00000010 -#define JITDATA_FLAG_INLINE 0x00000020 - -#define JITDATA_FLAG_COUNTDOWN 0x00000100 - -#define JITDATA_FLAG_SHOWINTERMEDIATE 0x20000000 -#define JITDATA_FLAG_SHOWDISASSEMBLE 0x40000000 -#define JITDATA_FLAG_VERBOSECALL 0x80000000 - - -#define JITDATA_HAS_FLAG_PARSE(jd) \ - ((jd)->flags & JITDATA_FLAG_PARSE) - -#define JITDATA_HAS_FLAG_VERIFY(jd) \ - ((jd)->flags & JITDATA_FLAG_VERIFY) - -#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \ - ((jd)->flags & JITDATA_FLAG_INSTRUMENT) - -#define JITDATA_HAS_FLAG_IFCONV(jd) \ - ((jd)->flags & JITDATA_FLAG_IFCONV) - -#define JITDATA_HAS_FLAG_REORDER(jd) \ - ((jd)->flags & JITDATA_FLAG_REORDER) - -#define JITDATA_HAS_FLAG_INLINE(jd) \ - ((jd)->flags & JITDATA_FLAG_INLINE) - -#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \ - ((jd)->flags & JITDATA_FLAG_COUNTDOWN) - -#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \ - ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE) - -#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \ - ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE) - -#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \ - ((jd)->flags & JITDATA_FLAG_VERBOSECALL) - - -/* exception_entry ************************************************************/ - -struct exception_entry { - basicblock *start; - basicblock *end; - basicblock *handler; - classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall) */ - exception_entry *next; /* next in list of exceptions when */ - /* loops are copied */ - exception_entry *down; /* next exception_entry */ -}; - - -/* macros for accessing variables ********************************************* - - Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)), - use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])). - -******************************************************************************/ - -#define VAROP(v) (jd->var + (v).varindex) -#define VAR(i) (jd->var + (i)) - -static inline bool var_is_local(const jitdata *jd, s4 i) { - return (i < jd->localcount); -} - -static inline bool var_is_prealloc(const jitdata *jd, s4 i) { - return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC)); -} - -static inline bool var_is_inout(const jitdata *jd, s4 i) { - const varinfo *v = jd->var + i; - return ( - (i >= jd->localcount) && ( - (!(v->flags & PREALLOC) && (v->flags & INOUT)) || - /* special case of TYPE_RET, used with JSR */ - ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET)) - ) - ); -} - -static inline bool var_is_temp(const jitdata *jd, s4 i) { - const varinfo *v = jd->var + i; - return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT)); -} - -static inline bool var_is_saved(const jitdata *jd, s4 i) { - return (jd->var[i].flags & SAVEDVAR); -} - - -/**************************** instruction structure ***************************/ - -/* branch_target_t: used in TABLESWITCH tables */ - -typedef union { - s4 insindex; /* used in parse */ - basicblock *block; /* valid after parse */ -} branch_target_t; - -/* lookup_target_t: used in LOOKUPSWITCH tables */ - -typedef struct { - s4 value; /* case value */ - branch_target_t target; /* branch target, see above */ -} lookup_target_t; - -/*** s1 operand ***/ - -typedef union { - s4 varindex; - s4 argcount; -} s1_operand_t; - -/*** s2 operand ***/ - -typedef union { - s4 varindex; - s4 *args; - classref_or_classinfo c; - unresolved_class *uc; - ptrint constval; /* for PUT*CONST */ - s4 tablelow; /* for TABLESWITCH */ - u4 lookupcount; /* for LOOKUPSWITCH */ - s4 retaddrnr; /* for ASTORE */ - instruction **iargs; /* for PHI */ -} s2_operand_t; - -/*** s3 operand ***/ - -typedef union { - s4 varindex; - ptrint constval; - classref_or_classinfo c; - constant_FMIref *fmiref; - unresolved_method *um; - unresolved_field *uf; - insinfo_inline *inlineinfo; /* for INLINE_START/END */ - s4 tablehigh; /* for TABLESWITCH */ - branch_target_t lookupdefault; /* for LOOKUPSWITCH */ - branch_target_t jsrtarget; /* for JSR */ - s4 javaindex; /* for *STORE */ - struct builtintable_entry *bte; -} s3_operand_t; - -/*** val operand ***/ - -typedef union { - s4 i; - s8 l; - float f; - double d; - void *anyptr; - java_handle_t *stringconst; /* for ACONST with string */ - classref_or_classinfo c; /* for ACONST with class */ -} val_operand_t; - -/*** dst operand ***/ - -typedef union { - s4 varindex; - basicblock *block; /* valid after parse */ - branch_target_t *table; /* for TABLESWITCH */ - lookup_target_t *lookup; /* for LOOKUPSWITCH */ - s4 insindex; /* used in parse */ -} dst_operand_t; - -/*** flags (32 bits) ***/ - -#define INS_FLAG_BASICBLOCK 0x01 /* marks a basic block start */ -#define INS_FLAG_UNRESOLVED 0x02 /* contains unresolved field/meth/class*/ -#define INS_FLAG_CLASS 0x04 /* for ACONST, PUT*CONST with class */ -#define INS_FLAG_ARRAY 0x08 /* for CHECKCAST/INSTANCEOF with array */ -#define INS_FLAG_CHECK 0x10 /* for *ALOAD|*ASTORE: check index */ - /* for BUILTIN: check exception */ -#define INS_FLAG_KILL_PREV 0x04 /* for *STORE, invalidate prev local */ -#define INS_FLAG_KILL_NEXT 0x08 /* for *STORE, invalidate next local */ -#define INS_FLAG_RETADDR 0x10 /* for ASTORE: op is a returnAddress */ - -#define INS_FLAG_ID_SHIFT 5 -#define INS_FLAG_ID_MASK (~0 << INS_FLAG_ID_SHIFT) - -typedef union { - u4 bits; -} flags_operand_t; - -/*** instruction ***/ - -/* The instruction format for the intermediate representation: */ - -struct instruction { - u2 opc; /* opcode */ - u2 line; /* line number */ -#if SIZEOF_VOID_P == 8 - flags_operand_t flags; /* 4 bytes */ -#endif - s1_operand_t s1; /* pointer-size */ - union { - struct { - s2_operand_t s2; /* pointer-size */ - s3_operand_t s3; /* pointer-size */ - } s23; /* XOR */ - val_operand_t val; /* long-size */ - } sx; - dst_operand_t dst; /* pointer-size */ -#if SIZEOF_VOID_P == 4 - flags_operand_t flags; /* 4 bytes */ -#endif -}; - - -#define INSTRUCTION_STARTS_BASICBLOCK(iptr) \ - ((iptr)->flags.bits & INS_FLAG_BASICBLOCK) - -#define INSTRUCTION_IS_RESOLVED(iptr) \ - (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED)) - -#define INSTRUCTION_IS_UNRESOLVED(iptr) \ - ((iptr)->flags.bits & INS_FLAG_UNRESOLVED) - -#define INSTRUCTION_MUST_CHECK(iptr) \ - ((iptr)->flags.bits & INS_FLAG_CHECK) - -#define INSTRUCTION_GET_FIELDREF(iptr,fref) \ - do { \ - if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \ - fref = iptr->sx.s23.s3.uf->fieldref; \ - else \ - fref = iptr->sx.s23.s3.fmiref; \ - } while (0) - -#define INSTRUCTION_GET_METHODREF(iptr,mref) \ - do { \ - if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \ - mref = iptr->sx.s23.s3.um->methodref; \ - else \ - mref = iptr->sx.s23.s3.fmiref; \ - } while (0) - -#define INSTRUCTION_GET_METHODDESC(iptr, md) \ - do { \ - if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \ - md = iptr->sx.s23.s3.um->methodref->parseddesc.md; \ - else \ - md = iptr->sx.s23.s3.fmiref->parseddesc.md; \ - } while (0) - -/* additional info structs for special instructions ***************************/ - -/* for ICMD_INLINE_START and ICMD_INLINE_END */ - -struct insinfo_inline { - /* fields copied from the inlining tree ----------------------------------*/ - insinfo_inline *parent; /* insinfo of the surrounding inlining, if any*/ - methodinfo *method; /* the inlined method starting/ending here */ - methodinfo *outer; /* the outer method suspended/resumed here */ - s4 synclocal; /* local index used for synchronization */ - bool synchronize; /* true if synchronization is needed */ - s4 throughcount; /* total # of pass-through variables */ - s4 paramcount; /* number of parameters of original call */ - s4 stackvarscount; /* source stackdepth at INLINE_START */ - s4 *stackvars; /* stack vars at INLINE_START */ - - /* fields set by inlining ------------------------------------------------*/ - s4 *javalocals_start; /* javalocals at start of inlined body */ - s4 *javalocals_end; /* javalocals after inlined body */ - - /* fields set by replacement point creation ------------------------------*/ -#if defined(ENABLE_REPLACEMENT) - rplpoint *rp; /* replacement point at INLINE_START */ -#endif - - /* fields set by the codegen ---------------------------------------------*/ - s4 startmpc; /* machine code offset of start of inlining */ -}; - - -/* basicblock *****************************************************************/ - -/* flags */ - -#define BBDELETED -2 -#define BBUNDEF -1 -#define BBREACHED 0 -#define BBFINISHED 1 - -#define BBTYPECHECK_UNDEF 2 -#define BBTYPECHECK_REACHED 3 - -#define BBTYPE_STD 0 /* standard basic block type */ -#define BBTYPE_EXH 1 /* exception handler basic block type */ -#define BBTYPE_SBR 2 /* subroutine basic block type */ - -#define BBFLAG_REPLACEMENT 0x01 /* put a replacement point at the start */ - -/* XXX basicblock wastes quite a lot of memory by having four flag fields */ -/* (flags, bitflags, type and lflags). Probably the last three could be */ -/* combined without loss of efficiency. The first one could be combined with */ -/* the others by using bitfields. */ - -/* XXX "flags" should probably be called "state", as it is an integer state */ - -struct basicblock { - s4 nr; /* basic block number */ - s4 flags; /* used during stack analysis, init with -1 */ - s4 bitflags; /* OR of BBFLAG_... constants, init with 0 */ - s4 type; /* basic block type (std, xhandler, subroutine*/ - s4 lflags; /* used during loop copying, init with 0 */ - - s4 icount; /* number of intermediate code instructions */ - instruction *iinstr; /* pointer to intermediate code instructions */ - - varinfo *inlocals; /* copy of locals on block entry */ - s4 *javalocals; /* map from java locals to cacao variables[+] */ - s4 *invars; /* array of in-variables at begin of block */ - s4 *outvars; /* array of out-variables at end of block */ - s4 indepth; /* stack depth at begin of basic block */ - s4 outdepth; /* stack depth end of basic block */ - s4 varstart; /* index of first non-invar block variable */ - s4 varcount; /* number of non-invar block variables */ - - s4 predecessorcount; - s4 successorcount; - basicblock **predecessors; /* array of predecessor basic blocks */ - basicblock **successors; /* array of successor basic blocks */ - - branchref *branchrefs; /* list of branches to be patched */ - - basicblock *next; /* used to build a BB list (instead of array) */ - basicblock *copied_to; /* points to the copy of this basic block */ - /* when loop nodes are copied */ - basicblock *original; /* block of which this block is a clone */ - /* NULL for the original block itself */ - methodinfo *method; /* method this block belongs to */ - insinfo_inline *inlineinfo; /* inlineinfo for the start of this block */ - - s4 mpc; /* machine code pc at start of block */ - - /* TODO: those fields are probably usefull for other passes as well. */ - -#if defined(ENABLE_SSA) - basicblock *idom; /* Immediate dominator, parent in dominator tree */ - basicblock **domsuccessors;/* Children in dominator tree */ - s4 domsuccessorcount; - - basicblock **domfrontier; /* Dominance frontier */ - s4 domfrontiercount; - - basicblock **exhandlers; /* Exception handlers for this block */ - s4 exhandlercount; - basicblock **expredecessors; /* Blocks this block is exception handler for */ - s4 expredecessorcount; - s4 exouts; /* Number of exceptional exits */ - - instruction *phis; /* Phi functions */ - s4 phicount; /* Number of phi functions */ - - void *vp; /* Freely used by different passes */ -#endif -}; - -#define FOR_EACH_SUCCESSOR(bptr, it) \ - for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it)) - -#define FOR_EACH_PREDECESSOR(bptr, it) \ - for ( \ - (it) = (bptr)->predecessors; \ - (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \ - ++(it) \ - ) - -#define FOR_EACH_INSTRUCTION(bptr, it) \ - for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it)) - -#if defined(ENABLE_SSA) - -#define FOR_EACH_EXHANDLER(bptr, it) \ - for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it)) - -#define FOR_EACH_EXPREDECESSOR(bptr, it) \ - for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it)) - -#endif - -/* [+]...the javalocals array: This array is indexed by the javaindex (the */ -/* local variable index ocurring in the original bytecode). An element */ -/* javalocals[javaindex] encodes where to find the contents of the */ -/* original variable at this point in the program. */ -/* There are three cases for javalocals[javaindex]: */ -/* >= 0.......it's an index into the jd->var array, where the */ -/* CACAO variable corresponding to the original local */ -/* can be found. */ -/* UNUSED.....the original variable is not live at this point */ -/* < UNUSED...the original variable contains a returnAddress at */ -/* this point. The number of the block to return to can */ -/* be calculated using RETADDR_FROM_JAVALOCAL: */ -/* */ -/* javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr) */ -/* RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr */ - -#define JAVALOCAL_FROM_RETADDR(nr) (UNUSED - (1 + (nr))) -#define RETADDR_FROM_JAVALOCAL(jl) (UNUSED - (1 + (jl))) - - -/* Macro for initializing newly allocated basic block's. It does not - need to zero fields, as we zero out the whole basic block array. */ - -#define BASICBLOCK_INIT(bptr,m) \ - do { \ - bptr->mpc = -1; \ - bptr->flags = -1; \ - bptr->type = BBTYPE_STD; \ - bptr->method = (m); \ - } while (0) - -static inline bool basicblock_reached(const basicblock *bptr) { - return (bptr->flags >= BBREACHED); -} - -/* data-flow constants for the ICMD table ************************************/ - -#define DF_0_TO_0 0 -#define DF_1_TO_0 1 -#define DF_2_TO_0 2 -#define DF_3_TO_0 3 - -#define DF_DST_BASE 4 /* from this value on, iptr->dst is a variable */ - -#define DF_0_TO_1 (DF_DST_BASE + 0) -#define DF_1_TO_1 (DF_DST_BASE + 1) -#define DF_2_TO_1 (DF_DST_BASE + 2) -#define DF_3_TO_1 (DF_DST_BASE + 3) -#define DF_N_TO_1 (DF_DST_BASE + 4) - -#define DF_INVOKE (DF_DST_BASE + 5) -#define DF_BUILTIN (DF_DST_BASE + 6) - -#define DF_COPY (DF_DST_BASE + 7) -#define DF_MOVE (DF_DST_BASE + 8) - -#define DF_DUP -1 -#define DF_DUP_X1 -1 -#define DF_DUP_X2 -1 -#define DF_DUP2 -1 -#define DF_DUP2_X1 -1 -#define DF_DUP2_X2 -1 -#define DF_SWAP -1 - -/* special data-flow recognized by verify/generate.pl: */ -#define DF_LOAD DF_COPY -#define DF_STORE DF_MOVE -#define DF_IINC DF_1_TO_1 -#define DF_POP DF_1_TO_0 -#define DF_POP2 DF_2_TO_0 - - -/* control-flow constants for the ICMD table *********************************/ - -#define CF_NORMAL 0 -#define CF_IF 1 - -#define CF_END_BASE 2 /* from here on, they mark the end of a superblock */ - -#define CF_END (CF_END_BASE + 0) -#define CF_GOTO (CF_END_BASE + 1) -#define CF_TABLE (CF_END_BASE + 2) -#define CF_LOOKUP (CF_END_BASE + 3) -#define CF_JSR (CF_END_BASE + 4) -#define CF_RET (CF_END_BASE + 5) - - -/* flag constants for the ICMD table *****************************************/ - -#define ICMDTABLE_PEI 0x0001 /* ICMD may throw an exception */ -#define ICMDTABLE_CALLS 0x0002 /* needs registers to be saved, may call */ - - -/* ICMD table entry **********************************************************/ - -typedef struct icmdtable_entry_t icmdtable_entry_t; - -struct icmdtable_entry_t { -#if !defined(NDEBUG) - char *name; /* name, without ICMD_ prefix */ -#endif - s4 dataflow; /* a DF_ constant, see above */ - s4 controlflow; /* a CF_ constant, see above */ - s4 flags; /* a combination of ICMDTABLE_ flags */ -}; - - -/* the ICMD table ************************************************************/ - -extern icmdtable_entry_t icmd_table[256]; - - -/********** JavaVM operation codes (sorted) and instruction lengths ***********/ - -enum { - ICMD_NOP = BC_nop, - - ICMD_ACONST = BC_aconst_null, - - ICMD_CHECKNULL = 2, - - ICMD_ICONST = BC_iconst_0, - - /* 3 */ - /* 4 */ - - ICMD_IDIVPOW2 = 5, - ICMD_LDIVPOW2 = 6, - - /* 7 */ - /* 8 */ - - ICMD_LCONST = BC_lconst_0, - - ICMD_LCMPCONST = 10, - - ICMD_FCONST = BC_fconst_0, - - /* 12 */ - /* 13 */ - - ICMD_DCONST = BC_dconst_0, - - ICMD_COPY = 15, - ICMD_MOVE = 16, - - /* 17 */ - /* 18 */ - /* 19 */ - /* 20 */ - - /* Order of LOAD instructions must be equal to order of TYPE_* - defines. */ - - ICMD_ILOAD = BC_iload, - ICMD_LLOAD = BC_lload, - ICMD_FLOAD = BC_fload, - ICMD_DLOAD = BC_dload, - ICMD_ALOAD = BC_aload, - - ICMD_IADDCONST = 26, - ICMD_ISUBCONST = 27, - ICMD_IMULCONST = 28, - ICMD_IANDCONST = 29, - ICMD_IORCONST = 30, - ICMD_IXORCONST = 31, - - ICMD_ISHLCONST = 32, - ICMD_ISHRCONST = 33, - ICMD_IUSHRCONST = 34, - - ICMD_IREMPOW2 = 35, - - ICMD_LADDCONST = 36, - ICMD_LSUBCONST = 37, - ICMD_LMULCONST = 38, - ICMD_LANDCONST = 39, - ICMD_LORCONST = 40, - ICMD_LXORCONST = 41, - - ICMD_LSHLCONST = 42, - ICMD_LSHRCONST = 43, - ICMD_LUSHRCONST = 44, - - ICMD_LREMPOW2 = 45, - - ICMD_IALOAD = BC_iaload, - ICMD_LALOAD = BC_laload, - ICMD_FALOAD = BC_faload, - ICMD_DALOAD = BC_daload, - ICMD_AALOAD = BC_aaload, - ICMD_BALOAD = BC_baload, - ICMD_CALOAD = BC_caload, - ICMD_SALOAD = BC_saload, - - /* Order of STORE instructions must be equal to order of TYPE_* - defines. */ - - ICMD_ISTORE = BC_istore, - ICMD_LSTORE = BC_lstore, - ICMD_FSTORE = BC_fstore, - ICMD_DSTORE = BC_dstore, - ICMD_ASTORE = BC_astore, - - ICMD_IF_LEQ = 59, - ICMD_IF_LNE = 60, - ICMD_IF_LLT = 61, - ICMD_IF_LGE = 62, - ICMD_IF_LGT = 63, - ICMD_IF_LLE = 64, - - ICMD_IF_LCMPEQ = 65, - ICMD_IF_LCMPNE = 66, - ICMD_IF_LCMPLT = 67, - ICMD_IF_LCMPGE = 68, - ICMD_IF_LCMPGT = 69, - ICMD_IF_LCMPLE = 70, - - /* 71 */ - /* 72 */ - /* 73 */ - /* 74 */ - /* 75 */ - /* 76 */ - /* 77 */ - /* 78 */ - - ICMD_IASTORE = BC_iastore, - ICMD_LASTORE = BC_lastore, - ICMD_FASTORE = BC_fastore, - ICMD_DASTORE = BC_dastore, - ICMD_AASTORE = BC_aastore, - ICMD_BASTORE = BC_bastore, - ICMD_CASTORE = BC_castore, - ICMD_SASTORE = BC_sastore, - - ICMD_POP = BC_pop, - ICMD_POP2 = BC_pop2, - ICMD_DUP = BC_dup, - ICMD_DUP_X1 = BC_dup_x1, - ICMD_DUP_X2 = BC_dup_x2, - ICMD_DUP2 = BC_dup2, - ICMD_DUP2_X1 = BC_dup2_x1, - ICMD_DUP2_X2 = BC_dup2_x2, - ICMD_SWAP = BC_swap, - - ICMD_IADD = BC_iadd, - ICMD_LADD = BC_ladd, - ICMD_FADD = BC_fadd, - ICMD_DADD = BC_dadd, - - ICMD_ISUB = BC_isub, - ICMD_LSUB = BC_lsub, - ICMD_FSUB = BC_fsub, - ICMD_DSUB = BC_dsub, - - ICMD_IMUL = BC_imul, - ICMD_LMUL = BC_lmul, - ICMD_FMUL = BC_fmul, - ICMD_DMUL = BC_dmul, - - ICMD_IDIV = BC_idiv, - ICMD_LDIV = BC_ldiv, - ICMD_FDIV = BC_fdiv, - ICMD_DDIV = BC_ddiv, - - ICMD_IREM = BC_irem, - ICMD_LREM = BC_lrem, - ICMD_FREM = BC_frem, - ICMD_DREM = BC_drem, - - ICMD_INEG = BC_ineg, - ICMD_LNEG = BC_lneg, - ICMD_FNEG = BC_fneg, - ICMD_DNEG = BC_dneg, - - ICMD_ISHL = BC_ishl, - ICMD_LSHL = BC_lshl, - ICMD_ISHR = BC_ishr, - ICMD_LSHR = BC_lshr, - ICMD_IUSHR = BC_iushr, - ICMD_LUSHR = BC_lushr, - - ICMD_IAND = BC_iand, - ICMD_LAND = BC_land, - ICMD_IOR = BC_ior, - ICMD_LOR = BC_lor, - ICMD_IXOR = BC_ixor, - ICMD_LXOR = BC_lxor, - - ICMD_IINC = BC_iinc, - - ICMD_I2L = BC_i2l, - ICMD_I2F = BC_i2f, - ICMD_I2D = BC_i2d, - ICMD_L2I = BC_l2i, - ICMD_L2F = BC_l2f, - ICMD_L2D = BC_l2d, - ICMD_F2I = BC_f2i, - ICMD_F2L = BC_f2l, - ICMD_F2D = BC_f2d, - ICMD_D2I = BC_d2i, - ICMD_D2L = BC_d2l, - ICMD_D2F = BC_d2f, - - ICMD_INT2BYTE = BC_int2byte, - ICMD_INT2CHAR = BC_int2char, - ICMD_INT2SHORT = BC_int2short, - - ICMD_LCMP = BC_lcmp, - ICMD_FCMPL = BC_fcmpl, - ICMD_FCMPG = BC_fcmpg, - ICMD_DCMPL = BC_dcmpl, - ICMD_DCMPG = BC_dcmpg, - - ICMD_IFEQ = BC_ifeq, - ICMD_IFNE = BC_ifne, - ICMD_IFLT = BC_iflt, - ICMD_IFGE = BC_ifge, - ICMD_IFGT = BC_ifgt, - ICMD_IFLE = BC_ifle, - - ICMD_IF_ICMPEQ = BC_if_icmpeq, - ICMD_IF_ICMPNE = BC_if_icmpne, - ICMD_IF_ICMPLT = BC_if_icmplt, - ICMD_IF_ICMPGE = BC_if_icmpge, - ICMD_IF_ICMPGT = BC_if_icmpgt, - ICMD_IF_ICMPLE = BC_if_icmple, - ICMD_IF_ACMPEQ = BC_if_acmpeq, - ICMD_IF_ACMPNE = BC_if_acmpne, - - ICMD_GOTO = BC_goto, - ICMD_JSR = BC_jsr, - ICMD_RET = BC_ret, - - ICMD_TABLESWITCH = BC_tableswitch, - ICMD_LOOKUPSWITCH = BC_lookupswitch, - - ICMD_IRETURN = BC_ireturn, - ICMD_LRETURN = BC_lreturn, - ICMD_FRETURN = BC_freturn, - ICMD_DRETURN = BC_dreturn, - ICMD_ARETURN = BC_areturn, - ICMD_RETURN = BC_return, - - ICMD_GETSTATIC = BC_getstatic, - ICMD_PUTSTATIC = BC_putstatic, - ICMD_GETFIELD = BC_getfield, - ICMD_PUTFIELD = BC_putfield, - - ICMD_INVOKEVIRTUAL = BC_invokevirtual, - ICMD_INVOKESPECIAL = BC_invokespecial, - ICMD_INVOKESTATIC = BC_invokestatic, - ICMD_INVOKEINTERFACE = BC_invokeinterface, - - /* 186 */ - - ICMD_NEW = BC_new, - ICMD_NEWARRAY = BC_newarray, - ICMD_ANEWARRAY = BC_anewarray, - - ICMD_ARRAYLENGTH = BC_arraylength, - - ICMD_ATHROW = BC_athrow, - - ICMD_CHECKCAST = BC_checkcast, - ICMD_INSTANCEOF = BC_instanceof, - - ICMD_MONITORENTER = BC_monitorenter, - ICMD_MONITOREXIT = BC_monitorexit, - - /* 196 */ - - ICMD_MULTIANEWARRAY = BC_multianewarray, - - ICMD_IFNULL = BC_ifnull, - ICMD_IFNONNULL = BC_ifnonnull, - - /* 200 */ - /* 201 */ - /* 202 */ - - ICMD_IASTORECONST = 204, - ICMD_LASTORECONST = 205, - ICMD_FASTORECONST = 206, - ICMD_DASTORECONST = 207, - ICMD_AASTORECONST = 208, - ICMD_BASTORECONST = 209, - ICMD_CASTORECONST = 210, - ICMD_SASTORECONST = 211, - - ICMD_PUTSTATICCONST = 212, - ICMD_PUTFIELDCONST = 213, - - ICMD_IMULPOW2 = 214, - ICMD_LMULPOW2 = 215, - - ICMD_GETEXCEPTION = 249, - ICMD_PHI = 250, - - ICMD_INLINE_START = 251, /* instruction before inlined method */ - ICMD_INLINE_END = 252, /* instruction after inlined method */ - ICMD_INLINE_BODY = 253, /* start of inlined body */ - - ICMD_BUILTIN = 255 /* internal opcode */ -}; - -/* Additional instruction accessors */ - -methoddesc *instruction_call_site(const instruction *iptr); - -static inline bool instruction_has_dst(const instruction *iptr) { - if ( - (icmd_table[iptr->opc].dataflow == DF_INVOKE) || - (icmd_table[iptr->opc].dataflow == DF_BUILTIN) - ) { - return instruction_call_site(iptr)->returntype.type != TYPE_VOID; - } else { - return icmd_table[iptr->opc].dataflow >= DF_DST_BASE; - } -} - -/***************************** register types *********************************/ - -#define REG_RES 0 /* reserved register for OS or code generator */ -#define REG_RET 1 /* return value register */ -#define REG_EXC 2 /* exception value register */ -#define REG_SAV 3 /* (callee) saved register */ -#define REG_TMP 4 /* scratch temporary register (caller saved) */ -#define REG_ARG 5 /* argument register (caller saved) */ - -#define REG_END -1 /* last entry in tables */ - -#define PARAMMODE_NUMBERED 0 -#define PARAMMODE_STUFFED 1 - - -/* function prototypes ********************************************************/ - -/* compiler initialisation */ -void jit_init(void); - -/* compiler finalisation */ -void jit_close(void); - -/* create a new jitdata */ -jitdata *jit_jitdata_new(methodinfo *m); - -/* compile a method with jit compiler */ -u1 *jit_compile(methodinfo *m); -u1 *jit_recompile(methodinfo *m); - -void jit_invalidate_code(methodinfo *m); -codeinfo *jit_get_current_code(methodinfo *m); -void jit_request_optimization(methodinfo *m); - -/* patch the method entrypoint */ -#if !defined(JIT_COMPILER_VIA_SIGNAL) -u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra); -#endif -void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr); - -s4 jit_complement_condition(s4 opcode); - -void jit_renumber_basicblocks(jitdata *jd); -#if !defined(NDEBUG) -void jit_check_basicblock_numbers(jitdata *jd); -#endif - - -/* machine dependent functions ************************************************/ - -#if defined(ENABLE_JIT) -void md_init(void); -#endif - -#if defined(ENABLE_INTRP) -void intrp_md_init(void); -#endif - -void *md_jit_method_patch_address(void *pv, void *ra, void *mptr); - -#endif /* _JIT_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/jit.hpp b/src/vm/jit/jit.hpp new file mode 100644 index 000000000..bb28fceeb --- /dev/null +++ b/src/vm/jit/jit.hpp @@ -0,0 +1,495 @@ +/* src/vm/jit/jit.hpp - Just-In-Time compiler + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _JIT_HPP +#define _JIT_HPP + +/* forward typedefs ***********************************************************/ + +typedef struct jitdata jitdata; +typedef struct basicblock basicblock; +typedef struct exception_entry exception_entry; + + +#include "config.h" +#include "vm/types.h" + +#include "vm/global.h" +#include "vm/method.h" +#include "vm/references.h" +#include "vm/resolve.h" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/reg.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stack.h" +#include "vm/jit/stacktrace.hpp" + +#if defined(ENABLE_INLINING) +# include "vm/jit/inline/inline.h" +#endif + +#include "vm/jit/ir/bytecode.h" +#include "vm/jit/ir/instruction.hpp" + +#if defined(ENABLE_LOOP) +# include "vm/jit/loop/loop.h" +#endif +#if defined(ENABLE_SSA) +# include "vm/jit/optimizing/lsra.h" +#endif +#if defined(ENABLE_LSRA) +# include "vm/jit/allocator/lsra.h" +#endif + +#include "vm/jit/verify/typeinfo.h" + + +/* common jit/codegen macros **************************************************/ + +#if defined(ENABLE_STATISTICS) +# define COUNT(x) (x)++ +# define COUNT_SPILLS /* use COUNT_(READ|WRITE)_SPILLS instead */ +# define COUNT_READ_SPILLS(var) \ + switch(var->type) { \ + case TYPE_FLT: count_spills_read_flt++; break; \ + case TYPE_DBL: count_spills_read_dbl++; break; \ + default: count_spills_read_ila++; break; \ + } + +# define COUNT_WRITE_SPILLS(var) \ + switch(var->type) { \ + case TYPE_FLT: count_spills_write_flt++; break; \ + case TYPE_DBL: count_spills_write_dbl++; break; \ + default: count_spills_write_ila++; break; \ + } + +#else +# define COUNT(x) /* nothing */ +# define COUNT_SPILLS /* nothing */ +# define COUNT_READ_SPILLS(x) /* nothing */ +# define COUNT_WRITE_SPILLS(x) /* nothing */ +#endif + +typedef struct interface_info interface_info; + +struct interface_info { + s4 flags; + s4 regoff; +}; + + +/* jitdata ********************************************************************/ + +struct jitdata { + methodinfo *m; /* methodinfo of the method compiled */ + codeinfo *code; + codegendata *cd; + registerdata *rd; +#if defined(ENABLE_LOOP) + loopdata *ld; +#endif +#if defined(ENABLE_SSA) || defined(ENABLE_LSRA) + lsradata *ls; +#endif + + u4 flags; /* contains JIT compiler flags */ + + instruction *instructions; /* ICMDs, valid between parse and stack */ + basicblock *basicblocks; /* start of basic block list */ + stackelement_t *stack; /* XXX should become stack.c internal */ + s4 instructioncount;/* XXX remove this? */ + s4 basicblockcount; /* number of basic blocks */ + s4 stackcount; /* number of stackelements to allocate */ + /* (passed from parse to stack) */ + + varinfo *var; /* array of variables */ + s4 vartop; /* next free index in var array */ + + s4 varcount; /* number of variables in var array */ + s4 localcount; /* number of locals at start of var ar. */ + s4 *local_map; /* map for renaming (de-coallescing) */ + /* locals and keeping the coalescing info for simplereg. */ + /* local_map[javaindex * 5 + type] = */ + /* >= 0......index into jd->var, or */ + /* UNUSED....this (javaindex,type) pair is not used */ + + s4 *reverselocalmap; /* map from CACAO varindex to javaindex */ + /* (varindex must be < localcount) */ + + s4 maxlocals; /* max. number of javalocals */ + + interface_info *interface_map; /* interface variables (for simplereg) */ + s4 maxinterfaces; /* max. number of interface variables */ + + s4 exceptiontablelength; /* exceptiontable length */ + exception_entry *exceptiontable; /* the exceptiontable */ + + basicblock *returnblock; /* block containing the *RETURN */ + /* (only use if returncount==1) */ + s4 returncount; /* number of return instructions */ + bool branchtoentry; /* true if first block is a target */ + bool branchtoend; /* true if end dummy is a target */ +}; + +#define FOR_EACH_BASICBLOCK(jd, it) \ + for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next) + +#define UNUSED -1 + +#define JITDATA_FLAG_PARSE 0x00000001 +#define JITDATA_FLAG_VERIFY 0x00000002 + +#define JITDATA_FLAG_INSTRUMENT 0x00000004 + +#define JITDATA_FLAG_IFCONV 0x00000008 +#define JITDATA_FLAG_REORDER 0x00000010 +#define JITDATA_FLAG_INLINE 0x00000020 + +#define JITDATA_FLAG_COUNTDOWN 0x00000100 + +#define JITDATA_FLAG_SHOWINTERMEDIATE 0x20000000 +#define JITDATA_FLAG_SHOWDISASSEMBLE 0x40000000 +#define JITDATA_FLAG_VERBOSECALL 0x80000000 + + +#define JITDATA_HAS_FLAG_PARSE(jd) \ + ((jd)->flags & JITDATA_FLAG_PARSE) + +#define JITDATA_HAS_FLAG_VERIFY(jd) \ + ((jd)->flags & JITDATA_FLAG_VERIFY) + +#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \ + ((jd)->flags & JITDATA_FLAG_INSTRUMENT) + +#define JITDATA_HAS_FLAG_IFCONV(jd) \ + ((jd)->flags & JITDATA_FLAG_IFCONV) + +#define JITDATA_HAS_FLAG_REORDER(jd) \ + ((jd)->flags & JITDATA_FLAG_REORDER) + +#define JITDATA_HAS_FLAG_INLINE(jd) \ + ((jd)->flags & JITDATA_FLAG_INLINE) + +#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \ + ((jd)->flags & JITDATA_FLAG_COUNTDOWN) + +#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \ + ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE) + +#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \ + ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE) + +#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \ + ((jd)->flags & JITDATA_FLAG_VERBOSECALL) + + +/* exception_entry ************************************************************/ + +struct exception_entry { + basicblock *start; + basicblock *end; + basicblock *handler; + classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall) */ + exception_entry *next; /* next in list of exceptions when */ + /* loops are copied */ + exception_entry *down; /* next exception_entry */ +}; + + +/* macros for accessing variables ********************************************* + + Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)), + use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])). + +******************************************************************************/ + +#define VAROP(v) (jd->var + (v).varindex) +#define VAR(i) (jd->var + (i)) + +static inline bool var_is_local(const jitdata *jd, s4 i) { + return (i < jd->localcount); +} + +static inline bool var_is_prealloc(const jitdata *jd, s4 i) { + return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC)); +} + +static inline bool var_is_inout(const jitdata *jd, s4 i) { + const varinfo *v = jd->var + i; + return ( + (i >= jd->localcount) && ( + (!(v->flags & PREALLOC) && (v->flags & INOUT)) || + /* special case of TYPE_RET, used with JSR */ + ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET)) + ) + ); +} + +static inline bool var_is_temp(const jitdata *jd, s4 i) { + const varinfo *v = jd->var + i; + return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT)); +} + +static inline bool var_is_saved(const jitdata *jd, s4 i) { + return (jd->var[i].flags & SAVEDVAR); +} + + +/* basicblock *****************************************************************/ + +/* flags */ + +#define BBDELETED -2 +#define BBUNDEF -1 +#define BBREACHED 0 +#define BBFINISHED 1 + +#define BBTYPECHECK_UNDEF 2 +#define BBTYPECHECK_REACHED 3 + +#define BBTYPE_STD 0 /* standard basic block type */ +#define BBTYPE_EXH 1 /* exception handler basic block type */ +#define BBTYPE_SBR 2 /* subroutine basic block type */ + +#define BBFLAG_REPLACEMENT 0x01 /* put a replacement point at the start */ + +/* XXX basicblock wastes quite a lot of memory by having four flag fields */ +/* (flags, bitflags, type and lflags). Probably the last three could be */ +/* combined without loss of efficiency. The first one could be combined with */ +/* the others by using bitfields. */ + +/* XXX "flags" should probably be called "state", as it is an integer state */ + +struct basicblock { + s4 nr; /* basic block number */ + s4 flags; /* used during stack analysis, init with -1 */ + s4 bitflags; /* OR of BBFLAG_... constants, init with 0 */ + s4 type; /* basic block type (std, xhandler, subroutine*/ + s4 lflags; /* used during loop copying, init with 0 */ + + s4 icount; /* number of intermediate code instructions */ + instruction *iinstr; /* pointer to intermediate code instructions */ + + varinfo *inlocals; /* copy of locals on block entry */ + s4 *javalocals; /* map from java locals to cacao variables[+] */ + s4 *invars; /* array of in-variables at begin of block */ + s4 *outvars; /* array of out-variables at end of block */ + s4 indepth; /* stack depth at begin of basic block */ + s4 outdepth; /* stack depth end of basic block */ + s4 varstart; /* index of first non-invar block variable */ + s4 varcount; /* number of non-invar block variables */ + + s4 predecessorcount; + s4 successorcount; + basicblock **predecessors; /* array of predecessor basic blocks */ + basicblock **successors; /* array of successor basic blocks */ + + branchref *branchrefs; /* list of branches to be patched */ + + basicblock *next; /* used to build a BB list (instead of array) */ + basicblock *copied_to; /* points to the copy of this basic block */ + /* when loop nodes are copied */ + basicblock *original; /* block of which this block is a clone */ + /* NULL for the original block itself */ + methodinfo *method; /* method this block belongs to */ + insinfo_inline *inlineinfo; /* inlineinfo for the start of this block */ + + s4 mpc; /* machine code pc at start of block */ + + /* TODO: those fields are probably usefull for other passes as well. */ + +#if defined(ENABLE_SSA) + basicblock *idom; /* Immediate dominator, parent in dominator tree */ + basicblock **domsuccessors;/* Children in dominator tree */ + s4 domsuccessorcount; + + basicblock **domfrontier; /* Dominance frontier */ + s4 domfrontiercount; + + basicblock **exhandlers; /* Exception handlers for this block */ + s4 exhandlercount; + basicblock **expredecessors; /* Blocks this block is exception handler for */ + s4 expredecessorcount; + s4 exouts; /* Number of exceptional exits */ + + instruction *phis; /* Phi functions */ + s4 phicount; /* Number of phi functions */ + + void *vp; /* Freely used by different passes */ +#endif +}; + +#define FOR_EACH_SUCCESSOR(bptr, it) \ + for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it)) + +#define FOR_EACH_PREDECESSOR(bptr, it) \ + for ( \ + (it) = (bptr)->predecessors; \ + (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \ + ++(it) \ + ) + +#define FOR_EACH_INSTRUCTION(bptr, it) \ + for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it)) + +#define FOR_EACH_INSTRUCTION_REV(bptr, it) \ + for ((it) = (bptr)->iinstr + (bptr)->icount - 1; (it) != (bptr)->iinstr - 1; --(it)) + +#if defined(ENABLE_SSA) + +#define FOR_EACH_EXHANDLER(bptr, it) \ + for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it)) + +#define FOR_EACH_EXPREDECESSOR(bptr, it) \ + for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it)) + +#endif + +/* [+]...the javalocals array: This array is indexed by the javaindex (the */ +/* local variable index ocurring in the original bytecode). An element */ +/* javalocals[javaindex] encodes where to find the contents of the */ +/* original variable at this point in the program. */ +/* There are three cases for javalocals[javaindex]: */ +/* >= 0.......it's an index into the jd->var array, where the */ +/* CACAO variable corresponding to the original local */ +/* can be found. */ +/* UNUSED.....the original variable is not live at this point */ +/* < UNUSED...the original variable contains a returnAddress at */ +/* this point. The number of the block to return to can */ +/* be calculated using RETADDR_FROM_JAVALOCAL: */ +/* */ +/* javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr) */ +/* RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr */ + +#define JAVALOCAL_FROM_RETADDR(nr) (UNUSED - (1 + (nr))) +#define RETADDR_FROM_JAVALOCAL(jl) (UNUSED - (1 + (jl))) + + +/* Macro for initializing newly allocated basic block's. It does not + need to zero fields, as we zero out the whole basic block array. */ + +#define BASICBLOCK_INIT(bptr,m) \ + do { \ + bptr->mpc = -1; \ + bptr->flags = -1; \ + bptr->type = BBTYPE_STD; \ + bptr->method = (m); \ + } while (0) + +static inline bool basicblock_reached(const basicblock *bptr) { + return (bptr->flags >= BBREACHED); +} + + + +/***************************** register types *********************************/ + +#define REG_RES 0 /* reserved register for OS or code generator */ +#define REG_RET 1 /* return value register */ +#define REG_EXC 2 /* exception value register */ +#define REG_SAV 3 /* (callee) saved register */ +#define REG_TMP 4 /* scratch temporary register (caller saved) */ +#define REG_ARG 5 /* argument register (caller saved) */ + +#define REG_END -1 /* last entry in tables */ + +#define PARAMMODE_NUMBERED 0 +#define PARAMMODE_STUFFED 1 + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* compiler initialisation */ +void jit_init(void); + +/* compiler finalisation */ +void jit_close(void); + +/* create a new jitdata */ +jitdata *jit_jitdata_new(methodinfo *m); + +/* compile a method with jit compiler */ +u1 *jit_compile(methodinfo *m); +u1 *jit_recompile(methodinfo *m); + +void jit_invalidate_code(methodinfo *m); +codeinfo *jit_get_current_code(methodinfo *m); +void jit_request_optimization(methodinfo *m); + +/* patch the method entrypoint */ +#if !defined(JIT_COMPILER_VIA_SIGNAL) +void *jit_asm_compile(methodinfo *m, void* mptr, void* sp, void* ra); +#endif +void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr); + +s4 jit_complement_condition(s4 opcode); + +void jit_renumber_basicblocks(jitdata *jd); +#if !defined(NDEBUG) +void jit_check_basicblock_numbers(jitdata *jd); +#endif + + +/* machine dependent functions ************************************************/ + +#if defined(ENABLE_JIT) +void md_init(void); +#endif + +#if defined(ENABLE_INTRP) +void intrp_md_init(void); +#endif + +void *md_jit_method_patch_address(void *pv, void *ra, void *mptr); + +#ifdef __cplusplus +} +#endif + +#endif // _JIT_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/linenumbertable.c b/src/vm/jit/linenumbertable.c index 835fea314..e906a06f7 100644 --- a/src/vm/jit/linenumbertable.c +++ b/src/vm/jit/linenumbertable.c @@ -30,15 +30,16 @@ #include "mm/memory.h" -#include "vm/jit/code.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/linenumbertable.h" - #if defined(ENABLE_STATISTICS) -# include "vmcore/options.h" -# include "vmcore/statistics.h" +# include "vm/options.h" +# include "vm/statistics.h" #endif +#include "vm/jit/code.hpp" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/linenumbertable.h" + + #if defined(__S390__) # define ADDR_MASK(type, x) ((type)((uintptr_t)(x) & 0x7FFFFFFF)) #else diff --git a/src/vm/jit/linenumbertable.h b/src/vm/jit/linenumbertable.h index 925cf2405..94ede9b10 100644 --- a/src/vm/jit/linenumbertable.h +++ b/src/vm/jit/linenumbertable.h @@ -1,6 +1,6 @@ /* src/vm/jit/linenumbertable.h - linenumber table - Copyright (C) 2007 + Copyright (C) 2007, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -39,12 +39,18 @@ typedef struct linenumbertable_list_entry_t linenumbertable_list_entry_t; #include "toolbox/list.h" -#include "vm/jit/jit.h" -#include "vm/jit/code.h" -#include "vm/jit/codegen-common.h" +#include "vm/method.h" -#include "vmcore/method.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/code.hpp" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/ir/instruction.hpp" + + +#ifdef __cplusplus +extern "C" { +#endif /* linenumbertable_t **********************************************************/ @@ -94,6 +100,10 @@ void linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction * int32_t linenumbertable_linenumber_for_pc(methodinfo **pm, codeinfo *code, void *pc); +#ifdef __cplusplus +} +#endif + #endif /* _LINENUMBERTABLE_H */ diff --git a/src/vm/jit/loop/analyze.c b/src/vm/jit/loop/analyze.c index 43a7dad53..211e492bd 100644 --- a/src/vm/jit/loop/analyze.c +++ b/src/vm/jit/loop/analyze.c @@ -35,7 +35,7 @@ #include "mm/memory.h" #include "toolbox/logging.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/stack.h" #include "vm/jit/loop/analyze.h" diff --git a/src/vm/jit/loop/analyze.h b/src/vm/jit/loop/analyze.h index d8fbc5e01..5b6650b24 100644 --- a/src/vm/jit/loop/analyze.h +++ b/src/vm/jit/loop/analyze.h @@ -36,7 +36,7 @@ #include "config.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* function prototypes ********************************************************/ diff --git a/src/vm/jit/loop/graph.c b/src/vm/jit/loop/graph.c index 09cd21d53..91f580d4b 100644 --- a/src/vm/jit/loop/graph.c +++ b/src/vm/jit/loop/graph.c @@ -38,7 +38,7 @@ #include "mm/memory.h" #include "toolbox/logging.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/loop/graph.h" #include "vm/jit/loop/loop.h" diff --git a/src/vm/jit/loop/graph.h b/src/vm/jit/loop/graph.h index ff3beb1f5..2f5978485 100644 --- a/src/vm/jit/loop/graph.h +++ b/src/vm/jit/loop/graph.h @@ -1,9 +1,7 @@ /* src/vm/jit/loop/graph.h - control flow graph header Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -31,9 +29,9 @@ #include "config.h" #include "vm/types.h" -#include "vm/jit/loop/loop.h" +#include "vm/method.h" -#include "vmcore/method.h" +#include "vm/jit/loop/loop.h" /* function prototypes ********************************************************/ diff --git a/src/vm/jit/loop/loop.c b/src/vm/jit/loop/loop.c index e817f02ba..56d4ee09f 100644 --- a/src/vm/jit/loop/loop.c +++ b/src/vm/jit/loop/loop.c @@ -43,7 +43,7 @@ #include "mm/memory.h" #include "toolbox/logging.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/loop/loop.h" #include "vm/jit/loop/graph.h" #include "vm/jit/loop/tracing.h" diff --git a/src/vm/jit/loop/loop.h b/src/vm/jit/loop/loop.h index 881fc746a..0a2eaa54a 100644 --- a/src/vm/jit/loop/loop.h +++ b/src/vm/jit/loop/loop.h @@ -1,9 +1,7 @@ /* src/vm/jit/loop/loop.h - array bound removal header - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -32,10 +30,9 @@ #include "vm/types.h" #include "vm/global.h" +#include "vm/method.h" -#include "vm/jit/jit.h" - -#include "vmcore/method.h" +#include "vm/jit/jit.hpp" /* Different types for struct Trace */ diff --git a/src/vm/jit/loop/tracing.c b/src/vm/jit/loop/tracing.c index 13df1e949..83e273e7d 100644 --- a/src/vm/jit/loop/tracing.c +++ b/src/vm/jit/loop/tracing.c @@ -35,7 +35,7 @@ #include "mm/memory.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "vm/resolve.h" #include "vm/jit/loop/loop.h" #include "vm/jit/loop/tracing.h" diff --git a/src/vm/jit/loop/tracing.h b/src/vm/jit/loop/tracing.h index d506be50e..fe4653be2 100644 --- a/src/vm/jit/loop/tracing.h +++ b/src/vm/jit/loop/tracing.h @@ -33,7 +33,7 @@ #ifndef _TRACING_H #define _TRACING_H -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" typedef struct Trace Trace; diff --git a/src/vm/jit/m68k/Makefile.am b/src/vm/jit/m68k/Makefile.am index eb3c1f4ac..85da92d08 100644 --- a/src/vm/jit/m68k/Makefile.am +++ b/src/vm/jit/m68k/Makefile.am @@ -33,7 +33,7 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h + md-atomic.hpp noinst_LTLIBRARIES = \ libarch.la @@ -51,6 +51,7 @@ libarch_la_SOURCES = \ emit.c \ patcher.c \ \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/m68k/codegen.c b/src/vm/jit/m68k/codegen.c index 41bd7c7f7..5d38065b9 100644 --- a/src/vm/jit/m68k/codegen.c +++ b/src/vm/jit/m68k/codegen.c @@ -35,36 +35,34 @@ #include "vm/jit/m68k/emit.h" #include "mm/memory.h" -#include "native/jni.h" + #include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/utf8.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/dseg.h" #include "vm/jit/linenumbertable.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/abi.h" #include "vm/jit/parse.h" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/utf8.h" - bool codegen_emit(jitdata *jd) { @@ -1994,9 +1992,6 @@ nowperformreturn: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ATMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); @@ -2060,14 +2055,10 @@ nowperformreturn: M_ALD(REG_ATMP1, s1, OFFSET(java_object_t, vftbl)); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP1, REG_ATMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ATMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_ISUB(REG_ITMP3, REG_ITMP1); M_ICMP(REG_ITMP2, REG_ITMP1); M_BHI(4); @@ -2119,9 +2110,6 @@ nowperformreturn: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ATMP1); assert(VAROP(iptr->s1)->type == TYPE_ADR); @@ -2181,14 +2169,10 @@ nowperformreturn: M_ALD(REG_ATMP2, s1, OFFSET(java_object_t, vftbl)); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval)); /* REG_ITMP3 == sub->vftbl->baseval */ M_ILD(REG_ITMP1, REG_ATMP3, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ATMP3, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_ISUB(REG_ITMP1, REG_ITMP3); M_ICMP(REG_ITMP2, REG_ITMP3); /* XXX was CMPU */ @@ -2455,7 +2439,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s M_AST(REG_ATMP3, REG_SP, 1 * 4); /* env ist first argument */ - M_AMOV_IMM(_Jv_env, REG_ATMP1); + M_AMOV_IMM(VM_get_jnienv(), REG_ATMP1); M_AST(REG_ATMP1, REG_SP, 0 * 4); } diff --git a/src/vm/jit/m68k/codegen.h b/src/vm/jit/m68k/codegen.h index 689dd9b6a..0cb13d0fa 100644 --- a/src/vm/jit/m68k/codegen.h +++ b/src/vm/jit/m68k/codegen.h @@ -1,9 +1,7 @@ /* src/vm/jit/m68k/codegen.h - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -63,11 +61,7 @@ #define PATCHER_NOPS \ do { M_TPFL; M_TPF; M_TPF } while (0); -#define PATCHER_CALL_SIZE (3*2) - -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE (2+2) +#define PATCHER_CALL_SIZE 2 /* coldfire instruction format: diff --git a/src/vm/jit/m68k/emit.c b/src/vm/jit/m68k/emit.c index 0b48ac636..81fc1288f 100644 --- a/src/vm/jit/m68k/emit.c +++ b/src/vm/jit/m68k/emit.c @@ -1,9 +1,7 @@ /* src/vm/jit/m68k/emit.c - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -34,12 +32,11 @@ #include "mm/memory.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/trace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" diff --git a/src/vm/jit/m68k/emit.h b/src/vm/jit/m68k/emit.h index 778c700bf..c0358ea8d 100644 --- a/src/vm/jit/m68k/emit.h +++ b/src/vm/jit/m68k/emit.h @@ -30,8 +30,8 @@ #include "config.h" #include "vm/types.h" -#include "vm/vm.h" -#include "vm/jit/codegen-common.h" +#include "vm/vm.hpp" +#include "vm/jit/codegen-common.hpp" void emit_mov_imm_reg (codegendata *cd, s4 imm, s4 dreg); void emit_mov_imm_areg(codegendata *cd, s4 imm, s4 dreg); diff --git a/src/vm/jit/m68k/linux/md-os.c b/src/vm/jit/m68k/linux/md-os.c index 444f55c97..21c54f56d 100644 --- a/src/vm/jit/m68k/linux/md-os.c +++ b/src/vm/jit/m68k/linux/md-os.c @@ -28,9 +28,8 @@ #include "vm/jit/m68k/md.h" #include "vm/jit/m68k/linux/md-abi.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" #include "vm/jit/trap.h" diff --git a/src/vm/jit/m68k/machine-instr.h b/src/vm/jit/m68k/machine-instr.h deleted file mode 100644 index 021e723b9..000000000 --- a/src/vm/jit/m68k/machine-instr.h +++ /dev/null @@ -1,62 +0,0 @@ -/* src/vm/jit/m68k/machine-instr.h - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long compare_and_swap(long *p, long oldval, long newval) -{ - /* XXX, coldifre has no atomic compare and swap instrcution */ - #warning "compare_and_swap is not atmically" - if (*p == oldval) { - *p = newval; - return oldval; - } - return *p; -} - - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER() __asm__ __volatile__ ( "" : : : "memory" ); - -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/m68k/md-atomic.hpp b/src/vm/jit/m68k/md-atomic.hpp new file mode 100644 index 000000000..ad5d4d247 --- /dev/null +++ b/src/vm/jit/m68k/md-atomic.hpp @@ -0,0 +1,122 @@ +/* src/vm/jit/m68k/md-atomic.hpp - m68k atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + return generic_compare_and_swap(p, oldval, newval); +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + return generic_compare_and_swap(p, oldval, newval); +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return generic_compare_and_swap(p, oldval, newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + generic_memory_barrier(); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/m68k/md-stubs.hpp b/src/vm/jit/m68k/md-stubs.hpp new file mode 100644 index 000000000..e7f84f6f3 --- /dev/null +++ b/src/vm/jit/m68k/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/m68k/md-stubs.hpp - m68k JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on a m68k architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 2 + 2; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/m68k/md-trap.h b/src/vm/jit/m68k/md-trap.h index 69a15a315..0e5fcca3c 100644 --- a/src/vm/jit/m68k/md-trap.h +++ b/src/vm/jit/m68k/md-trap.h @@ -48,7 +48,8 @@ enum { TRAP_ClassCastException = 5, TRAP_CHECK_EXCEPTION = 6, TRAP_PATCHER = 7, - TRAP_COMPILER = 8 + TRAP_COMPILER = 8, + TRAP_COUNTDOWN = 9 }; #endif /* _MD_TRAP_H */ diff --git a/src/vm/jit/m68k/md.c b/src/vm/jit/m68k/md.c index 9fb12da0c..071a19530 100644 --- a/src/vm/jit/m68k/md.c +++ b/src/vm/jit/m68k/md.c @@ -32,7 +32,7 @@ #include "vm/types.h" -#include "vm/vm.h" +#include "vm/vm.hpp" /* diff --git a/src/vm/jit/m68k/md.h b/src/vm/jit/m68k/md.h index bc64f4c73..5514cc4b8 100644 --- a/src/vm/jit/m68k/md.h +++ b/src/vm/jit/m68k/md.h @@ -33,7 +33,7 @@ #include #include -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/methodtree.h" diff --git a/src/vm/jit/m68k/patcher.c b/src/vm/jit/m68k/patcher.c index 71607c7f4..c9f55dfac 100644 --- a/src/vm/jit/m68k/patcher.c +++ b/src/vm/jit/m68k/patcher.c @@ -34,19 +34,16 @@ #include "mm/memory.h" #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" +#include "vm/options.h" +#include "vm/references.h" #include "vm/resolve.h" #include "vm/jit/asmpart.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" +#include "vm/jit/patcher-common.hpp" #include "codegen.h" @@ -133,9 +130,6 @@ bool patcher_invokevirtual(patchref_t *pr) /* patch back original code */ PATCH_BACK_ORIGINAL_MCODE; - /* if we show NOPs, we have to skip them */ - if (opt_shownops) ra += PATCHER_CALL_SIZE; - assert( *((u2*)(ra+8)) == 0x286b); /* patch vftbl index */ @@ -176,9 +170,6 @@ bool patcher_invokestatic_special(patchref_t *pr) /* patch back original code */ PATCH_BACK_ORIGINAL_MCODE; - /* patch stubroutine */ - if (opt_shownops) disp += PATCHER_CALL_SIZE; - *((ptrint *) (disp+2)) = (ptrint) m->stubroutine; /* synchronize inst cache */ @@ -212,7 +203,6 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; /* patch the classinfo pointer */ - if (opt_shownops) disp += PATCHER_CALL_SIZE; *((ptrint *) (disp+2)) = (ptrint) c; /* synchronize inst cache */ @@ -251,7 +241,6 @@ bool patcher_get_putstatic(patchref_t *pr) md_icacheflush(pr->mpc, 2); /* patch the field value's address */ - if (opt_shownops) disp += PATCHER_CALL_SIZE; assert(*((uint16_t*)(disp)) == 0x247c); *((intptr_t *) (disp+2)) = (intptr_t) fi->value; @@ -286,9 +275,6 @@ bool patcher_get_putfield(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; md_icacheflush(pr->mpc, 2); - /* if we show NOPs, we have to skip them */ - if (opt_shownops) ra += PATCHER_CALL_SIZE; - /* patch the field's offset */ if (IS_LNG_TYPE(fi->type)) { /* @@ -374,7 +360,6 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr) md_icacheflush(pr->mpc, 2); /* patch class flags */ - if (opt_shownops) disp += PATCHER_CALL_SIZE; assert( (*((u2*)(disp)) == 0x263c) || (*((u2*)(disp)) == 0x283c) ); *((s4 *) (disp + 2)) = (s4) c->flags; @@ -418,7 +403,6 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr) md_icacheflush(pr->mpc, 2); /* patch super class' vftbl */ - if (opt_shownops) disp += PATCHER_CALL_SIZE; assert( (*((u2*)disp) == 0x287c) || (*((u2*)disp)== 0x267c) ); *((s4 *) (disp+2)) = (s4) c->vftbl; @@ -463,9 +447,6 @@ bool patcher_instanceof_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; md_icacheflush(pr->mpc, 2); - /* if we show NOPs, we have to skip them */ - if (opt_shownops) ra += PATCHER_CALL_SIZE; - /* patch super class index */ disp = -(c->index); assert( *((u2*)(ra + 8)) == 0xd8bc ); @@ -517,9 +498,6 @@ bool patcher_checkcast_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; md_icacheflush(pr->mpc, 2); - /* if we show NOPs, we have to skip them */ - if (opt_shownops) ra += PATCHER_CALL_SIZE; - /* patch super class index */ disp = -(c->index); assert ( *((u2 *)(ra + 8)) == 0xd8bc ); @@ -562,7 +540,6 @@ bool patcher_resolve_native_function(patchref_t *pr) md_icacheflush(pr->mpc, 2); /* patch native function pointer */ - if (opt_shownops) disp += PATCHER_CALL_SIZE; *((ptrint *) (disp + 2)) = (ptrint) f; /* synchronize data cache */ @@ -604,7 +581,6 @@ bool patcher_invokeinterface(patchref_t *pr) md_icacheflush(pr->mpc, 2); /* if we show NOPs, we have to skip them */ - if (opt_shownops) ra += PATCHER_CALL_SIZE; assert( *((uint32_t*)ra) == 0x246f0000 ); /* patch interfacetable index (first #0) */ @@ -623,6 +599,8 @@ bool patcher_invokeinterface(patchref_t *pr) return true; } + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/methodtree.c b/src/vm/jit/methodtree.c index 262804ecb..0cb513794 100644 --- a/src/vm/jit/methodtree.c +++ b/src/vm/jit/methodtree.c @@ -29,12 +29,11 @@ #include "mm/memory.h" -#include "threads/thread.h" - #include "toolbox/avl.h" #include "vm/jit/asmpart.h" #include "vm/jit/methodtree.h" +#include "vm/jit/stacktrace.hpp" /* methodtree_element *********************************************************/ diff --git a/src/vm/jit/methodtree.h b/src/vm/jit/methodtree.h index e2be22043..eef8d3fca 100644 --- a/src/vm/jit/methodtree.h +++ b/src/vm/jit/methodtree.h @@ -30,6 +30,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #include "toolbox/avl.h" @@ -40,6 +44,10 @@ void methodtree_insert(void *startpc, void *endpc); void *methodtree_find(void *pc); void *methodtree_find_nocheck(void *pc); +#ifdef __cplusplus +} +#endif + #endif /* _METHODTREE_H */ diff --git a/src/vm/jit/mips/Makefile.am b/src/vm/jit/mips/Makefile.am index ce07cde79..751957ff1 100644 --- a/src/vm/jit/mips/Makefile.am +++ b/src/vm/jit/mips/Makefile.am @@ -35,9 +35,9 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h \ \ - md-asm.h + md-asm.h \ + md-atomic.hpp noinst_LTLIBRARIES = \ libarch.la @@ -57,6 +57,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/mips/asmpart.S b/src/vm/jit/mips/asmpart.S index 2a3b5fc0c..73732e6c6 100644 --- a/src/vm/jit/mips/asmpart.S +++ b/src/vm/jit/mips/asmpart.S @@ -51,8 +51,6 @@ .globl asm_abstractmethoderror - .globl compare_and_swap - /* asm_vm_call_method ********************************************************** * * @@ -423,16 +421,16 @@ ex_int2: l.d fs1,-3*8(t1) l.d fs2,-2*8(t1) l.d fs3,-1*8(t1) -#else /* SIZEOF_VOID_P == 8 */ +#else # if !defined(ENABLE_SOFT_FLOAT) - l.d fs0,-4*8(t1) - l.d fs1,-3*8(t1) - l.d fs2,-2*8(t1) - l.d fs3,-1*8(t1) - l.d fs4,-1*8(t1) + l.d fs0,-6*8(t1) + l.d fs1,-5*8(t1) + l.d fs2,-4*8(t1) + l.d fs3,-3*8(t1) + l.d fs4,-2*8(t1) l.d fs5,-1*8(t1) -# endif /* !defined(ENABLE_SOFT_FLOAT) */ -#endif /* SIZEOF_VOID_P == 8 */ +# endif +#endif ex_flt2: lw t1,FrameSize(pv) /* get frame size */ @@ -466,40 +464,6 @@ asm_abstractmethoderror: .end asm_abstractmethoderror - .ent compare_and_swap - -compare_and_swap: -1: -#if defined(__GNUC__) - .set mips2 -#endif - all v0,0(a0) -#if defined(__GNUC__) - .set mips0 -#endif - bne v0,a1,2f - move t0,a2 -#if defined(__GNUC__) - .set mips2 -#endif - asc t0,0(a0) -#if defined(__GNUC__) - .set mips0 -#endif - beqz t0,1b -2: -#if defined(__GNUC__) - .set mips2 -#endif - sync -#if defined(__GNUC__) - .set mips0 -#endif - j ra - - .end compare_and_swap - - /* disable exec-stacks ********************************************************/ #if defined(__linux__) && defined(__ELF__) diff --git a/src/vm/jit/mips/codegen.c b/src/vm/jit/mips/codegen.c index cbb334513..f77101c5f 100644 --- a/src/vm/jit/mips/codegen.c +++ b/src/vm/jit/mips/codegen.c @@ -42,29 +42,28 @@ #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/vm.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" +#include "vm/jit/replace.hpp" #include "vm/jit/trap.h" #if defined(ENABLE_LSRA) # include "vm/jit/allocator/lsra.h" #endif -#include "vmcore/class.h" -#include "vmcore/options.h" - /* codegen_emit **************************************************************** @@ -3236,9 +3235,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -3309,8 +3305,6 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); /* if (s1 != REG_ITMP1) { */ /* M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */ @@ -3325,8 +3319,6 @@ gen_method: M_ALD(REG_ITMP3, REG_PV, disp); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - /* } */ M_CMPULT(REG_ITMP3, REG_ITMP2, REG_ITMP3); emit_classcast_check(cd, iptr, ICMD_IFNE, REG_ITMP3, s1); @@ -3391,9 +3383,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); @@ -3471,14 +3460,10 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); M_CMPULT(REG_ITMP2, REG_ITMP1, d); M_XOR_IMM(d, 1, d); @@ -3885,7 +3870,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - disp = dseg_add_address(cd, _Jv_env); + disp = dseg_add_address(cd, VM_get_jnienv()); M_ALD(REG_A0, REG_PV, disp); } diff --git a/src/vm/jit/mips/codegen.h b/src/vm/jit/mips/codegen.h index c759180bf..188ad6eb7 100644 --- a/src/vm/jit/mips/codegen.h +++ b/src/vm/jit/mips/codegen.h @@ -1,9 +1,7 @@ /* src/vm/jit/mips/codegen.h - code generation macros and definitions for MIPS - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -31,7 +29,7 @@ #include "config.h" #include "vm/types.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* additional functions and macros to generate code ***************************/ @@ -122,11 +120,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 1 * 4 - - /* macros to create code ******************************************************/ /* code generation macros operands: diff --git a/src/vm/jit/mips/emit.c b/src/vm/jit/mips/emit.c index a8a7e225f..e21a41b82 100644 --- a/src/vm/jit/mips/emit.c +++ b/src/vm/jit/mips/emit.c @@ -36,22 +36,19 @@ #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */ +#include "vm/jit/builtin.hpp" +#include "vm/options.h" #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" - /* emit_load ******************************************************************* diff --git a/src/vm/jit/mips/irix/md-os.c b/src/vm/jit/mips/irix/md-os.c index d14fb611e..39117af25 100644 --- a/src/vm/jit/mips/irix/md-os.c +++ b/src/vm/jit/mips/irix/md-os.c @@ -1,9 +1,7 @@ /* src/vm/jit/mips/irix/md-os.c - machine dependent MIPS IRIX functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -37,15 +35,13 @@ #include "vm/jit/mips/codegen.h" #include "vm/jit/mips/md-abi.h" -#include "mm/gc-common.h" +#include "mm/gc.hpp" #include "vm/global.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/codegen-common.hpp" /* md_init ********************************************************************* @@ -145,34 +141,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - u1 *npc; - - _mc = &_uc->uc_mcontext; - - pc = (u1 *) _mc->gregs[CTX_EPC]; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) { - log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc); - _mc->gregs[CTX_EPC] = (ptrint) npc; - } -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/mips/linux/md-os.c b/src/vm/jit/mips/linux/md-os.c index aebc1666a..e94b20d76 100644 --- a/src/vm/jit/mips/linux/md-os.c +++ b/src/vm/jit/mips/linux/md-os.c @@ -37,15 +37,14 @@ #include "vm/jit/mips/md.h" #include "vm/jit/mips/md-abi.h" -#include "mm/gc-common.h" +#include "mm/gc.hpp" #include "mm/memory.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" +#include "vm/os.hpp" #include "vm/jit/asmpart.h" #include "vm/jit/executionstate.h" -#include "vm/jit/stacktrace.h" #include "vm/jit/trap.h" @@ -305,7 +304,7 @@ void md_executionstate_read(executionstate_t* es, void* context) _mc->fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->fpregs.fp_r) == sizeof(es->fltregs)); - system_memcpy(&es->fltregs, &_mc->fpregs.fp_r, sizeof(_mc->fpregs.fp_r)); + os_memcpy(&es->fltregs, &_mc->fpregs.fp_r, sizeof(_mc->fpregs.fp_r)); } @@ -338,7 +337,7 @@ void md_executionstate_write(executionstate_t* es, void* context) _mc->fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->fpregs.fp_r) == sizeof(es->fltregs)); - system_memcpy(&_mc->fpregs.fp_r, &es->fltregs, sizeof(_mc->fpregs.fp_r)); + os_memcpy(&_mc->fpregs.fp_r, &es->fltregs, sizeof(_mc->fpregs.fp_r)); /* Write special registers. */ @@ -354,41 +353,6 @@ void md_executionstate_write(executionstate_t* es, void* context) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - u1 *npc; - - _mc = &_uc->uc_mcontext; - -#if defined(__UCLIBC__) - pc = (u1 *) (ptrint) _mc->gpregs[CTX_EPC]; -#else - pc = (u1 *) (ptrint) _mc->pc; -#endif - - npc = critical_find_restart_point(pc); - - if (npc != NULL) { -#if defined(__UCLIBC__) - _mc->gpregs[CTX_EPC] = (ptrint) npc; -#else - _mc->pc = (ptrint) npc; -#endif - } -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/mips/machine-instr.h b/src/vm/jit/mips/machine-instr.h deleted file mode 100644 index 848a16480..000000000 --- a/src/vm/jit/mips/machine-instr.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -#if 0 - -/* If anyone wants to compile with gcc, use this section. - * It is not usable with the MIPSPro compiler. - * - * It is outdated, too. - */ - -static inline int -__attribute__ ((unused)) -compare_and_swap (volatile long *p, long oldval, long newval) -{ - long ret, temp; - - __asm__ __volatile__ - ("1:\n\t" - ".set push\n\t" - ".set mips2\n\t" - "lld %1,%5\n\t" - "move %0,$0\n\t" - "bne %1,%3,2f\n\t" - "move %0,%4\n\t" - "scd %0,%2\n\t" - ".set pop\n\t" - "beqz %0,1b\n" - "2:\n\t" - : "=&r" (ret), "=&r" (temp), "=m" (*p) - : "r" (oldval), "r" (newval), "m" (*p) - : "memory"); - - return ret; -} - -#else - -long compare_and_swap (long *p, long oldval, long newval); - -#define STORE_ORDER_BARRIER() -#define MEMORY_BARRIER_AFTER_ATOMIC() -#define MEMORY_BARRIER() - -#endif -#endif diff --git a/src/vm/jit/mips/md-abi.c b/src/vm/jit/mips/md-abi.c index 256fa4717..a2d9157c6 100644 --- a/src/vm/jit/mips/md-abi.c +++ b/src/vm/jit/mips/md-abi.c @@ -34,14 +34,13 @@ #include "mm/memory.h" +#include "vm/descriptor.h" #include "vm/global.h" +#include "vm/method.h" #include "vm/jit/abi.h" #include "vm/jit/stack.h" -#include "vmcore/descriptor.h" -#include "vmcore/method.h" - /* register descripton array **************************************************/ diff --git a/src/vm/jit/mips/md-atomic.hpp b/src/vm/jit/mips/md-atomic.hpp new file mode 100644 index 000000000..5cf0a3ef3 --- /dev/null +++ b/src/vm/jit/mips/md-atomic.hpp @@ -0,0 +1,166 @@ +/* src/vm/jit/mips/atomic.hpp - MIPS atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t result; + uint32_t temp; + + __asm__ __volatile__ ( + " .set push \n" + " .set mips2 \n" + "1: \n" + " ll %0,%5 \n" + " bne %0,%3,2f \n" + " move %1,%4 \n" + " sc %1,%2 \n" + " .set pop \n" + " beqz %1,1b \n" + "2: \n" + : "=&r" (result), "=&r" (temp), "=m" (*p) + : "r" (oldval), "r" (newval), "m" (*p) + : "memory"); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ +#if SIZEOF_VOID_P == 8 + uint64_t result; + uint64_t temp; + + __asm__ __volatile__ ( + " .set push \n" + " .set mips2 \n" + "1: \n" + " lld %0,%5 \n" + " bne %0,%3,2f \n" + " move %1,%4 \n" + " scd %1,%2 \n" + " .set pop \n" + " beqz %1,1b \n" + "2: \n" + : "=&r" (result), "=&r" (temp), "=m" (*p) + : "r" (oldval), "r" (newval), "m" (*p) + : "memory"); + + return result; +#else + return generic_compare_and_swap(p, oldval, newval); +#endif +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ +#if SIZEOF_VOID_P == 8 + return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval); +#else + return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval); +#endif +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/mips/md-stubs.hpp b/src/vm/jit/mips/md-stubs.hpp new file mode 100644 index 000000000..7451d76b8 --- /dev/null +++ b/src/vm/jit/mips/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/mips/md-stubs.hpp - MIPS JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on a MIPS architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 1 * 4; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/mips/md-trap.h b/src/vm/jit/mips/md-trap.h index 9fca702ef..dbbee3249 100644 --- a/src/vm/jit/mips/md-trap.h +++ b/src/vm/jit/mips/md-trap.h @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/mips/md.c b/src/vm/jit/mips/md.c index 61e5113ee..6a83c92da 100644 --- a/src/vm/jit/mips/md.c +++ b/src/vm/jit/mips/md.c @@ -35,9 +35,9 @@ #include "vm/jit/mips/md.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* md_jit_method_patch_address ************************************************* diff --git a/src/vm/jit/mips/md.h b/src/vm/jit/mips/md.h index fc70b19bd..100be5e30 100644 --- a/src/vm/jit/mips/md.h +++ b/src/vm/jit/mips/md.h @@ -1,9 +1,7 @@ /* src/vm/jit/mips/md.h - machine dependent MIPS functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -37,7 +35,7 @@ #include "vm/types.h" -#include "vm/vm.h" +#include "vm/vm.hpp" /* md_stacktrace_get_returnaddress ********************************************* @@ -70,28 +68,28 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe *******************************************************************************/ -inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) +inline static void* md_codegen_get_pv_from_pc(void* ra) { - u1 *pv; - u4 mcode; - s4 offset; + int32_t offset; + + uint32_t* pc = (uint32_t*) ra; /* get the offset of the instructions */ /* get first instruction word after jump */ - mcode = *((u4 *) ra); + uint32_t mcode = pc[0]; /* check if we have 2 instructions (lui, daddiu) */ if ((mcode >> 16) == 0x3c19) { /* get displacement of first instruction (lui) */ - offset = (s4) (mcode << 16); + offset = (int32_t) (mcode << 16); /* get displacement of second instruction (daddiu) */ - mcode = *((u4 *) (ra + 1 * 4)); + mcode = pc[1]; #if SIZEOF_VOID_P == 8 assert((mcode >> 16) == 0x6739); @@ -99,25 +97,23 @@ inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) assert((mcode >> 16) == 0x2739); #endif - offset += (s2) (mcode & 0x0000ffff); + offset += (int16_t) (mcode & 0x0000ffff); } else { /* get offset of first instruction (daddiu) */ - mcode = *((u4 *) ra); - #if SIZEOF_VOID_P == 8 assert((mcode >> 16) == 0x67fe); #else assert((mcode >> 16) == 0x27fe); #endif - offset = (s2) (mcode & 0x0000ffff); + offset = (int16_t) (mcode & 0x0000ffff); } /* calculate PV via RA + offset */ - pv = ra + offset; + void* pv = (void*) (((uintptr_t) ra) + offset); return pv; } diff --git a/src/vm/jit/mips/patcher.c b/src/vm/jit/mips/patcher.c index ef4f476b7..248635ba9 100644 --- a/src/vm/jit/mips/patcher.c +++ b/src/vm/jit/mips/patcher.c @@ -28,8 +28,6 @@ #include #include -#include "vm/types.h" - #include "vm/jit/mips/codegen.h" #include "vm/jit/mips/md.h" @@ -37,23 +35,16 @@ #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" - -#include "vm/jit/asmpart.h" -#include "vm/jit/patcher-common.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" +#include "vm/options.h" +#include "vm/references.h" #include "vm/resolve.h" -#include "vmcore/references.h" - -#define PATCH_BACK_ORIGINAL_MCODE \ - *((u4 *) pr->mpc) = (u4) pr->mcode; \ - md_icacheflush((u1 *) pr->mpc, PATCHER_CALL_SIZE); +#include "vm/jit/asmpart.h" +#include "vm/jit/patcher-common.hpp" /* patcher_patch_code ********************************************************** @@ -64,7 +55,8 @@ void patcher_patch_code(patchref_t *pr) { - PATCH_BACK_ORIGINAL_MCODE; + *((uint32_t*) pr->mpc) = (uint32_t) pr->mcode; + md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE); } @@ -80,36 +72,29 @@ void patcher_patch_code(patchref_t *pr) bool patcher_get_putstatic(patchref_t *pr) { - unresolved_field *uf; - u1 *datap; - fieldinfo *fi; - - /* get stuff from the stack */ + unresolved_field* uf = (unresolved_field *) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - uf = (unresolved_field *) pr->ref; - datap = (u1 *) pr->datap; + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - /* get the fieldinfo */ - - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - /* check if the field's class is initialized */ - + // Check if the field's class is initialized. if (!(fi->clazz->state & CLASS_INITIALIZED)) if (!initialize_class(fi->clazz)) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch the field value's address */ - - *((intptr_t *) datap) = (intptr_t) fi->value; - - /* synchronize data cache */ + // Patch the field value's address. + *datap = (uintptr_t) fi->value; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -125,46 +110,41 @@ bool patcher_get_putstatic(patchref_t *pr) bool patcher_get_putfield(patchref_t *pr) { - u1 *ra; - unresolved_field *uf; - fieldinfo *fi; + uint32_t* pc = (uint32_t*) pr->mpc; + unresolved_field* uf = (unresolved_field*) pr->ref; - /* get stuff from the stack */ + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - ra = (u1 *) pr->mpc; - uf = (unresolved_field *) pr->ref; - - /* get the fieldinfo */ - - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - #if SIZEOF_VOID_P == 4 if (IS_LNG_TYPE(fi->type)) { # if WORDS_BIGENDIAN == 1 - /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ - *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); - *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); + // ATTENTION: order of these instructions depend on M_LLD_INTERN. + // The first instruction is patched back later. + pr->mcode |= (int16_t) ((fi->offset + 0) & 0x0000ffff); + pc[1] |= (int16_t) ((fi->offset + 4) & 0x0000ffff); # else - /* ATTENTION: order of these instructions depend on M_LLD_INTERN */ - *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff); - *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff); + // ATTENTION: order of these instructions depend on M_LLD_INTERN. + // The first instruction is patched back later. + pr->mcode |= (int16_t) ((fi->offset + 4) & 0x0000ffff); + pc[1] |= (int16_t) ((fi->offset + 0) & 0x0000ffff); # endif } else #endif - *((u4 *) (ra + 0 * 4)) |= (s2) (fi->offset & 0x0000ffff); + { + // The instruction is patched back later. + pr->mcode |= (int16_t) (fi->offset & 0x0000ffff); + } - /* synchronize instruction cache */ + // Synchronize instruction cache. + md_icacheflush(pc, 2 * 4); - md_icacheflush(ra, 2 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -198,30 +178,24 @@ bool patcher_get_putfield(patchref_t *pr) bool patcher_resolve_classref_to_classinfo(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; - - /* get stuff from the stack */ + constant_classref* cr = (constant_classref*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - /* get the classinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch the classinfo pointer */ - - *((intptr_t *) datap) = (intptr_t) c; - - /* synchronize data cache */ + // Patch the class. + *datap = (uintptr_t) c; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -239,30 +213,24 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr) bool patcher_resolve_classref_to_vftbl(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; - - /* get stuff from the stack */ + constant_classref* cr = (constant_classref *) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; + // Resolve the field. + classinfo* c = resolve_classref_eager(cr); - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch super class' vftbl */ - - *((intptr_t *) datap) = (intptr_t) c->vftbl; - - /* synchronize data cache */ + // Patch super class' vftbl. + *datap = (uintptr_t) c->vftbl; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -281,30 +249,24 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr) bool patcher_resolve_classref_to_flags(patchref_t *pr) { - constant_classref *cr; - u1 *datap; - classinfo *c; - - /* get stuff from the stack */ + constant_classref* cr = (constant_classref*) pr->ref; + int32_t* datap = (int32_t*) pr->datap; - cr = (constant_classref *) pr->ref; - datap = (u1 *) pr->datap; + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch class flags */ - - *((int32_t *) datap) = (int32_t) c->flags; - - /* synchronize data cache */ + // Patch class flags. + *datap = (int32_t) c->flags; + // Synchronize data cache. md_dcacheflush(datap, sizeof(int32_t)); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -322,30 +284,24 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr) bool patcher_invokestatic_special(patchref_t *pr) { - unresolved_method *um; - u1 *datap; - methodinfo *m; - - /* get stuff from the stack */ - - um = (unresolved_method *) pr->ref; - datap = (u1 *) pr->datap; + unresolved_method* um = (unresolved_method*) pr->ref; + void** datap = (void*) pr->datap; - /* get the fieldinfo */ + // Resolve the method. + methodinfo* m = resolve_method_eager(um); - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* patch stubroutine */ - - *((ptrint *) datap) = (ptrint) m->stubroutine; - - /* synchronize data cache */ + // Patch stubroutine. + *datap = (void*) m->stubroutine; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -364,36 +320,23 @@ bool patcher_invokestatic_special(patchref_t *pr) bool patcher_invokevirtual(patchref_t *pr) { - u1 *ra; - unresolved_method *um; - methodinfo *m; + uint32_t* pc = (uint32_t*) pr->mpc; + unresolved_method* um = (unresolved_method*) pr->ref; - /* get stuff from the stack */ + // Resolve the method. + methodinfo* m = resolve_method_eager(um); - ra = (u1 *) pr->mpc; - um = (unresolved_method *) pr->ref; - - /* get the fieldinfo */ - - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Patch vftbl index. + pc[1] |= (int32_t) ((OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex) & 0x0000ffff); - /* patch vftbl index */ + // Synchronize instruction cache. + md_icacheflush(pc + 1, 1 * 4); - *((s4 *) (ra + 1 * 4)) |= - (s4) ((OFFSET(vftbl_t, table[0]) + - sizeof(methodptr) * m->vftblindex) & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 1 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -414,41 +357,26 @@ bool patcher_invokevirtual(patchref_t *pr) bool patcher_invokeinterface(patchref_t *pr) { - u1 *ra; - unresolved_method *um; - methodinfo *m; - - /* get stuff from the stack */ - - ra = (u1 *) pr->mpc; - um = (unresolved_method *) pr->ref; + uint32_t* pc = (uint32_t*) pr->mpc; + unresolved_method* um = (unresolved_method*) pr->ref; - /* get the fieldinfo */ + // Resovlve the method. + methodinfo* m = resolve_method_eager(um); - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch interfacetable index. + pc[1] |= (int32_t) ((OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index) & 0x0000ffff); - /* if we show disassembly, we have to skip the nop's */ + // Patch method offset. + pc[2] |= (int32_t) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x0000ffff); - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Synchronize instruction cache. + md_icacheflush(pc + 1, 2 * 4); - /* patch interfacetable index */ - - *((s4 *) (ra + 1 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - sizeof(methodptr*) * m->clazz->index) & 0x0000ffff); - - /* patch method offset */ - - *((s4 *) (ra + 2 * 4)) |= - (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 2 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -470,39 +398,24 @@ bool patcher_invokeinterface(patchref_t *pr) bool patcher_checkcast_interface(patchref_t *pr) { - u1 *ra; - constant_classref *cr; - classinfo *c; + uint32_t* pc = (uint32_t*) pr->mpc; + constant_classref* cr = (constant_classref*) pr->ref; - /* get stuff from the stack */ + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - ra = (u1 *) pr->mpc; - cr = (constant_classref *) pr->ref; - - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Patch super class index. + pc[2] |= (int32_t) (-(c->index) & 0x0000ffff); + pc[6] |= (int32_t) ((OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*)) & 0x0000ffff); - /* patch super class index */ + // Synchronize instruction cache. + md_icacheflush(pc + 2, 5 * 4); - *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); - /* *((s4 *) (ra + 5 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) - */ - /* c->index * sizeof(methodptr*)) & 0x0000ffff); */ - *((s4 *) (ra + 6 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)) & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 2 * 4, 5 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -524,37 +437,24 @@ bool patcher_checkcast_interface(patchref_t *pr) bool patcher_instanceof_interface(patchref_t *pr) { - u1 *ra; - constant_classref *cr; - classinfo *c; - - /* get stuff from the stack */ - - ra = (u1 *) pr->mpc; - cr = (constant_classref *) pr->ref; + uint32_t* pc = (uint32_t*) pr->mpc; + constant_classref* cr = (constant_classref*) pr->ref; - /* get the fieldinfo */ + // Resolve the method. + classinfo* c = resolve_classref_eager(cr); - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - - /* patch super class index */ - - *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x0000ffff); - *((s4 *) (ra + 5 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)) & 0x0000ffff); + // Patch super class index. + pc[2] |= (int32_t) (-(c->index) & 0x0000ffff); + pc[5] |= (int32_t) ((OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*)) & 0x0000ffff); - /* synchronize instruction cache */ + // Synchronize instruction cache. + md_icacheflush(pc + 2, 4 * 4); - md_icacheflush(ra + 2 * 4, 4 * 4); + // Patch back the original code. + patcher_patch_code(pr); return true; } diff --git a/src/vm/jit/mips/uclinux/md-os.c b/src/vm/jit/mips/uclinux/md-os.c index a28d2d1bc..fa352116b 100644 --- a/src/vm/jit/mips/uclinux/md-os.c +++ b/src/vm/jit/mips/uclinux/md-os.c @@ -1,9 +1,7 @@ /* src/vm/jit/mips/uclinux/md-os.c - machine dependent MIPS uClinux functions - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -32,7 +30,7 @@ #include "vm/types.h" -#include "vm/vm.h" +#include "vm/vm.hpp" /* md_init ********************************************************************* @@ -71,21 +69,6 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - vm_abort("md_critical_section_restart: IMPLEMENT ME!"); -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/oprofile-agent.cpp b/src/vm/jit/oprofile-agent.cpp new file mode 100644 index 000000000..cce16b84d --- /dev/null +++ b/src/vm/jit/oprofile-agent.cpp @@ -0,0 +1,118 @@ +/* src/vm/jit/oprofile-agent.cpp - oprofile agent implementation + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include "mm/memory.h" + +#include "vm/jit/code.hpp" +#include "vm/jit/oprofile-agent.hpp" + +#include + +/* static fields **************************************************************/ +op_agent_t OprofileAgent::_handle = 0; + +/** + * Initializes the OprofileAgent system. + * + */ +/* void OprofileAgent_initialize() */ +void OprofileAgent::initialize(void) +{ + _handle = op_open_agent(); + if (!_handle) + vm_abort_errno("unable to open opagent handle:"); +} + +/** + * Reports the given method to oprofile. + * + * This has to be done once per JIT compilation step for a specific method. + * + * @param m Method to register. + */ +/* void OprofileAgent_newmethod(methodinfo *m) */ +void OprofileAgent::newmethod(methodinfo *m) +{ + unsigned int real_length = (unsigned int) m->code->mcodelength - + (unsigned int) (m->code->entrypoint - m->code->mcode); + + char *buf; + s4 len; + + len = utf_bytes(m->clazz->name) + strlen(".") + + utf_bytes(m->name) + utf_bytes(m->descriptor) + strlen("0"); + + buf = MNEW(char, len); + + utf_copy_classname(buf, m->clazz->name); + strcat(buf, "."); + utf_cat(buf, m->name); + utf_cat(buf, m->descriptor); + + if (_handle) + op_write_native_code(_handle, buf, + (uint64_t) (ptrint) m->code->entrypoint, + (const void *) m->code->entrypoint, + real_length); + + MFREE(buf, char, len); +} + +/** + * Shuts down the OprofileAgent system. + * + */ +/* void OprofileAgent_close() */ +void OprofileAgent::close() +{ + if (_handle) + op_close_agent(_handle); + + _handle = 0; +} +/* Legacy C interface *********************************************************/ + +extern "C" { + +void OprofileAgent_initialize() { OprofileAgent::initialize(); } +void OprofileAgent_newmethod(methodinfo *m) { OprofileAgent::newmethod(m); } +void OprofileAgent_close() { OprofileAgent::close(); } + +} + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/oprofile-agent.hpp b/src/vm/jit/oprofile-agent.hpp new file mode 100644 index 000000000..9b8cbdb5d --- /dev/null +++ b/src/vm/jit/oprofile-agent.hpp @@ -0,0 +1,84 @@ +/* src/vm/jit/oprofile-agent.hpp - oprofile agent implementation + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _OPROFILE_AGENT_HPP +#define _OPROFILE_AGENT_HPP + +#include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include "vm/method.h" + +#include + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus + +class OprofileAgent +{ + static op_agent_t _handle; + +public: + static void initialize(); + + static void newmethod(methodinfo *); + + static void close(); +}; + +#else + +/* Legacy C interface *********************************************************/ + +typedef struct OprofileAgent OprofileAgent; + +void OprofileAgent_initialize(void); +void OprofileAgent_newmethod(methodinfo *); +void OprofileAgent_close(); + +#endif + +#endif /* _OPROFILE_AGENT_HPP */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/optimizing/Makefile.am b/src/vm/jit/optimizing/Makefile.am index b7c937c13..674a19d14 100644 --- a/src/vm/jit/optimizing/Makefile.am +++ b/src/vm/jit/optimizing/Makefile.am @@ -1,9 +1,7 @@ ## src/vm/jit/optimizing/Makefile.am ## -## Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, -## R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, -## C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, -## Institut f. Computersprachen - TU Wien +## Copyright (C) 1996-2005, 2006, 2007, 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO ## ## This file is part of CACAO. ## @@ -61,8 +59,8 @@ SSA_SOURCES = \ ssa_rename.h \ graph.c \ graph.h \ - dominators.c \ - dominators.h \ + dominators.cpp \ + dominators.hpp \ lifetimes.c \ lifetimes.h \ ssa2.c \ diff --git a/src/vm/jit/optimizing/bytecode_escape.c b/src/vm/jit/optimizing/bytecode_escape.c index 22fb1f281..4eb9bdc7c 100644 --- a/src/vm/jit/optimizing/bytecode_escape.c +++ b/src/vm/jit/optimizing/bytecode_escape.c @@ -19,21 +19,27 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ -#include "mm/dumpmemory.h" + +#include "config.h" + +#include + +#include "mm/dumpmemory.hpp" #include "mm/memory.h" #include "toolbox/bitvector.h" +#include "vm/class.h" +#include "vm/descriptor.h" #include "vm/global.h" -#include "vm/jit/ir/bytecode.h" -#include "vm/jit/optimizing/escape.h" +#include "vm/references.h" #include "vm/resolve.h" -#include "vmcore/class.h" -#include "vmcore/descriptor.h" -#include "vmcore/references.h" +#include "vm/jit/ir/bytecode.hpp" +#include "vm/jit/optimizing/escape.h" #include #include @@ -118,15 +124,10 @@ typedef struct { op_stack_slot_t *ptr; op_stack_slot_t *bottom; unsigned max; + bool *perror_flag; } op_stack_t; -#define stack_assert_position(stack, pos) \ - do { \ - assert((stack)->elements <= (pos)); \ - assert((pos) < (stack)->end); \ - } while (0) - -static void op_stack_init(op_stack_t *stack, unsigned max) { +static void op_stack_init(op_stack_t *stack, unsigned max, bool *perror_flag) { op_stack_slot_t *it; stack->elements = DMNEW(op_stack_slot_t, max * 2); @@ -140,6 +141,27 @@ static void op_stack_init(op_stack_t *stack, unsigned max) { stack->ptr = stack->start; stack->bottom = stack->start; + + stack->perror_flag = perror_flag; +} + +static void op_stack_set_error(op_stack_t *stack) { + *(stack->perror_flag) = true; +#if BC_ESCAPE_VERBOSE + printf("%s: error.\n", __FUNCTION__); +#endif +} + +static bool op_stack_test_position(op_stack_t *stack, op_stack_slot_t *pos) { + if (!(stack->elements <= pos)) { + op_stack_set_error(stack); + return false; + } else if (!(pos < stack->end)) { + op_stack_set_error(stack); + return false; + } else { + return true; + } } static void op_stack_reset(op_stack_t *stack) { @@ -160,7 +182,9 @@ static void op_stack_reset(op_stack_t *stack) { static op_stack_slot_t op_stack_pop(op_stack_t *stack) { op_stack_slot_t ret; stack->ptr -= 1; - stack_assert_position(stack, stack->ptr); + if (! op_stack_test_position(stack, stack->ptr)) { + return OP_STACK_SLOT_UNKNOWN; + } ret = *(stack->ptr); if (stack->ptr < stack->bottom) { stack->bottom = stack->ptr; @@ -169,19 +193,24 @@ static op_stack_slot_t op_stack_pop(op_stack_t *stack) { } static void op_stack_push(op_stack_t *stack, op_stack_slot_t element) { - stack_assert_position(stack, stack->ptr); - *(stack->ptr) = element; - stack->ptr += 1; + if (op_stack_test_position(stack, stack->ptr)) { + *(stack->ptr) = element; + stack->ptr += 1; + } } static op_stack_slot_t op_stack_get(const op_stack_t *stack, int offset) { - stack_assert_position(stack, stack->ptr - offset); - return *(stack->ptr - offset); + if (op_stack_test_position(stack, stack->ptr - offset)) { + return *(stack->ptr - offset); + } else { + return OP_STACK_SLOT_UNKNOWN; + } } static void op_stack_set(op_stack_t *stack, int offset, op_stack_slot_t value) { - stack_assert_position(stack, stack->ptr - offset); - *(stack->ptr - offset) = value; + if (op_stack_test_position(stack, stack->ptr - offset)) { + *(stack->ptr - offset) = value; + } } static inline void op_stack_push_unknown(op_stack_t *stack) { @@ -301,13 +330,22 @@ typedef struct { u1 *pos; u1 *instruction_start; s4 offset; + bool *perror_flag; } jcode_t; -static void jcode_init(jcode_t *jc, u1 *start, s4 length, s4 offset) { +static void jcode_init(jcode_t *jc, u1 *start, s4 length, s4 offset, bool *perror_flag) { jc->start = start; jc->end = jc->start + length; jc->pos = jc->start; jc->offset = offset; + jc->perror_flag = perror_flag; +} + +static void jcode_set_error(jcode_t *jc) { + *(jc->perror_flag) = true; +#if BC_ESCAPE_VERBOSE + printf("%s: error.\n", __FUNCTION__); +#endif } static void jcode_move_to_index(jcode_t *jc, s4 index) { @@ -347,38 +385,56 @@ static s4 jcode_get_index(const jcode_t *jc) { return jc->offset + (jc->pos - jc->start); } -#define jcode_assert_has_bytes(jc, n) \ - assert((jc->pos + n) <= jc->end) +bool jcode_test_has_bytes(jcode_t *jc, s4 n) { + if ((jc->pos + n) <= jc->end) { + return true; + } else { + jcode_set_error(jc); + return false; + } +} static u1 jcode_get_u1(jcode_t *jc) { u1 ret; - jcode_assert_has_bytes(jc, 1); - ret = jc->pos[0]; - jc->pos += 1; + if (jcode_test_has_bytes(jc, 1)) { + ret = jc->pos[0]; + jc->pos += 1; + } else { + ret = 0; + } return ret; } static s2 jcode_get_s2(jcode_t *jc) { s2 ret; - jcode_assert_has_bytes(jc, 2); - ret = (jc->pos[0] << 8) | (jc->pos[1]); - jc->pos += 2; + if (jcode_test_has_bytes(jc, 2)) { + ret = (jc->pos[0] << 8) | (jc->pos[1]); + jc->pos += 2; + } else { + ret = 0; + } return ret; } static u2 jcode_get_u2(jcode_t *jc) { u2 ret; - jcode_assert_has_bytes(jc, 2); - ret = (jc->pos[0] << 8) | (jc->pos[1]); - jc->pos += 2; + if (jcode_test_has_bytes(jc, 2)) { + ret = (jc->pos[0] << 8) | (jc->pos[1]); + jc->pos += 2; + } else { + ret = 0; + } return ret; } static s4 jcode_get_s4(jcode_t *jc) { s4 ret; - jcode_assert_has_bytes(jc, 4); - ret = (jc->pos[0] << 24) | (jc->pos[1] << 16) | (jc->pos[2] << 8) | (jc->pos[3]); - jc->pos += 4; + if (jcode_test_has_bytes(jc, 4)) { + ret = (jc->pos[0] << 24) | (jc->pos[1] << 16) | (jc->pos[2] << 8) | (jc->pos[3]); + jc->pos += 4; + } else { + ret = 0; + } return ret; } @@ -394,7 +450,9 @@ static s4 jcode_get_branch_target_wide(jcode_t *jc) { static s4 jcode_get_fall_through_target(jcode_t *jc) { int length = bytecode[*jc->instruction_start].length; - assert(length > 0); + if (length <= 0) { + jcode_set_error(jc); + } return jc->offset + (jc->instruction_start - jc->start) + length; } @@ -420,6 +478,8 @@ typedef struct { bool verbose; #endif int depth; + + bool fatal_error; } bc_escape_analysis_t; static void bc_escape_analysis_perform_intern(methodinfo *m, int depth); @@ -430,13 +490,13 @@ static void bc_escape_analysis_init(bc_escape_analysis_t *be, methodinfo *m, boo int a; u1 *ite; u1 t; - int ret_adr; unsigned n; + int ret_val_is_adr; be->method = m; be->stack = DNEW(op_stack_t); - op_stack_init(be->stack, m->maxstack); + op_stack_init(be->stack, m->maxstack, &(be->fatal_error)); be->basicblocks = DNEW(basicblock_work_list_t); basicblock_work_list_init(be->basicblocks); @@ -464,27 +524,28 @@ static void bc_escape_analysis_init(bc_escape_analysis_t *be, methodinfo *m, boo assert(l == be->local_to_adr_param_size); - /* Determine whether return type is address */ - - ret_adr = m->parseddesc->returntype.type == TYPE_ADR ? 1 : 0; + ret_val_is_adr = m->parseddesc->returntype.type == TYPE_ADR ? 1 : 0; /* Allocate param_escape on heap. */ be->param_escape_size = a; - n = a + ret_adr; + n = a + ret_val_is_adr; if (n == 0) { /* Use some non-NULL value. */ be->param_escape = (u1 *)1; } else { be->param_escape = MNEW(u1, n); + be->param_escape += ret_val_is_adr; } for (ite = be->param_escape; ite != be->param_escape + n; ++ite) { - *ite = (u1)ESCAPE_NONE; + *ite = escape_state_to_u1(ESCAPE_NONE); } - be->param_escape += ret_adr; + if (ret_val_is_adr) { + be->param_escape[-1] = escape_state_to_u1(ESCAPE_NONE); + } be->adr_param_dirty = DNEW(bit_vector_t); bit_vector_init(be->adr_param_dirty, a); @@ -499,6 +560,8 @@ static void bc_escape_analysis_init(bc_escape_analysis_t *be, methodinfo *m, boo #endif be->depth = depth; + + be->fatal_error = false; } static void bc_escape_analysis_branch_target(bc_escape_analysis_t *be, s4 branch_target) { @@ -524,8 +587,8 @@ static void bc_escape_analysis_adjust_state( parameters. */ if ( - old < ESCAPE_GLOBAL_THROUGH_METHOD && - escape_state >= ESCAPE_GLOBAL_THROUGH_METHOD + old < ESCAPE_GLOBAL && + escape_state >= ESCAPE_GLOBAL ) { be->non_escaping_adr_params -= 1; } @@ -550,16 +613,17 @@ static void bc_escape_analysis_dirty_2(bc_escape_analysis_t *be, s4 local) { bc_escape_analysis_dirty(be, local + 1); } -static void bc_escape_analyisis_returned(bc_escape_analysis_t *be, op_stack_slot_t value) { +static void bc_escape_analysis_returned(bc_escape_analysis_t *be, op_stack_slot_t value) { if (op_stack_slot_is_param(value)) { /* A parameter is returned, mark it as being returned. */ bit_vector_set(be->adr_param_returned, value.index); - } else if (op_stack_slot_is_unknown(value)) { - /* An untracked value is returned. - Conservatively asume a globally escaping value is returned. */ + /* The escape state of the return value will be adjusted later. */ + } else { + /* Adjust escape state of return value. */ if (be->method->parseddesc->returntype.type == TYPE_ADR) { - be->param_escape[-1] = (u1)ESCAPE_GLOBAL; + be->param_escape[-1] = escape_state_to_u1(ESCAPE_GLOBAL); } + bc_escape_analysis_adjust_state(be, value, ESCAPE_GLOBAL); } } @@ -589,6 +653,25 @@ value_category_t bc_escape_analysis_value_category(bc_escape_analysis_t *be, s4 } } +static void bc_escape_analysis_push_return_value( + bc_escape_analysis_t *be, + methoddesc *md +) { + switch (md->returntype.type) { + case TYPE_LNG: + case TYPE_DBL: + op_stack_push_unknown(be->stack); + op_stack_push_unknown(be->stack); + break; + case TYPE_VOID: + /* Do nothing */ + break; + default: + op_stack_push_unknown(be->stack); + break; + } +} + static void bc_escape_analysis_adjust_invoke_parameters( bc_escape_analysis_t *be, methodinfo *mi @@ -597,6 +680,8 @@ static void bc_escape_analysis_adjust_invoke_parameters( methoddesc *md = mi->parseddesc; u1 *paramescape = mi->paramescape; s4 stack_depth = md->paramslots; + unsigned num_params_returned = 0; + op_stack_slot_t param_returned; /* Process parameters. * The first parameter is at the highest depth on the stack. @@ -605,10 +690,14 @@ static void bc_escape_analysis_adjust_invoke_parameters( for (i = 0; i < md->paramcount; ++i) { switch (md->paramtypes[i].type) { case TYPE_ADR: + if (*paramescape & 0x80) { + num_params_returned += 1; + param_returned = op_stack_get(be->stack, stack_depth); + } bc_escape_analysis_adjust_state( be, op_stack_get(be->stack, stack_depth), - (escape_state_t)*(paramescape++) + escape_state_from_u1(*paramescape++) ); stack_depth -= 1; break; @@ -627,7 +716,20 @@ static void bc_escape_analysis_adjust_invoke_parameters( for (i = 0; i < md->paramslots; ++i) { op_stack_pop(be->stack); } + + /* Push return value. */ + if (md->returntype.type == TYPE_ADR) { + if ((num_params_returned == 1) && (mi->paramescape[-1] < ESCAPE_GLOBAL)) { + /* Only a single argument can be returned by the method, + and the retun value does not escape otherwise. */ + op_stack_push(be->stack, param_returned); + } else { + op_stack_push_unknown(be->stack); + } + } else { + bc_escape_analysis_push_return_value(be, md); + } } static void bc_escape_analysis_escape_invoke_parameters( @@ -638,6 +740,8 @@ static void bc_escape_analysis_escape_invoke_parameters( for (i = 0; i < md->paramslots; ++i) { bc_escape_analysis_adjust_state(be, op_stack_pop(be->stack), ESCAPE_GLOBAL); } + + bc_escape_analysis_push_return_value(be, md); } static void bc_escape_analysis_parse_invoke(bc_escape_analysis_t *be, jcode_t *jc) { @@ -713,7 +817,7 @@ static void bc_escape_analysis_parse_invoke(bc_escape_analysis_t *be, jcode_t *j or recurse into callee. Otherwise we must assume, that all parameters escape. */ - if (mi != NULL) { + if (mi != NULL && escape_is_monomorphic(be->method, mi)) { if (mi->paramescape == NULL) { bc_escape_analysis_perform_intern(mi, be->depth + 1); @@ -730,20 +834,6 @@ static void bc_escape_analysis_parse_invoke(bc_escape_analysis_t *be, jcode_t *j } else { bc_escape_analysis_escape_invoke_parameters(be, md); } - - switch (md->returntype.type) { - case TYPE_LNG: - case TYPE_DBL: - op_stack_push_unknown(be->stack); - op_stack_push_unknown(be->stack); - break; - case TYPE_VOID: - /* Do nothing */ - break; - default: - op_stack_push_unknown(be->stack); - break; - } } static void bc_escape_analysis_parse_tableswitch( @@ -825,7 +915,7 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod /* TODO end if all parameters escape */ /* TODO move code into process_instruction or the like */ - while ((! jcode_end(jc)) && (! bb_end)) { + while ((! jcode_end(jc)) && (! bb_end) && (! be->fatal_error)) { jcode_record_instruction_start(jc); @@ -1390,7 +1480,7 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod case BC_areturn: /* FIXME */ - bc_escape_analyisis_returned(be, op_stack_pop(be->stack)); + bc_escape_analysis_returned(be, op_stack_pop(be->stack)); bb_end = true; break; @@ -1593,7 +1683,7 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod } #endif - while (! op_stack_is_empty(be->stack)) { + while ((! op_stack_is_empty(be->stack)) && (! be->fatal_error)) { #if BC_ESCAPE_VERBOSE if (be->verbose) { dprintf(be->depth, "Stack element: "); @@ -1609,10 +1699,19 @@ static void bc_escape_analysis_process_basicblock(bc_escape_analysis_t *be, jcod } #endif } + + if (be->fatal_error) { +#if BC_ESCAPE_VERBOSE + if (be->verbose) { + printf("Fatal error while processing basic block. Aborting.\n"); + } +#endif + assert(0); + } } static void bc_escape_analysis_adjust_return_value(bc_escape_analysis_t *be) { - escape_state_t e, pe; + escape_state_t re, pe; int i; /* Only calculate, if return value is of type address. */ @@ -1621,22 +1720,20 @@ static void bc_escape_analysis_adjust_return_value(bc_escape_analysis_t *be) { return ; } - /* Get current escape state of return value. */ - - e = (escape_state_t)be->param_escape[-1]; - /* If a parameter can be returned, adjust to its escape state. */ for (i = 0; i < be->param_escape_size; ++i) { if (bit_vector_get(be->adr_param_returned, i)) { - pe = (escape_state_t)be->param_escape[i]; - if (pe > e) { - e = pe; + be->param_escape[i] |= 0x80; + + pe = escape_state_from_u1(be->param_escape[i]); + re = escape_state_from_u1(be->param_escape[-1]); + + if (pe > re) { + be->param_escape[-1] = escape_state_to_u1(pe); } } } - - be->param_escape[-1] = (u1)e; } static void bc_escape_analysis_analyze(bc_escape_analysis_t *be) { @@ -1664,7 +1761,8 @@ static void bc_escape_analysis_analyze(bc_escape_analysis_t *be) { &jc, be->method->jcode, be->method->jcodelength, - 0 + 0, + &(be->fatal_error) ); /* Process basicblock by basicblock. */ @@ -1702,6 +1800,10 @@ static void bc_escape_analysis_perform_intern(methodinfo *m, int depth) { } #endif + if (depth >= 3) { + return; + } + if (m->paramescape != NULL) { #if BC_ESCAPE_VERBOSE if (verbose) { @@ -1729,7 +1831,14 @@ static void bc_escape_analysis_perform_intern(methodinfo *m, int depth) { return; } - /* TODO threshold */ + if (m->jcodelength > 250) { +#if BC_ESCAPE_VERBOSE + if (verbose) { + dprintf(depth, "Bytecode too long: %d.\n", m->jcodelength); + } +#endif + return; + } be = DNEW(bc_escape_analysis_t); bc_escape_analysis_init(be, m, verbose, depth); diff --git a/src/vm/jit/optimizing/dominators.c b/src/vm/jit/optimizing/dominators.c deleted file mode 100644 index 3fcf46f6b..000000000 --- a/src/vm/jit/optimizing/dominators.c +++ /dev/null @@ -1,654 +0,0 @@ -/* src/vm/jit/optimizing/dominators.c - dominators and dominance frontier - - Copyright (C) 2005, 2006, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - -*/ - - -#include "mm/memory.h" - -#include "toolbox/bitvector.h" - -#include "vm/jit/jit.h" - -#include "vm/jit/optimizing/graph.h" -#include "vm/jit/optimizing/dominators.h" - -/* function prototypes */ -void dom_Dominators_init(dominatordata *dd, int basicblockcount); -#ifdef DOM_DEBUG_CHECK -int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount); -void dom_Link(dominatordata *dd, int p, int n, int basicblockcount); -void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N, - int basicblockcount); -#else -int dom_AncestorWithLowestSemi(dominatordata *dd, int v); -void dom_Link(dominatordata *dd, int p, int n); -void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N); -#endif - -/************************************* -Calculate Dominators -*************************************/ -dominatordata *compute_Dominators(graphdata *gd, int basicblockcount) { - int i,j,n,N,p,s,s_,v,y; - graphiterator iter; - dominatordata *dd; - - dd = DNEW(dominatordata); - - dom_Dominators_init(dd, basicblockcount); - - N=0; - - /* 1 ist the root node of the method */ - /* 0 is the artificial parent, where locals are set to their parameters */ - dom_DFS(gd, dd, -1, 0, &N -#ifdef DOM_DEBUG_CHECK - ,basicblockcount -#endif - ); - - for(i = N-1; i > 0; i--) { - _DOM_CHECK_BOUNDS(i, 0, basicblockcount); - n = dd->vertex[i]; - _DOM_CHECK_BOUNDS(n, 0, basicblockcount); - p = dd->parent[n]; - s = p; - j = graph_get_first_predecessor(gd, n, &iter); - for (; j != -1; j = graph_get_next(&iter)) { - _DOM_CHECK_BOUNDS(j, 0, basicblockcount); - if (dd->dfnum[j] <= dd->dfnum[n]) - s_ = j; - else - s_ = dd->semi[dom_AncestorWithLowestSemi(dd, j -#ifdef DOM_DEBUG_CHECK - ,basicblockcount -#endif - )]; - _DOM_CHECK_BOUNDS(s_, 0, basicblockcount); - _DOM_CHECK_BOUNDS(s, 0, basicblockcount); - if (dd->dfnum[s_] < dd->dfnum[s]) - s = s_; - } - dd->semi[n] = s; - _DOM_CHECK_BOUNDS(dd->num_bucket[s], 0, basicblockcount); - dd->bucket[s][dd->num_bucket[s]] = n; - dd->num_bucket[s]++; - dom_Link(dd, p, n -#ifdef DOM_DEBUG_CHECK - , basicblockcount -#endif - ); - _DOM_CHECK_BOUNDS(p, 0, basicblockcount); - for(j = 0; j < dd->num_bucket[p]; j++) { - _DOM_CHECK_BOUNDS(j, 0, basicblockcount); - v = dd->bucket[p][j]; - y = dom_AncestorWithLowestSemi(dd, v -#ifdef DOM_DEBUG_CHECK - , basicblockcount -#endif - ); - _DOM_CHECK_BOUNDS(y, 0, basicblockcount); - _DOM_CHECK_BOUNDS(v, 0, basicblockcount); - if (dd->semi[y] == dd->semi[v]) - dd->idom[v] = p; - else - dd->samedom[v] = y; - } - dd->num_bucket[p] = 0; - } - for(i = 1; i < N; i++) { - n = dd->vertex[i]; - _DOM_CHECK_BOUNDS(n, 0, basicblockcount); - if (dd->samedom[n] != -1) { - _DOM_CHECK_BOUNDS(dd->samedom[n], 0, basicblockcount); - dd->idom[n] = dd->idom[dd->samedom[n]]; - } - } - return dd; -} - -/******************************************** -compute Dominace Frontier -********************************************/ -void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n) { - int c,i,j; - bool *_S; - graphiterator iter; - - _S = DMNEW(bool, basicblockcount); - for(i = 0; i < basicblockcount; i++) - _S[i] = false; - i = graph_get_first_successor(gd, n, &iter); - for (; i != -1; i = graph_get_next(&iter)) { - _DOM_CHECK_BOUNDS(i, 0, basicblockcount); - if (dd->idom[i] != n) - _S[i] = true; - } - for(c=0; c < basicblockcount; c++) { - if (dd->idom[c] == n) { - computeDF(gd, dd, basicblockcount, c); - for(j=0; j < dd->num_DF[c]; j++) { - _DOM_CHECK_BOUNDS(dd->DF[c][j], 0, basicblockcount); - if (n != dd->idom[dd->DF[c][j]]) - /* n does not dominate DF[c][j] -> traverse idom list? */ - _S[dd->DF[c][j]] = true; - } - } - } - for(i = 0; i < basicblockcount; i++) - if (_S[i]) { - _DOM_CHECK_BOUNDS(dd->num_DF[n], 0, basicblockcount); - dd->DF[n][dd->num_DF[n]] = i; - dd->num_DF[n]++; - } -} - - -void dom_Dominators_init(dominatordata *dd, int basicblockcount) { - int i; - - dd->dfnum = DMNEW(int, basicblockcount); - dd->vertex = DMNEW(int, basicblockcount); - dd->parent = DMNEW(int, basicblockcount); - dd->semi = DMNEW(int, basicblockcount); - dd->ancestor = DMNEW(int, basicblockcount); - dd->idom = DMNEW(int, basicblockcount); - dd->samedom = DMNEW(int, basicblockcount); - dd->bucket = DMNEW(int*, basicblockcount); - dd->num_bucket = DMNEW(int, basicblockcount); - dd->DF = DMNEW(int*, basicblockcount); - dd->num_DF = DMNEW(int, basicblockcount); - dd->best = DMNEW(int, basicblockcount); - for (i=0; i < basicblockcount; i++) { - dd->dfnum[i] = -1; - dd->semi[i] = dd->ancestor[i] = dd->idom[i] = dd->samedom[i] = -1; - dd->num_bucket[i] = 0; - dd->bucket[i] = DMNEW(int, basicblockcount); - dd->num_DF[i] = 0; - dd->DF[i] = DMNEW(int, basicblockcount); - } -} - -/************************************** -Create Depth First Spanning Tree -**************************************/ -#ifdef DOM_DEBUG_CHECK -void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N, - int basicblockcount) { -#else -void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N) { -#endif - int i; - graphiterator iter; - - _DOM_CHECK_BOUNDS(n,0,basicblockcount); - if (dd->dfnum[n] == -1) { /* not visited till now? */ - dd->dfnum[n] = *N; - _DOM_CHECK_BOUNDS(*N,0,basicblockcount); - dd->vertex[*N] = n; - dd->parent[n] = p; - (*N)++; - i = graph_get_first_successor(gd, n, &iter); - for (; i != -1; i = graph_get_next(&iter)) { - dom_DFS(gd, dd, n, i, N -#ifdef DOM_DEBUG_CHECK - , basicblockcount -#endif - ); - } - } -} - -#ifdef DOM_DEBUG_CHECK -int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount) { -#else -int dom_AncestorWithLowestSemi(dominatordata *dd, int v) { -#endif - int a,b; - - _DOM_CHECK_BOUNDS(v, 0, basicblockcount); - a = dd->ancestor[v]; - _DOM_CHECK_BOUNDS(a,0,basicblockcount); - if (dd->ancestor[a] != -1) { - b = dom_AncestorWithLowestSemi(dd, a -#ifdef DOM_DEBUG_CHECK - , basicblockcount -#endif - ); - dd->ancestor[v] = dd->ancestor[a]; - _DOM_CHECK_BOUNDS(b,0,basicblockcount); - _DOM_CHECK_BOUNDS(dd->best[v],0,basicblockcount); - _DOM_CHECK_BOUNDS(dd->semi[dd->best[v]],0,basicblockcount); - if (dd->dfnum[dd->semi[b]] < dd->dfnum[dd->semi[dd->best[v]]]) - dd->best[v] = b; - } - return dd->best[v]; -} - -#ifdef DOM_DEBUG_CHECK -void dom_Link(dominatordata *dd, int p, int n, int basicblockcount) { -#else -void dom_Link(dominatordata *dd, int p, int n) { -#endif - _DOM_CHECK_BOUNDS(n,0,basicblockcount); - dd->ancestor[n] = p; - dd->best[n] = n; -} - -/*********************************************************/ - -typedef struct basicblock_info basicblock_info; - -struct basicblock_info { - basicblock *bb; - int dfnum; - basicblock_info *parent; - basicblock_info *semi; - basicblock_info *ancestor; - basicblock_info *best; - basicblock_info *idom; - basicblock_info *samedom; - basicblock_info **bucket; - unsigned bucketcount; -}; - -typedef struct dominator_tree_info dominator_tree_info; - -struct dominator_tree_info { - jitdata *jd; - basicblock_info *basicblocks; - basicblock_info **df_map; - unsigned df_counter; -}; - -static dominator_tree_info *dominator_tree_init(jitdata *jd) { - dominator_tree_info *di; - basicblock *itb; - basicblock_info *iti; - - di = DNEW(dominator_tree_info); - - di->jd = jd; - - di->basicblocks = DMNEW(basicblock_info, jd->basicblockcount); - MZERO(di->basicblocks, basicblock_info, jd->basicblockcount); - - for (iti = di->basicblocks; iti != di->basicblocks + jd->basicblockcount; ++iti) { - iti->dfnum = -1; - iti->bucket = DMNEW(basicblock_info *, jd->basicblockcount); - iti->bucketcount = 0; - } - - for (itb = jd->basicblocks; itb; itb = itb->next) { - di->basicblocks[itb->nr].bb = itb; - } - - di->df_map = DMNEW(basicblock_info *, jd->basicblockcount); - MZERO(di->df_map, basicblock_info *, jd->basicblockcount); - - di->df_counter = 0; - - return di; -} - -inline basicblock_info *dominator_tree_get_basicblock(dominator_tree_info *di, basicblock *bb) { - return di->basicblocks + bb->nr; -} - -static void dominator_tree_depth_first_search( - dominator_tree_info *di, basicblock_info *parent, basicblock_info *node -) { - basicblock **it; - - if (node->dfnum == -1) { - - node->dfnum = di->df_counter; - node->parent = parent; - di->df_map[di->df_counter] = node; - di->df_counter += 1; - - for (it = node->bb->successors; it != node->bb->successors + node->bb->successorcount; ++it) { - dominator_tree_depth_first_search( - di, node, - dominator_tree_get_basicblock(di, *it) - ); - } - } -} - -void dominator_tree_link(dominator_tree_info *di, basicblock_info *parent, basicblock_info *node) { - node->ancestor = parent; - node->best = node; -} - -basicblock_info *dominator_tree_ancestor_with_lowest_semi( - dominator_tree_info *di, basicblock_info *node -) { - basicblock_info *a, *b; - - a = node->ancestor; - - if (a->ancestor != NULL) { - b = dominator_tree_ancestor_with_lowest_semi(di, a); - node->ancestor = a->ancestor; - if (b->semi->dfnum < node->best->semi->dfnum) { - node->best = b; - } - } - - return node->best; -} - -void dominator_tree_build_intern(jitdata *jd) { - - dominator_tree_info *di; - basicblock_info *node; - basicblock_info *semicand; - basicblock_info *pred; - basicblock **itb; - basicblock_info **itii; - basicblock_info *v, *y; - int i; - - di = dominator_tree_init(jd); - - dominator_tree_depth_first_search(di, NULL, dominator_tree_get_basicblock(di, jd->basicblocks)); - - for (i = di->df_counter - 1; i >= 1; --i) { - node = di->df_map[i]; - - node->semi = node->parent; - - for ( - itb = node->bb->predecessors; - itb != node->bb->predecessors + node->bb->predecessorcount; - ++itb - ) { - - pred = dominator_tree_get_basicblock(di, *itb); - - if (pred->dfnum <= node->dfnum) { - semicand = pred; - } else { - semicand = dominator_tree_ancestor_with_lowest_semi(di, pred)->semi; - } - - if (semicand->dfnum < node->semi->dfnum) { - node->semi = semicand; - } - } - - node->semi->bucket[node->semi->bucketcount] = node; - node->semi->bucketcount += 1; - - dominator_tree_link(di, node->parent, node); - - for (itii = node->parent->bucket; itii != node->parent->bucket + node->parent->bucketcount; ++itii) { - v = *itii; - y = dominator_tree_ancestor_with_lowest_semi(di, v); - if (y->semi == v->semi) { - v->idom = node->parent; - } else { - v->samedom = y; - } - } - - node->parent->bucketcount = 0; - } - - for (i = 1; i < di->df_counter; ++i) { - node = di->df_map[i]; - if (node->samedom) { - node->idom = node->samedom->idom; - } - - node->bb->idom = node->idom->bb; - node->idom->bb->domsuccessorcount += 1; - } -} - -void dominator_tree_link_children(jitdata *jd) { - basicblock *bb; - int32_t ds; - /* basicblock number => current number of successors */ - unsigned *numsuccessors; - - /* Allocate memory for successors */ - - for (bb = jd->basicblocks; bb; bb = bb->next) { - if (bb->domsuccessorcount > 0) { - bb->domsuccessors = DMNEW(basicblock *, bb->domsuccessorcount); - } - } - - /* Allocate memory for per basic block counter of successors */ - - ds = dumpmemory_marker(); - numsuccessors = DMNEW(unsigned, jd->basicblockcount); - MZERO(numsuccessors, unsigned, jd->basicblockcount); - - /* Link immediate dominators with successors */ - - for (bb = jd->basicblocks; bb; bb = bb->next) { - if (bb->idom) { - bb->idom->domsuccessors[numsuccessors[bb->idom->nr]] = bb; - numsuccessors[bb->idom->nr] += 1; - } - } - - /* Free memory */ - - dumpmemory_release(ds); -} - -bool dominator_tree_build(jitdata *jd) { - int32_t ds; - - ds = dumpmemory_marker(); - dominator_tree_build_intern(jd); - dumpmemory_release(ds); - - dominator_tree_link_children(jd); - - return true; -} - -typedef struct dominance_frontier_item dominance_frontier_item; - -struct dominance_frontier_item { - basicblock *bb; - dominance_frontier_item *next; -}; - -typedef struct dominance_frontier_list dominance_frontier_list; - -struct dominance_frontier_list { - dominance_frontier_item *first; - unsigned count; -}; - -void dominance_frontier_list_add(dominance_frontier_list *list, basicblock *bb) { - dominance_frontier_item *item; - - for (item = list->first; item; item = item->next) { - if (item->bb == bb) return; - } - - item = DNEW(dominance_frontier_item); - item->bb = bb; - item->next = list->first; - list->first = item; - list->count += 1; -} - -typedef struct dominance_frontier_info dominance_frontier_info; - -struct dominance_frontier_info { - jitdata *jd; - dominance_frontier_list *map; -}; - -dominance_frontier_info *dominance_frontier_init(jitdata *jd) { - dominance_frontier_info *dfi = DNEW(dominance_frontier_info); - - dfi->jd = jd; - - dfi->map = DMNEW(dominance_frontier_list, jd->basicblockcount); - MZERO(dfi->map, dominance_frontier_list, jd->basicblockcount); - - return dfi; -} - -bool dominance_frontier_dominates(basicblock *d, basicblock *x) { - x = x->idom; - - while (x != NULL) { - if (x == d) { - return true; - } - x = x->idom; - } - - return false; -} - -void dominance_frontier_for_block(dominance_frontier_info *dfi, basicblock *b) { - basicblock **it; - dominance_frontier_item *itdf; - dominance_frontier_list s = { NULL, 0 }; - - for (it = b->successors; it != b->successors + b->successorcount; ++it) { - if ((*it)->idom != b) { - dominance_frontier_list_add(&s, *it); - } - } - - for (it = b->domsuccessors; it != b->domsuccessors + b->domsuccessorcount; ++it) { - dominance_frontier_for_block(dfi, *it); - for (itdf = dfi->map[(*it)->nr].first; itdf; itdf = itdf->next) { - if (! dominance_frontier_dominates(b, itdf->bb)) { - dominance_frontier_list_add(&s, itdf->bb); - } - } - } - - dfi->map[b->nr] = s; -} - -void dominance_frontier_store(dominance_frontier_info *dfi) { - basicblock *bb; - dominance_frontier_item *itdf; - basicblock **itout; - - for (bb = dfi->jd->basicblocks; bb; bb = bb->next) { - if (bb->nr < dfi->jd->basicblockcount) { - if (dfi->map[bb->nr].count > 0) { - bb->domfrontiercount = dfi->map[bb->nr].count; - itout = bb->domfrontier = DMNEW(basicblock *, bb->domfrontiercount); - for (itdf = dfi->map[bb->nr].first; itdf; itdf = itdf->next) { - *itout = itdf->bb; - itout += 1; - } - } - } - } -} - -bool dominance_frontier_build(jitdata *jd) { - int32_t ds = dumpmemory_marker(); - - dominance_frontier_info *dfi = dominance_frontier_init(jd); - dominance_frontier_for_block(dfi, jd->basicblocks); - dominance_frontier_store(dfi); -} - -#include "vm/jit/show.h" -#include "vm/jit/python.h" - -extern void graph_add_edge( graphdata *gd, int from, int to ); - -void dominator_tree_validate(jitdata *jd, dominatordata *_dd) { - int32_t ds = dumpmemory_marker(); - graphdata *gd; - int i, j; - basicblock *bptr, **it; - dominatordata *dd; - int *itnr; - bool found; - - fprintf(stderr, "%s/%s: \n", jd->m->clazz->name->text, jd->m->name->text); - gd = graph_init(jd->basicblockcount); - - for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { - for (it = bptr->successors; it != bptr->successors + bptr->successorcount; ++it) { - graph_add_edge(gd, bptr->nr, (*it)->nr); - } - } - - dd = compute_Dominators(gd, jd->basicblockcount); - - for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { - if (bptr->flags >= BBREACHED) { - if (bptr->idom == NULL) { - if (!(dd->idom[bptr->nr] == -1)) { - printf("-- %d %d\n", dd->idom[bptr->nr], bptr->nr); - assert(0); - } - } else { - assert(dd->idom[bptr->nr] == bptr->idom->nr); - } - } - } - - computeDF(gd, dd, jd->basicblockcount, 0); - - for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { - if (bptr->flags >= BBREACHED) { - assert(bptr->domfrontiercount == dd->num_DF[bptr->nr]); - for (itnr = dd->DF[bptr->nr]; itnr != dd->DF[bptr->nr] + dd->num_DF[bptr->nr]; ++itnr) { - found = false; - for (it = bptr->domfrontier; it != bptr->domfrontier + bptr->domfrontiercount; ++it) { - if ((*it)->nr == *itnr) { - found =true; break; - } - } - assert(found); - } - } - } - - dumpmemory_release(ds); -} - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vm/jit/optimizing/dominators.cpp b/src/vm/jit/optimizing/dominators.cpp new file mode 100644 index 000000000..4f8da4a9e --- /dev/null +++ b/src/vm/jit/optimizing/dominators.cpp @@ -0,0 +1,657 @@ +/* src/vm/jit/optimizing/dominators.cpp - dominators and dominance frontier + + Copyright (C) 2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + +*/ + + +#include "config.h" + +#include "config.h" + +#include "mm/memory.h" + +#include "toolbox/bitvector.h" + +#include "vm/jit/jit.hpp" + +#include "vm/jit/optimizing/graph.h" +#include "vm/jit/optimizing/dominators.hpp" + + +/* function prototypes */ +void dom_Dominators_init(dominatordata *dd, int basicblockcount); +#ifdef DOM_DEBUG_CHECK +int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount); +void dom_Link(dominatordata *dd, int p, int n, int basicblockcount); +void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N, + int basicblockcount); +#else +int dom_AncestorWithLowestSemi(dominatordata *dd, int v); +void dom_Link(dominatordata *dd, int p, int n); +void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N); +#endif + +/************************************* +Calculate Dominators +*************************************/ +dominatordata *compute_Dominators(graphdata *gd, int basicblockcount) { + int i,j,n,N,p,s,s_,v,y; + graphiterator iter; + dominatordata *dd; + + dd = (dominatordata*) DumpMemory::allocate(sizeof(dominatordata)); + + dom_Dominators_init(dd, basicblockcount); + + N=0; + + /* 1 ist the root node of the method */ + /* 0 is the artificial parent, where locals are set to their parameters */ + dom_DFS(gd, dd, -1, 0, &N +#ifdef DOM_DEBUG_CHECK + ,basicblockcount +#endif + ); + + for(i = N-1; i > 0; i--) { + _DOM_CHECK_BOUNDS(i, 0, basicblockcount); + n = dd->vertex[i]; + _DOM_CHECK_BOUNDS(n, 0, basicblockcount); + p = dd->parent[n]; + s = p; + j = graph_get_first_predecessor(gd, n, &iter); + for (; j != -1; j = graph_get_next(&iter)) { + _DOM_CHECK_BOUNDS(j, 0, basicblockcount); + if (dd->dfnum[j] <= dd->dfnum[n]) + s_ = j; + else + s_ = dd->semi[dom_AncestorWithLowestSemi(dd, j +#ifdef DOM_DEBUG_CHECK + ,basicblockcount +#endif + )]; + _DOM_CHECK_BOUNDS(s_, 0, basicblockcount); + _DOM_CHECK_BOUNDS(s, 0, basicblockcount); + if (dd->dfnum[s_] < dd->dfnum[s]) + s = s_; + } + dd->semi[n] = s; + _DOM_CHECK_BOUNDS(dd->num_bucket[s], 0, basicblockcount); + dd->bucket[s][dd->num_bucket[s]] = n; + dd->num_bucket[s]++; + dom_Link(dd, p, n +#ifdef DOM_DEBUG_CHECK + , basicblockcount +#endif + ); + _DOM_CHECK_BOUNDS(p, 0, basicblockcount); + for(j = 0; j < dd->num_bucket[p]; j++) { + _DOM_CHECK_BOUNDS(j, 0, basicblockcount); + v = dd->bucket[p][j]; + y = dom_AncestorWithLowestSemi(dd, v +#ifdef DOM_DEBUG_CHECK + , basicblockcount +#endif + ); + _DOM_CHECK_BOUNDS(y, 0, basicblockcount); + _DOM_CHECK_BOUNDS(v, 0, basicblockcount); + if (dd->semi[y] == dd->semi[v]) + dd->idom[v] = p; + else + dd->samedom[v] = y; + } + dd->num_bucket[p] = 0; + } + for(i = 1; i < N; i++) { + n = dd->vertex[i]; + _DOM_CHECK_BOUNDS(n, 0, basicblockcount); + if (dd->samedom[n] != -1) { + _DOM_CHECK_BOUNDS(dd->samedom[n], 0, basicblockcount); + dd->idom[n] = dd->idom[dd->samedom[n]]; + } + } + return dd; +} + +/******************************************** +compute Dominace Frontier +********************************************/ +void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n) { + int c,i,j; + bool *_S; + graphiterator iter; + + _S = (bool*) DumpMemory::allocate(sizeof(bool) * basicblockcount); + for(i = 0; i < basicblockcount; i++) + _S[i] = false; + i = graph_get_first_successor(gd, n, &iter); + for (; i != -1; i = graph_get_next(&iter)) { + _DOM_CHECK_BOUNDS(i, 0, basicblockcount); + if (dd->idom[i] != n) + _S[i] = true; + } + for(c=0; c < basicblockcount; c++) { + if (dd->idom[c] == n) { + computeDF(gd, dd, basicblockcount, c); + for(j=0; j < dd->num_DF[c]; j++) { + _DOM_CHECK_BOUNDS(dd->DF[c][j], 0, basicblockcount); + if (n != dd->idom[dd->DF[c][j]]) + /* n does not dominate DF[c][j] -> traverse idom list? */ + _S[dd->DF[c][j]] = true; + } + } + } + for(i = 0; i < basicblockcount; i++) + if (_S[i]) { + _DOM_CHECK_BOUNDS(dd->num_DF[n], 0, basicblockcount); + dd->DF[n][dd->num_DF[n]] = i; + dd->num_DF[n]++; + } +} + + +void dom_Dominators_init(dominatordata *dd, int basicblockcount) { + int i; + + dd->dfnum = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->vertex = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->parent = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->semi = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->ancestor = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->idom = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->samedom = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->bucket = (int**) DumpMemory::allocate(sizeof(int*) * basicblockcount); + dd->num_bucket = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->DF = (int**) DumpMemory::allocate(sizeof(int*) * basicblockcount); + dd->num_DF = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->best = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + for (i=0; i < basicblockcount; i++) { + dd->dfnum[i] = -1; + dd->semi[i] = dd->ancestor[i] = dd->idom[i] = dd->samedom[i] = -1; + dd->num_bucket[i] = 0; + dd->bucket[i] = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + dd->num_DF[i] = 0; + dd->DF[i] = (int*) DumpMemory::allocate(sizeof(int) * basicblockcount); + } +} + +/************************************** +Create Depth First Spanning Tree +**************************************/ +#ifdef DOM_DEBUG_CHECK +void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N, + int basicblockcount) { +#else +void dom_DFS(graphdata *gd, dominatordata *dd, int p, int n, int *N) { +#endif + int i; + graphiterator iter; + + _DOM_CHECK_BOUNDS(n,0,basicblockcount); + if (dd->dfnum[n] == -1) { /* not visited till now? */ + dd->dfnum[n] = *N; + _DOM_CHECK_BOUNDS(*N,0,basicblockcount); + dd->vertex[*N] = n; + dd->parent[n] = p; + (*N)++; + i = graph_get_first_successor(gd, n, &iter); + for (; i != -1; i = graph_get_next(&iter)) { + dom_DFS(gd, dd, n, i, N +#ifdef DOM_DEBUG_CHECK + , basicblockcount +#endif + ); + } + } +} + +#ifdef DOM_DEBUG_CHECK +int dom_AncestorWithLowestSemi(dominatordata *dd, int v, int basicblockcount) { +#else +int dom_AncestorWithLowestSemi(dominatordata *dd, int v) { +#endif + int a,b; + + _DOM_CHECK_BOUNDS(v, 0, basicblockcount); + a = dd->ancestor[v]; + _DOM_CHECK_BOUNDS(a,0,basicblockcount); + if (dd->ancestor[a] != -1) { + b = dom_AncestorWithLowestSemi(dd, a +#ifdef DOM_DEBUG_CHECK + , basicblockcount +#endif + ); + dd->ancestor[v] = dd->ancestor[a]; + _DOM_CHECK_BOUNDS(b,0,basicblockcount); + _DOM_CHECK_BOUNDS(dd->best[v],0,basicblockcount); + _DOM_CHECK_BOUNDS(dd->semi[dd->best[v]],0,basicblockcount); + if (dd->dfnum[dd->semi[b]] < dd->dfnum[dd->semi[dd->best[v]]]) + dd->best[v] = b; + } + return dd->best[v]; +} + +#ifdef DOM_DEBUG_CHECK +void dom_Link(dominatordata *dd, int p, int n, int basicblockcount) { +#else +void dom_Link(dominatordata *dd, int p, int n) { +#endif + _DOM_CHECK_BOUNDS(n,0,basicblockcount); + dd->ancestor[n] = p; + dd->best[n] = n; +} + +/*********************************************************/ + +typedef struct basicblock_info basicblock_info; + +struct basicblock_info { + basicblock *bb; + int dfnum; + basicblock_info *parent; + basicblock_info *semi; + basicblock_info *ancestor; + basicblock_info *best; + basicblock_info *idom; + basicblock_info *samedom; + basicblock_info **bucket; + unsigned bucketcount; +}; + +typedef struct dominator_tree_info dominator_tree_info; + +struct dominator_tree_info { + jitdata *jd; + basicblock_info *basicblocks; + basicblock_info **df_map; + unsigned df_counter; +}; + +static dominator_tree_info *dominator_tree_init(jitdata *jd) { + dominator_tree_info *di; + basicblock *itb; + basicblock_info *iti; + + di = (dominator_tree_info*) DumpMemory::allocate(sizeof(dominator_tree_info)); + + di->jd = jd; + + di->basicblocks = (basicblock_info*) DumpMemory::allocate(sizeof(basicblock_info) * jd->basicblockcount); + MZERO(di->basicblocks, basicblock_info, jd->basicblockcount); + + for (iti = di->basicblocks; iti != di->basicblocks + jd->basicblockcount; ++iti) { + iti->dfnum = -1; + iti->bucket = (basicblock_info**) DumpMemory::allocate(sizeof(basicblock_info*) * jd->basicblockcount); + iti->bucketcount = 0; + } + + for (itb = jd->basicblocks; itb; itb = itb->next) { + di->basicblocks[itb->nr].bb = itb; + } + + di->df_map = (basicblock_info**) DumpMemory::allocate(sizeof(basicblock_info*) * jd->basicblockcount); + MZERO(di->df_map, basicblock_info *, jd->basicblockcount); + + di->df_counter = 0; + + return di; +} + +static inline basicblock_info *dominator_tree_get_basicblock(dominator_tree_info *di, basicblock *bb) { + return di->basicblocks + bb->nr; +} + +static void dominator_tree_depth_first_search( + dominator_tree_info *di, basicblock_info *parent, basicblock_info *node +) { + basicblock **it; + + if (node->dfnum == -1) { + + node->dfnum = di->df_counter; + node->parent = parent; + di->df_map[di->df_counter] = node; + di->df_counter += 1; + + for (it = node->bb->successors; it != node->bb->successors + node->bb->successorcount; ++it) { + dominator_tree_depth_first_search( + di, node, + dominator_tree_get_basicblock(di, *it) + ); + } + } +} + +void dominator_tree_link(dominator_tree_info *di, basicblock_info *parent, basicblock_info *node) { + node->ancestor = parent; + node->best = node; +} + +basicblock_info *dominator_tree_ancestor_with_lowest_semi( + dominator_tree_info *di, basicblock_info *node +) { + basicblock_info *a, *b; + + a = node->ancestor; + + if (a->ancestor != NULL) { + b = dominator_tree_ancestor_with_lowest_semi(di, a); + node->ancestor = a->ancestor; + if (b->semi->dfnum < node->best->semi->dfnum) { + node->best = b; + } + } + + return node->best; +} + +void dominator_tree_build_intern(jitdata *jd) { + + dominator_tree_info *di; + basicblock_info *node; + basicblock_info *semicand; + basicblock_info *pred; + basicblock **itb; + basicblock_info **itii; + basicblock_info *v, *y; + int i; + + di = dominator_tree_init(jd); + + dominator_tree_depth_first_search(di, NULL, dominator_tree_get_basicblock(di, jd->basicblocks)); + + for (i = di->df_counter - 1; i >= 1; --i) { + node = di->df_map[i]; + + node->semi = node->parent; + + for ( + itb = node->bb->predecessors; + itb != node->bb->predecessors + node->bb->predecessorcount; + ++itb + ) { + + pred = dominator_tree_get_basicblock(di, *itb); + + if (pred->dfnum <= node->dfnum) { + semicand = pred; + } else { + semicand = dominator_tree_ancestor_with_lowest_semi(di, pred)->semi; + } + + if (semicand->dfnum < node->semi->dfnum) { + node->semi = semicand; + } + } + + node->semi->bucket[node->semi->bucketcount] = node; + node->semi->bucketcount += 1; + + dominator_tree_link(di, node->parent, node); + + for (itii = node->parent->bucket; itii != node->parent->bucket + node->parent->bucketcount; ++itii) { + v = *itii; + y = dominator_tree_ancestor_with_lowest_semi(di, v); + if (y->semi == v->semi) { + v->idom = node->parent; + } else { + v->samedom = y; + } + } + + node->parent->bucketcount = 0; + } + + for (i = 1; i < di->df_counter; ++i) { + node = di->df_map[i]; + if (node->samedom) { + node->idom = node->samedom->idom; + } + + node->bb->idom = node->idom->bb; + node->idom->bb->domsuccessorcount += 1; + } +} + +void dominator_tree_link_children(jitdata *jd) { + basicblock *bb; + /* basicblock number => current number of successors */ + unsigned *numsuccessors; + + // Create new dump memory area. + DumpMemoryArea dma; + + /* Allocate memory for successors */ + + for (bb = jd->basicblocks; bb; bb = bb->next) { + if (bb->domsuccessorcount > 0) { + bb->domsuccessors = (basicblock**) DumpMemory::allocate(sizeof(basicblock*) * bb->domsuccessorcount); + } + } + + /* Allocate memory for per basic block counter of successors */ + + numsuccessors = (unsigned*) DumpMemory::allocate(sizeof(unsigned) * jd->basicblockcount); + MZERO(numsuccessors, unsigned, jd->basicblockcount); + + /* Link immediate dominators with successors */ + + for (bb = jd->basicblocks; bb; bb = bb->next) { + if (bb->idom) { + bb->idom->domsuccessors[numsuccessors[bb->idom->nr]] = bb; + numsuccessors[bb->idom->nr] += 1; + } + } +} + +bool dominator_tree_build(jitdata *jd) { + // Create new dump memory area. + DumpMemoryArea dma; + + dominator_tree_build_intern(jd); + + dominator_tree_link_children(jd); + + return true; +} + +typedef struct dominance_frontier_item dominance_frontier_item; + +struct dominance_frontier_item { + basicblock *bb; + dominance_frontier_item *next; +}; + +typedef struct dominance_frontier_list dominance_frontier_list; + +struct dominance_frontier_list { + dominance_frontier_item *first; + unsigned count; +}; + +void dominance_frontier_list_add(dominance_frontier_list *list, basicblock *bb) { + dominance_frontier_item *item; + + for (item = list->first; item; item = item->next) { + if (item->bb == bb) return; + } + + item = (dominance_frontier_item*) DumpMemory::allocate(sizeof(dominance_frontier_item)); + item->bb = bb; + item->next = list->first; + list->first = item; + list->count += 1; +} + +typedef struct dominance_frontier_info dominance_frontier_info; + +struct dominance_frontier_info { + jitdata *jd; + dominance_frontier_list *map; +}; + +dominance_frontier_info *dominance_frontier_init(jitdata *jd) { + dominance_frontier_info *dfi = (dominance_frontier_info*) DumpMemory::allocate(sizeof(dominance_frontier_info)); + + dfi->jd = jd; + + dfi->map = (dominance_frontier_list*) DumpMemory::allocate(sizeof(dominance_frontier_list) * jd->basicblockcount); + MZERO(dfi->map, dominance_frontier_list, jd->basicblockcount); + + return dfi; +} + +bool dominance_frontier_dominates(basicblock *d, basicblock *x) { + x = x->idom; + + while (x != NULL) { + if (x == d) { + return true; + } + x = x->idom; + } + + return false; +} + +void dominance_frontier_for_block(dominance_frontier_info *dfi, basicblock *b) { + basicblock **it; + dominance_frontier_item *itdf; + dominance_frontier_list s = { NULL, 0 }; + + for (it = b->successors; it != b->successors + b->successorcount; ++it) { + if ((*it)->idom != b) { + dominance_frontier_list_add(&s, *it); + } + } + + for (it = b->domsuccessors; it != b->domsuccessors + b->domsuccessorcount; ++it) { + dominance_frontier_for_block(dfi, *it); + for (itdf = dfi->map[(*it)->nr].first; itdf; itdf = itdf->next) { + if (! dominance_frontier_dominates(b, itdf->bb)) { + dominance_frontier_list_add(&s, itdf->bb); + } + } + } + + dfi->map[b->nr] = s; +} + +void dominance_frontier_store(dominance_frontier_info *dfi) { + basicblock *bb; + dominance_frontier_item *itdf; + basicblock **itout; + + for (bb = dfi->jd->basicblocks; bb; bb = bb->next) { + if (bb->nr < dfi->jd->basicblockcount) { + if (dfi->map[bb->nr].count > 0) { + bb->domfrontiercount = dfi->map[bb->nr].count; + itout = bb->domfrontier = (basicblock**) DumpMemory::allocate(sizeof(basicblock*) * bb->domfrontiercount); + for (itdf = dfi->map[bb->nr].first; itdf; itdf = itdf->next) { + *itout = itdf->bb; + itout += 1; + } + } + } + } +} + +bool dominance_frontier_build(jitdata *jd) { + // Create new dump memory area. + DumpMemoryArea dma; + + dominance_frontier_info *dfi = dominance_frontier_init(jd); + dominance_frontier_for_block(dfi, jd->basicblocks); + dominance_frontier_store(dfi); +} + +#include "vm/jit/show.h" +#include "vm/jit/python.h" + +extern "C" void graph_add_edge( graphdata *gd, int from, int to ); + +void dominator_tree_validate(jitdata *jd, dominatordata *_dd) { + graphdata *gd; + int i, j; + basicblock *bptr, **it; + dominatordata *dd; + int *itnr; + bool found; + + // Create new dump memory area. + DumpMemoryArea dma; + + fprintf(stderr, "%s/%s: \n", jd->m->clazz->name->text, jd->m->name->text); + gd = graph_init(jd->basicblockcount); + + for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { + for (it = bptr->successors; it != bptr->successors + bptr->successorcount; ++it) { + graph_add_edge(gd, bptr->nr, (*it)->nr); + } + } + + dd = compute_Dominators(gd, jd->basicblockcount); + + for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { + if (bptr->flags >= BBREACHED) { + if (bptr->idom == NULL) { + if (!(dd->idom[bptr->nr] == -1)) { + printf("-- %d %d\n", dd->idom[bptr->nr], bptr->nr); + assert(0); + } + } else { + assert(dd->idom[bptr->nr] == bptr->idom->nr); + } + } + } + + computeDF(gd, dd, jd->basicblockcount, 0); + + for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { + if (bptr->flags >= BBREACHED) { + assert(bptr->domfrontiercount == dd->num_DF[bptr->nr]); + for (itnr = dd->DF[bptr->nr]; itnr != dd->DF[bptr->nr] + dd->num_DF[bptr->nr]; ++itnr) { + found = false; + for (it = bptr->domfrontier; it != bptr->domfrontier + bptr->domfrontiercount; ++it) { + if ((*it)->nr == *itnr) { + found =true; break; + } + } + assert(found); + } + } + } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/optimizing/dominators.h b/src/vm/jit/optimizing/dominators.h deleted file mode 100644 index 376b78e4a..000000000 --- a/src/vm/jit/optimizing/dominators.h +++ /dev/null @@ -1,94 +0,0 @@ -/* src/vm/jit/optimizing/dominators.h - Dominators and Dominance Frontier header - - Copyright (C) 2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Ullrich - - -*/ - - -#ifndef _DOMINATORS_H -#define _DOMINATORS_H - -#include "vm/jit/optimizing/graph.h" - -#if !defined(NDEBUG) -# include -/* # define DOM_DEBUG_CHECK */ -# define DOM_DEBUG_VERBOSE -#endif - -#ifdef DOM_DEBUG_CHECK -# define _DOM_CHECK_BOUNDS(i,l,h) assert( ((i) >= (l)) && ((i) < (h))); -# define _DOM_ASSERT(a) assert((a)); -#else -# define _DOM_CHECK_BOUNDS(i,l,h) -# define _DOM_ASSERT(a) -#endif - -struct dominatordata { - int *dfnum; /* [0..ls->basicblockcount[ */ - int *vertex; /* [0..ls->basicblockcount[ */ - int *parent; /* [0..ls->basicblockcount[ */ - int *semi; /* [0..ls->basicblockcount[ */ - int *ancestor; /* [0..ls->basicblockcount[ */ - int *idom; /* [0..ls->basicblockcount[ */ - int *samedom; /* [0..ls->basicblockcount[ */ - int **bucket; /* [0..ls->basicblockcount[[0..ls->bbc[ */ - int *num_bucket; /* [0..ls->basicblockcount[ */ - int *best; /* [0..ls->basicblockcount[ */ - int **DF; /* [0..ls->basicblockcount[[0..ls->bbc[ */ - int *num_DF; /* [0..ls->basicblockcount[ */ -}; - -typedef struct dominatordata dominatordata; - -/* function prototypes */ -dominatordata *compute_Dominators(graphdata *gd, int basicblockcount); -void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n); - -/* ............................... */ - -bool dominator_tree_build(jitdata *jd); - -bool dominance_frontier_build(jitdata *jd); - -void dominator_tree_validate(jitdata *jd, dominatordata *dd); - -#endif /* _DOMINATORS_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vm/jit/optimizing/dominators.hpp b/src/vm/jit/optimizing/dominators.hpp new file mode 100644 index 000000000..bd7df65b9 --- /dev/null +++ b/src/vm/jit/optimizing/dominators.hpp @@ -0,0 +1,99 @@ +/* src/vm/jit/optimizing/dominators.hpp - Dominators and Dominance Frontier header + + Copyright (C) 2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + +*/ + + +#ifndef _DOMINATORS_HPP +#define _DOMINATORS_HPP + +#include "config.h" + +#include "vm/jit/optimizing/graph.h" + +#if !defined(NDEBUG) +# include +/* # define DOM_DEBUG_CHECK */ +# define DOM_DEBUG_VERBOSE +#endif + +#ifdef DOM_DEBUG_CHECK +# define _DOM_CHECK_BOUNDS(i,l,h) assert( ((i) >= (l)) && ((i) < (h))); +# define _DOM_ASSERT(a) assert((a)); +#else +# define _DOM_CHECK_BOUNDS(i,l,h) +# define _DOM_ASSERT(a) +#endif + +struct dominatordata { + int *dfnum; /* [0..ls->basicblockcount[ */ + int *vertex; /* [0..ls->basicblockcount[ */ + int *parent; /* [0..ls->basicblockcount[ */ + int *semi; /* [0..ls->basicblockcount[ */ + int *ancestor; /* [0..ls->basicblockcount[ */ + int *idom; /* [0..ls->basicblockcount[ */ + int *samedom; /* [0..ls->basicblockcount[ */ + int **bucket; /* [0..ls->basicblockcount[[0..ls->bbc[ */ + int *num_bucket; /* [0..ls->basicblockcount[ */ + int *best; /* [0..ls->basicblockcount[ */ + int **DF; /* [0..ls->basicblockcount[[0..ls->bbc[ */ + int *num_DF; /* [0..ls->basicblockcount[ */ +}; + +typedef struct dominatordata dominatordata; + +/* function prototypes */ + +#ifdef __cplusplus +extern "C" { +#endif + +dominatordata *compute_Dominators(graphdata *gd, int basicblockcount); +void computeDF(graphdata *gd, dominatordata *dd, int basicblockcount, int n); + +/* ............................... */ + +bool dominator_tree_build(jitdata *jd); + +bool dominance_frontier_build(jitdata *jd); + +void dominator_tree_validate(jitdata *jd, dominatordata *dd); + +#ifdef __cplusplus +} +#endif + +#endif // _DOMINATORS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/optimizing/escape.c b/src/vm/jit/optimizing/escape.c index b1c0679d5..b0565836f 100644 --- a/src/vm/jit/optimizing/escape.c +++ b/src/vm/jit/optimizing/escape.c @@ -1,4 +1,4 @@ -/* src/vm/optimizing/escape.c +/* src/vm/jit/optimizing/escape.c Copyright (C) 2008 CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO @@ -19,12 +19,71 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ -#include "vm/jit/jit.h" -#include "vmcore/class.h" + +#include "config.h" + +#include "vm/class.h" +#include "vm/classcache.h" + +#include "vm/jit/jit.hpp" #include "vm/jit/optimizing/escape.h" +#include + +#if defined(ENABLE_ESCAPE_REASON) +#define ENABLE_REASON +#endif + +#if defined(ENABLE_REASON) +#define I2(why, tov, es) escape_analysis_record_reason(e, why, iptr, tov, es); +#else +#define I2(why, tov, es) +#endif +#define I(why, to, from) I2(why, instruction_ ## to (iptr), escape_analysis_get_state(e, instruction_ ## from (iptr))) +#define E2(why, var) I2(why, var, ESCAPE_GLOBAL) +#define E(why, which) E2(why, instruction_ ## which (iptr)) + +typedef enum { + RED = 31, + GREEN, + YELLOW, + BLUE, + MAGENTA, + CYAN, + WHITE, + COLOR_END +} color_t; + +#define ENABLE_COLOR + +static void color_start(color_t color) { +#if defined(ENABLE_COLOR) + if (RED <= color && color < COLOR_END) { + printf("\033[%dm", color); + } +#endif +} + +static void color_end() { +#if defined(ENABLE_COLOR) + printf("\033[m"); + fflush(stdout); +#endif +} + +static void color_printf(color_t color, const char *fmt, ...) { + va_list ap; + color_start(color); + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + color_end(); +} + + /*** escape_state *************************************************************/ const char *escape_state_to_string(escape_state_t escape_state) { @@ -33,7 +92,7 @@ const char *escape_state_to_string(escape_state_t escape_state) { str(ESCAPE_UNKNOWN) str(ESCAPE_NONE) str(ESCAPE_METHOD) - str(ESCAPE_GLOBAL_THROUGH_METHOD) + str(ESCAPE_METHOD_RETURN) str(ESCAPE_GLOBAL) default: return "???"; } @@ -150,6 +209,8 @@ typedef struct { instruction_list_t *allocations; instruction_list_t *getfields; + instruction_list_t *monitors; + instruction_list_t *returns; struct var_extra **var; @@ -274,12 +335,25 @@ void dependenCy_list_import(dependency_list_t *dl, dependency_list_t *other) { /*** var_extra ***************************************************************/ +#if defined(ENABLE_REASON) +typedef struct reason { + const char *why; + instruction *iptr; + struct reason *next; +} reason_t; +#endif + typedef struct var_extra { instruction *allocation; escape_state_t escape_state; s4 representant; dependency_list_t *dependency_list; - bool is_arg; /* TODO optimize */ + unsigned contains_arg:1; + unsigned contains_only_args:1; + /*signed adr_arg_num:30;*/ +#if defined(ENABLE_REASON) + reason_t *reasons; +#endif } var_extra_t; static void var_extra_init(var_extra_t *ve) { @@ -287,7 +361,12 @@ static void var_extra_init(var_extra_t *ve) { ve->escape_state = ESCAPE_NONE; ve->representant = -1; ve->dependency_list = NULL; - ve->is_arg = false; + ve->contains_arg = false; + ve->contains_only_args = false; + /*ve->adr_arg_num = -1;*/ +#if defined(ENABLE_REASON) + ve->reasons = NULL; +#endif } static inline var_extra_t *var_extra_get_no_alloc(const escape_analysis_t *e, s4 var) { @@ -371,18 +450,41 @@ static void escape_analysis_init(escape_analysis_t *e, jitdata *jd) { e->getfields = DNEW(instruction_list_t); instruction_list_init(e->getfields); + e->monitors = DNEW(instruction_list_t); + instruction_list_init(e->monitors); + + e->returns = DNEW(instruction_list_t); + instruction_list_init(e->returns); + e->var = DMNEW(var_extra_t *, jd->vartop); MZERO(e->var, var_extra_t *, jd->vartop); e->adr_args_count = 0; - e->verbose = ( - strcmp(e->jd->m->clazz->name->text, "gnu/java/util/regex/RESyntax") == 0 - && strcmp(e->jd->m->name->text, "") == 0 - ); e->verbose = 1; + e->verbose = strcmp(jd->m->name->text, "") == 0; + e->verbose = getenv("EV") != NULL; } +#if defined(ENABLE_REASON) +static void escape_analysis_record_reason(escape_analysis_t *e, const char *why, instruction *iptr, s4 var, escape_state_t es) { + var_extra_t *ve; + reason_t *re; + if (es == ESCAPE_GLOBAL || es == ESCAPE_METHOD_RETURN) { + var = var_extra_get_representant(e, var); + ve = var_extra_get(e, var); + re = NEW(reason_t); + re->why = why; + re->iptr= iptr; + re->next = ve->reasons; + ve->reasons = re; + if (e->verbose) { + printf("%d escapes because %s\n", var, why); + } + } +} +#endif + static void escape_analysis_set_allocation(escape_analysis_t *e, s4 var, instruction *iptr) { var_extra_get(e, var)->allocation = iptr; } @@ -396,12 +498,38 @@ static instruction *escape_analysis_get_allocation(const escape_analysis_t *e, s return ve->allocation; } -static void escape_analysis_set_is_argument(escape_analysis_t *e, s4 var) { - var_extra_get(e, var)->is_arg = true; +static void escape_analysis_set_contains_argument(escape_analysis_t *e, s4 var) { + var = var_extra_get_representant(e, var); + var_extra_get(e, var)->contains_arg = true; +} + +static bool escape_analysis_get_contains_argument(escape_analysis_t *e, s4 var) { + var = var_extra_get_representant(e, var); + return var_extra_get(e, var)->contains_arg; +} + +static void escape_analysis_set_contains_only_arguments(escape_analysis_t *e, s4 var) { + var = var_extra_get_representant(e, var); + var_extra_get(e, var)->contains_only_args = true; +} + +static bool escape_analysis_get_contains_only_arguments(escape_analysis_t *e, s4 var) { + var = var_extra_get_representant(e, var); + return var_extra_get(e, var)->contains_only_args; +} + +/* +static void escape_analysis_set_adr_arg_num(escape_analysis_t *e, s4 var, s4 num) { + var_extra_get(e, var)->adr_arg_num = num; +} + +static s4 escape_analysis_get_adr_arg_num(escape_analysis_t *e, s4 var) { + return var_extra_get(e, var)->adr_arg_num; } +*/ -static bool escape_analysis_get_is_argument(escape_analysis_t *e, s4 var) { - return var_extra_get(e, var)->is_arg; +static bool escape_analysis_in_same_set(escape_analysis_t *e, s4 var1, s4 var2) { + return var_extra_get_representant(e, var1) == var_extra_get_representant(e, var2); } static void escape_analysis_ensure_state(escape_analysis_t *e, s4 var, escape_state_t escape_state) { @@ -432,6 +560,10 @@ static void escape_analysis_ensure_state(escape_analysis_t *e, s4 var, escape_st dependency_list_item_get_dependency(it), escape_state ); + { + instruction *iptr = NULL; + I2("propagated by dependency", dependency_list_item_get_dependency(it), escape_state); + } } } } @@ -441,12 +573,6 @@ static escape_state_t escape_analysis_get_state(escape_analysis_t *e, s4 var) { return var_extra_get_escape_state(e, var); } -#define escape_analysis_assert_has_escape(e, var) \ - assert( \ - var_extra_get_no_alloc(e, var) && \ - (var_extra_get_no_alloc(e, var)->escape_state > ESCAPE_UNKNOWN) \ - ) - static classinfo *escape_analysis_classinfo_in_var(escape_analysis_t *e, s4 var) { instruction *iptr = escape_analysis_get_allocation(e, var); @@ -484,6 +610,8 @@ static void escape_analysis_merge(escape_analysis_t *e, s4 var1, s4 var2) { return; } + if (e->verbose) printf("Merging (%d,%d)\n", var1, var2); + ve1 = var_extra_get(e, var1); ve2 = var_extra_get(e, var2); @@ -496,10 +624,10 @@ static void escape_analysis_merge(escape_analysis_t *e, s4 var1, s4 var2) { ve2->representant = var1; - /* Adjust is_argument to logical or. */ + /* Adjust is_arg to logical or. */ - has_become_arg = ve1->is_arg != ve2->is_arg; - ve1->is_arg = ve1->is_arg || ve2->is_arg; + has_become_arg = ve1->contains_arg != ve2->contains_arg; + ve1->contains_arg = ve1->contains_arg || ve2->contains_arg; if (e->verbose && has_become_arg) printf("(%d,%d) has become arg.\n", var1, var2); @@ -521,8 +649,35 @@ static void escape_analysis_merge(escape_analysis_t *e, s4 var1, s4 var2) { dependency_list_item_get_dependency(itd), ESCAPE_GLOBAL ); + { + instruction *iptr = NULL; + E2("has become arg", dependency_list_item_get_dependency(itd)); + } + } + } + + /* Adjust contains_only_args to logical and. */ + + ve1->contains_only_args = ve1->contains_only_args && ve2->contains_only_args; + + /* Adjust address argument number contained in this var. */ + + /* + if (ve1->adr_arg_num != ve2->adr_arg_num) { + ve1->adr_arg_num = -1; + } + */ +#if defined(ENABLE_REASON) + if (ve1->reasons) { + reason_t *re = ve1->reasons; + while (re->next != NULL) { + re = re->next; } + re->next = ve2->reasons; + } else { + ve1->reasons = ve2->reasons; } +#endif } static void escape_analysis_add_dependency(escape_analysis_t *e, instruction *store) { @@ -534,7 +689,9 @@ static void escape_analysis_add_dependency(escape_analysis_t *e, instruction *st dependency_list_add(dl, store); if (e->verbose) { - printf("dependency_list_add\n"); + printf("dependency_list_add: %d.dependency_list.add( { ", obj); + show_icmd(e->jd, store, 0, 3); + printf(" } )\n"); } } @@ -545,12 +702,16 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio u1 *paramescape; unsigned i; instruction **iarg; - constant_FMIref *fmi; methodinfo *mi; - resolve_result_t result; + escape_state_t es; + const char *why; if (e->verbose) { - printf("processing %s@%d\n", icmd_table[iptr->opc].name, iptr->line); + color_start(CYAN); + printf("%d: ", iptr->line); + show_icmd(e->jd, iptr, 0, 3); + color_end(); + printf("\n"); } switch (instruction_get_opcode(iptr)) { @@ -568,46 +729,51 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio if (c == NULL) { escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); - if (e->verbose) printf("1\n"); + E("unresolved class", dst) } else if (c->finalizer != NULL) { escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); - if (e->verbose) printf("3\n"); + E("finalizer", dst) } else { escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE); - if (e->verbose) printf("2\n"); } instruction_list_add(e->allocations, iptr); break; + case ICMD_MONITORENTER: + case ICMD_MONITOREXIT: + + instruction_list_add(e->monitors, iptr); + + break; + case ICMD_NEWARRAY: case ICMD_ANEWARRAY: escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); escape_analysis_set_allocation(e, instruction_dst(iptr), iptr); instruction_list_add(e->allocations, iptr); - + E("untracked array", dst) break; case ICMD_PUTSTATIC: if (instruction_field_type(iptr) == TYPE_ADR) { - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL); + E("putstatic", s1) } break; case ICMD_PUTFIELD: if (instruction_field_type(iptr) == TYPE_ADR) { - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - escape_analysis_assert_has_escape(e, instruction_s2(iptr)); - */ - if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) { + if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) { escape_analysis_ensure_state(e, instruction_s2(iptr), ESCAPE_GLOBAL); + /* If s1 is currently not an argument, but can contain one later because + of a phi function, the merge function takes care to make all + dependencies escape globally. */ + E("putfield into argument", s2) } else { + I("putfield inherit", s2, s1); escape_analysis_ensure_state(e, instruction_s2(iptr), escape_analysis_get_state(e, instruction_s1(iptr))); escape_analysis_add_dependency(e, iptr); } @@ -615,13 +781,13 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio break; case ICMD_AASTORE: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - escape_analysis_assert_has_escape(e, instruction_s3(iptr)); - */ - if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) { + if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) { + if (e->verbose) printf("Contains argument.\n"); escape_analysis_ensure_state(e, instruction_s3(iptr), ESCAPE_GLOBAL); + E("aastore into argument", s3) } else { + if (e->verbose) printf("Contains no argument.\n"); + I("aastore", s3, s1) escape_analysis_ensure_state(e, instruction_s3(iptr), escape_analysis_get_state(e, instruction_s1(iptr))); escape_analysis_add_dependency(e, iptr); } @@ -630,22 +796,21 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio case ICMD_GETSTATIC: if (instruction_field_type(iptr) == TYPE_ADR) { escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); + E("loaded from static var", dst) escape_analysis_set_allocation(e, instruction_dst(iptr), iptr); } break; case ICMD_GETFIELD: if (instruction_field_type(iptr) == TYPE_ADR) { - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ - if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) { + if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) { /* Fields loaded from arguments escape globally. x = arg.foo; x.bar = y; => y escapes globally. */ escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); + E("loaded from arg", dst) } else { escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE); } @@ -657,19 +822,15 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio break; case ICMD_ARRAYLENGTH: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ + escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD); break; case ICMD_AALOAD: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ - if (escape_analysis_get_is_argument(e, instruction_s1(iptr))) { + if (escape_analysis_get_contains_argument(e, instruction_s1(iptr))) { /* If store into argument, escapes globally. See ICMD_GETFIELD. */ escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); + E("aaload from argument", dst) } else { escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE); } @@ -681,36 +842,27 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio case ICMD_IF_ACMPEQ: case ICMD_IF_ACMPNE: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - escape_analysis_assert_has_escape(e, instruction_s2(iptr)); - */ escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD); escape_analysis_ensure_state(e, instruction_s2(iptr), ESCAPE_METHOD); break; case ICMD_IFNULL: case ICMD_IFNONNULL: + escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD); + break; + case ICMD_CHECKNULL: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD); + escape_analysis_merge(e, instruction_s1(iptr), instruction_dst(iptr)); break; case ICMD_CHECKCAST: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ escape_analysis_merge(e, instruction_s1(iptr), instruction_dst(iptr)); escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD); escape_analysis_set_allocation(e, instruction_dst(iptr), iptr); break; case ICMD_INSTANCEOF: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD); break; @@ -721,15 +873,25 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio count = instruction_arg_count(iptr); mi = instruction_local_methodinfo(iptr); paramescape = NULL; + why = "???"; if (mi != NULL) { /* If the method could be resolved, it already is. */ paramescape = mi->paramescape; + if (e->verbose) { + if (paramescape) { + printf("Paramescape for callee available.\n"); + } + } + + if (paramescape) why = "Available param escape"; + if (paramescape == NULL) { if (e->verbose) { printf("BC escape analyzing callee.\n"); } + why = "BC param escape"; bc_escape_analysis_perform(mi); paramescape = mi->paramescape; } @@ -737,26 +899,66 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio if (e->verbose) { printf("Unresolved callee.\n"); } + why = "Unresolved callee"; + } + + if (iptr->opc == ICMD_INVOKEVIRTUAL || iptr->opc == ICMD_INVOKEINTERFACE) { + if (mi != NULL && !escape_is_monomorphic(e->jd->m, mi)) { + if (e->verbose) { + printf("Not monomorphic.\n"); + } + why = "Polymorphic"; + paramescape = NULL; + } } + /* Set the escape state of the return value. + This is: global if we down have information of the callee, or the callee + supplied escape state. */ + + if (instruction_return_type(iptr) == TYPE_ADR) { + if (paramescape == NULL) { + escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_GLOBAL); + E(why, dst); + } else { + es = escape_state_from_u1(paramescape[-1]); + I2(why, instruction_dst(iptr), es) + escape_analysis_ensure_state(e, instruction_dst(iptr), es); + } + escape_analysis_set_allocation(e, instruction_dst(iptr), iptr); + } + for (i = 0; i < count; ++i) { if (instruction_arg_type(iptr, i) == TYPE_ADR) { - /* - escape_analysis_assert_has_escape(e, instruction_arg(iptr, i)); - */ if (paramescape == NULL) { escape_analysis_ensure_state( e, instruction_arg(iptr, i), - instruction_local_methodinfo(iptr) && instruction_local_methodinfo(iptr)->jcode ? - ESCAPE_GLOBAL_THROUGH_METHOD : - ESCAPE_GLOBAL + ESCAPE_GLOBAL ); - } else if ((escape_state_t)*paramescape < ESCAPE_METHOD) { - escape_analysis_ensure_state(e, instruction_arg(iptr, i), ESCAPE_METHOD); + E2(why, instruction_arg(iptr, i)); + } else if (escape_state_from_u1(*paramescape) <= ESCAPE_METHOD) { + es = escape_state_from_u1(*paramescape); + + if (es < ESCAPE_METHOD) { + es = ESCAPE_METHOD; + } + + I2(why, instruction_arg(iptr, i), es); + escape_analysis_ensure_state(e, instruction_arg(iptr, i), es); + + if (*paramescape & 0x80) { + /* Parameter can be returned from method. + This creates an alias to the retur value. + If the return value escapes, the ES of the parameter needs + to be adjusted. */ + escape_analysis_merge(e, instruction_arg(iptr, i), instruction_dst(iptr)); + I2("return alias", instruction_arg(iptr, i), instruction_dst(iptr)); + } } else { - escape_analysis_ensure_state(e, instruction_arg(iptr, i), (escape_state_t)*paramescape); + escape_analysis_ensure_state(e, instruction_arg(iptr, i), ESCAPE_GLOBAL); + E2(why, instruction_arg(iptr, i)); } if (paramescape != NULL) { @@ -765,25 +967,20 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio } } - if (instruction_return_type(iptr) == TYPE_ADR) { - escape_analysis_ensure_state(e, instruction_dst(iptr), ESCAPE_NONE); - escape_analysis_set_allocation(e, instruction_dst(iptr), iptr); - } - break; case ICMD_ATHROW: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL); + E("throw", s1) break; case ICMD_ARETURN: - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ - escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL); + /* If we return only arguments, the return value escapes only the method. + ESCAPE_METHOD for now, and check later, if a different value than an + argument is possibly returned. */ + escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_METHOD_RETURN); + E("return", s1) + instruction_list_add(e->returns, iptr); break; case ICMD_ALOAD: @@ -791,9 +988,6 @@ static void escape_analysis_process_instruction(escape_analysis_t *e, instructio case ICMD_MOVE: case ICMD_COPY: if (instruction_dst_type(iptr, jd) == TYPE_ADR) { - /* - escape_analysis_assert_has_escape(e, instruction_s1(iptr)); - */ escape_analysis_merge(e, instruction_s1(iptr), instruction_dst(iptr)); escape_analysis_set_allocation(e, instruction_dst(iptr), iptr); } @@ -821,6 +1015,10 @@ static void escape_analysis_process_instructions(escape_analysis_t *e) { FOR_EACH_BASICBLOCK(e->jd, bptr) { + if (e->verbose) { + color_printf(CYAN, "=== BB %d ===\n", bptr->nr); + } + for (iptr = bptr->phis; iptr != bptr->phis + bptr->phicount; ++iptr) { escape_analysis_process_instruction(e, iptr); } @@ -832,12 +1030,30 @@ static void escape_analysis_process_instructions(escape_analysis_t *e) { } } +static void escape_analysis_post_process_returns(escape_analysis_t *e) { + instruction_list_item_t *iti; + instruction *iptr; + + if (e->verbose) printf("Post processing returns:\n"); + + FOR_EACH_INSTRUCTION_LIST(e->getfields, iti) { + iptr = iti->instr; + + if (! escape_analysis_get_contains_only_arguments(e, instruction_s1(iptr))) { + escape_analysis_ensure_state(e, instruction_s1(iptr), ESCAPE_GLOBAL); + E("return of not argument", s1) + } + } +} + static void escape_analysis_post_process_getfields(escape_analysis_t *e) { instruction_list_item_t *iti; dependency_list_item_t *itd; instruction *iptr; dependency_list_t *dl; + if (e->verbose) printf("Post processing getfields:\n"); + FOR_EACH_INSTRUCTION_LIST(e->getfields, iti) { iptr = iti->instr; @@ -860,6 +1076,7 @@ static void escape_analysis_post_process_getfields(escape_analysis_t *e) { dependency_list_item_get_dependency(itd), escape_analysis_get_state(e, instruction_dst(iptr)) ); + I2("post process getfield", dependency_list_item_get_dependency(itd), escape_analysis_get_state(e, instruction_dst(iptr))); } } } @@ -867,44 +1084,59 @@ static void escape_analysis_post_process_getfields(escape_analysis_t *e) { } } -static void display_allocation(escape_analysis_t *e, const char *prefix, const instruction *iptr, escape_state_t es) { - const char *cl = "WTF"; - classinfo *c; +static void escape_analysis_mark_monitors(escape_analysis_t *e) { + instruction_list_item_t *iti; + instruction *iptr; + + FOR_EACH_INSTRUCTION_LIST(e->monitors, iti) { + iptr = iti->instr; - if (instruction_get_opcode(iptr) == ICMD_NEW) { - c = escape_analysis_classinfo_in_var(e, instruction_arg(iptr, 0)); - if (c) { - cl = c->name->text; + /* TODO if argument does not escape, mark. */ + if (escape_analysis_get_state(e, instruction_arg(iptr, 0)) != ESCAPE_GLOBAL) { + if (e->verbose) { + printf("Monitor on thread local object!\n"); + } } } - - - printf( - " %s %s %s: %s %s @%d %s\n", - prefix, - e->jd->m->clazz->name->text, - e->jd->m->name->text, - icmd_table[iptr->opc].name, - cl, - iptr->line, - escape_state_to_string(es) - ); } static void escape_analysis_mark_allocations(escape_analysis_t *e) { instruction_list_item_t *iti; + instruction *iptr; escape_state_t es; -/* FOR_EACH_INSTRUCTION_LIST(e->allocations, iti) { - es = escape_analysis_get_state(e, instruction_dst(iti->instr)); - if (es < ESCAPE_GLOBAL_THROUGH_METHOD) { - display_allocation(e, "****", iti->instr, es); + iptr = iti->instr; + es = escape_analysis_get_state(e, instruction_dst(iptr)); + +#if defined(ENABLE_REASON) + if (instruction_get_opcode(iptr) == ICMD_NEW) { + var_extra_t *ve; + iptr->sx.s23.s3.bte = builtintable_get_internal(BUILTIN_escape_reason_new); + ve = var_extra_get(e, var_extra_get_representant(e, instruction_dst(iptr))); + iptr->escape_reasons = ve->reasons; + if (es < ESCAPE_METHOD_RETURN) { + assert(!ve->reasons); + reason_t *r = NEW(reason_t); + r->why = "No escape\n"; + r->iptr = NULL; + r->next = NULL; + iptr->escape_reasons = r; + } else { + assert(iptr->escape_reasons); + } } - if (es == ESCAPE_GLOBAL_THROUGH_METHOD) { - display_allocation(e, "!!!!", iti->instr, es); +#endif + +/* + if (instruction_get_opcode(iptr) == ICMD_NEW) { + es = escape_analysis_get_state(e, instruction_dst(iptr)); + if (es < ESCAPE_METHOD_RETURN) { + iptr->sx.s23.s3.bte = builtintable_get_internal(BUILTIN_tlh_new); + e->jd->code->flags |= CODE_FLAG_TLH; + } } - } */ + } } static void escape_analysis_process_arguments(escape_analysis_t *e) { @@ -922,7 +1154,9 @@ static void escape_analysis_process_arguments(escape_analysis_t *e) { if (t == TYPE_ADR) { if (varindex != UNUSED) { escape_analysis_ensure_state(e, varindex, ESCAPE_NONE); - escape_analysis_set_is_argument(e, varindex); + escape_analysis_set_contains_argument(e, varindex); + escape_analysis_set_contains_only_arguments(e, varindex); + /*escape_analysis_set_adr_arg_num(e, varindex, e->adr_args_count);*/ } e->adr_args_count += 1; } @@ -937,11 +1171,18 @@ static void escape_analysis_export_arguments(escape_analysis_t *e) { s4 varindex; methoddesc *md; u1 *paramescape; + instruction_list_item_t *iti; + instruction *iptr; + escape_state_t es, re; + int ret_val_is_adr; md = e->jd->m->parseddesc; - paramescape = MNEW(u1, e->adr_args_count); - e->jd->m->paramescape = paramescape; + ret_val_is_adr = (md->returntype.type == TYPE_ADR) ? 1 : 0; + + paramescape = MNEW(u1, e->adr_args_count + ret_val_is_adr); + + e->jd->m->paramescape = paramescape + ret_val_is_adr; for (p = 0, l = 0; p < md->paramcount; ++p) { t = md->paramtypes[p].type; @@ -950,16 +1191,59 @@ static void escape_analysis_export_arguments(escape_analysis_t *e) { if (varindex == UNUSED) { *paramescape = (u1)ESCAPE_NONE; } else { - *paramescape = (u1)escape_analysis_get_state(e, varindex); - } - if (e->verbose) { - printf("adr parameter %d: %s\n", p, escape_state_to_string((escape_state_t)*paramescape)); + es = escape_analysis_get_state(e, varindex); + + if (es == ESCAPE_METHOD_RETURN) { + *paramescape = escape_state_to_u1(ESCAPE_METHOD) | 0x80; + if (e->verbose) { + printf("non-escaping adr parameter returned: %d\n", p); + } + } else { + *paramescape = escape_state_to_u1(es); + } + } paramescape += 1; } l += IS_2_WORD_TYPE(t) ? 2 : 1; } + + if (ret_val_is_adr) { + /* Calculate escape state of return value as maximum escape state of all + values returned. */ + + re = ESCAPE_NONE; + + FOR_EACH_INSTRUCTION_LIST(e->returns, iti) { + iptr = iti->instr; + es = escape_analysis_get_state(e, instruction_s1(iptr)); + + if (es > re) { + re = es; + } + } + + e->jd->m->paramescape[-1] = escape_state_to_u1(re); + } +} + +#if defined(ENABLE_REASON) +void print_escape_reasons() { + reason_t *re = THREADOBJECT->escape_reasons; + + fprintf(stderr, "DYN_REASON"); + + for (; re; re = re->next) { + fprintf(stderr,":%s", re->why); + } + + fprintf(stderr, "\n"); +} + +void set_escape_reasons(void *vp) { + THREADOBJECT->escape_reasons = vp; } +#endif static void escape_analysis_display(escape_analysis_t *e) { instruction_list_item_t *iti; @@ -968,13 +1252,26 @@ static void escape_analysis_display(escape_analysis_t *e) { FOR_EACH_INSTRUCTION_LIST(e->allocations, iti) { iptr = iti->instr; - ve = var_extra_get(e, instruction_dst(iptr)); + ve = var_extra_get(e, var_extra_get_representant(e, instruction_dst(iptr))); + show_icmd(e->jd, iptr-1, 0, 3); + printf("\n"); + show_icmd(e->jd, iptr, 0, 3); + printf("\n"); printf( - "%s@%d: %s\n", + "%s@%d: --%s-- %d\n\n", icmd_table[iptr->opc].name, iptr->line, - escape_state_to_string(ve->escape_state) + escape_state_to_string(ve->escape_state), + ve->representant ); +#if defined(ENABLE_REASON) + { + reason_t *re; + for (re = ve->reasons; re; re = re->next) { + printf("ESCAPE_REASON: %s\n", re->why); + } + } +#endif } } @@ -983,25 +1280,72 @@ void escape_analysis_perform(jitdata *jd) { jd->m->flags |= ACC_METHOD_EA; - /*bc_escape_analysis_perform(jd->m);*/ - e = DNEW(escape_analysis_t); escape_analysis_init(e, jd); if (e->verbose) - printf("==== %s/%s ====\n", e->jd->m->clazz->name->text, e->jd->m->name->text); + color_printf(RED, "\n\n==== %s/%s ====\n\n", e->jd->m->clazz->name->text, e->jd->m->name->text); - /*fprintf(stderr, ".");*/ - escape_analysis_process_arguments(e); escape_analysis_process_instructions(e); escape_analysis_post_process_getfields(e); + escape_analysis_post_process_returns(e); + escape_analysis_export_arguments(e); if (e->verbose) escape_analysis_display(e); + + if (e->verbose) { + int i, j, r; + for (i = 0; i < jd->vartop; ++i) { + r = var_extra_get_representant(e, i); + if (i == r) { + printf("EES of %d: ", i); + for (j = 0; j < jd->vartop; ++j) { + if (var_extra_get_representant(e, j) == r) { + printf("%d, ", j); + } + } + printf("\n"); + } + } + printf("\n"); + } + escape_analysis_mark_allocations(e); + escape_analysis_mark_monitors(e); jd->m->flags &= ~ACC_METHOD_EA; } void escape_analysis_escape_check(void *vp) { } + +/*** monomorphic *************************************************************/ + +bool escape_is_monomorphic(methodinfo *caller, methodinfo *callee) { + + /* Non-speculative case */ + + if (callee->flags & (ACC_STATIC | ACC_FINAL | ACC_PRIVATE)) { + return true; + } + + if ( + (callee->flags & (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED| ACC_ABSTRACT)) + == (ACC_METHOD_MONOMORPHIC | ACC_METHOD_IMPLEMENTED) + ) { + + /* Mark that we have used the information about monomorphy. */ + + callee->flags |= ACC_METHOD_MONOMORPHY_USED; + + /* We assume the callee is monomorphic. */ + + method_add_assumption_monomorphic(caller, callee); + + return true; + } + + return false; +} + diff --git a/src/vm/jit/optimizing/escape.h b/src/vm/jit/optimizing/escape.h index 2f427fa31..4b9b9ec4e 100644 --- a/src/vm/jit/optimizing/escape.h +++ b/src/vm/jit/optimizing/escape.h @@ -24,21 +24,31 @@ #ifndef _VM_JIT_OPTIMIZING_ESCAPE_H #define _VM_JIT_OPTIMIZING_ESCAPE_H -#include "vm/jit/jit.h" -#include "vmcore/method.h" +#include "vm/jit/jit.hpp" +#include "vm/method.h" typedef enum { ESCAPE_UNKNOWN, ESCAPE_NONE, ESCAPE_METHOD, - ESCAPE_GLOBAL_THROUGH_METHOD, + ESCAPE_METHOD_RETURN, ESCAPE_GLOBAL } escape_state_t; +static inline escape_state_t escape_state_from_u1(u1 x) { + return (escape_state_t)(x & ~0x80); +} + +static inline u1 escape_state_to_u1(escape_state_t x) { + return (u1)x; +} + void escape_analysis_perform(jitdata *jd); void escape_analysis_escape_check(void *vp); void bc_escape_analysis_perform(methodinfo *m); +bool escape_is_monomorphic(methodinfo *caller, methodinfo *callee); + #endif diff --git a/src/vm/jit/optimizing/graph.c b/src/vm/jit/optimizing/graph.c index 9ffe18468..fdde38c0c 100644 --- a/src/vm/jit/optimizing/graph.c +++ b/src/vm/jit/optimizing/graph.c @@ -1,9 +1,7 @@ /* src/vm/jit/optimizing/graph.c - CFG - Copyright (C) 2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien + Copyright (C) 2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Ullrich - - $Id: graph.c$ - */ #include @@ -38,14 +30,14 @@ #include "toolbox/bitvector.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/optimizing/lsra.h" #include "vm/jit/optimizing/ssa.h" #include "vm/jit/optimizing/graph.h" #ifdef GRAPH_DEBUG_VERBOSE -#include "vmcore/options.h" +#include "vm/options.h" #endif /* Helpers for graph_make_cfg */ diff --git a/src/vm/jit/optimizing/graph.h b/src/vm/jit/optimizing/graph.h index 12ad79381..088eb4568 100644 --- a/src/vm/jit/optimizing/graph.h +++ b/src/vm/jit/optimizing/graph.h @@ -1,9 +1,7 @@ /* src/vm/jit/optimizing/graph.h - control flow graph header - Copyright (C) 2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien + Copyright (C) 2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,17 +20,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Ullrich - - */ #ifndef _LSRA_GRAPH_H #define _LSRA_GRAPH_H +#include "config.h" + #include "vm/jit/optimizing/lsra.h" #if !defined(NDEBUG) @@ -77,6 +72,11 @@ typedef struct graph_element graph_element; typedef graph_element *graphiterator; /* function prototypes */ + +#ifdef __cplusplus +extern "C" { +#endif + void transform_BB(jitdata *, graphdata *gd); graphdata *graph_init(int basicblockcount); /* Generate the CFG */ @@ -90,6 +90,9 @@ int graph_get_num_successor(graphdata *gd, int b_index); bool graph_has_multiple_successors( graphdata *gd, int b_index); bool graph_has_multiple_predecessors( graphdata *gd, int b_index); +#ifdef __cplusplus +} +#endif #endif /* _LSRA_GRAPH_H */ diff --git a/src/vm/jit/optimizing/ifconv.c b/src/vm/jit/optimizing/ifconv.c index bfaef14a7..ca31ee84e 100644 --- a/src/vm/jit/optimizing/ifconv.c +++ b/src/vm/jit/optimizing/ifconv.c @@ -1,9 +1,7 @@ -/* src/vm/jit/ifconv/ifconv.c - if-conversion +/* src/vm/jit/optimizing/ifconv.c - if-conversion - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -31,15 +29,14 @@ #include "vm/types.h" -#include "vm/vm.h" +#include "vm/method.h" +#include "vm/vm.hpp" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/reg.h" #include "vm/jit/show.h" -#include "vmcore/method.h" - /* patterns for a total number of 3 instructions ******************************/ diff --git a/src/vm/jit/optimizing/ifconv.h b/src/vm/jit/optimizing/ifconv.h index 3fe01878d..92c32f6c4 100644 --- a/src/vm/jit/optimizing/ifconv.h +++ b/src/vm/jit/optimizing/ifconv.h @@ -1,9 +1,7 @@ /* src/vm/jit/optimizing/ifconv.h - if-conversion - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -29,19 +27,24 @@ #define _IFCONV_H #include "config.h" -#include "vm/types.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/reg.h" +#include -#include "vmcore/method.h" +#include "vm/jit/jit.hpp" /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool ifconv_static(jitdata *jd); +#ifdef __cplusplus +} +#endif + #endif /* _IFCONV_H */ diff --git a/src/vm/jit/optimizing/lifetimes.c b/src/vm/jit/optimizing/lifetimes.c index 54b9732d4..d8f8d349f 100644 --- a/src/vm/jit/optimizing/lifetimes.c +++ b/src/vm/jit/optimizing/lifetimes.c @@ -1,4 +1,4 @@ -/* src/vm/jit/lsra.inc - lifetime anaylsis +/* src/vm/jit/optimizing/lifetimes.c - lifetime anaylsis Copyright (C) 2005, 2006, 2008 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO @@ -23,6 +23,8 @@ */ +#include "config.h" + #include #include @@ -31,12 +33,12 @@ #include "toolbox/bitvector.h" #include "toolbox/worklist.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "vm/resolve.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" +#include "vm/exceptions.hpp" +#include "vm/string.hpp" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/optimizing/graph.h" #include "vm/jit/optimizing/lsra.h" @@ -44,7 +46,7 @@ #include "vm/jit/optimizing/lifetimes.h" #ifdef LT_DEBUG_VERBOSE -#include "vmcore/options.h" +#include "vm/options.h" #endif #include diff --git a/src/vm/jit/optimizing/lifetimes.h b/src/vm/jit/optimizing/lifetimes.h index 08f4ae6ca..94655cf97 100644 --- a/src/vm/jit/optimizing/lifetimes.h +++ b/src/vm/jit/optimizing/lifetimes.h @@ -26,7 +26,9 @@ #ifndef _LIFETIMES_H #define _LIFETIMES_H -#include "vm/jit/optimizing/dominators.h" +#include "config.h" + +#include "vm/jit/optimizing/dominators.hpp" #if !defined(NDEBUG) # include diff --git a/src/vm/jit/optimizing/lsra.c b/src/vm/jit/optimizing/lsra.c index 3b2006772..be33abe5f 100644 --- a/src/vm/jit/optimizing/lsra.c +++ b/src/vm/jit/optimizing/lsra.c @@ -35,13 +35,13 @@ #include "toolbox/bitvector.h" -#include "vmcore/statistics.h" -#include "vmcore/options.h" -#include "vmcore/method.h" +#include "vm/statistics.h" +#include "vm/options.h" +#include "vm/method.h" #include "vm/jit/abi.h" #include "vm/jit/reg.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/optimizing/graph.h" #include "vm/jit/optimizing/lifetimes.h" diff --git a/src/vm/jit/optimizing/profile.c b/src/vm/jit/optimizing/profile.c index 319b2289a..541c019e8 100644 --- a/src/vm/jit/optimizing/profile.c +++ b/src/vm/jit/optimizing/profile.c @@ -33,22 +33,21 @@ #include "mm/memory.h" #include "threads/threadlist.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/stringlocal.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/classcache.h" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/string.hpp" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/methodheader.h" #include "vm/jit/methodtree.h" #include "vm/jit/optimizing/recompile.h" -#include "vmcore/class.h" -#include "vmcore/classcache.h" -#include "vmcore/method.h" -#include "vmcore/options.h" - /* profile_init **************************************************************** diff --git a/src/vm/jit/optimizing/profile.h b/src/vm/jit/optimizing/profile.h index a88c1b611..a235afacd 100644 --- a/src/vm/jit/optimizing/profile.h +++ b/src/vm/jit/optimizing/profile.h @@ -1,9 +1,7 @@ -/* src/vm/jit/profile.h - runtime profiling +/* src/vm/jit/optimizing/profile.h - runtime profiling - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -35,6 +27,11 @@ #define _PROFILE_H #include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/types.h" #include "vm/global.h" @@ -49,6 +46,10 @@ bool profile_start_thread(void); void profile_printstats(void); #endif +#ifdef __cplusplus +} +#endif + #endif /* _PROFILE_H */ diff --git a/src/vm/jit/optimizing/recompile.c b/src/vm/jit/optimizing/recompile.c index aa6198913..19809bfe4 100644 --- a/src/vm/jit/optimizing/recompile.c +++ b/src/vm/jit/optimizing/recompile.c @@ -32,28 +32,29 @@ #include "mm/memory.h" -#include "threads/lock-common.h" -#include "threads/thread.h" +#include "threads/condition.hpp" +#include "threads/mutex.hpp" +#include "threads/thread.hpp" #include "toolbox/list.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" +#include "vm/jit/builtin.hpp" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/options.h" +#include "vm/string.hpp" -#include "vm/jit/code.h" -#include "vm/jit/jit.h" +#include "vm/jit/code.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/optimizing/recompile.h" -#include "vmcore/classcache.h" -#include "vmcore/options.h" - /* global variables ***********************************************************/ -static java_object_t *lock_thread_recompile; -static list_t *list_recompile_methods; +static Mutex *recompile_thread_mutex; +static Condition *recompile_thread_cond; +static list_t *list_recompile_methods; /* recompile_init ************************************************************** @@ -66,11 +67,10 @@ bool recompile_init(void) { TRACESUBSYSTEMINITIALIZATION("recompile_init"); - /* initialize the recompile lock object */ - - lock_thread_recompile = NEW(java_object_t); + /* initialize the recompile thread mutex and condition */ - LOCK_INIT_OBJECT_LOCK(lock_thread_recompile); + recompile_thread_mutex = Mutex_new(); + recompile_thread_cond = Condition_new(); /* create method list */ @@ -163,17 +163,17 @@ static void recompile_thread(void) list_method_entry *lme; while (true) { - /* get the lock on the recompile lock object, so we can call wait */ + /* get the lock on the recompile mutex, so we can call wait */ - LOCK_MONITOR_ENTER(lock_thread_recompile); + Mutex_lock(recompile_thread_mutex); - /* wait forever on that object till we are signaled */ - - LOCK_WAIT_FOREVER(lock_thread_recompile); + /* wait forever on that condition till we are signaled */ + + Condition_wait(recompile_thread_cond, recompile_thread_mutex); /* leave the lock */ - LOCK_MONITOR_EXIT(lock_thread_recompile); + Mutex_unlock(recompile_thread_mutex); /* get the next method and recompile it */ @@ -244,17 +244,17 @@ void recompile_queue_method(methodinfo *m) list_add_last(list_recompile_methods, lme); - /* get the lock on the recompile lock object, so we can call notify */ + /* get the lock on the recompile mutex, so we can call notify */ - LOCK_MONITOR_ENTER(lock_thread_recompile); + Mutex_lock(recompile_thread_mutex); /* signal the recompiler thread */ - - LOCK_NOTIFY(lock_thread_recompile); + + Condition_signal(recompile_thread_cond); /* leave the lock */ - LOCK_MONITOR_EXIT(lock_thread_recompile); + Mutex_unlock(recompile_thread_mutex); } diff --git a/src/vm/jit/optimizing/recompile.h b/src/vm/jit/optimizing/recompile.h index ca71ac98c..42e53a6ad 100644 --- a/src/vm/jit/optimizing/recompile.h +++ b/src/vm/jit/optimizing/recompile.h @@ -1,9 +1,7 @@ /* src/vm/jit/optimizing/recompile.h - recompilation system - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -29,6 +27,11 @@ #define _RECOMPILE_H #include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + #include "vm/types.h" #include "vm/global.h" @@ -51,7 +54,11 @@ bool recompile_start_thread(void); void recompile_queue_method(methodinfo *m); -#endif /* _PROFILE_H */ +#ifdef __cplusplus +} +#endif + +#endif /* _RECOMPILE_H */ /* diff --git a/src/vm/jit/optimizing/reorder.c b/src/vm/jit/optimizing/reorder.c index bd43c3685..2b135943f 100644 --- a/src/vm/jit/optimizing/reorder.c +++ b/src/vm/jit/optimizing/reorder.c @@ -38,7 +38,7 @@ #include "vm/types.h" #include "mm/memory.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* reorder_place_next_unplaced_block ******************************************* diff --git a/src/vm/jit/optimizing/reorder.h b/src/vm/jit/optimizing/reorder.h index d76b46351..fccc8e77e 100644 --- a/src/vm/jit/optimizing/reorder.h +++ b/src/vm/jit/optimizing/reorder.h @@ -1,9 +1,7 @@ -/* src/vm/reorder.h - basic block reordering +/* src/vm/optimizing/reorder.h - basic block reordering - Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -35,15 +27,24 @@ #define _REORDER_H #include "config.h" -#include "vm/types.h" -#include "vm/jit/jit.h" +#include + +#include "vm/jit/jit.hpp" /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool reorder(jitdata *jd); +#ifdef __cplusplus +} +#endif + #endif /* _REORDER_H */ diff --git a/src/vm/jit/optimizing/ssa.c b/src/vm/jit/optimizing/ssa.c index 721323e4b..357f323f6 100644 --- a/src/vm/jit/optimizing/ssa.c +++ b/src/vm/jit/optimizing/ssa.c @@ -33,13 +33,13 @@ #include "toolbox/bitvector.h" #include "toolbox/worklist.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" -#include "vm/jit/jit.h" /* icmd_table */ +#include "vm/jit/jit.hpp" /* icmd_table */ #include "vm/jit/ir/bytecode.h" -#include "vm/jit/optimizing/dominators.h" +#include "vm/jit/optimizing/dominators.hpp" #include "vm/jit/optimizing/graph.h" #include "vm/jit/optimizing/lifetimes.h" #include "vm/jit/optimizing/lsra.h" @@ -51,7 +51,7 @@ #include "vm/jit/python.h" #if defined(SSA_DEBUG_VERBOSE) -#include "vmcore/options.h" /* compileverbose */ +#include "vm/options.h" /* compileverbose */ #endif /* function prototypes */ @@ -133,6 +133,7 @@ void ssa(jitdata *jd) { yssa(jd); } /*pythonpass_run(jd, "foo", "after");*/ + cfg_remove_root(jd); return; ls = jd->ls; diff --git a/src/vm/jit/optimizing/ssa.h b/src/vm/jit/optimizing/ssa.h index 56ba88184..78b488ab1 100644 --- a/src/vm/jit/optimizing/ssa.h +++ b/src/vm/jit/optimizing/ssa.h @@ -1,9 +1,7 @@ /* src/vm/jit/optimizing/ssa.h - static single assignment form header - Copyright (C) 2005 - 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien + Copyright (C) 2005, 2006, 2007, 2008 + CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO This file is part of CACAO. @@ -19,14 +17,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Ullrich - - $Id: ssa.h$ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ @@ -34,6 +26,8 @@ #ifndef _SSA_H #define _SSA_H +#include "config.h" + #include "vm/jit/optimizing/graph.h" #if !defined(NDEBUG) @@ -51,9 +45,20 @@ #endif /* function prototypes */ + +#ifdef __cplusplus +extern "C" { +#endif + void ssa_init(jitdata *); void ssa(jitdata */* , graphdata **/); +void fix_exception_handlers(jitdata *jd); + +#ifdef __cplusplus +} +#endif + #endif /* _SSA_H */ /* diff --git a/src/vm/jit/optimizing/ssa2.c b/src/vm/jit/optimizing/ssa2.c index 024677742..ad1038a85 100644 --- a/src/vm/jit/optimizing/ssa2.c +++ b/src/vm/jit/optimizing/ssa2.c @@ -33,7 +33,7 @@ #include "toolbox/worklist.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #if 1 #define printf(...) do { if (getenv("VERB")) printf(__VA_ARGS__); } while (0) diff --git a/src/vm/jit/optimizing/ssa3.c b/src/vm/jit/optimizing/ssa3.c index 0f8c1306d..5a8da53d0 100644 --- a/src/vm/jit/optimizing/ssa3.c +++ b/src/vm/jit/optimizing/ssa3.c @@ -1,4 +1,4 @@ -/* src/vm/optimizing/ssa3.c +/* src/vm/jit/optimizing/ssa3.c Copyright (C) 2008 CACAOVM - Verein zu Foerderung der freien virtuellen Machine CACAO @@ -38,19 +38,22 @@ * Unify access to phi args. */ -#include "vm/jit/jit.h" + +#include "config.h" + +#include "vm/jit/jit.hpp" #include "vm/global.h" #include "mm/memory.h" -#include "mm/dumpmemory.h" +#include "mm/dumpmemory.hpp" #include "toolbox/list.h" #include #include -#define ELIMINATE_NOP_LOAD_STORE +/*#define ELIMINATE_NOP_LOAD_STORE*/ #define FIXME(x) x #define SSA_VERIFY -/* #define SSA_VERBOSE */ +/*#define SSA_VERBOSE */ /* __attribute__((always_inline)) @@ -345,8 +348,8 @@ static inline void instruction_set_uses(instruction *iptr, s4 *buf, s4 *uses, un /*** vars *******************************************************************/ -#define VARS_CATEGORY_SHIFT 29 -#define VARS_INDEX_MASK 0x1FFFFFFF +#define VARS_CATEGORY_SHIFT 28 +#define VARS_INDEX_MASK 0x0FFFFFFF #define VARS_CATEGORY_LOCAL 0 #define VARS_CATEGORY_STACK 1 @@ -354,8 +357,15 @@ static inline void instruction_set_uses(instruction *iptr, s4 *buf, s4 *uses, un #define VAR_TYPE_SUBSTITUED 666 +#define OLD_INDEX_UNUSED -2 + typedef struct { - varinfo items[9000]; /* XXX hardcoded max */ + varinfo v; + s4 old_index; +} vars_item_t; + +typedef struct { + vars_item_t items[9000]; /* XXX hardcoded max */ unsigned max; unsigned count; unsigned category; @@ -365,7 +375,8 @@ static inline unsigned vars_add_item(vars_t *vs, const varinfo *item) { unsigned i = vs->count; assert(i < vs->max); vs->count += 1; - vs->items[i] = *item; + vs->items[i].v = *item; + vs->items[i].old_index = OLD_INDEX_UNUSED; return (vs->category << VARS_CATEGORY_SHIFT) | i; } @@ -378,7 +389,7 @@ static inline unsigned vars_add(vars_t *vs) { static inline varinfo *vars_back(vars_t *vs) { assert(vs->count > 0); - return vs->items + (vs->count - 1); + return &(vs->items[vs->count - 1].v); } static inline void vars_init(vars_t *vs, unsigned category) { @@ -400,8 +411,8 @@ static void vars_subst(vars_t *vs, unsigned varindex, unsigned replacementindex) varindex = vars_get_index(varindex); replacementindex = vars_get_index(replacementindex); - vs->items[varindex].type = VAR_TYPE_SUBSTITUED; - vs->items[varindex].vv.regoff = replacementindex; + vs->items[varindex].v.type = VAR_TYPE_SUBSTITUED; + vs->items[varindex].v.vv.ii[1] = replacementindex; } static unsigned vars_resolve_subst(const vars_t *vs, unsigned varindex) { @@ -410,36 +421,80 @@ static unsigned vars_resolve_subst(const vars_t *vs, unsigned varindex) { #endif varindex = vars_get_index(varindex); - if (vs->items[varindex].type == VAR_TYPE_SUBSTITUED) /*fprintf(stderr, "*")*/; + if (vs->items[varindex].v.type == VAR_TYPE_SUBSTITUED) /*fprintf(stderr, "*")*/; - while (vs->items[varindex].type == VAR_TYPE_SUBSTITUED) { + while (vs->items[varindex].v.type == VAR_TYPE_SUBSTITUED) { assert(loop_ctr++ != vs->count); - varindex = vs->items[varindex].vv.regoff; + varindex = vs->items[varindex].v.vv.ii[1]; } return (vs->category << VARS_CATEGORY_SHIFT) | varindex ; } static void vars_copy_to_final(vars_t *vs, varinfo *dst) { - const varinfo *it; + const vars_item_t *it; unsigned subst; for (it = vs->items; it != vs->items + vs->count; ++it, ++dst) { /* Copy variable. */ - *dst = *it; + *dst = it->v; /* Eliminate VAR_TYPE_SUBSTITUED as it leads to problems. */ if (dst->type == VAR_TYPE_SUBSTITUED) { subst = vars_get_index(vars_resolve_subst(vs, it - vs->items)); - dst->type = vs->items[subst].type; + dst->type = vs->items[subst].v.type; } } } +static void vars_import(vars_t *vs, varinfo *v, unsigned count, s4 old_index) { + vars_item_t *it; + + assert((vs->count + count) <= vs->max); + + it = vs->items + vs->count; + vs->count += count; + + while (count-- > 0) { + it->v = *v; + it->old_index = old_index; + it += 1; + v += 1; + old_index += 1; + } +} + +static inline void vars_record_old_index(vars_t *vs, unsigned varindex, s4 old_index) { + vars_item_t *item; + varindex = vars_get_index(varindex); + + assert(varindex < vs->count); + + item = vs->items + varindex; + + assert( + item->old_index == OLD_INDEX_UNUSED || + item->old_index == old_index + ); + + item->old_index = old_index; +} + +static inline s4 vars_get_old_index(vars_t *vs, unsigned varindex) { + s4 old; + + varindex = vars_get_index(varindex); + + assert(varindex < vs->count); + old = vs->items[varindex].old_index; + assert(old != OLD_INDEX_UNUSED); + + return old; +} /*** phis *******************************************************************/ @@ -486,13 +541,15 @@ FIXME() inline void phis_print(const phis_t *ps) { } #endif -static inline void phis_copy_to(const phis_t *ps, instruction *dst) { - MCOPY( - dst, - ps->items, - instruction, - ps->count - ); +static inline unsigned phis_copy_to(const phis_t *ps, instruction *dst) { + instruction *it; + instruction *out = dst; + + FOR_EACH_PHI_FUNCTION(ps, it) { + *(out++) = *it; + } + + return (out - dst); } /*** state_array ************************************************************/ @@ -680,31 +737,41 @@ instruction *traversal_create_phi(traversal_t *t, vars_t *v, unsigned argcount, state_array_set(t->state_array, index, phi); + vars_record_old_index(v, phi->dst.varindex, index); + return phi; } static void traversal_rename_def(traversal_t *t, vars_t *vars, instruction *iptr) { const varinfo *v; unsigned index; + s4 old; state_array_assert_items(t->state_array); v = t->ops->var_num_to_varinfo(t->ops_vp, iptr->dst.varindex); index = t->ops->var_num_to_index(t->ops_vp, iptr->dst.varindex); + old = iptr->dst.varindex; iptr->dst.varindex = vars_add_item(vars, v); state_array_set(t->state_array, index, iptr); + + vars_record_old_index(vars, iptr->dst.varindex, index); } -static void traversal_rename_use(traversal_t *t, s4 *puse) { +static void traversal_rename_use(traversal_t *t, vars_t *vars, s4 *puse) { unsigned index; + s4 old; state_array_assert_items(t->state_array); index = t->ops->var_num_to_index(t->ops_vp, *puse); assert(state_array_get(t->state_array, index)); + old = *puse; *puse = state_array_get_var(t->state_array, index); + + vars_record_old_index(vars, *puse, index); } static inline unsigned traversal_variables_count(traversal_t *t) { @@ -862,6 +929,18 @@ typedef struct ssa_info { basicblock_chain_t *new_blocks; + struct { + s4 maxlocals; + s4 maxinterfaces; + s4 *local_map; + varinfo *var; + s4 vartop; + s4 varcount; + s4 localcount; + } original; + + unsigned keep_in_out:1; + } ssa_info, ssa_info_t; void ssa_info_init(ssa_info_t *ssa, jitdata *jd) { @@ -871,8 +950,7 @@ void ssa_info_init(ssa_info_t *ssa, jitdata *jd) { vars_init(ssa->locals, VARS_CATEGORY_LOCAL); /* Initialize first version of locals, that is always available. */ - MCOPY(ssa->locals->items, jd->var, varinfo, jd->localcount); - ssa->locals->count = jd->localcount; + vars_import(ssa->locals, jd->var, jd->localcount, 0); ssa->stack = DNEW(vars_t); vars_init(ssa->stack, VARS_CATEGORY_STACK); @@ -882,16 +960,26 @@ void ssa_info_init(ssa_info_t *ssa, jitdata *jd) { ssa->new_blocks = DNEW(basicblock_chain_t); basicblock_chain_init(ssa->new_blocks); + + ssa->original.maxlocals = jd->maxlocals; + ssa->original.maxinterfaces = jd->maxinterfaces; + ssa->original.local_map = jd->local_map; + ssa->original.var = jd->var; + ssa->original.vartop = jd->vartop; + ssa->original.varcount = jd->varcount; + ssa->original.localcount = jd->localcount; + + ssa->keep_in_out = false; } /*** others_mapping *********************************************************/ static inline void others_mapping_set(ssa_info *ssa, s4 var, s4 new_var) { - ssa->jd->var[var].vv.regoff = new_var; + ssa->jd->var[var].vv.ii[1] = new_var; } static inline s4 others_mapping_get(const ssa_info *ssa, s4 var) { - return ssa->jd->var[var].vv.regoff; + return ssa->jd->var[var].vv.ii[1]; } /*** code *******************************************************************/ @@ -907,6 +995,8 @@ void fix_exception_handlers(jitdata *jd) { basicblock_chain_t chain; basicblock *last = NULL; basicblock *marker = NULL; + s4 vartop; + unsigned i; if (jd->exceptiontablelength == 0) { return; @@ -914,22 +1004,38 @@ void fix_exception_handlers(jitdata *jd) { basicblock_chain_init(&chain); - /* We need to allocate new iovars */ - - avail_vars = (jd->varcount - jd->vartop); - add_vars = jd->exceptiontablelength; + /* Remember, where we started adding IO variables. */ - if (add_vars > avail_vars) { - add_vars -= avail_vars; - jd->var = DMREALLOC(jd->var, varinfo, jd->varcount, jd->varcount + add_vars); - jd->varcount += add_vars; - } + vartop = jd->vartop; /* For each exception handler block, create one block with a prologue block */ FOR_EACH_BASICBLOCK(jd, bptr) { if (bptr->type == BBTYPE_EXH) { + /* + + +---- EXH (exh)-------+ + | in0 in1 in2 exc | + | ..... | + +---------------------+ + + === TRANSFORMED TO ===> + + +---- PROL (exh) -------+ + | in0 in1 in2 | + | GETEXECEPTION => OU3 | + | GOTO REAL_EXH | + | in0 in1 in2 OU3 | + +-----------------------+ + + +---- REAL_EXH (std) -+ + | in0 in1 in2 exc | + | ...... | + +---------------------+ + + */ + bptr->type = BBTYPE_STD; bptr->predecessorcount = 0; /* legacy */ @@ -940,7 +1046,24 @@ void fix_exception_handlers(jitdata *jd) { iptr = DMNEW(instruction, 2); MZERO(iptr, instruction, 2); + + /* Create outvars */ + + exh->outdepth = bptr->indepth; + if (exh->outdepth > 0) { + exh->outvars = DMNEW(s4, exh->outdepth); + for (i = 0; i < exh->outdepth; ++i) { + exh->outvars[i] = vartop++; + } + } + + /* Create invars */ + + exh->indepth = exh->outdepth - 1; + exh->invars = exh->outvars; + +#if 0 /* Create new outvar */ assert(jd->vartop < jd->varcount); @@ -948,6 +1071,7 @@ void fix_exception_handlers(jitdata *jd) { jd->vartop += 1; jd->var[v].type = TYPE_ADR; jd->var[v].flags = INOUT; +#endif exh->nr = jd->basicblockcount; jd->basicblockcount += 1; @@ -955,9 +1079,11 @@ void fix_exception_handlers(jitdata *jd) { exh->type = BBTYPE_EXH; exh->icount = 2; exh->iinstr = iptr; +/* exh->outdepth = 1; exh->outvars = DNEW(s4); exh->outvars[0] = v; +*/ exh->predecessorcount = -1; /* legacy */ exh->flags = BBFINISHED; exh->method = jd->m; @@ -967,7 +1093,7 @@ void fix_exception_handlers(jitdata *jd) { /* Get exception */ iptr->opc = ICMD_GETEXCEPTION; - iptr->dst.varindex = v; + iptr->dst.varindex = exh->outvars[exh->outdepth - 1]; iptr += 1; /* Goto real exception handler */ @@ -986,6 +1112,19 @@ void fix_exception_handlers(jitdata *jd) { } } + /* We need to allocate the new iovars in the var array */ + + avail_vars = (jd->varcount - jd->vartop); + add_vars = (vartop - jd->vartop); + + if (add_vars > avail_vars) { + add_vars -= avail_vars; + jd->var = DMREALLOC(jd->var, varinfo, jd->varcount, jd->varcount + add_vars); + jd->varcount += add_vars; + } + + jd->vartop = vartop; + /* Put the chain of exception handlers between just before the last basic block (end marker). */ @@ -1003,9 +1142,68 @@ void fix_exception_handlers(jitdata *jd) { for (ee = jd->exceptiontable; ee; ee = ee->down) { assert(ee->handler->vp); - ee->handler = ee->handler->vp; + + bptr = ee->handler; + exh = (basicblock *)ee->handler->vp; + + ee->handler = exh; + + /* Set up IO variables in newly craeted exception handlers. */ + + for (i = 0; i < exh->outdepth; ++i) { + v = exh->outvars[i]; + + jd->var[v].flags = INOUT; + jd->var[v].type = jd->var[ bptr->invars[i] ].type; + } + } + +} + +void unfix_exception_handlers(jitdata *jd) { + basicblock *bptr, *exh; + unsigned i; + exception_entry *ee; +#if !defined(NDEBUG) + bool found = false; +#endif + + FOR_EACH_BASICBLOCK(jd, bptr) { + if (bptr->type == BBTYPE_EXH) { + assert(bptr->iinstr[1].opc == ICMD_GOTO); + exh = bptr->iinstr[1].dst.block; + + bptr->type = BBDELETED; + bptr->icount = 0; + bptr->indepth = 0; + bptr->outdepth = 0; + exh->type = BBTYPE_EXH; + bptr->vp = exh; + + /* bptr is no more a predecessor of exh */ + + for (i = 0; i < exh->predecessorcount; ++i) { + if (exh->predecessors[i] == bptr) { + exh->predecessors[i] = exh->predecessors[exh->predecessorcount - 1]; + exh->predecessorcount -= 1; +#if !defined(NDEBUG) + found = true; +#endif + break; + } + } + + assert(found); + + } else { + bptr->vp = NULL; + } } + for (ee = jd->exceptiontable; ee; ee = ee->down) { + assert(ee->handler->vp); + ee->handler = ee->handler->vp; + } } /*** ssa_enter ***************************************************************/ @@ -1119,6 +1317,10 @@ static void ssa_enter_verify_no_redundant_phis(ssa_info_t *ssa) { basicblock *bptr; basicblock_info_t *bbi; instruction *itph; + + /* XXX */ + return; + FOR_EACH_BASICBLOCK(ssa->jd, bptr) { if (basicblock_reached(bptr)) { bbi = bb_info(bptr); @@ -1241,6 +1443,14 @@ static void ssa_enter_process_pei(ssa_info *ssa, basicblock *bb, unsigned pei) { basicblock_get_ex_predecessor_index(bb, pei, *itsucc), ssa->locals ); + + ssa_enter_merge( + bbi->stack, + succi->stack, + *itsucc, + basicblock_get_ex_predecessor_index(bb, pei, *itsucc), + ssa->stack + ); } } @@ -1249,6 +1459,9 @@ static FIXME(bool) ssa_enter_eliminate_redundant_phis(traversal_t *t, vars_t *vs instruction *itph; bool ret = false; + /* XXX */ + return; + FOR_EACH_PHI_FUNCTION(t->phis, itph) { phi_calculate_redundancy(itph); @@ -1346,23 +1559,33 @@ static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) { state_array_allocate_items(bbi->stack->state_array); } +#if 0 /* Exception handlers have a clean stack. */ + /* Not true with inlining. */ + if (bb->type == BBTYPE_EXH) { state_array_assert_no_items(bbi->stack->state_array); state_array_allocate_items(bbi->stack->state_array); } +#endif /* Some in/out vars get marked as INOUT in simplereg, and are not marked at this point. Mark them manually. */ for (ituse = bb->invars; ituse != bb->invars + bb->indepth; ++ituse) { + if (ssa->keep_in_out && ssa->jd->var[*ituse].type == TYPE_RET) { + continue; + } ssa->jd->var[*ituse].flags |= INOUT; ssa->jd->var[*ituse].flags &= ~PREALLOC; } for (ituse = bb->outvars; ituse != bb->outvars + bb->outdepth; ++ituse) { + if (ssa->keep_in_out && ssa->jd->var[*ituse].type == TYPE_RET) { + continue; + } ssa->jd->var[*ituse].flags |= INOUT; ssa->jd->var[*ituse].flags &= ~PREALLOC; } @@ -1404,11 +1627,13 @@ static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) { if (var_is_local(ssa->jd, *ituse)) { traversal_rename_use( bbi->locals, + ssa->locals, ituse ); } else if (var_is_inout(ssa->jd, *ituse)) { traversal_rename_use( bbi->stack, + ssa->stack, ituse ); } else { @@ -1437,6 +1662,7 @@ static void ssa_enter_process_block(ssa_info *ssa, basicblock *bb) { ssa->others, ssa->jd->var + iptr->dst.varindex ); + vars_record_old_index(ssa->others, iptr->dst.varindex, old); others_mapping_set(ssa, old, iptr->dst.varindex); } } @@ -1456,6 +1682,7 @@ static void ssa_enter_export_variables(ssa_info *ssa) { s4 *it; unsigned i, j; jitdata *jd = ssa->jd; + s4 *local_map; vartop = ssa->locals->count + ssa->stack->count + ssa->others->count; vars = DMNEW(varinfo, vartop); @@ -1470,13 +1697,15 @@ static void ssa_enter_export_variables(ssa_info *ssa) { /* Grow local map to accomodate all new locals and iovars. But keep the local map for version 1 of locals, that contains the holes. */ - jd->local_map = DMREALLOC( - jd->local_map, - s4, - 5 * jd->maxlocals, + local_map = DMNEW( + s4, 5 * (jd->maxlocals + ssa->locals->count + ssa->stack->count - jd->localcount) ); + MCOPY(local_map, jd->local_map, s4, 5 * jd->maxlocals); + + jd->local_map = local_map; + it = jd->local_map + (jd->maxlocals * 5); /* start adding entries here */ /* Add version > 1 of all locals */ @@ -1524,19 +1753,15 @@ static void ssa_enter_export_phis(ssa_info_t *ssa) { FOR_EACH_BASICBLOCK(ssa->jd, bptr) { bbi = bb_info(bptr); if (bbi != NULL) { - bptr->phicount = - bbi->locals->phis->count + - bbi->stack->phis->count; - - bptr->phis = DMNEW(instruction, bptr->phicount); + bptr->phis = DMNEW(instruction, bbi->locals->phis->count + bbi->stack->phis->count); dst = bptr->phis; - phis_copy_to(bbi->locals->phis, dst); + dst += phis_copy_to(bbi->locals->phis, dst); - dst += bbi->locals->phis->count; + dst += phis_copy_to(bbi->stack->phis, dst); - phis_copy_to(bbi->stack->phis, dst); + bptr->phicount = dst - bptr->phis; } } } @@ -1569,8 +1794,10 @@ void ssa_enter_eliminate_categories(ssa_info_t *ssa) { bbi = bb_info(bb); - bb->indepth = 0; - bb->outdepth = 0; + if (! ssa->keep_in_out) { + bb->indepth = 0; + bb->outdepth = 0; + } if (bbi != NULL) { FOR_EACH_PHI_FUNCTION(bbi->locals->phis, itph) { @@ -2055,20 +2282,115 @@ static void ssa_leave_create_exceptional_phi_moves(ssa_info *ssa) { } } +void ssa_simple_leave_restore(ssa_info_t *ssa, basicblock *bptr, s4 *pvar) { + s4 var = *pvar; + s4 index; + basicblock_info_t *bbi; + + if (var < ssa->locals->count) { + *pvar = vars_get_old_index(ssa->locals, var); + } else if (var < ssa->locals->count + ssa->stack->count) { + + index = vars_get_old_index( + ssa->stack, + var - ssa->locals->count + ); + + bbi = bb_info(bptr); + + /* We have to determine whether to take an invar or an outvar for + the stack depth ``index''. + The state array contains the last definition of the stack element + at the given depth. + */ + + if (state_array_get_var(bbi->stack->state_array, index) == var) { + /* The last definition of a stack depth inside the basicblock. + This is the outvar at the given depth. + If there is no outvar at the given depth, it must be an invar. + */ + if (index < bptr->outdepth) { + *pvar = bptr->outvars[index]; + } else if (index < bptr->indepth) { + *pvar = bptr->invars[index]; + } else { + assert(0); + } + } else { + /* A different than the last definition of a stack depth. + This must be an invar. + */ + assert(index < bptr->indepth); + *pvar = bptr->invars[index]; + } + } else { + *pvar = vars_get_old_index( + ssa->others, + var - ssa->locals->count - ssa->stack->count + ); + } +} + +void ssa_simple_leave(ssa_info_t *ssa) { + basicblock *bptr; + instruction *iptr; + s4 *ituse, *uses; + unsigned uses_count; + + FOR_EACH_BASICBLOCK(ssa->jd, bptr) { + if (bptr->type == BBTYPE_EXH) { + /* (Aritifical) exception handler blocks will be eliminated. */ + continue; + } + /* In reverse order. We need to rename the definition after any use! */ + FOR_EACH_INSTRUCTION_REV(bptr, iptr) { + if (instruction_has_dst(iptr)) { + ssa_simple_leave_restore(ssa, bptr, &(iptr->dst.varindex)); + } + instruction_get_uses(iptr, ssa->s_buf, &uses, &uses_count); + for (ituse = uses; ituse != uses + uses_count; ++ituse) { + ssa_simple_leave_restore(ssa, bptr, ituse); + } + instruction_set_uses(iptr, ssa->s_buf, uses, uses_count); + } + bptr->phicount = 0; + } + + unfix_exception_handlers(ssa->jd); + + ssa->jd->maxlocals = ssa->original.maxlocals; + ssa->jd->maxinterfaces = ssa->original.maxinterfaces; + ssa->jd->local_map =ssa->original.local_map; + ssa->jd->var = ssa->original.var; + ssa->jd->vartop = ssa->original.vartop; + ssa->jd->varcount = ssa->original.varcount; + ssa->jd->localcount = ssa->original.localcount; +} + +#include "vm/rt-timing.h" + void yssa(jitdata *jd) { basicblock *it; basicblock_info_t *iti; ssa_info *ssa; + struct timespec bs, es, be, ee; + + RT_TIMING_GET_TIME(bs); + #ifdef SSA_VERBOSE - printf("=============== [ before %s ] =========================\n", jd->m->name->text); - show_method(jd, 3); - printf("=============== [ /before ] =========================\n"); + bool verb = true; + if (verb) { + printf("=============== [ before %s ] =========================\n", jd->m->name->text); + show_method(jd, 3); + printf("=============== [ /before ] =========================\n"); + } #endif ssa = DNEW(ssa_info); ssa_info_init(ssa, jd); + ssa->keep_in_out = true; FOR_EACH_BASICBLOCK(jd, it) { if (basicblock_reached(it)) { @@ -2094,18 +2416,38 @@ void yssa(jitdata *jd) { /*ssa_enter_create_phi_graph(ssa);*/ + RT_TIMING_GET_TIME(be); escape_analysis_perform(ssa->jd); + RT_TIMING_GET_TIME(ee); + /* ssa_leave_create_phi_moves(ssa); ssa_leave_create_exceptional_phi_moves(ssa); + */ + +#ifdef SSA_VERBOSE + if (verb) { + printf("=============== [ mid ] =========================\n"); + show_method(jd, 3); + printf("=============== [ /mid ] =========================\n"); + } +#endif + + ssa_simple_leave(ssa); #ifdef SSA_VERBOSE - printf("=============== [ after ] =========================\n"); - show_method(jd, 3); - printf("=============== [ /after ] =========================\n"); + if (verb) { + printf("=============== [ after ] =========================\n"); + show_method(jd, 3); + printf("=============== [ /after ] =========================\n"); + } #endif + RT_TIMING_GET_TIME(es); + + RT_TIMING_TIME_DIFF(bs, es, RT_TIMING_1); + RT_TIMING_TIME_DIFF(be, ee, RT_TIMING_2); } void eliminate_subbasicblocks(jitdata *jd) { diff --git a/src/vm/jit/optimizing/ssa_phi.c b/src/vm/jit/optimizing/ssa_phi.c index 9ab4f6c29..e79b1654d 100644 --- a/src/vm/jit/optimizing/ssa_phi.c +++ b/src/vm/jit/optimizing/ssa_phi.c @@ -1,9 +1,7 @@ /* src/vm/jit/optimizing/ssa.c - static single-assignment form - Copyright (C) 2005 - 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien + Copyright (C) 2005-2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,13 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - Contact: cacao@complang.tuwien.ac.at - - Authors: Christian Ullrich +*/ - $Id: $ -*/ +#include "config.h" #include #include @@ -38,11 +33,11 @@ #include "toolbox/bitvector.h" #include "toolbox/worklist.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" -#include "vm/jit/jit.h" /* icmd_table */ +#include "vm/jit/jit.hpp" /* icmd_table */ -#include "vm/jit/optimizing/dominators.h" +#include "vm/jit/optimizing/dominators.hpp" #include "vm/jit/optimizing/graph.h" #include "vm/jit/optimizing/lifetimes.h" #include "vm/jit/optimizing/lsra.h" @@ -50,7 +45,7 @@ #include "vm/jit/optimizing/ssa_phi.h" #if defined(SSA_DEBUG_VERBOSE) -#include "vmcore/options.h" /* compileverbose */ +#include "vm/options.h" /* compileverbose */ #endif /* ssa_place_phi_functions ***************************************************** diff --git a/src/vm/jit/optimizing/ssa_rename.c b/src/vm/jit/optimizing/ssa_rename.c index 474419c12..87fdd130f 100644 --- a/src/vm/jit/optimizing/ssa_rename.c +++ b/src/vm/jit/optimizing/ssa_rename.c @@ -33,11 +33,11 @@ #include "toolbox/bitvector.h" #include "toolbox/worklist.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" -#include "vm/jit/jit.h" /* icmd_table */ +#include "vm/jit/jit.hpp" /* icmd_table */ -#include "vm/jit/optimizing/dominators.h" +#include "vm/jit/optimizing/dominators.hpp" #include "vm/jit/optimizing/graph.h" #include "vm/jit/optimizing/lifetimes.h" #include "vm/jit/optimizing/lsra.h" @@ -45,7 +45,7 @@ #include "vm/jit/optimizing/ssa_rename.h" #if defined(SSA_DEBUG_VERBOSE) -#include "vmcore/options.h" /* compileverbose */ +#include "vm/options.h" /* compileverbose */ #endif /* function prototypes */ diff --git a/src/vm/jit/parisc/arch.h b/src/vm/jit/parisc/arch.h index 6b99040fb..c693d6ec5 100644 --- a/src/vm/jit/parisc/arch.h +++ b/src/vm/jit/parisc/arch.h @@ -1,9 +1,7 @@ /* src/vm/jit/parisc/arch.h - architecture defines for PA-RISC - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -95,8 +93,6 @@ #endif -#define USE_FAKE_ATOMIC_INSTRUCTIONS 1 - /* replacement ****************************************************************/ #define REPLACEMENT_PATCH_SIZE 4 /* bytes */ diff --git a/src/vm/jit/parse.c b/src/vm/jit/parse.c index db707e714..bd9d48f27 100644 --- a/src/vm/jit/parse.c +++ b/src/vm/jit/parse.c @@ -38,28 +38,28 @@ #include "toolbox/logging.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/resolve.h" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/string.hpp" +#include "vm/suck.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/parse.h" #include "vm/jit/loop/loop.h" #include "vm/jit/ir/bytecode.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vm/resolve.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#include "vmcore/suck.h" #define INSTRUCTIONS_INCREMENT 5 /* number of additional instructions to */ /* allocate if space runs out */ diff --git a/src/vm/jit/parse.h b/src/vm/jit/parse.h index 55917d6a2..b10d7dad5 100644 --- a/src/vm/jit/parse.h +++ b/src/vm/jit/parse.h @@ -1,9 +1,7 @@ /* src/vm/jit/parse.h - parser header - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,11 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Author: Christian Thalinger - Edwin Steiner - */ @@ -37,7 +30,7 @@ #include "vm/types.h" #include "vm/global.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" /* macros for verifier checks during parsing **********************************/ @@ -276,8 +269,16 @@ /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool parse(jitdata *jd); +#ifdef __cplusplus +} +#endif + #endif /* _PARSE_H */ diff --git a/src/vm/jit/patcher-common.c b/src/vm/jit/patcher-common.c deleted file mode 100644 index b3fbe3042..000000000 --- a/src/vm/jit/patcher-common.c +++ /dev/null @@ -1,498 +0,0 @@ -/* src/vm/jit/patcher-common.c - architecture independent code patching stuff - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "codegen.h" /* for PATCHER_NOPS */ -#include "md.h" - -#include "mm/memory.h" - -#include "native/native.h" - -#include "threads/lock-common.h" - -#include "toolbox/list.h" -#include "toolbox/logging.h" /* XXX remove me! */ - -#include "vm/exceptions.h" -#include "vm/initialize.h" -#include "vm/resolve.h" -#include "vm/vm.h" /* for vm_abort */ - -#include "vm/jit/code.h" -#include "vm/jit/disass.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" - -#include "vmcore/options.h" - - -/* patcher_function_list ******************************************************* - - This is a list which maps patcher function pointers to the according - names of the patcher functions. It is only usefull for debugging - purposes. - -*******************************************************************************/ - -#if !defined(NDEBUG) -typedef struct patcher_function_list_t { - functionptr patcher; - char *name; -} patcher_function_list_t; - -static patcher_function_list_t patcher_function_list[] = { - { PATCHER_initialize_class, "initialize_class" }, - { PATCHER_resolve_class, "resolve_class" }, - { PATCHER_resolve_native_function, "resolve_native_function" }, - { PATCHER_invokestatic_special, "invokestatic_special" }, - { PATCHER_invokevirtual, "invokevirtual" }, - { PATCHER_invokeinterface, "invokeinterface" }, - { NULL, "-UNKNOWN PATCHER FUNCTION-" } -}; -#endif - - -/* patcher_list_create ********************************************************* - - Creates an empty patcher list for the given codeinfo. - -*******************************************************************************/ - -void patcher_list_create(codeinfo *code) -{ - code->patchers = list_create(OFFSET(patchref_t, linkage)); -} - - -/* patcher_list_reset ********************************************************** - - Resets the patcher list inside a codeinfo. This is usefull when - resetting a codeinfo for recompiling. - -*******************************************************************************/ - -void patcher_list_reset(codeinfo *code) -{ - patchref_t *pr; - - /* free all elements of the list */ - - while((pr = list_first(code->patchers)) != NULL) { - list_remove(code->patchers, pr); - - FREE(pr, patchref_t); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_patchref -= sizeof(patchref_t); -#endif - } -} - -/* patcher_list_free *********************************************************** - - Frees the patcher list and all its entries for the given codeinfo. - -*******************************************************************************/ - -void patcher_list_free(codeinfo *code) -{ - /* free all elements of the list */ - - patcher_list_reset(code); - - /* free the list itself */ - - FREE(code->patchers, list_t); -} - - -/* patcher_list_find *********************************************************** - - Find an entry inside the patcher list for the given codeinfo - by specifying the program counter of the patcher position. - - NOTE: Caller should hold the patcher list lock or maintain - exclusive access otherwise. - -*******************************************************************************/ - -static patchref_t *patcher_list_find(codeinfo *code, u1 *pc) -{ - patchref_t *pr; - - /* walk through all patcher references for the given codeinfo */ - - pr = list_first(code->patchers); - - while (pr) { - -/*#define TRACE_PATCHER_FIND*/ -#ifdef TRACE_PATCHER_FIND - log_println("patcher_list_find: %p == %p", pr->mpc, pc); -#endif - - if (pr->mpc == (ptrint) pc) - return pr; - - pr = list_next(code->patchers, pr); - } - - return NULL; -} - - -/* patcher_add_patch_ref ******************************************************* - - Appends a new patcher reference to the list of patching positions. - -*******************************************************************************/ - -void patcher_add_patch_ref(jitdata *jd, functionptr patcher, voidptr ref, - s4 disp) -{ - codegendata *cd; - codeinfo *code; - patchref_t *pr; - s4 patchmpc; - - cd = jd->cd; - code = jd->code; - patchmpc = cd->mcodeptr - cd->mcodebase; - -#if !defined(NDEBUG) - if (patcher_list_find(code, (u1 *) (intptr_t) patchmpc) != NULL) - vm_abort("patcher_add_patch_ref: different patchers at same position."); -#endif - - /* allocate patchref on heap (at least freed together with codeinfo) */ - - pr = NEW(patchref_t); - list_add_first(code->patchers, pr); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_patchref += sizeof(patchref_t); -#endif - - /* set patcher information (mpc is resolved later) */ - - pr->mpc = patchmpc; - pr->disp = disp; - pr->patcher = patcher; - pr->ref = ref; - pr->mcode = 0; - pr->done = false; - - /* Generate NOPs for opt_shownops. */ - - if (opt_shownops) - PATCHER_NOPS; - -#if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__SPARC_64__) || defined(__X86_64__)) - - /* XXX We can remove that when we don't use UD2 anymore on i386 - and x86_64. */ - - /* On some architectures the patcher stub call instruction might - be longer than the actual instruction generated. On this - architectures we store the last patcher call position and after - the basic block code generation is completed, we check the - range and maybe generate some nop's. */ - /* The nops are generated in codegen_emit in each codegen */ - - cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE; -#endif -} - - -/** - * Resolve all patchers in the current JIT run. - * - * @param jd JIT data-structure - */ -void patcher_resolve(jitdata* jd) -{ - codeinfo* code; - patchref_t* pr; - - /* Get required compiler data. */ - - code = jd->code; - - for (pr = list_first(code->patchers); pr != NULL; pr = list_next(code->patchers, pr)) { - pr->mpc += (intptr_t) code->entrypoint; - pr->datap = (intptr_t) (pr->disp + code->entrypoint); - } -} - - -/* patcher_handler ************************************************************* - - Handles the request to patch JIT code at the given patching - position. This function is normally called by the signal - handler. - - NOTE: The patcher list lock is used to maintain exclusive - access of the patched position (in fact of the whole code). - After patching has suceeded, the patcher reference should be - removed from the patcher list to avoid double patching. - -*******************************************************************************/ - -#if !defined(NDEBUG) -/* XXX this indent is not thread safe! */ -/* XXX if you want it thread safe, place patcher_depth in threadobject! */ -static int patcher_depth = 0; -#define TRACE_PATCHER_INDENT for (i=0; ipatchers); - - /* search the patcher information for the given PC */ - - pr = patcher_list_find(code, pc); - - if (pr == NULL) - vm_abort("patcher_handler: Unable to find patcher reference."); - - if (pr->done) { -#if !defined(NDEBUG) - if (opt_DebugPatcher) { - log_println("patcher_handler: double-patching detected!"); - } -#endif - LOCK_MONITOR_EXIT(code->patchers); - return NULL; - } - -#if !defined(NDEBUG) - if (opt_DebugPatcher) { - for (l = patcher_function_list; l->patcher != NULL; l++) - if (l->patcher == pr->patcher) - break; - - TRACE_PATCHER_INDENT; printf("patching in "); method_print(code->m); printf(" at %p\n", (void *) pr->mpc); - TRACE_PATCHER_INDENT; printf("\tpatcher function = %s <%p>\n", l->name, (void *) (intptr_t) pr->patcher); - - TRACE_PATCHER_INDENT; - printf("\tmachine code before = "); - -# if defined(ENABLE_DISASSEMBLER) - disassinstr((void *) pr->mpc); -# else - printf("disassembler disabled\n"); -# endif - - patcher_depth++; - assert(patcher_depth > 0); - } -#endif - - /* cast the passed function to a patcher function */ - - patcher_function = (bool (*)(patchref_t *)) (ptrint) pr->patcher; - - /* call the proper patcher function */ - - result = (patcher_function)(pr); - -#if !defined(NDEBUG) - if (opt_DebugPatcher) { - assert(patcher_depth > 0); - patcher_depth--; - - TRACE_PATCHER_INDENT; - printf("\tmachine code after = "); - -# if defined(ENABLE_DISASSEMBLER) - disassinstr((void *) pr->mpc); -# else - printf("disassembler disabled\n"); -# endif - - if (result == false) { - TRACE_PATCHER_INDENT; printf("\tPATCHER EXCEPTION!\n"); - } - } -#endif - - /* check for return value and exit accordingly */ - - if (result == false) { - e = exceptions_get_and_clear_exception(); - - LOCK_MONITOR_EXIT(code->patchers); - - return e; - } - - pr->done = true; /* XXX this is only preliminary to prevent double-patching */ - - LOCK_MONITOR_EXIT(code->patchers); - - return NULL; -} - - -/* patcher_initialize_class **************************************************** - - Initalizes a given classinfo pointer. - This function does not patch any data. - -*******************************************************************************/ - -bool patcher_initialize_class(patchref_t *pr) -{ - classinfo *c; - - /* get stuff from the patcher reference */ - - c = (classinfo *) pr->ref; - - /* check if the class is initialized */ - - if (!(c->state & CLASS_INITIALIZED)) - if (!initialize_class(c)) - return false; - - /* patch back original code */ - - patcher_patch_code(pr); - - return true; -} - - -/* patcher_resolve_class ******************************************************* - - Resolves a given unresolved class reference. - This function does not patch any data. - -*******************************************************************************/ - -#ifdef ENABLE_VERIFIER -bool patcher_resolve_class(patchref_t *pr) -{ - unresolved_class *uc; - - /* get stuff from the patcher reference */ - - uc = (unresolved_class *) pr->ref; - - /* resolve the class and check subtype constraints */ - - if (!resolve_class_eager_no_access_check(uc)) - return false; - - /* patch back original code */ - - patcher_patch_code(pr); - - return true; -} -#endif /* ENABLE_VERIFIER */ - - -/* patcher_resolve_native_function ********************************************* - - Resolves the native function for a given methodinfo. - This function patches one data segment word. - -*******************************************************************************/ - -bool patcher_resolve_native_function(patchref_t *pr) -{ - methodinfo *m; - uint8_t *datap; - functionptr f; - - /* get stuff from the patcher reference */ - - m = (methodinfo *) pr->ref; - datap = (uint8_t *) pr->datap; - - /* resolve native function */ - - if (!(f = native_method_resolve(m))) - return false; - - /* patch native function pointer */ - - *((intptr_t *) datap) = (intptr_t) f; - - /* synchronize data cache */ - - md_dcacheflush(datap, SIZEOF_VOID_P); - - /* patch back original code */ - - patcher_patch_code(pr); - - return true; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ - diff --git a/src/vm/jit/patcher-common.cpp b/src/vm/jit/patcher-common.cpp new file mode 100644 index 000000000..a33aba789 --- /dev/null +++ b/src/vm/jit/patcher-common.cpp @@ -0,0 +1,533 @@ +/* src/vm/jit/patcher-common.cpp - architecture independent code patching stuff + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "codegen.h" /* for PATCHER_NOPS */ +#include "md.h" + +#include "mm/memory.h" + +#include "native/native.h" + +#include "toolbox/list.h" +#include "toolbox/logging.h" /* XXX remove me! */ + +#include "vm/exceptions.hpp" +#include "vm/initialize.h" +#include "vm/options.h" +#include "vm/resolve.h" +#include "vm/vm.hpp" /* for vm_abort */ + +#include "vm/jit/code.hpp" +#include "vm/jit/disass.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" + + +/* patcher_function_list ******************************************************* + + This is a list which maps patcher function pointers to the according + names of the patcher functions. It is only usefull for debugging + purposes. + +*******************************************************************************/ + +#if !defined(NDEBUG) +typedef struct patcher_function_list_t { + functionptr patcher; + const char* name; +} patcher_function_list_t; + +static patcher_function_list_t patcher_function_list[] = { + { PATCHER_initialize_class, "initialize_class" }, + { PATCHER_resolve_class, "resolve_class" }, + { PATCHER_resolve_native_function, "resolve_native_function" }, + { PATCHER_invokestatic_special, "invokestatic_special" }, + { PATCHER_invokevirtual, "invokevirtual" }, + { PATCHER_invokeinterface, "invokeinterface" }, + { NULL, "-UNKNOWN PATCHER FUNCTION-" } +}; +#endif + + +/* patcher_list_create ********************************************************* + + Creates an empty patcher list for the given codeinfo. + +*******************************************************************************/ + +void patcher_list_create(codeinfo *code) +{ + code->patchers = list_create(OFFSET(patchref_t, linkage)); +} + + +/* patcher_list_reset ********************************************************** + + Resets the patcher list inside a codeinfo. This is usefull when + resetting a codeinfo for recompiling. + +*******************************************************************************/ + +void patcher_list_reset(codeinfo *code) +{ + patchref_t *pr; + + /* free all elements of the list */ + + while((pr = (patchref_t*) list_first(code->patchers)) != NULL) { + list_remove(code->patchers, pr); + + FREE(pr, patchref_t); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_patchref -= sizeof(patchref_t); +#endif + } +} + +/* patcher_list_free *********************************************************** + + Frees the patcher list and all its entries for the given codeinfo. + +*******************************************************************************/ + +void patcher_list_free(codeinfo *code) +{ + /* free all elements of the list */ + + patcher_list_reset(code); + + /* free the list itself */ + + list_free(code->patchers); +} + + +/* patcher_list_find *********************************************************** + + Find an entry inside the patcher list for the given codeinfo + by specifying the program counter of the patcher position. + + NOTE: Caller should hold the patcher list lock or maintain + exclusive access otherwise. + +*******************************************************************************/ + +static patchref_t *patcher_list_find(codeinfo *code, void *pc) +{ + patchref_t *pr; + + /* walk through all patcher references for the given codeinfo */ + + pr = (patchref_t*) list_first(code->patchers); + + while (pr) { + +/*#define TRACE_PATCHER_FIND*/ +#ifdef TRACE_PATCHER_FIND + log_println("patcher_list_find: %p == %p", pr->mpc, pc); +#endif + + if (pr->mpc == (ptrint) pc) + return pr; + + pr = (patchref_t*) list_next(code->patchers, pr); + } + + return NULL; +} + + +/* patcher_add_patch_ref ******************************************************* + + Appends a new patcher reference to the list of patching positions. + +*******************************************************************************/ + +void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp) +{ + codegendata *cd; + codeinfo *code; + patchref_t *pr; + s4 patchmpc; + + cd = jd->cd; + code = jd->code; + patchmpc = cd->mcodeptr - cd->mcodebase; + +#if !defined(NDEBUG) + if (patcher_list_find(code, (void*) (intptr_t) patchmpc) != NULL) + vm_abort("patcher_add_patch_ref: different patchers at same position."); +#endif + + /* allocate patchref on heap (at least freed together with codeinfo) */ + + pr = NEW(patchref_t); + list_add_first(code->patchers, pr); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_patchref += sizeof(patchref_t); +#endif + + /* set patcher information (mpc is resolved later) */ + + pr->mpc = patchmpc; + pr->disp = disp; + pr->patcher = patcher; + pr->ref = ref; + pr->mcode = 0; + pr->done = false; + +#if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__SPARC_64__) || defined(__X86_64__)) + + /* XXX We can remove that when we don't use UD2 anymore on i386 + and x86_64. */ + + /* On some architectures the patcher stub call instruction might + be longer than the actual instruction generated. On this + architectures we store the last patcher call position and after + the basic block code generation is completed, we check the + range and maybe generate some nop's. */ + /* The nops are generated in codegen_emit in each codegen */ + + cd->lastmcodeptr = cd->mcodeptr + PATCHER_CALL_SIZE; +#endif +} + + +/** + * Resolve all patchers in the current JIT run. + * + * @param jd JIT data-structure + */ +void patcher_resolve(jitdata* jd) +{ + codeinfo* code; + patchref_t* pr; + + /* Get required compiler data. */ + + code = jd->code; + + for (pr = (patchref_t*) list_first(code->patchers); pr != NULL; pr = (patchref_t*) list_next(code->patchers, pr)) { + pr->mpc += (intptr_t) code->entrypoint; + pr->datap = (intptr_t) (pr->disp + code->entrypoint); + } +} + + +/** + * Check if the patcher is already patched. This is done by comparing + * the machine instruction. + * + * @param pr Patcher structure. + * + * @return true if patched, false otherwise. + */ +bool patcher_is_patched(patchref_t* pr) +{ + // Validate the instruction at the patching position is the same + // instruction as the patcher structure contains. + uint32_t mcode = *((uint32_t*) pr->mpc); + + if (mcode != pr->mcode) { + // The code differs. + return false; + } + + return true; +} + + +/** + * + */ +bool patcher_is_patched_at(void* pc) +{ + codeinfo* code = code_find_codeinfo_for_pc(pc); + + // Get the patcher for the given PC. + patchref_t* pr = patcher_list_find(code, pc); + + if (pr == NULL) { + // The given PC is not a patcher position. + return false; + } + + // Validate the instruction. + return patcher_is_patched(pr); +} + + +/* patcher_handler ************************************************************* + + Handles the request to patch JIT code at the given patching + position. This function is normally called by the signal + handler. + + NOTE: The patcher list lock is used to maintain exclusive + access of the patched position (in fact of the whole code). + After patching has suceeded, the patcher reference should be + removed from the patcher list to avoid double patching. + +*******************************************************************************/ + +#if !defined(NDEBUG) +/* XXX this indent is not thread safe! */ +/* XXX if you want it thread safe, place patcher_depth in threadobject! */ +static int patcher_depth = 0; +#define TRACE_PATCHER_INDENT for (i=0; ipatchers); + + /* search the patcher information for the given PC */ + + pr = patcher_list_find(code, pc); + + if (pr == NULL) + vm_abort("patcher_handler: Unable to find patcher reference."); + + if (pr->done) { +#if !defined(NDEBUG) + if (opt_DebugPatcher) { + log_println("patcher_handler: double-patching detected!"); + } +#endif + list_unlock(code->patchers); + return NULL; + } + +#if !defined(NDEBUG) + if (opt_DebugPatcher) { + for (l = patcher_function_list; l->patcher != NULL; l++) + if (l->patcher == pr->patcher) + break; + + TRACE_PATCHER_INDENT; printf("patching in "); method_print(code->m); printf(" at %p\n", (void *) pr->mpc); + TRACE_PATCHER_INDENT; printf("\tpatcher function = %s <%p>\n", l->name, (void *) (intptr_t) pr->patcher); + + TRACE_PATCHER_INDENT; + printf("\tmachine code before = "); + +# if defined(ENABLE_DISASSEMBLER) + disassinstr((u1*) (void*) pr->mpc); +# else + printf("%x at %p (disassembler disabled)\n", *((uint32_t*) pr->mpc), (void*) pr->mpc); +# endif + + patcher_depth++; + assert(patcher_depth > 0); + } +#endif + + /* cast the passed function to a patcher function */ + + patcher_function = (bool (*)(patchref_t *)) (ptrint) pr->patcher; + + /* call the proper patcher function */ + + result = (patcher_function)(pr); + +#if !defined(NDEBUG) + if (opt_DebugPatcher) { + assert(patcher_depth > 0); + patcher_depth--; + + TRACE_PATCHER_INDENT; + printf("\tmachine code after = "); + +# if defined(ENABLE_DISASSEMBLER) + disassinstr((u1*) (void*) pr->mpc); +# else + printf("%x at %p (disassembler disabled)\n", *((uint32_t*) pr->mpc), (void*) pr->mpc); +# endif + + if (result == false) { + TRACE_PATCHER_INDENT; printf("\tPATCHER EXCEPTION!\n"); + } + } +#endif + + /* check for return value and exit accordingly */ + + if (result == false) { + e = exceptions_get_and_clear_exception(); + + list_unlock(code->patchers); + + return e; + } + + pr->done = true; /* XXX this is only preliminary to prevent double-patching */ + + list_unlock(code->patchers); + + return NULL; +} + + +/* patcher_initialize_class **************************************************** + + Initalizes a given classinfo pointer. + This function does not patch any data. + +*******************************************************************************/ + +bool patcher_initialize_class(patchref_t *pr) +{ + classinfo *c; + + /* get stuff from the patcher reference */ + + c = (classinfo *) pr->ref; + + /* check if the class is initialized */ + + if (!(c->state & CLASS_INITIALIZED)) + if (!initialize_class(c)) + return false; + + /* patch back original code */ + + patcher_patch_code(pr); + + return true; +} + + +/* patcher_resolve_class ******************************************************* + + Resolves a given unresolved class reference. + This function does not patch any data. + +*******************************************************************************/ + +#ifdef ENABLE_VERIFIER +bool patcher_resolve_class(patchref_t *pr) +{ + unresolved_class *uc; + + /* get stuff from the patcher reference */ + + uc = (unresolved_class *) pr->ref; + + /* resolve the class and check subtype constraints */ + + if (!resolve_class_eager_no_access_check(uc)) + return false; + + /* patch back original code */ + + patcher_patch_code(pr); + + return true; +} +#endif /* ENABLE_VERIFIER */ + + +/* patcher_resolve_native_function ********************************************* + + Resolves the native function for a given methodinfo. + This function patches one data segment word. + +*******************************************************************************/ + +bool patcher_resolve_native_function(patchref_t *pr) +{ + methodinfo *m; + uint8_t *datap; + functionptr f; + + /* get stuff from the patcher reference */ + + m = (methodinfo *) pr->ref; + datap = (uint8_t *) pr->datap; + + /* resolve native function */ + + if (!(f = native_method_resolve(m))) + return false; + + /* patch native function pointer */ + + *((intptr_t *) datap) = (intptr_t) f; + + /* synchronize data cache */ + + md_dcacheflush(datap, SIZEOF_VOID_P); + + /* patch back original code */ + + patcher_patch_code(pr); + + return true; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ + diff --git a/src/vm/jit/patcher-common.h b/src/vm/jit/patcher-common.h deleted file mode 100644 index a10344797..000000000 --- a/src/vm/jit/patcher-common.h +++ /dev/null @@ -1,200 +0,0 @@ -/* src/vm/jit/patcher-common.h - architecture independent code patching stuff - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _PATCHER_COMMON_H -#define _PATCHER_COMMON_H - -/* forward typedefs ***********************************************************/ - -#include "config.h" -#include "vm/types.h" - -#include "toolbox/list.h" - -#include "vm/global.h" - -#include "vm/jit/jit.h" - - -/* patchref_t ****************************************************************** - - A patcher reference contains information about a code position - which needs additional code patching during runtime. - -*******************************************************************************/ - -typedef struct patchref_t { - ptrint mpc; /* absolute position in code segment */ - ptrint datap; /* absolute position in data segment */ - s4 disp; /* displacement of ref in the data segment */ - functionptr patcher; /* patcher function to call */ - voidptr ref; /* reference passed */ - u8 mcode; /* machine code to be patched back in */ - bool done; /* XXX preliminary: patch already applied? */ - listnode_t linkage; -} patchref_t; - - -/* macros *********************************************************************/ - - -/* function prototypes ********************************************************/ - -void patcher_list_create(codeinfo *code); -void patcher_list_reset(codeinfo *code); -void patcher_list_free(codeinfo *code); - -void patcher_add_patch_ref(jitdata *jd, functionptr patcher, voidptr ref, - s4 disp); - -void patcher_resolve(jitdata* jd); - -java_handle_t *patcher_handler(u1 *pc); - - -/* empty patcher (just patches back original mcode) ***************************/ - -void patcher_patch_code(patchref_t *pr); - - -/* patcher prototypes and macros **********************************************/ - -/* new patcher functions */ - -bool patcher_resolve_class(patchref_t *pr); -#define PATCHER_resolve_class (functionptr) patcher_resolve_class - -bool patcher_initialize_class(patchref_t *pr); -#define PATCHER_initialize_class (functionptr) patcher_initialize_class - -bool patcher_resolve_classref_to_classinfo(patchref_t *pr); -#define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo - -bool patcher_resolve_classref_to_vftbl(patchref_t *pr); -#define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl - -bool patcher_resolve_classref_to_index(patchref_t *pr); -#define PATCHER_resolve_classref_to_index (functionptr) patcher_resolve_classref_to_index - -bool patcher_resolve_classref_to_flags(patchref_t *pr); -#define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags - -bool patcher_resolve_native_function(patchref_t *pr); -#define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function - -/* old patcher functions */ - -bool patcher_get_putstatic(patchref_t *pr); -#define PATCHER_get_putstatic (functionptr) patcher_get_putstatic - -#if defined(__I386__) - -bool patcher_getfield(patchref_t *pr); -#define PATCHER_getfield (functionptr) patcher_getfield - -bool patcher_putfield(patchref_t *pr); -#define PATCHER_putfield (functionptr) patcher_putfield - -#else - -bool patcher_get_putfield(patchref_t *pr); -#define PATCHER_get_putfield (functionptr) patcher_get_putfield - -#endif /* defined(__I386__) */ - -#if defined(__I386__) || defined(__X86_64__) - -bool patcher_putfieldconst(patchref_t *pr); -#define PATCHER_putfieldconst (functionptr) patcher_putfieldconst - -#endif /* defined(__I386__) || defined(__X86_64__) */ - -bool patcher_invokestatic_special(patchref_t *pr); -#define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special - -bool patcher_invokevirtual(patchref_t *pr); -#define PATCHER_invokevirtual (functionptr) patcher_invokevirtual - -bool patcher_invokeinterface(patchref_t *pr); -#define PATCHER_invokeinterface (functionptr) patcher_invokeinterface - -#if defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) - -bool patcher_checkcast_interface(patchref_t *pr); -#define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface - -bool patcher_instanceof_interface(patchref_t *pr); -#define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface - -#endif /* defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) */ - -#if defined(__S390__) - -bool patcher_checkcast_instanceof_interface(patchref_t *pr); -#define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface - -#endif /* defined(__S390__) */ - -#if defined(__I386__) - -bool patcher_aconst(patchref_t *pr); -#define PATCHER_aconst (functionptr) patcher_aconst - -bool patcher_builtin_multianewarray(patchref_t *pr); -#define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray - -bool patcher_builtin_arraycheckcast(patchref_t *pr); -#define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast - -bool patcher_checkcast_instanceof_flags(patchref_t *pr); -#define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags - -bool patcher_checkcast_class(patchref_t *pr); -#define PATCHER_checkcast_class (functionptr) patcher_checkcast_class - -bool patcher_instanceof_class(patchref_t *pr); -#define PATCHER_instanceof_class (functionptr) patcher_instanceof_class - -#endif /* defined(__I386__) */ - - -#endif /* _PATCHER_COMMON_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/patcher-common.hpp b/src/vm/jit/patcher-common.hpp new file mode 100644 index 000000000..5f25ae83f --- /dev/null +++ b/src/vm/jit/patcher-common.hpp @@ -0,0 +1,210 @@ +/* src/vm/jit/patcher-common.hpp - architecture independent code patching stuff + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _PATCHER_COMMON_HPP +#define _PATCHER_COMMON_HPP + +/* forward typedefs ***********************************************************/ + +#include "config.h" +#include "vm/types.h" + +#include "toolbox/list.h" + +#include "vm/global.h" + +#include "vm/jit/jit.hpp" + + +/* patchref_t ****************************************************************** + + A patcher reference contains information about a code position + which needs additional code patching during runtime. + +*******************************************************************************/ + +typedef struct patchref_t { + ptrint mpc; /* absolute position in code segment */ + ptrint datap; /* absolute position in data segment */ + s4 disp; /* displacement of ref in the data segment */ + functionptr patcher; /* patcher function to call */ + void* ref; /* reference passed */ + uint32_t mcode; /* machine code to be patched back in */ + bool done; /* XXX preliminary: patch already applied? */ + listnode_t linkage; +} patchref_t; + + +/* macros *********************************************************************/ + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +void patcher_list_create(codeinfo *code); +void patcher_list_reset(codeinfo *code); +void patcher_list_free(codeinfo *code); + +void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp); + +void patcher_resolve(jitdata* jd); + +bool patcher_is_patched(patchref_t* pr); +bool patcher_is_patched_at(void* pc); + +// MD function. +bool patcher_is_valid_trap_instruction_at(void* pc); + +java_handle_t *patcher_handler(u1 *pc); + + +/* empty patcher (just patches back original mcode) ***************************/ + +void patcher_patch_code(patchref_t *pr); + + +/* patcher prototypes and macros **********************************************/ + +/* new patcher functions */ + +bool patcher_resolve_class(patchref_t *pr); +#define PATCHER_resolve_class (functionptr) patcher_resolve_class + +bool patcher_initialize_class(patchref_t *pr); +#define PATCHER_initialize_class (functionptr) patcher_initialize_class + +bool patcher_resolve_classref_to_classinfo(patchref_t *pr); +#define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo + +bool patcher_resolve_classref_to_vftbl(patchref_t *pr); +#define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl + +bool patcher_resolve_classref_to_index(patchref_t *pr); +#define PATCHER_resolve_classref_to_index (functionptr) patcher_resolve_classref_to_index + +bool patcher_resolve_classref_to_flags(patchref_t *pr); +#define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags + +bool patcher_resolve_native_function(patchref_t *pr); +#define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function + +/* old patcher functions */ + +bool patcher_get_putstatic(patchref_t *pr); +#define PATCHER_get_putstatic (functionptr) patcher_get_putstatic + +#if defined(__I386__) + +bool patcher_getfield(patchref_t *pr); +#define PATCHER_getfield (functionptr) patcher_getfield + +bool patcher_putfield(patchref_t *pr); +#define PATCHER_putfield (functionptr) patcher_putfield + +#else + +bool patcher_get_putfield(patchref_t *pr); +#define PATCHER_get_putfield (functionptr) patcher_get_putfield + +#endif /* defined(__I386__) */ + +#if defined(__I386__) || defined(__X86_64__) + +bool patcher_putfieldconst(patchref_t *pr); +#define PATCHER_putfieldconst (functionptr) patcher_putfieldconst + +#endif /* defined(__I386__) || defined(__X86_64__) */ + +bool patcher_invokestatic_special(patchref_t *pr); +#define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special + +bool patcher_invokevirtual(patchref_t *pr); +#define PATCHER_invokevirtual (functionptr) patcher_invokevirtual + +bool patcher_invokeinterface(patchref_t *pr); +#define PATCHER_invokeinterface (functionptr) patcher_invokeinterface + +#if defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) + +bool patcher_checkcast_interface(patchref_t *pr); +#define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface + +bool patcher_instanceof_interface(patchref_t *pr); +#define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface + +#endif /* defined(__ALPHA__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) */ + +#if defined(__S390__) + +bool patcher_checkcast_instanceof_interface(patchref_t *pr); +#define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface + +#endif /* defined(__S390__) */ + +#if defined(__I386__) + +bool patcher_aconst(patchref_t *pr); +#define PATCHER_aconst (functionptr) patcher_aconst + +bool patcher_builtin_multianewarray(patchref_t *pr); +#define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray + +bool patcher_builtin_arraycheckcast(patchref_t *pr); +#define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast + +bool patcher_checkcast_instanceof_flags(patchref_t *pr); +#define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags + +bool patcher_checkcast_class(patchref_t *pr); +#define PATCHER_checkcast_class (functionptr) patcher_checkcast_class + +bool patcher_instanceof_class(patchref_t *pr); +#define PATCHER_instanceof_class (functionptr) patcher_instanceof_class + +#endif /* defined(__I386__) */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PATCHER_COMMON_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/powerpc/Makefile.am b/src/vm/jit/powerpc/Makefile.am index d8e59bfa4..730fb9d8f 100644 --- a/src/vm/jit/powerpc/Makefile.am +++ b/src/vm/jit/powerpc/Makefile.am @@ -35,7 +35,7 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h + md-atomic.hpp noinst_LTLIBRARIES = \ libarch.la @@ -53,6 +53,7 @@ libarch_la_SOURCES = \ emit.c \ patcher.c \ \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/powerpc/asmpart.S b/src/vm/jit/powerpc/asmpart.S index 3413a354f..cae9439fa 100644 --- a/src/vm/jit/powerpc/asmpart.S +++ b/src/vm/jit/powerpc/asmpart.S @@ -57,9 +57,6 @@ .globl asm_cacheflush - .globl asm_compare_and_swap - .globl asm_memory_barrier - /* asm_vm_call_method ********************************************************** * * @@ -463,36 +460,6 @@ asm_cacheflush: blr -/* asm_compare_and_swap ******************************************************** - - XXX - -*******************************************************************************/ - -asm_compare_and_swap: -1: - lwarx a6,0,a0 - subf. r0,a6,a1 - bne- 2f - or r0,a2,a2 - stwcx. r0,0,a0 - bne- 1b -2: - mr a0,a6 - blr - - -/* asm_memory_barrier ********************************************************** - - XXX - -*******************************************************************************/ - -asm_memory_barrier: - sync - blr - - #if defined(__DARWIN__) .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32 diff --git a/src/vm/jit/powerpc/codegen.c b/src/vm/jit/powerpc/codegen.c index 378a7279e..5d296e8df 100644 --- a/src/vm/jit/powerpc/codegen.c +++ b/src/vm/jit/powerpc/codegen.c @@ -43,35 +43,33 @@ #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/methodheader.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" #if defined(ENABLE_LSRA) # include "vm/jit/allocator/lsra.h" #endif -#include "vmcore/loader.h" -#include "vmcore/options.h" - /* codegen ********************************************************************* @@ -2439,9 +2437,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -2514,16 +2509,12 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ALD(REG_ITMP2, REG_PV, disp); if (s1 != REG_ITMP1) { M_ILD(REG_ITMP1, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_ISUB(REG_ITMP3, REG_ITMP1, REG_ITMP3); } else { @@ -2531,8 +2522,6 @@ gen_method: M_ISUB(REG_ITMP3, REG_ITMP2, REG_ITMP3); M_ALD(REG_ITMP2, REG_PV, disp); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - - CODEGEN_CRITICAL_SECTION_END; } M_CMPU(REG_ITMP3, REG_ITMP2); emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1); @@ -2594,9 +2583,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); @@ -2675,14 +2661,10 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); M_CMPU(REG_ITMP1, REG_ITMP2); M_CLR(d); @@ -2985,7 +2967,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - disp = dseg_add_address(cd, _Jv_env); + disp = dseg_add_address(cd, VM_get_jnienv()); M_ALD(REG_A0, REG_PV, disp); } diff --git a/src/vm/jit/powerpc/codegen.h b/src/vm/jit/powerpc/codegen.h index ea6f98435..d43c38ccd 100644 --- a/src/vm/jit/powerpc/codegen.h +++ b/src/vm/jit/powerpc/codegen.h @@ -32,7 +32,7 @@ #include "md-abi.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/reg.h" @@ -122,11 +122,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 1 * 4 - - /* macros to create code ******************************************************/ #define M_OP3(opcode,y,oe,rc,d,a,b) \ diff --git a/src/vm/jit/powerpc/darwin/md-abi.c b/src/vm/jit/powerpc/darwin/md-abi.c index 783991af9..68899b4ee 100644 --- a/src/vm/jit/powerpc/darwin/md-abi.c +++ b/src/vm/jit/powerpc/darwin/md-abi.c @@ -29,13 +29,12 @@ #include "vm/jit/powerpc/darwin/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" #include "vm/jit/stack.h" -#include "vmcore/descriptor.h" - /* register descripton arrays *************************************************/ diff --git a/src/vm/jit/powerpc/darwin/md-os.c b/src/vm/jit/powerpc/darwin/md-os.c index 44b0f73d8..d2e6bf231 100644 --- a/src/vm/jit/powerpc/darwin/md-os.c +++ b/src/vm/jit/powerpc/darwin/md-os.c @@ -35,16 +35,13 @@ #include "vm/jit/powerpc/codegen.h" #include "vm/jit/powerpc/darwin/md-abi.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" #include "vm/global.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" /* md_signal_handler_sigsegv *************************************************** @@ -251,34 +248,6 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t _mc; - ppc_thread_state_t *_ss; - u1 *pc; - u1 *npc; - - _mc = _uc->uc_mcontext; - _ss = &_mc->ss; - - pc = (u1 *) _ss->srr0; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) - _ss->srr0 = (ptrint) npc; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/powerpc/emit.c b/src/vm/jit/powerpc/emit.c index 65927bb8a..724ff58f1 100644 --- a/src/vm/jit/powerpc/emit.c +++ b/src/vm/jit/powerpc/emit.c @@ -38,20 +38,18 @@ #include "threads/lock-common.h" -#include "vm/exceptions.h" +#include "vm/options.h" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/replace.h" -#include "vm/jit/trace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" - /* emit_load ******************************************************************* diff --git a/src/vm/jit/powerpc/linux/md-abi.c b/src/vm/jit/powerpc/linux/md-abi.c index af175d4ca..df5af31db 100644 --- a/src/vm/jit/powerpc/linux/md-abi.c +++ b/src/vm/jit/powerpc/linux/md-abi.c @@ -30,13 +30,12 @@ #include "vm/jit/powerpc/linux/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" #include "vm/jit/stack.h" -#include "vmcore/descriptor.h" - /* register descripton arrays *************************************************/ diff --git a/src/vm/jit/powerpc/linux/md-os.c b/src/vm/jit/powerpc/linux/md-os.c index beab97d87..02c95b6d4 100644 --- a/src/vm/jit/powerpc/linux/md-os.c +++ b/src/vm/jit/powerpc/linux/md-os.c @@ -35,12 +35,11 @@ #include "vm/jit/powerpc/md.h" #include "vm/jit/powerpc/linux/md-abi.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" #include "vm/signallocal.h" -#include "vm/stringlocal.h" +#include "vm/os.hpp" #include "vm/jit/asmpart.h" #include "vm/jit/executionstate.h" @@ -49,11 +48,8 @@ # include "vm/jit/optimizing/profile.h" #endif -#include "vm/jit/stacktrace.h" #include "vm/jit/trap.h" -#include "vmcore/system.h" - /* md_signal_handler_sigsegv *************************************************** @@ -335,7 +331,7 @@ void md_executionstate_read(executionstate_t *es, void *context) * the _mc->fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs)); - system_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs)); + os_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs)); } @@ -370,7 +366,7 @@ void md_executionstate_write(executionstate_t *es, void *context) * the _mc->fpregs[i] can cause invalid conversions. */ assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs)); - system_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs)); + os_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs)); /* write special registers */ _gregs[PT_NIP] = (ptrint) es->pc; @@ -380,39 +376,6 @@ void md_executionstate_write(executionstate_t *es, void *context) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - unsigned long *_gregs; - u1 *pc; - u1 *npc; - -#if defined(__UCLIBC__) - _mc = &(_uc->uc_mcontext); - _gregs = _mc->regs->gpr; -#else - _mc = _uc->uc_mcontext.uc_regs; - _gregs = _mc->gregs; -#endif - - pc = (u1 *) _gregs[PT_NIP]; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) - _gregs[PT_NIP] = (ptrint) npc; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/powerpc/machine-instr.h b/src/vm/jit/powerpc/machine-instr.h deleted file mode 100644 index 8c7ba6ea4..000000000 --- a/src/vm/jit/powerpc/machine-instr.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long compare_and_swap(long *p, long oldval, long newval) -{ - long ret, temp; - - __asm__ __volatile__ ("\n\ -1: lwarx %0,0,%4 \n\ - subf. %1,%0,%2 \n\ - bne- 2f \n\ - or %1,%3,%3 \n\ - stwcx. %1,0,%4 \n\ - bne- 1b \n\ -2: \n\ -" : "=&r"(ret), "=&r"(temp) - : "r"(oldval), "r"(newval), "r"(p) : "cr0", "memory"); - - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("isync" : : : "memory"); -#define MEMORY_BARRIER() __asm__ __volatile__ ( "sync" : : : "memory" ); - -#endif diff --git a/src/vm/jit/powerpc/md-atomic.hpp b/src/vm/jit/powerpc/md-atomic.hpp new file mode 100644 index 000000000..09a3533e8 --- /dev/null +++ b/src/vm/jit/powerpc/md-atomic.hpp @@ -0,0 +1,137 @@ +/* src/vm/jit/powerpc/md-atomic.hpp - PowerPC atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t temp; + uint32_t result; + + __asm__ __volatile__ ( + "1: \n" + " lwarx %0,0,%4 \n" + " subf. %1,%0,%2 \n" + " bne- 2f \n" + " or %1,%3,%3 \n" + " stwcx. %1,0,%4 \n" + " bne- 1b \n" + "2: \n" + : "=&r" (result), "=&r" (temp) + : "r" (oldval), "r" (newval), "r" (p) + : "cr0", "memory"); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + return Atomic::generic_compare_and_swap(p, oldval, newval); +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("sync" : : : "memory"); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("isync" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/powerpc/md-stubs.hpp b/src/vm/jit/powerpc/md-stubs.hpp new file mode 100644 index 000000000..caf3cc6b3 --- /dev/null +++ b/src/vm/jit/powerpc/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/powerpc/md-stubs.hpp - PowerPC JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on a PowerPC architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 1 * 4; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/powerpc/md-trap.h b/src/vm/jit/powerpc/md-trap.h index 3e5523526..fc9807d08 100644 --- a/src/vm/jit/powerpc/md-trap.h +++ b/src/vm/jit/powerpc/md-trap.h @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/powerpc/md.c b/src/vm/jit/powerpc/md.c index b85321c9d..3595f407a 100644 --- a/src/vm/jit/powerpc/md.c +++ b/src/vm/jit/powerpc/md.c @@ -1,9 +1,7 @@ /* src/vm/jit/powerpc/md.c - machine dependent PowerPC functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -37,9 +35,9 @@ #include "vm/jit/powerpc/md.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* md_init ********************************************************************* diff --git a/src/vm/jit/powerpc/md.h b/src/vm/jit/powerpc/md.h index 657288598..33724ab14 100644 --- a/src/vm/jit/powerpc/md.h +++ b/src/vm/jit/powerpc/md.h @@ -1,9 +1,7 @@ /* src/vm/jit/powerpc/md.h - machine dependent PowerPC functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -36,10 +34,10 @@ #include "vm/jit/powerpc/codegen.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" /* md_stacktrace_get_returnaddress ********************************************* @@ -77,46 +75,46 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe *******************************************************************************/ -inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) +inline static void* md_codegen_get_pv_from_pc(void* ra) { - u1 *pv; - u4 mcode; - s4 offset; + int32_t offset; + + uint32_t* pc = (uint32_t*) ra; /* get first instruction word after jump */ - mcode = *((u4 *) (ra + 1 * 4)); + uint32_t mcode = pc[1]; /* check if we have 2 instructions (addis, addi) */ if ((mcode >> 16) == 0x3dab) { /* get displacement of first instruction (addis) */ - offset = (s4) (mcode << 16); + offset = (int32_t) (mcode << 16); /* get displacement of second instruction (addi) */ - mcode = *((u4 *) (ra + 2 * 4)); + mcode = pc[2]; /* check for addi instruction */ assert((mcode >> 16) == 0x39ad); - offset += (s2) (mcode & 0x0000ffff); - - } else { + offset += (int16_t) (mcode & 0x0000ffff); + } + else { /* check for addi instruction */ assert((mcode >> 16) == 0x39ab); /* get offset of first instruction (addi) */ - offset = (s2) (mcode & 0x0000ffff); + offset = (int16_t) (mcode & 0x0000ffff); } /* calculate PV via RA + offset */ - pv = ra + offset; + void* pv = (void*) (((uintptr_t) ra) + offset); return pv; } diff --git a/src/vm/jit/powerpc/netbsd/md-os.c b/src/vm/jit/powerpc/netbsd/md-os.c index 695508830..a18683ef7 100644 --- a/src/vm/jit/powerpc/netbsd/md-os.c +++ b/src/vm/jit/powerpc/netbsd/md-os.c @@ -1,9 +1,7 @@ /* src/vm/jit/powerpc/netbsd/md-os.c - machine dependent PowerPC NetBSD functions - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ @@ -39,11 +31,10 @@ #include "vm/jit/powerpc/netbsd/md-abi.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" + #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" /* md_signal_handle_sigsegv **************************************************** @@ -92,14 +83,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *uc) -{ - /* XXX set pc to restart address */ -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/powerpc/patcher.c b/src/vm/jit/powerpc/patcher.c index f87a1a99d..186131ee4 100644 --- a/src/vm/jit/powerpc/patcher.c +++ b/src/vm/jit/powerpc/patcher.c @@ -36,20 +36,17 @@ #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" +#include "vm/options.h" +#include "vm/references.h" +#include "vm/resolve.h" #include "vm/jit/asmpart.h" #include "vm/jit/methodheader.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vm/resolve.h" -#include "vmcore/references.h" +#include "vm/jit/patcher-common.hpp" #define PATCH_BACK_ORIGINAL_MCODE \ @@ -291,11 +288,6 @@ bool patcher_get_putfield(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show NOPs, we have to skip them */ - - if (opt_shownops) - ra = ra + 1 * 4; - /* patch the field's offset */ if (IS_LNG_TYPE(fi->type)) { @@ -400,11 +392,6 @@ bool patcher_invokevirtual(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show NOPs, we have to skip them */ - - if (opt_shownops) - ra = ra + 1 * 4; - /* patch vftbl index */ disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex); @@ -451,11 +438,6 @@ bool patcher_invokeinterface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show NOPs, we have to skip them */ - - if (opt_shownops) - ra = ra + 1 * 4; - /* patch interfacetable index */ disp = OFFSET(vftbl_t, interfacetable[0]) - @@ -514,11 +496,6 @@ bool patcher_checkcast_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show NOPs, we have to skip them */ - - if (opt_shownops) - ra = ra + 1 * 4; - /* patch super class index */ disp = -(c->index); @@ -570,11 +547,6 @@ bool patcher_instanceof_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* if we show NOPs, we have to skip them */ - - if (opt_shownops) - ra = ra + 1 * 4; - /* patch super class index */ disp = -(c->index); diff --git a/src/vm/jit/powerpc64/Makefile.am b/src/vm/jit/powerpc64/Makefile.am index 4ec4826ae..d61007a20 100644 --- a/src/vm/jit/powerpc64/Makefile.am +++ b/src/vm/jit/powerpc64/Makefile.am @@ -33,7 +33,7 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h + md-atomic.hpp noinst_LTLIBRARIES = libarch.la @@ -50,6 +50,7 @@ libarch_la_SOURCES = \ emit.c \ patcher.c \ \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/powerpc64/codegen.c b/src/vm/jit/powerpc64/codegen.c index f9cd0fbe6..69fe64073 100644 --- a/src/vm/jit/powerpc64/codegen.c +++ b/src/vm/jit/powerpc64/codegen.c @@ -44,30 +44,28 @@ #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - #if defined(ENABLE_LSRA) # include "vm/jit/allocator/lsra.h" #endif @@ -2204,10 +2202,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) { - CODEGEN_CRITICAL_SECTION_NEW; - } - s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -2276,16 +2270,12 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ALD(REG_ITMP2, REG_PV, disp); if (s1 != REG_ITMP1) { M_ILD(REG_ITMP1, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_SUB(REG_ITMP3, REG_ITMP1, REG_ITMP3); M_EXTSW(REG_ITMP3, REG_ITMP3); } else { @@ -2294,9 +2284,6 @@ gen_method: M_EXTSW(REG_ITMP3, REG_ITMP3); M_ALD(REG_ITMP2, REG_PV, disp); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - - CODEGEN_CRITICAL_SECTION_END; - } M_CMPU(REG_ITMP3, REG_ITMP2); emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1); @@ -2373,10 +2360,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) { - CODEGEN_CRITICAL_SECTION_NEW; - } - s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); if (s1 == d) { @@ -2453,14 +2436,10 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_SUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); M_EXTSW(REG_ITMP1, REG_ITMP1); M_CMPU(REG_ITMP1, REG_ITMP2); @@ -2727,7 +2706,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - disp = dseg_add_unique_address(cd, _Jv_env); + disp = dseg_add_unique_address(cd, VM_get_jnienv()); M_ALD(REG_A0, REG_PV, disp); } diff --git a/src/vm/jit/powerpc64/codegen.h b/src/vm/jit/powerpc64/codegen.h index 1ffe1bfd9..34a710bcb 100644 --- a/src/vm/jit/powerpc64/codegen.h +++ b/src/vm/jit/powerpc64/codegen.h @@ -1,10 +1,8 @@ -/* src/vm/jit/powerpc64/codegen.h - code generation macros and definitions for - 64-bit PowerPC +/* src/vm/jit/powerpc64/codegen.h - code generation macros and + definitions for PowerPC64 - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -23,14 +21,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Andreas Krall - Stefan Ring - Christian Thalinger - Christian Ullrich - - */ @@ -42,7 +32,7 @@ #include "md-abi.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/reg.h" @@ -116,11 +106,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 1 * 4 - - /* macros to create code ******************************************************/ #define M_OP3(opcode,y,oe,rc,d,a,b) \ diff --git a/src/vm/jit/powerpc64/emit.c b/src/vm/jit/powerpc64/emit.c index b2a5119ee..5eb86886a 100644 --- a/src/vm/jit/powerpc64/emit.c +++ b/src/vm/jit/powerpc64/emit.c @@ -36,18 +36,16 @@ #include "threads/lock-common.h" -#include "vm/exceptions.h" -#include "vm/vm.h" +#include "vm/options.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/trace.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" - /* emit_load ******************************************************************* diff --git a/src/vm/jit/powerpc64/linux/md-abi.c b/src/vm/jit/powerpc64/linux/md-abi.c index f1a054e12..68f1ae5e7 100644 --- a/src/vm/jit/powerpc64/linux/md-abi.c +++ b/src/vm/jit/powerpc64/linux/md-abi.c @@ -31,16 +31,12 @@ #include "vm/jit/powerpc64/linux/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" #include "vm/jit/stack.h" -#include "vmcore/descriptor.h" - - -#define CACAO_ALIGN(a) do { if ((a) & 1) (a)++; } while (0) - /* register descripton array **************************************************/ diff --git a/src/vm/jit/powerpc64/linux/md-os.c b/src/vm/jit/powerpc64/linux/md-os.c index 8b292f1ad..977992e33 100644 --- a/src/vm/jit/powerpc64/linux/md-os.c +++ b/src/vm/jit/powerpc64/linux/md-os.c @@ -35,19 +35,19 @@ #include "vm/jit/powerpc64/md.h" #include "vm/jit/powerpc64/linux/md-abi.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" #include "vm/signallocal.h" +#include "vm/os.hpp" #include "vm/jit/asmpart.h" +#include "vm/jit/executionstate.h" #if defined(ENABLE_PROFILING) # include "vm/jit/optimizing/profile.h" #endif -#include "vm/jit/stacktrace.h" #include "vm/jit/trap.h" @@ -179,31 +179,87 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) #endif -/* md_critical_section_restart ************************************************* +/* md_executionstate_read ****************************************************** - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. + Read the given context into an executionstate. *******************************************************************************/ -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) +void md_executionstate_read(executionstate_t *es, void *context) { - mcontext_t *_mc; - u1 *pc; - u1 *npc; +#if 0 + ucontext_t *_uc; + mcontext_t *_mc; + unsigned long *_gregs; + s4 i; - _mc = &(_uc->uc_mcontext); + _uc = (ucontext_t *) context; - pc = (u1 *) _mc->gp_regs[PT_NIP]; + _mc = _uc->uc_mcontext.uc_regs; + _gregs = _mc->gregs; + + /* read special registers */ + es->pc = (u1 *) _gregs[PT_NIP]; + es->sp = (u1 *) _gregs[REG_SP]; + es->pv = (u1 *) _gregs[REG_PV]; + es->ra = (u1 *) _gregs[PT_LNK]; - npc = critical_find_restart_point(pc); + /* read integer registers */ + for (i = 0; i < INT_REG_CNT; i++) + es->intregs[i] = _gregs[i]; + + /* read float registers */ + /* Do not use the assignment operator '=', as the type of + * the _mc->fpregs[i] can cause invalid conversions. */ + + assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs)); + os_memcpy(&es->fltregs, &_mc->fpregs.fpregs, sizeof(_mc->fpregs.fpregs)); +#endif - if (npc != NULL) - _mc->gp_regs[PT_NIP] = (ptrint) npc; + vm_abort("md_executionstate_read: IMPLEMENT ME!"); } + + +/* md_executionstate_write ***************************************************** + + Write the given executionstate back to the context. + +*******************************************************************************/ + +void md_executionstate_write(executionstate_t *es, void *context) +{ +#if 0 + ucontext_t *_uc; + mcontext_t *_mc; + unsigned long *_gregs; + s4 i; + + _uc = (ucontext_t *) context; + + _mc = _uc->uc_mcontext.uc_regs; + _gregs = _mc->gregs; + + /* write integer registers */ + for (i = 0; i < INT_REG_CNT; i++) + _gregs[i] = es->intregs[i]; + + /* write float registers */ + /* Do not use the assignment operator '=', as the type of + * the _mc->fpregs[i] can cause invalid conversions. */ + + assert(sizeof(_mc->fpregs.fpregs) == sizeof(es->fltregs)); + os_memcpy(&_mc->fpregs.fpregs, &es->fltregs, sizeof(_mc->fpregs.fpregs)); + + /* write special registers */ + _gregs[PT_NIP] = (ptrint) es->pc; + _gregs[REG_SP] = (ptrint) es->sp; + _gregs[REG_PV] = (ptrint) es->pv; + _gregs[PT_LNK] = (ptrint) es->ra; #endif + vm_abort("md_executionstate_write: IMPLEMENT ME!"); +} + /* * These are local overrides for various environment variables in Emacs. diff --git a/src/vm/jit/powerpc64/machine-instr.h b/src/vm/jit/powerpc64/machine-instr.h deleted file mode 100644 index 5e3390c19..000000000 --- a/src/vm/jit/powerpc64/machine-instr.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long compare_and_swap(long *p, long oldval, long newval) -{ - long ret, temp; - - __asm__ __volatile__ ("\n\ -1: ldarx %0,0,%4 \n\ - subf. %1,%0,%2 \n\ - bne- 2f \n\ - or %1,%3,%3 \n\ - stdcx. %1,0,%4 \n\ - bne- 1b \n\ -2: \n\ -" : "=&r"(ret), "=&r"(temp) - : "r"(oldval), "r"(newval), "r"(p) : "cr0", "memory"); - - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("isync" : : : "memory"); -#define MEMORY_BARRIER() __asm__ __volatile__ ( "sync" : : : "memory" ); - -#endif diff --git a/src/vm/jit/powerpc64/md-atomic.hpp b/src/vm/jit/powerpc64/md-atomic.hpp new file mode 100644 index 000000000..f469e7515 --- /dev/null +++ b/src/vm/jit/powerpc64/md-atomic.hpp @@ -0,0 +1,154 @@ +/* src/vm/jit/powerpc64/atomic.hpp - PowerPC64 atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t temp; + uint32_t result; + + __asm__ __volatile__ ( + "1: \n" + " lwarx %0,0,%4 \n" + " subf. %1,%0,%2 \n" + " bne- 2f \n" + " or %1,%3,%3 \n" + " stwcx. %1,0,%4 \n" + " bne- 1b \n" + "2: \n" + : "=&r" (result), "=&r" (temp) + : "r" (oldval), "r" (newval), "r" (p) + : "cr0", "memory"); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + uint64_t temp; + uint64_t result; + + __asm__ __volatile__ ( + "1: \n" + " ldarx %0,0,%4 \n" + " subf. %1,%0,%2 \n" + " bne- 2f \n" + " or %1,%3,%3 \n" + " stdcx. %1,0,%4 \n" + " bne- 1b \n" + "2: \n" + : "=&r" (result), "=&r" (temp) + : "r" (oldval), "r" (newval), "r" (p) + : "cr0", "memory"); + + return result; +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("sync" : : : "memory"); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * An instruction memory barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("isync" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/powerpc64/md-stubs.hpp b/src/vm/jit/powerpc64/md-stubs.hpp new file mode 100644 index 000000000..5356f7fa9 --- /dev/null +++ b/src/vm/jit/powerpc64/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/powerpc64/md-stubs.hpp - PowerPC64 JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on a PowerPC64 architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 1 * 4; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/powerpc64/md-trap.h b/src/vm/jit/powerpc64/md-trap.h index 7e8c5b6fd..dad8d1f7d 100644 --- a/src/vm/jit/powerpc64/md-trap.h +++ b/src/vm/jit/powerpc64/md-trap.h @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/powerpc64/md.c b/src/vm/jit/powerpc64/md.c index 3e8bc5c15..15b564227 100644 --- a/src/vm/jit/powerpc64/md.c +++ b/src/vm/jit/powerpc64/md.c @@ -37,10 +37,9 @@ #include "vm/jit/powerpc64/codegen.h" #include "vm/jit/powerpc64/md.h" -#include "vm/exceptions.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/trap.h" diff --git a/src/vm/jit/powerpc64/md.h b/src/vm/jit/powerpc64/md.h index 4a4d165e9..b70509f86 100644 --- a/src/vm/jit/powerpc64/md.h +++ b/src/vm/jit/powerpc64/md.h @@ -1,9 +1,7 @@ /* src/vm/jit/powerpc64/md.h - machine dependent PowerPC functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -36,10 +34,10 @@ #include "vm/jit/powerpc64/codegen.h" #include "vm/global.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/asmpart.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* md_stacktrace_get_returnaddress ********************************************* @@ -77,37 +75,37 @@ inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframe *******************************************************************************/ -inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) +inline static void* md_codegen_get_pv_from_pc(void* ra) { - u1 *pv; - u4 mcode; - s4 offset; + int32_t offset; + + uint32_t* pc = (uint32_t*) ra; /* get first instruction word after jump */ - mcode = *((u4 *) (ra + 1 * 4)); + uint32_t mcode = pc[1]; /* check if we have 2 instructions (addis, addi) */ if ((mcode >> 16) == 0x3dcb) { /* get displacement of first instruction (addis) */ - offset = (s4) (mcode << 16); + offset = (int32_t) (mcode << 16); /* get displacement of second instruction (addi) */ - mcode = *((u4 *) (ra + 2 * 4)); + mcode = pc[2]; /* check for addi instruction */ assert((mcode >> 16) == 0x39ce); - offset += (s2) (mcode & 0x0000ffff); + offset += (int16_t) (mcode & 0x0000ffff); } else if ((mcode >> 16) == 0x39cb) { /* get offset of first instruction (addi) */ - offset = (s2) (mcode & 0x0000ffff); + offset = (int16_t) (mcode & 0x0000ffff); } else { vm_abort("md_codegen_get_pv_from_pc: unknown instruction %x", mcode); @@ -119,7 +117,7 @@ inline static u1 *md_codegen_get_pv_from_pc(u1 *ra) /* calculate PV via RA + offset */ - pv = ra + offset; + void* pv = (void*) (((uintptr_t) ra) + offset); return pv; } diff --git a/src/vm/jit/powerpc64/patcher.c b/src/vm/jit/powerpc64/patcher.c index 8f6f160ad..999ae7aae 100644 --- a/src/vm/jit/powerpc64/patcher.c +++ b/src/vm/jit/powerpc64/patcher.c @@ -36,20 +36,17 @@ #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" +#include "vm/options.h" +#include "vm/references.h" +#include "vm/resolve.h" #include "vm/jit/asmpart.h" #include "vm/jit/methodheader.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" -#include "vm/resolve.h" +#include "vm/jit/patcher-common.hpp" /* patcher_patch_code ********************************************************** @@ -60,13 +57,11 @@ void patcher_patch_code(patchref_t *pr) { - /* patch back original code */ + // Patch back original code. + *((uint32_t*) pr->mpc) = pr->mcode; - *((u4 *) pr->mpc) = pr->mcode; - - /* synchronize instruction cache */ - - md_icacheflush(pr->mpc, 4); + // Synchronize instruction cache. + md_icacheflush((void*) pr->mpc, 1 * 4); } @@ -106,14 +101,6 @@ bool patcher_get_putstatic(patchref_t *pr) if (!initialize_class(fi->clazz)) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - /* patch the field value's address */ *((intptr_t *) datap) = (intptr_t) fi->value; @@ -122,6 +109,9 @@ bool patcher_get_putstatic(patchref_t *pr) md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -151,26 +141,12 @@ bool patcher_get_putfield(patchref_t *pr) if (!(fi = resolve_field_eager(uf))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; + // Patch the field offset in the patcher. We also need this to + // validate patchers. + pr->mcode |= (int16_t) (fi->offset & 0x0000ffff); - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - - /* patch the field's offset */ - - *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff); - - /* synchronize instruction cache */ - - md_icacheflush(ra, 8); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -207,22 +183,15 @@ bool patcher_invokestatic_special(patchref_t *pr) if (!(m = resolve_method_eager(um))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* patch stubroutine */ - + // Patch stubroutine. *((ptrint *) datap) = (ptrint) m->stubroutine; - /* synchronize data cache */ - + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -258,29 +227,17 @@ bool patcher_invokevirtual(patchref_t *pr) if (!(m = resolve_method_eager(um))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - - /* patch vftbl index */ - + // Patch vftbl index. disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex); - *((s4 *) (ra + 4)) |= (disp & 0x0000ffff); - - /* synchronize instruction cache */ + *((uint32_t*) (ra + 1 * 4)) |= (disp & 0x0000ffff); + // Synchronize instruction cache. md_icacheflush(ra, 2 * 4); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -317,40 +274,25 @@ bool patcher_invokeinterface(patchref_t *pr) if (!(m = resolve_method_eager(um))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - - /* patch interfacetable index */ - + // Patch interfacetable index. disp = OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->clazz->index; - /* XXX TWISTI: check displacement */ - - *((s4 *) (ra + 1 * 4)) |= (disp & 0x0000ffff); - - /* patch method offset */ + // XXX TWISTI: check displacement + *((uint32_t*) (ra + 1 * 4)) |= (disp & 0x0000ffff); + // Patch method offset. disp = sizeof(methodptr) * (m - m->clazz->methods); - /* XXX TWISTI: check displacement */ - - *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff); - - /* synchronize instruction cache */ + // XXX TWISTI: check displacement + *((uint32_t*) (ra + 2 * 4)) |= (disp & 0x0000ffff); + // Synchronize instruction cache. md_icacheflush(ra, 3 * 4); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -387,28 +329,18 @@ bool patcher_checkcast_interface(patchref_t *pr) return false; } - /* patch back original code */ - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* if we show NOPs, we have to skip them */ - if (opt_shownops) - ra = ra +4; - - /* patch super class index */ + // Patch super class index. disp = -(c->index); - - *((s4*)(ra + 2*4)) |= (disp & 0x0000ffff); + *((uint32_t*) (ra + 2 * 4)) |= (disp & 0x0000ffff); disp = OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*); + *((uint32_t*) (ra + 5 * 4)) |= (disp & 0x0000ffff); - *((s4 *)(ra + 5*4)) |= (disp & 0x0000ffff); + // Synchronize instruction cache. + md_icacheflush(ra, 6 * 4); - /* sync instruction cache */ - md_icacheflush(ra, 6*4); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -446,33 +378,19 @@ bool patcher_instanceof_interface(patchref_t *pr) if (!(c = resolve_classref_eager(cr))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* if we show disassembly, we have to skip the nop */ - - if (opt_shownops) - ra = ra + 4; - - /* patch super class index */ - + // Patch super class index. disp = -(c->index); - - *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff); + *((uint32_t*) (ra + 2 * 4)) |= (disp & 0x0000ffff); disp = OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*); + *((uint32_t*) (ra + 4 * 4)) |= (disp & 0x0000ffff); - *((s4 *) (ra + 4 * 4)) |= (disp & 0x0000ffff); - - /* synchronize instruction cache */ - + // Synchronize instruction cache. md_icacheflush(ra, 5 * 4); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -527,22 +445,15 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr) if (!(c = resolve_classref_eager(cr))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* patch the classinfo pointer */ - - *((ptrint *) datap) = (ptrint) c; - - /* synchronize data cache */ + // Patch the classinfo pointer. + *((uintptr_t*) datap) = (uintptr_t) c; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -584,22 +495,15 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr) if (!(c = resolve_classref_eager(cr))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* patch super class' vftbl */ - - *((ptrint *) datap) = (ptrint) c->vftbl; - - /* synchronize data cache */ + // Patch super class' vftbl. + *((uintptr_t*) datap) = (uintptr_t) c->vftbl; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -631,22 +535,15 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr) if (!(c = resolve_classref_eager(cr))) return false; - /* patch back original code */ - - *((u4 *) ra) = mcode; - - /* synchronize instruction cache */ - - md_icacheflush(ra, 4); - - /* patch class flags */ - - *((s4 *) datap) = (s4) c->flags; - - /* synchronize data cache */ + // Patch class flags. + *((int32_t*) datap) = (int32_t) c->flags; + // Synchronize data cache. md_dcacheflush(datap, SIZEOF_VOID_P); + // Patch back the original code. + patcher_patch_code(pr); + return true; } diff --git a/src/vm/jit/python.c b/src/vm/jit/python.c index 025c11f62..cd42b4b87 100644 --- a/src/vm/jit/python.c +++ b/src/vm/jit/python.c @@ -79,11 +79,11 @@ #include "vm/jit/python.h" #include "vm/jit/show.h" #if defined(ENABLE_THREADS) -# include "threads/lock-common.h" +# include "threads/mutex.hpp" #endif #if defined(ENABLE_THREADS) -static java_object_t *python_global_lock; +static Mutex *python_global_mutex; #endif /* @@ -1825,8 +1825,7 @@ void pythonpass_init() { } #if defined(ENABLE_THREADS) - python_global_lock = NEW(java_object_t); - LOCK_INIT_OBJECT_LOCK(python_global_lock); + python_global_mutex = Mutex_new(); #endif } @@ -1847,7 +1846,7 @@ int pythonpass_run(jitdata *jd, const char *module, const char *function) { int success = 0; root_state root; - LOCK_MONITOR_ENTER(python_global_lock); + Mutex_lock(python_global_mutex); pymodname = PyString_FromString(module); pymod = PyImport_Import(pymodname); @@ -1888,7 +1887,7 @@ int pythonpass_run(jitdata *jd, const char *module, const char *function) { Py_XDECREF(pyret); Py_XDECREF(objcache); - LOCK_MONITOR_EXIT(python_global_lock); + Mutex_unlock(python_global_mutex); return (success == 1 ? 1 : 0); } diff --git a/src/vm/jit/python.h b/src/vm/jit/python.h index 56a44d429..5d6378413 100644 --- a/src/vm/jit/python.h +++ b/src/vm/jit/python.h @@ -26,7 +26,7 @@ #define _VM_JIT_PYTHON_H #if defined(ENABLE_PYTHON) -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" void pythonpass_init(); void pythonpass_cleanup(); diff --git a/src/vm/jit/reg.h b/src/vm/jit/reg.h index 66e989f00..3efd2b1ef 100644 --- a/src/vm/jit/reg.h +++ b/src/vm/jit/reg.h @@ -37,7 +37,7 @@ typedef struct registerdata registerdata; #include "arch.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/verify/typeinfo.h" @@ -53,6 +53,7 @@ struct varinfo { float f; double d; basicblock *retaddr; + s4 ii[2]; } vv; #if defined(ENABLE_VERIFIER) typeinfo_t typeinfo; /* type info for reference types */ @@ -132,8 +133,16 @@ struct registerdata { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + void reg_setup(jitdata *jd); +#ifdef __cplusplus +} +#endif + #endif /* _REG_H */ diff --git a/src/vm/jit/replace.c b/src/vm/jit/replace.c deleted file mode 100644 index 5895bec06..000000000 --- a/src/vm/jit/replace.c +++ /dev/null @@ -1,3481 +0,0 @@ -/* src/vm/jit/replace.c - on-stack replacement of methods - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -#include "config.h" -#include "vm/types.h" - -#include -#include -#include - -#include "arch.h" -#include "md.h" - -#if defined(ENABLE_GC_CACAO) -# include "mm/cacao-gc/gc.h" -#endif - -#include "mm/memory.h" - -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/stringlocal.h" - -#include "vm/jit/abi.h" -#include "vm/jit/asmpart.h" -#include "vm/jit/disass.h" -#include "vm/jit/executionstate.h" -#include "vm/jit/jit.h" -#include "vm/jit/methodheader.h" -#include "vm/jit/replace.h" -#include "vm/jit/show.h" -#include "vm/jit/stack.h" - -#include "vmcore/options.h" -#include "vmcore/classcache.h" - - -#define REPLACE_PATCH_DYNAMIC_CALL -/*#define REPLACE_PATCH_ALL*/ - -#if defined(ENABLE_VMLOG) -#include -#endif - -/*** architecture-dependent configuration *************************************/ - -/* first unset the macros (default) */ -#undef REPLACE_RA_BETWEEN_FRAMES -#undef REPLACE_RA_TOP_OF_FRAME -#undef REPLACE_RA_LINKAGE_AREA -#undef REPLACE_LEAFMETHODS_RA_REGISTER -#undef REPLACE_REG_RA - -/* i386, x86_64 and m68k */ -#if defined(__I386__) || defined(__X86_64__) || defined(__M68K__) -#define REPLACE_RA_BETWEEN_FRAMES -/* alpha */ -#elif defined(__ALPHA__) -#define REPLACE_RA_TOP_OF_FRAME -#define REPLACE_LEAFMETHODS_RA_REGISTER -#define REPLACE_REG_RA REG_RA -/* powerpc */ -#elif defined(__POWERPC__) -#define REPLACE_RA_LINKAGE_AREA -#define REPLACE_LEAFMETHODS_RA_REGISTER -#define REPLACE_REG_RA REG_ITMP3 /* the execution state has the LR in itmp3 */ -/* s390 */ -#elif defined(__S390__) -#define REPLACE_RA_TOP_OF_FRAME -#define REPLACE_REG_RA REG_ITMP3 -#endif - - -/*** configuration of native stack slot size **********************************/ - -/* XXX this should be in md-abi.h files, probably */ - -#if defined(HAS_4BYTE_STACKSLOT) -#define SIZE_OF_STACKSLOT 4 -#define STACK_SLOTS_PER_FLOAT 2 -typedef u4 stackslot_t; -#else -#define SIZE_OF_STACKSLOT 8 -#define STACK_SLOTS_PER_FLOAT 1 -typedef u8 stackslot_t; -#endif - - -/*** debugging ****************************************************************/ - -#if !defined(NDEBUG) -static void java_value_print(s4 type, replace_val_t value); -static void replace_stackframeinfo_println(stackframeinfo_t *sfi); -#endif - -#if !defined(NDEBUG) -#define DOLOG(code) do{ if (opt_TraceReplacement > 1) { code; } } while(0) -#define DOLOG_SHORT(code) do{ if (opt_TraceReplacement > 0) { code; } } while(0) -#else -#define DOLOG(code) -#define DOLOG_SHORT(code) -#endif - - -/*** statistics ***************************************************************/ - -#define REPLACE_STATISTICS - -#if defined(REPLACE_STATISTICS) - -static int stat_replacements = 0; -static int stat_frames = 0; -static int stat_recompile = 0; -static int stat_staticpatch = 0; -static int stat_unroll_inline = 0; -static int stat_unroll_call = 0; -static int stat_dist_frames[20] = { 0 }; -static int stat_dist_locals[20] = { 0 }; -static int stat_dist_locals_adr[10] = { 0 }; -static int stat_dist_locals_prim[10] = { 0 }; -static int stat_dist_locals_ret[10] = { 0 }; -static int stat_dist_locals_void[10] = { 0 }; -static int stat_dist_stack[10] = { 0 }; -static int stat_dist_stack_adr[10] = { 0 }; -static int stat_dist_stack_prim[10] = { 0 }; -static int stat_dist_stack_ret[10] = { 0 }; -static int stat_methods = 0; -static int stat_rploints = 0; -static int stat_regallocs = 0; -static int stat_dist_method_rplpoints[20] = { 0 }; - -#define REPLACE_COUNT(cnt) (cnt)++ -#define REPLACE_COUNT_IF(cnt, cond) do{ if(cond) (cnt)++; } while(0) -#define REPLACE_COUNT_INC(cnt, inc) ((cnt) += (inc)) - -#define REPLACE_COUNT_DIST(array, val) \ - do { \ - int limit = (sizeof(array) / sizeof(int)) - 1; \ - if ((val) < (limit)) (array)[val]++; \ - else (array)[limit]++; \ - } while (0) - -static void replace_statistics_source_frame(sourceframe_t *frame); - -#else - -#define REPLACE_COUNT(cnt) -#define REPLACE_COUNT_IF(cnt, cond) -#define REPLACE_COUNT_INC(cnt, inc) -#define REPLACE_COUNT_DIST(array, val) - -#endif /* defined(REPLACE_STATISTICS) */ - - -/*** constants used internally ************************************************/ - -#define TOP_IS_NORMAL 0 -#define TOP_IS_ON_STACK 1 -#define TOP_IS_IN_ITMP1 2 -#define TOP_IS_VOID 3 - - -/******************************************************************************/ -/* PART I: Creating / freeing replacement points */ -/******************************************************************************/ - - -/* replace_create_replacement_point ******************************************** - - Create a replacement point. - - IN: - jd...............current jitdata - iinfo............inlining info for the current position - rp...............pre-allocated (uninitialized) rplpoint - type.............RPLPOINT_TYPE constant - iptr.............current instruction - *pra.............current rplalloc pointer - javalocals.......the javalocals at the current point - stackvars........the stack variables at the current point - stackdepth.......the stack depth at the current point - paramcount.......number of parameters at the start of stackvars - - OUT: - *rpa.............points to the next free rplalloc - -*******************************************************************************/ - -static void replace_create_replacement_point(jitdata *jd, - insinfo_inline *iinfo, - rplpoint *rp, - s4 type, - instruction *iptr, - rplalloc **pra, - s4 *javalocals, - s4 *stackvars, - s4 stackdepth, - s4 paramcount) -{ - rplalloc *ra; - s4 i; - varinfo *v; - s4 index; - - ra = *pra; - - REPLACE_COUNT(stat_rploints); - - rp->method = (iinfo) ? iinfo->method : jd->m; - rp->pc = NULL; /* set by codegen */ - rp->callsize = 0; /* set by codegen */ - rp->regalloc = ra; - rp->flags = 0; - rp->type = type; - rp->id = iptr->flags.bits >> INS_FLAG_ID_SHIFT; - - /* XXX unify these two fields */ - rp->parent = (iinfo) ? iinfo->rp : NULL; - - /* store local allocation info of javalocals */ - - if (javalocals) { - for (i = 0; i < rp->method->maxlocals; ++i) { - index = javalocals[i]; - if (index == UNUSED) - continue; - - ra->index = i; - if (index >= 0) { - v = VAR(index); - ra->flags = v->flags & (INMEMORY); - ra->regoff = v->vv.regoff; - ra->type = v->type; - } - else { - ra->regoff = RETADDR_FROM_JAVALOCAL(index); - ra->type = TYPE_RET; - ra->flags = 0; - } - ra++; - } - } - - /* store allocation info of java stack vars */ - - for (i = 0; i < stackdepth; ++i) { - v = VAR(stackvars[i]); - ra->flags = v->flags & (INMEMORY); - ra->index = (i < paramcount) ? RPLALLOC_PARAM : RPLALLOC_STACK; - ra->type = v->type; - /* XXX how to handle locals on the stack containing returnAddresses? */ - if (v->type == TYPE_RET) { - assert(stackvars[i] >= jd->localcount); - ra->regoff = v->vv.retaddr->nr; - } - else - ra->regoff = v->vv.regoff; - ra++; - } - - /* total number of allocations */ - - rp->regalloccount = ra - rp->regalloc; - - *pra = ra; -} - - -/* replace_create_inline_start_replacement_point ******************************* - - Create an INLINE_START replacement point. - - IN: - jd...............current jitdata - rp...............pre-allocated (uninitialized) rplpoint - iptr.............current instruction - *pra.............current rplalloc pointer - javalocals.......the javalocals at the current point - - OUT: - *rpa.............points to the next free rplalloc - - RETURN VALUE: - the insinfo_inline * for the following inlined body - -*******************************************************************************/ - -static insinfo_inline * replace_create_inline_start_replacement_point( - jitdata *jd, - rplpoint *rp, - instruction *iptr, - rplalloc **pra, - s4 *javalocals) -{ - insinfo_inline *calleeinfo; - rplalloc *ra; - - calleeinfo = iptr->sx.s23.s3.inlineinfo; - - calleeinfo->rp = rp; - - replace_create_replacement_point(jd, calleeinfo->parent, rp, - RPLPOINT_TYPE_INLINE, iptr, pra, - javalocals, - calleeinfo->stackvars, calleeinfo->stackvarscount, - calleeinfo->paramcount); - - if (calleeinfo->synclocal != UNUSED) { - ra = (*pra)++; - ra->index = RPLALLOC_SYNC; - ra->regoff = jd->var[calleeinfo->synclocal].vv.regoff; - ra->flags = jd->var[calleeinfo->synclocal].flags & INMEMORY; - ra->type = TYPE_ADR; - - rp->regalloccount++; - } - - return calleeinfo; -} - - -/* replace_create_replacement_points ******************************************* - - Create the replacement points for the given code. - - IN: - jd...............current jitdata, must not have any replacement points - - OUT: - code->rplpoints.......set to the list of replacement points - code->rplpointcount...number of replacement points - code->regalloc........list of allocation info - code->regalloccount...total length of allocation info list - code->globalcount.....number of global allocations at the - start of code->regalloc - - RETURN VALUE: - true.............everything ok - false............an exception has been thrown - -*******************************************************************************/ - -#define CLEAR_javalocals(array, method) \ - do { \ - for (i=0; i<(method)->maxlocals; ++i) \ - (array)[i] = UNUSED; \ - } while (0) - -#define COPY_OR_CLEAR_javalocals(dest, array, method) \ - do { \ - if ((array) != NULL) \ - MCOPY((dest), (array), s4, (method)->maxlocals); \ - else \ - CLEAR_javalocals((dest), (method)); \ - } while (0) - -#define COUNT_javalocals(array, method, counter) \ - do { \ - for (i=0; i<(method)->maxlocals; ++i) \ - if ((array)[i] != UNUSED) \ - (counter)++; \ - } while (0) - -bool replace_create_replacement_points(jitdata *jd) -{ - codeinfo *code; - registerdata *rd; - basicblock *bptr; - int count; - methodinfo *m; - rplpoint *rplpoints; - rplpoint *rp; - int alloccount; - rplalloc *regalloc; - rplalloc *ra; - int i; - instruction *iptr; - instruction *iend; - s4 *javalocals; - s4 *jl; - methoddesc *md; - insinfo_inline *iinfo; - s4 startcount; - s4 firstcount; -#if defined(REPLACE_PATCH_DYNAMIC_CALL) - bool needentry; -#endif - - REPLACE_COUNT(stat_methods); - - /* get required compiler data */ - - code = jd->code; - rd = jd->rd; - - /* assert that we wont overwrite already allocated data */ - - assert(code); - assert(code->m); - assert(code->rplpoints == NULL); - assert(code->rplpointcount == 0); - assert(code->regalloc == NULL); - assert(code->regalloccount == 0); - assert(code->globalcount == 0); - - m = code->m; - - /* in instance methods, we may need a rplpoint at the method entry */ - -#if defined(REPLACE_PATCH_DYNAMIC_CALL) - if (!(m->flags & ACC_STATIC)) { - jd->basicblocks[0].bitflags |= BBFLAG_REPLACEMENT; - needentry = true; - } - else { - needentry = false; - } -#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */ - - /* iterate over the basic block list to find replacement points */ - - count = 0; - alloccount = 0; - - javalocals = DMNEW(s4, jd->maxlocals); - - for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { - - /* skip dead code */ - - if (bptr->flags < BBFINISHED) - continue; - - /* get info about this block */ - - m = bptr->method; - iinfo = bptr->inlineinfo; - - /* initialize javalocals at the start of this block */ - - COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m); - - /* iterate over the instructions */ - - iptr = bptr->iinstr; - iend = iptr + bptr->icount; - startcount = count; - firstcount = count; - - for (; iptr != iend; ++iptr) { - switch (iptr->opc) { -#if defined(ENABLE_GC_CACAO) - case ICMD_BUILTIN: - md = iptr->sx.s23.s3.bte->md; - count++; - COUNT_javalocals(javalocals, m, alloccount); - alloccount += iptr->s1.argcount; - if (iinfo) - alloccount -= iinfo->throughcount; - break; -#endif - - case ICMD_INVOKESTATIC: - case ICMD_INVOKESPECIAL: - case ICMD_INVOKEVIRTUAL: - case ICMD_INVOKEINTERFACE: - INSTRUCTION_GET_METHODDESC(iptr, md); - count++; - COUNT_javalocals(javalocals, m, alloccount); - alloccount += iptr->s1.argcount; - if (iinfo) - alloccount -= iinfo->throughcount; - break; - - case ICMD_ISTORE: - case ICMD_LSTORE: - case ICMD_FSTORE: - case ICMD_DSTORE: - case ICMD_ASTORE: - stack_javalocals_store(iptr, javalocals); - break; - - case ICMD_IRETURN: - case ICMD_LRETURN: - case ICMD_FRETURN: - case ICMD_DRETURN: - case ICMD_ARETURN: - alloccount += 1; - /* FALLTHROUGH! */ - case ICMD_RETURN: - count++; - break; - - case ICMD_INLINE_START: - iinfo = iptr->sx.s23.s3.inlineinfo; - - count++; - COUNT_javalocals(javalocals, m, alloccount); - alloccount += iinfo->stackvarscount; - if (iinfo->synclocal != UNUSED) - alloccount++; - - m = iinfo->method; - /* javalocals may be set at next block start, or now */ - COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m); - break; - - case ICMD_INLINE_BODY: - assert(iinfo == iptr->sx.s23.s3.inlineinfo); - - jl = iinfo->javalocals_start; - if (jl == NULL) { - /* get the javalocals from the following block start */ - assert(bptr->next); - jl = bptr->next->javalocals; - } - count++; - COUNT_javalocals(jl, m, alloccount); - break; - - case ICMD_INLINE_END: - assert(iinfo == iptr->sx.s23.s3.inlineinfo || - iinfo == iptr->sx.s23.s3.inlineinfo->parent); - iinfo = iptr->sx.s23.s3.inlineinfo; - m = iinfo->outer; - if (iinfo->javalocals_end) - MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals); - iinfo = iinfo->parent; - break; - } - - if (iptr == bptr->iinstr) - firstcount = count; - } /* end instruction loop */ - - /* create replacement points at targets of backward branches */ - /* We only need the replacement point there, if there is no */ - /* replacement point inside the block. */ - - if (bptr->bitflags & BBFLAG_REPLACEMENT) { -#if defined(REPLACE_PATCH_DYNAMIC_CALL) - int test = (needentry && bptr == jd->basicblocks) ? firstcount : count; -#else - int test = count; -#endif - if (test > startcount) { - /* we don't need an extra rplpoint */ - bptr->bitflags &= ~BBFLAG_REPLACEMENT; - } - else { - count++; - alloccount += bptr->indepth; - if (bptr->inlineinfo) - alloccount -= bptr->inlineinfo->throughcount; - - COUNT_javalocals(bptr->javalocals, bptr->method, alloccount); - } - } - - } /* end basicblock loop */ - - /* if no points were found, there's nothing to do */ - - if (!count) - return true; - - /* allocate replacement point array and allocation array */ - - rplpoints = MNEW(rplpoint, count); - regalloc = MNEW(rplalloc, alloccount); - ra = regalloc; - - /* initialize replacement point structs */ - - rp = rplpoints; - - /* XXX try to share code with the counting loop! */ - - for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { - /* skip dead code */ - - if (bptr->flags < BBFINISHED) - continue; - - /* get info about this block */ - - m = bptr->method; - iinfo = bptr->inlineinfo; - - /* initialize javalocals at the start of this block */ - - COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m); - - /* create replacement points at targets of backward branches */ - - if (bptr->bitflags & BBFLAG_REPLACEMENT) { - - i = (iinfo) ? iinfo->throughcount : 0; - replace_create_replacement_point(jd, iinfo, rp++, - bptr->type, bptr->iinstr, &ra, - bptr->javalocals, bptr->invars + i, bptr->indepth - i, 0); - - if (JITDATA_HAS_FLAG_COUNTDOWN(jd)) - rp[-1].flags |= RPLPOINT_FLAG_COUNTDOWN; - } - - /* iterate over the instructions */ - - iptr = bptr->iinstr; - iend = iptr + bptr->icount; - - for (; iptr != iend; ++iptr) { - switch (iptr->opc) { -#if defined(ENABLE_GC_CACAO) - case ICMD_BUILTIN: - md = iptr->sx.s23.s3.bte->md; - - i = (iinfo) ? iinfo->throughcount : 0; - replace_create_replacement_point(jd, iinfo, rp++, - RPLPOINT_TYPE_CALL, iptr, &ra, - javalocals, iptr->sx.s23.s2.args, - iptr->s1.argcount - i, - md->paramcount); - break; -#endif - - case ICMD_INVOKESTATIC: - case ICMD_INVOKESPECIAL: - case ICMD_INVOKEVIRTUAL: - case ICMD_INVOKEINTERFACE: - INSTRUCTION_GET_METHODDESC(iptr, md); - - i = (iinfo) ? iinfo->throughcount : 0; - replace_create_replacement_point(jd, iinfo, rp++, - RPLPOINT_TYPE_CALL, iptr, &ra, - javalocals, iptr->sx.s23.s2.args, - iptr->s1.argcount - i, - md->paramcount); - break; - - case ICMD_ISTORE: - case ICMD_LSTORE: - case ICMD_FSTORE: - case ICMD_DSTORE: - case ICMD_ASTORE: - stack_javalocals_store(iptr, javalocals); - break; - - case ICMD_IRETURN: - case ICMD_LRETURN: - case ICMD_FRETURN: - case ICMD_DRETURN: - case ICMD_ARETURN: - replace_create_replacement_point(jd, iinfo, rp++, - RPLPOINT_TYPE_RETURN, iptr, &ra, - NULL, &(iptr->s1.varindex), 1, 0); - break; - - case ICMD_RETURN: - replace_create_replacement_point(jd, iinfo, rp++, - RPLPOINT_TYPE_RETURN, iptr, &ra, - NULL, NULL, 0, 0); - break; - - case ICMD_INLINE_START: - iinfo = replace_create_inline_start_replacement_point( - jd, rp++, iptr, &ra, javalocals); - m = iinfo->method; - /* javalocals may be set at next block start, or now */ - COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m); - break; - - case ICMD_INLINE_BODY: - assert(iinfo == iptr->sx.s23.s3.inlineinfo); - - jl = iinfo->javalocals_start; - if (jl == NULL) { - /* get the javalocals from the following block start */ - assert(bptr->next); - jl = bptr->next->javalocals; - } - /* create a non-trappable rplpoint */ - replace_create_replacement_point(jd, iinfo, rp++, - RPLPOINT_TYPE_BODY, iptr, &ra, - jl, NULL, 0, 0); - rp[-1].flags |= RPLPOINT_FLAG_NOTRAP; - break; - - case ICMD_INLINE_END: - assert(iinfo == iptr->sx.s23.s3.inlineinfo || - iinfo == iptr->sx.s23.s3.inlineinfo->parent); - iinfo = iptr->sx.s23.s3.inlineinfo; - m = iinfo->outer; - if (iinfo->javalocals_end) - MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals); - iinfo = iinfo->parent; - break; - } - } /* end instruction loop */ - } /* end basicblock loop */ - - assert((rp - rplpoints) == count); - assert((ra - regalloc) == alloccount); - - /* store the data in the codeinfo */ - - code->rplpoints = rplpoints; - code->rplpointcount = count; - code->regalloc = regalloc; - code->regalloccount = alloccount; - code->globalcount = 0; - code->savedintcount = INT_SAV_CNT - rd->savintreguse; - code->savedfltcount = FLT_SAV_CNT - rd->savfltreguse; -#if defined(HAS_ADDRESS_REGISTER_FILE) - code->savedadrcount = ADR_SAV_CNT - rd->savadrreguse; -#endif - code->memuse = rd->memuse; - code->stackframesize = jd->cd->stackframesize; - - REPLACE_COUNT_DIST(stat_dist_method_rplpoints, count); - REPLACE_COUNT_INC(stat_regallocs, alloccount); - - /* everything alright */ - - return true; -} - - -/* replace_free_replacement_points ********************************************* - - Free memory used by replacement points. - - IN: - code.............codeinfo whose replacement points should be freed. - -*******************************************************************************/ - -void replace_free_replacement_points(codeinfo *code) -{ - assert(code); - - if (code->rplpoints) - MFREE(code->rplpoints,rplpoint,code->rplpointcount); - - if (code->regalloc) - MFREE(code->regalloc,rplalloc,code->regalloccount); - - code->rplpoints = NULL; - code->rplpointcount = 0; - code->regalloc = NULL; - code->regalloccount = 0; - code->globalcount = 0; -} - - -/******************************************************************************/ -/* PART II: Activating / deactivating replacement points */ -/******************************************************************************/ - - -/* replace_activate_replacement_points ***************************************** - - Activate the replacement points of the given compilation unit. When this - function returns, the replacement points are "armed", so each thread - reaching one of the points will enter the replacement mechanism. - - IN: - code.............codeinfo of which replacement points should be - activated - mappable.........if true, only mappable replacement points are - activated - -*******************************************************************************/ - -void replace_activate_replacement_points(codeinfo *code, bool mappable) -{ - rplpoint *rp; - s4 i; - s4 count; - u1 *savedmcode; - - assert(code->savedmcode == NULL); - - /* count trappable replacement points */ - - count = 0; - i = code->rplpointcount; - rp = code->rplpoints; - for (; i--; rp++) { - if (rp->flags & RPLPOINT_FLAG_NOTRAP) - continue; - - if (mappable && (rp->type == RPLPOINT_TYPE_RETURN)) - continue; - - count++; - } - - /* allocate buffer for saved machine code */ - - savedmcode = MNEW(u1, count * REPLACEMENT_PATCH_SIZE); - code->savedmcode = savedmcode; - savedmcode += count * REPLACEMENT_PATCH_SIZE; - - /* activate trappable replacement points */ - /* (in reverse order to handle overlapping points within basic blocks) */ - - i = code->rplpointcount; - rp = code->rplpoints + i; - while (rp--, i--) { - assert(!(rp->flags & RPLPOINT_FLAG_ACTIVE)); - - if (rp->flags & RPLPOINT_FLAG_NOTRAP) - continue; - - if (mappable && (rp->type == RPLPOINT_TYPE_RETURN)) - continue; - - DOLOG( printf("activate replacement point:\n"); - replace_replacement_point_println(rp, 1); fflush(stdout); ); - - savedmcode -= REPLACEMENT_PATCH_SIZE; - -#if defined(ENABLE_JIT) -# if defined(ENABLE_DISASSEMBLER) - DOLOG( printf("\tinstruction before: "); - disassinstr(rp->pc); fflush(stdout); ); -# endif - - md_patch_replacement_point(rp->pc, savedmcode, false); - -# if defined(ENABLE_DISASSEMBLER) - DOLOG( printf("\tinstruction after : "); - disassinstr(rp->pc); fflush(stdout); ); -# endif -#endif - - rp->flags |= RPLPOINT_FLAG_ACTIVE; - } - - assert(savedmcode == code->savedmcode); -} - - -/* replace_deactivate_replacement_points *************************************** - - Deactivate a replacement points in the given compilation unit. - When this function returns, the replacement points will be "un-armed", - that is a each thread reaching a point will just continue normally. - - IN: - code.............the compilation unit - -*******************************************************************************/ - -void replace_deactivate_replacement_points(codeinfo *code) -{ - rplpoint *rp; - s4 i; - s4 count; - u1 *savedmcode; - - if (code->savedmcode == NULL) { - /* disarm countdown points by patching the branches */ - - i = code->rplpointcount; - rp = code->rplpoints; - for (; i--; rp++) { - if ((rp->flags & (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN)) - == RPLPOINT_FLAG_COUNTDOWN) - { -#if 0 - *(s4*) (rp->pc + 9) = 0; /* XXX machine dependent! */ -#endif - } - } - return; - } - - assert(code->savedmcode != NULL); - savedmcode = code->savedmcode; - - /* de-activate each trappable replacement point */ - - i = code->rplpointcount; - rp = code->rplpoints; - count = 0; - for (; i--; rp++) { - if (!(rp->flags & RPLPOINT_FLAG_ACTIVE)) - continue; - - count++; - - DOLOG( printf("deactivate replacement point:\n"); - replace_replacement_point_println(rp, 1); fflush(stdout); ); - -#if defined(ENABLE_JIT) -# if defined(ENABLE_DISASSEMBLER) - DOLOG( printf("\tinstruction before: "); - disassinstr(rp->pc); fflush(stdout); ); -# endif - - md_patch_replacement_point(rp->pc, savedmcode, true); - -# if defined(ENABLE_DISASSEMBLER) - DOLOG( printf("\tinstruction before: "); - disassinstr(rp->pc); fflush(stdout); ); -# endif -#endif - - rp->flags &= ~RPLPOINT_FLAG_ACTIVE; - - savedmcode += REPLACEMENT_PATCH_SIZE; - } - - assert(savedmcode == code->savedmcode + count * REPLACEMENT_PATCH_SIZE); - - /* free saved machine code */ - - MFREE(code->savedmcode, u1, count * REPLACEMENT_PATCH_SIZE); - code->savedmcode = NULL; -} - - -/******************************************************************************/ -/* PART III: The replacement mechanism */ -/******************************************************************************/ - - -/* replace_read_value ********************************************************** - - Read a value with the given allocation from the execution state. - - IN: - es...............execution state - ra...............allocation - javaval..........where to put the value - - OUT: - *javaval.........the value - -*******************************************************************************/ - -static void replace_read_value(executionstate_t *es, - rplalloc *ra, - replace_val_t *javaval) -{ - if (ra->flags & INMEMORY) { - /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */ -#ifdef HAS_4BYTE_STACKSLOT - if (IS_2_WORD_TYPE(ra->type)) { - javaval->l = *(u8*)(es->sp + ra->regoff); - } - else { -#endif - javaval->p = *(ptrint*)(es->sp + ra->regoff); -#ifdef HAS_4BYTE_STACKSLOT - } -#endif - } - else { - /* allocated register */ - if (IS_FLT_DBL_TYPE(ra->type)) { - javaval->d = es->fltregs[ra->regoff]; - - if (ra->type == TYPE_FLT) - javaval->f = javaval->d; - } -#if defined(HAS_ADDRESS_REGISTER_FILE) - else if (IS_ADR_TYPE(ra->type)) { - javaval->p = es->adrregs[ra->regoff]; - } -#endif - else { -#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS) - if (ra->type == TYPE_LNG) { - javaval->words.lo = es->intregs[GET_LOW_REG(ra->regoff)]; - javaval->words.hi = es->intregs[GET_HIGH_REG(ra->regoff)]; - } - else -#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */ - javaval->p = es->intregs[ra->regoff]; - } - } -} - - -/* replace_write_value ********************************************************* - - Write a value to the given allocation in the execution state. - - IN: - es...............execution state - ra...............allocation - *javaval.........the value - -*******************************************************************************/ - -static void replace_write_value(executionstate_t *es, - rplalloc *ra, - replace_val_t *javaval) -{ - if (ra->flags & INMEMORY) { - /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */ -#ifdef HAS_4BYTE_STACKSLOT - if (IS_2_WORD_TYPE(ra->type)) { - *(u8*)(es->sp + ra->regoff) = javaval->l; - } - else { -#endif - *(ptrint*)(es->sp + ra->regoff) = javaval->p; -#ifdef HAS_4BYTE_STACKSLOT - } -#endif - } - else { - /* allocated register */ - switch (ra->type) { - case TYPE_FLT: - es->fltregs[ra->regoff] = (double) javaval->f; - break; - case TYPE_DBL: - es->fltregs[ra->regoff] = javaval->d; - break; -#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS) - case TYPE_LNG: - es->intregs[GET_LOW_REG(ra->regoff)] = javaval->words.lo; - es->intregs[GET_HIGH_REG(ra->regoff)] = javaval->words.hi; - break; -#endif -#if defined(HAS_ADDRESS_REGISTER_FILE) - case TYPE_ADR: - es->adrregs[ra->regoff] = javaval->p; -#endif - default: - es->intregs[ra->regoff] = javaval->p; - } - } -} - - -/* replace_new_sourceframe ***************************************************** - - Allocate a new source frame and insert it at the front of the frame list. - - IN: - ss...............the source state - - OUT: - ss->frames.......set to new frame (the new head of the frame list). - - RETURN VALUE: - returns the new frame - -*******************************************************************************/ - -static sourceframe_t *replace_new_sourceframe(sourcestate_t *ss) -{ - sourceframe_t *frame; - - frame = DNEW(sourceframe_t); - MZERO(frame, sourceframe_t, 1); - - frame->down = ss->frames; - ss->frames = frame; - - return frame; -} - - -/* replace_read_executionstate ************************************************* - - Read a source frame from the given executions state. - The new source frame is pushed to the front of the frame list of the - source state. - - IN: - rp...............replacement point at which `es` was taken - es...............execution state - ss...............the source state to add the source frame to - topframe.........true, if the first (top-most) source frame on the - stack is to be read - - OUT: - *ss..............the source state with the newly created source frame - added - -*******************************************************************************/ - -static s4 replace_normalize_type_map[] = { -/* RPLPOINT_TYPE_STD |--> */ RPLPOINT_TYPE_STD, -/* RPLPOINT_TYPE_EXH |--> */ RPLPOINT_TYPE_STD, -/* RPLPOINT_TYPE_SBR |--> */ RPLPOINT_TYPE_STD, -/* RPLPOINT_TYPE_CALL |--> */ RPLPOINT_TYPE_CALL, -/* RPLPOINT_TYPE_INLINE |--> */ RPLPOINT_TYPE_CALL, -/* RPLPOINT_TYPE_RETURN |--> */ RPLPOINT_TYPE_RETURN, -/* RPLPOINT_TYPE_BODY |--> */ RPLPOINT_TYPE_STD -}; - - -static void replace_read_executionstate(rplpoint *rp, - executionstate_t *es, - sourcestate_t *ss, - bool topframe) -{ - methodinfo *m; - codeinfo *code; - int count; - int i; - rplalloc *ra; - sourceframe_t *frame; - int topslot; - stackslot_t *sp; - stackslot_t *basesp; - - code = code_find_codeinfo_for_pc(rp->pc); - m = rp->method; - topslot = TOP_IS_NORMAL; - - /* stack pointer */ - - sp = (stackslot_t *) es->sp; - - /* in some cases the top stack slot is passed in REG_ITMP1 */ - - if (rp->type == BBTYPE_EXH) { - topslot = TOP_IS_IN_ITMP1; - } - - /* calculate base stack pointer */ - - basesp = sp + code->stackframesize; - - /* create the source frame */ - - frame = replace_new_sourceframe(ss); - frame->method = rp->method; - frame->id = rp->id; - assert(rp->type >= 0 && rp->type < sizeof(replace_normalize_type_map)/sizeof(s4)); - frame->type = replace_normalize_type_map[rp->type]; - frame->fromrp = rp; - frame->fromcode = code; - - /* read local variables */ - - count = m->maxlocals; - frame->javalocalcount = count; - frame->javalocals = DMNEW(replace_val_t, count); - frame->javalocaltype = DMNEW(u1, count); - - /* mark values as undefined */ - for (i=0; ijavalocals[i].l = (u8) 0x00dead0000dead00ULL; -#endif - frame->javalocaltype[i] = TYPE_VOID; - } - - /* some entries in the intregs array are not meaningful */ - /*es->intregs[REG_ITMP3] = (u8) 0x11dead1111dead11ULL;*/ -#if !defined(NDEBUG) - es->intregs[REG_SP ] = (ptrint) 0x11dead1111dead11ULL; -#ifdef REG_PV - es->intregs[REG_PV ] = (ptrint) 0x11dead1111dead11ULL; -#endif -#endif /* !defined(NDEBUG) */ - - /* read javalocals */ - - count = rp->regalloccount; - ra = rp->regalloc; - - while (count && (i = ra->index) >= 0) { - assert(i < m->maxlocals); - frame->javalocaltype[i] = ra->type; - if (ra->type == TYPE_RET) - frame->javalocals[i].i = ra->regoff; - else - replace_read_value(es, ra, frame->javalocals + i); - ra++; - count--; - } - - /* read instance, if this is the first rplpoint */ - -#if defined(REPLACE_PATCH_DYNAMIC_CALL) - if (topframe && !(rp->method->flags & ACC_STATIC) && rp == code->rplpoints) { -#if 1 - /* we are at the start of the method body, so if local 0 is set, */ - /* it is the instance. */ - if (frame->javalocaltype[0] == TYPE_ADR) - frame->instance = frame->javalocals[0]; -#else - rplalloc instra; - methoddesc *md; - - md = rp->method->parseddesc; - assert(md->params); - assert(md->paramcount >= 1); - instra.type = TYPE_ADR; - instra.regoff = md->params[0].regoff; - if (md->params[0].inmemory) { - instra.flags = INMEMORY; - instra.regoff += (1 + code->stackframesize) * SIZE_OF_STACKSLOT; - } - else { - instra.flags = 0; - } - replace_read_value(es, &instra, &(frame->instance)); -#endif - } -#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */ - - /* read stack slots */ - - frame->javastackdepth = count; - frame->javastack = DMNEW(replace_val_t, count); - frame->javastacktype = DMNEW(u1, count); - -#if !defined(NDEBUG) - /* mark values as undefined */ - for (i=0; ijavastack[i].l = (u8) 0x00dead0000dead00ULL; - frame->javastacktype[i] = TYPE_VOID; - } -#endif /* !defined(NDEBUG) */ - - i = 0; - - /* the first stack slot is special in SBR and EXH blocks */ - - if (topslot == TOP_IS_ON_STACK) { - assert(count); - - assert(ra->index == RPLALLOC_STACK); - assert(ra->type == TYPE_ADR); - frame->javastack[i].p = sp[-1]; - frame->javastacktype[i] = TYPE_ADR; /* XXX RET */ - count--; - i++; - ra++; - } - else if (topslot == TOP_IS_IN_ITMP1) { - assert(count); - - assert(ra->index == RPLALLOC_STACK); - assert(ra->type == TYPE_ADR); - frame->javastack[i].p = es->intregs[REG_ITMP1]; - frame->javastacktype[i] = TYPE_ADR; /* XXX RET */ - count--; - i++; - ra++; - } - else if (topslot == TOP_IS_VOID) { - assert(count); - - assert(ra->index == RPLALLOC_STACK); - frame->javastack[i].l = 0; - frame->javastacktype[i] = TYPE_VOID; - count--; - i++; - ra++; - } - - /* read remaining stack slots */ - - for (; count--; ra++) { - if (ra->index == RPLALLOC_SYNC) { - assert(rp->type == RPLPOINT_TYPE_INLINE); - - /* only read synchronization slots when traversing an inline point */ - - if (!topframe) { - sourceframe_t *calleeframe = frame->down; - assert(calleeframe); - assert(calleeframe->syncslotcount == 0); - assert(calleeframe->syncslots == NULL); - - calleeframe->syncslotcount = 1; - calleeframe->syncslots = DMNEW(replace_val_t, 1); - replace_read_value(es,ra,calleeframe->syncslots); - } - - frame->javastackdepth--; - continue; - } - - assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM); - - /* do not read parameters of calls down the call chain */ - - if (!topframe && ra->index == RPLALLOC_PARAM) { - frame->javastackdepth--; - } - else { - if (ra->type == TYPE_RET) - frame->javastack[i].i = ra->regoff; - else - replace_read_value(es,ra,frame->javastack + i); - frame->javastacktype[i] = ra->type; - i++; - } - } -} - - -/* replace_write_executionstate ************************************************ - - Pop a source frame from the front of the frame list of the given source state - and write its values into the execution state. - - IN: - rp...............replacement point for which execution state should be - created - es...............the execution state to modify - ss...............the given source state - topframe.........true, if this is the last (top-most) source frame to be - translated - - OUT: - *es..............the execution state derived from the source state - -*******************************************************************************/ - -static void replace_write_executionstate(rplpoint *rp, - executionstate_t *es, - sourcestate_t *ss, - bool topframe) -{ - methodinfo *m; - codeinfo *code; - int count; - int i; - rplalloc *ra; - sourceframe_t *frame; - int topslot; - stackslot_t *sp; - stackslot_t *basesp; - - code = code_find_codeinfo_for_pc(rp->pc); - m = rp->method; - topslot = TOP_IS_NORMAL; - - /* pop a source frame */ - - frame = ss->frames; - assert(frame); - ss->frames = frame->down; - - /* calculate stack pointer */ - - sp = (stackslot_t *) es->sp; - - basesp = sp + code->stackframesize; - - /* in some cases the top stack slot is passed in REG_ITMP1 */ - - if (rp->type == BBTYPE_EXH) { - topslot = TOP_IS_IN_ITMP1; - } - - /* write javalocals */ - - ra = rp->regalloc; - count = rp->regalloccount; - - while (count && (i = ra->index) >= 0) { - assert(i < m->maxlocals); - assert(i < frame->javalocalcount); - assert(ra->type == frame->javalocaltype[i]); - if (ra->type == TYPE_RET) { - /* XXX assert that it matches this rplpoint */ - } - else - replace_write_value(es, ra, frame->javalocals + i); - count--; - ra++; - } - - /* write stack slots */ - - i = 0; - - /* the first stack slot is special in SBR and EXH blocks */ - - if (topslot == TOP_IS_ON_STACK) { - assert(count); - - assert(ra->index == RPLALLOC_STACK); - assert(i < frame->javastackdepth); - assert(frame->javastacktype[i] == TYPE_ADR); - sp[-1] = frame->javastack[i].p; - count--; - i++; - ra++; - } - else if (topslot == TOP_IS_IN_ITMP1) { - assert(count); - - assert(ra->index == RPLALLOC_STACK); - assert(i < frame->javastackdepth); - assert(frame->javastacktype[i] == TYPE_ADR); - es->intregs[REG_ITMP1] = frame->javastack[i].p; - count--; - i++; - ra++; - } - else if (topslot == TOP_IS_VOID) { - assert(count); - - assert(ra->index == RPLALLOC_STACK); - assert(i < frame->javastackdepth); - assert(frame->javastacktype[i] == TYPE_VOID); - count--; - i++; - ra++; - } - - /* write remaining stack slots */ - - for (; count--; ra++) { - if (ra->index == RPLALLOC_SYNC) { - assert(rp->type == RPLPOINT_TYPE_INLINE); - - /* only write synchronization slots when traversing an inline point */ - - if (!topframe) { - assert(frame->down); - assert(frame->down->syncslotcount == 1); /* XXX need to understand more cases */ - assert(frame->down->syncslots != NULL); - - replace_write_value(es,ra,frame->down->syncslots); - } - continue; - } - - assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM); - - /* do not write parameters of calls down the call chain */ - - if (!topframe && ra->index == RPLALLOC_PARAM) { - /* skip it */ - } - else { - assert(i < frame->javastackdepth); - assert(ra->type == frame->javastacktype[i]); - if (ra->type == TYPE_RET) { - /* XXX assert that it matches this rplpoint */ - } - else { - replace_write_value(es,ra,frame->javastack + i); - } - i++; - } - } - - /* set new pc */ - - es->pc = rp->pc; -} - - -/* replace_pop_activation_record *********************************************** - - Peel a stack frame from the execution state. - - *** This function imitates the effects of the method epilog *** - *** and returning from the method call. *** - - IN: - es...............execution state - frame............source frame, receives synchronization slots - - OUT: - *es..............the execution state after popping the stack frame - -*******************************************************************************/ - -u1* replace_pop_activation_record(executionstate_t *es, - sourceframe_t *frame) -{ - u1 *ra; - u1 *pv; - s4 reg; - s4 i; - s4 count; - codeinfo *code; - stackslot_t *basesp; - stackslot_t *sp; - - assert(es->code); - assert(frame); - - /* read the return address */ - -#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) - if (code_is_leafmethod(es->code)) - ra = (u1*) (ptrint) es->intregs[REPLACE_REG_RA]; - else -#endif - ra = md_stacktrace_get_returnaddress(es->sp, - SIZE_OF_STACKSLOT * es->code->stackframesize); - - DOLOG( printf("RA = %p\n", (void*)ra); ); - - assert(ra); - - /* calculate the base of the stack frame */ - - sp = (stackslot_t *) es->sp; - basesp = sp + es->code->stackframesize; - - /* read slots used for synchronization */ - - assert(frame->syncslotcount == 0); - assert(frame->syncslots == NULL); - count = code_get_sync_slot_count(es->code); - frame->syncslotcount = count; - frame->syncslots = DMNEW(replace_val_t, count); - for (i=0; isyncslots[i].p = sp[es->code->memuse + i]; /* XXX */ - } - - /* restore return address, if part of frame */ - -#if defined(REPLACE_RA_TOP_OF_FRAME) -#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) - if (!code_is_leafmethod(es->code)) -#endif - es->intregs[REPLACE_REG_RA] = *--basesp; -#endif /* REPLACE_RA_TOP_OF_FRAME */ - -#if defined(REPLACE_RA_LINKAGE_AREA) -#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) - if (!code_is_leafmethod(es->code)) -#endif - es->intregs[REPLACE_REG_RA] = basesp[LA_LR_OFFSET / sizeof(stackslot_t)]; -#endif /* REPLACE_RA_LINKAGE_AREA */ - - /* restore saved int registers */ - - reg = INT_REG_CNT; - for (i=0; icode->savedintcount; ++i) { - while (nregdescint[--reg] != REG_SAV) - ; - es->intregs[reg] = *--basesp; - } - - /* restore saved flt registers */ - - /* XXX align? */ - reg = FLT_REG_CNT; - for (i=0; icode->savedfltcount; ++i) { - while (nregdescfloat[--reg] != REG_SAV) - ; - basesp -= STACK_SLOTS_PER_FLOAT; - es->fltregs[reg] = *(double*)basesp; - } - -#if defined(HAS_ADDRESS_REGISTER_FILE) - /* restore saved adr registers */ - - reg = ADR_REG_CNT; - for (i=0; icode->savedadrcount; ++i) { - while (nregdescadr[--reg] != REG_SAV) - ; - es->adrregs[reg] = *--basesp; - } -#endif - - /* adjust the stackpointer */ - - es->sp += SIZE_OF_STACKSLOT * es->code->stackframesize; - -#if defined(REPLACE_RA_BETWEEN_FRAMES) - es->sp += SIZE_OF_STACKSLOT; /* skip return address */ -#endif - - /* Set the new pc. Subtract one so we do not hit the replacement point */ - /* of the instruction following the call, if there is one. */ - - es->pc = ra - 1; - - /* find the new codeinfo */ - - pv = md_codegen_get_pv_from_pc(ra); - DOLOG( printf("PV = %p\n", (void*) pv); ); - - code = code_get_codeinfo_for_pv(pv); - DOLOG( printf("CODE = %p\n", (void*) code); ); - - /* return NULL if we reached native code */ - - es->pv = pv; - es->code = code; - - /* in debugging mode clobber non-saved registers */ - -#if !defined(NDEBUG) - /* for debugging */ - for (i=0; iintregs[i] = (ptrint) 0x33dead3333dead33ULL; - for (i=0; ifltregs[i]) = 0x33dead3333dead33ULL; -# if defined(HAS_ADDRESS_REGISTER_FILE) - for (i=0; iadrregs[i] = (ptrint) 0x33dead3333dead33ULL; -# endif -#endif /* !defined(NDEBUG) */ - - return (code) ? ra : NULL; -} - - -/* replace_patch_method_pointer ************************************************ - - Patch a method pointer (may be in code, data segment, vftbl, or interface - table). - - IN: - mpp..............address of the method pointer to patch - entrypoint.......the new entrypoint of the method - kind.............kind of call to patch, used only for debugging - -*******************************************************************************/ - -static void replace_patch_method_pointer(methodptr *mpp, - methodptr entrypoint, - const char *kind) -{ -#if !defined(NDEBUG) - codeinfo *oldcode; - codeinfo *newcode; -#endif - - DOLOG( printf("patch method pointer from: %p to %p\n", - (void*) *mpp, (void*)entrypoint); ); - -#if !defined(NDEBUG) - oldcode = code_get_codeinfo_for_pv(*mpp); - newcode = code_get_codeinfo_for_pv(entrypoint); - - DOLOG_SHORT( printf("\tpatch %s %p ", kind, (void*) oldcode); - method_println(oldcode->m); - printf("\t with %p ", (void*) newcode); - method_println(newcode->m); ); - - assert(oldcode->m == newcode->m); -#endif - - /* write the new entrypoint */ - - *mpp = (methodptr) entrypoint; -} - - -/* replace_patch_class ********************************************************* - - Patch a method in the given class. - - IN: - vftbl............vftbl of the class - m................the method to patch - oldentrypoint....the old entrypoint to replace - entrypoint.......the new entrypoint - -*******************************************************************************/ - -void replace_patch_class(vftbl_t *vftbl, - methodinfo *m, - u1 *oldentrypoint, - u1 *entrypoint) -{ - s4 i; - methodptr *mpp; - methodptr *mppend; - - /* patch the vftbl of the class */ - - replace_patch_method_pointer(vftbl->table + m->vftblindex, - entrypoint, - "virtual "); - - /* patch the interface tables */ - - assert(oldentrypoint); - - for (i=0; i < vftbl->interfacetablelength; ++i) { - mpp = vftbl->interfacetable[-i]; - mppend = mpp + vftbl->interfacevftbllength[i]; - for (; mpp != mppend; ++mpp) - if (*mpp == oldentrypoint) { - replace_patch_method_pointer(mpp, entrypoint, "interface"); - } - } -} - - -/* replace_patch_class_hierarchy *********************************************** - - Patch a method in all loaded classes. - - IN: - m................the method to patch - oldentrypoint....the old entrypoint to replace - entrypoint.......the new entrypoint - -*******************************************************************************/ - -struct replace_patch_data_t { - methodinfo *m; - u1 *oldentrypoint; - u1 *entrypoint; -}; - -void replace_patch_callback(classinfo *c, struct replace_patch_data_t *pd) -{ - vftbl_t *vftbl = c->vftbl; - - if (vftbl != NULL - && vftbl->vftbllength > pd->m->vftblindex - && vftbl->table[pd->m->vftblindex] != &asm_abstractmethoderror - && code_get_methodinfo_for_pv(vftbl->table[pd->m->vftblindex]) == pd->m) - { - replace_patch_class(c->vftbl, pd->m, pd->oldentrypoint, pd->entrypoint); - } -} - -void replace_patch_class_hierarchy(methodinfo *m, - u1 *oldentrypoint, - u1 *entrypoint) -{ - struct replace_patch_data_t pd; - - pd.m = m; - pd.oldentrypoint = oldentrypoint; - pd.entrypoint = entrypoint; - - DOLOG_SHORT( printf("patching class hierarchy: "); - method_println(m); ); - - classcache_foreach_loaded_class( - (classcache_foreach_functionptr_t) &replace_patch_callback, - (void*) &pd); -} - - -/* replace_patch_future_calls ************************************************** - - Analyse a call site and depending on the kind of call patch the call, the - virtual function table, or the interface table. - - IN: - ra...............return address pointing after the call site - callerframe......source frame of the caller - calleeframe......source frame of the callee, must have been mapped - -*******************************************************************************/ - -void replace_patch_future_calls(u1 *ra, - sourceframe_t *callerframe, - sourceframe_t *calleeframe) -{ - u1 *patchpos; - methodptr entrypoint; - methodptr oldentrypoint; - bool atentry; - void *pv; - codeinfo *calleecode; - methodinfo *calleem; - java_object_t *obj; - vftbl_t *vftbl; - - assert(ra); - assert(callerframe->down == calleeframe); - - /* get the new codeinfo and the method that shall be entered */ - - calleecode = calleeframe->tocode; - assert(calleecode); - - calleem = calleeframe->method; - assert(calleem == calleecode->m); - - entrypoint = (methodptr) calleecode->entrypoint; - - /* check if we are at an method entry rplpoint at the innermost frame */ - - atentry = (calleeframe->down == NULL) - && !(calleem->flags & ACC_STATIC) - && (calleeframe->fromrp->id == 0); /* XXX */ - - /* get the position to patch, in case it was a statically bound call */ - - pv = callerframe->fromcode->entrypoint; - patchpos = md_jit_method_patch_address(pv, ra, NULL); - - if (patchpos == NULL) { - /* the call was dispatched dynamically */ - - /* we can only patch such calls if we are at the entry point */ - - if (!atentry) - return; - - assert((calleem->flags & ACC_STATIC) == 0); - - oldentrypoint = calleeframe->fromcode->entrypoint; - - /* we need to know the instance */ - - if (!calleeframe->instance.a) { - DOLOG_SHORT( printf("WARNING: object instance unknown!\n"); ); - replace_patch_class_hierarchy(calleem, oldentrypoint, entrypoint); - return; - } - - /* get the vftbl */ - - obj = calleeframe->instance.a; - vftbl = obj->vftbl; - - assert(vftbl->clazz->vftbl == vftbl); - - DOLOG_SHORT( printf("\tclass: "); class_println(vftbl->clazz); ); - - replace_patch_class(vftbl, calleem, oldentrypoint, entrypoint); - } - else { - /* the call was statically bound */ - - replace_patch_method_pointer((methodptr *) patchpos, entrypoint, "static "); - } -} - - -/* replace_push_activation_record ********************************************** - - Push a stack frame onto the execution state. - - *** This function imitates the effects of a call and the *** - *** method prolog of the callee. *** - - IN: - es...............execution state - rpcall...........the replacement point at the call site - callerframe......source frame of the caller, or NULL for creating the - first frame - calleeframe......source frame of the callee, must have been mapped - - OUT: - *es..............the execution state after pushing the stack frame - -*******************************************************************************/ - -void replace_push_activation_record(executionstate_t *es, - rplpoint *rpcall, - sourceframe_t *callerframe, - sourceframe_t *calleeframe) -{ - s4 reg; - s4 i; - s4 count; - stackslot_t *basesp; - stackslot_t *sp; - u1 *ra; - codeinfo *calleecode; - - assert(es); - assert(!rpcall || callerframe); - assert(!rpcall || rpcall->type == RPLPOINT_TYPE_CALL); - assert(!rpcall || rpcall == callerframe->torp); - assert(calleeframe); - assert(!callerframe || calleeframe == callerframe->down); - - /* the compilation unit we are entering */ - - calleecode = calleeframe->tocode; - assert(calleecode); - - /* calculate the return address */ - - if (rpcall) - ra = rpcall->pc + rpcall->callsize; - else - ra = es->pc + 1 /* XXX this is ugly */; - - /* write the return address */ - -#if defined(REPLACE_RA_BETWEEN_FRAMES) - es->sp -= SIZE_OF_STACKSLOT; - - *((stackslot_t *)es->sp) = (stackslot_t) ra; -#endif /* REPLACE_RA_BETWEEN_FRAMES */ - -#if defined(REPLACE_REG_RA) - es->intregs[REPLACE_REG_RA] = (ptrint) ra; -#endif - - /* we move into a new code unit */ - - es->code = calleecode; - - /* set the new pc XXX not needed? */ - - es->pc = calleecode->entrypoint; - - /* build the stackframe */ - - DOLOG( printf("building stackframe of %d words at %p\n", - calleecode->stackframesize, (void*)es->sp); ); - - sp = (stackslot_t *) es->sp; - basesp = sp; - - sp -= calleecode->stackframesize; - es->sp = (u1*) sp; - - /* in debug mode, invalidate stack frame first */ - - /* XXX may not invalidate linkage area used by native code! */ -#if !defined(NDEBUG) && 0 - for (i=0; i<(basesp - sp); ++i) { - sp[i] = 0xdeaddeadU; - } -#endif - - /* save the return address register */ - -#if defined(REPLACE_RA_TOP_OF_FRAME) -#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) - if (!code_is_leafmethod(calleecode)) -#endif - *--basesp = (ptrint) ra; -#endif /* REPLACE_RA_TOP_OF_FRAME */ - -#if defined(REPLACE_RA_LINKAGE_AREA) -#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) - if (!code_is_leafmethod(calleecode)) -#endif - basesp[LA_LR_OFFSET / sizeof(stackslot_t)] = (ptrint) ra; -#endif /* REPLACE_RA_LINKAGE_AREA */ - - /* save int registers */ - - reg = INT_REG_CNT; - for (i=0; isavedintcount; ++i) { - while (nregdescint[--reg] != REG_SAV) - ; - *--basesp = es->intregs[reg]; - - /* XXX may not clobber saved regs used by native code! */ -#if !defined(NDEBUG) && 0 - es->intregs[reg] = (ptrint) 0x44dead4444dead44ULL; -#endif - } - - /* save flt registers */ - - /* XXX align? */ - reg = FLT_REG_CNT; - for (i=0; isavedfltcount; ++i) { - while (nregdescfloat[--reg] != REG_SAV) - ; - basesp -= STACK_SLOTS_PER_FLOAT; - *(double*)basesp = es->fltregs[reg]; - - /* XXX may not clobber saved regs used by native code! */ -#if !defined(NDEBUG) && 0 - *(u8*)&(es->fltregs[reg]) = 0x44dead4444dead44ULL; -#endif - } - -#if defined(HAS_ADDRESS_REGISTER_FILE) - /* save adr registers */ - - reg = ADR_REG_CNT; - for (i=0; isavedadrcount; ++i) { - while (nregdescadr[--reg] != REG_SAV) - ; - *--basesp = es->adrregs[reg]; - - /* XXX may not clobber saved regs used by native code! */ -#if !defined(NDEBUG) && 0 - es->adrregs[reg] = (ptrint) 0x44dead4444dead44ULL; -#endif - } -#endif - - /* write slots used for synchronization */ - - count = code_get_sync_slot_count(calleecode); - assert(count == calleeframe->syncslotcount); - for (i=0; imemuse + i] = calleeframe->syncslots[i].p; - } - - /* set the PV */ - - es->pv = calleecode->entrypoint; - - /* redirect future invocations */ - - if (callerframe && rpcall) { -#if defined(REPLACE_PATCH_ALL) - if (rpcall->type == callerframe->fromrp->type) -#else - if (rpcall == callerframe->fromrp) -#endif - replace_patch_future_calls(ra, callerframe, calleeframe); - } -} - - -/* replace_find_replacement_point ********************************************** - - Find the replacement point in the given code corresponding to the - position given in the source frame. - - IN: - code.............the codeinfo in which to search the rplpoint - frame............the source frame defining the position to look for - parent...........parent replacement point to match - - RETURN VALUE: - the replacement point - -*******************************************************************************/ - -rplpoint * replace_find_replacement_point(codeinfo *code, - sourceframe_t *frame, - rplpoint *parent) -{ - methodinfo *m; - rplpoint *rp; - s4 i; - s4 j; - s4 stacki; - rplalloc *ra; - - assert(code); - assert(frame); - - DOLOG( printf("searching replacement point for:\n"); - replace_source_frame_println(frame); ); - - m = frame->method; - - DOLOG( printf("code = %p\n", (void*)code); ); - - rp = code->rplpoints; - i = code->rplpointcount; - while (i--) { - if (rp->id == frame->id && rp->method == frame->method - && rp->parent == parent - && replace_normalize_type_map[rp->type] == frame->type) - { - /* check if returnAddresses match */ - /* XXX optimize: only do this if JSRs in method */ - DOLOG( printf("checking match for:"); - replace_replacement_point_println(rp, 1); fflush(stdout); ); - ra = rp->regalloc; - stacki = 0; - for (j = rp->regalloccount; j--; ++ra) { - if (ra->type == TYPE_RET) { - if (ra->index == RPLALLOC_STACK) { - assert(stacki < frame->javastackdepth); - if (frame->javastack[stacki].i != ra->regoff) - goto no_match; - stacki++; - } - else { - assert(ra->index >= 0 && ra->index < frame->javalocalcount); - if (frame->javalocals[ra->index].i != ra->regoff) - goto no_match; - } - } - } - - /* found */ - return rp; - } -no_match: - rp++; - } - -#if !defined(NDEBUG) - printf("candidate replacement points were:\n"); - rp = code->rplpoints; - i = code->rplpointcount; - for (; i--; ++rp) { - replace_replacement_point_println(rp, 1); - } -#endif - - vm_abort("no matching replacement point found"); - return NULL; /* NOT REACHED */ -} - - -/* replace_find_replacement_point_for_pc *************************************** - - Find the nearest replacement point at or before the given PC. The - given PC has to be between (rp->pc) and (rp->pc+rp->callsize) for - the replacement point to be found. - - IN: - code.............compilation unit the PC is in - pc...............the machine code PC - - RETURN VALUE: - the replacement point found, or - NULL if no replacement point was found - -*******************************************************************************/ - -rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc) -{ - rplpoint *found; - rplpoint *rp; - s4 i; - - DOLOG( printf("searching for rp at pc:%p in %p ", (void*)pc, (void*)code); - method_println(code->m); ); - - found = NULL; - - rp = code->rplpoints; - for (i=0; irplpointcount; ++i, ++rp) { - DOLOG( replace_replacement_point_println(rp, 2); ); - if (rp->pc <= pc && rp->pc + rp->callsize >= pc) - found = rp; - } - - return found; -} - - -/* replace_pop_native_frame **************************************************** - - Unroll a native frame in the execution state and create a source frame - for it. - - IN: - es...............current execution state - ss...............the current source state - sfi..............stackframeinfo for the native frame - - OUT: - es...............execution state after unrolling the native frame - ss...............gets the added native source frame - -*******************************************************************************/ - -static void replace_pop_native_frame(executionstate_t *es, - sourcestate_t *ss, - stackframeinfo_t *sfi) -{ - sourceframe_t *frame; - codeinfo *code; - s4 i,j; - - assert(sfi); - - frame = replace_new_sourceframe(ss); - - frame->sfi = sfi; - - /* remember pc and size of native frame */ - - frame->nativepc = es->pc; - frame->nativeframesize = (es->sp != 0) ? (sfi->sp - es->sp) : 0; - assert(frame->nativeframesize >= 0); - - /* remember values of saved registers */ - - j = 0; - for (i=0; inativesavint[j++] = es->intregs[i]; - } - - j = 0; - for (i=0; inativesavflt[j++] = es->fltregs[i]; - } - -#if defined(HAS_ADDRESS_REGISTER_FILE) - j = 0; - for (i=0; inativesavadr[j++] = es->adrregs[i]; - } -#endif - - /* restore saved registers */ - -#if defined(ENABLE_GC_CACAO) && !defined(HAS_ADDRESS_REGISTER_FILE) - j = 0; - for (i=0; iintregs[i] = sfi->intregs[j++]; - } -#else - /* XXX we don't have them, yet, in the sfi, so clear them */ - - for (i=0; iintregs[i] = 0; - } -#endif - - /* XXX we don't have float registers in the sfi, so clear them */ - - for (i=0; ifltregs[i] = 0.0; - } - -#if defined(HAS_ADDRESS_REGISTER_FILE) -# if defined(ENABLE_GC_CACAO) - j = 0; - for (i=0; iadrregs[i] = sfi->adrregs[j++]; - } -# else - for (i=0; iadrregs[i] = 0; - } -# endif -#endif - - /* restore codeinfo of the native stub */ - - code = code_get_codeinfo_for_pv(sfi->pv); - - /* restore sp, pv, pc and codeinfo of the parent method */ - - /* XXX michi: use this instead: - es->sp = sfi->sp + code->stackframesize; */ - es->sp = sfi->sp + (*(s4 *) (sfi->pv + FrameSize)); -#if defined(REPLACE_RA_BETWEEN_FRAMES) - es->sp += SIZE_OF_STACKSLOT; /* skip return address */ -#endif - es->pv = md_codegen_get_pv_from_pc(sfi->ra); - es->pc = ((sfi->xpc) ? sfi->xpc : sfi->ra) - 1; - es->code = code_get_codeinfo_for_pv(es->pv); -} - - -/* replace_push_native_frame *************************************************** - - Rebuild a native frame onto the execution state and remove its source frame. - - Note: The native frame is "rebuild" by setting fields like PC and stack - pointer in the execution state accordingly. Values in the - stackframeinfo may be modified, but the actual stack frame of the - native code is not touched. - - IN: - es...............current execution state - ss...............the current source state - - OUT: - es...............execution state after re-rolling the native frame - ss...............the native source frame is removed - -*******************************************************************************/ - -static void replace_push_native_frame(executionstate_t *es, sourcestate_t *ss) -{ - sourceframe_t *frame; - s4 i,j; - - assert(es); - assert(ss); - - DOLOG( printf("pushing native frame\n"); ); - - /* remove the frame from the source state */ - - frame = ss->frames; - assert(frame); - assert(REPLACE_IS_NATIVE_FRAME(frame)); - - ss->frames = frame->down; - - /* skip sp for the native stub */ - - es->sp -= (*(s4 *) (frame->sfi->pv + FrameSize)); -#if defined(REPLACE_RA_BETWEEN_FRAMES) - es->sp -= SIZE_OF_STACKSLOT; /* skip return address */ -#endif - - /* assert that the native frame has not moved */ - - assert(es->sp == frame->sfi->sp); - - /* update saved registers in the stackframeinfo */ - -#if defined(ENABLE_GC_CACAO) - j = 0; -# if !defined(HAS_ADDRESS_REGISTER_FILE) - for (i=0; isfi->intregs[j++] = es->intregs[i]; - } -# else - for (i=0; isfi->adrregs[j++] = es->adrregs[i]; - } -# endif - - /* XXX leave float registers untouched here */ -#endif - - /* restore saved registers */ - - j = 0; - for (i=0; iintregs[i] = frame->nativesavint[j++]; - } - - j = 0; - for (i=0; ifltregs[i] = frame->nativesavflt[j++]; - } - -#if defined(HAS_ADDRESS_REGISTER_FILE) - j = 0; - for (i=0; iadrregs[i] = frame->nativesavadr[j++]; - } -#endif - - /* skip the native frame on the machine stack */ - - es->sp -= frame->nativeframesize; - - /* set the pc the next frame must return to */ - - es->pc = frame->nativepc; -} - - -/* replace_recover_source_state ************************************************ - - Recover the source state from the given replacement point and execution - state. - - IN: - rp...............replacement point that has been reached, if any - sfi..............stackframeinfo, if called from native code - es...............execution state at the replacement point rp - - RETURN VALUE: - the source state - -*******************************************************************************/ - -sourcestate_t *replace_recover_source_state(rplpoint *rp, - stackframeinfo_t *sfi, - executionstate_t *es) -{ - sourcestate_t *ss; - u1 *ra; - bool locked; -#if defined(REPLACE_STATISTICS) - s4 depth; -#endif - - /* create the source frame structure in dump memory */ - - ss = DNEW(sourcestate_t); - ss->frames = NULL; - - /* each iteration of the loop recovers one source frame */ - - depth = 0; - locked = false; - - while (rp || sfi) { - - DOLOG( executionstate_println(es); ); - - /* if we are not at a replacement point, it is a native frame */ - - if (rp == NULL) { - DOLOG( printf("native frame: sfi: "); replace_stackframeinfo_println(sfi); ); - - locked = true; - replace_pop_native_frame(es, ss, sfi); - sfi = sfi->prev; - - if (es->code == NULL) - continue; - - goto after_machine_frame; - } - - /* read the values for this source frame from the execution state */ - - DOLOG( printf("recovering source state for%s:\n", - (ss->frames == NULL) ? " TOPFRAME" : ""); - replace_replacement_point_println(rp, 1); ); - - replace_read_executionstate(rp, es, ss, ss->frames == NULL); - -#if defined(ENABLE_VMLOG) - vmlog_cacao_unrol_method(ss->frames->method); -#endif - -#if defined(REPLACE_STATISTICS) - REPLACE_COUNT(stat_frames); - depth++; - replace_statistics_source_frame(ss->frames); -#endif - - /* in locked areas (below native frames), identity map the frame */ - - if (locked) { - ss->frames->torp = ss->frames->fromrp; - ss->frames->tocode = ss->frames->fromcode; - } - - /* unroll to the next (outer) frame */ - - if (rp->parent) { - /* this frame is in inlined code */ - - DOLOG( printf("INLINED!\n"); ); - - rp = rp->parent; - - assert(rp->type == RPLPOINT_TYPE_INLINE); - REPLACE_COUNT(stat_unroll_inline); - } - else { - /* this frame had been called at machine-level. pop it. */ - - DOLOG( printf("UNWIND\n"); ); - - ra = replace_pop_activation_record(es, ss->frames); - if (ra == NULL) { - DOLOG( printf("REACHED NATIVE CODE\n"); ); - - rp = NULL; - -#if !defined(ENABLE_GC_CACAO) - break; /* XXX remove to activate native frames */ -#endif - continue; - } - - /* find the replacement point at the call site */ - -after_machine_frame: - rp = replace_find_replacement_point_for_pc(es->code, es->pc); - - if (rp == NULL) - vm_abort("could not find replacement point while unrolling call"); - - DOLOG( printf("found replacement point.\n"); - replace_replacement_point_println(rp, 1); ); - - assert(rp->type == RPLPOINT_TYPE_CALL); - REPLACE_COUNT(stat_unroll_call); - } - } /* end loop over source frames */ - - REPLACE_COUNT_DIST(stat_dist_frames, depth); - - return ss; -} - - -/* replace_map_source_state **************************************************** - - Map each source frame in the given source state to a target replacement - point and compilation unit. If no valid code is available for a source - frame, it is (re)compiled. - - IN: - ss...............the source state - - OUT: - ss...............the source state, modified: The `torp` and `tocode` - fields of each source frame are set. - - RETURN VALUE: - true.............everything went ok - false............an exception has been thrown - -*******************************************************************************/ - -static bool replace_map_source_state(sourcestate_t *ss) -{ - sourceframe_t *frame; - codeinfo *code; - rplpoint *rp; - rplpoint *parent; /* parent of inlined rplpoint */ -#if defined(REPLACE_STATISTICS) - codeinfo *oldcode; -#endif - - parent = NULL; - code = NULL; - - /* iterate over the source frames from outermost to innermost */ - - for (frame = ss->frames; frame != NULL; frame = frame->down) { - - /* XXX skip native frames */ - - if (REPLACE_IS_NATIVE_FRAME(frame)) { - parent = NULL; - continue; - } - - /* map frames which are not already mapped */ - - if (frame->tocode) { - code = frame->tocode; - rp = frame->torp; - assert(rp); - } - else { - assert(frame->torp == NULL); - - if (parent == NULL) { - /* find code for this frame */ - -#if defined(REPLACE_STATISTICS) - oldcode = frame->method->code; -#endif - /* request optimization of hot methods and their callers */ - - if (frame->method->hitcountdown < 0 - || (frame->down && frame->down->method->hitcountdown < 0)) - jit_request_optimization(frame->method); - - code = jit_get_current_code(frame->method); - - if (code == NULL) - return false; /* exception */ - - REPLACE_COUNT_IF(stat_recompile, code != oldcode); - } - - assert(code); - - /* map this frame */ - - rp = replace_find_replacement_point(code, frame, parent); - - frame->tocode = code; - frame->torp = rp; - } - - if (rp->type == RPLPOINT_TYPE_CALL) { - parent = NULL; - } - else { - /* inlining */ - parent = rp; - } - } - - return true; -} - - -/* replace_map_source_state_identity ******************************************* - - Map each source frame in the given source state to the same replacement - point and compilation unit it was derived from. This is mainly used for - garbage collection. - - IN: - ss...............the source state - - OUT: - ss...............the source state, modified: The `torp` and `tocode` - fields of each source frame are set. - -*******************************************************************************/ - -#if defined(ENABLE_GC_CACAO) -static void replace_map_source_state_identity(sourcestate_t *ss) -{ - sourceframe_t *frame; - - /* iterate over the source frames from outermost to innermost */ - - for (frame = ss->frames; frame != NULL; frame = frame->down) { - - /* skip native frames */ - - if (REPLACE_IS_NATIVE_FRAME(frame)) { - continue; - } - - /* map frames using the identity mapping */ - - if (frame->tocode) { - assert(frame->tocode == frame->fromcode); - assert(frame->torp == frame->fromrp); - } else { - assert(frame->tocode == NULL); - assert(frame->torp == NULL); - frame->tocode = frame->fromcode; - frame->torp = frame->fromrp; - } - } -} -#endif - - -/* replace_build_execution_state *********************************************** - - Build an execution state for the given (mapped) source state. - - !!! CAUTION: This function rewrites the machine stack !!! - - THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA! - - IN: - ss...............the source state. Must have been mapped by - replace_map_source_state before. - es...............the base execution state on which to build - - OUT: - *es..............the new execution state - -*******************************************************************************/ - -static void replace_build_execution_state(sourcestate_t *ss, - executionstate_t *es) -{ - rplpoint *rp; - sourceframe_t *prevframe; - rplpoint *parent; - - parent = NULL; - prevframe = NULL; - rp = NULL; - - while (ss->frames) { - - if (REPLACE_IS_NATIVE_FRAME(ss->frames)) { - prevframe = ss->frames; - replace_push_native_frame(es, ss); - parent = NULL; - rp = NULL; - continue; - } - - if (parent == NULL) { - /* create a machine-level stack frame */ - - DOLOG( printf("pushing activation record for:\n"); - if (rp) replace_replacement_point_println(rp, 1); - else printf("\tfirst frame\n"); ); - - replace_push_activation_record(es, rp, prevframe, ss->frames); - - DOLOG( executionstate_println(es); ); - } - - rp = ss->frames->torp; - assert(rp); - - DOLOG( printf("creating execution state for%s:\n", - (ss->frames->down == NULL) ? " TOPFRAME" : ""); - replace_replacement_point_println(ss->frames->fromrp, 1); - replace_replacement_point_println(rp, 1); ); - - es->code = ss->frames->tocode; - prevframe = ss->frames; - -#if defined(ENABLE_VMLOG) - vmlog_cacao_rerol_method(ss->frames->method); -#endif - - replace_write_executionstate(rp, es, ss, ss->frames->down == NULL); - - DOLOG( executionstate_println(es); ); - - if (rp->type == RPLPOINT_TYPE_CALL) { - parent = NULL; - } - else { - /* inlining */ - parent = rp; - } - } -} - - -/* replace_me ****************************************************************** - - This function is called by the signal handler when a thread reaches - a replacement point. `replace_me` must map the execution state to the - target replacement point and let execution continue there. - - THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA! - - IN: - rp...............replacement point that has been reached - es...............execution state read by signal handler - -*******************************************************************************/ - -static void replace_me(rplpoint *rp, executionstate_t *es) -{ - stackframeinfo_t *sfi; - sourcestate_t *ss; - sourceframe_t *frame; - codeinfo *origcode; - rplpoint *origrp; -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - threadobject *thread; -#endif - int32_t dumpmarker; - - origcode = es->code; - origrp = rp; - - DOLOG_SHORT( printf("REPLACING(%d %p): (id %d %p) ", - stat_replacements, (void*)THREADOBJECT, - rp->id, (void*)rp); - method_println(es->code->m); ); - - DOLOG( replace_replacement_point_println(rp, 1); ); - - REPLACE_COUNT(stat_replacements); - - /* mark start of dump memory area */ - - DMARKER; - - /* Get the stackframeinfo for the current thread. */ - - sfi = threads_get_current_stackframeinfo(); - - /* recover source state */ - - ss = replace_recover_source_state(rp, sfi, es); - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - /* if there is a collection pending, we assume the replacement point should - suspend this thread */ - - if (gc_pending) { - - thread = THREADOBJECT; - - DOLOG_SHORT( printf("REPLACEMENT: Suspending thread for GC now!\n"); ); - - /* map the sourcestate using the identity mapping */ - replace_map_source_state_identity(ss); - - /* since we enter the same method again, we turn off rps now */ - /* XXX michi: can we really do this? what if the rp was active before - we activated it for the gc? */ - replace_deactivate_replacement_points(origcode); - - /* remember executionstate and sourcestate for this thread */ - GC_EXECUTIONSTATE = es; - GC_SOURCESTATE = ss; - - /* really suspend this thread now (PC = 0) */ - threads_suspend_ack(NULL, NULL); - - DOLOG_SHORT( printf("REPLACEMENT: Resuming thread after GC now!\n"); ); - - } else { -#endif /*defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)*/ - - /* map the source state */ - - if (!replace_map_source_state(ss)) - vm_abort("exception during method replacement"); - - DOLOG( replace_sourcestate_println(ss); ); - - DOLOG_SHORT( replace_sourcestate_println_short(ss); ); - -#if !defined(NDEBUG) - /* avoid infinite loops by self-replacement, only if not in testing mode */ - - if (!opt_TestReplacement) { - frame = ss->frames; - while (frame->down) - frame = frame->down; - - if (frame->torp == origrp) { - DOLOG_SHORT( - printf("WARNING: identity replacement, turning off rps to avoid infinite loop\n"); - ); - replace_deactivate_replacement_points(origcode); - } - } -#endif - -#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) - } -#endif - - /* build the new execution state */ - - replace_build_execution_state(ss, es); - -#if !defined(NDEBUG) - /* continue execution after patched machine code, if testing mode enabled */ - - if (opt_TestReplacement) - es->pc += REPLACEMENT_PATCH_SIZE; -#endif - - /* release dump area */ - - DRELEASE; -} - - -/* replace_me_wrapper ********************************************************** - - This function is called by the signal handler. It determines if there - is an active replacement point pending at the given PC and returns - accordingly. - - THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA! - - IN: - pc...............the program counter that triggered the replacement. - context..........the context (machine state) to which the - replacement should be applied. - - OUT: - context..........the context after replacement finished. - - RETURN VALUE: - true.............replacement done, everything went ok - false............no replacement done, context unchanged - -*******************************************************************************/ - -bool replace_me_wrapper(u1 *pc, void *context) -{ - codeinfo *code; - rplpoint *rp; - executionstate_t es; - - /* search the codeinfo for the given PC */ - - code = code_find_codeinfo_for_pc(pc); - assert(code); - - /* search for a replacement point at the given PC */ - - rp = replace_find_replacement_point_for_pc(code, pc); - - /* check if the replacement point belongs to given PC and is active */ - - if ((rp != NULL) && (rp->pc == pc) && (rp->flags & RPLPOINT_FLAG_ACTIVE)) { - -#if !defined(NDEBUG) - executionstate_sanity_check(context); -#endif - - /* set codeinfo pointer in execution state */ - - es.code = code; - - /* read execution state from current context */ - - md_executionstate_read(&es, context); - - DOLOG( printf("REPLACEMENT READ: "); - executionstate_println(&es); ); - - /* do the actual replacement */ - - replace_me(rp, &es); - - /* write execution state to current context */ - - md_executionstate_write(&es, context); - - DOLOG( printf("REPLACEMENT WRITE: "); - executionstate_println(&es); ); - - /* new code is entered after returning */ - - DOLOG( printf("JUMPING IN!\n"); fflush(stdout); ); - return true; - } - else - return false; -} - - -/******************************************************************************/ -/* NOTE: Stuff specific to the exact GC is below. */ -/******************************************************************************/ - -#if defined(ENABLE_GC_CACAO) -void replace_gc_from_native(threadobject *thread, u1 *pc, u1 *sp) -{ - stackframeinfo_t *sfi; - executionstate_t *es; - sourcestate_t *ss; - - /* Get the stackframeinfo of this thread. */ - - assert(thread == THREADOBJECT); - - sfi = threads_get_current_stackframeinfo(); - - /* create the execution state */ - es = DNEW(executionstate_t); - es->pc = pc; - es->sp = sp; - es->pv = 0; /* since we are in a native, PV is invalid! */ - es->code = NULL; /* since we are in a native, we do not have a codeinfo */ - - /* we assume we are in a native (no replacement point)! */ - ss = replace_recover_source_state(NULL, sfi, es); - - /* map the sourcestate using the identity mapping */ - replace_map_source_state_identity(ss); - - /* remember executionstate and sourcestate for this thread */ - GC_EXECUTIONSTATE = es; - GC_SOURCESTATE = ss; -} -#endif - -#if defined(ENABLE_GC_CACAO) -void replace_gc_into_native(threadobject *thread) -{ - executionstate_t *es; - sourcestate_t *ss; - - /* get the executionstate and sourcestate for the given thread */ - es = GC_EXECUTIONSTATE; - ss = GC_SOURCESTATE; - - /* rebuild the stack of the given thread */ - replace_build_execution_state(ss, es); -} -#endif - - -/******************************************************************************/ -/* NOTE: No important code below. */ -/******************************************************************************/ - - -/* statistics *****************************************************************/ - -#if defined(REPLACE_STATISTICS) -static void print_freq(FILE *file,int *array,int limit) -{ - int i; - int sum = 0; - int cum = 0; - for (i=0; i=%3d: %8d\n",limit,array[limit]); -} -#endif /* defined(REPLACE_STATISTICS) */ - - -#if defined(REPLACE_STATISTICS) - -#define REPLACE_PRINT_DIST(name, array) \ - printf(" " name " distribution:\n"); \ - print_freq(stdout, (array), sizeof(array)/sizeof(int) - 1); - -void replace_print_statistics(void) -{ - printf("replacement statistics:\n"); - printf(" # of replacements: %d\n", stat_replacements); - printf(" # of frames: %d\n", stat_frames); - printf(" # of recompilations: %d\n", stat_recompile); - printf(" patched static calls:%d\n", stat_staticpatch); - printf(" unrolled inlines: %d\n", stat_unroll_inline); - printf(" unrolled calls: %d\n", stat_unroll_call); - REPLACE_PRINT_DIST("frame depth", stat_dist_frames); - REPLACE_PRINT_DIST("locals per frame", stat_dist_locals); - REPLACE_PRINT_DIST("ADR locals per frame", stat_dist_locals_adr); - REPLACE_PRINT_DIST("primitive locals per frame", stat_dist_locals_prim); - REPLACE_PRINT_DIST("RET locals per frame", stat_dist_locals_ret); - REPLACE_PRINT_DIST("void locals per frame", stat_dist_locals_void); - REPLACE_PRINT_DIST("stack slots per frame", stat_dist_stack); - REPLACE_PRINT_DIST("ADR stack slots per frame", stat_dist_stack_adr); - REPLACE_PRINT_DIST("primitive stack slots per frame", stat_dist_stack_prim); - REPLACE_PRINT_DIST("RET stack slots per frame", stat_dist_stack_ret); - printf("\n"); - printf(" # of methods: %d\n", stat_methods); - printf(" # of replacement points: %d\n", stat_rploints); - printf(" # of regallocs: %d\n", stat_regallocs); - printf(" per rplpoint: %f\n", (double)stat_regallocs / stat_rploints); - printf(" per method: %f\n", (double)stat_regallocs / stat_methods); - REPLACE_PRINT_DIST("replacement points per method", stat_dist_method_rplpoints); - printf("\n"); - -} -#endif /* defined(REPLACE_STATISTICS) */ - - -#if defined(REPLACE_STATISTICS) -static void replace_statistics_source_frame(sourceframe_t *frame) -{ - int adr = 0; - int ret = 0; - int prim = 0; - int vd = 0; - int n = 0; - int i; - - for (i=0; ijavalocalcount; ++i) { - switch (frame->javalocaltype[i]) { - case TYPE_ADR: adr++; break; - case TYPE_RET: ret++; break; - case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break; - case TYPE_VOID: vd++; break; - default: assert(0); - } - n++; - } - REPLACE_COUNT_DIST(stat_dist_locals, n); - REPLACE_COUNT_DIST(stat_dist_locals_adr, adr); - REPLACE_COUNT_DIST(stat_dist_locals_void, vd); - REPLACE_COUNT_DIST(stat_dist_locals_ret, ret); - REPLACE_COUNT_DIST(stat_dist_locals_prim, prim); - adr = ret = prim = n = 0; - for (i=0; ijavastackdepth; ++i) { - switch (frame->javastacktype[i]) { - case TYPE_ADR: adr++; break; - case TYPE_RET: ret++; break; - case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break; - } - n++; - } - REPLACE_COUNT_DIST(stat_dist_stack, n); - REPLACE_COUNT_DIST(stat_dist_stack_adr, adr); - REPLACE_COUNT_DIST(stat_dist_stack_ret, ret); - REPLACE_COUNT_DIST(stat_dist_stack_prim, prim); -} -#endif /* defined(REPLACE_STATISTICS) */ - - -/* debugging helpers **********************************************************/ - -/* replace_replacement_point_println ******************************************* - - Print replacement point info. - - IN: - rp...............the replacement point to print - -*******************************************************************************/ - -#if !defined(NDEBUG) - -#define TYPECHAR(t) (((t) >= 0 && (t) <= TYPE_RET) ? show_jit_type_letters[t] : '?') - -static char *replace_type_str[] = { - "STD", - "EXH", - "SBR", - "CALL", - "INLINE", - "RETURN", - "BODY" -}; - -void replace_replacement_point_println(rplpoint *rp, int depth) -{ - int j; - int index; - - if (!rp) { - printf("(rplpoint *)NULL\n"); - return; - } - - for (j=0; jid, (void*)rp,rp->pc,rp->callsize, - replace_type_str[rp->type]); - if (rp->flags & RPLPOINT_FLAG_NOTRAP) - printf(" NOTRAP"); - if (rp->flags & RPLPOINT_FLAG_COUNTDOWN) - printf(" COUNTDOWN"); - if (rp->flags & RPLPOINT_FLAG_ACTIVE) - printf(" ACTIVE"); - printf(" parent:%p\n", (void*)rp->parent); - for (j=0; jregalloccount); - - for (j=0; jregalloccount; ++j) { - if (j) - putchar(' '); - index = rp->regalloc[j].index; - switch (index) { - case RPLALLOC_STACK: printf("S"); break; - case RPLALLOC_PARAM: printf("P"); break; - case RPLALLOC_SYNC : printf("Y"); break; - default: printf("%d", index); - } - printf(":%1c:", TYPECHAR(rp->regalloc[j].type)); - if (rp->regalloc[j].type == TYPE_RET) { - printf("ret(L%03d)", rp->regalloc[j].regoff); - } - else { - show_allocation(rp->regalloc[j].type, rp->regalloc[j].flags, rp->regalloc[j].regoff); - } - } - - printf("]\n"); - for (j=0; jmethod); - - printf("\n"); -} -#endif /* !defined(NDEBUG) */ - - -/* replace_show_replacement_points ********************************************* - - Print replacement point info. - - IN: - code.............codeinfo whose replacement points should be printed. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void replace_show_replacement_points(codeinfo *code) -{ - int i; - int depth; - rplpoint *rp; - rplpoint *parent; - - if (!code) { - printf("(codeinfo *)NULL\n"); - return; - } - - printf("\treplacement points: %d\n",code->rplpointcount); - - printf("\ttotal allocations : %d\n",code->regalloccount); - printf("\tsaved int regs : %d\n",code->savedintcount); - printf("\tsaved flt regs : %d\n",code->savedfltcount); -#if defined(HAS_ADDRESS_REGISTER_FILE) - printf("\tsaved adr regs : %d\n",code->savedadrcount); -#endif - printf("\tmemuse : %d\n",code->memuse); - - printf("\n"); - - for (i=0; irplpointcount; ++i) { - rp = code->rplpoints + i; - - depth = 1; - parent = rp->parent; - while (parent) { - depth++; - parent = parent->parent; - } - replace_replacement_point_println(rp, depth); - } -} -#endif - - -#if !defined(NDEBUG) -static void java_value_print(s4 type, replace_val_t value) -{ - java_object_t *obj; - utf *u; - - printf("%016llx",(unsigned long long) value.l); - - if (type < 0 || type > TYPE_RET) - printf(" ", type); - else - printf(" %s", show_jit_type_names[type]); - - if (type == TYPE_ADR && value.a != NULL) { - obj = value.a; - putchar(' '); - utf_display_printable_ascii_classname(obj->vftbl->clazz->name); - - if (obj->vftbl->clazz == class_java_lang_String) { - printf(" \""); - u = javastring_toutf(obj, false); - utf_display_printable_ascii(u); - printf("\""); - } - } - else if (type == TYPE_INT) { - printf(" %ld", (long) value.i); - } - else if (type == TYPE_LNG) { - printf(" %lld", (long long) value.l); - } - else if (type == TYPE_FLT) { - printf(" %f", value.f); - } - else if (type == TYPE_DBL) { - printf(" %f", value.d); - } -} -#endif /* !defined(NDEBUG) */ - - -#if !defined(NDEBUG) -void replace_source_frame_println(sourceframe_t *frame) -{ - s4 i,j; - s4 t; - - if (REPLACE_IS_NATIVE_FRAME(frame)) { - printf("\tNATIVE\n"); - printf("\tsfi: "); replace_stackframeinfo_println(frame->sfi); - printf("\tnativepc: %p\n", frame->nativepc); - printf("\tframesize: %d\n", frame->nativeframesize); - - j = 0; - for (i=0; inativesavint[j++]); - } - - j = 0; - for (i=0; inativesavflt[j++]); - } - - printf("\n"); - return; - } - - printf("\t"); - method_println(frame->method); - printf("\tid: %d\n", frame->id); - printf("\ttype: %s\n", replace_type_str[frame->type]); - printf("\n"); - - if (frame->instance.a) { - printf("\tinstance: "); - java_value_print(TYPE_ADR, frame->instance); - printf("\n"); - } - - if (frame->javalocalcount) { - printf("\tlocals (%d):\n",frame->javalocalcount); - for (i=0; ijavalocalcount; ++i) { - t = frame->javalocaltype[i]; - if (t == TYPE_VOID) { - printf("\tlocal[ %2d] = void\n",i); - } - else { - printf("\tlocal[%c%2d] = ",TYPECHAR(t),i); - java_value_print(t, frame->javalocals[i]); - printf("\n"); - } - } - printf("\n"); - } - - if (frame->javastackdepth) { - printf("\tstack (depth %d):\n",frame->javastackdepth); - for (i=0; ijavastackdepth; ++i) { - t = frame->javastacktype[i]; - if (t == TYPE_VOID) { - printf("\tstack[%2d] = void", i); - } - else { - printf("\tstack[%2d] = ",i); - java_value_print(frame->javastacktype[i], frame->javastack[i]); - printf("\n"); - } - } - printf("\n"); - } - - if (frame->syncslotcount) { - printf("\tsynchronization slots (%d):\n",frame->syncslotcount); - for (i=0; isyncslotcount; ++i) { - printf("\tslot[%2d] = ",i); -#ifdef HAS_4BYTE_STACKSLOT - printf("%08lx\n",(unsigned long) frame->syncslots[i].p); -#else - printf("%016llx\n",(unsigned long long) frame->syncslots[i].p); -#endif - } - printf("\n"); - } - - if (frame->fromcode) { - printf("\tfrom %p ", (void*)frame->fromcode); - method_println(frame->fromcode->m); - } - if (frame->tocode) { - printf("\tto %p ", (void*)frame->tocode); - method_println(frame->tocode->m); - } - - if (frame->fromrp) { - printf("\tfrom replacement point:\n"); - replace_replacement_point_println(frame->fromrp, 2); - } - if (frame->torp) { - printf("\tto replacement point:\n"); - replace_replacement_point_println(frame->torp, 2); - } - - printf("\n"); -} -#endif /* !defined(NDEBUG) */ - - -/* replace_sourcestate_println ************************************************* - - Print source state - - IN: - ss...............the source state to print - -*******************************************************************************/ - -#if !defined(NDEBUG) -void replace_sourcestate_println(sourcestate_t *ss) -{ - int i; - sourceframe_t *frame; - - if (!ss) { - printf("(sourcestate_t *)NULL\n"); - return; - } - - printf("sourcestate_t:\n"); - - for (i=0, frame = ss->frames; frame != NULL; frame = frame->down, ++i) { - printf(" frame %d:\n", i); - replace_source_frame_println(frame); - } -} -#endif - - -/* replace_sourcestate_println_short ******************************************* - - Print a compact representation of the given source state. - - IN: - ss...............the source state to print - -*******************************************************************************/ - -#if !defined(NDEBUG) -void replace_sourcestate_println_short(sourcestate_t *ss) -{ - sourceframe_t *frame; - - for (frame = ss->frames; frame != NULL; frame = frame->down) { - printf("\t"); - - if (REPLACE_IS_NATIVE_FRAME(frame)) { - printf("NATIVE (pc %p size %d) ", - (void*)frame->nativepc, frame->nativeframesize); - replace_stackframeinfo_println(frame->sfi); - continue; - } - - if (frame->torp) { - printf("%c", (frame->torp == frame->fromrp) ? '=' : '+'); - } - - printf("%s", replace_type_str[frame->fromrp->type]); - - if (frame->torp && frame->torp->type != frame->fromrp->type) - printf("->%s", replace_type_str[frame->torp->type]); - - if (frame->tocode != frame->fromcode) - printf(" (%p->%p/%d) ", - (void*) frame->fromcode, (void*) frame->tocode, - frame->fromrp->id); - else - printf(" (%p/%d) ", (void*) frame->fromcode, frame->fromrp->id); - - method_println(frame->method); - } -} -#endif - -#if !defined(NDEBUG) -static void replace_stackframeinfo_println(stackframeinfo_t *sfi) -{ - printf("prev=%p pv=%p sp=%p ra=%p xpc=%p method=", - (void*)sfi->prev, (void*)sfi->pv, (void*)sfi->sp, - (void*)sfi->ra, (void*)sfi->xpc); - - if (sfi->code) - method_println(sfi->code->m); - else - printf("(nil)\n"); -} -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/replace.cpp b/src/vm/jit/replace.cpp new file mode 100644 index 000000000..ae6233c3e --- /dev/null +++ b/src/vm/jit/replace.cpp @@ -0,0 +1,3604 @@ +/* src/vm/jit/replace.cpp - on-stack replacement of methods + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" +#include "vm/types.h" + +#include +#include +#include + +#include "arch.h" +#include "md.h" + +#if defined(ENABLE_GC_CACAO) +# include "mm/cacao-gc/gc.h" +#endif + +#include "mm/dumpmemory.hpp" +#include "mm/memory.h" + +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/classcache.h" +#include "vm/globals.hpp" +#include "vm/options.h" +#include "vm/string.hpp" + +#if defined(ENABLE_RT_TIMING) +# include "vm/rt-timing.h" +#endif + +#include "vm/jit/abi.h" +#include "vm/jit/asmpart.h" +#include "vm/jit/disass.h" +#include "vm/jit/executionstate.h" +#include "vm/jit/jit.hpp" +#include "vm/jit/methodheader.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/show.h" +#include "vm/jit/stack.h" + + +#define REPLACE_PATCH_DYNAMIC_CALL +/*#define REPLACE_PATCH_ALL*/ + +#if defined(ENABLE_VMLOG) +#include +#endif + +/*** architecture-dependent configuration *************************************/ + +/* first unset the macros (default) */ +#undef REPLACE_RA_BETWEEN_FRAMES +#undef REPLACE_RA_TOP_OF_FRAME +#undef REPLACE_RA_LINKAGE_AREA +#undef REPLACE_LEAFMETHODS_RA_REGISTER + +/* i386, x86_64 and m68k */ +#if defined(__I386__) || defined(__X86_64__) || defined(__M68K__) +#define REPLACE_RA_BETWEEN_FRAMES +/* alpha */ +#elif defined(__ALPHA__) +#define REPLACE_RA_TOP_OF_FRAME +#define REPLACE_LEAFMETHODS_RA_REGISTER +/* powerpc */ +#elif defined(__POWERPC__) +#define REPLACE_RA_LINKAGE_AREA +#define REPLACE_LEAFMETHODS_RA_REGISTER +/* s390 */ +#elif defined(__S390__) +#define REPLACE_RA_TOP_OF_FRAME +#endif + + +/*** configuration of native stack slot size **********************************/ + +/* XXX this should be in md-abi.h files, probably */ + +#if defined(HAS_4BYTE_STACKSLOT) +#define SIZE_OF_STACKSLOT 4 +#define STACK_SLOTS_PER_FLOAT 2 +typedef u4 stackslot_t; +#else +#define SIZE_OF_STACKSLOT 8 +#define STACK_SLOTS_PER_FLOAT 1 +typedef u8 stackslot_t; +#endif + + +/*** debugging ****************************************************************/ + +#if !defined(NDEBUG) +static void java_value_print(s4 type, replace_val_t value); +static void replace_stackframeinfo_println(stackframeinfo_t *sfi); +#endif + +#if !defined(NDEBUG) +#define DOLOG(code) do{ if (opt_TraceReplacement > 1) { code; } } while(0) +#define DOLOG_SHORT(code) do{ if (opt_TraceReplacement > 0) { code; } } while(0) +#else +#define DOLOG(code) +#define DOLOG_SHORT(code) +#endif + + +/*** statistics ***************************************************************/ + +#define REPLACE_STATISTICS + +#if defined(REPLACE_STATISTICS) + +static int stat_replacements = 0; +static int stat_frames = 0; +static int stat_recompile = 0; +static int stat_staticpatch = 0; +static int stat_unroll_inline = 0; +static int stat_unroll_call = 0; +static int stat_dist_frames[20] = { 0 }; +static int stat_dist_locals[20] = { 0 }; +static int stat_dist_locals_adr[10] = { 0 }; +static int stat_dist_locals_prim[10] = { 0 }; +static int stat_dist_locals_ret[10] = { 0 }; +static int stat_dist_locals_void[10] = { 0 }; +static int stat_dist_stack[10] = { 0 }; +static int stat_dist_stack_adr[10] = { 0 }; +static int stat_dist_stack_prim[10] = { 0 }; +static int stat_dist_stack_ret[10] = { 0 }; +static int stat_methods = 0; +static int stat_rploints = 0; +static int stat_regallocs = 0; +static int stat_dist_method_rplpoints[20] = { 0 }; + +#define REPLACE_COUNT(cnt) (cnt)++ +#define REPLACE_COUNT_IF(cnt, cond) do{ if(cond) (cnt)++; } while(0) +#define REPLACE_COUNT_INC(cnt, inc) ((cnt) += (inc)) + +#define REPLACE_COUNT_DIST(array, val) \ + do { \ + int limit = (sizeof(array) / sizeof(int)) - 1; \ + if ((val) < (limit)) (array)[val]++; \ + else (array)[limit]++; \ + } while (0) + +static void replace_statistics_source_frame(sourceframe_t *frame); + +#else + +#define REPLACE_COUNT(cnt) +#define REPLACE_COUNT_IF(cnt, cond) +#define REPLACE_COUNT_INC(cnt, inc) +#define REPLACE_COUNT_DIST(array, val) + +#endif /* defined(REPLACE_STATISTICS) */ + + +/*** constants used internally ************************************************/ + +#define TOP_IS_NORMAL 0 +#define TOP_IS_ON_STACK 1 +#define TOP_IS_IN_ITMP1 2 +#define TOP_IS_VOID 3 + + +/******************************************************************************/ +/* PART I: Creating / freeing replacement points */ +/******************************************************************************/ + + +/* replace_create_replacement_point ******************************************** + + Create a replacement point. + + IN: + jd...............current jitdata + iinfo............inlining info for the current position + rp...............pre-allocated (uninitialized) rplpoint + type.............RPLPOINT_TYPE constant + iptr.............current instruction + *pra.............current rplalloc pointer + javalocals.......the javalocals at the current point + stackvars........the stack variables at the current point + stackdepth.......the stack depth at the current point + paramcount.......number of parameters at the start of stackvars + + OUT: + *rpa.............points to the next free rplalloc + +*******************************************************************************/ + +static void replace_create_replacement_point(jitdata *jd, + insinfo_inline *iinfo, + rplpoint *rp, + s4 type, + instruction *iptr, + rplalloc **pra, + s4 *javalocals, + s4 *stackvars, + s4 stackdepth, + s4 paramcount) +{ + rplalloc *ra; + s4 i; + varinfo *v; + s4 index; + + ra = *pra; + + REPLACE_COUNT(stat_rploints); + + rp->method = (iinfo) ? iinfo->method : jd->m; + rp->pc = NULL; /* set by codegen */ + rp->callsize = 0; /* set by codegen */ + rp->regalloc = ra; + rp->flags = 0; + rp->type = type; + rp->id = iptr->flags.bits >> INS_FLAG_ID_SHIFT; + + /* XXX unify these two fields */ + rp->parent = (iinfo) ? iinfo->rp : NULL; + + /* store local allocation info of javalocals */ + + if (javalocals) { + for (i = 0; i < rp->method->maxlocals; ++i) { + index = javalocals[i]; + if (index == UNUSED) + continue; + + ra->index = i; + if (index >= 0) { + v = VAR(index); + ra->flags = v->flags & (INMEMORY); + ra->regoff = v->vv.regoff; + ra->type = v->type; + } + else { + ra->regoff = RETADDR_FROM_JAVALOCAL(index); + ra->type = TYPE_RET; + ra->flags = 0; + } + ra++; + } + } + + /* store allocation info of java stack vars */ + + for (i = 0; i < stackdepth; ++i) { + v = VAR(stackvars[i]); + ra->flags = v->flags & (INMEMORY); + ra->index = (i < paramcount) ? RPLALLOC_PARAM : RPLALLOC_STACK; + ra->type = v->type; + /* XXX how to handle locals on the stack containing returnAddresses? */ + if (v->type == TYPE_RET) { + assert(stackvars[i] >= jd->localcount); + ra->regoff = v->vv.retaddr->nr; + } + else + ra->regoff = v->vv.regoff; + ra++; + } + + /* total number of allocations */ + + rp->regalloccount = ra - rp->regalloc; + + *pra = ra; +} + + +/* replace_create_inline_start_replacement_point ******************************* + + Create an INLINE_START replacement point. + + IN: + jd...............current jitdata + rp...............pre-allocated (uninitialized) rplpoint + iptr.............current instruction + *pra.............current rplalloc pointer + javalocals.......the javalocals at the current point + + OUT: + *rpa.............points to the next free rplalloc + + RETURN VALUE: + the insinfo_inline * for the following inlined body + +*******************************************************************************/ + +static insinfo_inline * replace_create_inline_start_replacement_point( + jitdata *jd, + rplpoint *rp, + instruction *iptr, + rplalloc **pra, + s4 *javalocals) +{ + insinfo_inline *calleeinfo; + rplalloc *ra; + + calleeinfo = iptr->sx.s23.s3.inlineinfo; + + calleeinfo->rp = rp; + + replace_create_replacement_point(jd, calleeinfo->parent, rp, + RPLPOINT_TYPE_INLINE, iptr, pra, + javalocals, + calleeinfo->stackvars, calleeinfo->stackvarscount, + calleeinfo->paramcount); + + if (calleeinfo->synclocal != UNUSED) { + ra = (*pra)++; + ra->index = RPLALLOC_SYNC; + ra->regoff = jd->var[calleeinfo->synclocal].vv.regoff; + ra->flags = jd->var[calleeinfo->synclocal].flags & INMEMORY; + ra->type = TYPE_ADR; + + rp->regalloccount++; + } + + return calleeinfo; +} + + +/* replace_create_replacement_points ******************************************* + + Create the replacement points for the given code. + + IN: + jd...............current jitdata, must not have any replacement points + + OUT: + code->rplpoints.......set to the list of replacement points + code->rplpointcount...number of replacement points + code->regalloc........list of allocation info + code->regalloccount...total length of allocation info list + code->globalcount.....number of global allocations at the + start of code->regalloc + + RETURN VALUE: + true.............everything ok + false............an exception has been thrown + +*******************************************************************************/ + +#define CLEAR_javalocals(array, method) \ + do { \ + for (i=0; i<(method)->maxlocals; ++i) \ + (array)[i] = UNUSED; \ + } while (0) + +#define COPY_OR_CLEAR_javalocals(dest, array, method) \ + do { \ + if ((array) != NULL) \ + MCOPY((dest), (array), s4, (method)->maxlocals); \ + else \ + CLEAR_javalocals((dest), (method)); \ + } while (0) + +#define COUNT_javalocals(array, method, counter) \ + do { \ + for (i=0; i<(method)->maxlocals; ++i) \ + if ((array)[i] != UNUSED) \ + (counter)++; \ + } while (0) + +bool replace_create_replacement_points(jitdata *jd) +{ + codeinfo *code; + registerdata *rd; + basicblock *bptr; + int count; + methodinfo *m; + rplpoint *rplpoints; + rplpoint *rp; + int alloccount; + rplalloc *regalloc; + rplalloc *ra; + int i; + instruction *iptr; + instruction *iend; + s4 *javalocals; + s4 *jl; + methoddesc *md; + insinfo_inline *iinfo; + s4 startcount; + s4 firstcount; +#if defined(REPLACE_PATCH_DYNAMIC_CALL) + bool needentry; +#endif + + REPLACE_COUNT(stat_methods); + + /* get required compiler data */ + + code = jd->code; + rd = jd->rd; + + /* assert that we wont overwrite already allocated data */ + + assert(code); + assert(code->m); + assert(code->rplpoints == NULL); + assert(code->rplpointcount == 0); + assert(code->regalloc == NULL); + assert(code->regalloccount == 0); + assert(code->globalcount == 0); + + m = code->m; + + /* in instance methods, we may need a rplpoint at the method entry */ + +#if defined(REPLACE_PATCH_DYNAMIC_CALL) + if (!(m->flags & ACC_STATIC)) { + jd->basicblocks[0].bitflags |= BBFLAG_REPLACEMENT; + needentry = true; + } + else { + needentry = false; + } +#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */ + + /* iterate over the basic block list to find replacement points */ + + count = 0; + alloccount = 0; + + javalocals = (s4*) DumpMemory::allocate(sizeof(s4) * jd->maxlocals); + + for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { + + /* skip dead code */ + + if (bptr->flags < BBFINISHED) + continue; + + /* get info about this block */ + + m = bptr->method; + iinfo = bptr->inlineinfo; + + /* initialize javalocals at the start of this block */ + + COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m); + + /* iterate over the instructions */ + + iptr = bptr->iinstr; + iend = iptr + bptr->icount; + startcount = count; + firstcount = count; + + for (; iptr != iend; ++iptr) { + switch (iptr->opc) { +#if defined(ENABLE_GC_CACAO) + case ICMD_BUILTIN: + md = iptr->sx.s23.s3.bte->md; + count++; + COUNT_javalocals(javalocals, m, alloccount); + alloccount += iptr->s1.argcount; + if (iinfo) + alloccount -= iinfo->throughcount; + break; +#endif + + case ICMD_INVOKESTATIC: + case ICMD_INVOKESPECIAL: + case ICMD_INVOKEVIRTUAL: + case ICMD_INVOKEINTERFACE: + INSTRUCTION_GET_METHODDESC(iptr, md); + count++; + COUNT_javalocals(javalocals, m, alloccount); + alloccount += iptr->s1.argcount; + if (iinfo) + alloccount -= iinfo->throughcount; + break; + + case ICMD_ISTORE: + case ICMD_LSTORE: + case ICMD_FSTORE: + case ICMD_DSTORE: + case ICMD_ASTORE: + stack_javalocals_store(iptr, javalocals); + break; + + case ICMD_IRETURN: + case ICMD_LRETURN: + case ICMD_FRETURN: + case ICMD_DRETURN: + case ICMD_ARETURN: + alloccount += 1; + /* FALLTHROUGH! */ + case ICMD_RETURN: + count++; + break; + + case ICMD_INLINE_START: + iinfo = iptr->sx.s23.s3.inlineinfo; + + count++; + COUNT_javalocals(javalocals, m, alloccount); + alloccount += iinfo->stackvarscount; + if (iinfo->synclocal != UNUSED) + alloccount++; + + m = iinfo->method; + /* javalocals may be set at next block start, or now */ + COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m); + break; + + case ICMD_INLINE_BODY: + assert(iinfo == iptr->sx.s23.s3.inlineinfo); + + jl = iinfo->javalocals_start; + if (jl == NULL) { + /* get the javalocals from the following block start */ + assert(bptr->next); + jl = bptr->next->javalocals; + } + count++; + COUNT_javalocals(jl, m, alloccount); + break; + + case ICMD_INLINE_END: + assert(iinfo == iptr->sx.s23.s3.inlineinfo || + iinfo == iptr->sx.s23.s3.inlineinfo->parent); + iinfo = iptr->sx.s23.s3.inlineinfo; + m = iinfo->outer; + if (iinfo->javalocals_end) + MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals); + iinfo = iinfo->parent; + break; + } + + if (iptr == bptr->iinstr) + firstcount = count; + } /* end instruction loop */ + + /* create replacement points at targets of backward branches */ + /* We only need the replacement point there, if there is no */ + /* replacement point inside the block. */ + + if (bptr->bitflags & BBFLAG_REPLACEMENT) { +#if defined(REPLACE_PATCH_DYNAMIC_CALL) + int test = (needentry && bptr == jd->basicblocks) ? firstcount : count; +#else + int test = count; +#endif + if (test > startcount) { + /* we don't need an extra rplpoint */ + bptr->bitflags &= ~BBFLAG_REPLACEMENT; + } + else { + count++; + alloccount += bptr->indepth; + if (bptr->inlineinfo) + alloccount -= bptr->inlineinfo->throughcount; + + COUNT_javalocals(bptr->javalocals, bptr->method, alloccount); + } + } + + } /* end basicblock loop */ + + /* if no points were found, there's nothing to do */ + + if (!count) + return true; + + /* allocate replacement point array and allocation array */ + + rplpoints = MNEW(rplpoint, count); + regalloc = MNEW(rplalloc, alloccount); + ra = regalloc; + + /* initialize replacement point structs */ + + rp = rplpoints; + + /* XXX try to share code with the counting loop! */ + + for (bptr = jd->basicblocks; bptr; bptr = bptr->next) { + /* skip dead code */ + + if (bptr->flags < BBFINISHED) + continue; + + /* get info about this block */ + + m = bptr->method; + iinfo = bptr->inlineinfo; + + /* initialize javalocals at the start of this block */ + + COPY_OR_CLEAR_javalocals(javalocals, bptr->javalocals, m); + + /* create replacement points at targets of backward branches */ + + if (bptr->bitflags & BBFLAG_REPLACEMENT) { + + i = (iinfo) ? iinfo->throughcount : 0; + replace_create_replacement_point(jd, iinfo, rp++, + bptr->type, bptr->iinstr, &ra, + bptr->javalocals, bptr->invars + i, bptr->indepth - i, 0); + + if (JITDATA_HAS_FLAG_COUNTDOWN(jd)) + rp[-1].flags |= RPLPOINT_FLAG_COUNTDOWN; + } + + /* iterate over the instructions */ + + iptr = bptr->iinstr; + iend = iptr + bptr->icount; + + for (; iptr != iend; ++iptr) { + switch (iptr->opc) { +#if defined(ENABLE_GC_CACAO) + case ICMD_BUILTIN: + md = iptr->sx.s23.s3.bte->md; + + i = (iinfo) ? iinfo->throughcount : 0; + replace_create_replacement_point(jd, iinfo, rp++, + RPLPOINT_TYPE_CALL, iptr, &ra, + javalocals, iptr->sx.s23.s2.args, + iptr->s1.argcount - i, + md->paramcount); + break; +#endif + + case ICMD_INVOKESTATIC: + case ICMD_INVOKESPECIAL: + case ICMD_INVOKEVIRTUAL: + case ICMD_INVOKEINTERFACE: + INSTRUCTION_GET_METHODDESC(iptr, md); + + i = (iinfo) ? iinfo->throughcount : 0; + replace_create_replacement_point(jd, iinfo, rp++, + RPLPOINT_TYPE_CALL, iptr, &ra, + javalocals, iptr->sx.s23.s2.args, + iptr->s1.argcount - i, + md->paramcount); + break; + + case ICMD_ISTORE: + case ICMD_LSTORE: + case ICMD_FSTORE: + case ICMD_DSTORE: + case ICMD_ASTORE: + stack_javalocals_store(iptr, javalocals); + break; + + case ICMD_IRETURN: + case ICMD_LRETURN: + case ICMD_FRETURN: + case ICMD_DRETURN: + case ICMD_ARETURN: + replace_create_replacement_point(jd, iinfo, rp++, + RPLPOINT_TYPE_RETURN, iptr, &ra, + NULL, &(iptr->s1.varindex), 1, 0); + break; + + case ICMD_RETURN: + replace_create_replacement_point(jd, iinfo, rp++, + RPLPOINT_TYPE_RETURN, iptr, &ra, + NULL, NULL, 0, 0); + break; + + case ICMD_INLINE_START: + iinfo = replace_create_inline_start_replacement_point( + jd, rp++, iptr, &ra, javalocals); + m = iinfo->method; + /* javalocals may be set at next block start, or now */ + COPY_OR_CLEAR_javalocals(javalocals, iinfo->javalocals_start, m); + break; + + case ICMD_INLINE_BODY: + assert(iinfo == iptr->sx.s23.s3.inlineinfo); + + jl = iinfo->javalocals_start; + if (jl == NULL) { + /* get the javalocals from the following block start */ + assert(bptr->next); + jl = bptr->next->javalocals; + } + /* create a non-trappable rplpoint */ + replace_create_replacement_point(jd, iinfo, rp++, + RPLPOINT_TYPE_BODY, iptr, &ra, + jl, NULL, 0, 0); + rp[-1].flags |= RPLPOINT_FLAG_NOTRAP; + break; + + case ICMD_INLINE_END: + assert(iinfo == iptr->sx.s23.s3.inlineinfo || + iinfo == iptr->sx.s23.s3.inlineinfo->parent); + iinfo = iptr->sx.s23.s3.inlineinfo; + m = iinfo->outer; + if (iinfo->javalocals_end) + MCOPY(javalocals, iinfo->javalocals_end, s4, m->maxlocals); + iinfo = iinfo->parent; + break; + } + } /* end instruction loop */ + } /* end basicblock loop */ + + assert((rp - rplpoints) == count); + assert((ra - regalloc) == alloccount); + + /* store the data in the codeinfo */ + + code->rplpoints = rplpoints; + code->rplpointcount = count; + code->regalloc = regalloc; + code->regalloccount = alloccount; + code->globalcount = 0; + code->savedintcount = INT_SAV_CNT - rd->savintreguse; + code->savedfltcount = FLT_SAV_CNT - rd->savfltreguse; +#if defined(HAS_ADDRESS_REGISTER_FILE) + code->savedadrcount = ADR_SAV_CNT - rd->savadrreguse; +#endif + code->memuse = rd->memuse; + code->stackframesize = jd->cd->stackframesize; + + REPLACE_COUNT_DIST(stat_dist_method_rplpoints, count); + REPLACE_COUNT_INC(stat_regallocs, alloccount); + + /* everything alright */ + + return true; +} + + +/* replace_free_replacement_points ********************************************* + + Free memory used by replacement points. + + IN: + code.............codeinfo whose replacement points should be freed. + +*******************************************************************************/ + +void replace_free_replacement_points(codeinfo *code) +{ + assert(code); + + if (code->rplpoints) + MFREE(code->rplpoints,rplpoint,code->rplpointcount); + + if (code->regalloc) + MFREE(code->regalloc,rplalloc,code->regalloccount); + + code->rplpoints = NULL; + code->rplpointcount = 0; + code->regalloc = NULL; + code->regalloccount = 0; + code->globalcount = 0; +} + + +/******************************************************************************/ +/* PART II: Activating / deactivating replacement points */ +/******************************************************************************/ + + +/* replace_activate_replacement_points ***************************************** + + Activate the replacement points of the given compilation unit. When this + function returns, the replacement points are "armed", so each thread + reaching one of the points will enter the replacement mechanism. + + IN: + code.............codeinfo of which replacement points should be + activated + mappable.........if true, only mappable replacement points are + activated + +*******************************************************************************/ + +void replace_activate_replacement_points(codeinfo *code, bool mappable) +{ + rplpoint *rp; + s4 i; + s4 count; + u1 *savedmcode; + + assert(code->savedmcode == NULL); + + /* count trappable replacement points */ + + count = 0; + i = code->rplpointcount; + rp = code->rplpoints; + for (; i--; rp++) { + if (rp->flags & RPLPOINT_FLAG_NOTRAP) + continue; + + if (mappable && (rp->type == RPLPOINT_TYPE_RETURN)) + continue; + + count++; + } + + /* allocate buffer for saved machine code */ + + savedmcode = MNEW(u1, count * REPLACEMENT_PATCH_SIZE); + code->savedmcode = savedmcode; + savedmcode += count * REPLACEMENT_PATCH_SIZE; + + /* activate trappable replacement points */ + /* (in reverse order to handle overlapping points within basic blocks) */ + + i = code->rplpointcount; + rp = code->rplpoints + i; + while (rp--, i--) { + assert(!(rp->flags & RPLPOINT_FLAG_ACTIVE)); + + if (rp->flags & RPLPOINT_FLAG_NOTRAP) + continue; + + if (mappable && (rp->type == RPLPOINT_TYPE_RETURN)) + continue; + + DOLOG( printf("activate replacement point:\n"); + replace_replacement_point_println(rp, 1); fflush(stdout); ); + + savedmcode -= REPLACEMENT_PATCH_SIZE; + +#if defined(ENABLE_JIT) +# if defined(ENABLE_DISASSEMBLER) + DOLOG( printf("\tinstruction before: "); + disassinstr(rp->pc); fflush(stdout); ); +# endif + + md_patch_replacement_point(rp->pc, savedmcode, false); + +# if defined(ENABLE_DISASSEMBLER) + DOLOG( printf("\tinstruction after : "); + disassinstr(rp->pc); fflush(stdout); ); +# endif +#endif + + rp->flags |= RPLPOINT_FLAG_ACTIVE; + } + + assert(savedmcode == code->savedmcode); +} + + +/* replace_deactivate_replacement_points *************************************** + + Deactivate a replacement points in the given compilation unit. + When this function returns, the replacement points will be "un-armed", + that is a each thread reaching a point will just continue normally. + + IN: + code.............the compilation unit + +*******************************************************************************/ + +void replace_deactivate_replacement_points(codeinfo *code) +{ + rplpoint *rp; + s4 i; + s4 count; + u1 *savedmcode; + + if (code->savedmcode == NULL) { + /* disarm countdown points by patching the branches */ + + i = code->rplpointcount; + rp = code->rplpoints; + for (; i--; rp++) { + if ((rp->flags & (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN)) + == RPLPOINT_FLAG_COUNTDOWN) + { +#if 0 + *(s4*) (rp->pc + 9) = 0; /* XXX machine dependent! */ +#endif + } + } + return; + } + + assert(code->savedmcode != NULL); + savedmcode = code->savedmcode; + + /* de-activate each trappable replacement point */ + + i = code->rplpointcount; + rp = code->rplpoints; + count = 0; + for (; i--; rp++) { + if (!(rp->flags & RPLPOINT_FLAG_ACTIVE)) + continue; + + count++; + + DOLOG( printf("deactivate replacement point:\n"); + replace_replacement_point_println(rp, 1); fflush(stdout); ); + +#if defined(ENABLE_JIT) +# if defined(ENABLE_DISASSEMBLER) + DOLOG( printf("\tinstruction before: "); + disassinstr(rp->pc); fflush(stdout); ); +# endif + + md_patch_replacement_point(rp->pc, savedmcode, true); + +# if defined(ENABLE_DISASSEMBLER) + DOLOG( printf("\tinstruction before: "); + disassinstr(rp->pc); fflush(stdout); ); +# endif +#endif + + rp->flags &= ~RPLPOINT_FLAG_ACTIVE; + + savedmcode += REPLACEMENT_PATCH_SIZE; + } + + assert(savedmcode == code->savedmcode + count * REPLACEMENT_PATCH_SIZE); + + /* free saved machine code */ + + MFREE(code->savedmcode, u1, count * REPLACEMENT_PATCH_SIZE); + code->savedmcode = NULL; +} + + +/******************************************************************************/ +/* PART III: The replacement mechanism */ +/******************************************************************************/ + + +/* replace_read_value ********************************************************** + + Read a value with the given allocation from the execution state. + + IN: + es...............execution state + ra...............allocation + javaval..........where to put the value + + OUT: + *javaval.........the value + +*******************************************************************************/ + +static void replace_read_value(executionstate_t *es, + rplalloc *ra, + replace_val_t *javaval) +{ + if (ra->flags & INMEMORY) { + /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */ +#ifdef HAS_4BYTE_STACKSLOT + if (IS_2_WORD_TYPE(ra->type)) { + javaval->l = *(u8*)(es->sp + ra->regoff); + } + else { +#endif + javaval->p = *(ptrint*)(es->sp + ra->regoff); +#ifdef HAS_4BYTE_STACKSLOT + } +#endif + } + else { + /* allocated register */ + if (IS_FLT_DBL_TYPE(ra->type)) { + javaval->d = es->fltregs[ra->regoff]; + + if (ra->type == TYPE_FLT) + javaval->f = javaval->d; + } +#if defined(HAS_ADDRESS_REGISTER_FILE) + else if (IS_ADR_TYPE(ra->type)) { + javaval->p = es->adrregs[ra->regoff]; + } +#endif + else { +#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS) + if (ra->type == TYPE_LNG) { + javaval->words.lo = es->intregs[GET_LOW_REG(ra->regoff)]; + javaval->words.hi = es->intregs[GET_HIGH_REG(ra->regoff)]; + } + else +#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */ + javaval->p = es->intregs[ra->regoff]; + } + } +} + + +/* replace_write_value ********************************************************* + + Write a value to the given allocation in the execution state. + + IN: + es...............execution state + ra...............allocation + *javaval.........the value + +*******************************************************************************/ + +static void replace_write_value(executionstate_t *es, + rplalloc *ra, + replace_val_t *javaval) +{ + if (ra->flags & INMEMORY) { + /* XXX HAS_4BYTE_STACKSLOT may not be the right discriminant here */ +#ifdef HAS_4BYTE_STACKSLOT + if (IS_2_WORD_TYPE(ra->type)) { + *(u8*)(es->sp + ra->regoff) = javaval->l; + } + else { +#endif + *(ptrint*)(es->sp + ra->regoff) = javaval->p; +#ifdef HAS_4BYTE_STACKSLOT + } +#endif + } + else { + /* allocated register */ + switch (ra->type) { + case TYPE_FLT: + es->fltregs[ra->regoff] = (double) javaval->f; + break; + case TYPE_DBL: + es->fltregs[ra->regoff] = javaval->d; + break; +#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS) + case TYPE_LNG: + es->intregs[GET_LOW_REG(ra->regoff)] = javaval->words.lo; + es->intregs[GET_HIGH_REG(ra->regoff)] = javaval->words.hi; + break; +#endif +#if defined(HAS_ADDRESS_REGISTER_FILE) + case TYPE_ADR: + es->adrregs[ra->regoff] = javaval->p; +#endif + default: + es->intregs[ra->regoff] = javaval->p; + } + } +} + + +/* replace_new_sourceframe ***************************************************** + + Allocate a new source frame and insert it at the front of the frame list. + + IN: + ss...............the source state + + OUT: + ss->frames.......set to new frame (the new head of the frame list). + + RETURN VALUE: + returns the new frame + +*******************************************************************************/ + +static sourceframe_t *replace_new_sourceframe(sourcestate_t *ss) +{ + sourceframe_t *frame; + + frame = (sourceframe_t*) DumpMemory::allocate(sizeof(sourceframe_t)); + MZERO(frame, sourceframe_t, 1); + + frame->down = ss->frames; + ss->frames = frame; + + return frame; +} + + +/* replace_read_executionstate ************************************************* + + Read a source frame from the given executions state. + The new source frame is pushed to the front of the frame list of the + source state. + + IN: + rp...............replacement point at which `es` was taken + es...............execution state + ss...............the source state to add the source frame to + topframe.........true, if the first (top-most) source frame on the + stack is to be read + + OUT: + *ss..............the source state with the newly created source frame + added + +*******************************************************************************/ + +static s4 replace_normalize_type_map[] = { +/* RPLPOINT_TYPE_STD |--> */ RPLPOINT_TYPE_STD, +/* RPLPOINT_TYPE_EXH |--> */ RPLPOINT_TYPE_STD, +/* RPLPOINT_TYPE_SBR |--> */ RPLPOINT_TYPE_STD, +/* RPLPOINT_TYPE_CALL |--> */ RPLPOINT_TYPE_CALL, +/* RPLPOINT_TYPE_INLINE |--> */ RPLPOINT_TYPE_CALL, +/* RPLPOINT_TYPE_RETURN |--> */ RPLPOINT_TYPE_RETURN, +/* RPLPOINT_TYPE_BODY |--> */ RPLPOINT_TYPE_STD +}; + + +static void replace_read_executionstate(rplpoint *rp, + executionstate_t *es, + sourcestate_t *ss, + bool topframe) +{ + methodinfo *m; + codeinfo *code; + int count; + int i; + rplalloc *ra; + sourceframe_t *frame; + int topslot; + stackslot_t *sp; + stackslot_t *basesp; + + code = code_find_codeinfo_for_pc(rp->pc); + m = rp->method; + topslot = TOP_IS_NORMAL; + + /* stack pointer */ + + sp = (stackslot_t *) es->sp; + + /* in some cases the top stack slot is passed in REG_ITMP1 */ + + if (rp->type == BBTYPE_EXH) { + topslot = TOP_IS_IN_ITMP1; + } + + /* calculate base stack pointer */ + + basesp = sp + code->stackframesize; + + /* create the source frame */ + + frame = replace_new_sourceframe(ss); + frame->method = rp->method; + frame->id = rp->id; + assert(rp->type >= 0 && rp->type < sizeof(replace_normalize_type_map)/sizeof(s4)); + frame->type = replace_normalize_type_map[rp->type]; + frame->fromrp = rp; + frame->fromcode = code; + + /* read local variables */ + + count = m->maxlocals; + frame->javalocalcount = count; + frame->javalocals = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t) * count); + frame->javalocaltype = (u1*) DumpMemory::allocate(sizeof(u1) * count); + + /* mark values as undefined */ + for (i=0; ijavalocals[i].l = (u8) 0x00dead0000dead00ULL; +#endif + frame->javalocaltype[i] = TYPE_VOID; + } + + /* some entries in the intregs array are not meaningful */ + /*es->intregs[REG_ITMP3] = (u8) 0x11dead1111dead11ULL;*/ +#if !defined(NDEBUG) + es->intregs[REG_SP ] = (ptrint) 0x11dead1111dead11ULL; +#ifdef REG_PV + es->intregs[REG_PV ] = (ptrint) 0x11dead1111dead11ULL; +#endif +#endif /* !defined(NDEBUG) */ + + /* read javalocals */ + + count = rp->regalloccount; + ra = rp->regalloc; + + while (count && (i = ra->index) >= 0) { + assert(i < m->maxlocals); + frame->javalocaltype[i] = ra->type; + if (ra->type == TYPE_RET) + frame->javalocals[i].i = ra->regoff; + else + replace_read_value(es, ra, frame->javalocals + i); + ra++; + count--; + } + + /* read instance, if this is the first rplpoint */ + +#if defined(REPLACE_PATCH_DYNAMIC_CALL) + if (topframe && !(rp->method->flags & ACC_STATIC) && rp == code->rplpoints) { +#if 1 + /* we are at the start of the method body, so if local 0 is set, */ + /* it is the instance. */ + if (frame->javalocaltype[0] == TYPE_ADR) + frame->instance = frame->javalocals[0]; +#else + rplalloc instra; + methoddesc *md; + + md = rp->method->parseddesc; + assert(md->params); + assert(md->paramcount >= 1); + instra.type = TYPE_ADR; + instra.regoff = md->params[0].regoff; + if (md->params[0].inmemory) { + instra.flags = INMEMORY; + instra.regoff += (1 + code->stackframesize) * SIZE_OF_STACKSLOT; + } + else { + instra.flags = 0; + } + replace_read_value(es, &instra, &(frame->instance)); +#endif + } +#if defined(__I386__) + else if (!(rp->method->flags & ACC_STATIC)) { + /* On i386 we always pass the first argument on stack. */ + frame->instance.a = *(java_object_t **)(basesp + 1); + } +#endif +#endif /* defined(REPLACE_PATCH_DYNAMIC_CALL) */ + + /* read stack slots */ + + frame->javastackdepth = count; + frame->javastack = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t) * count); + frame->javastacktype = (u1*) DumpMemory::allocate(sizeof(u1) * count); + +#if !defined(NDEBUG) + /* mark values as undefined */ + for (i=0; ijavastack[i].l = (u8) 0x00dead0000dead00ULL; + frame->javastacktype[i] = TYPE_VOID; + } +#endif /* !defined(NDEBUG) */ + + i = 0; + + /* the first stack slot is special in SBR and EXH blocks */ + + if (topslot == TOP_IS_ON_STACK) { + assert(count); + + assert(ra->index == RPLALLOC_STACK); + assert(ra->type == TYPE_ADR); + frame->javastack[i].p = sp[-1]; + frame->javastacktype[i] = TYPE_ADR; /* XXX RET */ + count--; + i++; + ra++; + } + else if (topslot == TOP_IS_IN_ITMP1) { + assert(count); + + assert(ra->index == RPLALLOC_STACK); + assert(ra->type == TYPE_ADR); + frame->javastack[i].p = es->intregs[REG_ITMP1]; + frame->javastacktype[i] = TYPE_ADR; /* XXX RET */ + count--; + i++; + ra++; + } + else if (topslot == TOP_IS_VOID) { + assert(count); + + assert(ra->index == RPLALLOC_STACK); + frame->javastack[i].l = 0; + frame->javastacktype[i] = TYPE_VOID; + count--; + i++; + ra++; + } + + /* read remaining stack slots */ + + for (; count--; ra++) { + if (ra->index == RPLALLOC_SYNC) { + assert(rp->type == RPLPOINT_TYPE_INLINE); + + /* only read synchronization slots when traversing an inline point */ + + if (!topframe) { + sourceframe_t *calleeframe = frame->down; + assert(calleeframe); + assert(calleeframe->syncslotcount == 0); + assert(calleeframe->syncslots == NULL); + + calleeframe->syncslotcount = 1; + calleeframe->syncslots = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t)); + replace_read_value(es,ra,calleeframe->syncslots); + } + + frame->javastackdepth--; + continue; + } + + assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM); + + /* do not read parameters of calls down the call chain */ + + if (!topframe && ra->index == RPLALLOC_PARAM) { + frame->javastackdepth--; + } + else { + if (ra->type == TYPE_RET) + frame->javastack[i].i = ra->regoff; + else + replace_read_value(es,ra,frame->javastack + i); + frame->javastacktype[i] = ra->type; + i++; + } + } +} + + +/* replace_write_executionstate ************************************************ + + Pop a source frame from the front of the frame list of the given source state + and write its values into the execution state. + + IN: + rp...............replacement point for which execution state should be + created + es...............the execution state to modify + ss...............the given source state + topframe.........true, if this is the last (top-most) source frame to be + translated + + OUT: + *es..............the execution state derived from the source state + +*******************************************************************************/ + +static void replace_write_executionstate(rplpoint *rp, + executionstate_t *es, + sourcestate_t *ss, + bool topframe) +{ + methodinfo *m; + codeinfo *code; + int count; + int i; + rplalloc *ra; + sourceframe_t *frame; + int topslot; + stackslot_t *sp; + stackslot_t *basesp; + + code = code_find_codeinfo_for_pc(rp->pc); + m = rp->method; + topslot = TOP_IS_NORMAL; + + /* pop a source frame */ + + frame = ss->frames; + assert(frame); + ss->frames = frame->down; + + /* calculate stack pointer */ + + sp = (stackslot_t *) es->sp; + + basesp = sp + code->stackframesize; + + /* in some cases the top stack slot is passed in REG_ITMP1 */ + + if (rp->type == BBTYPE_EXH) { + topslot = TOP_IS_IN_ITMP1; + } + + /* write javalocals */ + + ra = rp->regalloc; + count = rp->regalloccount; + + while (count && (i = ra->index) >= 0) { + assert(i < m->maxlocals); + assert(i < frame->javalocalcount); + assert(ra->type == frame->javalocaltype[i]); + if (ra->type == TYPE_RET) { + /* XXX assert that it matches this rplpoint */ + } + else + replace_write_value(es, ra, frame->javalocals + i); + count--; + ra++; + } + + /* write stack slots */ + + i = 0; + + /* the first stack slot is special in SBR and EXH blocks */ + + if (topslot == TOP_IS_ON_STACK) { + assert(count); + + assert(ra->index == RPLALLOC_STACK); + assert(i < frame->javastackdepth); + assert(frame->javastacktype[i] == TYPE_ADR); + sp[-1] = frame->javastack[i].p; + count--; + i++; + ra++; + } + else if (topslot == TOP_IS_IN_ITMP1) { + assert(count); + + assert(ra->index == RPLALLOC_STACK); + assert(i < frame->javastackdepth); + assert(frame->javastacktype[i] == TYPE_ADR); + es->intregs[REG_ITMP1] = frame->javastack[i].p; + count--; + i++; + ra++; + } + else if (topslot == TOP_IS_VOID) { + assert(count); + + assert(ra->index == RPLALLOC_STACK); + assert(i < frame->javastackdepth); + assert(frame->javastacktype[i] == TYPE_VOID); + count--; + i++; + ra++; + } + + /* write remaining stack slots */ + + for (; count--; ra++) { + if (ra->index == RPLALLOC_SYNC) { + assert(rp->type == RPLPOINT_TYPE_INLINE); + + /* only write synchronization slots when traversing an inline point */ + + if (!topframe) { + assert(frame->down); + assert(frame->down->syncslotcount == 1); /* XXX need to understand more cases */ + assert(frame->down->syncslots != NULL); + + replace_write_value(es,ra,frame->down->syncslots); + } + continue; + } + + assert(ra->index == RPLALLOC_STACK || ra->index == RPLALLOC_PARAM); + + /* do not write parameters of calls down the call chain */ + + if (!topframe && ra->index == RPLALLOC_PARAM) { + /* skip it */ + /* + ra->index = RPLALLOC_PARAM; + replace_val_t v; + v.l = 0; + replace_write_value(es,ra,&v); + */ + } + else { + assert(i < frame->javastackdepth); + assert(ra->type == frame->javastacktype[i]); + if (ra->type == TYPE_RET) { + /* XXX assert that it matches this rplpoint */ + } + else { + replace_write_value(es,ra,frame->javastack + i); + } + i++; + } + } + + /* set new pc */ + + es->pc = rp->pc; +} + + +/* md_pop_stackframe *********************************************************** + + Restore callee-saved registers (including the RA register), + set the stack pointer to the next stackframe, + set the PC to the return address of the popped frame. + + *** This function imitates the effects of the method epilog *** + *** and returning from the method call. *** + + IN: + es...............execution state + + OUT: + *es..............the execution state after popping the stack frame + NOTE: es->code and es->pv are NOT updated. + +*******************************************************************************/ + +void md_pop_stackframe(executionstate_t *es) +{ + u1 *ra; + s4 ra_align_off; + s4 reg; + s4 i; + stackslot_t *basesp; + stackslot_t *sp; + + assert(es->code); + + /* alignment offset of RA */ + + ra_align_off = 0; +#if defined(REPLACE_RA_BETWEEN_FRAMES) + if (es->code->stackframesize) + ra_align_off = SIZE_OF_STACKSLOT - SIZEOF_VOID_P; +#endif + + /* read the return address */ + +#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) + if (code_is_leafmethod(es->code)) + ra = es->ra; + else +#endif + ra = (u1*) md_stacktrace_get_returnaddress(es->sp, + SIZE_OF_STACKSLOT * es->code->stackframesize + ra_align_off); + + /* calculate the base of the stack frame */ + + sp = (stackslot_t *) es->sp; + basesp = sp + es->code->stackframesize; + + /* restore return address, if part of frame */ + +#if defined(REPLACE_RA_TOP_OF_FRAME) +#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) + if (!code_is_leafmethod(es->code)) +#endif + es->ra = (u1*) (ptrint) *--basesp; +#endif /* REPLACE_RA_TOP_OF_FRAME */ + +#if defined(REPLACE_RA_LINKAGE_AREA) +#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) + if (!code_is_leafmethod(es->code)) +#endif + es->ra = (u1*) (ptrint) basesp[LA_LR_OFFSET / sizeof(stackslot_t)]; +#endif /* REPLACE_RA_LINKAGE_AREA */ + + /* restore saved int registers */ + + reg = INT_REG_CNT; + for (i=0; icode->savedintcount; ++i) { + while (nregdescint[--reg] != REG_SAV) + ; + es->intregs[reg] = *--basesp; + } + + /* restore saved flt registers */ + + /* XXX align? */ + reg = FLT_REG_CNT; + for (i=0; icode->savedfltcount; ++i) { + while (nregdescfloat[--reg] != REG_SAV) + ; + basesp -= STACK_SLOTS_PER_FLOAT; + es->fltregs[reg] = *(double*)basesp; + } + +#if defined(HAS_ADDRESS_REGISTER_FILE) + /* restore saved adr registers */ + + reg = ADR_REG_CNT; + for (i=0; icode->savedadrcount; ++i) { + while (nregdescadr[--reg] != REG_SAV) + ; + es->adrregs[reg] = *--basesp; + } +#endif + + /* adjust the stackpointer */ + + es->sp += SIZE_OF_STACKSLOT * es->code->stackframesize; + +#if defined(REPLACE_RA_BETWEEN_FRAMES) + es->sp += ra_align_off + SIZEOF_VOID_P; /* skip return address */ +#endif + + /* set the program counter to the return address */ + + es->pc = ra; + + /* in debugging mode clobber non-saved registers */ + +#if !defined(NDEBUG) + /* for debugging */ + for (i=0; iintregs[i] = (ptrint) 0x33dead3333dead33ULL; + for (i=0; ifltregs[i]) = 0x33dead3333dead33ULL; +# if defined(HAS_ADDRESS_REGISTER_FILE) + for (i=0; iadrregs[i] = (ptrint) 0x33dead3333dead33ULL; +# endif +#endif /* !defined(NDEBUG) */ +} + + +/* md_push_stackframe ********************************************************** + + Save the given return address, build the new stackframe, + and store callee-saved registers. + + *** This function imitates the effects of a call and the *** + *** method prolog of the callee. *** + + IN: + es...............execution state + calleecode.......the code we are "calling" + ra...............the return address to save + + OUT: + *es..............the execution state after pushing the stack frame + NOTE: es->pc, es->code, and es->pv are NOT updated. + +*******************************************************************************/ + +void md_push_stackframe(executionstate_t *es, codeinfo *calleecode, u1 *ra) +{ + s4 reg; + s4 i; + stackslot_t *basesp; + stackslot_t *sp; + + assert(es); + assert(calleecode); + + /* write the return address */ + +#if defined(REPLACE_RA_BETWEEN_FRAMES) + es->sp -= SIZEOF_VOID_P; + *((void **)es->sp) = (void *) ra; + if (calleecode->stackframesize) + es->sp -= (SIZE_OF_STACKSLOT - SIZEOF_VOID_P); +#endif /* REPLACE_RA_BETWEEN_FRAMES */ + + es->ra = (u1*) (ptrint) ra; + + /* build the stackframe */ + + DOLOG( printf("building stackframe of %d words at %p\n", + calleecode->stackframesize, (void*)es->sp); ); + + sp = (stackslot_t *) es->sp; + basesp = sp; + + sp -= calleecode->stackframesize; + es->sp = (u1*) sp; + + /* in debug mode, invalidate stack frame first */ + + /* XXX may not invalidate linkage area used by native code! */ + +#if !defined(NDEBUG) && 0 + for (i=0; i< (basesp - sp) && i < 1; ++i) { + sp[i] = 0xdeaddeadU; + } +#endif + +#if defined(__I386__) + /* Stackslot 0 may contain the object instance for vftbl patching. + Destroy it, so there's no undefined value used. */ + if ((basesp - sp) > 0) { + sp[0] = 0; + } +#endif + + /* save the return address register */ + +#if defined(REPLACE_RA_TOP_OF_FRAME) +#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) + if (!code_is_leafmethod(calleecode)) +#endif + *--basesp = (ptrint) ra; +#endif /* REPLACE_RA_TOP_OF_FRAME */ + +#if defined(REPLACE_RA_LINKAGE_AREA) +#if defined(REPLACE_LEAFMETHODS_RA_REGISTER) + if (!code_is_leafmethod(calleecode)) +#endif + basesp[LA_LR_OFFSET / sizeof(stackslot_t)] = (ptrint) ra; +#endif /* REPLACE_RA_LINKAGE_AREA */ + + /* save int registers */ + + reg = INT_REG_CNT; + for (i=0; isavedintcount; ++i) { + while (nregdescint[--reg] != REG_SAV) + ; + *--basesp = es->intregs[reg]; + + /* XXX may not clobber saved regs used by native code! */ +#if !defined(NDEBUG) && 0 + es->intregs[reg] = (ptrint) 0x44dead4444dead44ULL; +#endif + } + + /* save flt registers */ + + /* XXX align? */ + reg = FLT_REG_CNT; + for (i=0; isavedfltcount; ++i) { + while (nregdescfloat[--reg] != REG_SAV) + ; + basesp -= STACK_SLOTS_PER_FLOAT; + *(double*)basesp = es->fltregs[reg]; + + /* XXX may not clobber saved regs used by native code! */ +#if !defined(NDEBUG) && 0 + *(u8*)&(es->fltregs[reg]) = 0x44dead4444dead44ULL; +#endif + } + +#if defined(HAS_ADDRESS_REGISTER_FILE) + /* save adr registers */ + + reg = ADR_REG_CNT; + for (i=0; isavedadrcount; ++i) { + while (nregdescadr[--reg] != REG_SAV) + ; + *--basesp = es->adrregs[reg]; + + /* XXX may not clobber saved regs used by native code! */ +#if !defined(NDEBUG) && 0 + es->adrregs[reg] = (ptrint) 0x44dead4444dead44ULL; +#endif + } +#endif +} + + +/* replace_pop_activation_record *********************************************** + + Peel a stack frame from the execution state. + + *** This function imitates the effects of the method epilog *** + *** and returning from the method call. *** + + IN: + es...............execution state + frame............source frame, receives synchronization slots + + OUT: + *es..............the execution state after popping the stack frame + + RETURN VALUE: + the return address of the poped activation record + +*******************************************************************************/ + +u1* replace_pop_activation_record(executionstate_t *es, + sourceframe_t *frame) +{ + u1 *ra; + s4 i; + s4 count; + codeinfo *code; + stackslot_t *sp; + + assert(es->code); + assert(frame); + + /* calculate the base of the stack frame */ + + sp = (stackslot_t *) es->sp; + assert(frame->syncslotcount == 0); + assert(frame->syncslots == NULL); + count = code_get_sync_slot_count(es->code); + frame->syncslotcount = count; + frame->syncslots = (replace_val_t*) DumpMemory::allocate(sizeof(replace_val_t) * count); + for (i=0; isyncslots[i].p = sp[es->code->memuse + i]; /* XXX md_ function */ + } + + /* pop the stackframe */ + + md_pop_stackframe(es); + + ra = es->pc; + + DOLOG( printf("RA = %p\n", (void*)ra); ); + + /* Subtract one from the PC so we do not hit the replacement point */ + /* of the instruction following the call, if there is one. */ + + es->pc--; + + /* find the new codeinfo */ + + void* pv = md_codegen_get_pv_from_pc(ra); + DOLOG( printf("PV = %p\n", pv); ); + + code = code_get_codeinfo_for_pv(pv); + DOLOG( printf("CODE = %p\n", (void*) code); ); + + /* return NULL if we reached native code */ + + es->pv = (uint8_t*) pv; + es->code = code; + + return (code) ? ra : NULL; +} + + +/* replace_patch_method_pointer ************************************************ + + Patch a method pointer (may be in code, data segment, vftbl, or interface + table). + + IN: + mpp..............address of the method pointer to patch + entrypoint.......the new entrypoint of the method + kind.............kind of call to patch, used only for debugging + +*******************************************************************************/ + +static void replace_patch_method_pointer(methodptr *mpp, + methodptr entrypoint, + const char *kind) +{ +#if !defined(NDEBUG) + codeinfo *oldcode; + codeinfo *newcode; +#endif + + DOLOG( printf("patch method pointer from: %p to %p\n", + (void*) *mpp, (void*)entrypoint); ); + +#if !defined(NDEBUG) + oldcode = code_get_codeinfo_for_pv(*mpp); + newcode = code_get_codeinfo_for_pv(entrypoint); + + DOLOG_SHORT( printf("\tpatch %s %p ", kind, (void*) oldcode); + method_println(oldcode->m); + printf("\t with %p ", (void*) newcode); + method_println(newcode->m); ); + + assert(oldcode->m == newcode->m); +#endif + + /* write the new entrypoint */ + + *mpp = (methodptr) entrypoint; +} + + +/* replace_patch_class ********************************************************* + + Patch a method in the given class. + + IN: + vftbl............vftbl of the class + m................the method to patch + oldentrypoint....the old entrypoint to replace + entrypoint.......the new entrypoint + +*******************************************************************************/ + +void replace_patch_class(vftbl_t *vftbl, + methodinfo *m, + u1 *oldentrypoint, + u1 *entrypoint) +{ + s4 i; + methodptr *mpp; + methodptr *mppend; + + /* patch the vftbl of the class */ + + replace_patch_method_pointer(vftbl->table + m->vftblindex, + entrypoint, + "virtual "); + + /* patch the interface tables */ + + assert(oldentrypoint); + + for (i=0; i < vftbl->interfacetablelength; ++i) { + mpp = vftbl->interfacetable[-i]; + mppend = mpp + vftbl->interfacevftbllength[i]; + for (; mpp != mppend; ++mpp) + if (*mpp == oldentrypoint) { + replace_patch_method_pointer(mpp, entrypoint, "interface"); + } + } +} + + +/* replace_patch_class_hierarchy *********************************************** + + Patch a method in all loaded classes. + + IN: + m................the method to patch + oldentrypoint....the old entrypoint to replace + entrypoint.......the new entrypoint + +*******************************************************************************/ + +struct replace_patch_data_t { + methodinfo *m; + u1 *oldentrypoint; + u1 *entrypoint; +}; + +void replace_patch_callback(classinfo *c, struct replace_patch_data_t *pd) +{ + vftbl_t *vftbl = c->vftbl; + + if (vftbl != NULL + && vftbl->vftbllength > pd->m->vftblindex + && (void*) vftbl->table[pd->m->vftblindex] != (void*) (uintptr_t) &asm_abstractmethoderror + && code_get_methodinfo_for_pv(vftbl->table[pd->m->vftblindex]) == pd->m) + { + replace_patch_class(c->vftbl, pd->m, pd->oldentrypoint, pd->entrypoint); + } +} + +void replace_patch_class_hierarchy(methodinfo *m, + u1 *oldentrypoint, + u1 *entrypoint) +{ + struct replace_patch_data_t pd; + + pd.m = m; + pd.oldentrypoint = oldentrypoint; + pd.entrypoint = entrypoint; + + DOLOG_SHORT( printf("patching class hierarchy: "); + method_println(m); ); + + classcache_foreach_loaded_class( + (classcache_foreach_functionptr_t) &replace_patch_callback, + (void*) &pd); +} + + +/* replace_patch_future_calls ************************************************** + + Analyse a call site and depending on the kind of call patch the call, the + virtual function table, or the interface table. + + IN: + ra...............return address pointing after the call site + callerframe......source frame of the caller + calleeframe......source frame of the callee, must have been mapped + +*******************************************************************************/ + +void replace_patch_future_calls(u1 *ra, + sourceframe_t *callerframe, + sourceframe_t *calleeframe) +{ + u1 *patchpos; + methodptr entrypoint; + methodptr oldentrypoint; + bool atentry; + void *pv; + codeinfo *calleecode; + methodinfo *calleem; + java_object_t *obj; + vftbl_t *vftbl; + + assert(ra); + assert(callerframe->down == calleeframe); + + /* get the new codeinfo and the method that shall be entered */ + + calleecode = calleeframe->tocode; + assert(calleecode); + + calleem = calleeframe->method; + assert(calleem == calleecode->m); + + entrypoint = (methodptr) calleecode->entrypoint; + + /* check if we are at an method entry rplpoint at the innermost frame */ + + atentry = (calleeframe->down == NULL) + && !(calleem->flags & ACC_STATIC) + && (calleeframe->fromrp->id == 0); /* XXX */ + + /* get the position to patch, in case it was a statically bound call */ + + pv = callerframe->fromcode->entrypoint; + patchpos = (u1*) md_jit_method_patch_address(pv, ra, NULL); + + if (patchpos == NULL) { + /* the call was dispatched dynamically */ + + /* we can only patch such calls if we are at the entry point */ + +#if !defined(__I386__) + /* On i386 we always know the instance argument. */ + if (!atentry) + return; +#endif + + assert((calleem->flags & ACC_STATIC) == 0); + + oldentrypoint = calleeframe->fromcode->entrypoint; + + /* we need to know the instance */ + + if (!calleeframe->instance.a) { + DOLOG_SHORT( printf("WARNING: object instance unknown!\n"); ); + replace_patch_class_hierarchy(calleem, oldentrypoint, entrypoint); + return; + } + + /* get the vftbl */ + + obj = calleeframe->instance.a; + vftbl = obj->vftbl; + + assert(vftbl->clazz->vftbl == vftbl); + + DOLOG_SHORT( printf("\tclass: "); class_println(vftbl->clazz); ); + + replace_patch_class(vftbl, calleem, oldentrypoint, entrypoint); + } + else { + /* the call was statically bound */ + +#if defined(__I386__) + /* It happens that there is a patcher trap. (pm) */ + if (*(u2 *)(patchpos - 1) == 0x0b0f) { + } else +#endif + replace_patch_method_pointer((methodptr *) patchpos, entrypoint, "static "); + } +} + + +/* replace_push_activation_record ********************************************** + + Push a stack frame onto the execution state. + + *** This function imitates the effects of a call and the *** + *** method prolog of the callee. *** + + IN: + es...............execution state + rpcall...........the replacement point at the call site + callerframe......source frame of the caller, or NULL for creating the + first frame + calleeframe......source frame of the callee, must have been mapped + + OUT: + *es..............the execution state after pushing the stack frame + +*******************************************************************************/ + +void replace_push_activation_record(executionstate_t *es, + rplpoint *rpcall, + sourceframe_t *callerframe, + sourceframe_t *calleeframe) +{ + s4 i; + s4 count; + stackslot_t *sp; + u1 *ra; + codeinfo *calleecode; + + assert(es); + assert(!rpcall || callerframe); + assert(!rpcall || rpcall->type == RPLPOINT_TYPE_CALL); + assert(!rpcall || rpcall == callerframe->torp); + assert(calleeframe); + assert(!callerframe || calleeframe == callerframe->down); + + /* the compilation unit we are entering */ + + calleecode = calleeframe->tocode; + assert(calleecode); + + /* calculate the return address */ + + if (rpcall) + ra = rpcall->pc + rpcall->callsize; + else + ra = es->pc + 1 /* XXX this is ugly */; + + /* push the stackframe */ + + md_push_stackframe(es, calleecode, ra); + + /* we move into a new code unit, set code, PC, PV */ + + es->code = calleecode; + es->pc = calleecode->entrypoint; /* XXX not needed? */ + es->pv = calleecode->entrypoint; + + /* write slots used for synchronization */ + + sp = (stackslot_t *) es->sp; + count = code_get_sync_slot_count(calleecode); + assert(count == calleeframe->syncslotcount); + for (i=0; imemuse + i] = calleeframe->syncslots[i].p; + } + + /* redirect future invocations */ + + if (callerframe && rpcall) { +#if defined(REPLACE_PATCH_ALL) + if (rpcall->type == callerframe->fromrp->type) +#else + if (rpcall == callerframe->fromrp) +#endif + replace_patch_future_calls(ra, callerframe, calleeframe); + } +} + + +/* replace_find_replacement_point ********************************************** + + Find the replacement point in the given code corresponding to the + position given in the source frame. + + IN: + code.............the codeinfo in which to search the rplpoint + frame............the source frame defining the position to look for + parent...........parent replacement point to match + + RETURN VALUE: + the replacement point + +*******************************************************************************/ + +rplpoint * replace_find_replacement_point(codeinfo *code, + sourceframe_t *frame, + rplpoint *parent) +{ + methodinfo *m; + rplpoint *rp; + s4 i; + s4 j; + s4 stacki; + rplalloc *ra; + + assert(code); + assert(frame); + + DOLOG( printf("searching replacement point for:\n"); + replace_source_frame_println(frame); ); + + m = frame->method; + + DOLOG( printf("code = %p\n", (void*)code); ); + + rp = code->rplpoints; + i = code->rplpointcount; + while (i--) { + if (rp->id == frame->id && rp->method == frame->method + && rp->parent == parent + && replace_normalize_type_map[rp->type] == frame->type) + { + /* check if returnAddresses match */ + /* XXX optimize: only do this if JSRs in method */ + DOLOG( printf("checking match for:"); + replace_replacement_point_println(rp, 1); fflush(stdout); ); + ra = rp->regalloc; + stacki = 0; + for (j = rp->regalloccount; j--; ++ra) { + if (ra->type == TYPE_RET) { + if (ra->index == RPLALLOC_STACK) { + assert(stacki < frame->javastackdepth); + if (frame->javastack[stacki].i != ra->regoff) + goto no_match; + stacki++; + } + else { + assert(ra->index >= 0 && ra->index < frame->javalocalcount); + if (frame->javalocals[ra->index].i != ra->regoff) + goto no_match; + } + } + } + + /* found */ + return rp; + } +no_match: + rp++; + } + +#if !defined(NDEBUG) + printf("candidate replacement points were:\n"); + rp = code->rplpoints; + i = code->rplpointcount; + for (; i--; ++rp) { + replace_replacement_point_println(rp, 1); + } +#endif + + vm_abort("no matching replacement point found"); + return NULL; /* NOT REACHED */ +} + + +/* replace_find_replacement_point_for_pc *************************************** + + Find the nearest replacement point at or before the given PC. The + given PC has to be between (rp->pc) and (rp->pc+rp->callsize) for + the replacement point to be found. + + IN: + code.............compilation unit the PC is in + pc...............the machine code PC + + RETURN VALUE: + the replacement point found, or + NULL if no replacement point was found + +*******************************************************************************/ + +rplpoint *replace_find_replacement_point_for_pc(codeinfo *code, u1 *pc, unsigned desired_flags) +{ + rplpoint *found; + rplpoint *rp; + s4 i; + + DOLOG( printf("searching for rp at pc:%p in %p ", (void*)pc, (void*)code); + method_println(code->m); ); + + found = NULL; + + rp = code->rplpoints; + for (i=0; irplpointcount; ++i, ++rp) { + DOLOG( replace_replacement_point_println(rp, 2); ); + if (rp->pc <= pc && rp->pc + rp->callsize >= pc) { + if (desired_flags) { + if (rp->flags & desired_flags) { + found = rp; + } + } else { + found = rp; + } + } + } + + return found; +} + +/* replace_pop_native_frame **************************************************** + + Unroll a native frame in the execution state and create a source frame + for it. + + IN: + es...............current execution state + ss...............the current source state + sfi..............stackframeinfo for the native frame + + OUT: + es...............execution state after unrolling the native frame + ss...............gets the added native source frame + +*******************************************************************************/ + +static void replace_pop_native_frame(executionstate_t *es, + sourcestate_t *ss, + stackframeinfo_t *sfi) +{ + sourceframe_t *frame; + codeinfo *code; + s4 i,j; + + assert(sfi); + + frame = replace_new_sourceframe(ss); + + frame->sfi = sfi; + + /* remember pc and size of native frame */ + + frame->nativepc = es->pc; + frame->nativeframesize = (es->sp != 0) ? (((uintptr_t) sfi->sp) - ((uintptr_t) es->sp)) : 0; + assert(frame->nativeframesize >= 0); + + /* remember values of saved registers */ + + j = 0; + for (i=0; inativesavint[j++] = es->intregs[i]; + } + + j = 0; + for (i=0; inativesavflt[j++] = es->fltregs[i]; + } + +#if defined(HAS_ADDRESS_REGISTER_FILE) + j = 0; + for (i=0; inativesavadr[j++] = es->adrregs[i]; + } +#endif + + /* restore saved registers */ + +#if defined(ENABLE_GC_CACAO) && !defined(HAS_ADDRESS_REGISTER_FILE) + j = 0; + for (i=0; iintregs[i] = sfi->intregs[j++]; + } +#else + /* XXX we don't have them, yet, in the sfi, so clear them */ + + for (i=0; iintregs[i] = 0; + } +#endif + + /* XXX we don't have float registers in the sfi, so clear them */ + + for (i=0; ifltregs[i] = 0.0; + } + +#if defined(HAS_ADDRESS_REGISTER_FILE) +# if defined(ENABLE_GC_CACAO) + j = 0; + for (i=0; iadrregs[i] = sfi->adrregs[j++]; + } +# else + for (i=0; iadrregs[i] = 0; + } +# endif +#endif + + /* restore codeinfo of the native stub */ + + code = code_get_codeinfo_for_pv(sfi->pv); + + /* restore sp, pv, pc and codeinfo of the parent method */ + + /* XXX michi: use this instead: + es->sp = sfi->sp + code->stackframesize; */ + es->sp = (uint8_t*) (((uintptr_t) sfi->sp) + (*(s4 *) (((uintptr_t) sfi->pv) + FrameSize))); +#if defined(REPLACE_RA_BETWEEN_FRAMES) + es->sp += SIZE_OF_STACKSLOT; /* skip return address */ +#endif + es->pv = (uint8_t*) md_codegen_get_pv_from_pc(sfi->ra); + es->pc = (uint8_t*) (((uintptr_t) ((sfi->xpc) ? sfi->xpc : sfi->ra)) - 1); + es->code = code_get_codeinfo_for_pv(es->pv); +} + + +/* replace_push_native_frame *************************************************** + + Rebuild a native frame onto the execution state and remove its source frame. + + Note: The native frame is "rebuild" by setting fields like PC and stack + pointer in the execution state accordingly. Values in the + stackframeinfo may be modified, but the actual stack frame of the + native code is not touched. + + IN: + es...............current execution state + ss...............the current source state + + OUT: + es...............execution state after re-rolling the native frame + ss...............the native source frame is removed + +*******************************************************************************/ + +static void replace_push_native_frame(executionstate_t *es, sourcestate_t *ss) +{ + sourceframe_t *frame; + s4 i,j; + + assert(es); + assert(ss); + + DOLOG( printf("pushing native frame\n"); ); + + /* remove the frame from the source state */ + + frame = ss->frames; + assert(frame); + assert(REPLACE_IS_NATIVE_FRAME(frame)); + + ss->frames = frame->down; + + /* skip sp for the native stub */ + + es->sp -= (*(s4 *) (((uintptr_t) frame->sfi->pv) + FrameSize)); +#if defined(REPLACE_RA_BETWEEN_FRAMES) + es->sp -= SIZE_OF_STACKSLOT; /* skip return address */ +#endif + + /* assert that the native frame has not moved */ + + assert(es->sp == frame->sfi->sp); + + /* update saved registers in the stackframeinfo */ + +#if defined(ENABLE_GC_CACAO) + j = 0; +# if !defined(HAS_ADDRESS_REGISTER_FILE) + for (i=0; isfi->intregs[j++] = es->intregs[i]; + } +# else + for (i=0; isfi->adrregs[j++] = es->adrregs[i]; + } +# endif + + /* XXX leave float registers untouched here */ +#endif + + /* restore saved registers */ + + j = 0; + for (i=0; iintregs[i] = frame->nativesavint[j++]; + } + + j = 0; + for (i=0; ifltregs[i] = frame->nativesavflt[j++]; + } + +#if defined(HAS_ADDRESS_REGISTER_FILE) + j = 0; + for (i=0; iadrregs[i] = frame->nativesavadr[j++]; + } +#endif + + /* skip the native frame on the machine stack */ + + es->sp -= frame->nativeframesize; + + /* set the pc the next frame must return to */ + + es->pc = frame->nativepc; +} + + +/* replace_recover_source_state ************************************************ + + Recover the source state from the given replacement point and execution + state. + + IN: + rp...............replacement point that has been reached, if any + sfi..............stackframeinfo, if called from native code + es...............execution state at the replacement point rp + + RETURN VALUE: + the source state + +*******************************************************************************/ + +sourcestate_t *replace_recover_source_state(rplpoint *rp, + stackframeinfo_t *sfi, + executionstate_t *es) +{ + sourcestate_t *ss; + u1 *ra; + bool locked; +#if defined(REPLACE_STATISTICS) + s4 depth; +#endif + + /* create the source frame structure in dump memory */ + + ss = (sourcestate_t*) DumpMemory::allocate(sizeof(sourcestate_t)); + ss->frames = NULL; + + /* each iteration of the loop recovers one source frame */ + + depth = 0; + locked = false; + + while (rp || sfi) { + + DOLOG( executionstate_println(es); ); + + /* if we are not at a replacement point, it is a native frame */ + + if (rp == NULL) { + DOLOG( printf("native frame: sfi: "); replace_stackframeinfo_println(sfi); ); + + locked = true; + replace_pop_native_frame(es, ss, sfi); + sfi = sfi->prev; + + if (es->code == NULL) + continue; + + goto after_machine_frame; + } + + /* read the values for this source frame from the execution state */ + + DOLOG( printf("recovering source state for%s:\n", + (ss->frames == NULL) ? " TOPFRAME" : ""); + replace_replacement_point_println(rp, 1); ); + + replace_read_executionstate(rp, es, ss, ss->frames == NULL); + +#if defined(ENABLE_VMLOG) + vmlog_cacao_unrol_method(ss->frames->method); +#endif + +#if defined(REPLACE_STATISTICS) + REPLACE_COUNT(stat_frames); + depth++; + replace_statistics_source_frame(ss->frames); +#endif + + /* in locked areas (below native frames), identity map the frame */ + + if (locked) { + ss->frames->torp = ss->frames->fromrp; + ss->frames->tocode = ss->frames->fromcode; + } + + /* unroll to the next (outer) frame */ + + if (rp->parent) { + /* this frame is in inlined code */ + + DOLOG( printf("INLINED!\n"); ); + + rp = rp->parent; + + assert(rp->type == RPLPOINT_TYPE_INLINE); + REPLACE_COUNT(stat_unroll_inline); + } + else { + /* this frame had been called at machine-level. pop it. */ + + DOLOG( printf("UNWIND\n"); ); + + ra = replace_pop_activation_record(es, ss->frames); + if (ra == NULL) { + DOLOG( printf("REACHED NATIVE CODE\n"); ); + + rp = NULL; + +#if !defined(ENABLE_GC_CACAO) + break; /* XXX remove to activate native frames */ +#endif + continue; + } + + /* find the replacement point at the call site */ + +after_machine_frame: + rp = replace_find_replacement_point_for_pc(es->code, es->pc, 0); + + if (rp == NULL) + vm_abort("could not find replacement point while unrolling call"); + + DOLOG( printf("found replacement point.\n"); + replace_replacement_point_println(rp, 1); ); + + assert(rp->type == RPLPOINT_TYPE_CALL); + REPLACE_COUNT(stat_unroll_call); + } + } /* end loop over source frames */ + + REPLACE_COUNT_DIST(stat_dist_frames, depth); + + return ss; +} + + +/* replace_map_source_state **************************************************** + + Map each source frame in the given source state to a target replacement + point and compilation unit. If no valid code is available for a source + frame, it is (re)compiled. + + IN: + ss...............the source state + + OUT: + ss...............the source state, modified: The `torp` and `tocode` + fields of each source frame are set. + + RETURN VALUE: + true.............everything went ok + false............an exception has been thrown + +*******************************************************************************/ + +static bool replace_map_source_state(sourcestate_t *ss) +{ + sourceframe_t *frame; + codeinfo *code; + rplpoint *rp; + rplpoint *parent; /* parent of inlined rplpoint */ +#if defined(REPLACE_STATISTICS) + codeinfo *oldcode; +#endif + + parent = NULL; + code = NULL; + + /* iterate over the source frames from outermost to innermost */ + + for (frame = ss->frames; frame != NULL; frame = frame->down) { + + /* XXX skip native frames */ + + if (REPLACE_IS_NATIVE_FRAME(frame)) { + parent = NULL; + continue; + } + + /* map frames which are not already mapped */ + + if (frame->tocode) { + code = frame->tocode; + rp = frame->torp; + assert(rp); + } + else { + assert(frame->torp == NULL); + + if (parent == NULL) { + /* find code for this frame */ + +#if defined(REPLACE_STATISTICS) + oldcode = frame->method->code; +#endif + /* request optimization of hot methods and their callers */ + + if (frame->method->hitcountdown < 0 + || (frame->down && frame->down->method->hitcountdown < 0)) + jit_request_optimization(frame->method); + + code = jit_get_current_code(frame->method); + + if (code == NULL) + return false; /* exception */ + + REPLACE_COUNT_IF(stat_recompile, code != oldcode); + } + + assert(code); + + /* map this frame */ + + rp = replace_find_replacement_point(code, frame, parent); + + frame->tocode = code; + frame->torp = rp; + } + + if (rp->type == RPLPOINT_TYPE_CALL) { + parent = NULL; + } + else { + /* inlining */ + parent = rp; + } + } + + return true; +} + + +/* replace_map_source_state_identity ******************************************* + + Map each source frame in the given source state to the same replacement + point and compilation unit it was derived from. This is mainly used for + garbage collection. + + IN: + ss...............the source state + + OUT: + ss...............the source state, modified: The `torp` and `tocode` + fields of each source frame are set. + +*******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +static void replace_map_source_state_identity(sourcestate_t *ss) +{ + sourceframe_t *frame; + + /* iterate over the source frames from outermost to innermost */ + + for (frame = ss->frames; frame != NULL; frame = frame->down) { + + /* skip native frames */ + + if (REPLACE_IS_NATIVE_FRAME(frame)) { + continue; + } + + /* map frames using the identity mapping */ + + if (frame->tocode) { + assert(frame->tocode == frame->fromcode); + assert(frame->torp == frame->fromrp); + } else { + assert(frame->tocode == NULL); + assert(frame->torp == NULL); + frame->tocode = frame->fromcode; + frame->torp = frame->fromrp; + } + } +} +#endif + + +/* replace_build_execution_state *********************************************** + + Build an execution state for the given (mapped) source state. + + !!! CAUTION: This function rewrites the machine stack !!! + + THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA! + + IN: + ss...............the source state. Must have been mapped by + replace_map_source_state before. + es...............the base execution state on which to build + + OUT: + *es..............the new execution state + +*******************************************************************************/ + +static void replace_build_execution_state(sourcestate_t *ss, + executionstate_t *es) +{ + rplpoint *rp; + sourceframe_t *prevframe; + rplpoint *parent; + + parent = NULL; + prevframe = NULL; + rp = NULL; + + while (ss->frames) { + + if (REPLACE_IS_NATIVE_FRAME(ss->frames)) { + prevframe = ss->frames; + replace_push_native_frame(es, ss); + parent = NULL; + rp = NULL; + continue; + } + + if (parent == NULL) { + /* create a machine-level stack frame */ + + DOLOG( printf("pushing activation record for:\n"); + if (rp) replace_replacement_point_println(rp, 1); + else printf("\tfirst frame\n"); ); + + replace_push_activation_record(es, rp, prevframe, ss->frames); + + DOLOG( executionstate_println(es); ); + } + + rp = ss->frames->torp; + assert(rp); + + DOLOG( printf("creating execution state for%s:\n", + (ss->frames->down == NULL) ? " TOPFRAME" : ""); + replace_replacement_point_println(ss->frames->fromrp, 1); + replace_replacement_point_println(rp, 1); ); + + es->code = ss->frames->tocode; + prevframe = ss->frames; + +#if defined(ENABLE_VMLOG) + vmlog_cacao_rerol_method(ss->frames->method); +#endif + + replace_write_executionstate(rp, es, ss, ss->frames->down == NULL); + + DOLOG( executionstate_println(es); ); + + if (rp->type == RPLPOINT_TYPE_CALL) { + parent = NULL; + } + else { + /* inlining */ + parent = rp; + } + } +} + + +/* replace_me ****************************************************************** + + This function is called by the signal handler when a thread reaches + a replacement point. `replace_me` must map the execution state to the + target replacement point and let execution continue there. + + THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA! + + IN: + rp...............replacement point that has been reached + es...............execution state read by signal handler + +*******************************************************************************/ + +static void replace_me(rplpoint *rp, executionstate_t *es) +{ + stackframeinfo_t *sfi; + sourcestate_t *ss; + sourceframe_t *frame; + codeinfo *origcode; + rplpoint *origrp; +#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) + threadobject *thread; +#endif + + origcode = es->code; + origrp = rp; + +#if defined(ENABLE_TLH) + /*printf("Replacing in %s/%s\n", rp->method->clazz->name->text, rp->method->name->text);*/ +#endif + + /*if (strcmp(rp->method->clazz->name->text, "antlr/AlternativeElement") == 0 && strcmp(rp->method->name->text, "getAutoGenType") ==0) opt_TraceReplacement = 2; else opt_TraceReplacement = 0;*/ + + DOLOG_SHORT( printf("REPLACING(%d %p): (id %d %p) ", + stat_replacements, (void*)THREADOBJECT, + rp->id, (void*)rp); + method_println(es->code->m); ); + + DOLOG( replace_replacement_point_println(rp, 1); ); + + REPLACE_COUNT(stat_replacements); + + // Create new dump memory area. + DumpMemoryArea dma; + + /* Get the stackframeinfo for the current thread. */ + + sfi = threads_get_current_stackframeinfo(); + + /* recover source state */ + + ss = replace_recover_source_state(rp, sfi, es); + +#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) + /* if there is a collection pending, we assume the replacement point should + suspend this thread */ + + if (gc_pending) { + + thread = THREADOBJECT; + + DOLOG_SHORT( printf("REPLACEMENT: Suspending thread for GC now!\n"); ); + + /* map the sourcestate using the identity mapping */ + replace_map_source_state_identity(ss); + + /* since we enter the same method again, we turn off rps now */ + /* XXX michi: can we really do this? what if the rp was active before + we activated it for the gc? */ + replace_deactivate_replacement_points(origcode); + + /* remember executionstate and sourcestate for this thread */ + GC_EXECUTIONSTATE = es; + GC_SOURCESTATE = ss; + + /* really suspend this thread now (PC = 0) */ + threads_suspend_ack(NULL, NULL); + + DOLOG_SHORT( printf("REPLACEMENT: Resuming thread after GC now!\n"); ); + + } else { +#endif /*defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO)*/ + + /* map the source state */ + + if (!replace_map_source_state(ss)) + vm_abort("exception during method replacement"); + + DOLOG( replace_sourcestate_println(ss); ); + + DOLOG_SHORT( replace_sourcestate_println_short(ss); ); + +#if !defined(NDEBUG) + /* avoid infinite loops by self-replacement, only if not in testing mode */ + + if (!opt_TestReplacement) { + frame = ss->frames; + while (frame->down) + frame = frame->down; + + if (frame->torp == origrp) { + DOLOG_SHORT( + printf("WARNING: identity replacement, turning off rps to avoid infinite loop\n"); + ); + replace_deactivate_replacement_points(origcode); + } + } +#endif + +#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) + } +#endif + + /* build the new execution state */ + + replace_build_execution_state(ss, es); + +#if !defined(NDEBUG) + /* continue execution after patched machine code, if testing mode enabled */ + + if (opt_TestReplacement) + es->pc += REPLACEMENT_PATCH_SIZE; +#endif +} + + +/* replace_me_wrapper ********************************************************** + + This function is called by the signal handler. It determines if there + is an active replacement point pending at the given PC and returns + accordingly. + + THIS FUNCTION MUST BE CALLED USING A SAFE STACK AREA! + + IN: + pc...............the program counter that triggered the replacement. + context..........the context (machine state) to which the + replacement should be applied. + + OUT: + context..........the context after replacement finished. + + RETURN VALUE: + true.............replacement done, everything went ok + false............no replacement done, context unchanged + +*******************************************************************************/ + +bool replace_me_wrapper(u1 *pc, void *context) +{ + codeinfo *code; + rplpoint *rp; + executionstate_t es; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +#endif + + /* search the codeinfo for the given PC */ + + code = code_find_codeinfo_for_pc(pc); + assert(code); + + /* search for a replacement point at the given PC */ + + rp = replace_find_replacement_point_for_pc(code, pc, (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN)); + + /* check if the replacement point belongs to given PC and is active */ + + if ((rp != NULL) && (rp->pc == pc) + && (rp->flags & (RPLPOINT_FLAG_ACTIVE | RPLPOINT_FLAG_COUNTDOWN))) { + + DOLOG( printf("valid replacement point\n"); ); + +#if !defined(NDEBUG) + executionstate_sanity_check(context); +#endif + + /* set codeinfo pointer in execution state */ + + es.code = code; + + /* read execution state from current context */ + + md_executionstate_read(&es, context); + + DOLOG( printf("REPLACEMENT READ: "); + executionstate_println(&es); ); + + /* do the actual replacement */ + +#if defined(ENABLE_RT_TIMING) + RT_TIMING_GET_TIME(time_start); +#endif + + replace_me(rp, &es); + +#if defined(ENABLE_RT_TIMING) + RT_TIMING_GET_TIME(time_end); + RT_TIMING_TIME_DIFF(time_start, time_end, RT_TIMING_REPLACE); +#endif + + /* write execution state to current context */ + + md_executionstate_write(&es, context); + + DOLOG( printf("REPLACEMENT WRITE: "); + executionstate_println(&es); ); + + /* new code is entered after returning */ + + DOLOG( printf("JUMPING IN!\n"); fflush(stdout); ); + return true; + } + else + return false; +} + + +/******************************************************************************/ +/* NOTE: Stuff specific to the exact GC is below. */ +/******************************************************************************/ + +#if defined(ENABLE_GC_CACAO) +void replace_gc_from_native(threadobject *thread, u1 *pc, u1 *sp) +{ + stackframeinfo_t *sfi; + executionstate_t *es; + sourcestate_t *ss; + + /* Get the stackframeinfo of this thread. */ + + assert(thread == THREADOBJECT); + + sfi = threads_get_current_stackframeinfo(); + + /* create the execution state */ + es = (executionstate_t*) DumpMemory::allocate(sizeof(executionstate_t)); + es->pc = pc; + es->sp = sp; + es->pv = 0; /* since we are in a native, PV is invalid! */ + es->code = NULL; /* since we are in a native, we do not have a codeinfo */ + + /* we assume we are in a native (no replacement point)! */ + ss = replace_recover_source_state(NULL, sfi, es); + + /* map the sourcestate using the identity mapping */ + replace_map_source_state_identity(ss); + + /* remember executionstate and sourcestate for this thread */ + GC_EXECUTIONSTATE = es; + GC_SOURCESTATE = ss; +} +#endif + +#if defined(ENABLE_GC_CACAO) +void replace_gc_into_native(threadobject *thread) +{ + executionstate_t *es; + sourcestate_t *ss; + + /* get the executionstate and sourcestate for the given thread */ + es = GC_EXECUTIONSTATE; + ss = GC_SOURCESTATE; + + /* rebuild the stack of the given thread */ + replace_build_execution_state(ss, es); +} +#endif + + +/******************************************************************************/ +/* NOTE: No important code below. */ +/******************************************************************************/ + + +/* statistics *****************************************************************/ + +#if defined(REPLACE_STATISTICS) +static void print_freq(FILE *file,int *array,int limit) +{ + int i; + int sum = 0; + int cum = 0; + for (i=0; i=%3d: %8d\n",limit,array[limit]); +} +#endif /* defined(REPLACE_STATISTICS) */ + + +#if defined(REPLACE_STATISTICS) + +#define REPLACE_PRINT_DIST(name, array) \ + printf(" " name " distribution:\n"); \ + print_freq(stdout, (array), sizeof(array)/sizeof(int) - 1); + +void replace_print_statistics(void) +{ + printf("replacement statistics:\n"); + printf(" # of replacements: %d\n", stat_replacements); + printf(" # of frames: %d\n", stat_frames); + printf(" # of recompilations: %d\n", stat_recompile); + printf(" patched static calls:%d\n", stat_staticpatch); + printf(" unrolled inlines: %d\n", stat_unroll_inline); + printf(" unrolled calls: %d\n", stat_unroll_call); + REPLACE_PRINT_DIST("frame depth", stat_dist_frames); + REPLACE_PRINT_DIST("locals per frame", stat_dist_locals); + REPLACE_PRINT_DIST("ADR locals per frame", stat_dist_locals_adr); + REPLACE_PRINT_DIST("primitive locals per frame", stat_dist_locals_prim); + REPLACE_PRINT_DIST("RET locals per frame", stat_dist_locals_ret); + REPLACE_PRINT_DIST("void locals per frame", stat_dist_locals_void); + REPLACE_PRINT_DIST("stack slots per frame", stat_dist_stack); + REPLACE_PRINT_DIST("ADR stack slots per frame", stat_dist_stack_adr); + REPLACE_PRINT_DIST("primitive stack slots per frame", stat_dist_stack_prim); + REPLACE_PRINT_DIST("RET stack slots per frame", stat_dist_stack_ret); + printf("\n"); + printf(" # of methods: %d\n", stat_methods); + printf(" # of replacement points: %d\n", stat_rploints); + printf(" # of regallocs: %d\n", stat_regallocs); + printf(" per rplpoint: %f\n", (double)stat_regallocs / stat_rploints); + printf(" per method: %f\n", (double)stat_regallocs / stat_methods); + REPLACE_PRINT_DIST("replacement points per method", stat_dist_method_rplpoints); + printf("\n"); + +} +#endif /* defined(REPLACE_STATISTICS) */ + + +#if defined(REPLACE_STATISTICS) +static void replace_statistics_source_frame(sourceframe_t *frame) +{ + int adr = 0; + int ret = 0; + int prim = 0; + int vd = 0; + int n = 0; + int i; + + for (i=0; ijavalocalcount; ++i) { + switch (frame->javalocaltype[i]) { + case TYPE_ADR: adr++; break; + case TYPE_RET: ret++; break; + case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break; + case TYPE_VOID: vd++; break; + default: assert(0); + } + n++; + } + REPLACE_COUNT_DIST(stat_dist_locals, n); + REPLACE_COUNT_DIST(stat_dist_locals_adr, adr); + REPLACE_COUNT_DIST(stat_dist_locals_void, vd); + REPLACE_COUNT_DIST(stat_dist_locals_ret, ret); + REPLACE_COUNT_DIST(stat_dist_locals_prim, prim); + adr = ret = prim = n = 0; + for (i=0; ijavastackdepth; ++i) { + switch (frame->javastacktype[i]) { + case TYPE_ADR: adr++; break; + case TYPE_RET: ret++; break; + case TYPE_INT: case TYPE_LNG: case TYPE_FLT: case TYPE_DBL: prim++; break; + } + n++; + } + REPLACE_COUNT_DIST(stat_dist_stack, n); + REPLACE_COUNT_DIST(stat_dist_stack_adr, adr); + REPLACE_COUNT_DIST(stat_dist_stack_ret, ret); + REPLACE_COUNT_DIST(stat_dist_stack_prim, prim); +} +#endif /* defined(REPLACE_STATISTICS) */ + + +/* debugging helpers **********************************************************/ + +/* replace_replacement_point_println ******************************************* + + Print replacement point info. + + IN: + rp...............the replacement point to print + +*******************************************************************************/ + +#if !defined(NDEBUG) + +#define TYPECHAR(t) (((t) >= 0 && (t) <= TYPE_RET) ? show_jit_type_letters[t] : '?') + +static const char *replace_type_str[] = { + "STD", + "EXH", + "SBR", + "CALL", + "INLINE", + "RETURN", + "BODY" +}; + +void replace_replacement_point_println(rplpoint *rp, int depth) +{ + int j; + int index; + + if (!rp) { + printf("(rplpoint *)NULL\n"); + return; + } + + for (j=0; jid, (void*)rp,rp->pc,rp->callsize, + replace_type_str[rp->type]); + if (rp->flags & RPLPOINT_FLAG_NOTRAP) + printf(" NOTRAP"); + if (rp->flags & RPLPOINT_FLAG_COUNTDOWN) + printf(" COUNTDOWN"); + if (rp->flags & RPLPOINT_FLAG_ACTIVE) + printf(" ACTIVE"); + printf(" parent:%p\n", (void*)rp->parent); + for (j=0; jregalloccount); + + for (j=0; jregalloccount; ++j) { + if (j) + putchar(' '); + index = rp->regalloc[j].index; + switch (index) { + case RPLALLOC_STACK: printf("S"); break; + case RPLALLOC_PARAM: printf("P"); break; + case RPLALLOC_SYNC : printf("Y"); break; + default: printf("%d", index); + } + printf(":%1c:", TYPECHAR(rp->regalloc[j].type)); + if (rp->regalloc[j].type == TYPE_RET) { + printf("ret(L%03d)", rp->regalloc[j].regoff); + } + else { + show_allocation(rp->regalloc[j].type, rp->regalloc[j].flags, rp->regalloc[j].regoff); + } + } + + printf("]\n"); + for (j=0; jmethod); + + printf("\n"); +} +#endif /* !defined(NDEBUG) */ + + +/* replace_show_replacement_points ********************************************* + + Print replacement point info. + + IN: + code.............codeinfo whose replacement points should be printed. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void replace_show_replacement_points(codeinfo *code) +{ + int i; + int depth; + rplpoint *rp; + rplpoint *parent; + + if (!code) { + printf("(codeinfo *)NULL\n"); + return; + } + + printf("\treplacement points: %d\n",code->rplpointcount); + + printf("\ttotal allocations : %d\n",code->regalloccount); + printf("\tsaved int regs : %d\n",code->savedintcount); + printf("\tsaved flt regs : %d\n",code->savedfltcount); +#if defined(HAS_ADDRESS_REGISTER_FILE) + printf("\tsaved adr regs : %d\n",code->savedadrcount); +#endif + printf("\tmemuse : %d\n",code->memuse); + + printf("\n"); + + for (i=0; irplpointcount; ++i) { + rp = code->rplpoints + i; + + depth = 1; + parent = rp->parent; + while (parent) { + depth++; + parent = parent->parent; + } + replace_replacement_point_println(rp, depth); + } +} +#endif + + +#if !defined(NDEBUG) +static void java_value_print(s4 type, replace_val_t value) +{ + java_object_t *obj; + utf *u; + + printf("%016llx",(unsigned long long) value.l); + + if (type < 0 || type > TYPE_RET) + printf(" ", type); + else + printf(" %s", show_jit_type_names[type]); + + if (type == TYPE_ADR && value.a != NULL) { + obj = value.a; + putchar(' '); + utf_display_printable_ascii_classname(obj->vftbl->clazz->name); + + if (obj->vftbl->clazz == class_java_lang_String) { + printf(" \""); + u = javastring_toutf(obj, false); + utf_display_printable_ascii(u); + printf("\""); + } + } + else if (type == TYPE_INT) { + printf(" %ld", (long) value.i); + } + else if (type == TYPE_LNG) { + printf(" %lld", (long long) value.l); + } + else if (type == TYPE_FLT) { + printf(" %f", value.f); + } + else if (type == TYPE_DBL) { + printf(" %f", value.d); + } +} +#endif /* !defined(NDEBUG) */ + + +#if !defined(NDEBUG) +void replace_source_frame_println(sourceframe_t *frame) +{ + s4 i,j; + s4 t; + + if (REPLACE_IS_NATIVE_FRAME(frame)) { + printf("\tNATIVE\n"); + printf("\tsfi: "); replace_stackframeinfo_println(frame->sfi); + printf("\tnativepc: %p\n", frame->nativepc); + printf("\tframesize: %d\n", frame->nativeframesize); + + j = 0; + for (i=0; inativesavint[j++]); + } + + j = 0; + for (i=0; inativesavflt[j++]); + } + + printf("\n"); + return; + } + + printf("\t"); + method_println(frame->method); + printf("\tid: %d\n", frame->id); + printf("\ttype: %s\n", replace_type_str[frame->type]); + printf("\n"); + + if (frame->instance.a) { + printf("\tinstance: "); + java_value_print(TYPE_ADR, frame->instance); + printf("\n"); + } + + if (frame->javalocalcount) { + printf("\tlocals (%d):\n",frame->javalocalcount); + for (i=0; ijavalocalcount; ++i) { + t = frame->javalocaltype[i]; + if (t == TYPE_VOID) { + printf("\tlocal[ %2d] = void\n",i); + } + else { + printf("\tlocal[%c%2d] = ",TYPECHAR(t),i); + java_value_print(t, frame->javalocals[i]); + printf("\n"); + } + } + printf("\n"); + } + + if (frame->javastackdepth) { + printf("\tstack (depth %d):\n",frame->javastackdepth); + for (i=0; ijavastackdepth; ++i) { + t = frame->javastacktype[i]; + if (t == TYPE_VOID) { + printf("\tstack[%2d] = void", i); + } + else { + printf("\tstack[%2d] = ",i); + java_value_print(frame->javastacktype[i], frame->javastack[i]); + printf("\n"); + } + } + printf("\n"); + } + + if (frame->syncslotcount) { + printf("\tsynchronization slots (%d):\n",frame->syncslotcount); + for (i=0; isyncslotcount; ++i) { + printf("\tslot[%2d] = ",i); +#ifdef HAS_4BYTE_STACKSLOT + printf("%08lx\n",(unsigned long) frame->syncslots[i].p); +#else + printf("%016llx\n",(unsigned long long) frame->syncslots[i].p); +#endif + } + printf("\n"); + } + + if (frame->fromcode) { + printf("\tfrom %p ", (void*)frame->fromcode); + method_println(frame->fromcode->m); + } + if (frame->tocode) { + printf("\tto %p ", (void*)frame->tocode); + method_println(frame->tocode->m); + } + + if (frame->fromrp) { + printf("\tfrom replacement point:\n"); + replace_replacement_point_println(frame->fromrp, 2); + } + if (frame->torp) { + printf("\tto replacement point:\n"); + replace_replacement_point_println(frame->torp, 2); + } + + printf("\n"); +} +#endif /* !defined(NDEBUG) */ + + +/* replace_sourcestate_println ************************************************* + + Print source state + + IN: + ss...............the source state to print + +*******************************************************************************/ + +#if !defined(NDEBUG) +void replace_sourcestate_println(sourcestate_t *ss) +{ + int i; + sourceframe_t *frame; + + if (!ss) { + printf("(sourcestate_t *)NULL\n"); + return; + } + + printf("sourcestate_t:\n"); + + for (i=0, frame = ss->frames; frame != NULL; frame = frame->down, ++i) { + printf(" frame %d:\n", i); + replace_source_frame_println(frame); + } +} +#endif + + +/* replace_sourcestate_println_short ******************************************* + + Print a compact representation of the given source state. + + IN: + ss...............the source state to print + +*******************************************************************************/ + +#if !defined(NDEBUG) +void replace_sourcestate_println_short(sourcestate_t *ss) +{ + sourceframe_t *frame; + + for (frame = ss->frames; frame != NULL; frame = frame->down) { + printf("\t"); + + if (REPLACE_IS_NATIVE_FRAME(frame)) { + printf("NATIVE (pc %p size %d) ", + (void*)frame->nativepc, frame->nativeframesize); + replace_stackframeinfo_println(frame->sfi); + continue; + } + + if (frame->torp) { + printf("%c", (frame->torp == frame->fromrp) ? '=' : '+'); + } + + printf("%s", replace_type_str[frame->fromrp->type]); + + if (frame->torp && frame->torp->type != frame->fromrp->type) + printf("->%s", replace_type_str[frame->torp->type]); + + if (frame->tocode != frame->fromcode) + printf(" (%p->%p/%d) ", + (void*) frame->fromcode, (void*) frame->tocode, + frame->fromrp->id); + else + printf(" (%p/%d) ", (void*) frame->fromcode, frame->fromrp->id); + + method_println(frame->method); + } +} +#endif + +#if !defined(NDEBUG) +static void replace_stackframeinfo_println(stackframeinfo_t *sfi) +{ + printf("prev=%p pv=%p sp=%p ra=%p xpc=%p method=", + (void*)sfi->prev, (void*)sfi->pv, (void*)sfi->sp, + (void*)sfi->ra, (void*)sfi->xpc); + + if (sfi->code) + method_println(sfi->code->m); + else + printf("(nil)\n"); +} +#endif + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/replace.h b/src/vm/jit/replace.h deleted file mode 100644 index 752cd385f..000000000 --- a/src/vm/jit/replace.h +++ /dev/null @@ -1,284 +0,0 @@ -/* src/vm/jit/replace.h - on-stack replacement of methods - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _REPLACE_H -#define _REPLACE_H - -#include "config.h" -#include "vm/types.h" - -#if !defined(ENABLE_REPLACEMENT) - -/*** macros for the codegens (disabled version) ************************/ - -#define REPLACEMENT_POINTS_INIT(cd, jd) -#define REPLACEMENT_POINTS_RESET(cd, jd) -#define REPLACEMENT_POINT_BLOCK_START(cd, bptr) -#define REPLACEMENT_POINT_INLINE_START(cd, iptr) -#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr) -#define REPLACEMENT_POINT_RETURN(cd, iptr) -#define REPLACEMENT_POINT_INVOKE(cd, iptr) -#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr) -#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr) -#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr) - -#else /* defined(ENABLE_REPLACEMENT) */ - -/* forward typedefs ***********************************************************/ - -typedef struct rplalloc rplalloc; -typedef struct rplpoint rplpoint; -typedef struct sourcestate_t sourcestate_t; -typedef struct sourceframe_t sourceframe_t; -typedef union replace_val_t replace_val_t; - -#include "arch.h" -#include "md-abi.h" - -#include "vm/jit/reg.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/method.h" - - -/*** structs *********************************************************/ - -#define RPLALLOC_STACK -1 -#define RPLALLOC_PARAM -2 -#define RPLALLOC_SYNC -3 - -/* `rplalloc` is a compact struct for register allocation info */ - -/* XXX optimize this for space efficiency */ -struct rplalloc { - s4 index; /* local index, -1 for stack slot */ - s4 regoff; /* register index / stack slot offset */ - unsigned int flags:4; /* OR of (INMEMORY,...) */ - unsigned int type:4; /* TYPE_... constant */ -}; - -#if INMEMORY > 0x08 -#error value of INMEMORY is too big to fit in rplalloc.flags -#endif - - -/* XXX what to do about overlapping rplpoints? */ -/* CAUTION: Do not change the numerical values. These are used as */ -/* indices into replace_normalize_type_map. */ -#define RPLPOINT_TYPE_STD BBTYPE_STD -#define RPLPOINT_TYPE_EXH BBTYPE_EXH -#define RPLPOINT_TYPE_SBR BBTYPE_SBR -#define RPLPOINT_TYPE_CALL 3 -#define RPLPOINT_TYPE_INLINE 4 -#define RPLPOINT_TYPE_RETURN 5 -#define RPLPOINT_TYPE_BODY 6 - -#define RPLPOINT_FLAG_NOTRAP 0x01 /* rplpoint cannot be trapped */ -#define RPLPOINT_FLAG_COUNTDOWN 0x02 /* count down hits */ -#define RPLPOINT_FLAG_ACTIVE 0x08 /* trap is active */ - - -#if !defined(NDEBUG) -#define RPLPOINT_CHECK(type) , RPLPOINT_TYPE_##type -#define RPLPOINT_CHECK_BB(bptr) , (bptr)->type -#else -#define RPLPOINT_CHECK(type) -#define RPLPOINT_CHECK_BB(bptr) -#endif - - -/* An `rplpoint` represents a replacement point in a compiled method */ - -struct rplpoint { - u1 *pc; /* machine code PC of this point */ - methodinfo *method; /* source method this point is in */ - rplpoint *parent; /* rplpoint of the inlined body */ /* XXX unify with code */ - rplalloc *regalloc; /* pointer to register index table */ - s4 id; /* id of the rplpoint within method */ - s4 callsize; /* size of call code in bytes */ - unsigned int regalloccount:20; /* number of local allocations */ - unsigned int type:4; /* RPLPOINT_TYPE_... constant */ - unsigned int flags:8; /* OR of RPLPOINT_... constants */ -}; - - -union replace_val_t { - s4 i; - s8 l; - ptrint p; - struct { - u4 lo; - u4 hi; - } words; - float f; - double d; - java_object_t *a; -}; - - - u1 *ra; /* return address / link register */ -struct sourceframe_t { - sourceframe_t *down; /* source frame down the call chain */ - - methodinfo *method; /* method this frame is in */ - s4 id; - s4 type; - - /* values */ - replace_val_t instance; - - replace_val_t *javastack; /* values of stack vars */ - u1 *javastacktype; /* types of stack vars */ - s4 javastackdepth; /* number of stack vars */ - - replace_val_t *javalocals; /* values of javalocals */ - u1 *javalocaltype; /* types of javalocals */ - s4 javalocalcount; /* number of javalocals */ - - replace_val_t *syncslots; - s4 syncslotcount; /* XXX do we need more than one? */ - - /* mapping info */ - rplpoint *fromrp; /* rplpoint used to read this frame */ - codeinfo *fromcode; /* code this frame was using */ - rplpoint *torp; /* rplpoint this frame was mapped to */ - codeinfo *tocode; /* code this frame was mapped to */ - - /* info for native frames */ - stackframeinfo_t *sfi; /* sfi for native frames, otherwise NULL */ - s4 nativeframesize; /* size (bytes) of native frame */ - u1 *nativepc; - ptrint nativesavint[INT_SAV_CNT]; /* XXX temporary */ - double nativesavflt[FLT_REG_CNT]; /* XXX temporary */ -#if defined(HAS_ADDRESS_REGISTER_FILE) - ptrint nativesavadr[ADR_SAV_CNT]; /* XXX temporary */ -#endif -}; - -#define REPLACE_IS_NATIVE_FRAME(frame) ((frame)->sfi != NULL) -#define REPLACE_IS_JAVA_FRAME(frame) ((frame)->sfi == NULL) - - -struct sourcestate_t { - sourceframe_t *frames; /* list of source frames, from bottom up */ -}; - - -/*** macros for the codegens *******************************************/ - -#define REPLACEMENT_POINTS_INIT(cd, jd) \ - if (!replace_create_replacement_points(jd)) \ - return false; \ - (cd)->replacementpoint = (jd)->code->rplpoints; - -#define REPLACEMENT_POINTS_RESET(cd, jd) \ - (cd)->replacementpoint = (jd)->code->rplpoints; - -#define REPLACEMENT_POINT_BLOCK_START(cd, bptr) \ - if ((bptr)->bitflags & BBFLAG_REPLACEMENT) \ - codegen_set_replacement_point((cd) RPLPOINT_CHECK_BB(bptr)); - -#define REPLACEMENT_POINT_INLINE_START(cd, iptr) \ - codegen_set_replacement_point(cd RPLPOINT_CHECK(INLINE)); - -#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr) \ - codegen_set_replacement_point_notrap(cd RPLPOINT_CHECK(BODY)); - -#define REPLACEMENT_POINT_RETURN(cd, iptr) \ - codegen_set_replacement_point(cd RPLPOINT_CHECK(RETURN)); - -#define REPLACEMENT_POINT_INVOKE(cd, iptr) \ - codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL)); - -#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr) \ - if (iptr->opc != ICMD_BUILTIN) \ - cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\ - - (ptrint) cd->replacementpoint[-1].pc; - - -/*** macros for the codegens (for GC) **********************************/ - -#if defined(ENABLE_GC_CACAO) - -#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr) \ - codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL)); - -#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr) \ - if (iptr->opc == ICMD_BUILTIN) \ - cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\ - - (ptrint) cd->replacementpoint[-1].pc; - -#else /* defined(ENABLE_GC_CACAO) */ - -#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr) -#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr) - -#endif /* defined(ENABLE_GC_CACAO) */ - - -/*** prototypes ********************************************************/ - -bool replace_create_replacement_points(jitdata *jd); -void replace_free_replacement_points(codeinfo *code); - -void replace_activate_replacement_points(codeinfo *code, bool mappable); -void replace_deactivate_replacement_points(codeinfo *code); - -bool replace_me_wrapper(u1 *pc, void *context); - -#if !defined(NDEBUG) -void replace_show_replacement_points(codeinfo *code); -void replace_replacement_point_println(rplpoint *rp, int depth); -void replace_sourcestate_println(sourcestate_t *ss); -void replace_sourcestate_println_short(sourcestate_t *ss); -void replace_source_frame_println(sourceframe_t *frame); -#endif - -/* machine dependent functions (code in ARCH_DIR/md.c) */ - -#if defined(ENABLE_JIT) -void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert); -#endif - -#endif /* defined(ENABLE_REPLACEMENT) */ - -#endif /* _REPLACE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/replace.hpp b/src/vm/jit/replace.hpp new file mode 100644 index 000000000..20b61ec70 --- /dev/null +++ b/src/vm/jit/replace.hpp @@ -0,0 +1,289 @@ +/* src/vm/jit/replace.hpp - on-stack replacement of methods + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _REPLACE_HPP +#define _REPLACE_HPP + +#include "config.h" +#include "vm/types.h" + +#if !defined(ENABLE_REPLACEMENT) + +/*** macros for the codegens (disabled version) ************************/ + +#define REPLACEMENT_POINTS_INIT(cd, jd) +#define REPLACEMENT_POINTS_RESET(cd, jd) +#define REPLACEMENT_POINT_BLOCK_START(cd, bptr) +#define REPLACEMENT_POINT_INLINE_START(cd, iptr) +#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr) +#define REPLACEMENT_POINT_RETURN(cd, iptr) +#define REPLACEMENT_POINT_INVOKE(cd, iptr) +#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr) +#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr) +#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr) + +#else /* defined(ENABLE_REPLACEMENT) */ + +/* forward typedefs ***********************************************************/ + +typedef struct rplalloc rplalloc; +typedef struct rplpoint rplpoint; +typedef struct sourcestate_t sourcestate_t; +typedef struct sourceframe_t sourceframe_t; +typedef union replace_val_t replace_val_t; + +#include "arch.h" +#include "md-abi.h" + +#include "vm/method.h" + +#include "vm/jit/reg.h" +#include "vm/jit/stacktrace.hpp" + + +/*** structs *********************************************************/ + +#define RPLALLOC_STACK -1 +#define RPLALLOC_PARAM -2 +#define RPLALLOC_SYNC -3 + +/* `rplalloc` is a compact struct for register allocation info */ + +/* XXX optimize this for space efficiency */ +struct rplalloc { + s4 index; /* local index, -1 for stack slot */ + s4 regoff; /* register index / stack slot offset */ + unsigned int flags:4; /* OR of (INMEMORY,...) */ + unsigned int type:4; /* TYPE_... constant */ +}; + +#if INMEMORY > 0x08 +#error value of INMEMORY is too big to fit in rplalloc.flags +#endif + + +/* XXX what to do about overlapping rplpoints? */ +/* CAUTION: Do not change the numerical values. These are used as */ +/* indices into replace_normalize_type_map. */ +#define RPLPOINT_TYPE_STD BBTYPE_STD +#define RPLPOINT_TYPE_EXH BBTYPE_EXH +#define RPLPOINT_TYPE_SBR BBTYPE_SBR +#define RPLPOINT_TYPE_CALL 3 +#define RPLPOINT_TYPE_INLINE 4 +#define RPLPOINT_TYPE_RETURN 5 +#define RPLPOINT_TYPE_BODY 6 + +#define RPLPOINT_FLAG_NOTRAP 0x01 /* rplpoint cannot be trapped */ +#define RPLPOINT_FLAG_COUNTDOWN 0x02 /* count down hits */ +#define RPLPOINT_FLAG_ACTIVE 0x08 /* trap is active */ + + +#if !defined(NDEBUG) +#define RPLPOINT_CHECK(type) , RPLPOINT_TYPE_##type +#define RPLPOINT_CHECK_BB(bptr) , (bptr)->type +#else +#define RPLPOINT_CHECK(type) +#define RPLPOINT_CHECK_BB(bptr) +#endif + + +/* An `rplpoint` represents a replacement point in a compiled method */ + +struct rplpoint { + u1 *pc; /* machine code PC of this point */ + methodinfo *method; /* source method this point is in */ + rplpoint *parent; /* rplpoint of the inlined body */ /* XXX unify with code */ + rplalloc *regalloc; /* pointer to register index table */ + s4 id; /* id of the rplpoint within method */ + s4 callsize; /* size of call code in bytes */ + unsigned int regalloccount:20; /* number of local allocations */ + unsigned int type:4; /* RPLPOINT_TYPE_... constant */ + unsigned int flags:8; /* OR of RPLPOINT_... constants */ +}; + + +union replace_val_t { + s4 i; + s8 l; + ptrint p; + struct { + u4 lo; + u4 hi; + } words; + float f; + double d; + java_object_t *a; +}; + + +struct sourceframe_t { + sourceframe_t *down; /* source frame down the call chain */ + + methodinfo *method; /* method this frame is in */ + s4 id; + s4 type; + + /* values */ + replace_val_t instance; + + replace_val_t *javastack; /* values of stack vars */ + u1 *javastacktype; /* types of stack vars */ + s4 javastackdepth; /* number of stack vars */ + + replace_val_t *javalocals; /* values of javalocals */ + u1 *javalocaltype; /* types of javalocals */ + s4 javalocalcount; /* number of javalocals */ + + replace_val_t *syncslots; + s4 syncslotcount; /* XXX do we need more than one? */ + + /* mapping info */ + rplpoint *fromrp; /* rplpoint used to read this frame */ + codeinfo *fromcode; /* code this frame was using */ + rplpoint *torp; /* rplpoint this frame was mapped to */ + codeinfo *tocode; /* code this frame was mapped to */ + + /* info for native frames */ + stackframeinfo_t *sfi; /* sfi for native frames, otherwise NULL */ + s4 nativeframesize; /* size (bytes) of native frame */ + u1 *nativepc; + ptrint nativesavint[INT_SAV_CNT]; /* XXX temporary */ + double nativesavflt[FLT_REG_CNT]; /* XXX temporary */ +#if defined(HAS_ADDRESS_REGISTER_FILE) + ptrint nativesavadr[ADR_SAV_CNT]; /* XXX temporary */ +#endif +}; + +#define REPLACE_IS_NATIVE_FRAME(frame) ((frame)->sfi != NULL) +#define REPLACE_IS_JAVA_FRAME(frame) ((frame)->sfi == NULL) + + +struct sourcestate_t { + sourceframe_t *frames; /* list of source frames, from bottom up */ +}; + + +/*** macros for the codegens *******************************************/ + +#define REPLACEMENT_POINTS_INIT(cd, jd) \ + if (!replace_create_replacement_points(jd)) \ + return false; \ + (cd)->replacementpoint = (jd)->code->rplpoints; + +#define REPLACEMENT_POINTS_RESET(cd, jd) \ + (cd)->replacementpoint = (jd)->code->rplpoints; + +#define REPLACEMENT_POINT_BLOCK_START(cd, bptr) \ + if ((bptr)->bitflags & BBFLAG_REPLACEMENT) \ + codegen_set_replacement_point((cd) RPLPOINT_CHECK_BB(bptr)); + +#define REPLACEMENT_POINT_INLINE_START(cd, iptr) \ + codegen_set_replacement_point(cd RPLPOINT_CHECK(INLINE)); + +#define REPLACEMENT_POINT_INLINE_BODY(cd, iptr) \ + codegen_set_replacement_point_notrap(cd RPLPOINT_CHECK(BODY)); + +#define REPLACEMENT_POINT_RETURN(cd, iptr) \ + codegen_set_replacement_point(cd RPLPOINT_CHECK(RETURN)); + +#define REPLACEMENT_POINT_INVOKE(cd, iptr) \ + codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL)); + +#define REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr) \ + if (iptr->opc != ICMD_BUILTIN) \ + cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\ + - (ptrint) cd->replacementpoint[-1].pc; + + +/*** macros for the codegens (for GC) **********************************/ + +#if defined(ENABLE_GC_CACAO) + +#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr) \ + codegen_set_replacement_point(cd RPLPOINT_CHECK(CALL)); + +#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr) \ + if (iptr->opc == ICMD_BUILTIN) \ + cd->replacementpoint[-1].callsize = (cd->mcodeptr - cd->mcodebase)\ + - (ptrint) cd->replacementpoint[-1].pc; + +#else // ENABLE_GC_CACAO + +#define REPLACEMENT_POINT_FORGC_BUILTIN(cd, iptr) +#define REPLACEMENT_POINT_FORGC_BUILTIN_RETURN(cd, iptr) + +#endif // ENABLE_GC_CACAO + + +/*** prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +bool replace_create_replacement_points(jitdata *jd); +void replace_free_replacement_points(codeinfo *code); + +void replace_activate_replacement_points(codeinfo *code, bool mappable); +void replace_deactivate_replacement_points(codeinfo *code); + +bool replace_me_wrapper(u1 *pc, void *context); + +#if !defined(NDEBUG) +void replace_show_replacement_points(codeinfo *code); +void replace_replacement_point_println(rplpoint *rp, int depth); +void replace_sourcestate_println(sourcestate_t *ss); +void replace_sourcestate_println_short(sourcestate_t *ss); +void replace_source_frame_println(sourceframe_t *frame); +#endif + +/* machine dependent functions (code in ARCH_DIR/md.c) */ + +#if defined(ENABLE_JIT) +void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // ENABLE_REPLACEMENT + +#endif // _REPLACE_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/s390/Makefile.am b/src/vm/jit/s390/Makefile.am index a9c16bd31..002ce18e8 100644 --- a/src/vm/jit/s390/Makefile.am +++ b/src/vm/jit/s390/Makefile.am @@ -28,9 +28,9 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h \ \ - md-asm.h + md-asm.h \ + md-atomic.hpp noinst_LTLIBRARIES = \ libarch.la @@ -51,6 +51,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/s390/codegen.c b/src/vm/jit/s390/codegen.c index 37de06900..15754e1db 100644 --- a/src/vm/jit/s390/codegen.c +++ b/src/vm/jit/s390/codegen.c @@ -34,7 +34,6 @@ #include "vm/jit/s390/emit.h" #include "vm/jit/s390/md-abi.h" -#include "native/jni.h" #include "native/localref.h" #include "native/native.h" @@ -42,33 +41,31 @@ #include "threads/lock-common.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/statistics.h" #include "vm/types.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #if defined(ENABLE_LSRA) # include "vm/jit/allocator/lsra.h" #endif #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/methodheader.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" @@ -3003,9 +3000,6 @@ gen_method: supervftbl = super->vftbl; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -3083,8 +3077,6 @@ gen_method: } #if 1 - CODEGEN_CRITICAL_SECTION_START; - /* REG_ITMP3 := baseval(s1) */ M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); @@ -3100,8 +3092,6 @@ gen_method: M_ALD_DSEG(REG_ITMP2, disp); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_CMPU(REG_ITMP3, REG_ITMP2); /* Unsigned compare */ /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */ @@ -3111,16 +3101,12 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD_DSEG(REG_ITMP3, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval)); M_ISUB(REG_ITMP3, REG_ITMP2); M_ALD_DSEG(REG_ITMP3, disp); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_CMPU(REG_ITMP2, REG_ITMP3); /* Unsigned compare */ /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */ /* M_BEQZ(REG_ITMP3, 0); branch if (! itmp) -> branch if > */ @@ -3223,9 +3209,6 @@ gen_method: # define LABEL_EXIT_INTERFACE_DONE BRANCH_LABEL_5 # define LABEL_EXIT_CLASS_NULL BRANCH_LABEL_6 - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); if (s1 == d) { @@ -3327,14 +3310,10 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD_DSEG(REG_ITMP2, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_ISUB(REG_ITMP3, REG_ITMP1); /* itmp1 := itmp1 (sub.baseval) - itmp3 (super.baseval) */ M_CMPU(REG_ITMP1, REG_ITMP2); /* d := (uint)REG_ITMP1 <= (uint)REG_ITMP2 */ @@ -3665,7 +3644,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - disp = dseg_add_address(cd, _Jv_env); + disp = dseg_add_address(cd, VM_get_jnienv()); M_ALD_DSEG(REG_A0, disp); } diff --git a/src/vm/jit/s390/codegen.h b/src/vm/jit/s390/codegen.h index 8cb750ac9..3e5262d45 100644 --- a/src/vm/jit/s390/codegen.h +++ b/src/vm/jit/s390/codegen.h @@ -1,9 +1,7 @@ /* src/vm/jit/s390/codegen.h - code generation macros for s390 - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -34,7 +32,7 @@ #include "vm/types.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* MCODECHECK(icnt) */ @@ -49,7 +47,6 @@ #define PATCHER_CALL_SIZE 2 /* size in bytes of a patcher call */ #define PATCHER_NOPS M_NOP3 -#define PATCHER_NOPS_SKIP 2 /* branch defines ************************************************************/ @@ -64,9 +61,6 @@ } \ } while (0) -/* stub defines **************************************************************/ - -#define COMPILERSTUB_CODESIZE (SZ_AHI + SZ_L + SZ_L + SZ_BCR) /* *** BIG TODO *** * Make all this inline functions !!!!!!!!!! diff --git a/src/vm/jit/s390/emit.c b/src/vm/jit/s390/emit.c index 9ac259c71..2d501b823 100644 --- a/src/vm/jit/s390/emit.c +++ b/src/vm/jit/s390/emit.c @@ -35,24 +35,22 @@ #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" #include "vm/global.h" #include "vm/types.h" +#include "vm/options.h" #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#include "vm/jit/trace.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" - /* emit_load ******************************************************************* diff --git a/src/vm/jit/s390/machine-instr.h b/src/vm/jit/s390/machine-instr.h deleted file mode 100644 index b470961aa..000000000 --- a/src/vm/jit/s390/machine-instr.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -/* Taken from linux kernel source - * include/asm-s390/atomic.h - * - * S390 version - * Copyright (C) 1999-2005 IBM Deutschland Entwicklung GmbH, IBM Corporation - * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), - * Denis Joseph Barrow, - * Arnd Bergmann (arndb@de.ibm.com) - * - * Derived from "include/asm-i386/bitops.h" - * Copyright (C) 1992, Linus Torvalds - */ - -static inline long -compare_and_swap (volatile long *p, long oldval, long newval) -{ - __asm__ __volatile__(" cs %0,%3,0(%2)\n" - : "+d" (oldval), "=m" (*p) - : "a" (p), "d" (newval), "m" (*p) - : "cc", "memory" ); - return oldval; -} - -/* - * Taken from linux kerenl source - * include/asm-s390/system.h - * - * S390 version - * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation - * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), - * - * Derived from "include/asm-i386/system.h" - */ - -/* - * Force strict CPU ordering. - * And yes, this is required on UP too when we're talking - * to devices. - * - * This is very similar to the ppc eieio/sync instruction in that is - * does a checkpoint syncronisation & makes sure that - * all memory ops have completed wrt other CPU's ( see 7-15 POP DJB ). - */ - -#define eieio() __asm__ __volatile__ ( "bcr 15,0" : : : "memory" ) - -#define STORE_ORDER_BARRIER() eieio() -#define MEMORY_BARRIER() eieio() - -/* TODO not sure if the following two can't be just empty. */ - -#define MEMORY_BARRIER_AFTER_ATOMIC() eieio() - -#endif diff --git a/src/vm/jit/s390/md-abi.c b/src/vm/jit/s390/md-abi.c index 99715c6e1..95ad22ac5 100644 --- a/src/vm/jit/s390/md-abi.c +++ b/src/vm/jit/s390/md-abi.c @@ -25,16 +25,15 @@ #include "config.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/types.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/stack.h" #include "vm/jit/s390/md-abi.h" -#include "vmcore/descriptor.h" - #include diff --git a/src/vm/jit/s390/md-atomic.hpp b/src/vm/jit/s390/md-atomic.hpp new file mode 100644 index 000000000..fafb6426d --- /dev/null +++ b/src/vm/jit/s390/md-atomic.hpp @@ -0,0 +1,127 @@ +/* src/vm/jit/s390/md-atomic.hpp - s390 atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + __asm__ __volatile__ ( + "cs %0,%3,0(%2)\n" + : "+d" (oldval), "=m" (*p) + : "a" (p), "d" (newval), "m" (*p) + : "cc", "memory" ); + + return oldval; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + return generic_compare_and_swap(p, oldval, newval); +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("bcr 15,0" : : : "memory" ); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + memory_barrier(); +} + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + memory_barrier(); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/s390/md-stubs.hpp b/src/vm/jit/s390/md-stubs.hpp new file mode 100644 index 000000000..6fbe8228c --- /dev/null +++ b/src/vm/jit/s390/md-stubs.hpp @@ -0,0 +1,58 @@ +/* src/vm/jit/s390/md-stubs.hpp - s390 JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + +#include "vm/jit/s390/codegen.h" + + +/** + * Return the code size of a compiler on a s390 architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return (SZ_AHI + SZ_L + SZ_L + SZ_BCR); +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/s390/md-trap.h b/src/vm/jit/s390/md-trap.h index ac0fe0816..a5e05a071 100644 --- a/src/vm/jit/s390/md-trap.h +++ b/src/vm/jit/s390/md-trap.h @@ -46,7 +46,8 @@ enum { TRAP_ClassCastException = 4, TRAP_CHECK_EXCEPTION = 5, TRAP_PATCHER = 6, - TRAP_COMPILER = 7 + TRAP_COMPILER = 7, + TRAP_COUNTDOWN = 8 }; #endif /* _MD_TRAP_H */ diff --git a/src/vm/jit/s390/md.c b/src/vm/jit/s390/md.c index 3959f0a91..5e11280ac 100644 --- a/src/vm/jit/s390/md.c +++ b/src/vm/jit/s390/md.c @@ -34,9 +34,9 @@ #include "vm/jit/s390/md-abi.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/exceptions.h" +#include "vm/exceptions.hpp" #include "vm/signallocal.h" #include "vm/jit/asmpart.h" @@ -44,15 +44,15 @@ #include "vm/jit/executionstate.h" #include "vm/jit/methodheader.h" #include "vm/jit/methodtree.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" #if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) -#include "vmcore/options.h" /* XXX debug */ +#include "vm/options.h" /* XXX debug */ #include "vm/jit/disass.h" /* XXX debug */ #endif -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/s390/codegen.h" #include "vm/jit/s390/md.h" @@ -412,27 +412,6 @@ void md_executionstate_write(executionstate_t* es, void* context) } -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - void *npc; - - _mc = &_uc->uc_mcontext; - - pc = (u1 *)_mc->psw.addr; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) { - log_println("%s: pc=%p, npc=%p", __FUNCTION__, pc, npc); - _mc->psw.addr = (ptrint) npc; - } -} -#endif - - /* md_jit_method_patch_address ************************************************* Gets the patch address of the currently compiled method. The offset diff --git a/src/vm/jit/s390/md.h b/src/vm/jit/s390/md.h index 1664cd417..cbb7f9b6d 100644 --- a/src/vm/jit/s390/md.h +++ b/src/vm/jit/s390/md.h @@ -31,7 +31,7 @@ #include #include -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/methodtree.h" diff --git a/src/vm/jit/s390/patcher.c b/src/vm/jit/s390/patcher.c index 667aa0758..c5c0e6a37 100644 --- a/src/vm/jit/s390/patcher.c +++ b/src/vm/jit/s390/patcher.c @@ -30,19 +30,20 @@ #include "mm/memory.h" #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/s390/codegen.h" -#include "vm/jit/s390/md-abi.h" -#include "vm/jit/stacktrace.h" +#include "vm/options.h" +#include "vm/references.h" #include "vm/resolve.h" #include "vm/types.h" -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" + +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/s390/codegen.h" +#include "vm/jit/s390/md-abi.h" + #define PATCH_BACK_ORIGINAL_MCODE \ *((u2 *) pr->mpc) = (u2) pr->mcode; @@ -130,11 +131,6 @@ bool patcher_get_putfield(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* If NOPs are generated, skip them */ - - if (opt_shownops) - ra += PATCHER_NOPS_SKIP; - /* If there is an operand load before, skip the load size passed in disp (see ICMD_PUTFIELD) */ ra += disp; @@ -218,11 +214,6 @@ bool patcher_invokevirtual(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* If NOPs are generated, skip them */ - - if (opt_shownops) - ra += PATCHER_NOPS_SKIP; - /* patch vftbl index */ @@ -266,11 +257,6 @@ bool patcher_invokeinterface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* If NOPs are generated, skip them */ - - if (opt_shownops) - ra += PATCHER_NOPS_SKIP; - /* get interfacetable index */ idx = (s4) (OFFSET(vftbl_t, interfacetable[0]) - @@ -427,11 +413,6 @@ bool patcher_checkcast_instanceof_interface(patchref_t *pr) PATCH_BACK_ORIGINAL_MCODE; - /* If NOPs are generated, skip them */ - - if (opt_shownops) - ra += PATCHER_NOPS_SKIP; - /* patch super class index */ /* From here, split your editor and open codegen.c */ diff --git a/src/vm/jit/show.c b/src/vm/jit/show.c index 0b429ccad..6075ffa8f 100644 --- a/src/vm/jit/show.c +++ b/src/vm/jit/show.c @@ -35,30 +35,29 @@ #include "threads/lock-common.h" #include "vm/global.h" -#include "vm/builtin.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/jit/builtin.hpp" +#include "vm/options.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" #include "vm/jit/abi.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/show.h" #include "vm/jit/disass.h" #include "vm/jit/stack.h" #include "vm/jit/parse.h" -#include "vmcore/options.h" - #if defined(ENABLE_DEBUG_FILTER) # include # include -# include "threads/thread.h" +# include "threads/thread.hpp" #endif /* global variables ***********************************************************/ -#if defined(ENABLE_THREADS) && !defined(NDEBUG) -static java_object_t *show_global_lock; +#if !defined(NDEBUG) +static Mutex* mutex; #endif @@ -81,9 +80,7 @@ bool show_init(void) #if defined(ENABLE_THREADS) /* initialize the show lock */ - show_global_lock = NEW(java_object_t); - - LOCK_INIT_OBJECT_LOCK(show_global_lock); + mutex = Mutex_new(); #endif #if defined(ENABLE_DEBUG_FILTER) @@ -158,7 +155,7 @@ void show_method(jitdata *jd, int stage) is not reentrant-able and we could not read functions printed at the same time. */ - LOCK_MONITOR_ENTER(show_global_lock); + Mutex_lock(mutex); #if defined(ENABLE_INTRP) if (opt_intrp) @@ -389,7 +386,7 @@ void show_method(jitdata *jd, int stage) } #endif - LOCK_MONITOR_EXIT(show_global_lock); + Mutex_unlock(mutex); /* finally flush the output */ @@ -549,6 +546,18 @@ void show_basicblock(jitdata *jd, basicblock *bptr, int stage) } #endif /* defined(ENABLE_INLINING) */ +#if defined(ENABLE_SSA) + + iptr = bptr->phis; + + for (i = 0; i < bptr->phicount; i++, iptr++) { + printf("%4d:%4d: ", iptr->line, iptr->flags.bits >> INS_FLAG_ID_SHIFT); + + show_icmd(jd, iptr, deadcode, irstage); + printf("\n"); + } +#endif + iptr = bptr->iinstr; for (i = 0; i < bptr->icount; i++, iptr++) { @@ -1425,6 +1434,19 @@ void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage) case ICMD_GETEXCEPTION: SHOW_DST(iptr); break; +#if defined(ENABLE_SSA) + case ICMD_PHI: + printf("[ "); + for (i = 0; i < iptr->s1.argcount; ++i) { + SHOW_VARIABLE(iptr->sx.s23.s2.iargs[i]->dst.varindex); + } + printf("] "); + SHOW_DST(iptr); + if (iptr->flags.bits & (1 << 0)) printf("used "); + if (iptr->flags.bits & (1 << 1)) printf("redundantAll "); + if (iptr->flags.bits & (1 << 2)) printf("redundantOne "); + break; +#endif } fflush(stdout); } @@ -1536,7 +1558,6 @@ void show_filters_apply(methodinfo *m) { int res; char *method_name; s4 len; - int32_t dumpmarker; /* compose full name of method */ @@ -1547,9 +1568,7 @@ void show_filters_apply(methodinfo *m) { utf_bytes(m->descriptor) + 1; - DMARKER; - - method_name = DMNEW(char, len); + method_name = MNEW(char, len); utf_cat_classname(method_name, m->clazz->name); strcat(method_name, "."); @@ -1574,9 +1593,8 @@ void show_filters_apply(methodinfo *m) { } } - /* release memory */ - - DRELEASE; + // Release memory. + MFREE(method_name, char, len); } #define STATE_IS_INITIAL() ((FILTERVERBOSECALLCTR[0] == 0) && (FILTERVERBOSECALLCTR[1] == 0)) diff --git a/src/vm/jit/show.h b/src/vm/jit/show.h index 573932273..8e0c4c720 100644 --- a/src/vm/jit/show.h +++ b/src/vm/jit/show.h @@ -1,9 +1,7 @@ /* src/vm/jit/show.h - showing the intermediate representation - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,25 +20,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Andreas Krall - - Changes: Edwin Steiner - Christian Thalinger - Christian Ullrich - - */ #ifndef _SHOW_H #define _SHOW_H +#ifdef __cplusplus +extern "C" { +#endif + #include "config.h" #include "vm/types.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* compiler stage defines *****************************************************/ @@ -82,9 +75,13 @@ int show_filters_test_verbosecall_enter(methodinfo *m); int show_filters_test_verbosecall_exit(methodinfo *m); #endif +#ifdef __cplusplus +} +#endif #endif /* _SHOW_H */ + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/sparc64/Makefile.am b/src/vm/jit/sparc64/Makefile.am index 38535c3a8..2fbeef9f5 100644 --- a/src/vm/jit/sparc64/Makefile.am +++ b/src/vm/jit/sparc64/Makefile.am @@ -34,9 +34,9 @@ LIBS = noinst_HEADERS = \ arch.h \ - machine-instr.h \ \ - md-asm.h + md-asm.h \ + md-atomic.hpp noinst_LTLIBRARIES = libarch.la @@ -57,6 +57,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/sparc64/codegen.c b/src/vm/jit/sparc64/codegen.c index d13339a8a..87e3084cd 100644 --- a/src/vm/jit/sparc64/codegen.c +++ b/src/vm/jit/sparc64/codegen.c @@ -39,28 +39,27 @@ #include "mm/memory.h" -#include "native/jni.h" #include "native/localref.h" #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" + +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/options.h" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/parse.h" #include "vm/jit/patcher.h" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/sparc64/solaris/macro_rename.h" @@ -2671,9 +2670,6 @@ gen_method: superindex = super->index; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); /* if class is not resolved, check which code to call */ @@ -2744,16 +2740,12 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval)); M_SUB(REG_ITMP2, REG_ITMP3, REG_ITMP2); M_ALD(REG_ITMP3, REG_PV, disp); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - /* } */ M_CMP(REG_ITMP3, REG_ITMP2); emit_classcast_check(cd, iptr, BRANCH_ULT, REG_ITMP3, s1); @@ -2836,9 +2828,6 @@ gen_method: supervftbl = super->vftbl; } - if ((super == NULL) || !(super->flags & ACC_INTERFACE)) - CODEGEN_CRITICAL_SECTION_NEW; - s1 = emit_load_s1(jd, iptr, REG_ITMP1); d = codegen_reg_of_dst(jd, iptr, REG_ITMP2); if (s1 == d) { @@ -2914,14 +2903,10 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_object_t, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); - CODEGEN_CRITICAL_SECTION_START; - M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); - CODEGEN_CRITICAL_SECTION_END; - M_SUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); M_CMP(REG_ITMP1, REG_ITMP2); M_XCMOVULE_IMM(1, d); @@ -3434,7 +3419,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f) /* put env into first argument register */ - disp = dseg_add_address(cd, _Jv_env); + disp = dseg_add_address(cd, VM_get_jnienv()); M_ALD(REG_OUT0, REG_PV_CALLEE, disp); /* do the native function call */ diff --git a/src/vm/jit/sparc64/codegen.h b/src/vm/jit/sparc64/codegen.h index ade165128..b64cf4fc6 100644 --- a/src/vm/jit/sparc64/codegen.h +++ b/src/vm/jit/sparc64/codegen.h @@ -1,10 +1,8 @@ -/* src/vm/jit/sparc64/codegen.h - code generation macros and definitions for - Sparc64 +/* src/vm/jit/sparc64/codegen.h - code generation macros and + definitions for SPARC64 - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -31,7 +29,7 @@ #include "config.h" #include "vm/types.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "md-abi.h" /* for INT_NATARG_CNT */ @@ -72,11 +70,6 @@ s4 nat_argintregs[INT_NATARG_CNT]; } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 4 * 4 - - /* additional functions and macros to generate code ***************************/ diff --git a/src/vm/jit/sparc64/emit.c b/src/vm/jit/sparc64/emit.c index def530822..e7f8f379e 100644 --- a/src/vm/jit/sparc64/emit.c +++ b/src/vm/jit/sparc64/emit.c @@ -1,9 +1,7 @@ /* src/vm/jit/sparc64/emit.c - SPARC code emitter functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -37,18 +35,16 @@ #include "mm/memory.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" /* XXX for gen_resolvebranch */ +#include "vm/jit/builtin.hpp" +#include "vm/options.h" + #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" -#include "vm/builtin.h" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/replace.h" - -#include "vmcore/options.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/replace.hpp" #include "vm/jit/sparc64/solaris/macro_rename.h" diff --git a/src/vm/jit/sparc64/linux/md-os.c b/src/vm/jit/sparc64/linux/md-os.c index 114459477..e1cdfdb9f 100644 --- a/src/vm/jit/sparc64/linux/md-os.c +++ b/src/vm/jit/sparc64/linux/md-os.c @@ -35,10 +35,9 @@ #include "vm/jit/sparc64/md-abi.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" @@ -176,40 +175,6 @@ void md_icacheflush(u1 *addr, s4 nbytes) } } -#if defined(ENABLE_THREADS) -/* md_critical_section_restart ************************************************ - - Search the critical sections tree for a matching section and set - the NPC to the restart point, if necessary. - - Reads PC and modifies NPC. - -******************************************************************************/ - -void md_critical_section_restart(ucontext_t *_uc) -{ - /* mcontext_t *_mc; */ - sigcontext *ctx; - u1 *pc; - u1 *npc; - - printf("ignoring md_critical_section_restart\n"); - return; - - /* again, we are getting sigcontext instead of ucontext */ - ctx = (sigcontext *) _uc; - - pc = (u1 *) ctx->sigc_regs.tpc; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) { - log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc); - ctx->sigc_regs.tnpc = (ptrint) npc; - } - -} -#endif /* * These are local overrides for various environment variables in Emacs. diff --git a/src/vm/jit/sparc64/machine-instr.h b/src/vm/jit/sparc64/machine-instr.h deleted file mode 100644 index cc07238e7..000000000 --- a/src/vm/jit/sparc64/machine-instr.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -#include "toolbox/logging.h" - -static inline long -__attribute__ ((unused)) -compare_and_swap (volatile long *p, long oldval, long newval) -{ - long ret; - /*dolog("compare_and_swap(%p [%d], %d, %d)", p, *p, oldval, newval);*/ - - __asm__ __volatile__ ( - "mov %3,%0\n\t" - "casx [%4],%2,%0\n\t" - : "=&r"(ret), "=m"(*p) - : "r"(oldval), "r"(newval), "r"(p)); - - /*dolog("compare_and_swap() return=%d mem=%d", ret, *p);*/ - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("wmb" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("mb" : : : "memory"); -#define MEMORY_BARRIER() __asm__ __volatile__ ( \ - "membar 0x0F" : : : "memory" ); - -#endif diff --git a/src/vm/jit/sparc64/md-abi.c b/src/vm/jit/sparc64/md-abi.c index 4afd70d7c..cc12be598 100644 --- a/src/vm/jit/sparc64/md-abi.c +++ b/src/vm/jit/sparc64/md-abi.c @@ -28,13 +28,12 @@ #include "vm/jit/sparc64/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" #include "vm/jit/stack.h" -#include "vmcore/descriptor.h" - /* temp */ #include "mm/memory.h" #include diff --git a/src/vm/jit/sparc64/md-atomic.hpp b/src/vm/jit/sparc64/md-atomic.hpp new file mode 100644 index 000000000..5539c38db --- /dev/null +++ b/src/vm/jit/sparc64/md-atomic.hpp @@ -0,0 +1,143 @@ +/* src/vm/jit/sparc64/atomic.hpp - SPARC64 atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ +#if 0 + // This one should be correct. + uint32_t result; + + __asm__ __volatile__ ( + " mov %3,%0 \n" + " cas [%4],%2,%0 \n" + : "=&r" (result), "=m" (*p) + : "r" (oldval), "r" (newval), "r" (p)); + + return result; +#else + return generic_compare_and_swap(p, oldval, newval); +#endif +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + uint64_t result; + + __asm__ __volatile__ ( + " mov %3,%0 \n" + " casx [%4],%2,%0 \n" + : "=&r" (result), "=m" (*p) + : "r" (oldval), "r" (newval), "r" (p)); + + return result; +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("membar 0x0F" : : : "memory" ); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("wmb" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + __asm__ __volatile__ ("mb" : : : "memory"); +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/sparc64/md-stubs.hpp b/src/vm/jit/sparc64/md-stubs.hpp new file mode 100644 index 000000000..eb0dc65d7 --- /dev/null +++ b/src/vm/jit/sparc64/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/sparc64/md-stubs.hpp - SPARC64 JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on a SPARC64 architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 4 * 4; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/sparc64/md-trap.h b/src/vm/jit/sparc64/md-trap.h index e06903192..9cfaaeaee 100644 --- a/src/vm/jit/sparc64/md-trap.h +++ b/src/vm/jit/sparc64/md-trap.h @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/sparc64/md.c b/src/vm/jit/sparc64/md.c index caf2d003d..398fb809d 100644 --- a/src/vm/jit/sparc64/md.c +++ b/src/vm/jit/sparc64/md.c @@ -1,9 +1,7 @@ /* src/vm/jit/sparc64/md.c - machine dependent SPARC64 functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -34,12 +32,9 @@ #include "vm/jit/sparc64/md-abi.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" - #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" /* assembler function prototypes **********************************************/ diff --git a/src/vm/jit/sparc64/md.h b/src/vm/jit/sparc64/md.h index a66b2552a..f47f7750d 100644 --- a/src/vm/jit/sparc64/md.h +++ b/src/vm/jit/sparc64/md.h @@ -35,7 +35,7 @@ #include "vm/types.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" /* md_stacktrace_get_returnaddress ********************************************* diff --git a/src/vm/jit/sparc64/patcher.c b/src/vm/jit/sparc64/patcher.c index 576e710c9..2d9cc8da9 100644 --- a/src/vm/jit/sparc64/patcher.c +++ b/src/vm/jit/sparc64/patcher.c @@ -37,20 +37,20 @@ #include "vm/jit/sparc64/md-abi.h" #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/field.hpp" #include "vm/initialize.h" +#include "vm/options.h" +#include "vm/references.h" +#include "vm/resolve.h" #include "vm/jit/asmpart.h" #include "vm/jit/patcher.h" #include "vm/jit/methodheader.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" -#include "vm/resolve.h" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/sparc64/solaris/macro_rename.h" @@ -231,22 +231,9 @@ bool patcher_get_putfield(u1 *sp) if (!(fi = resolve_field_eager(uf))) return false; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) { - /* patch the field's offset into the instruction */ - - *((u4 *) (ra + 2 * 4)) |= (s2) (fi->offset & 0x00001fff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 2 * 4, 1 * 4); - } - else { - /* otherwise store the patched instruction on the stack */ + /* store the patched instruction on the stack */ - *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x00001fff); - } + *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x00001fff); return true; } @@ -445,28 +432,11 @@ bool patcher_invokevirtual(u1 *sp) if (!(m = resolve_method_eager(um))) return false; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) { - ra = ra + PATCHER_CALL_SIZE; - - /* patch vftbl index */ - - *((s4 *) (ra + 1 * 4)) |= - (s4) ((OFFSET(vftbl_t, table[0]) + - sizeof(methodptr) * m->vftblindex) & 0x00001fff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 1 * 4); - } - else { - /* patch vftbl index */ + /* patch vftbl index */ - *((s4 *) (sp + 3 * 8 + 4)) |= - (s4) ((OFFSET(vftbl_t, table[0]) + - sizeof(methodptr) * m->vftblindex) & 0x00001fff); - } + *((s4 *) (sp + 3 * 8 + 4)) |= + (s4) ((OFFSET(vftbl_t, table[0]) + + sizeof(methodptr) * m->vftblindex) & 0x00001fff); return true; } @@ -501,42 +471,20 @@ bool patcher_invokeinterface(u1 *sp) if (!(m = resolve_method_eager(um))) return false; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) { - ra = ra + PATCHER_CALL_SIZE; - - /* patch interfacetable index */ - - *((s4 *) (ra + 1 * 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - sizeof(methodptr*) * m->clazz->index) & 0x00001fff); - - /* patch method offset */ - - *((s4 *) (ra + 2 * 4)) |= - (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x00001fff); - - /* synchronize instruction cache */ - - md_icacheflush(ra + 1 * 4, 2 * 4); - } - else { - /* patch interfacetable index */ + /* patch interfacetable index */ - *((s4 *) (sp + 3 * 8 + 4)) |= - (s4) ((OFFSET(vftbl_t, interfacetable[0]) - - sizeof(methodptr*) * m->clazz->index) & 0x00001fff); + *((s4 *) (sp + 3 * 8 + 4)) |= + (s4) ((OFFSET(vftbl_t, interfacetable[0]) - + sizeof(methodptr*) * m->clazz->index) & 0x00001fff); - /* patch method offset */ + /* patch method offset */ - *((s4 *) (ra + 2 * 4)) |= - (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x00001fff); + *((s4 *) (ra + 2 * 4)) |= + (s4) ((sizeof(methodptr) * (m - m->clazz->methods)) & 0x00001fff); - /* synchronize instruction cache */ + /* synchronize instruction cache */ - md_icacheflush(ra + 2 * 4, 1 * 4); - } + md_icacheflush(ra + 2 * 4, 1 * 4); return true; } @@ -614,11 +562,6 @@ bool patcher_checkcast_interface(u1 *sp) if (!(c = resolve_classref_eager(cr))) return false; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch super class index */ *((s4 *) (ra + 2 * 4)) |= (s4) (-(c->index) & 0x00001fff); @@ -629,10 +572,7 @@ bool patcher_checkcast_interface(u1 *sp) /* synchronize instruction cache */ - if (opt_shownops) - md_icacheflush(ra - 2 * 4, (6 + EXCEPTION_CHECK_INSTRUCTIONS) * 4); - else - md_icacheflush(ra, (4 + EXCEPTION_CHECK_INSTRUCTIONS) * 4); + md_icacheflush(ra, (4 + EXCEPTION_CHECK_INSTRUCTIONS) * 4); return true; } @@ -667,11 +607,6 @@ bool patcher_instanceof_interface(u1 *sp) if (!(c = resolve_classref_eager(cr))) return false; - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - /* patch super class index */ *((s4 *) (ra + 2 * 4)) |= (s4) ((c->index) & 0x00001fff); @@ -681,10 +616,7 @@ bool patcher_instanceof_interface(u1 *sp) /* synchronize instruction cache */ - if (opt_shownops) - md_icacheflush(ra - PATCHER_CALL_SIZE * 4, 8 * 4); - else - md_icacheflush(ra, 6 * 4); + md_icacheflush(ra, 6 * 4); return true; } diff --git a/src/vm/jit/sparc64/solaris/md-os.c b/src/vm/jit/sparc64/solaris/md-os.c index 81f191896..7c4c802a8 100644 --- a/src/vm/jit/sparc64/solaris/md-os.c +++ b/src/vm/jit/sparc64/solaris/md-os.c @@ -37,12 +37,10 @@ #include "vm/jit/sparc64/codegen.h" #include "vm/jit/sparc64/md-abi.h" -#include "vm/exceptions.h" #include "vm/signallocal.h" -#include "vm/stringlocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" @@ -151,22 +149,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) } -#if defined(USE_THREADS) && defined(NATIVE_THREADS) -void thread_restartcriticalsection(ucontext_t *_uc) -{ - mcontext_t *_mc; - void *critical; - - _mc = &_uc->uc_mcontext; - - critical = thread_checkcritical((void *) _mc->sc_pc); - - if (critical) - _mc->sc_pc = (ptrint) critical; -} -#endif - - /* md_icacheflush ************************************************************** Calls the system's function to flush the instruction cache. diff --git a/src/vm/jit/stack.c b/src/vm/jit/stack.c index e692269d2..8d40f084f 100644 --- a/src/vm/jit/stack.c +++ b/src/vm/jit/stack.c @@ -39,14 +39,21 @@ #include "toolbox/logging.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/builtin.h" -#include "vm/stringlocal.h" +#include "vm/options.h" +#include "vm/resolve.h" +#include "vm/string.hpp" #include "vm/types.h" +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + #include "vm/jit/abi.h" #include "vm/jit/cfg.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/parse.h" #include "vm/jit/show.h" @@ -54,7 +61,7 @@ # include "vm/jit/disass.h" #endif -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/stack.h" #if 0 @@ -66,13 +73,6 @@ #endif #endif -#include "vmcore/options.h" -#include "vm/resolve.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - /*#define STACK_VERBOSE*/ diff --git a/src/vm/jit/stack.h b/src/vm/jit/stack.h index eceb2db22..803d2db11 100644 --- a/src/vm/jit/stack.h +++ b/src/vm/jit/stack.h @@ -37,10 +37,9 @@ typedef struct stackelement_t stackelement_t; #include "vm/types.h" -#include "vm/exceptions.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/reg.h" @@ -162,12 +161,20 @@ struct stackelement_t { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + bool stack_init(void); bool stack_analyse(jitdata *jd); void stack_javalocals_store(instruction *iptr, s4 *javalocals); +#ifdef __cplusplus +} +#endif + #endif /* _STACK_H */ diff --git a/src/vm/jit/stacktrace.c b/src/vm/jit/stacktrace.c deleted file mode 100644 index 4f4765aca..000000000 --- a/src/vm/jit/stacktrace.c +++ /dev/null @@ -1,1328 +0,0 @@ -/* src/vm/jit/stacktrace.c - machine independent stacktrace system - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include - -#include "vm/types.h" - -#include "md.h" - -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "vm/jit/stacktrace.h" - -#include "vm/global.h" /* required here for native includes */ -#include "native/jni.h" -#include "native/llni.h" - -#include "native/include/java_lang_Object.h" -#include "native/include/java_lang_Throwable.h" - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -# include "native/include/gnu_classpath_Pointer.h" -# include "native/include/java_lang_VMThrowable.h" -#endif - -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/cycles-stats.h" -#include "vm/exceptions.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/linenumbertable.h" -#include "vm/jit/methodheader.h" -#include "vm/jit/methodtree.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/options.h" - - -/* global variables ***********************************************************/ - -CYCLES_STATS_DECLARE(stacktrace_overhead , 100, 1) -CYCLES_STATS_DECLARE(stacktrace_fillInStackTrace, 40, 5000) -CYCLES_STATS_DECLARE(stacktrace_get, 40, 5000) -CYCLES_STATS_DECLARE(stacktrace_getClassContext , 40, 5000) -CYCLES_STATS_DECLARE(stacktrace_getCurrentClass , 40, 5000) -CYCLES_STATS_DECLARE(stacktrace_get_stack , 40, 10000) - - -/* stacktrace_stackframeinfo_add *********************************************** - - Fills a stackframe info structure with the given or calculated - values and adds it to the chain. - -*******************************************************************************/ - -void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc) -{ - stackframeinfo_t *currentsfi; - codeinfo *code; -#if defined(ENABLE_JIT) - s4 framesize; -#endif - - /* Get current stackframe info. */ - - currentsfi = threads_get_current_stackframeinfo(); - - /* sometimes we don't have pv handy (e.g. in asmpart.S: - L_asm_call_jit_compiler_exception or in the interpreter). */ - - if (pv == NULL) { -#if defined(ENABLE_INTRP) - if (opt_intrp) - pv = methodtree_find(ra); - else -#endif - { -#if defined(ENABLE_JIT) -# if defined(__SPARC_64__) - pv = md_get_pv_from_stackframe(sp); -# else - pv = md_codegen_get_pv_from_pc(ra); -# endif -#endif - } - } - - /* Get codeinfo pointer for the parent Java method. */ - - code = code_get_codeinfo_for_pv(pv); - - /* XXX */ - /* assert(m != NULL); */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - /* When using the interpreter, we pass RA to the function. */ - - if (!opt_intrp) { -# endif -# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__) - /* On i386 and x86_64 we always have to get the return address - from the stack. */ - /* m68k has return address on stack always */ - /* On S390 we use REG_RA as REG_ITMP3, so we have always to get - the RA from stack. */ - - framesize = *((u4 *) (pv + FrameSize)); - - ra = md_stacktrace_get_returnaddress(sp, framesize); -# else - /* If the method is a non-leaf function, we need to get the - return address from the stack. For leaf functions the - return address is set correctly. This makes the assembler - and the signal handler code simpler. The code is NULL is - the asm_vm_call_method special case. */ - - if ((code == NULL) || !code_is_leafmethod(code)) { - framesize = *((u4 *) (pv + FrameSize)); - - ra = md_stacktrace_get_returnaddress(sp, framesize); - } -# endif -# if defined(ENABLE_INTRP) - } -# endif -#endif - - /* Calculate XPC when not given. The XPC is then the return - address of the current method minus 1 because the RA points to - the instruction after the call instruction. This is required - e.g. for method stubs. */ - - if (xpc == NULL) { - xpc = (void *) (((intptr_t) ra) - 1); - } - - /* Fill new stackframeinfo structure. */ - - sfi->prev = currentsfi; - sfi->code = code; - sfi->pv = pv; - sfi->sp = sp; - sfi->ra = ra; - sfi->xpc = xpc; - -#if !defined(NDEBUG) - if (opt_DebugStackFrameInfo) { - log_start(); - log_print("[stackframeinfo add : sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=", - sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc); - method_print(sfi->code->m); - log_print("]"); - log_finish(); - } -#endif - - /* Store new stackframeinfo pointer. */ - - threads_set_current_stackframeinfo(sfi); - - /* set the native world flag for the current thread */ - /* ATTENTION: This flag tells the GC how to treat this thread in case of - a collection. Set this flag _after_ a valid stackframe info was set. */ - - THREAD_NATIVEWORLD_ENTER; -} - - -/* stacktrace_stackframeinfo_remove ******************************************** - - Remove the given stackframeinfo from the chain in the current - thread. - -*******************************************************************************/ - -void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi) -{ - /* Clear the native world flag for the current thread. */ - /* ATTENTION: Clear this flag _before_ removing the stackframe info. */ - - THREAD_NATIVEWORLD_EXIT; - -#if !defined(NDEBUG) - if (opt_DebugStackFrameInfo) { - log_start(); - log_print("[stackframeinfo remove: sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=", - sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc); - method_print(sfi->code->m); - log_print("]"); - log_finish(); - } -#endif - - /* Set previous stackframe info. */ - - threads_set_current_stackframeinfo(sfi->prev); -} - - -/* stacktrace_stackframeinfo_fill ********************************************** - - Fill the temporary stackframeinfo structure with the values given - in sfi. - - IN: - tmpsfi ... temporary stackframeinfo - sfi ...... stackframeinfo to be used in the next iteration - -*******************************************************************************/ - -static inline void stacktrace_stackframeinfo_fill(stackframeinfo_t *tmpsfi, stackframeinfo_t *sfi) -{ - /* Sanity checks. */ - - assert(tmpsfi != NULL); - assert(sfi != NULL); - - /* Fill the temporary stackframeinfo. */ - - tmpsfi->code = sfi->code; - tmpsfi->pv = sfi->pv; - tmpsfi->sp = sfi->sp; - tmpsfi->ra = sfi->ra; - tmpsfi->xpc = sfi->xpc; - - /* Set the previous stackframe info of the temporary one to the - next in the chain. */ - - tmpsfi->prev = sfi->prev; - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace fill]"); -#endif -} - - -/* stacktrace_stackframeinfo_next ********************************************** - - Walk the stack (or the stackframeinfo-chain) to the next method and - return the new stackframe values in the temporary stackframeinfo - passed. - - ATTENTION: This function does NOT skip builtin methods! - - IN: - tmpsfi ... temporary stackframeinfo of current method - -*******************************************************************************/ - -static inline void stacktrace_stackframeinfo_next(stackframeinfo_t *tmpsfi) -{ - codeinfo *code; - void *pv; - void *sp; - void *ra; - void *xpc; - uint32_t framesize; - stackframeinfo_t *prevsfi; - - /* Sanity check. */ - - assert(tmpsfi != NULL); - - /* Get values from the stackframeinfo. */ - - code = tmpsfi->code; - pv = tmpsfi->pv; - sp = tmpsfi->sp; - ra = tmpsfi->ra; - xpc = tmpsfi->xpc; - - /* Get the current stack frame size. */ - - framesize = *((uint32_t *) (((intptr_t) pv) + FrameSize)); - - /* Get the RA of the current stack frame (RA to the parent Java - method) if the current method is a non-leaf method. Otherwise - the value in the stackframeinfo is correct (from the signal - handler). */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - ra = intrp_md_stacktrace_get_returnaddress(sp, framesize); - else -# endif - { - if (!code_is_leafmethod(code)) - ra = md_stacktrace_get_returnaddress(sp, framesize); - } -#else - ra = intrp_md_stacktrace_get_returnaddress(sp, framesize); -#endif - - /* Get the PV for the parent Java method. */ - -#if defined(ENABLE_INTRP) - if (opt_intrp) - pv = methodtree_find(ra); - else -#endif - { -#if defined(ENABLE_JIT) -# if defined(__SPARC_64__) - sp = md_get_framepointer(sp); - pv = md_get_pv_from_stackframe(sp); -# else - pv = md_codegen_get_pv_from_pc(ra); -# endif -#endif - } - - /* Get the codeinfo pointer for the parent Java method. */ - - code = code_get_codeinfo_for_pv(pv); - - /* Calculate the SP for the parent Java method. */ - -#if defined(ENABLE_INTRP) - if (opt_intrp) - sp = *(u1 **) (sp - framesize); - else -#endif - { -#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__) - sp = (void *) (((intptr_t) sp) + framesize + SIZEOF_VOID_P); -#elif defined(__SPARC_64__) - /* already has the new sp */ -#else - sp = (void *) (((intptr_t) sp) + framesize); -#endif - } - - /* If the new codeinfo pointer is NULL we reached a - asm_vm_call_method function. In this case we get the next - values from the previous stackframeinfo in the chain. - Otherwise the new values have been calculated before. */ - - if (code == NULL) { - prevsfi = tmpsfi->prev; - - /* If the previous stackframeinfo in the chain is NULL we - reached the top of the stacktrace. We set code and prev to - NULL to mark the end, which is checked in - stacktrace_stackframeinfo_end_check. */ - - if (prevsfi == NULL) { - tmpsfi->code = NULL; - tmpsfi->prev = NULL; - return; - } - - /* Fill the temporary stackframeinfo with the new values. */ - - stacktrace_stackframeinfo_fill(tmpsfi, prevsfi); - } - else { - /* Store the new values in the stackframeinfo. NOTE: We - subtract 1 from the RA to get the XPC, because the RA - points to the instruction after the call instruction. */ - - tmpsfi->code = code; - tmpsfi->pv = pv; - tmpsfi->sp = sp; - tmpsfi->ra = ra; - tmpsfi->xpc = (void *) (((intptr_t) ra) - 1); - } - -#if !defined(NDEBUG) - /* Print current method information. */ - - if (opt_DebugStackTrace) { - log_start(); - log_print("[stacktrace: method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=", - tmpsfi->code->m, tmpsfi->pv, tmpsfi->sp, tmpsfi->ra, - tmpsfi->xpc); - method_print(tmpsfi->code->m); - log_print("]"); - log_finish(); - } -#endif -} - - -/* stacktrace_stackframeinfo_end_check ***************************************** - - Check if we reached the end of the stacktrace. - - IN: - tmpsfi ... temporary stackframeinfo of current method - - RETURN: - true .... the end is reached - false ... the end is not reached - -*******************************************************************************/ - -static inline bool stacktrace_stackframeinfo_end_check(stackframeinfo_t *tmpsfi) -{ - /* Sanity check. */ - - assert(tmpsfi != NULL); - - if ((tmpsfi->code == NULL) && (tmpsfi->prev == NULL)) { -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace stop]"); -#endif - - return true; - } - - return false; -} - - -/* stacktrace_depth ************************************************************ - - Calculates and returns the depth of the current stacktrace. - - IN: - sfi ... stackframeinfo where to start the stacktrace - - RETURN: - depth of the stacktrace - -*******************************************************************************/ - -static int stacktrace_depth(stackframeinfo_t *sfi) -{ - stackframeinfo_t tmpsfi; - int depth; - methodinfo *m; - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_depth]"); -#endif - - /* XXX This is not correct, but a workaround for threads-dump for - now. */ -/* assert(sfi != NULL); */ - if (sfi == NULL) - return 0; - - /* Iterate over all stackframes. */ - - depth = 0; - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get methodinfo. */ - - m = tmpsfi.code->m; - - /* Skip builtin methods. */ - - if (m->flags & ACC_METHOD_BUILTIN) - continue; - - depth++; - } - - return depth; -} - - -/* stacktrace_get ************************************************************** - - Builds and returns a stacktrace starting from the given stackframe - info and returns the stacktrace structure wrapped in a Java - byte-array to not confuse the GC. - - IN: - sfi ... stackframe info to start stacktrace from - - RETURN: - stacktrace as Java byte-array - -*******************************************************************************/ - -java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi) -{ - stackframeinfo_t tmpsfi; - int depth; - java_handle_bytearray_t *ba; - int32_t ba_size; - stacktrace_t *st; - stacktrace_entry_t *ste; - methodinfo *m; - bool skip_fillInStackTrace; - bool skip_init; - - CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_get]"); -#endif - - skip_fillInStackTrace = true; - skip_init = true; - - depth = stacktrace_depth(sfi); - - if (depth == 0) - return NULL; - - /* Allocate memory from the GC heap and copy the stacktrace - buffer. */ - /* ATTENTION: Use a Java byte-array for this to not confuse the - GC. */ - /* FIXME: We waste some memory here as we skip some entries - later. */ - - ba_size = sizeof(stacktrace_t) + sizeof(stacktrace_entry_t) * depth; - - ba = builtin_newarray_byte(ba_size); - - if (ba == NULL) - goto return_NULL; - - /* Get a stacktrace entry pointer. */ - /* ATTENTION: We need a critical section here because we use the - byte-array data pointer directly. */ - - LLNI_CRITICAL_START; - - st = (stacktrace_t *) LLNI_array_data(ba); - - ste = st->entries; - - /* Iterate over the whole stack. */ - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get the methodinfo. */ - - m = tmpsfi.code->m; - - /* Skip builtin methods. */ - - if (m->flags & ACC_METHOD_BUILTIN) - continue; - - /* This logic is taken from - hotspot/src/share/vm/classfile/javaClasses.cpp - (java_lang_Throwable::fill_in_stack_trace). */ - - if (skip_fillInStackTrace == true) { - /* Check "fillInStackTrace" only once, so we negate the - flag after the first time check. */ - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - /* For GNU Classpath we also need to skip - VMThrowable.fillInStackTrace(). */ - - if ((m->clazz == class_java_lang_VMThrowable) && - (m->name == utf_fillInStackTrace)) - continue; -#endif - - skip_fillInStackTrace = false; - - if (m->name == utf_fillInStackTrace) - continue; - } - - /* Skip methods of the exceptions klass. If there is - methods that belongs to a superclass of the - exception we are going to skipping them in stack trace. */ - - if (skip_init == true) { - if ((m->name == utf_init) && - (class_issubclass(m->clazz, class_java_lang_Throwable))) { - continue; - } - else { - /* If no "Throwable.init()" method found, we stop - checking it next time. */ - - skip_init = false; - } - } - - /* Store the stacktrace entry and increment the pointer. */ - - ste->code = tmpsfi.code; - ste->pc = tmpsfi.xpc; - - ste++; - } - - /* Store the number of entries in the stacktrace structure. */ - - st->length = ste - st->entries; - - LLNI_CRITICAL_END; - - /* release dump memory */ - -/* dump_release(dumpsize); */ - - CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace, - stacktrace_overhead) - return ba; - -return_NULL: -/* dump_release(dumpsize); */ - - CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace, - stacktrace_overhead) - - return NULL; -} - - -/* stacktrace_get_current ****************************************************** - - Builds and returns a stacktrace from the current thread and returns - the stacktrace structure wrapped in a Java byte-array to not - confuse the GC. - - RETURN: - stacktrace as Java byte-array - -*******************************************************************************/ - -java_handle_bytearray_t *stacktrace_get_current(void) -{ - stackframeinfo_t *sfi; - java_handle_bytearray_t *ba; - - sfi = threads_get_current_stackframeinfo(); - ba = stacktrace_get(sfi); - - return ba; -} - - -/* stacktrace_get_caller_class ************************************************* - - Get the class on the stack at the given depth. This function skips - various special classes or methods. - - ARGUMENTS: - depth ... depth to get caller class of - - RETURN: - caller class - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -classinfo *stacktrace_get_caller_class(int depth) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - methodinfo *m; - classinfo *c; - int i; - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_get_caller_class]"); -#endif - - /* Get the stackframeinfo of the current thread. */ - - sfi = threads_get_current_stackframeinfo(); - - /* Iterate over the whole stack until we reached the requested - depth. */ - - i = 0; - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - - m = tmpsfi.code->m; - c = m->clazz; - - /* Skip builtin methods. */ - - if (m->flags & ACC_METHOD_BUILTIN) - continue; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp - (vframeStreamCommon::security_get_caller_frame). */ - - /* This is java.lang.reflect.Method.invoke(), skip it. */ - - if (m == method_java_lang_reflect_Method_invoke) - continue; - - /* This is an auxiliary frame, skip it. */ - - if (class_issubclass(c, class_sun_reflect_MagicAccessorImpl)) - continue; -#endif - - /* We reached the requested depth. */ - - if (i >= depth) - return c; - - i++; - } - - return NULL; -} -#endif - - -/* stacktrace_first_nonnull_classloader **************************************** - - Returns the first non-null (user-defined) classloader on the stack. - If none is found NULL is returned. - - RETURN: - classloader - -*******************************************************************************/ - -classloader_t *stacktrace_first_nonnull_classloader(void) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - methodinfo *m; - classloader_t *cl; - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_first_nonnull_classloader]"); -#endif - - /* Get the stackframeinfo of the current thread. */ - - sfi = threads_get_current_stackframeinfo(); - - /* Iterate over the whole stack. */ - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - - m = tmpsfi.code->m; - cl = class_get_classloader(m->clazz); - - if (cl != NULL) - return cl; - } - - return NULL; -} - - -/* stacktrace_getClassContext ************************************************** - - Creates a Class context array. - - RETURN VALUE: - the array of java.lang.Class objects, or - NULL if an exception has been thrown - -*******************************************************************************/ - -java_handle_objectarray_t *stacktrace_getClassContext(void) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - int depth; - java_handle_objectarray_t *oa; - java_object_t **data; - int i; - methodinfo *m; - - CYCLES_STATS_DECLARE_AND_START - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_getClassContext]"); -#endif - - sfi = threads_get_current_stackframeinfo(); - - /* Get the depth of the current stack. */ - - depth = stacktrace_depth(sfi); - - /* The first stackframe corresponds to the method whose - implementation calls this native function. We remove that - entry. */ - - depth--; - stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_next(&tmpsfi); - - /* Allocate the Class array. */ - - oa = builtin_anewarray(depth, class_java_lang_Class); - - if (oa == NULL) { - CYCLES_STATS_END(stacktrace_getClassContext); - - return NULL; - } - - /* Fill the Class array from the stacktrace list. */ - - LLNI_CRITICAL_START; - - data = LLNI_array_data(oa); - - /* Iterate over the whole stack. */ - - i = 0; - - for (; - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get methodinfo. */ - - m = tmpsfi.code->m; - - /* Skip builtin methods. */ - - if (m->flags & ACC_METHOD_BUILTIN) - continue; - - /* Store the class in the array. */ - - data[i] = (java_object_t *) m->clazz; - - i++; - } - - LLNI_CRITICAL_END; - - CYCLES_STATS_END(stacktrace_getClassContext) - - return oa; -} - - -/* stacktrace_getCurrentClass ************************************************** - - Find the current class by walking the stack trace. - - Quote from the JNI documentation: - - In the Java 2 Platform, FindClass locates the class loader - associated with the current native method. If the native code - belongs to a system class, no class loader will be - involved. Otherwise, the proper class loader will be invoked to - load and link the named class. When FindClass is called through the - Invocation Interface, there is no current native method or its - associated class loader. In that case, the result of - ClassLoader.getBaseClassLoader is used." - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -classinfo *stacktrace_get_current_class(void) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - methodinfo *m; - - CYCLES_STATS_DECLARE_AND_START; - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_get_current_class]"); -#endif - - /* Get the stackframeinfo of the current thread. */ - - sfi = threads_get_current_stackframeinfo(); - - /* If the stackframeinfo is NULL then FindClass is called through - the Invocation Interface and we return NULL */ - - if (sfi == NULL) { - CYCLES_STATS_END(stacktrace_getCurrentClass); - - return NULL; - } - - /* Iterate over the whole stack. */ - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get the methodinfo. */ - - m = tmpsfi.code->m; - - if (m->clazz == class_java_security_PrivilegedAction) { - CYCLES_STATS_END(stacktrace_getCurrentClass); - - return NULL; - } - - if (m->clazz != NULL) { - CYCLES_STATS_END(stacktrace_getCurrentClass); - - return m->clazz; - } - } - - /* No Java method found on the stack. */ - - CYCLES_STATS_END(stacktrace_getCurrentClass); - - return NULL; -} -#endif /* ENABLE_JAVASE */ - - -/* stacktrace_get_stack ******************************************************** - - Create a 2-dimensional array for java.security.VMAccessControler. - - RETURN VALUE: - the arrary, or - NULL if an exception has been thrown - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -java_handle_objectarray_t *stacktrace_get_stack(void) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - int depth; - java_handle_objectarray_t *oa; - java_handle_objectarray_t *classes; - java_handle_objectarray_t *methodnames; - methodinfo *m; - java_handle_t *string; - int i; - - CYCLES_STATS_DECLARE_AND_START - -#if !defined(NDEBUG) - if (opt_DebugStackTrace) - log_println("[stacktrace_get_stack]"); -#endif - - /* Get the stackframeinfo of the current thread. */ - - sfi = threads_get_current_stackframeinfo(); - - /* Get the depth of the current stack. */ - - depth = stacktrace_depth(sfi); - - if (depth == 0) - return NULL; - - /* Allocate the required arrays. */ - - oa = builtin_anewarray(2, arrayclass_java_lang_Object); - - if (oa == NULL) - goto return_NULL; - - classes = builtin_anewarray(depth, class_java_lang_Class); - - if (classes == NULL) - goto return_NULL; - - methodnames = builtin_anewarray(depth, class_java_lang_String); - - if (methodnames == NULL) - goto return_NULL; - - /* Set up the 2-dimensional array. */ - - array_objectarray_element_set(oa, 0, (java_handle_t *) classes); - array_objectarray_element_set(oa, 1, (java_handle_t *) methodnames); - - /* Iterate over the whole stack. */ - /* TODO We should use a critical section here to speed things - up. */ - - i = 0; - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get the methodinfo. */ - - m = tmpsfi.code->m; - - /* Skip builtin methods. */ - - if (m->flags & ACC_METHOD_BUILTIN) - continue; - - /* Store the class in the array. */ - /* NOTE: We use a LLNI-macro here, because a classinfo is not - a handle. */ - - LLNI_array_direct(classes, i) = (java_object_t *) m->clazz; - - /* Store the name in the array. */ - - string = javastring_new(m->name); - - if (string == NULL) - goto return_NULL; - - array_objectarray_element_set(methodnames, i, string); - - i++; - } - - CYCLES_STATS_END(stacktrace_get_stack) - - return oa; - -return_NULL: - CYCLES_STATS_END(stacktrace_get_stack) - - return NULL; -} -#endif - - -/* stacktrace_print_entry **************************************************** - - Print line for a stacktrace entry. - - ARGUMENTS: - m ............ methodinfo of the entry - linenumber ... linenumber of the entry - -*******************************************************************************/ - -static void stacktrace_print_entry(methodinfo *m, int32_t linenumber) -{ - /* Sanity check. */ - - assert(m != NULL); - - printf("\tat "); - - if (m->flags & ACC_METHOD_BUILTIN) - printf("NULL"); - else - utf_display_printable_ascii_classname(m->clazz->name); - - printf("."); - utf_display_printable_ascii(m->name); - utf_display_printable_ascii(m->descriptor); - - if (m->flags & ACC_NATIVE) { - puts("(Native Method)"); - } - else { - if (m->flags & ACC_METHOD_BUILTIN) { - puts("(builtin)"); - } - else { - printf("("); - utf_display_printable_ascii(m->clazz->sourcefile); - printf(":%d)\n", linenumber); - } - } - - fflush(stdout); -} - - -/* stacktrace_print ************************************************************ - - Print the given stacktrace with CACAO intern methods only (no Java - code required). - - This method is used by stacktrace_dump_trace and - builtin_trace_exception. - - IN: - st ... stacktrace to print - -*******************************************************************************/ - -void stacktrace_print(stacktrace_t *st) -{ - stacktrace_entry_t *ste; - methodinfo *m; - int32_t linenumber; - int i; - - ste = &(st->entries[0]); - - for (i = 0; i < st->length; i++, ste++) { - m = ste->code->m; - - /* Get the line number. */ - - linenumber = linenumbertable_linenumber_for_pc(&m, ste->code, ste->pc); - - stacktrace_print_entry(m, linenumber); - } -} - - -/* stacktrace_print_current **************************************************** - - Print the current stacktrace of the current thread. - - NOTE: This function prints all frames of the stacktrace and does - not skip frames like stacktrace_get. - -*******************************************************************************/ - -void stacktrace_print_current(void) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - codeinfo *code; - methodinfo *m; - int32_t linenumber; - - sfi = threads_get_current_stackframeinfo(); - - if (sfi == NULL) { - puts("\t<>"); - fflush(stdout); - return; - } - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get the methodinfo. */ - - code = tmpsfi.code; - m = code->m; - - /* Get the line number. */ - - linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc); - - stacktrace_print_entry(m, linenumber); - } -} - - -/* stacktrace_print_of_thread ************************************************** - - Print the current stacktrace of the given thread. - - ARGUMENTS: - t ... thread - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void stacktrace_print_of_thread(threadobject *t) -{ - stackframeinfo_t *sfi; - stackframeinfo_t tmpsfi; - codeinfo *code; - methodinfo *m; - int32_t linenumber; - - /* Build a stacktrace for the passed thread. */ - - sfi = t->_stackframeinfo; - - if (sfi == NULL) { - puts("\t<>"); - fflush(stdout); - return; - } - - for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); - stacktrace_stackframeinfo_end_check(&tmpsfi) == false; - stacktrace_stackframeinfo_next(&tmpsfi)) { - /* Get the methodinfo. */ - - code = tmpsfi.code; - m = code->m; - - /* Get the line number. */ - - linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc); - - stacktrace_print_entry(m, linenumber); - } -} -#endif - - -/* stacktrace_print_exception ************************************************** - - Print the stacktrace of a given exception (more or less a wrapper - to stacktrace_print). - - IN: - h ... handle of exception to print - -*******************************************************************************/ - -void stacktrace_print_exception(java_handle_t *h) -{ - java_lang_Throwable *o; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - java_lang_VMThrowable *vmt; -#endif - - java_lang_Object *backtrace; - java_handle_bytearray_t *ba; - stacktrace_t *st; - - o = (java_lang_Throwable *) h; - - if (o == NULL) - return; - - /* now print the stacktrace */ - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - LLNI_field_get_ref(o, vmState, vmt); - LLNI_field_get_ref(vmt, vmdata, backtrace); - -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - LLNI_field_get_ref(o, backtrace, backtrace); - -#else -# error unknown classpath configuration -#endif - - ba = (java_handle_bytearray_t *) backtrace; - - /* Sanity check. */ - - assert(ba != NULL); - - /* We need a critical section here as we use the byte-array data - pointer directly. */ - - LLNI_CRITICAL_START; - - st = (stacktrace_t *) LLNI_array_data(ba); - - stacktrace_print(st); - - LLNI_CRITICAL_END; -} - - -#if defined(ENABLE_CYCLES_STATS) -void stacktrace_print_cycles_stats(FILE *file) -{ - CYCLES_STATS_PRINT_OVERHEAD(stacktrace_overhead, file); - CYCLES_STATS_PRINT(stacktrace_get, file); - CYCLES_STATS_PRINT(stacktrace_getClassContext , file); - CYCLES_STATS_PRINT(stacktrace_getCurrentClass , file); - CYCLES_STATS_PRINT(stacktrace_get_stack, file); -} -#endif - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/stacktrace.cpp b/src/vm/jit/stacktrace.cpp new file mode 100644 index 000000000..8f6f4fca7 --- /dev/null +++ b/src/vm/jit/stacktrace.cpp @@ -0,0 +1,1312 @@ +/* src/vm/jit/stacktrace.cpp - machine independent stacktrace system + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include + +#include "vm/types.h" + +#include "md.h" + +#include "mm/gc.hpp" +#include "mm/memory.h" + +#include "vm/jit/stacktrace.hpp" + +#include "native/llni.h" + +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/cycles-stats.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/asmpart.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/linenumbertable.h" +#include "vm/jit/methodheader.h" +#include "vm/jit/methodtree.h" + + +// FIXME Use C-linkage for now. +extern "C" { + +/* global variables ***********************************************************/ + +CYCLES_STATS_DECLARE(stacktrace_overhead , 100, 1) +CYCLES_STATS_DECLARE(stacktrace_fillInStackTrace, 40, 5000) +CYCLES_STATS_DECLARE(stacktrace_get, 40, 5000) +CYCLES_STATS_DECLARE(stacktrace_getClassContext , 40, 5000) +CYCLES_STATS_DECLARE(stacktrace_getCurrentClass , 40, 5000) +CYCLES_STATS_DECLARE(stacktrace_get_stack , 40, 10000) + + +/* stacktrace_stackframeinfo_add *********************************************** + + Fills a stackframe info structure with the given or calculated + values and adds it to the chain. + +*******************************************************************************/ + +void stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc) +{ + stackframeinfo_t *currentsfi; + codeinfo *code; +#if defined(ENABLE_JIT) + s4 framesize; +#endif + + /* Get current stackframe info. */ + + currentsfi = threads_get_current_stackframeinfo(); + + /* sometimes we don't have pv handy (e.g. in asmpart.S: + L_asm_call_jit_compiler_exception or in the interpreter). */ + + if (pv == NULL) { +#if defined(ENABLE_INTRP) + if (opt_intrp) + pv = methodtree_find(ra); + else +#endif + { +#if defined(ENABLE_JIT) +# if defined(__SPARC_64__) + pv = md_get_pv_from_stackframe(sp); +# else + pv = md_codegen_get_pv_from_pc(ra); +# endif +#endif + } + } + + /* Get codeinfo pointer for the parent Java method. */ + + code = code_get_codeinfo_for_pv(pv); + + /* XXX */ + /* assert(m != NULL); */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + /* When using the interpreter, we pass RA to the function. */ + + if (!opt_intrp) { +# endif +# if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__) + /* On i386 and x86_64 we always have to get the return address + from the stack. */ + /* m68k has return address on stack always */ + /* On S390 we use REG_RA as REG_ITMP3, so we have always to get + the RA from stack. */ + + framesize = *((u4 *) (((uintptr_t) pv) + FrameSize)); + + ra = md_stacktrace_get_returnaddress(sp, framesize); +# else + /* If the method is a non-leaf function, we need to get the + return address from the stack. For leaf functions the + return address is set correctly. This makes the assembler + and the signal handler code simpler. The code is NULL is + the asm_vm_call_method special case. */ + + if ((code == NULL) || !code_is_leafmethod(code)) { + framesize = *((u4 *) (((uintptr_t) pv) + FrameSize)); + + ra = md_stacktrace_get_returnaddress(sp, framesize); + } +# endif +# if defined(ENABLE_INTRP) + } +# endif +#endif + + /* Calculate XPC when not given. The XPC is then the return + address of the current method minus 1 because the RA points to + the instruction after the call instruction. This is required + e.g. for method stubs. */ + + if (xpc == NULL) { + xpc = (void *) (((intptr_t) ra) - 1); + } + + /* Fill new stackframeinfo structure. */ + + sfi->prev = currentsfi; + sfi->code = code; + sfi->pv = pv; + sfi->sp = sp; + sfi->ra = ra; + sfi->xpc = xpc; + +#if !defined(NDEBUG) + if (opt_DebugStackFrameInfo) { + log_start(); + log_print("[stackframeinfo add : sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=", + sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc); + method_print(sfi->code->m); + log_print("]"); + log_finish(); + } +#endif + + /* Store new stackframeinfo pointer. */ + + threads_set_current_stackframeinfo(sfi); + + /* set the native world flag for the current thread */ + /* ATTENTION: This flag tells the GC how to treat this thread in case of + a collection. Set this flag _after_ a valid stackframe info was set. */ + + THREAD_NATIVEWORLD_ENTER; +} + + +/* stacktrace_stackframeinfo_remove ******************************************** + + Remove the given stackframeinfo from the chain in the current + thread. + +*******************************************************************************/ + +void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi) +{ + /* Clear the native world flag for the current thread. */ + /* ATTENTION: Clear this flag _before_ removing the stackframe info. */ + + THREAD_NATIVEWORLD_EXIT; + +#if !defined(NDEBUG) + if (opt_DebugStackFrameInfo) { + log_start(); + log_print("[stackframeinfo remove: sfi=%p, method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=", + sfi, sfi->code->m, sfi->pv, sfi->sp, sfi->ra, sfi->xpc); + method_print(sfi->code->m); + log_print("]"); + log_finish(); + } +#endif + + /* Set previous stackframe info. */ + + threads_set_current_stackframeinfo(sfi->prev); +} + + +/* stacktrace_stackframeinfo_fill ********************************************** + + Fill the temporary stackframeinfo structure with the values given + in sfi. + + IN: + tmpsfi ... temporary stackframeinfo + sfi ...... stackframeinfo to be used in the next iteration + +*******************************************************************************/ + +static inline void stacktrace_stackframeinfo_fill(stackframeinfo_t *tmpsfi, stackframeinfo_t *sfi) +{ + /* Sanity checks. */ + + assert(tmpsfi != NULL); + assert(sfi != NULL); + + /* Fill the temporary stackframeinfo. */ + + tmpsfi->code = sfi->code; + tmpsfi->pv = sfi->pv; + tmpsfi->sp = sfi->sp; + tmpsfi->ra = sfi->ra; + tmpsfi->xpc = sfi->xpc; + + /* Set the previous stackframe info of the temporary one to the + next in the chain. */ + + tmpsfi->prev = sfi->prev; + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace fill]"); +#endif +} + + +/* stacktrace_stackframeinfo_next ********************************************** + + Walk the stack (or the stackframeinfo-chain) to the next method and + return the new stackframe values in the temporary stackframeinfo + passed. + + ATTENTION: This function does NOT skip builtin methods! + + IN: + tmpsfi ... temporary stackframeinfo of current method + +*******************************************************************************/ + +static inline void stacktrace_stackframeinfo_next(stackframeinfo_t *tmpsfi) +{ + codeinfo *code; + void *pv; + void *sp; + void *ra; + void *xpc; + uint32_t framesize; + stackframeinfo_t *prevsfi; + + /* Sanity check. */ + + assert(tmpsfi != NULL); + + /* Get values from the stackframeinfo. */ + + code = tmpsfi->code; + pv = tmpsfi->pv; + sp = tmpsfi->sp; + ra = tmpsfi->ra; + xpc = tmpsfi->xpc; + + /* Get the current stack frame size. */ + + framesize = *((uint32_t *) (((intptr_t) pv) + FrameSize)); + + /* Get the RA of the current stack frame (RA to the parent Java + method) if the current method is a non-leaf method. Otherwise + the value in the stackframeinfo is correct (from the signal + handler). */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) + ra = intrp_md_stacktrace_get_returnaddress(sp, framesize); + else +# endif + { + if (!code_is_leafmethod(code)) + ra = md_stacktrace_get_returnaddress(sp, framesize); + } +#else + ra = intrp_md_stacktrace_get_returnaddress(sp, framesize); +#endif + + /* Get the PV for the parent Java method. */ + +#if defined(ENABLE_INTRP) + if (opt_intrp) + pv = methodtree_find(ra); + else +#endif + { +#if defined(ENABLE_JIT) +# if defined(__SPARC_64__) + sp = md_get_framepointer(sp); + pv = md_get_pv_from_stackframe(sp); +# else + pv = md_codegen_get_pv_from_pc(ra); +# endif +#endif + } + + /* Get the codeinfo pointer for the parent Java method. */ + + code = code_get_codeinfo_for_pv(pv); + + /* Calculate the SP for the parent Java method. */ + +#if defined(ENABLE_INTRP) + if (opt_intrp) + sp = *(u1 **) (sp - framesize); + else +#endif + { +#if defined(__I386__) || defined (__X86_64__) || defined (__M68K__) + sp = (void *) (((intptr_t) sp) + framesize + SIZEOF_VOID_P); +#elif defined(__SPARC_64__) + /* already has the new sp */ +#else + sp = (void *) (((intptr_t) sp) + framesize); +#endif + } + + /* If the new codeinfo pointer is NULL we reached a + asm_vm_call_method function. In this case we get the next + values from the previous stackframeinfo in the chain. + Otherwise the new values have been calculated before. */ + + if (code == NULL) { + prevsfi = tmpsfi->prev; + + /* If the previous stackframeinfo in the chain is NULL we + reached the top of the stacktrace. We set code and prev to + NULL to mark the end, which is checked in + stacktrace_stackframeinfo_end_check. */ + + if (prevsfi == NULL) { + tmpsfi->code = NULL; + tmpsfi->prev = NULL; + return; + } + + /* Fill the temporary stackframeinfo with the new values. */ + + stacktrace_stackframeinfo_fill(tmpsfi, prevsfi); + } + else { + /* Store the new values in the stackframeinfo. NOTE: We + subtract 1 from the RA to get the XPC, because the RA + points to the instruction after the call instruction. */ + + tmpsfi->code = code; + tmpsfi->pv = pv; + tmpsfi->sp = sp; + tmpsfi->ra = ra; + tmpsfi->xpc = (void *) (((intptr_t) ra) - 1); + } + +#if !defined(NDEBUG) + /* Print current method information. */ + + if (opt_DebugStackTrace) { + log_start(); + log_print("[stacktrace: method=%p, pv=%p, sp=%p, ra=%p, xpc=%p, method=", + tmpsfi->code->m, tmpsfi->pv, tmpsfi->sp, tmpsfi->ra, + tmpsfi->xpc); + method_print(tmpsfi->code->m); + log_print("]"); + log_finish(); + } +#endif +} + + +/* stacktrace_stackframeinfo_end_check ***************************************** + + Check if we reached the end of the stacktrace. + + IN: + tmpsfi ... temporary stackframeinfo of current method + + RETURN: + true .... the end is reached + false ... the end is not reached + +*******************************************************************************/ + +static inline bool stacktrace_stackframeinfo_end_check(stackframeinfo_t *tmpsfi) +{ + /* Sanity check. */ + + assert(tmpsfi != NULL); + + if ((tmpsfi->code == NULL) && (tmpsfi->prev == NULL)) { +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace stop]"); +#endif + + return true; + } + + return false; +} + + +/* stacktrace_depth ************************************************************ + + Calculates and returns the depth of the current stacktrace. + + IN: + sfi ... stackframeinfo where to start the stacktrace + + RETURN: + depth of the stacktrace + +*******************************************************************************/ + +static int stacktrace_depth(stackframeinfo_t *sfi) +{ + stackframeinfo_t tmpsfi; + int depth; + methodinfo *m; + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_depth]"); +#endif + + /* XXX This is not correct, but a workaround for threads-dump for + now. */ +/* assert(sfi != NULL); */ + if (sfi == NULL) + return 0; + + /* Iterate over all stackframes. */ + + depth = 0; + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get methodinfo. */ + + m = tmpsfi.code->m; + + /* Skip builtin methods. */ + + if (m->flags & ACC_METHOD_BUILTIN) + continue; + + depth++; + } + + return depth; +} + + +/* stacktrace_get ************************************************************** + + Builds and returns a stacktrace starting from the given stackframe + info and returns the stacktrace structure wrapped in a Java + byte-array to not confuse the GC. + + IN: + sfi ... stackframe info to start stacktrace from + + RETURN: + stacktrace as Java byte-array + +*******************************************************************************/ + +java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi) +{ + stackframeinfo_t tmpsfi; + int depth; + java_handle_bytearray_t *ba; + int32_t ba_size; + stacktrace_t *st; + stacktrace_entry_t *ste; + methodinfo *m; + bool skip_fillInStackTrace; + bool skip_init; + + CYCLES_STATS_DECLARE_AND_START_WITH_OVERHEAD + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_get]"); +#endif + + skip_fillInStackTrace = true; + skip_init = true; + + depth = stacktrace_depth(sfi); + + if (depth == 0) + return NULL; + + /* Allocate memory from the GC heap and copy the stacktrace + buffer. */ + /* ATTENTION: Use a Java byte-array for this to not confuse the + GC. */ + /* FIXME: We waste some memory here as we skip some entries + later. */ + + ba_size = sizeof(stacktrace_t) + sizeof(stacktrace_entry_t) * depth; + + ba = builtin_newarray_byte(ba_size); + + if (ba == NULL) + goto return_NULL; + + /* Get a stacktrace entry pointer. */ + /* ATTENTION: We need a critical section here because we use the + byte-array data pointer directly. */ + + LLNI_CRITICAL_START; + + st = (stacktrace_t *) LLNI_array_data(ba); + + ste = st->entries; + + /* Iterate over the whole stack. */ + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get the methodinfo. */ + + m = tmpsfi.code->m; + + /* Skip builtin methods. */ + + if (m->flags & ACC_METHOD_BUILTIN) + continue; + + /* This logic is taken from + hotspot/src/share/vm/classfile/javaClasses.cpp + (java_lang_Throwable::fill_in_stack_trace). */ + + if (skip_fillInStackTrace == true) { + /* Check "fillInStackTrace" only once, so we negate the + flag after the first time check. */ + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + /* For GNU Classpath we also need to skip + VMThrowable.fillInStackTrace(). */ + + if ((m->clazz == class_java_lang_VMThrowable) && + (m->name == utf_fillInStackTrace)) + continue; +#endif + + skip_fillInStackTrace = false; + + if (m->name == utf_fillInStackTrace) + continue; + } + + /* Skip methods of the exceptions klass. If there is + methods that belongs to a superclass of the + exception we are going to skipping them in stack trace. */ + + if (skip_init == true) { + if ((m->name == utf_init) && + (class_issubclass(m->clazz, class_java_lang_Throwable))) { + continue; + } + else { + /* If no "Throwable.init()" method found, we stop + checking it next time. */ + + skip_init = false; + } + } + + /* Store the stacktrace entry and increment the pointer. */ + + ste->code = tmpsfi.code; + ste->pc = tmpsfi.xpc; + + ste++; + } + + /* Store the number of entries in the stacktrace structure. */ + + st->length = ste - st->entries; + + LLNI_CRITICAL_END; + + /* release dump memory */ + +/* dump_release(dumpsize); */ + + CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace, + stacktrace_overhead) + return ba; + +return_NULL: +/* dump_release(dumpsize); */ + + CYCLES_STATS_END_WITH_OVERHEAD(stacktrace_fillInStackTrace, + stacktrace_overhead) + + return NULL; +} + + +/* stacktrace_get_current ****************************************************** + + Builds and returns a stacktrace from the current thread and returns + the stacktrace structure wrapped in a Java byte-array to not + confuse the GC. + + RETURN: + stacktrace as Java byte-array + +*******************************************************************************/ + +java_handle_bytearray_t *stacktrace_get_current(void) +{ + stackframeinfo_t *sfi; + java_handle_bytearray_t *ba; + + sfi = threads_get_current_stackframeinfo(); + ba = stacktrace_get(sfi); + + return ba; +} + + +/* stacktrace_get_caller_class ************************************************* + + Get the class on the stack at the given depth. This function skips + various special classes or methods. + + ARGUMENTS: + depth ... depth to get caller class of + + RETURN: + caller class + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +classinfo *stacktrace_get_caller_class(int depth) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + methodinfo *m; + classinfo *c; + int i; + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_get_caller_class]"); +#endif + + /* Get the stackframeinfo of the current thread. */ + + sfi = threads_get_current_stackframeinfo(); + + /* Iterate over the whole stack until we reached the requested + depth. */ + + i = 0; + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + + m = tmpsfi.code->m; + c = m->clazz; + + /* Skip builtin methods. */ + + if (m->flags & ACC_METHOD_BUILTIN) + continue; + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + /* NOTE: See hotspot/src/share/vm/runtime/vframe.cpp + (vframeStreamCommon::security_get_caller_frame). */ + + /* This is java.lang.reflect.Method.invoke(), skip it. */ + + if (m == method_java_lang_reflect_Method_invoke) + continue; + + /* This is an auxiliary frame, skip it. */ + + if (class_issubclass(c, class_sun_reflect_MagicAccessorImpl)) + continue; +#endif + + /* We reached the requested depth. */ + + if (i >= depth) + return c; + + i++; + } + + return NULL; +} +#endif + + +/* stacktrace_first_nonnull_classloader **************************************** + + Returns the first non-null (user-defined) classloader on the stack. + If none is found NULL is returned. + + RETURN: + classloader + +*******************************************************************************/ + +classloader_t *stacktrace_first_nonnull_classloader(void) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + methodinfo *m; + classloader_t *cl; + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_first_nonnull_classloader]"); +#endif + + /* Get the stackframeinfo of the current thread. */ + + sfi = threads_get_current_stackframeinfo(); + + /* Iterate over the whole stack. */ + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + + m = tmpsfi.code->m; + cl = class_get_classloader(m->clazz); + + if (cl != NULL) + return cl; + } + + return NULL; +} + + +/* stacktrace_getClassContext ************************************************** + + Creates a Class context array. + + RETURN VALUE: + the array of java.lang.Class objects, or + NULL if an exception has been thrown + +*******************************************************************************/ + +java_handle_objectarray_t *stacktrace_getClassContext(void) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + int depth; + java_handle_objectarray_t *oa; + java_object_t **data; + int i; + methodinfo *m; + + CYCLES_STATS_DECLARE_AND_START + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_getClassContext]"); +#endif + + sfi = threads_get_current_stackframeinfo(); + + /* Get the depth of the current stack. */ + + depth = stacktrace_depth(sfi); + + /* The first stackframe corresponds to the method whose + implementation calls this native function. We remove that + entry. */ + + depth--; + stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_next(&tmpsfi); + + /* Allocate the Class array. */ + + oa = builtin_anewarray(depth, class_java_lang_Class); + + if (oa == NULL) { + CYCLES_STATS_END(stacktrace_getClassContext); + + return NULL; + } + + /* Fill the Class array from the stacktrace list. */ + + LLNI_CRITICAL_START; + + data = LLNI_array_data(oa); + + /* Iterate over the whole stack. */ + + i = 0; + + for (; + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get methodinfo. */ + + m = tmpsfi.code->m; + + /* Skip builtin methods. */ + + if (m->flags & ACC_METHOD_BUILTIN) + continue; + + /* Store the class in the array. */ + + data[i] = (java_object_t *) m->clazz; + + i++; + } + + LLNI_CRITICAL_END; + + CYCLES_STATS_END(stacktrace_getClassContext) + + return oa; +} + + +/* stacktrace_getCurrentClass ************************************************** + + Find the current class by walking the stack trace. + + Quote from the JNI documentation: + + In the Java 2 Platform, FindClass locates the class loader + associated with the current native method. If the native code + belongs to a system class, no class loader will be + involved. Otherwise, the proper class loader will be invoked to + load and link the named class. When FindClass is called through the + Invocation Interface, there is no current native method or its + associated class loader. In that case, the result of + ClassLoader.getBaseClassLoader is used." + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +classinfo *stacktrace_get_current_class(void) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + methodinfo *m; + + CYCLES_STATS_DECLARE_AND_START; + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_get_current_class]"); +#endif + + /* Get the stackframeinfo of the current thread. */ + + sfi = threads_get_current_stackframeinfo(); + + /* If the stackframeinfo is NULL then FindClass is called through + the Invocation Interface and we return NULL */ + + if (sfi == NULL) { + CYCLES_STATS_END(stacktrace_getCurrentClass); + + return NULL; + } + + /* Iterate over the whole stack. */ + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get the methodinfo. */ + + m = tmpsfi.code->m; + + if (m->clazz == class_java_security_PrivilegedAction) { + CYCLES_STATS_END(stacktrace_getCurrentClass); + + return NULL; + } + + if (m->clazz != NULL) { + CYCLES_STATS_END(stacktrace_getCurrentClass); + + return m->clazz; + } + } + + /* No Java method found on the stack. */ + + CYCLES_STATS_END(stacktrace_getCurrentClass); + + return NULL; +} +#endif /* ENABLE_JAVASE */ + + +/* stacktrace_get_stack ******************************************************** + + Create a 2-dimensional array for java.security.VMAccessControler. + + RETURN VALUE: + the arrary, or + NULL if an exception has been thrown + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) && defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +java_handle_objectarray_t *stacktrace_get_stack(void) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + int depth; + java_handle_objectarray_t *oa; + java_handle_objectarray_t *classes; + java_handle_objectarray_t *methodnames; + methodinfo *m; + java_handle_t *string; + int i; + + CYCLES_STATS_DECLARE_AND_START + +#if !defined(NDEBUG) + if (opt_DebugStackTrace) + log_println("[stacktrace_get_stack]"); +#endif + + /* Get the stackframeinfo of the current thread. */ + + sfi = threads_get_current_stackframeinfo(); + + /* Get the depth of the current stack. */ + + depth = stacktrace_depth(sfi); + + if (depth == 0) + return NULL; + + /* Allocate the required arrays. */ + + oa = builtin_anewarray(2, arrayclass_java_lang_Object); + + if (oa == NULL) + goto return_NULL; + + classes = builtin_anewarray(depth, class_java_lang_Class); + + if (classes == NULL) + goto return_NULL; + + methodnames = builtin_anewarray(depth, class_java_lang_String); + + if (methodnames == NULL) + goto return_NULL; + + /* Set up the 2-dimensional array. */ + + array_objectarray_element_set(oa, 0, (java_handle_t *) classes); + array_objectarray_element_set(oa, 1, (java_handle_t *) methodnames); + + /* Iterate over the whole stack. */ + /* TODO We should use a critical section here to speed things + up. */ + + i = 0; + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get the methodinfo. */ + + m = tmpsfi.code->m; + + /* Skip builtin methods. */ + + if (m->flags & ACC_METHOD_BUILTIN) + continue; + + /* Store the class in the array. */ + /* NOTE: We use a LLNI-macro here, because a classinfo is not + a handle. */ + + LLNI_array_direct(classes, i) = (java_object_t *) m->clazz; + + /* Store the name in the array. */ + + string = javastring_new(m->name); + + if (string == NULL) + goto return_NULL; + + array_objectarray_element_set(methodnames, i, string); + + i++; + } + + CYCLES_STATS_END(stacktrace_get_stack) + + return oa; + +return_NULL: + CYCLES_STATS_END(stacktrace_get_stack) + + return NULL; +} +#endif + + +/* stacktrace_print_entry **************************************************** + + Print line for a stacktrace entry. + + ARGUMENTS: + m ............ methodinfo of the entry + linenumber ... linenumber of the entry + +*******************************************************************************/ + +static void stacktrace_print_entry(methodinfo *m, int32_t linenumber) +{ + /* Sanity check. */ + + assert(m != NULL); + + printf("\tat "); + + if (m->flags & ACC_METHOD_BUILTIN) + printf("NULL"); + else + utf_display_printable_ascii_classname(m->clazz->name); + + printf("."); + utf_display_printable_ascii(m->name); + utf_display_printable_ascii(m->descriptor); + + if (m->flags & ACC_NATIVE) { + puts("(Native Method)"); + } + else { + if (m->flags & ACC_METHOD_BUILTIN) { + puts("(builtin)"); + } + else { + printf("("); + utf_display_printable_ascii(m->clazz->sourcefile); + printf(":%d)\n", linenumber); + } + } + + fflush(stdout); +} + + +/* stacktrace_print ************************************************************ + + Print the given stacktrace with CACAO intern methods only (no Java + code required). + + This method is used by stacktrace_dump_trace and + builtin_trace_exception. + + IN: + st ... stacktrace to print + +*******************************************************************************/ + +void stacktrace_print(stacktrace_t *st) +{ + stacktrace_entry_t *ste; + methodinfo *m; + int32_t linenumber; + int i; + + ste = &(st->entries[0]); + + for (i = 0; i < st->length; i++, ste++) { + m = ste->code->m; + + /* Get the line number. */ + + linenumber = linenumbertable_linenumber_for_pc(&m, ste->code, ste->pc); + + stacktrace_print_entry(m, linenumber); + } +} + + +/* stacktrace_print_current **************************************************** + + Print the current stacktrace of the current thread. + + NOTE: This function prints all frames of the stacktrace and does + not skip frames like stacktrace_get. + +*******************************************************************************/ + +void stacktrace_print_current(void) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + codeinfo *code; + methodinfo *m; + int32_t linenumber; + + sfi = threads_get_current_stackframeinfo(); + + if (sfi == NULL) { + puts("\t<>"); + fflush(stdout); + return; + } + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get the methodinfo. */ + + code = tmpsfi.code; + m = code->m; + + /* Get the line number. */ + + linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc); + + stacktrace_print_entry(m, linenumber); + } +} + + +/* stacktrace_print_of_thread ************************************************** + + Print the current stacktrace of the given thread. + + ARGUMENTS: + t ... thread + +*******************************************************************************/ + +#if defined(ENABLE_THREADS) +void stacktrace_print_of_thread(threadobject *t) +{ + stackframeinfo_t *sfi; + stackframeinfo_t tmpsfi; + codeinfo *code; + methodinfo *m; + int32_t linenumber; + + /* Build a stacktrace for the passed thread. */ + + sfi = t->_stackframeinfo; + + if (sfi == NULL) { + puts("\t<>"); + fflush(stdout); + return; + } + + for (stacktrace_stackframeinfo_fill(&tmpsfi, sfi); + stacktrace_stackframeinfo_end_check(&tmpsfi) == false; + stacktrace_stackframeinfo_next(&tmpsfi)) { + /* Get the methodinfo. */ + + code = tmpsfi.code; + m = code->m; + + /* Get the line number. */ + + linenumber = linenumbertable_linenumber_for_pc(&m, code, tmpsfi.xpc); + + stacktrace_print_entry(m, linenumber); + } +} +#endif + + +/* stacktrace_print_exception ************************************************** + + Print the stacktrace of a given exception (more or less a wrapper + to stacktrace_print). + + IN: + h ... handle of exception to print + +*******************************************************************************/ + +void stacktrace_print_exception(java_handle_t *h) +{ + if (h == NULL) + return; + + java_lang_Throwable t(h); + + /* now print the stacktrace */ + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + java_lang_VMThrowable vmt(t.get_vmState()); + java_handle_bytearray_t* backtrace = vmt.get_vmdata(); + +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) || defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + java_handle_bytearray_t* backtrace = t.get_backtrace(); + +#else +# error unknown classpath configuration +#endif + + // Sanity check. + + assert(backtrace != NULL); + + /* We need a critical section here as we use the byte-array data + pointer directly. */ + + LLNI_CRITICAL_START; + + stacktrace_t* st = (stacktrace_t*) LLNI_array_data(backtrace); + + stacktrace_print(st); + + LLNI_CRITICAL_END; +} + + +#if defined(ENABLE_CYCLES_STATS) +void stacktrace_print_cycles_stats(FILE *file) +{ + CYCLES_STATS_PRINT_OVERHEAD(stacktrace_overhead, file); + CYCLES_STATS_PRINT(stacktrace_get, file); + CYCLES_STATS_PRINT(stacktrace_getClassContext , file); + CYCLES_STATS_PRINT(stacktrace_getCurrentClass , file); + CYCLES_STATS_PRINT(stacktrace_get_stack, file); +} +#endif + +} // extern "C" + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/stacktrace.h b/src/vm/jit/stacktrace.h deleted file mode 100644 index e21c348a1..000000000 --- a/src/vm/jit/stacktrace.h +++ /dev/null @@ -1,153 +0,0 @@ -/* src/vm/jit/stacktrace.h - header file for stacktrace generation - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _STACKTRACE_H -#define _STACKTRACE_H - -/* forward typedefs ***********************************************************/ - -typedef struct stackframeinfo_t stackframeinfo_t; -typedef struct stacktrace_entry_t stacktrace_entry_t; -typedef struct stacktrace_t stacktrace_t; - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "md-abi.h" - -#include "threads/thread.h" - -#include "vm/global.h" - -#include "vm/jit/code.h" - -#include "vmcore/class.h" - - -/* stackframeinfo ************************************************************** - - ATTENTION: Keep the number of elements of this structure even, to - make sure that the stack keeps aligned (e.g. 16-bytes for x86_64). - -*******************************************************************************/ - -struct stackframeinfo_t { - stackframeinfo_t *prev; /* pointer to prev stackframeinfo */ - codeinfo *code; /* codeinfo of current method */ - u1 *pv; /* PV of current function */ - u1 *sp; /* SP of parent Java function */ - u1 *ra; /* RA to parent Java function */ - u1 *xpc; /* XPC (for inline stubs) */ -#if defined(ENABLE_GC_CACAO) - /* - * The exact GC needs to be able to recover saved registers, so the - * native-stub saves these registers here - */ -# if defined(HAS_ADDRESS_REGISTER_FILE) - uintptr_t adrregs[ADR_SAV_CNT]; -# else - uintptr_t intregs[INT_SAV_CNT]; -# endif -#endif -}; - - -/* stacktrace_entry_t *********************************************************/ - -struct stacktrace_entry_t { - codeinfo *code; /* codeinfo pointer of this method */ - void *pc; /* PC in this method */ -}; - - -/* stacktrace_t ***************************************************************/ - -struct stacktrace_t { - int32_t length; /* length of the entries array */ - stacktrace_entry_t entries[1]; /* stacktrace entries */ -}; - - -/* function prototypes ********************************************************/ - -void stacktrace_stackframeinfo_add(stackframeinfo_t *sfi, u1 *pv, u1 *sp, u1 *ra, u1 *xpc); -void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi); - -java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi); -java_handle_bytearray_t *stacktrace_get_current(void); - -#if defined(ENABLE_JAVASE) -classinfo *stacktrace_get_caller_class(int depth); -classloader_t *stacktrace_first_nonnull_classloader(void); -java_handle_objectarray_t *stacktrace_getClassContext(void); -classinfo *stacktrace_get_current_class(void); -java_handle_objectarray_t *stacktrace_get_stack(void); -#endif - -void stacktrace_print(stacktrace_t *st); -void stacktrace_print_current(void); - -#if defined(ENABLE_THREADS) -void stacktrace_print_of_thread(threadobject *t); -#endif - -void stacktrace_print_exception(java_handle_t *h); - -/* machine dependent functions (code in ARCH_DIR/md.c) */ - -#if defined(ENABLE_JIT) -# if defined(__SPARC_64__) -u1 *md_get_framepointer(u1 *sp); -u1 *md_get_pv_from_stackframe(u1 *sp); -# endif -#endif - -#if defined(ENABLE_INTRP) -u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize); -#endif - -#if defined(ENABLE_CYCLES_STATS) -void stacktrace_print_cycles_stats(FILE *file); -#endif - -#endif /* _STACKTRACE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/stacktrace.hpp b/src/vm/jit/stacktrace.hpp new file mode 100644 index 000000000..d37064eda --- /dev/null +++ b/src/vm/jit/stacktrace.hpp @@ -0,0 +1,161 @@ +/* src/vm/jit/stacktrace.hpp - header file for stacktrace generation + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _STACKTRACE_HPP +#define _STACKTRACE_HPP + +/* forward typedefs ***********************************************************/ + +typedef struct stackframeinfo_t stackframeinfo_t; +typedef struct stacktrace_entry_t stacktrace_entry_t; +typedef struct stacktrace_t stacktrace_t; + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "md-abi.h" + +#include "threads/thread.hpp" + +#include "vm/class.h" +#include "vm/global.h" + +#include "vm/jit/code.hpp" + + +/* stackframeinfo ************************************************************** + + ATTENTION: Keep the number of elements of this structure even, to + make sure that the stack keeps aligned (e.g. 16-bytes for x86_64). + +*******************************************************************************/ + +struct stackframeinfo_t { + stackframeinfo_t *prev; /* pointer to prev stackframeinfo */ + codeinfo *code; /* codeinfo of current method */ + void *pv; /* PV of current function */ + void *sp; /* SP of parent Java function */ + void *ra; /* RA to parent Java function */ + void *xpc; /* XPC (for inline stubs) */ +#if defined(ENABLE_GC_CACAO) + /* + * The exact GC needs to be able to recover saved registers, so the + * native-stub saves these registers here + */ +# if defined(HAS_ADDRESS_REGISTER_FILE) + uintptr_t adrregs[ADR_SAV_CNT]; +# else + uintptr_t intregs[INT_SAV_CNT]; +# endif +#endif +}; + + +/* stacktrace_entry_t *********************************************************/ + +struct stacktrace_entry_t { + codeinfo *code; /* codeinfo pointer of this method */ + void *pc; /* PC in this method */ +}; + + +/* stacktrace_t ***************************************************************/ + +struct stacktrace_t { + int32_t length; /* length of the entries array */ + stacktrace_entry_t entries[1]; /* stacktrace entries */ +}; + + +/* function prototypes ********************************************************/ + +// FIXME Use C-linkage for now. +#ifdef __cplusplus +extern "C" { +#endif + +void stacktrace_stackframeinfo_add(stackframeinfo_t* sfi, void* pv, void* sp, void* ra, void* xpc); +void stacktrace_stackframeinfo_remove(stackframeinfo_t *sfi); + +java_handle_bytearray_t *stacktrace_get(stackframeinfo_t *sfi); +java_handle_bytearray_t *stacktrace_get_current(void); + +#if defined(ENABLE_JAVASE) +classinfo *stacktrace_get_caller_class(int depth); +classloader_t *stacktrace_first_nonnull_classloader(void); +java_handle_objectarray_t *stacktrace_getClassContext(void); +classinfo *stacktrace_get_current_class(void); +java_handle_objectarray_t *stacktrace_get_stack(void); +#endif + +void stacktrace_print(stacktrace_t *st); +void stacktrace_print_current(void); + +#if defined(ENABLE_THREADS) +void stacktrace_print_of_thread(threadobject *t); +#endif + +void stacktrace_print_exception(java_handle_t *h); + +/* machine dependent functions (code in ARCH_DIR/md.c) */ + +#if defined(ENABLE_JIT) +# if defined(__SPARC_64__) +u1 *md_get_framepointer(u1 *sp); +u1 *md_get_pv_from_stackframe(u1 *sp); +# endif +#endif + +#if defined(ENABLE_INTRP) +void* intrp_md_stacktrace_get_returnaddress(void* sp, int32_t framesize); +#endif + +#if defined(ENABLE_CYCLES_STATS) +void stacktrace_print_cycles_stats(FILE *file); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // _STACKTRACE_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/stubs.cpp b/src/vm/jit/stubs.cpp new file mode 100644 index 000000000..bc458af5c --- /dev/null +++ b/src/vm/jit/stubs.cpp @@ -0,0 +1,439 @@ +/* src/vm/jit/stubs.cpp - JIT stubs + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +// Include machine dependent headers. +#include "md.h" + +#include "mm/dumpmemory.hpp" + +#include "vm/method.h" +#include "vm/options.h" + +#include "vm/jit/abi.h" +#include "vm/jit/code.hpp" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/disass.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/show.h" +#include "vm/jit/stubs.hpp" + + +/** + * Wrapper for codegen_emit_stub_compiler. + * + * @param m Method object. + * + * @return Pointer to the compiler stub code. + */ +void* CompilerStub::generate(methodinfo *m) +{ + jitdata *jd; + codegendata *cd; + ptrint *d; /* pointer to data memory */ + u1 *c; /* pointer to code memory */ + + // Create new dump memory area. + DumpMemoryArea dma; + + /* allocate required data structures */ + + jd = (jitdata*) DumpMemory::allocate(sizeof(jitdata)); + + jd->m = m; + jd->cd = (codegendata*) DumpMemory::allocate(sizeof(codegendata)); + jd->flags = 0; + + /* get required compiler data */ + + cd = jd->cd; + +#if !defined(JIT_COMPILER_VIA_SIGNAL) + /* allocate code memory */ + + c = CNEW(u1, 3 * SIZEOF_VOID_P + get_code_size()); + + /* set pointers correctly */ + + d = (ptrint *) c; + + cd->mcodebase = c; + + c = c + 3 * SIZEOF_VOID_P; + cd->mcodeptr = c; + + /* NOTE: The codeinfo pointer is actually a pointer to the + methodinfo (this fakes a codeinfo structure). */ + + d[0] = (ptrint) asm_call_jit_compiler; + d[1] = (ptrint) m; + d[2] = (ptrint) &d[1]; /* fake code->m */ + + /* call the emit function */ + + codegen_emit_stub_compiler(jd); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_cstub_len += 3 * SIZEOF_VOID_P + get_code_size(); +#endif + + /* flush caches */ + + md_cacheflush(cd->mcodebase, 3 * SIZEOF_VOID_P + get_code_size()); +#else + /* Allocate code memory. */ + + c = CNEW(uint8_t, 2 * SIZEOF_VOID_P + get_code_size()); + + /* Set pointers correctly. */ + + d = (ptrint *) c; + + cd->mcodebase = c; + + c = c + 2 * SIZEOF_VOID_P; + cd->mcodeptr = c; + + /* NOTE: The codeinfo pointer is actually a pointer to the + methodinfo (this fakes a codeinfo structure). */ + + d[0] = (ptrint) m; + d[1] = (ptrint) &d[0]; /* fake code->m */ + + /* Emit the trap instruction. */ + + emit_trap_compiler(cd); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_cstub_len += 2 * SIZEOF_VOID_P + get_code_size(); +#endif + + /* Flush caches. */ + + md_cacheflush(cd->mcodebase, 2 * SIZEOF_VOID_P + get_code_size()); +#endif + + /* return native stub code */ + + return c; +} + + +/** + * Free a compiler stub from memory. + * + * @param + */ +void CompilerStub::remove(void* stub) +{ + // Pass size 1 to keep the intern function happy. + CFREE(stub, 1); +} + + +/* codegen_disassemble_nativestub ********************************************** + + Disassembles the generated builtin or native stub. + +*******************************************************************************/ + +#if defined(ENABLE_DISASSEMBLER) +static void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end) +{ + printf("Stub code: "); + if (m->clazz != NULL) + utf_fprint_printable_ascii_classname(stdout, m->clazz->name); + else + printf("NULL"); + printf("."); + utf_fprint_printable_ascii(stdout, m->name); + utf_fprint_printable_ascii(stdout, m->descriptor); + printf("\nLength: %d\n\n", (s4) (end - start)); + + DISASSEMBLE(start, end); +} +#endif + + +/** + * Wrapper for codegen_emit_stub_native. + * + * @param m Method object. + * @param bte Builtin function structure. + */ +void BuiltinStub::generate(methodinfo* m, builtintable_entry* bte) +{ + jitdata *jd; + codeinfo *code; + int skipparams; + + // Create new dump memory area. + DumpMemoryArea dma; + + /* Create JIT data structure. */ + + jd = jit_jitdata_new(m); + + /* Get required compiler data. */ + + code = jd->code; + + /* Stubs are non-leaf methods. */ + + code_unflag_leafmethod(code); + + /* setup code generation stuff */ + + codegen_setup(jd); + + /* Set the number of native arguments we need to skip. */ + + skipparams = 0; + + /* generate the code */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) { +# endif + assert(bte->fp != NULL); + codegen_emit_stub_native(jd, bte->md, bte->fp, skipparams); +# if defined(ENABLE_INTRP) + } +# endif +#endif + + /* reallocate the memory and finish the code generation */ + + codegen_finish(jd); + + /* set the stub entry point in the builtin table */ + + bte->stub = code->entrypoint; + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_stub_native += code->mcodelength; +#endif + +#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) + /* disassemble native stub */ + + if (opt_DisassembleStubs) { + codegen_disassemble_stub(m, + (u1 *) (ptrint) code->entrypoint, + (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen)); + + /* show data segment */ + + if (opt_showddatasegment) + dseg_display(jd); + } +#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */ +} + + +/** + * Wrapper for codegen_emit_stub_native. + * + * @param m Method object of the native function. + * @param f Native function pointer. + * + * @return The codeinfo representing the stub code. + */ +codeinfo* NativeStub::generate(methodinfo* m, functionptr f) +{ + jitdata *jd; + codeinfo *code; + methoddesc *md; + methoddesc *nmd; + int skipparams; + + // Create new dump memory area. + DumpMemoryArea dma; + + /* Create JIT data structure. */ + + jd = jit_jitdata_new(m); + + /* Get required compiler data. */ + + code = jd->code; + + /* Stubs are non-leaf methods. */ + + code_unflag_leafmethod(code); + + /* set the flags for the current JIT run */ + +#if defined(ENABLE_PROFILING) + if (opt_prof) + jd->flags |= JITDATA_FLAG_INSTRUMENT; +#endif + + if (opt_verbosecall) + jd->flags |= JITDATA_FLAG_VERBOSECALL; + + /* setup code generation stuff */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) +# endif + reg_setup(jd); +#endif + + codegen_setup(jd); + + /* create new method descriptor with additional native parameters */ + + md = m->parseddesc; + + /* Set the number of native arguments we need to skip. */ + + if (m->flags & ACC_STATIC) + skipparams = 2; + else + skipparams = 1; + + nmd = (methoddesc*) DumpMemory::allocate(sizeof(methoddesc) - sizeof(typedesc) + + md->paramcount * sizeof(typedesc) + + skipparams * sizeof(typedesc)); + + nmd->paramcount = md->paramcount + skipparams; + + nmd->params = (paramdesc*) DumpMemory::allocate(sizeof(paramdesc) * nmd->paramcount); + + nmd->paramtypes[0].type = TYPE_ADR; /* add environment pointer */ + + if (m->flags & ACC_STATIC) + nmd->paramtypes[1].type = TYPE_ADR; /* add class pointer */ + + MCOPY(nmd->paramtypes + skipparams, md->paramtypes, typedesc, + md->paramcount); + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (!opt_intrp) +# endif + /* pre-allocate the arguments for the native ABI */ + + md_param_alloc_native(nmd); +#endif + + /* generate the code */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) + intrp_createnativestub(f, jd, nmd); + else +# endif + codegen_emit_stub_native(jd, nmd, f, skipparams); +#else + intrp_createnativestub(f, jd, nmd); +#endif + + /* reallocate the memory and finish the code generation */ + + codegen_finish(jd); + +#if defined(ENABLE_STATISTICS) + /* must be done after codegen_finish() */ + + if (opt_stat) + size_stub_native += code->mcodelength; +#endif + +#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) + /* disassemble native stub */ + + if (opt_DisassembleStubs) { +# if defined(ENABLE_DEBUG_FILTER) + if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD) +# endif + { + codegen_disassemble_stub(m, + (u1 *) (ptrint) code->entrypoint, + (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen)); + + /* show data segment */ + + if (opt_showddatasegment) + dseg_display(jd); + } + } +#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */ + + /* return native stub code */ + + return code; +} + + +/** + * Free a native stub from memory. + * + * @param stub Pointer to stub memory. + */ +void NativeStub::remove(void* stub) +{ + // Pass size 1 to keep the intern function happy. + CFREE(stub, 1); +} + + +// Legacy C interface. + +extern "C" { + void* CompilerStub_generate(methodinfo* m) { return CompilerStub::generate(m); } + void CompilerStub_remove(void* stub) { CompilerStub::remove(stub); } + + void BuiltinStub_generate(methodinfo* m, builtintable_entry* bte) { BuiltinStub::generate(m, bte); } + + void NativeStub_remove(void* stub) { NativeStub::remove(stub); } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/stubs.hpp b/src/vm/jit/stubs.hpp new file mode 100644 index 000000000..ac4041f39 --- /dev/null +++ b/src/vm/jit/stubs.hpp @@ -0,0 +1,99 @@ +/* src/vm/jit/stubs.hpp - JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _STUBS_HPP +#define _STUBS_HPP + +#include "config.h" + +#include + +#include "vm/method.h" + +#include "vm/jit/code.hpp" + + +#ifdef __cplusplus + +/** + * Class for compiler stub generation. + */ +class CompilerStub { +public: + static inline int get_code_size(); + + static void* generate(methodinfo* m); + static void remove(void* stub); +}; + + +/** + * Class for builtin stub generation. + */ +class BuiltinStub { +public: + static void generate(methodinfo* m, builtintable_entry* bte); +}; + + +/** + * Class for native stub generation. + */ +class NativeStub { +public: + static codeinfo* generate(methodinfo* m, functionptr f); + static void remove(void* stub); +}; + + +// Include machine dependent implementation. +#include "md-stubs.hpp" + +#else + +// Legacy C interface. + +void* CompilerStub_generate(methodinfo* m); +void* CompilerStub_remove(void* stub); +void BuiltinStub_generate(methodinfo* m, builtintable_entry* bte); +void NativeStub_remove(void* stub); + +#endif + +#endif // _STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/trace.c b/src/vm/jit/trace.c deleted file mode 100644 index ba7599937..000000000 --- a/src/vm/jit/trace.c +++ /dev/null @@ -1,643 +0,0 @@ -/* src/vm/jit/trace.c - Functions for tracing from java code. - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -#include "config.h" - -#include - -#include "arch.h" -#include "md-abi.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" - -#include "native/include/java_lang_String.h" -#include "native/include/java_lang_Throwable.h" - -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/global.h" -#include "vm/stringlocal.h" -#include "vm/jit/argument.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/trace.h" -#include "vm/jit/show.h" - -#include "vmcore/options.h" -#include "vmcore/utf8.h" - - -#if !defined(NDEBUG) - - -/* global variables ***********************************************************/ - -#if !defined(ENABLE_THREADS) -s4 _no_threads_tracejavacallindent = 0; -u4 _no_threads_tracejavacallcount= 0; -#endif - - -/* trace_java_call_print_argument ********************************************** - - XXX: Document me! - -*******************************************************************************/ - -static char *trace_java_call_print_argument(methodinfo *m, char *logtext, s4 *logtextlen, typedesc *paramtype, imm_union imu) -{ - java_object_t *o; - classinfo *c; - utf *u; - u4 len; - - switch (paramtype->type) { - case TYPE_INT: - sprintf(logtext + strlen(logtext), "%d (0x%08x)", (int32_t)imu.l, (int32_t)imu.l); - break; - - case TYPE_LNG: -#if SIZEOF_VOID_P == 4 - sprintf(logtext + strlen(logtext), "%lld (0x%016llx)", imu.l, imu.l); -#else - sprintf(logtext + strlen(logtext), "%ld (0x%016lx)", imu.l, imu.l); -#endif - break; - - case TYPE_FLT: - sprintf(logtext + strlen(logtext), "%g (0x%08x)", imu.f, imu.i); - break; - - case TYPE_DBL: -#if SIZEOF_VOID_P == 4 - sprintf(logtext + strlen(logtext), "%g (0x%016llx)", imu.d, imu.l); -#else - sprintf(logtext + strlen(logtext), "%g (0x%016lx)", imu.d, imu.l); -#endif - break; - - case TYPE_ADR: -#if SIZEOF_VOID_P == 4 - sprintf(logtext + strlen(logtext), "0x%08x", (ptrint) imu.l); -#else - sprintf(logtext + strlen(logtext), "0x%016lx", (ptrint) imu.l); -#endif - - /* Workaround for sun.misc.Unsafe methods. In the future - (exact GC) we should check if the address is on the GC - heap. */ - - if ((m->clazz != NULL) && - (m->clazz->name == utf_new_char("sun/misc/Unsafe"))) - break; - - /* Cast to java.lang.Object. */ - - o = (java_object_t *) (ptrint) imu.l; - - /* Check return argument for java.lang.Class or - java.lang.String. */ - - if (o != NULL) { - if (o->vftbl->clazz == class_java_lang_String) { - /* get java.lang.String object and the length of the - string */ - - u = javastring_toutf(o, false); - - len = strlen(" (String = \"") + utf_bytes(u) + strlen("\")"); - - /* realloc memory for string length */ - - logtext = DMREALLOC(logtext, char, *logtextlen, *logtextlen + len); - *logtextlen += len; - - /* convert to utf8 string and strcat it to the logtext */ - - strcat(logtext, " (String = \""); - utf_cat(logtext, u); - strcat(logtext, "\")"); - } - else { - if (o->vftbl->clazz == class_java_lang_Class) { - /* if the object returned is a java.lang.Class - cast it to classinfo structure and get the name - of the class */ - - c = (classinfo *) o; - - u = c->name; - } - else { - /* if the object returned is not a java.lang.String or - a java.lang.Class just print the name of the class */ - - u = o->vftbl->clazz->name; - } - - len = strlen(" (Class = \"") + utf_bytes(u) + strlen("\")"); - - /* realloc memory for string length */ - - logtext = DMREALLOC(logtext, char, *logtextlen, *logtextlen + len); - *logtextlen += len; - - /* strcat to the logtext */ - - strcat(logtext, " (Class = \""); - utf_cat_classname(logtext, u); - strcat(logtext, "\")"); - } - } - } - - return logtext; -} - -/* trace_java_call_enter ****************************************************** - - Traces an entry into a java method. - - arg_regs: Array containing all argument registers as int64_t values in - the same order as listed in m->methoddesc. The array is usually allocated - on the stack and used for restoring the argument registers later. - - stack: Pointer to first on stack argument in the same format passed to - asm_vm_call_method. - -*******************************************************************************/ - -void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack) -{ - methoddesc *md; - imm_union arg; - char *logtext; - s4 logtextlen; - s4 i; - s4 pos; - int32_t dumpmarker; - - /* We don't trace builtin functions here because the argument - passing happens via the native ABI and does not fit these - functions. */ - - if (method_is_builtin(m)) - return; - -#if defined(ENABLE_DEBUG_FILTER) - if (!show_filters_test_verbosecall_enter(m)) - return; -#endif - -#if defined(ENABLE_VMLOG) - vmlog_cacao_enter_method(m); - return; -#endif - - md = m->parseddesc; - - /* calculate message length */ - - logtextlen = - strlen("4294967295 ") + - strlen("-2147483647-") + /* INT_MAX should be sufficient */ - TRACEJAVACALLINDENT + - strlen("called: ") + - ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) + - strlen(".") + - utf_bytes(m->name) + - utf_bytes(m->descriptor); - - /* Actually it's not possible to have all flags printed, but: - safety first! */ - - logtextlen += - strlen(" PUBLIC") + - strlen(" PRIVATE") + - strlen(" PROTECTED") + - strlen(" STATIC") + - strlen(" FINAL") + - strlen(" SYNCHRONIZED") + - strlen(" VOLATILE") + - strlen(" TRANSIENT") + - strlen(" NATIVE") + - strlen(" INTERFACE") + - strlen(" ABSTRACT") + - strlen(" METHOD_BUILTIN"); - - /* add maximal argument length */ - - logtextlen += - strlen("(") + - strlen("-9223372036854775808 (0x123456789abcdef0), ") * md->paramcount + - strlen("...(255)") + - strlen(")"); - - /* allocate memory */ - - DMARKER; - - logtext = DMNEW(char, logtextlen); - - TRACEJAVACALLCOUNT++; - - sprintf(logtext, "%10d ", TRACEJAVACALLCOUNT); - sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT); - - pos = strlen(logtext); - - for (i = 0; i < TRACEJAVACALLINDENT; i++) - logtext[pos++] = '\t'; - - strcpy(logtext + pos, "called: "); - - if (m->clazz != NULL) - utf_cat_classname(logtext, m->clazz->name); - else - strcat(logtext, "NULL"); - strcat(logtext, "."); - utf_cat(logtext, m->name); - utf_cat(logtext, m->descriptor); - - if (m->flags & ACC_PUBLIC) strcat(logtext, " PUBLIC"); - if (m->flags & ACC_PRIVATE) strcat(logtext, " PRIVATE"); - if (m->flags & ACC_PROTECTED) strcat(logtext, " PROTECTED"); - if (m->flags & ACC_STATIC) strcat(logtext, " STATIC"); - if (m->flags & ACC_FINAL) strcat(logtext, " FINAL"); - if (m->flags & ACC_SYNCHRONIZED) strcat(logtext, " SYNCHRONIZED"); - if (m->flags & ACC_VOLATILE) strcat(logtext, " VOLATILE"); - if (m->flags & ACC_TRANSIENT) strcat(logtext, " TRANSIENT"); - if (m->flags & ACC_NATIVE) strcat(logtext, " NATIVE"); - if (m->flags & ACC_INTERFACE) strcat(logtext, " INTERFACE"); - if (m->flags & ACC_ABSTRACT) strcat(logtext, " ABSTRACT"); - - strcat(logtext, "("); - - for (i = 0; i < md->paramcount; ++i) { - arg = argument_jitarray_load(md, i, arg_regs, stack); - logtext = trace_java_call_print_argument(m, logtext, &logtextlen, - &md->paramtypes[i], arg); - if (i != (md->paramcount - 1)) { - strcat(logtext, ", "); - } - } - - strcat(logtext, ")"); - - log_text(logtext); - - /* release memory */ - - DRELEASE; - - TRACEJAVACALLINDENT++; - -} - -/* trace_java_call_exit ******************************************************** - - Traces an exit form a java method. - - return_regs: Array of size 1 containing return register. - The array is usually allocated on the stack and used for restoring the - registers later. - -*******************************************************************************/ - -void trace_java_call_exit(methodinfo *m, uint64_t *return_regs) -{ - methoddesc *md; - char *logtext; - s4 logtextlen; - s4 i; - s4 pos; - imm_union val; - int32_t dumpmarker; - - /* We don't trace builtin functions here because the argument - passing happens via the native ABI and does not fit these - functions. */ - - if (method_is_builtin(m)) - return; - -#if defined(ENABLE_DEBUG_FILTER) - if (!show_filters_test_verbosecall_exit(m)) - return; -#endif - -#if defined(ENABLE_VMLOG) - vmlog_cacao_leave_method(m); - return; -#endif - - md = m->parseddesc; - - /* outdent the log message */ - - if (TRACEJAVACALLINDENT) - TRACEJAVACALLINDENT--; - else - log_text("trace_java_call_exit: WARNING: unmatched unindent"); - - /* calculate message length */ - - logtextlen = - strlen("4294967295 ") + - strlen("-2147483647-") + /* INT_MAX should be sufficient */ - TRACEJAVACALLINDENT + - strlen("finished: ") + - ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) + - strlen(".") + - utf_bytes(m->name) + - utf_bytes(m->descriptor) + - strlen(" SYNCHRONIZED") + strlen("(") + strlen(")"); - - /* add maximal argument length */ - - logtextlen += strlen("->0.4872328470301428 (0x0123456789abcdef)"); - - /* allocate memory */ - - DMARKER; - - logtext = DMNEW(char, logtextlen); - - /* generate the message */ - - sprintf(logtext, " "); - sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT); - - pos = strlen(logtext); - - for (i = 0; i < TRACEJAVACALLINDENT; i++) - logtext[pos++] = '\t'; - - strcpy(logtext + pos, "finished: "); - if (m->clazz != NULL) - utf_cat_classname(logtext, m->clazz->name); - else - strcat(logtext, "NULL"); - strcat(logtext, "."); - utf_cat(logtext, m->name); - utf_cat(logtext, m->descriptor); - - if (!IS_VOID_TYPE(md->returntype.type)) { - strcat(logtext, "->"); - val = argument_jitreturn_load(md, return_regs); - - logtext = - trace_java_call_print_argument(m, logtext, &logtextlen, - &md->returntype, val); - } - - log_text(logtext); - - /* release memory */ - - DRELEASE; -} - - -/* trace_exception ************************************************************* - - Traces an exception which is handled by exceptions_handle_exception. - -*******************************************************************************/ - -void trace_exception(java_object_t *xptr, methodinfo *m, void *pos) -{ - char *logtext; - s4 logtextlen; - codeinfo *code; - int32_t dumpmarker; - - /* calculate message length */ - - if (xptr) { - logtextlen = - strlen("Exception ") + utf_bytes(xptr->vftbl->clazz->name); - } - else { - logtextlen = strlen("Some Throwable"); - } - - logtextlen += strlen(" thrown in "); - - if (m) { - logtextlen += - utf_bytes(m->clazz->name) + - strlen(".") + - utf_bytes(m->name) + - utf_bytes(m->descriptor) + - strlen("(NOSYNC,NATIVE"); - -#if SIZEOF_VOID_P == 8 - logtextlen += - strlen(")(0x123456789abcdef0) at position 0x123456789abcdef0 ("); -#else - logtextlen += strlen(")(0x12345678) at position 0x12345678 ("); -#endif - - if (m->clazz->sourcefile == NULL) - logtextlen += strlen(""); - else - logtextlen += utf_bytes(m->clazz->sourcefile); - - logtextlen += strlen(":65536)"); - - } - else { - logtextlen += strlen("call_java_method"); - } - - logtextlen += strlen("0"); - - /* allocate memory */ - - DMARKER; - - logtext = DMNEW(char, logtextlen); - - if (xptr) { - strcpy(logtext, "Exception "); - utf_cat_classname(logtext, xptr->vftbl->clazz->name); - - } else { - strcpy(logtext, "Some Throwable"); - } - - strcat(logtext, " thrown in "); - - if (m) { - utf_cat_classname(logtext, m->clazz->name); - strcat(logtext, "."); - utf_cat(logtext, m->name); - utf_cat(logtext, m->descriptor); - - if (m->flags & ACC_SYNCHRONIZED) - strcat(logtext, "(SYNC"); - else - strcat(logtext, "(NOSYNC"); - - if (m->flags & ACC_NATIVE) { - strcat(logtext, ",NATIVE"); - - code = m->code; - -#if SIZEOF_VOID_P == 8 - sprintf(logtext + strlen(logtext), - ")(0x%016lx) at position 0x%016lx", - (ptrint) code->entrypoint, (ptrint) pos); -#else - sprintf(logtext + strlen(logtext), - ")(0x%08x) at position 0x%08x", - (ptrint) code->entrypoint, (ptrint) pos); -#endif - - } else { - - /* XXX preliminary: This should get the actual codeinfo */ - /* in which the exception happened. */ - code = m->code; - -#if SIZEOF_VOID_P == 8 - sprintf(logtext + strlen(logtext), - ")(0x%016lx) at position 0x%016lx (", - (ptrint) code->entrypoint, (ptrint) pos); -#else - sprintf(logtext + strlen(logtext), - ")(0x%08x) at position 0x%08x (", - (ptrint) code->entrypoint, (ptrint) pos); -#endif - - if (m->clazz->sourcefile == NULL) - strcat(logtext, ""); - else - utf_cat(logtext, m->clazz->sourcefile); - - sprintf(logtext + strlen(logtext), ":%d)", 0); - } - - } else - strcat(logtext, "call_java_method"); - - log_text(logtext); - - /* release memory */ - - DRELEASE; -} - - -/* trace_exception_builtin ***************************************************** - - Traces an exception which is thrown by builtin_throw_exception. - -*******************************************************************************/ - -void trace_exception_builtin(java_object_t *xptr) -{ - java_lang_Throwable *t; - java_lang_String *s; - char *logtext; - s4 logtextlen; - int32_t dumpmarker; - - t = (java_lang_Throwable *) xptr; - - /* get detail message */ - if (t) - LLNI_field_get_ref(t, detailMessage, s); - - /* calculate message length */ - - logtextlen = strlen("Builtin exception thrown: ") + strlen("0"); - - if (t) { - logtextlen += - utf_bytes(xptr->vftbl->clazz->name); - if (s) { - logtextlen += strlen(": ") + - u2_utflength(LLNI_field_direct(s, value)->data - + LLNI_field_direct(s, offset), - LLNI_field_direct(s,count)); - } - } - else { - logtextlen += strlen("(nil)"); - } - - /* allocate memory */ - - DMARKER; - - logtext = DMNEW(char, logtextlen); - - strcpy(logtext, "Builtin exception thrown: "); - - if (t) { - utf_cat_classname(logtext, xptr->vftbl->clazz->name); - - if (s) { - char *buf; - - buf = javastring_tochar((java_handle_t *) s); - strcat(logtext, ": "); - strcat(logtext, buf); - MFREE(buf, char, strlen(buf) + 1); - } - - } else { - strcat(logtext, "(nil)"); - } - - log_text(logtext); - - /* release memory */ - - DRELEASE; -} - - -#endif /* !defined(NDEBUG) */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/trace.cpp b/src/vm/jit/trace.cpp new file mode 100644 index 000000000..e3b735b54 --- /dev/null +++ b/src/vm/jit/trace.cpp @@ -0,0 +1,624 @@ +/* src/vm/jit/trace.cpp - Functions for tracing from java code. + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "arch.h" +#include "md-abi.h" + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/options.h" +#include "vm/string.hpp" +#include "vm/utf8.h" + +#include "vm/jit/argument.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/trace.hpp" +#include "vm/jit/show.h" + + +#if !defined(NDEBUG) + +// FIXME For now we export everything as C functions. +extern "C" { + +/* global variables ***********************************************************/ + +#if !defined(ENABLE_THREADS) +s4 _no_threads_tracejavacallindent = 0; +u4 _no_threads_tracejavacallcount= 0; +#endif + + +/* trace_java_call_print_argument ********************************************** + + XXX: Document me! + +*******************************************************************************/ + +static char *trace_java_call_print_argument(methodinfo *m, char *logtext, s4 *logtextlen, typedesc *paramtype, imm_union imu) +{ + java_object_t *o; + classinfo *c; + utf *u; + u4 len; + + switch (paramtype->type) { + case TYPE_INT: + sprintf(logtext + strlen(logtext), "%d (0x%08x)", (int32_t)imu.l, (int32_t)imu.l); + break; + + case TYPE_LNG: +#if SIZEOF_VOID_P == 4 + sprintf(logtext + strlen(logtext), "%lld (0x%016llx)", imu.l, imu.l); +#else + sprintf(logtext + strlen(logtext), "%ld (0x%016lx)", imu.l, imu.l); +#endif + break; + + case TYPE_FLT: + sprintf(logtext + strlen(logtext), "%g (0x%08x)", imu.f, imu.i); + break; + + case TYPE_DBL: +#if SIZEOF_VOID_P == 4 + sprintf(logtext + strlen(logtext), "%g (0x%016llx)", imu.d, imu.l); +#else + sprintf(logtext + strlen(logtext), "%g (0x%016lx)", imu.d, imu.l); +#endif + break; + + case TYPE_ADR: +#if SIZEOF_VOID_P == 4 + sprintf(logtext + strlen(logtext), "0x%08x", (ptrint) imu.l); +#else + sprintf(logtext + strlen(logtext), "0x%016lx", (ptrint) imu.l); +#endif + + /* Workaround for sun.misc.Unsafe methods. In the future + (exact GC) we should check if the address is on the GC + heap. */ + + if ((m->clazz != NULL) && + (m->clazz->name == utf_new_char("sun/misc/Unsafe"))) + break; + + /* Cast to java.lang.Object. */ + + o = (java_handle_t*) (uintptr_t) imu.l; + + /* Check return argument for java.lang.Class or + java.lang.String. */ + + if (o != NULL) { + if (o->vftbl->clazz == class_java_lang_String) { + /* get java.lang.String object and the length of the + string */ + + u = javastring_toutf(o, false); + + len = strlen(" (String = \"") + utf_bytes(u) + strlen("\")"); + + /* realloc memory for string length */ + + logtext = (char*) DumpMemory::reallocate(logtext, *logtextlen, *logtextlen + len); + *logtextlen += len; + + /* convert to utf8 string and strcat it to the logtext */ + + strcat(logtext, " (String = \""); + utf_cat(logtext, u); + strcat(logtext, "\")"); + } + else { + if (o->vftbl->clazz == class_java_lang_Class) { + /* if the object returned is a java.lang.Class + cast it to classinfo structure and get the name + of the class */ + + c = (classinfo *) o; + + u = c->name; + } + else { + /* if the object returned is not a java.lang.String or + a java.lang.Class just print the name of the class */ + + u = o->vftbl->clazz->name; + } + + len = strlen(" (Class = \"") + utf_bytes(u) + strlen("\")"); + + /* realloc memory for string length */ + + logtext = (char*) DumpMemory::reallocate(logtext, *logtextlen, *logtextlen + len); + *logtextlen += len; + + /* strcat to the logtext */ + + strcat(logtext, " (Class = \""); + utf_cat_classname(logtext, u); + strcat(logtext, "\")"); + } + } + } + + return logtext; +} + +/* trace_java_call_enter ****************************************************** + + Traces an entry into a java method. + + arg_regs: Array containing all argument registers as int64_t values in + the same order as listed in m->methoddesc. The array is usually allocated + on the stack and used for restoring the argument registers later. + + stack: Pointer to first on stack argument in the same format passed to + asm_vm_call_method. + +*******************************************************************************/ + +void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack) +{ + methoddesc *md; + imm_union arg; + char *logtext; + s4 logtextlen; + s4 i; + s4 pos; + + /* We don't trace builtin functions here because the argument + passing happens via the native ABI and does not fit these + functions. */ + + if (method_is_builtin(m)) + return; + +#if defined(ENABLE_DEBUG_FILTER) + if (!show_filters_test_verbosecall_enter(m)) + return; +#endif + +#if defined(ENABLE_VMLOG) + vmlog_cacao_enter_method(m); + return; +#endif + + md = m->parseddesc; + + /* calculate message length */ + + logtextlen = + strlen("4294967295 ") + + strlen("-2147483647-") + /* INT_MAX should be sufficient */ + TRACEJAVACALLINDENT + + strlen("called: ") + + ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) + + strlen(".") + + utf_bytes(m->name) + + utf_bytes(m->descriptor); + + /* Actually it's not possible to have all flags printed, but: + safety first! */ + + logtextlen += + strlen(" PUBLIC") + + strlen(" PRIVATE") + + strlen(" PROTECTED") + + strlen(" STATIC") + + strlen(" FINAL") + + strlen(" SYNCHRONIZED") + + strlen(" VOLATILE") + + strlen(" TRANSIENT") + + strlen(" NATIVE") + + strlen(" INTERFACE") + + strlen(" ABSTRACT") + + strlen(" METHOD_BUILTIN"); + + /* add maximal argument length */ + + logtextlen += + strlen("(") + + strlen("-9223372036854775808 (0x123456789abcdef0), ") * md->paramcount + + strlen("...(255)") + + strlen(")"); + + // Create new dump memory area. + DumpMemoryArea dma; + + // TODO Use a std::string here. + logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen); + + TRACEJAVACALLCOUNT++; + + sprintf(logtext, "%10d ", TRACEJAVACALLCOUNT); + sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT); + + pos = strlen(logtext); + + for (i = 0; i < TRACEJAVACALLINDENT; i++) + logtext[pos++] = '\t'; + + strcpy(logtext + pos, "called: "); + + if (m->clazz != NULL) + utf_cat_classname(logtext, m->clazz->name); + else + strcat(logtext, "NULL"); + strcat(logtext, "."); + utf_cat(logtext, m->name); + utf_cat(logtext, m->descriptor); + + if (m->flags & ACC_PUBLIC) strcat(logtext, " PUBLIC"); + if (m->flags & ACC_PRIVATE) strcat(logtext, " PRIVATE"); + if (m->flags & ACC_PROTECTED) strcat(logtext, " PROTECTED"); + if (m->flags & ACC_STATIC) strcat(logtext, " STATIC"); + if (m->flags & ACC_FINAL) strcat(logtext, " FINAL"); + if (m->flags & ACC_SYNCHRONIZED) strcat(logtext, " SYNCHRONIZED"); + if (m->flags & ACC_VOLATILE) strcat(logtext, " VOLATILE"); + if (m->flags & ACC_TRANSIENT) strcat(logtext, " TRANSIENT"); + if (m->flags & ACC_NATIVE) strcat(logtext, " NATIVE"); + if (m->flags & ACC_INTERFACE) strcat(logtext, " INTERFACE"); + if (m->flags & ACC_ABSTRACT) strcat(logtext, " ABSTRACT"); + + strcat(logtext, "("); + + for (i = 0; i < md->paramcount; ++i) { + arg = argument_jitarray_load(md, i, arg_regs, stack); + logtext = trace_java_call_print_argument(m, logtext, &logtextlen, + &md->paramtypes[i], arg); + if (i != (md->paramcount - 1)) { + strcat(logtext, ", "); + } + } + + strcat(logtext, ")"); + + log_text(logtext); + + TRACEJAVACALLINDENT++; +} + +/* trace_java_call_exit ******************************************************** + + Traces an exit form a java method. + + return_regs: Array of size 1 containing return register. + The array is usually allocated on the stack and used for restoring the + registers later. + +*******************************************************************************/ + +void trace_java_call_exit(methodinfo *m, uint64_t *return_regs) +{ + methoddesc *md; + char *logtext; + s4 logtextlen; + s4 i; + s4 pos; + imm_union val; + + /* We don't trace builtin functions here because the argument + passing happens via the native ABI and does not fit these + functions. */ + + if (method_is_builtin(m)) + return; + +#if defined(ENABLE_DEBUG_FILTER) + if (!show_filters_test_verbosecall_exit(m)) + return; +#endif + +#if defined(ENABLE_VMLOG) + vmlog_cacao_leave_method(m); + return; +#endif + + md = m->parseddesc; + + /* outdent the log message */ + + if (TRACEJAVACALLINDENT) + TRACEJAVACALLINDENT--; + else + log_text("trace_java_call_exit: WARNING: unmatched unindent"); + + /* calculate message length */ + + logtextlen = + strlen("4294967295 ") + + strlen("-2147483647-") + /* INT_MAX should be sufficient */ + TRACEJAVACALLINDENT + + strlen("finished: ") + + ((m->clazz == NULL) ? strlen("NULL") : utf_bytes(m->clazz->name)) + + strlen(".") + + utf_bytes(m->name) + + utf_bytes(m->descriptor) + + strlen(" SYNCHRONIZED") + strlen("(") + strlen(")"); + + /* add maximal argument length */ + + logtextlen += strlen("->0.4872328470301428 (0x0123456789abcdef)"); + + // Create new dump memory area. + DumpMemoryArea dma; + + // TODO Use a std::string here. + logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen); + + /* generate the message */ + + sprintf(logtext, " "); + sprintf(logtext + strlen(logtext), "-%d-", TRACEJAVACALLINDENT); + + pos = strlen(logtext); + + for (i = 0; i < TRACEJAVACALLINDENT; i++) + logtext[pos++] = '\t'; + + strcpy(logtext + pos, "finished: "); + if (m->clazz != NULL) + utf_cat_classname(logtext, m->clazz->name); + else + strcat(logtext, "NULL"); + strcat(logtext, "."); + utf_cat(logtext, m->name); + utf_cat(logtext, m->descriptor); + + if (!IS_VOID_TYPE(md->returntype.type)) { + strcat(logtext, "->"); + val = argument_jitreturn_load(md, return_regs); + + logtext = + trace_java_call_print_argument(m, logtext, &logtextlen, + &md->returntype, val); + } + + log_text(logtext); +} + + +/* trace_exception ************************************************************* + + Traces an exception which is handled by exceptions_handle_exception. + +*******************************************************************************/ + +void trace_exception(java_object_t *xptr, methodinfo *m, void *pos) +{ + char *logtext; + s4 logtextlen; + codeinfo *code; + + /* calculate message length */ + + if (xptr) { + logtextlen = + strlen("Exception ") + utf_bytes(xptr->vftbl->clazz->name); + } + else { + logtextlen = strlen("Some Throwable"); + } + + logtextlen += strlen(" thrown in "); + + if (m) { + logtextlen += + utf_bytes(m->clazz->name) + + strlen(".") + + utf_bytes(m->name) + + utf_bytes(m->descriptor) + + strlen("(NOSYNC,NATIVE"); + +#if SIZEOF_VOID_P == 8 + logtextlen += + strlen(")(0x123456789abcdef0) at position 0x123456789abcdef0 ("); +#else + logtextlen += strlen(")(0x12345678) at position 0x12345678 ("); +#endif + + if (m->clazz->sourcefile == NULL) + logtextlen += strlen(""); + else + logtextlen += utf_bytes(m->clazz->sourcefile); + + logtextlen += strlen(":65536)"); + + } + else { + logtextlen += strlen("call_java_method"); + } + + logtextlen += strlen("0"); + + // Create new dump memory area. + DumpMemoryArea dma; + + // TODO Use a std::string here. + logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen); + + if (xptr) { + strcpy(logtext, "Exception "); + utf_cat_classname(logtext, xptr->vftbl->clazz->name); + + } else { + strcpy(logtext, "Some Throwable"); + } + + strcat(logtext, " thrown in "); + + if (m) { + utf_cat_classname(logtext, m->clazz->name); + strcat(logtext, "."); + utf_cat(logtext, m->name); + utf_cat(logtext, m->descriptor); + + if (m->flags & ACC_SYNCHRONIZED) + strcat(logtext, "(SYNC"); + else + strcat(logtext, "(NOSYNC"); + + if (m->flags & ACC_NATIVE) { + strcat(logtext, ",NATIVE"); + + code = m->code; + +#if SIZEOF_VOID_P == 8 + sprintf(logtext + strlen(logtext), + ")(0x%016lx) at position 0x%016lx", + (ptrint) code->entrypoint, (ptrint) pos); +#else + sprintf(logtext + strlen(logtext), + ")(0x%08x) at position 0x%08x", + (ptrint) code->entrypoint, (ptrint) pos); +#endif + + } else { + + /* XXX preliminary: This should get the actual codeinfo */ + /* in which the exception happened. */ + code = m->code; + +#if SIZEOF_VOID_P == 8 + sprintf(logtext + strlen(logtext), + ")(0x%016lx) at position 0x%016lx (", + (ptrint) code->entrypoint, (ptrint) pos); +#else + sprintf(logtext + strlen(logtext), + ")(0x%08x) at position 0x%08x (", + (ptrint) code->entrypoint, (ptrint) pos); +#endif + + if (m->clazz->sourcefile == NULL) + strcat(logtext, ""); + else + utf_cat(logtext, m->clazz->sourcefile); + + sprintf(logtext + strlen(logtext), ":%d)", 0); + } + + } else + strcat(logtext, "call_java_method"); + + log_text(logtext); +} + + +/* trace_exception_builtin ***************************************************** + + Traces an exception which is thrown by builtin_throw_exception. + +*******************************************************************************/ + +void trace_exception_builtin(java_handle_t* h) +{ + char *logtext; + s4 logtextlen; + + java_lang_Throwable jlt(h); + + // Get detail message. + java_handle_t* s = NULL; + + if (jlt.get_handle() != NULL) + s = jlt.get_detailMessage(); + + java_lang_String jls(s); + + /* calculate message length */ + + logtextlen = strlen("Builtin exception thrown: ") + strlen("0"); + + if (jlt.get_handle() != NULL) { + logtextlen += utf_bytes(jlt.get_vftbl()->clazz->name); + + if (jls.get_handle()) { + // FIXME This is not handle capable! + logtextlen += strlen(": ") + + u2_utflength(jls.get_value()->data + jls.get_offset(), jls.get_count()); + } + } + else { + logtextlen += strlen("(nil)"); + } + + // Create new dump memory area. + DumpMemoryArea dma; + + logtext = (char*) DumpMemory::allocate(sizeof(char) * logtextlen); + + strcpy(logtext, "Builtin exception thrown: "); + + if (jlt.get_handle()) { + utf_cat_classname(logtext, jlt.get_vftbl()->clazz->name); + + if (s) { + char *buf; + + buf = javastring_tochar(jls.get_handle()); + strcat(logtext, ": "); + strcat(logtext, buf); + MFREE(buf, char, strlen(buf) + 1); + } + + } else { + strcat(logtext, "(nil)"); + } + + log_text(logtext); +} + +} // extern "C" + +#endif /* !defined(NDEBUG) */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/trace.h b/src/vm/jit/trace.h deleted file mode 100644 index db41359b2..000000000 --- a/src/vm/jit/trace.h +++ /dev/null @@ -1,60 +0,0 @@ -/* src/vm/jit/trace.h - Functions for tracing from java code. - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -#ifndef _VM_JIT_TRACE_H -#define _VM_JIT_TRACE_H - -#include "config.h" - -#include - -#include "vmcore/method.h" - -#if !defined(NDEBUG) - -void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack); -void trace_java_call_exit(methodinfo *m, uint64_t *return_regs); - -void trace_exception(java_object_t *xptr, methodinfo *m, void *pos); -void trace_exception_builtin(java_object_t *xptr); - -#endif /* !defined(NDEBUG) */ - -#endif /* _VM_JIT_TRACE_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/jit/trace.hpp b/src/vm/jit/trace.hpp new file mode 100644 index 000000000..06d808dbf --- /dev/null +++ b/src/vm/jit/trace.hpp @@ -0,0 +1,70 @@ +/* src/vm/jit/trace.hpp - Functions for tracing from java code. + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _VM_JIT_TRACE_HPP +#define _VM_JIT_TRACE_HPP + +#include "config.h" + +#include + +#include "vm/method.h" + +#if !defined(NDEBUG) + +// FIXME For now we export everything as C functions. +#ifdef __cplusplus +extern "C" { +#endif + + +void trace_java_call_enter(methodinfo *m, uint64_t *arg_regs, uint64_t *stack); +void trace_java_call_exit(methodinfo *m, uint64_t *return_regs); + +void trace_exception(java_object_t *xptr, methodinfo *m, void *pos); +void trace_exception_builtin(java_object_t *xptr); + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(NDEBUG) */ + +#endif // _VM_JIT_TRACE_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/trap.c b/src/vm/jit/trap.c index d06295235..258530b1e 100644 --- a/src/vm/jit/trap.c +++ b/src/vm/jit/trap.c @@ -31,23 +31,24 @@ #include "md-trap.h" +#include "mm/memory.h" + #include "native/llni.h" #include "toolbox/logging.h" -#include "vm/exceptions.h" -#include "vm/vm.h" +#include "vm/exceptions.hpp" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/vm.hpp" -#include "vm/jit/code.h" +#include "vm/jit/code.hpp" #include "vm/jit/disass.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/methodtree.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/options.h" -#include "vmcore/system.h" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" /** @@ -66,9 +67,9 @@ void trap_init(void) /* mmap a memory page at address 0x0, so our hardware-exceptions work. */ - pagesize = system_getpagesize(); + pagesize = os_getpagesize(); - (void) system_mmap_anonymous(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED); + (void) os_mmap_anonymous(NULL, pagesize, PROT_NONE, MAP_PRIVATE | MAP_FIXED); #endif TRACESUBSYSTEMINITIALIZATION("trap_init"); @@ -182,6 +183,15 @@ void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xp p = jit_compile_handle(m, sfi.pv, ra, (void *) val); break; +#if defined(ENABLE_REPLACEMENT) + case TRAP_COUNTDOWN: +#if defined(__I386__) + replace_me_wrapper((char*)xpc - 13, context); +#endif + p = NULL; + break; +#endif + default: /* Let's try to get a backtrace. */ diff --git a/src/vm/jit/trap.h b/src/vm/jit/trap.h index 8eb295bd5..6a18c35dc 100644 --- a/src/vm/jit/trap.h +++ b/src/vm/jit/trap.h @@ -30,6 +30,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + /* Include machine dependent trap stuff. */ #include "md-trap.h" @@ -40,6 +44,10 @@ void trap_init(void); void* trap_handle(int type, intptr_t val, void *pv, void *sp, void *ra, void *xpc, void *context); +#ifdef __cplusplus +} +#endif + #endif /* _TRAP_H */ diff --git a/src/vm/jit/verify/icmds.c b/src/vm/jit/verify/icmds.c index d308d8b79..65adf817d 100644 --- a/src/vm/jit/verify/icmds.c +++ b/src/vm/jit/verify/icmds.c @@ -1,9 +1,7 @@ /* src/vm/jit/verify/icmds.c - ICMD-specific type checking code - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. diff --git a/src/vm/jit/verify/typecheck-common.c b/src/vm/jit/verify/typecheck-common.c index 5b559438a..f574a4c07 100644 --- a/src/vm/jit/verify/typecheck-common.c +++ b/src/vm/jit/verify/typecheck-common.c @@ -29,9 +29,13 @@ #include -#include -#include -#include +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" + +#include "vm/jit/show.h" + +#include "typecheck-common.h" + /****************************************************************************/ /* DEBUG HELPERS */ diff --git a/src/vm/jit/verify/typecheck-common.h b/src/vm/jit/verify/typecheck-common.h index fd3f6ab6f..226113f16 100644 --- a/src/vm/jit/verify/typecheck-common.h +++ b/src/vm/jit/verify/typecheck-common.h @@ -32,7 +32,7 @@ #include -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /****************************************************************************/ diff --git a/src/vm/jit/verify/typecheck-stackbased.c b/src/vm/jit/verify/typecheck-stackbased.c index 5141dd871..5ce3d5008 100644 --- a/src/vm/jit/verify/typecheck-stackbased.c +++ b/src/vm/jit/verify/typecheck-stackbased.c @@ -29,12 +29,14 @@ #include "vm/types.h" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "mm/memory.h" #include "vm/array.h" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/primitive.h" +#include "vm/globals.hpp" +#include "vm/primitive.hpp" #include "vm/jit/parse.h" #include "vm/jit/show.h" diff --git a/src/vm/jit/verify/typecheck-typeinferer.c b/src/vm/jit/verify/typecheck-typeinferer.c index 35005828c..ba6a40c22 100644 --- a/src/vm/jit/verify/typecheck-typeinferer.c +++ b/src/vm/jit/verify/typecheck-typeinferer.c @@ -1,9 +1,7 @@ /* src/vm/jit/verify/typecheck-typeinferer.c - type inference pass - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -37,23 +35,23 @@ #include "toolbox/logging.h" -#include "vm/array.h" #include "vm/access.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/primitive.h" +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" #include "vm/resolve.h" -#include "vm/vm.h" +#include "vm/vm.hpp" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/show.h" #include "vm/jit/parse.h" #include "vm/jit/verify/typecheck-typeinferer.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - #define TYPECHECK_NO_STATISTICS #include diff --git a/src/vm/jit/verify/typecheck-typeinferer.h b/src/vm/jit/verify/typecheck-typeinferer.h index 530a5e1e2..6684ac939 100644 --- a/src/vm/jit/verify/typecheck-typeinferer.h +++ b/src/vm/jit/verify/typecheck-typeinferer.h @@ -36,7 +36,7 @@ #include "config.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* function prototypes ********************************************************/ diff --git a/src/vm/jit/verify/typecheck.c b/src/vm/jit/verify/typecheck.c index e679e9526..878217c3f 100644 --- a/src/vm/jit/verify/typecheck.c +++ b/src/vm/jit/verify/typecheck.c @@ -149,19 +149,19 @@ error reporting. #include "vm/access.h" #include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/primitive.h" +#include "vm/globals.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" #include "vm/resolve.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/parse.h" #include "vm/jit/show.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - #include diff --git a/src/vm/jit/verify/typecheck.h b/src/vm/jit/verify/typecheck.h index 01492ea53..dac58ca41 100644 --- a/src/vm/jit/verify/typecheck.h +++ b/src/vm/jit/verify/typecheck.h @@ -1,9 +1,7 @@ /* src/vm/jit/verify/typecheck.h - type checking header - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,11 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - */ @@ -36,16 +29,24 @@ #include "config.h" #include "vm/global.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + #if defined(ENABLE_VERIFIER) bool typecheck(jitdata *jd); bool typecheck_stackbased(jitdata *jd); #endif +#ifdef __cplusplus +} +#endif + #endif /* _TYPECHECK_H */ diff --git a/src/vm/jit/verify/typeinfo.c b/src/vm/jit/verify/typeinfo.c index f31c4c958..258dec8e9 100644 --- a/src/vm/jit/verify/typeinfo.c +++ b/src/vm/jit/verify/typeinfo.c @@ -33,17 +33,17 @@ #include "toolbox/logging.h" #include "vm/array.h" -#include "vm/exceptions.h" -#include "vm/primitive.h" +#include "vm/class.h" +#include "vm/descriptor.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/loader.hpp" +#include "vm/primitive.hpp" #include "vm/resolve.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/verify/typeinfo.h" -#include "vmcore/class.h" -#include "vmcore/descriptor.h" -#include "vmcore/loader.h" - /* check if a linked class is an array class. Only use for linked classes! */ #define CLASSINFO_IS_ARRAY(clsinfo) ((clsinfo)->vftbl->arraydesc != NULL) diff --git a/src/vm/jit/verify/typeinfo.h b/src/vm/jit/verify/typeinfo.h index e35214928..70bfcc11f 100644 --- a/src/vm/jit/verify/typeinfo.h +++ b/src/vm/jit/verify/typeinfo.h @@ -35,8 +35,7 @@ typedef struct typedescriptor typedescriptor_t; #include "vm/types.h" #include "vm/global.h" - -#include "vmcore/references.h" +#include "vm/references.h" /* configuration **************************************************************/ diff --git a/src/vm/jit/x86_64/Makefile.am b/src/vm/jit/x86_64/Makefile.am index 839f39c7b..354c92ec1 100644 --- a/src/vm/jit/x86_64/Makefile.am +++ b/src/vm/jit/x86_64/Makefile.am @@ -28,15 +28,16 @@ LIBS = DIST_SUBDIRS = \ freebsd \ - linux + linux \ + solaris SUBDIRS = $(OS_DIR) noinst_HEADERS = \ arch.h \ - machine-instr.h \ \ - md-asm.h + md-asm.h \ + md-atomic.hpp noinst_LTLIBRARIES = libarch.la @@ -56,6 +57,7 @@ libarch_la_SOURCES = \ \ md-abi.c \ md-abi.h \ + md-stubs.hpp \ md-trap.h \ md.c \ md.h diff --git a/src/vm/jit/x86_64/asmpart.S b/src/vm/jit/x86_64/asmpart.S index 4f7a69f9f..5807491ec 100644 --- a/src/vm/jit/x86_64/asmpart.S +++ b/src/vm/jit/x86_64/asmpart.S @@ -1,9 +1,7 @@ /* src/vm/jit/x86_64/asmpart.S - Java-C interface functions for x86_64 - Copyright (C) 1996-2005, 2006, 2007, 2008 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -58,9 +56,6 @@ .globl asm_builtin_d2i .globl asm_builtin_d2l - .globl asm_compare_and_swap - .globl asm_memory_barrier - .globl asm_get_cycle_count @@ -394,30 +389,6 @@ asm_builtin_d2l: ret -/* asm_compare_and_swap ******************************************************** - - Does an atomic compare and swap. Required for the lock - implementation. - -*******************************************************************************/ - -asm_compare_and_swap: - mov a1,v0 /* v0 is %rax */ - lock cmpxchg a2,(a0) - ret - - -/* asm_memory_barrier ********************************************************** - - A memory barrier for the Java Memory Model. - -*******************************************************************************/ - -asm_memory_barrier: - mfence - ret - - /* asm_get_cycle_count ********************************************************* Get the current time-stamp counter from the CPU. diff --git a/src/vm/jit/x86_64/codegen.c b/src/vm/jit/x86_64/codegen.c index e9f2c2828..dc42a9a96 100644 --- a/src/vm/jit/x86_64/codegen.c +++ b/src/vm/jit/x86_64/codegen.c @@ -1,9 +1,7 @@ /* src/vm/jit/x86_64/codegen.c - machine code generator for x86_64 - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -41,43 +39,41 @@ #include "mm/memory.h" -#include "native/jni.h" #include "native/localref.h" #include "native/native.h" #include "threads/lock-common.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/statistics.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" #include "vm/jit/abi.h" #include "vm/jit/asmpart.h" -#include "vm/jit/code.h" -#include "vm/jit/codegen-common.h" +#include "vm/jit/code.hpp" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/dseg.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" #include "vm/jit/linenumbertable.h" #include "vm/jit/methodheader.h" #include "vm/jit/parse.h" -#include "vm/jit/patcher-common.h" +#include "vm/jit/patcher-common.hpp" #include "vm/jit/reg.h" -#include "vm/jit/replace.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/replace.hpp" +#include "vm/jit/stacktrace.hpp" #include "vm/jit/trap.h" #if defined(ENABLE_LSRA) # include "vm/jit/allocator/lsra.h" #endif -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" - /* codegen_emit **************************************************************** @@ -1889,8 +1885,8 @@ bool codegen_emit(jitdata *jd) if (IS_IMM32(iptr->sx.s23.s2.constval)) M_LST_IMM32(iptr->sx.s23.s2.constval, REG_ITMP1, 0); else { - M_IST_IMM(iptr->sx.s23.s2.constval, REG_ITMP1, 0); - M_IST_IMM(iptr->sx.s23.s2.constval >> 32, REG_ITMP1, 4); + M_MOV_IMM(iptr->sx.s23.s2.constval, REG_ITMP2); + M_LST(REG_ITMP2, REG_ITMP1, 0); } break; } @@ -2012,9 +2008,12 @@ bool codegen_emit(jitdata *jd) case TYPE_LNG: case TYPE_ADR: case TYPE_DBL: - /* XXX why no check for IS_IMM32? */ - M_IST32_IMM(iptr->sx.s23.s2.constval, s1, disp); - M_IST32_IMM(iptr->sx.s23.s2.constval >> 32, s1, disp + 4); + /* XXX why no check for IS_IMM32? -- probably because of the patcher */ + M_MOV_IMM(iptr->sx.s23.s2.constval, REG_ITMP2); + if (disp) /* resolved, disp can never be 0 */ + M_LST(REG_ITMP2, s1, disp); + else /* unresolved */ + M_LST32(REG_ITMP2, s1, disp); break; } break; @@ -3075,7 +3074,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s /* put env into first argument register */ - M_MOV_IMM(_Jv_env, REG_A0); + M_MOV_IMM(VM_get_jnienv(), REG_A0); } /* Call the native function. */ @@ -3090,7 +3089,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s case TYPE_INT: case TYPE_LNG: case TYPE_ADR: - switch (md->returntype.decltype) { + switch (md->returntype.primitivetype) { case PRIMITIVETYPE_BOOLEAN: M_BZEXT(REG_RESULT, REG_RESULT); break; diff --git a/src/vm/jit/x86_64/codegen.h b/src/vm/jit/x86_64/codegen.h index e4c3d1c0f..cb073729d 100644 --- a/src/vm/jit/x86_64/codegen.h +++ b/src/vm/jit/x86_64/codegen.h @@ -1,9 +1,7 @@ /* src/vm/jit/x86_64/codegen.h - code generation macros for x86_64 - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -36,7 +34,7 @@ #include "vm/jit/x86_64/emit.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" /* additional functions and macros to generate code ***************************/ @@ -131,11 +129,6 @@ } while (0) -/* stub defines ***************************************************************/ - -#define COMPILERSTUB_CODESIZE 8 - - /* macros to create code ******************************************************/ #define M_BYTE1(a) \ diff --git a/src/vm/jit/x86_64/emit.c b/src/vm/jit/x86_64/emit.c index ba1766fe3..a30f7ec45 100644 --- a/src/vm/jit/x86_64/emit.c +++ b/src/vm/jit/x86_64/emit.c @@ -1,9 +1,7 @@ /* src/vm/jit/x86_64/emit.c - x86_64 code emitter functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -39,19 +37,19 @@ #include "threads/lock-common.h" +#include "vm/options.h" + #include "vm/jit/abi.h" #include "vm/jit/abi-asm.h" #include "vm/jit/asmpart.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/emit-common.h" -#include "vm/jit/jit.h" -#include "vm/jit/patcher-common.h" -#include "vm/jit/replace.h" -#include "vm/jit/trace.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/emit-common.hpp" +#include "vm/jit/jit.hpp" +#include "vm/jit/patcher-common.hpp" +#include "vm/jit/replace.hpp" +#include "vm/jit/trace.hpp" #include "vm/jit/trap.h" -#include "vmcore/options.h" - /* emit_load ******************************************************************* @@ -110,7 +108,7 @@ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg) *******************************************************************************/ -inline void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d) +void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d) { codegendata *cd; s4 disp; diff --git a/src/vm/jit/x86_64/emit.h b/src/vm/jit/x86_64/emit.h index a53ca05b2..4a1cb4c98 100644 --- a/src/vm/jit/x86_64/emit.h +++ b/src/vm/jit/x86_64/emit.h @@ -31,8 +31,8 @@ #include "config.h" #include "vm/types.h" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" /* macros to create code ******************************************************/ diff --git a/src/vm/jit/x86_64/freebsd/md-os.c b/src/vm/jit/x86_64/freebsd/md-os.c index 6e4a2b227..4b683342a 100644 --- a/src/vm/jit/x86_64/freebsd/md-os.c +++ b/src/vm/jit/x86_64/freebsd/md-os.c @@ -29,12 +29,12 @@ #include #include -#include "threads/thread.h" +#include "threads/thread.hpp" #include "vm/signallocal.h" #include "vm/jit/asmpart.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" /* md_signal_handler_sigsegv *************************************************** @@ -129,25 +129,6 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) #endif -#if defined(ENABLE_THREADS) -void thread_restartcriticalsection(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - void *critical; - - _mc = &_uc->uc_mcontext; - - pc = (u1 *) _mc->mc_rip; - - critical = critical_find_restart_point(pc); - - if (critical != NULL) - _mc->mc_rip = (ptrint) critical; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/x86_64/linux/md-os.c b/src/vm/jit/x86_64/linux/md-os.c index 8b8bf32d5..4f3b27585 100644 --- a/src/vm/jit/x86_64/linux/md-os.c +++ b/src/vm/jit/x86_64/linux/md-os.c @@ -37,15 +37,15 @@ #include "vm/jit/x86_64/codegen.h" #include "vm/jit/x86_64/md.h" -#include "threads/thread.h" +#include "threads/thread.hpp" -#include "vm/builtin.h" +#include "vm/jit/builtin.hpp" #include "vm/signallocal.h" #include "vm/jit/asmpart.h" #include "vm/jit/executionstate.h" #include "vm/jit/trap.h" -#include "vm/jit/stacktrace.h" +#include "vm/jit/stacktrace.hpp" /* md_signal_handler_sigsegv *************************************************** @@ -498,35 +498,6 @@ void md_executionstate_write(executionstate_t *es, void *context) } -/* md_critical_section_restart ************************************************* - - Search the critical sections tree for a matching section and set - the PC to the restart point, if necessary. - -*******************************************************************************/ - -#if defined(ENABLE_THREADS) -void md_critical_section_restart(ucontext_t *_uc) -{ - mcontext_t *_mc; - u1 *pc; - u1 *npc; - - _mc = &_uc->uc_mcontext; - - /* ATTENTION: Don't use CACAO's internal REG_* defines as they are - different to the ones in . */ - - pc = (u1 *) _mc->gregs[REG_RIP]; - - npc = critical_find_restart_point(pc); - - if (npc != NULL) - _mc->gregs[REG_RIP] = (ptrint) npc; -} -#endif - - /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/x86_64/machine-instr.h b/src/vm/jit/x86_64/machine-instr.h deleted file mode 100644 index 3afe548eb..000000000 --- a/src/vm/jit/x86_64/machine-instr.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _MACHINE_INSTR_H -#define _MACHINE_INSTR_H - -static inline long -__attribute__ ((unused)) -compare_and_swap (volatile long *p, long oldval, long newval) -{ - long ret; - - __asm__ __volatile__ ("lock; cmpxchgq %2, %1" - : "=a" (ret), "=m" (*p) - : "r" (newval), "m" (*p), "0" (oldval)); - return ret; -} - -#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory"); -#define MEMORY_BARRIER_AFTER_ATOMIC() /* nothing */ -#define MEMORY_BARRIER() __asm__ __volatile__ ( \ - "mfence" : : : "memory" ); - -#endif diff --git a/src/vm/jit/x86_64/md-abi.c b/src/vm/jit/x86_64/md-abi.c index 9ae511b14..fd248a596 100644 --- a/src/vm/jit/x86_64/md-abi.c +++ b/src/vm/jit/x86_64/md-abi.c @@ -28,14 +28,13 @@ #include "vm/jit/x86_64/md-abi.h" +#include "vm/descriptor.h" #include "vm/global.h" #include "vm/jit/abi.h" -#include "vm/jit/jit.h" /* for REG_* (maybe can be removed) */ +#include "vm/jit/jit.hpp" /* for REG_* (maybe can be removed) */ #include "vm/jit/stack.h" -#include "vmcore/descriptor.h" - /* register descripton array **************************************************/ diff --git a/src/vm/jit/x86_64/md-atomic.hpp b/src/vm/jit/x86_64/md-atomic.hpp new file mode 100644 index 000000000..accef01af --- /dev/null +++ b/src/vm/jit/x86_64/md-atomic.hpp @@ -0,0 +1,134 @@ +/* src/vm/jit/x86_64/atomic.hpp - x86_64 atomic instructions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_ATOMIC_HPP +#define _MD_ATOMIC_HPP + +#include "config.h" + +#include + +#include "threads/atomic.hpp" + + +/** + * An atomic compare and swap for 32-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval) +{ + uint32_t result; + + __asm__ __volatile__ ("lock; cmpxchgl %2, %1" + : "=a" (result), "=m" (*p) + : "r" (newval), "m" (*p), "0" (oldval)); + + return result; +} + + +/** + * An atomic compare and swap for 64-bit integer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval) +{ + uint64_t result; + + __asm__ __volatile__ ("lock; cmpxchgq %2, %1" + : "=a" (result), "=m" (*p) + : "r" (newval), "m" (*p), "0" (oldval)); + + return result; +} + + +/** + * An atomic compare and swap for pointer values. + * + * @param p Pointer to memory address. + * @param oldval Old value to be expected. + * @param newval New value to be stored. + * + * @return value of the memory location before the store + */ +inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval) +{ + return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval); +} + + +/** + * A memory barrier. + */ +inline void Atomic::memory_barrier(void) +{ + __asm__ __volatile__ ("mfence" : : : "memory"); +} + + +/** + * A write memory barrier. + */ +inline void Atomic::write_memory_barrier(void) +{ + __asm__ __volatile__ ("" : : : "memory"); +} + + +/** + * An instruction barrier. + */ +inline void Atomic::instruction_barrier(void) +{ + // Nothing. +} + +#endif // _MD_ATOMIC_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/x86_64/md-stubs.hpp b/src/vm/jit/x86_64/md-stubs.hpp new file mode 100644 index 000000000..521a814b4 --- /dev/null +++ b/src/vm/jit/x86_64/md-stubs.hpp @@ -0,0 +1,56 @@ +/* src/vm/jit/x86_64/md-stubs.hpp - x86_64 JIT stubs + + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _MD_STUBS_HPP +#define _MD_STUBS_HPP + +#include "config.h" + + +/** + * Return the code size of a compiler on a x86_64 architecture. + * + * @return Code size in bytes. + */ +int CompilerStub::get_code_size() +{ + return 8; +} + +#endif // _MD_STUBS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit/x86_64/md-trap.h b/src/vm/jit/x86_64/md-trap.h index 6493e3559..c78e31b95 100644 --- a/src/vm/jit/x86_64/md-trap.h +++ b/src/vm/jit/x86_64/md-trap.h @@ -58,6 +58,7 @@ enum { /* Don't use 8 (could be a normal load offset). */ TRAP_COMPILER = 9, + TRAP_COUNTDOWN = 10, TRAP_END }; diff --git a/src/vm/jit/x86_64/md.c b/src/vm/jit/x86_64/md.c index dc4b3fab1..586550cfd 100644 --- a/src/vm/jit/x86_64/md.c +++ b/src/vm/jit/x86_64/md.c @@ -1,9 +1,7 @@ /* src/vm/jit/x86_64/md.c - machine dependent x86_64 functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -33,10 +31,10 @@ #include "vm/jit/x86_64/md-abi.h" -#include "vm/vm.h" +#include "vm/vm.hpp" -#include "vm/jit/codegen-common.h" -#include "vm/jit/jit.h" +#include "vm/jit/codegen-common.hpp" +#include "vm/jit/jit.hpp" /* md_init ********************************************************************* diff --git a/src/vm/jit/x86_64/md.h b/src/vm/jit/x86_64/md.h index f60e9720f..6495479a8 100644 --- a/src/vm/jit/x86_64/md.h +++ b/src/vm/jit/x86_64/md.h @@ -1,6 +1,7 @@ /* src/vm/jit/x86_64/md.h - machine dependent x86_64 functions Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -30,7 +31,7 @@ #include #include -#include "vm/jit/codegen-common.h" +#include "vm/jit/codegen-common.hpp" #include "vm/jit/methodtree.h" @@ -82,9 +83,10 @@ inline static void *md_codegen_get_pv_from_pc(void *ra) *******************************************************************************/ -inline static void md_cacheflush(u1 *addr, s4 nbytes) +inline static void md_cacheflush(void* addr, int nbytes) { - /* do nothing */ + // Compiler optimization barrier (see PR97). + __asm__ __volatile__ ("" : : : "memory"); } @@ -94,9 +96,10 @@ inline static void md_cacheflush(u1 *addr, s4 nbytes) *******************************************************************************/ -inline static void md_icacheflush(u1 *addr, s4 nbytes) +inline static void md_icacheflush(void* addr, int nbytes) { - /* do nothing */ + // Compiler optimization barrier (see PR97). + __asm__ __volatile__ ("" : : : "memory"); } @@ -106,9 +109,10 @@ inline static void md_icacheflush(u1 *addr, s4 nbytes) *******************************************************************************/ -inline static void md_dcacheflush(u1 *addr, s4 nbytes) +inline static void md_dcacheflush(void* addr, int nbytes) { - /* do nothing */ + // Compiler optimization barrier (see PR97). + __asm__ __volatile__ ("" : : : "memory"); } #endif /* _VM_JIT_X86_64_MD_H */ diff --git a/src/vm/jit/x86_64/patcher.c b/src/vm/jit/x86_64/patcher.c index 2ab929aaf..49a5d3f6a 100644 --- a/src/vm/jit/x86_64/patcher.c +++ b/src/vm/jit/x86_64/patcher.c @@ -30,29 +30,21 @@ #include "vm/types.h" #include "vm/jit/x86_64/codegen.h" +#include "vm/jit/x86_64/md.h" #include "mm/memory.h" #include "native/native.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/initialize.h" - -#include "vm/jit/patcher-common.h" -#include "vm/jit/stacktrace.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/options.h" -#include "vmcore/references.h" +#include "vm/options.h" +#include "vm/references.h" #include "vm/resolve.h" - -#define PATCH_BACK_ORIGINAL_MCODE \ - do { \ - *((uint16_t *) pr->mpc) = (uint16_t) pr->mcode; \ - } while (0) +#include "vm/jit/patcher-common.hpp" /* patcher_patch_code ********************************************************** @@ -63,7 +55,8 @@ void patcher_patch_code(patchref_t *pr) { - PATCH_BACK_ORIGINAL_MCODE; + *((uint16_t*) pr->mpc) = (uint16_t) pr->mcode; + md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE); } @@ -93,23 +86,23 @@ void patcher_patch_code(patchref_t *pr) bool patcher_resolve_classref_to_classinfo(patchref_t *pr) { - constant_classref *cr; - intptr_t *datap; - classinfo *c; - - cr = (constant_classref *) pr->ref; - datap = (intptr_t *) pr->datap; + constant_classref* cr = (constant_classref*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - /* get the classinfo */ + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch the class. + *datap = (uintptr_t) c; - /* patch the classinfo pointer */ + // Synchronize data cache. + md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P); - *datap = (intptr_t) c; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -126,25 +119,23 @@ bool patcher_resolve_classref_to_classinfo(patchref_t *pr) bool patcher_resolve_classref_to_vftbl(patchref_t *pr) { - constant_classref *cr; - intptr_t *datap; - classinfo *c; + constant_classref* cr = (constant_classref*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - /* get stuff from the stack */ + // Resolve the field. + classinfo* c = resolve_classref_eager(cr); - cr = (constant_classref *) pr->ref; - datap = (intptr_t *) pr->datap; - - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch super class' vftbl. + *datap = (uintptr_t) c->vftbl; - /* patch super class' vftbl */ + // Synchronize data cache. + md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P); - *datap = (intptr_t) c->vftbl; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -160,31 +151,26 @@ bool patcher_resolve_classref_to_vftbl(patchref_t *pr) bool patcher_resolve_classref_to_flags(patchref_t *pr) { - constant_classref *cr; - int32_t *datap; - classinfo *c; - uint8_t *ra; - - cr = (constant_classref *) pr->ref; - datap = (int32_t *) pr->datap; - ra = (uint8_t *) pr->mpc; + constant_classref* cr = (constant_classref*) pr->ref; +/* int32_t* datap = (int32_t*) pr->datap; */ + uint8_t* ra = (uint8_t*) pr->mpc; - /* get the fieldinfo */ + // Resolve the field. + classinfo* c = resolve_classref_eager(cr); - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Patch class flags. +/* *datap = c->flags; */ + *((int32_t*) (ra + 2)) = c->flags; - /* patch class flags */ + // Synchronize data cache. +/* md_dcacheflush(datap, sizeof(int32_t)); */ + md_icacheflush(ra + 2, sizeof(int32_t)); -/* *datap = c->flags; */ - *((int32_t *) (ra + 2)) = c->flags; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -202,29 +188,28 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr) bool patcher_get_putstatic(patchref_t *pr) { - unresolved_field *uf; - intptr_t *datap; - fieldinfo *fi; - - uf = (unresolved_field *) pr->ref; - datap = (intptr_t *) pr->datap; + unresolved_field* uf = (unresolved_field*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - /* get the fieldinfo */ + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - /* check if the field's class is initialized */ - + // Check if the field's class is initialized/ if (!(fi->clazz->state & CLASS_INITIALIZED)) if (!initialize_class(fi->clazz)) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch the field value's address. + *datap = (uintptr_t) fi->value; - /* patch the field value's address */ + // Synchronize data cache. + md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P); - *datap = (intptr_t) fi->value; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -241,50 +226,38 @@ bool patcher_get_putstatic(patchref_t *pr) bool patcher_get_putfield(patchref_t *pr) { - uint8_t *ra; - unresolved_field *uf; - fieldinfo *fi; - uint8_t byte; + uint8_t* pc = (uint8_t*) pr->mpc; + unresolved_field* uf = (unresolved_field*) pr->ref; - ra = (uint8_t *) pr->mpc; - uf = (unresolved_field *) pr->ref; + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - /* get the fieldinfo */ - - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - - /* Patch the field's offset: we check for the field type, because - the instructions have different lengths. */ - + // Patch the field's offset: we check for the field type, because + // the instructions have different lengths. if (IS_INT_LNG_TYPE(fi->type)) { - /* Check for special case: %rsp or %r12 as base register. */ - - byte = *(ra + 3); - - if (byte == 0x24) - *((int32_t *) (ra + 4)) = fi->offset; + // Check for special case: %rsp or %r12 as base register. + if (pc[3] == 0x24) + *((int32_t*) (pc + 4)) = fi->offset; else - *((int32_t *) (ra + 3)) = fi->offset; + *((int32_t*) (pc + 3)) = fi->offset; } else { - /* Check for special case: %rsp or %r12 as base register. */ - - byte = *(ra + 5); - - if (byte == 0x24) - *((int32_t *) (ra + 6)) = fi->offset; + // Check for special case: %rsp or %r12 as base register. + if (pc[5] == 0x24) + *((int32_t*) (pc + 6)) = fi->offset; else - *((int32_t *) (ra + 5)) = fi->offset; + *((int32_t*) (pc + 5)) = fi->offset; } + // Synchronize instruction cache. + md_icacheflush(pc, 6 + sizeof(int32_t)); + + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -300,53 +273,37 @@ bool patcher_get_putfield(patchref_t *pr) bool patcher_putfieldconst(patchref_t *pr) { - uint8_t *ra; - unresolved_field *uf; - fieldinfo *fi; - uint8_t byte; - - ra = (uint8_t *) pr->mpc; - uf = (unresolved_field *) pr->ref; + uint8_t* pc = (uint8_t*) pr->mpc; + unresolved_field* uf = (unresolved_field*) pr->ref; - /* get the fieldinfo */ + // Resolve the field. + fieldinfo* fi = resolve_field_eager(uf); - if (!(fi = resolve_field_eager(uf))) + if (fi == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - - /* patch the field's offset */ - + // Patch the field's offset. if (IS_2_WORD_TYPE(fi->type) || IS_ADR_TYPE(fi->type)) { - /* handle special case when the base register is %r12 */ - - byte = *(ra + 2); - - if (byte == 0x84) { - *((uint32_t *) (ra + 4)) = fi->offset; - *((uint32_t *) (ra + 12 + 4)) = fi->offset + 4; - } - else { - *((uint32_t *) (ra + 3)) = fi->offset; - *((uint32_t *) (ra + 11 + 3)) = fi->offset + 4; - } + // Handle special case when the base register is %r12. + if (pc[12] == 0x94) + *((uint32_t*) (pc + 14)) = fi->offset; + else + *((uint32_t*) (pc + 13)) = fi->offset; } else { - /* handle special case when the base register is %r12 */ - - byte = *(ra + 2); - - if (byte == 0x84) - *((uint32_t *) (ra + 4)) = fi->offset; + // Handle special case when the base register is %r12. + if (pc[2] == 0x84) + *((uint32_t*) (pc + 4)) = fi->offset; else - *((uint32_t *) (ra + 3)) = fi->offset; + *((uint32_t*) (pc + 3)) = fi->offset; } + // Synchronize instruction cache. + md_icacheflush(pc, 14 + sizeof(int32_t)); + + // Patch back the original code. + patcher_patch_code(pr); + return true; } @@ -363,25 +320,23 @@ bool patcher_putfieldconst(patchref_t *pr) bool patcher_invokestatic_special(patchref_t *pr) { - unresolved_method *um; - intptr_t *datap; - methodinfo *m; - - /* get stuff from the stack */ + unresolved_method* um = (unresolved_method*) pr->ref; + uintptr_t* datap = (uintptr_t*) pr->datap; - um = (unresolved_method *) pr->ref; - datap = (intptr_t *) pr->datap; + // Resolve the method. + methodinfo* m = resolve_method_eager(um); - /* get the fieldinfo */ - - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; + // Patch stubroutine. + *datap = (uintptr_t) m->stubroutine; - /* patch stubroutine */ + // Synchronize data cache. + md_dcacheflush((void*) pr->datap, SIZEOF_VOID_P); - *datap = (intptr_t) m->stubroutine; + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -400,30 +355,23 @@ bool patcher_invokestatic_special(patchref_t *pr) bool patcher_invokevirtual(patchref_t *pr) { - uint8_t *ra; - unresolved_method *um; - methodinfo *m; - - ra = (uint8_t *) pr->mpc; - um = (unresolved_method *) pr->ref; + uint8_t* pc = (uint8_t*) pr->mpc; + unresolved_method* um = (unresolved_method*) pr->ref; - /* get the methodinfo */ + // Resovlve the method. + methodinfo* m = resolve_method_eager(um); - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ + // Patch vftbl index. + *((int32_t*) (pc + 3 + 3)) = (int32_t) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex); - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Synchronize instruction cache. + md_icacheflush(pc + 3 + 3, SIZEOF_VOID_P); - /* patch vftbl index */ - - *((int32_t *) (ra + 3 + 3)) = - (int32_t) (OFFSET(vftbl_t, table[0]) + - sizeof(methodptr) * m->vftblindex); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -443,37 +391,26 @@ bool patcher_invokevirtual(patchref_t *pr) bool patcher_invokeinterface(patchref_t *pr) { - uint8_t *ra; - unresolved_method *um; - methodinfo *m; - - /* get stuff from the stack */ - - ra = (uint8_t *) pr->mpc; - um = (unresolved_method *) pr->ref; + uint8_t* pc = (uint8_t*) pr->mpc; + unresolved_method* um = (unresolved_method*) pr->ref; - /* get the fieldinfo */ + // Resolve the method. + methodinfo* m = resolve_method_eager(um); - if (!(m = resolve_method_eager(um))) + if (m == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; - - /* patch interfacetable index */ + // Patch interfacetable index. + *((int32_t*) (pc + 3 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr) * m->clazz->index); - *((int32_t *) (ra + 3 + 3)) = - (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - - sizeof(methodptr) * m->clazz->index); + // Patch method offset. + *((int32_t*) (pc + 3 + 7 + 3)) = (int32_t) (sizeof(methodptr) * (m - m->clazz->methods)); - /* patch method offset */ + // Synchronize instruction cache. + md_icacheflush(pc + 3 + 3, SIZEOF_VOID_P + 3 + SIZEOF_VOID_P); - *((int32_t *) (ra + 3 + 7 + 3)) = - (int32_t) (sizeof(methodptr) * (m - m->clazz->methods)); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -494,32 +431,25 @@ bool patcher_invokeinterface(patchref_t *pr) bool patcher_checkcast_interface(patchref_t *pr) { - uint8_t *ra; - constant_classref *cr; - classinfo *c; + uint8_t* pc = (uint8_t*) pr->mpc; + constant_classref* cr = (constant_classref*) pr->ref; - ra = (uint8_t *) pr->mpc; - cr = (constant_classref *) pr->ref; + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Patch super class index. + *((int32_t*) (pc + 7 + 3)) = c->index; - /* patch super class index */ + *((int32_t*) (pc + 7 + 7 + 6 + 8 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*)); - *((int32_t *) (ra + 7 + 3)) = c->index; + // Synchronize instruction cache. + md_icacheflush(pc + 7 + 3, sizeof(int32_t) + 6 + 8 + 3 + sizeof(int32_t)); - *((int32_t *) (ra + 7 + 7 + 6 + 8 + 3)) = - (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)); + // Patch back the original code. + patcher_patch_code(pr); return true; } @@ -539,32 +469,25 @@ bool patcher_checkcast_interface(patchref_t *pr) bool patcher_instanceof_interface(patchref_t *pr) { - uint8_t *ra; - constant_classref *cr; - classinfo *c; + uint8_t* pc = (uint8_t*) pr->mpc; + constant_classref* cr = (constant_classref*) pr->ref; - ra = (uint8_t *) pr->mpc; - cr = (constant_classref *) pr->ref; + // Resolve the class. + classinfo* c = resolve_classref_eager(cr); - /* get the fieldinfo */ - - if (!(c = resolve_classref_eager(cr))) + if (c == NULL) return false; - PATCH_BACK_ORIGINAL_MCODE; - - /* if we show disassembly, we have to skip the nop's */ - - if (opt_shownops) - ra = ra + PATCHER_CALL_SIZE; + // Patch super class index. + *((int32_t*) (pc + 7 + 3)) = c->index; - /* patch super class index */ + *((int32_t*) (pc + 7 + 7 + 6 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*)); - *((int32_t *) (ra + 7 + 3)) = c->index; + // Synchronize instruction cache. + md_icacheflush(pc + 7 + 3, sizeof(int32_t) + 6 + 3 + sizeof(int32_t)); - *((int32_t *) (ra + 7 + 7 + 6 + 3)) = - (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - - c->index * sizeof(methodptr*)); + // Patch back the original code. + patcher_patch_code(pr); return true; } diff --git a/src/vm/jit/x86_64/solaris/Makefile.am b/src/vm/jit/x86_64/solaris/Makefile.am new file mode 100644 index 000000000..aea86fd9f --- /dev/null +++ b/src/vm/jit/x86_64/solaris/Makefile.am @@ -0,0 +1,43 @@ +## src/vm/jit/x86_64/solaris/Makefile.am +## +## Copyright (C) 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +## +## This file is part of CACAO. +## +## This program is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + + +AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_builddir)/src + +LIBS = + +noinst_HEADERS = + +noinst_LTLIBRARIES = \ + libmd.la + +libmd_la_SOURCES = \ + md-os.c + + +## Local variables: +## mode: Makefile +## indent-tabs-mode: t +## c-basic-offset: 4 +## tab-width: 8 +## compile-command: "automake --add-missing" +## End: diff --git a/src/vm/jit/x86_64/solaris/md-os.c b/src/vm/jit/x86_64/solaris/md-os.c new file mode 100644 index 000000000..14824a49e --- /dev/null +++ b/src/vm/jit/x86_64/solaris/md-os.c @@ -0,0 +1,525 @@ +/* src/vm/jit/x86_64/solaris/md-os.c - machine dependent x86_64 Solaris functions + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include + +#include "vm/types.h" + +#include "vm/jit/x86_64/codegen.h" +#include "vm/jit/x86_64/md.h" + +#include "threads/thread.hpp" + +#include "vm/jit/builtin.hpp" +#include "vm/signallocal.h" + +#include "vm/jit/asmpart.h" +#include "vm/jit/executionstate.h" +#include "vm/jit/trap.h" +#include "vm/jit/stacktrace.hpp" + + +/* md_signal_handler_sigsegv *************************************************** + + Signal handler for hardware exception. + +*******************************************************************************/ + +void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + void *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + u1 opc; + u1 mod; + u1 rm; + s4 d; + s4 disp; + int type; + intptr_t val; + void *p; + java_object_t *o; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + /* ATTENTION: Don't use CACAO's internal REG_* defines as they are + different to the ones in . */ + + pv = NULL; /* is resolved during stackframeinfo creation */ + sp = (u1 *) _mc->gregs[REG_RSP]; + xpc = (u1 *) _mc->gregs[REG_RIP]; + ra = xpc; /* return address is equal to XPC */ + +#if 0 + /* check for StackOverflowException */ + + threads_check_stackoverflow(sp); +#endif + + /* get exception-throwing instruction */ + + opc = M_ALD_MEM_GET_OPC(xpc); + mod = M_ALD_MEM_GET_MOD(xpc); + rm = M_ALD_MEM_GET_RM(xpc); + + /* for values see emit_mov_mem_reg and emit_mem */ + + if ((opc == 0x8b) && (mod == 0) && (rm == 4)) { + /* this was a hardware-exception */ + + d = M_ALD_MEM_GET_REG(xpc); + disp = M_ALD_MEM_GET_DISP(xpc); + + /* we use the exception type as load displacement */ + + type = disp; + + /* XXX FIX ME! */ + + /* ATTENTION: The _mc->gregs layout is even worse than on + i386! See /usr/include/sys/ucontext.h. We need a + switch-case here... */ + + switch (d) { + case 0: /* REG_RAX == 14 */ + d = REG_RAX; + break; + case 1: /* REG_RCX == 13 */ + d = REG_RCX; + break; + case 2: /* REG_RDX == 12 */ + d = REG_RDX; + break; + case 3: /* REG_RBX == 11 */ + d = REG_RBX; + break; + case 4: /* REG_RSP == 20 */ + d = REG_RSP; + break; + case 5: /* REG_RBP == 10 */ + d = REG_RBP; + break; + case 6: /* REG_RSI == 9 */ + d = REG_RSI; + break; + case 7: /* REG_RDI == 8 */ + d = REG_RDI; + break; + case 8: /* REG_R8 == 7 */ + d = REG_R8; + break; + case 9: /* REG_R9 == 6 */ + d = REG_R9; + break; + case 10: /* REG_R10 == 5 */ + d = REG_R10; + break; + case 11: /* REG_R11 == 4 */ + d = REG_R11; + break; + case 12: /* REG_R12 == 3 */ + d = REG_R12; + break; + case 13: /* REG_R13 == 2 */ + d = REG_R13; + break; + case 14: /* REG_R14 == 1 */ + d = REG_R14; + break; + case 15: /* REG_R15 == 0 */ + d = REG_R15; + break; + } + + val = _mc->gregs[d]; + + if (type == TRAP_COMPILER) { + /* The PV from the compiler stub is equal to the XPC. */ + + pv = xpc; + + /* We use a framesize of zero here because the call pushed + the return addres onto the stack. */ + + ra = md_stacktrace_get_returnaddress(sp, 0); + + /* Skip the RA on the stack. */ + + sp = sp + 1 * SIZEOF_VOID_P; + + /* The XPC is the RA minus 1, because the RA points to the + instruction after the call. */ + + xpc = ra - 3; + } + } + else { + /* this was a normal NPE */ + + type = TRAP_NullPointerException; + val = 0; + } + + /* Handle the trap. */ + + p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + /* Set registers. */ + + if (type == TRAP_COMPILER) { + if (p == NULL) { + o = builtin_retrieve_exception(); + + _mc->gregs[REG_RSP] = (uintptr_t) sp; /* Remove RA from stack. */ + + _mc->gregs[REG_RAX] = (uintptr_t) o; + _mc->gregs[REG_R10] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception; + } + else { + _mc->gregs[REG_RIP] = (uintptr_t) p; + } + } + else { + _mc->gregs[REG_RAX] = (uintptr_t) p; + _mc->gregs[REG_R10] = (uintptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_RIP] = (uintptr_t) asm_handle_exception; + } +} + + +/* md_signal_handler_sigfpe **************************************************** + + ArithmeticException signal handler for hardware divide by zero + check. + +*******************************************************************************/ + +void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + int type; + intptr_t val; + void *p; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + /* ATTENTION: Don't use CACAO's internal REG_* defines as they are + different to the ones in . */ + + pv = NULL; + sp = (u1 *) _mc->gregs[REG_RSP]; + xpc = (u1 *) _mc->gregs[REG_RIP]; + ra = xpc; /* return address is equal to xpc */ + + /* This is an ArithmeticException. */ + + type = TRAP_ArithmeticException; + val = 0; + + /* Handle the trap. */ + + p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + /* set registers */ + + _mc->gregs[REG_RAX] = (intptr_t) p; + _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception; +} + + +/* md_signal_handler_sigill **************************************************** + + Signal handler for patchers. + +*******************************************************************************/ + +void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pv; + u1 *sp; + u1 *ra; + u1 *xpc; + int type; + intptr_t val; + void *p; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + /* ATTENTION: Don't use CACAO's internal REG_* defines as they are + different to the ones in . */ + + pv = NULL; + sp = (u1 *) _mc->gregs[REG_RSP]; + xpc = (u1 *) _mc->gregs[REG_RIP]; + ra = xpc; /* return address is equal to xpc */ + + /* This is a patcher. */ + + type = TRAP_PATCHER; + val = 0; + + /* Handle the trap. */ + + p = trap_handle(type, val, pv, sp, ra, xpc, _p); + + /* set registers */ + + if (p != NULL) { + _mc->gregs[REG_RAX] = (intptr_t) p; + _mc->gregs[REG_R10] = (intptr_t) xpc; /* REG_ITMP2_XPC */ + _mc->gregs[REG_RIP] = (intptr_t) asm_handle_exception; + } +} + + +/* md_signal_handler_sigusr1 *************************************************** + + Signal handler for suspending threads. + +*******************************************************************************/ + +#if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) +void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p) +{ + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pc; + u1 *sp; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + /* ATTENTION: Don't use CACAO's internal REG_* defines as they are + different to the ones in . */ + + /* get the PC and SP for this thread */ + pc = (u1 *) _mc->gregs[REG_RIP]; + sp = (u1 *) _mc->gregs[REG_RSP]; + + /* now suspend the current thread */ + threads_suspend_ack(pc, sp); +} +#endif + + +/* md_signal_handler_sigusr2 *************************************************** + + Signal handler for profiling sampling. + +*******************************************************************************/ + +#if defined(ENABLE_THREADS) +void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p) +{ + threadobject *t; + ucontext_t *_uc; + mcontext_t *_mc; + u1 *pc; + + t = THREADOBJECT; + + _uc = (ucontext_t *) _p; + _mc = &_uc->uc_mcontext; + + /* ATTENTION: Don't use CACAO's internal REG_* defines as they are + different to the ones in . */ + + pc = (u1 *) _mc->gregs[REG_RIP]; + + t->pc = pc; +} +#endif + + +/* md_executionstate_read ****************************************************** + + Read the given context into an executionstate. + +*******************************************************************************/ + +void md_executionstate_read(executionstate_t *es, void *context) +{ + ucontext_t *_uc; + mcontext_t *_mc; + s4 i; + s4 d; + + _uc = (ucontext_t *) context; + _mc = &_uc->uc_mcontext; + + /* read special registers */ + es->pc = (u1 *) _mc->gregs[REG_RIP]; + es->sp = (u1 *) _mc->gregs[REG_RSP]; + es->pv = NULL; + + /* read integer registers */ + for (i = 0; i < INT_REG_CNT; i++) { + /* XXX FIX ME! */ + + switch (i) { + case 0: /* REG_RAX == 13 */ + d = REG_RAX; + break; + case 1: /* REG_RCX == 14 */ + d = REG_RCX; + break; + case 2: /* REG_RDX == 12 */ + d = REG_RDX; + break; + case 3: /* REG_RBX == 11 */ + d = REG_RBX; + break; + case 4: /* REG_RSP == 15 */ + d = REG_RSP; + break; + case 5: /* REG_RBP == 10 */ + d = REG_RBP; + break; + case 6: /* REG_RSI == 9 */ + d = REG_RSI; + break; + case 7: /* REG_RDI == 8 */ + d = REG_RDI; + break; + case 8: /* REG_R8 == 0 */ + case 9: /* REG_R9 == 1 */ + case 10: /* REG_R10 == 2 */ + case 11: /* REG_R11 == 3 */ + case 12: /* REG_R12 == 4 */ + case 13: /* REG_R13 == 5 */ + case 14: /* REG_R14 == 6 */ + case 15: /* REG_R15 == 7 */ + d = i - 8; + break; + } + + es->intregs[i] = _mc->gregs[d]; + } + + /* read float registers */ + for (i = 0; i < FLT_REG_CNT; i++) + es->fltregs[i] = 0xdeadbeefdeadbeefL; +} + + +/* md_executionstate_write ***************************************************** + + Write the given executionstate back to the context. + +*******************************************************************************/ + +void md_executionstate_write(executionstate_t *es, void *context) +{ + ucontext_t *_uc; + mcontext_t *_mc; + s4 i; + s4 d; + + _uc = (ucontext_t *) context; + _mc = &_uc->uc_mcontext; + + /* write integer registers */ + for (i = 0; i < INT_REG_CNT; i++) { + /* XXX FIX ME! */ + + switch (i) { + case 0: /* REG_RAX == 13 */ + d = REG_RAX; + break; + case 1: /* REG_RCX == 14 */ + d = REG_RCX; + break; + case 2: /* REG_RDX == 12 */ + d = REG_RDX; + break; + case 3: /* REG_RBX == 11 */ + d = REG_RBX; + break; + case 4: /* REG_RSP == 15 */ + d = REG_RSP; + break; + case 5: /* REG_RBP == 10 */ + d = REG_RBP; + break; + case 6: /* REG_RSI == 9 */ + d = REG_RSI; + break; + case 7: /* REG_RDI == 8 */ + d = REG_RDI; + break; + case 8: /* REG_R8 == 0 */ + case 9: /* REG_R9 == 1 */ + case 10: /* REG_R10 == 2 */ + case 11: /* REG_R11 == 3 */ + case 12: /* REG_R12 == 4 */ + case 13: /* REG_R13 == 5 */ + case 14: /* REG_R14 == 6 */ + case 15: /* REG_R15 == 7 */ + d = i - 8; + break; + } + + _mc->gregs[d] = es->intregs[i]; + } + + /* write special registers */ + _mc->gregs[REG_RIP] = (ptrint) es->pc; + _mc->gregs[REG_RSP] = (ptrint) es->sp; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/jit_interface.h b/src/vm/jit_interface.h deleted file mode 100644 index 89fbf6139..000000000 --- a/src/vm/jit_interface.h +++ /dev/null @@ -1,75 +0,0 @@ -/* src/vm/jit_interface.h - prototypes of jit functions used in vm/ code - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _JIT_INTERFACE -#define _JIT_INTERFACE - -#include "config.h" -#include "vm/types.h" - - -/* These functions are used from vm/ but defined in vm/jit/ */ - -void code_free_code_of_method(methodinfo *m); - -u1 *codegen_generate_stub_compiler(methodinfo *m); -codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f); - -#if defined(ENABLE_INTRP) -u1 *intrp_createcompilerstub(methodinfo *m); -#endif - -void removecompilerstub(u1 *stub); -void removenativestub(u1 *stub); - -void jit_invalidate_code(methodinfo *m); - -void md_param_alloc(methoddesc *md); -void md_param_alloc_native(methoddesc *md); - -/* stub for throwing AbstractMethodError's */ -#if defined(ENABLE_JIT) -void asm_abstractmethoderror(void); -#endif - -#if defined(ENABLE_INTRP) -void intrp_asm_abstractmethoderror(void); -#endif - -#endif /* _JIT_INTERFACE */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vm/linker.c b/src/vm/linker.c new file mode 100644 index 000000000..438c7eec6 --- /dev/null +++ b/src/vm/linker.c @@ -0,0 +1,1372 @@ +/* src/vm/linker.c - class linker functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "native/native.h" + +#include "threads/lock-common.h" +#include "threads/mutex.hpp" + +#include "toolbox/logging.h" + +#include "vm/access.h" +#include "vm/array.h" +#include "vm/class.h" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/rt-timing.h" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/asmpart.h" +#include "vm/jit/stubs.hpp" + + +/* debugging macros ***********************************************************/ + +#if !defined(NDEBUG) +# define TRACELINKCLASS(c) \ + do { \ + if (opt_TraceLinkClass) { \ + log_start(); \ + log_print("[Linking "); \ + class_print((c)); \ + log_print("]"); \ + log_finish(); \ + } \ + } while (0) +#else +# define TRACELINKCLASS(c) +#endif + + +/* #include "vm/resolve.h" */ +/* copied prototype to avoid bootstrapping problem: */ +classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess); + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#if !defined(NDEBUG) && defined(ENABLE_INLINING) +#define INLINELOG(code) do { if (opt_TraceInlining) { code } } while (0) +#else +#define INLINELOG(code) +#endif + + +/* global variables ***********************************************************/ + +static s4 interfaceindex; /* sequential numbering of interfaces */ +static s4 classvalue; + + +/* private functions **********************************************************/ + +static classinfo *link_class_intern(classinfo *c); +static arraydescriptor *link_array(classinfo *c); +static void linker_compute_class_values(classinfo *c); +static void linker_compute_subclasses(classinfo *c); +static bool linker_addinterface(classinfo *c, classinfo *ic); +static s4 class_highestinterface(classinfo *c); + + +/* linker_init ***************************************************************** + + Initializes the linker subsystem and links classes required for the + primitive table. + +*******************************************************************************/ + +void linker_preinit(void) +{ + TRACESUBSYSTEMINITIALIZATION("linker_preinit"); + + /* Reset interface index. */ + + interfaceindex = 0; + + /* Link the most basic classes. */ + + if (!link_class(class_java_lang_Object)) + vm_abort("linker_preinit: linking java/lang/Object failed"); + +#if defined(ENABLE_JAVASE) + if (!link_class(class_java_lang_Cloneable)) + vm_abort("linker_preinit: linking java/lang/Cloneable failed"); + + if (!link_class(class_java_io_Serializable)) + vm_abort("linker_preinit: linking java/io/Serializable failed"); +#endif +} + + +/* linker_init ***************************************************************** + + Links all classes required in the VM. + +*******************************************************************************/ + +void linker_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("linker_init"); + + /* Link java.lang.Class as first class of the system, because we + need it's vftbl for all other classes so we can use a class as + object. */ + + if (!link_class(class_java_lang_Class)) + vm_abort("linker_init: linking java/lang/Class failed"); + + /* Now set the header.vftbl of all classes which were created + before java.lang.Class was linked. */ + + class_postset_header_vftbl(); + + /* Link primitive-type wrapping classes. */ + +#if defined(ENABLE_JAVASE) + if (!link_class(class_java_lang_Void)) + vm_abort("linker_init: linking failed"); +#endif + + if (!link_class(class_java_lang_Boolean)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Byte)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Character)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Short)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Integer)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Long)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Float)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Double)) + vm_abort("linker_init: linking failed"); + + /* Link important system classes. */ + + if (!link_class(class_java_lang_String)) + vm_abort("linker_init: linking java/lang/String failed"); + +#if defined(ENABLE_JAVASE) + if (!link_class(class_java_lang_ClassLoader)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_SecurityManager)) + vm_abort("linker_init: linking failed"); +#endif + + if (!link_class(class_java_lang_System)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_Thread)) + vm_abort("linker_init: linking failed"); + +#if defined(ENABLE_JAVASE) + if (!link_class(class_java_lang_ThreadGroup)) + vm_abort("linker_init: linking failed"); +#endif + + if (!link_class(class_java_lang_Throwable)) + vm_abort("linker_init: linking failed"); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + if (!link_class(class_java_lang_VMSystem)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_VMThread)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_VMThrowable)) + vm_abort("linker_init: linking failed"); +#endif + + /* Important system exceptions. */ + + if (!link_class(class_java_lang_Exception)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_ClassNotFoundException)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_RuntimeException)) + vm_abort("linker_init: linking failed"); + + /* some classes which may be used more often */ + +#if defined(ENABLE_JAVASE) + if (!link_class(class_java_lang_StackTraceElement)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_reflect_Constructor)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_reflect_Field)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_reflect_Method)) + vm_abort("linker_init: linking failed"); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + if (!link_class(class_java_lang_reflect_VMConstructor)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_reflect_VMField)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_lang_reflect_VMMethod)) + vm_abort("linker_init: linking failed"); +# endif + + if (!link_class(class_java_security_PrivilegedAction)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_util_Vector)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_java_util_HashMap)) + vm_abort("linker_init: linking failed"); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + if (!link_class(class_sun_misc_Signal)) + vm_abort("linker_init: linking failed"); + + if (!link_class(class_sun_reflect_MagicAccessorImpl)) + vm_abort("linker_init: linking failed"); +# endif + + if (!link_class(arrayclass_java_lang_Object)) + vm_abort("linker_init: linking failed"); +#endif + + + /* create pseudo classes used by the typechecker */ + + /* pseudo class for Arraystubs (extends java.lang.Object) */ + + pseudo_class_Arraystub = + class_create_classinfo(utf_new_char("$ARRAYSTUB$")); + pseudo_class_Arraystub->state |= CLASS_LOADED; + pseudo_class_Arraystub->super = class_java_lang_Object; + +#if defined(ENABLE_JAVASE) + + pseudo_class_Arraystub->interfacescount = 2; + pseudo_class_Arraystub->interfaces = MNEW(classinfo*, 2); + pseudo_class_Arraystub->interfaces[0] = class_java_lang_Cloneable; + pseudo_class_Arraystub->interfaces[1] = class_java_io_Serializable; + +#elif defined(ENABLE_JAVAME_CLDC1_1) + + pseudo_class_Arraystub->interfacescount = 0; + pseudo_class_Arraystub->interfaces = NULL; + +#else +# error unknown Java configuration +#endif + + if (!classcache_store_unique(pseudo_class_Arraystub)) + vm_abort("linker_init: could not cache pseudo_class_Arraystub"); + + if (!link_class(pseudo_class_Arraystub)) + vm_abort("linker_init: linking pseudo_class_Arraystub failed"); + + /* pseudo class representing the null type */ + + pseudo_class_Null = class_create_classinfo(utf_new_char("$NULL$")); + pseudo_class_Null->state |= CLASS_LOADED; + pseudo_class_Null->super = class_java_lang_Object; + + if (!classcache_store_unique(pseudo_class_Null)) + vm_abort("linker_init: could not cache pseudo_class_Null"); + + if (!link_class(pseudo_class_Null)) + vm_abort("linker_init: linking failed"); + + /* pseudo class representing new uninitialized objects */ + + pseudo_class_New = class_create_classinfo(utf_new_char("$NEW$")); + pseudo_class_New->state |= CLASS_LOADED; + pseudo_class_New->state |= CLASS_LINKED; /* XXX is this allright? */ + pseudo_class_New->super = class_java_lang_Object; + + if (!classcache_store_unique(pseudo_class_New)) + vm_abort("linker_init: could not cache pseudo_class_New"); + + /* Correct vftbl-entries (retarded loading and linking of class + java/lang/String). */ + + stringtable_update(); +} + + +/* link_class ****************************************************************** + + Wrapper function for link_class_intern to ease monitor enter/exit + and exception handling. + +*******************************************************************************/ + +classinfo *link_class(classinfo *c) +{ + classinfo *r; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_end; +#endif + + RT_TIMING_GET_TIME(time_start); + + if (c == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + LOCK_MONITOR_ENTER(c); + + /* Maybe the class is currently linking or is already linked.*/ + + if ((c->state & CLASS_LINKING) || (c->state & CLASS_LINKED)) { + LOCK_MONITOR_EXIT(c); + + return c; + } + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getcompilingtime) + compilingtime_stop(); + + if (opt_getloadingtime) + loadingtime_start(); +#endif + + /* call the internal function */ + + r = link_class_intern(c); + + /* If return value is NULL, we had a problem and the class is not + linked. */ + + if (r == NULL) + c->state &= ~CLASS_LINKING; + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getloadingtime) + loadingtime_stop(); + + if (opt_getcompilingtime) + compilingtime_start(); +#endif + + LOCK_MONITOR_EXIT(c); + + RT_TIMING_GET_TIME(time_end); + + RT_TIMING_TIME_DIFF(time_start,time_end,RT_TIMING_LINK_TOTAL); + + return r; +} + + +/* linker_overwrite_method ***************************************************** + + Overwrite a method with another one, update method flags and check + assumptions. + + IN: + mg................the general method being overwritten + ms................the overwriting (more specialized) method + wl................worklist where to add invalidated methods + + RETURN VALUE: + true..............everything ok + false.............an exception has been thrown + +*******************************************************************************/ + +static bool linker_overwrite_method(methodinfo *mg, + methodinfo *ms, + method_worklist **wl) +{ + classinfo *cg; + classinfo *cs; + + cg = mg->clazz; + cs = ms->clazz; + + /* overriding a final method is illegal */ + + if (mg->flags & ACC_FINAL) { + exceptions_throw_verifyerror(mg, "Overriding final method"); + return false; + } + + /* method ms overwrites method mg */ + +#if defined(ENABLE_VERIFIER) + /* Add loading constraints (for the more general types of method mg). */ + /* Not for , as it is not invoked virtually. */ + + if ((ms->name != utf_init) + && !classcache_add_constraints_for_params( + cs->classloader, cg->classloader, mg)) + { + return false; + } +#endif + + /* inherit the vftbl index, and record the overwriting */ + + ms->vftblindex = mg->vftblindex; + ms->overwrites = mg; + + /* update flags and check assumptions */ + /* methods are a special case, as they are never dispatched dynamically */ + + if ((ms->flags & ACC_METHOD_IMPLEMENTED) && ms->name != utf_init) { + do { + +#if defined(ENABLE_TLH) + if (mg->flags & ACC_METHOD_MONOMORPHY_USED) { + printf("%s/%s is evil! the siner is %s/%s\n", mg->clazz->name->text, mg->name->text, + ms->clazz->name->text, ms->name->text); + ms->flags |= ACC_METHOD_PARENT_MONOMORPHY_USED; + } +#endif + + if (mg->flags & ACC_METHOD_IMPLEMENTED) { + /* this adds another implementation */ + + mg->flags &= ~ACC_METHOD_MONOMORPHIC; + + INLINELOG( printf("becomes polymorphic: "); method_println(mg); ); + + method_break_assumption_monomorphic(mg, wl); + } + else { + /* this is the first implementation */ + + mg->flags |= ACC_METHOD_IMPLEMENTED; + + INLINELOG( printf("becomes implemented: "); method_println(mg); ); + } + + ms = mg; + mg = mg->overwrites; + } while (mg != NULL); + } + + return true; +} + + +/* link_class_intern *********************************************************** + + Tries to link a class. The function calculates the length in bytes + that an instance of this class requires as well as the VTBL for + methods and interface methods. + +*******************************************************************************/ + +static int build_display_inner(classinfo *topc, classinfo *c, int i) +{ + int depth; + if (!c) + return 0; + do { + if (c->vftbl->arraydesc) + { + arraydescriptor *a = c->vftbl->arraydesc; + if (a->elementvftbl && a->elementvftbl->clazz->super) + { + classinfo *cls = a->elementvftbl->clazz->super; + int n; + for (n=0; ndimension; n++) + cls = class_array_of(cls, true); + depth = build_display_inner(topc, cls, i+1); + break; + } + if (a->componentvftbl && a->elementvftbl) + { + depth = build_display_inner(topc, a->componentvftbl->clazz, i+1); + break; + } + } + depth = build_display_inner(topc, c->super, i+1); + } while (false); + if (depth >= DISPLAY_SIZE) + { + if (depth == DISPLAY_SIZE) + { + topc->vftbl->subtype_overflow = malloc(sizeof(void*) * (i+1)); +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_vftbl_len += sizeof(void*) * (i+1); +#endif + } + topc->vftbl->subtype_overflow[depth - DISPLAY_SIZE] = c->vftbl; + return depth + 1; + } + topc->vftbl->subtype_display[depth] = c->vftbl; + return depth + 1; +} + +static void build_display(classinfo *c) +{ + int depth; + int i; + + depth = build_display_inner(c, c, 0) - 1; + c->vftbl->subtype_depth = depth; + if (depth >= DISPLAY_SIZE) + { + c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[DISPLAY_SIZE]); + } + else + { + c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[0]) + sizeof(void*) * depth; + for (i=depth+1; i<=DISPLAY_SIZE; i++) + c->vftbl->subtype_display[i] = NULL; + } +} + +static classinfo *link_class_intern(classinfo *c) +{ + classinfo *super; /* super class */ + classinfo *tc; /* temporary class variable */ + s4 supervftbllength; /* vftbllegnth of super class */ + s4 vftbllength; /* vftbllength of current class */ + s4 interfacetablelength; /* interface table length */ + vftbl_t *v; /* vftbl of current class */ + s4 i; /* interface/method/field counter */ + arraydescriptor *arraydesc; /* descriptor for array classes */ + method_worklist *worklist; /* worklist for recompilation */ +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_resolving, time_compute_vftbl, + time_abstract, time_compute_iftbl, time_fill_vftbl, + time_offsets, time_fill_iftbl, time_finalizer, + time_subclasses; +#endif + + RT_TIMING_GET_TIME(time_start); + + TRACELINKCLASS(c); + + /* the class must be loaded */ + + /* XXX should this be a specific exception? */ + assert(c->state & CLASS_LOADED); + + /* This is check in link_class. */ + + assert(!(c->state & CLASS_LINKED)); + + /* cache the self-reference of this class */ + /* we do this for cases where the defining loader of the class */ + /* has not yet been recorded as an initiating loader for the class */ + /* this is needed so subsequent code can assume that self-refs */ + /* will always resolve lazily */ + /* No need to do it for the bootloader - it is always registered */ + /* as initiating loader for the classes it loads. */ + if (c->classloader) + classcache_store(c->classloader,c,false); + + /* this class is currently linking */ + + c->state |= CLASS_LINKING; + + arraydesc = NULL; + worklist = NULL; + + /* Link the super interfaces. */ + + for (i = 0; i < c->interfacescount; i++) { + tc = c->interfaces[i]; + + if (!(tc->state & CLASS_LINKED)) + if (!link_class(tc)) + return NULL; + } + + /* check super class */ + + super = NULL; + + /* Check for java/lang/Object. */ + + if (c->super == NULL) { + c->index = 0; + c->instancesize = sizeof(java_object_t); + + vftbllength = supervftbllength = 0; + + c->finalizer = NULL; + } + else { + /* Get super class. */ + + super = c->super; + + /* Link the super class if necessary. */ + + if (!(super->state & CLASS_LINKED)) + if (!link_class(super)) + return NULL; + + /* OR the ACC_CLASS_HAS_POINTERS and the ACC_CLASS_REFERENCE_* + flags. */ + + c->flags |= (super->flags & + (ACC_CLASS_HAS_POINTERS | ACC_CLASS_REFERENCE_MASK)); + + /* handle array classes */ + + if (c->name->text[0] == '[') + if (!(arraydesc = link_array(c))) + return NULL; + + if (c->flags & ACC_INTERFACE) + c->index = interfaceindex++; + else + c->index = super->index + 1; + + c->instancesize = super->instancesize; + + vftbllength = supervftbllength = super->vftbl->vftbllength; + + c->finalizer = super->finalizer; + } + RT_TIMING_GET_TIME(time_resolving); + + + /* compute vftbl length */ + + for (i = 0; i < c->methodscount; i++) { + methodinfo *m = &(c->methods[i]); + + if (!(m->flags & ACC_STATIC)) { /* is instance method */ + tc = super; + + while (tc) { + s4 j; + + for (j = 0; j < tc->methodscount; j++) { + if (method_canoverwrite(m, &(tc->methods[j]))) { + if (tc->methods[j].flags & ACC_PRIVATE) + goto notfoundvftblindex; + + /* package-private methods in other packages */ + /* must not be overridden */ + /* (see Java Language Specification 8.4.8.1) */ + if ( !(tc->methods[j].flags & (ACC_PUBLIC | ACC_PROTECTED)) + && !SAME_PACKAGE(c,tc) ) + { + goto notfoundvftblindex; + } + + if (!linker_overwrite_method(&(tc->methods[j]), m, &worklist)) + return NULL; + + goto foundvftblindex; + } + } + + tc = tc->super; + } + + notfoundvftblindex: + m->vftblindex = (vftbllength++); + foundvftblindex: + ; + } + } + RT_TIMING_GET_TIME(time_compute_vftbl); + + + /* Check all interfaces of an abstract class (maybe be an + interface too) for unimplemented methods. Such methods are + called miranda-methods and are marked with the ACC_MIRANDA + flag. VMClass.getDeclaredMethods does not return such + methods. */ + + if (c->flags & ACC_ABSTRACT) { + classinfo *ic; + methodinfo *im; + s4 abstractmethodscount; + s4 j; + s4 k; + + abstractmethodscount = 0; + + /* check all interfaces of the abstract class */ + + for (i = 0; i < c->interfacescount; i++) { + ic = c->interfaces[i]; + + for (j = 0; j < ic->methodscount; j++) { + im = &(ic->methods[j]); + + /* skip `' and `' */ + + if ((im->name == utf_clinit) || (im->name == utf_init)) + continue; + + for (tc = c; tc != NULL; tc = tc->super) { + for (k = 0; k < tc->methodscount; k++) { + if (method_canoverwrite(im, &(tc->methods[k]))) + goto noabstractmethod; + } + } + + abstractmethodscount++; + + noabstractmethod: + ; + } + } + + if (abstractmethodscount > 0) { + methodinfo *am; + + /* reallocate methods memory */ + + c->methods = MREALLOC(c->methods, methodinfo, c->methodscount, + c->methodscount + abstractmethodscount); + + for (i = 0; i < c->interfacescount; i++) { + ic = c->interfaces[i]; + + for (j = 0; j < ic->methodscount; j++) { + im = &(ic->methods[j]); + + /* skip `' and `' */ + + if ((im->name == utf_clinit) || (im->name == utf_init)) + continue; + + for (tc = c; tc != NULL; tc = tc->super) { + for (k = 0; k < tc->methodscount; k++) { + if (method_canoverwrite(im, &(tc->methods[k]))) + goto noabstractmethod2; + } + } + + /* Copy the method found into the new c->methods + array and tag it as miranda-method. */ + + am = &(c->methods[c->methodscount]); + c->methodscount++; + + MCOPY(am, im, methodinfo, 1); + + am->vftblindex = (vftbllength++); + am->clazz = c; + am->flags |= ACC_MIRANDA; + + noabstractmethod2: + ; + } + } + } + } + RT_TIMING_GET_TIME(time_abstract); + + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_vftbl_len += + sizeof(vftbl_t) + (sizeof(methodptr) * (vftbllength - 1)); +#endif + + /* compute interfacetable length */ + + interfacetablelength = 0; + + for (tc = c; tc != NULL; tc = tc->super) { + for (i = 0; i < tc->interfacescount; i++) { + s4 h = class_highestinterface(tc->interfaces[i]) + 1; + + if (h > interfacetablelength) + interfacetablelength = h; + } + } + RT_TIMING_GET_TIME(time_compute_iftbl); + + /* allocate virtual function table */ + + v = (vftbl_t *) mem_alloc(sizeof(vftbl_t) + + sizeof(methodptr) * (vftbllength - 1) + + sizeof(methodptr*) * (interfacetablelength - (interfacetablelength > 0))); + v = (vftbl_t *) (((methodptr *) v) + + (interfacetablelength - 1) * (interfacetablelength > 1)); + + c->vftbl = v; + v->clazz = c; + v->vftbllength = vftbllength; + v->interfacetablelength = interfacetablelength; + v->arraydesc = arraydesc; + + /* store interface index in vftbl */ + + if (c->flags & ACC_INTERFACE) + v->baseval = -(c->index); + + /* copy virtual function table of super class */ + + for (i = 0; i < supervftbllength; i++) + v->table[i] = super->vftbl->table[i]; + + /* Fill the remaining vftbl slots with the AbstractMethodError + stub (all after the super class slots, because they are already + initialized). */ + + for (; i < vftbllength; i++) { +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) + v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror; + else +# endif + v->table[i] = (methodptr) (ptrint) &asm_abstractmethoderror; +#else + v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror; +#endif + } + + /* add method stubs into virtual function table */ + + for (i = 0; i < c->methodscount; i++) { + methodinfo *m = &(c->methods[i]); + + assert(m->stubroutine == NULL); + + /* Don't create a compiler stub for abstract methods as they + throw an AbstractMethodError with the default stub in the + vftbl. This entry is simply copied by sub-classes. */ + + if (m->flags & ACC_ABSTRACT) + continue; + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) + m->stubroutine = intrp_createcompilerstub(m); + else +#endif + m->stubroutine = CompilerStub_generate(m); +#else + m->stubroutine = intrp_createcompilerstub(m); +#endif + + /* static methods are not in the vftbl */ + + if (m->flags & ACC_STATIC) + continue; + + /* insert the stubroutine into the vftbl */ + + v->table[m->vftblindex] = (methodptr) (ptrint) m->stubroutine; + } + RT_TIMING_GET_TIME(time_fill_vftbl); + + /* compute instance size and offset of each field */ + + for (i = 0; i < c->fieldscount; i++) { + s4 dsize; + fieldinfo *f = &(c->fields[i]); + + if (!(f->flags & ACC_STATIC)) { + dsize = descriptor_typesize(f->parseddesc); + c->instancesize = MEMORY_ALIGN(c->instancesize, dsize); + f->offset = c->instancesize; + c->instancesize += dsize; + } + } + RT_TIMING_GET_TIME(time_offsets); + + /* initialize interfacetable and interfacevftbllength */ + + v->interfacevftbllength = MNEW(s4, interfacetablelength); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_vftbl_len += (4 + sizeof(s4)) * v->interfacetablelength; +#endif + + for (i = 0; i < interfacetablelength; i++) { + v->interfacevftbllength[i] = 0; + v->interfacetable[-i] = NULL; + } + + /* add interfaces */ + + for (tc = c; tc != NULL; tc = tc->super) + for (i = 0; i < tc->interfacescount; i++) + if (!linker_addinterface(c, tc->interfaces[i])) + return NULL; + + RT_TIMING_GET_TIME(time_fill_iftbl); + + /* add finalizer method (not for java.lang.Object) */ + + if (super) { + methodinfo *fi; + + fi = class_findmethod(c, utf_finalize, utf_void__void); + + if (fi) + if (!(fi->flags & ACC_STATIC)) + c->finalizer = fi; + } + RT_TIMING_GET_TIME(time_finalizer); + + /* final tasks */ + + linker_compute_subclasses(c); + + /* FIXME: this is completely useless now */ + RT_TIMING_GET_TIME(time_subclasses); + + build_display(c); + + /* revert the linking state and class is linked */ + + c->state = (c->state & ~CLASS_LINKING) | CLASS_LINKED; + + /* check worklist */ + + /* XXX must this also be done in case of exception? */ + + while (worklist != NULL) { + method_worklist *wi = worklist; + + worklist = worklist->next; + + INLINELOG( printf("MUST BE RECOMPILED: "); method_println(wi->m); ); + jit_invalidate_code(wi->m); + + /* XXX put worklist into dump memory? */ + FREE(wi, method_worklist); + } + + RT_TIMING_TIME_DIFF(time_start ,time_resolving ,RT_TIMING_LINK_RESOLVE); + RT_TIMING_TIME_DIFF(time_resolving ,time_compute_vftbl,RT_TIMING_LINK_C_VFTBL); + RT_TIMING_TIME_DIFF(time_compute_vftbl,time_abstract ,RT_TIMING_LINK_ABSTRACT); + RT_TIMING_TIME_DIFF(time_abstract ,time_compute_iftbl,RT_TIMING_LINK_C_IFTBL); + RT_TIMING_TIME_DIFF(time_compute_iftbl,time_fill_vftbl ,RT_TIMING_LINK_F_VFTBL); + RT_TIMING_TIME_DIFF(time_fill_vftbl ,time_offsets ,RT_TIMING_LINK_OFFSETS); + RT_TIMING_TIME_DIFF(time_offsets ,time_fill_iftbl ,RT_TIMING_LINK_F_IFTBL); + RT_TIMING_TIME_DIFF(time_fill_iftbl ,time_finalizer ,RT_TIMING_LINK_FINALIZER); + RT_TIMING_TIME_DIFF(time_finalizer ,time_subclasses ,RT_TIMING_LINK_SUBCLASS); + + /* just return c to show that we didn't had a problem */ + + return c; +} + + +/* link_array ****************************************************************** + + This function is called by link_class to create the arraydescriptor + for an array class. + + This function returns NULL if the array cannot be linked because + the component type has not been linked yet. + +*******************************************************************************/ + +static arraydescriptor *link_array(classinfo *c) +{ + classinfo *comp; + s4 namelen; + arraydescriptor *desc; + vftbl_t *compvftbl; + utf *u; + + comp = NULL; + namelen = c->name->blength; + + /* Check the component type */ + + switch (c->name->text[1]) { + case '[': + /* c is an array of arrays. */ + u = utf_new(c->name->text + 1, namelen - 1); + if (!(comp = load_class_from_classloader(u, c->classloader))) + return NULL; + break; + + case 'L': + /* c is an array of objects. */ + u = utf_new(c->name->text + 2, namelen - 3); + if (!(comp = load_class_from_classloader(u, c->classloader))) + return NULL; + break; + } + + /* If the component type has not been linked, link it now */ + + assert(!comp || (comp->state & CLASS_LOADED)); + + if (comp && !(comp->state & CLASS_LINKED)) + if (!link_class(comp)) + return NULL; + + /* Allocate the arraydescriptor */ + + desc = NEW(arraydescriptor); + + if (comp) { + /* c is an array of references */ + desc->arraytype = ARRAYTYPE_OBJECT; + desc->componentsize = sizeof(void*); + desc->dataoffset = OFFSET(java_objectarray_t, data); + + compvftbl = comp->vftbl; + + if (!compvftbl) { + log_text("Component class has no vftbl"); + assert(0); + } + + desc->componentvftbl = compvftbl; + + if (compvftbl->arraydesc) { + desc->elementvftbl = compvftbl->arraydesc->elementvftbl; + + if (compvftbl->arraydesc->dimension >= 255) { + log_text("Creating array of dimension >255"); + assert(0); + } + + desc->dimension = compvftbl->arraydesc->dimension + 1; + desc->elementtype = compvftbl->arraydesc->elementtype; + + } else { + desc->elementvftbl = compvftbl; + desc->dimension = 1; + desc->elementtype = ARRAYTYPE_OBJECT; + } + + } else { + /* c is an array of a primitive type */ + switch (c->name->text[1]) { + case 'Z': + desc->arraytype = ARRAYTYPE_BOOLEAN; + desc->dataoffset = OFFSET(java_booleanarray_t,data); + desc->componentsize = sizeof(u1); + break; + + case 'B': + desc->arraytype = ARRAYTYPE_BYTE; + desc->dataoffset = OFFSET(java_bytearray_t,data); + desc->componentsize = sizeof(u1); + break; + + case 'C': + desc->arraytype = ARRAYTYPE_CHAR; + desc->dataoffset = OFFSET(java_chararray_t,data); + desc->componentsize = sizeof(u2); + break; + + case 'D': + desc->arraytype = ARRAYTYPE_DOUBLE; + desc->dataoffset = OFFSET(java_doublearray_t,data); + desc->componentsize = sizeof(double); + break; + + case 'F': + desc->arraytype = ARRAYTYPE_FLOAT; + desc->dataoffset = OFFSET(java_floatarray_t,data); + desc->componentsize = sizeof(float); + break; + + case 'I': + desc->arraytype = ARRAYTYPE_INT; + desc->dataoffset = OFFSET(java_intarray_t,data); + desc->componentsize = sizeof(s4); + break; + + case 'J': + desc->arraytype = ARRAYTYPE_LONG; + desc->dataoffset = OFFSET(java_longarray_t,data); + desc->componentsize = sizeof(s8); + break; + + case 'S': + desc->arraytype = ARRAYTYPE_SHORT; + desc->dataoffset = OFFSET(java_shortarray_t,data); + desc->componentsize = sizeof(s2); + break; + + default: + exceptions_throw_noclassdeffounderror(c->name); + return NULL; + } + + desc->componentvftbl = NULL; + desc->elementvftbl = NULL; + desc->dimension = 1; + desc->elementtype = desc->arraytype; + } + + return desc; +} + + +/* linker_compute_subclasses *************************************************** + + XXX + + ATTENTION: DO NOT REMOVE ANY OF THE LOCKING MECHANISMS BELOW: + This function needs to take the class renumber lock and stop the + world during class renumbering. The lock is used in C code which + is not that performance critical. Whereas JIT code uses critical + sections to atomically access the class values. + +*******************************************************************************/ + +static void linker_compute_subclasses(classinfo *c) +{ + + if (!(c->flags & ACC_INTERFACE)) { + c->nextsub = NULL; + c->sub = NULL; + c->vftbl->baseval = 1; /* so it does not look like an interface */ + } + + if (!(c->flags & ACC_INTERFACE) && (c->super != NULL)) { + c->nextsub = c->super->sub; + c->super->sub = c; + } + + classvalue = 0; + +} + + +/* linker_compute_class_values ************************************************* + + XXX + +*******************************************************************************/ + +static void linker_compute_class_values(classinfo *c) +{ + classinfo *subs; + + c->vftbl->baseval = ++classvalue; + + subs = c->sub; + + while (subs) { + linker_compute_class_values(subs); + + subs = subs->nextsub; + } + + c->vftbl->diffval = classvalue - c->vftbl->baseval; +} + + +/* linker_addinterface ********************************************************* + + Is needed by link_class for adding a VTBL to a class. All + interfaces implemented by ic are added as well. + + RETURN VALUE: + true.........everything ok + false........an exception has been thrown + +*******************************************************************************/ + +static bool linker_addinterface(classinfo *c, classinfo *ic) +{ + s4 j, k; + vftbl_t *v; + s4 i; + classinfo *sc; + methodinfo *m; + + v = c->vftbl; + i = ic->index; + + if (i >= v->interfacetablelength) + vm_abort("Internal error: interfacetable overflow"); + + /* if this interface has already been added, return immediately */ + + if (v->interfacetable[-i] != NULL) + return true; + + if (ic->methodscount == 0) { /* fake entry needed for subtype test */ + v->interfacevftbllength[i] = 1; + v->interfacetable[-i] = MNEW(methodptr, 1); + v->interfacetable[-i][0] = NULL; + } + else { + v->interfacevftbllength[i] = ic->methodscount; + v->interfacetable[-i] = MNEW(methodptr, ic->methodscount); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_vftbl_len += sizeof(methodptr) * + (ic->methodscount + (ic->methodscount == 0)); +#endif + + for (j = 0; j < ic->methodscount; j++) { + for (sc = c; sc != NULL; sc = sc->super) { + for (k = 0; k < sc->methodscount; k++) { + m = &(sc->methods[k]); + + if (method_canoverwrite(m, &(ic->methods[j]))) { + /* method m overwrites the (abstract) method */ +#if defined(ENABLE_VERIFIER) + /* Add loading constraints (for the more + general types of the method + ic->methods[j]). */ + if (!classcache_add_constraints_for_params( + c->classloader, ic->classloader, + &(ic->methods[j]))) + { + return false; + } +#endif + + /* XXX taken from gcj */ + /* check for ACC_STATIC: IncompatibleClassChangeError */ + + /* check for !ACC_PUBLIC: IllegalAccessError */ + + /* check for ACC_ABSTRACT: AbstracMethodError, + not sure about that one */ + + v->interfacetable[-i][j] = v->table[m->vftblindex]; + goto foundmethod; + } + } + } + + /* If no method was found, insert the AbstractMethodError + stub. */ + +#if defined(ENABLE_JIT) +# if defined(ENABLE_INTRP) + if (opt_intrp) + v->interfacetable[-i][j] = + (methodptr) (ptrint) &intrp_asm_abstractmethoderror; + else +# endif + v->interfacetable[-i][j] = + (methodptr) (ptrint) &asm_abstractmethoderror; +#else + v->interfacetable[-i][j] = + (methodptr) (ptrint) &intrp_asm_abstractmethoderror; +#endif + + foundmethod: + ; + } + } + + /* add superinterfaces of this interface */ + + for (j = 0; j < ic->interfacescount; j++) + if (!linker_addinterface(c, ic->interfaces[j])) + return false; + + /* everything ok */ + + return true; +} + + +/* class_highestinterface ****************************************************** + + Used by the function link_class to determine the amount of memory + needed for the interface table. + +*******************************************************************************/ + +static s4 class_highestinterface(classinfo *c) +{ + s4 h; + s4 h2; + s4 i; + + /* check for ACC_INTERFACE bit already done in link_class_intern */ + + h = c->index; + + for (i = 0; i < c->interfacescount; i++) { + h2 = class_highestinterface(c->interfaces[i]); + + if (h2 > h) + h = h2; + } + + return h; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/linker.h b/src/vm/linker.h new file mode 100644 index 000000000..b9dc1876f --- /dev/null +++ b/src/vm/linker.h @@ -0,0 +1,172 @@ +/* src/vm/linker.h - class linker header + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _LINKER_H +#define _LINKER_H + +/* forward typedefs ***********************************************************/ + +typedef struct _vftbl vftbl_t; +typedef struct arraydescriptor arraydescriptor; +typedef struct primitivetypeinfo primitivetypeinfo; + + +#include "config.h" +#include "vm/types.h" + +#include "threads/mutex.hpp" + +#include "vm/class.h" +#include "vm/references.h" + + +/* virtual function table ****************************************************** + + The vtbl has a bidirectional layout with open ends at both sides. + interfacetablelength gives the number of entries of the interface + table at the start of the vftbl. The vftbl pointer points to + &interfacetable[0]. vftbllength gives the number of entries of + table at the end of the vftbl. + + runtime type check (checkcast): + + Different methods are used for runtime type check depending on the + argument of checkcast/instanceof. + + A check against a class is implemented via relative numbering on + the class hierachy tree. The tree is numbered in a depth first + traversal setting the base field and the diff field. The diff field + gets the result of (high - base) so that a range check can be + implemented by an unsigned compare. A sub type test is done by + checking the inclusion of base of the sub class in the range of the + superclass. + + A check against an interface is implemented via the + interfacevftbl. If the interfacevftbl contains a nonnull value a + class is a subclass of this interface. + + interfacetable: + + Like standard virtual methods interface methods are called using + virtual function tables. All interfaces are numbered sequentially + (starting with zero). For each class there exist an interface table + of virtual function tables for each implemented interface. The + length of the interface table is determined by the highest number + of an implemented interface. + + The following example assumes a class which implements interface 0 and 3: + + interfacetablelength = 4 + + | ... | +----------+ + +-----------+ | method 2 |---> method z + | class | | method 1 |---> method y + +-----------+ | method 0 |---> method x + | ivftbl 0 |----------> +----------+ + vftblptr ---> +-----------+ + | ivftbl -1 |--> NULL +----------+ + | ivftbl -2 |--> NULL | method 1 |---> method x + | ivftbl -3 |-----+ | method 0 |---> method a + +-----------+ +----> +----------+ + + +---------------+ + | length 3 = 2 | + | length 2 = 0 | + | length 1 = 0 | + | length 0 = 3 | + interfacevftbllength ---> +---------------+ + +*******************************************************************************/ + +#define DISPLAY_SIZE 4 + +struct _vftbl { + methodptr *interfacetable[1]; /* interface table (access via macro) */ + classinfo *clazz; /* class, the vtbl belongs to */ + arraydescriptor *arraydesc; /* for array classes, otherwise NULL */ + s4 vftbllength; /* virtual function table length */ + s4 interfacetablelength; /* interface table length */ + s4 baseval; /* base for runtime type check */ + /* (-index for interfaces) */ + s4 diffval; /* high - base for runtime type check */ + + s4 subtype_depth; + s4 subtype_offset; + struct _vftbl *subtype_display[DISPLAY_SIZE+1]; /* the last one is cache */ + struct _vftbl **subtype_overflow; + + s4 *interfacevftbllength; /* length of interface vftbls */ + methodptr table[1]; /* class vftbl */ +}; + + +/* arraydescriptor ************************************************************* + + For every array class an arraydescriptor is allocated which + describes the array class. The arraydescriptor is referenced from + the vftbl of the array class. + +*******************************************************************************/ + +struct arraydescriptor { + vftbl_t *componentvftbl; /* vftbl of the component type, NULL for primit. */ + vftbl_t *elementvftbl; /* vftbl of the element type, NULL for primitive */ + s2 arraytype; /* ARRAYTYPE_* constant */ + s2 dimension; /* dimension of the array (always >= 1) */ + s4 dataoffset; /* offset of the array data from object pointer */ + s4 componentsize; /* size of a component in bytes */ + s2 elementtype; /* ARRAYTYPE_* constant */ +}; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +void linker_preinit(void); +void linker_init(void); +classinfo *link_class(classinfo *c); + +#ifdef __cplusplus +} +#endif + +#endif /* _LINKER_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/loader.cpp b/src/vm/loader.cpp new file mode 100644 index 000000000..6c43e927a --- /dev/null +++ b/src/vm/loader.cpp @@ -0,0 +1,2221 @@ +/* src/vm/loader.cpp - class loader functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "vm/types.h" + +#include "mm/dumpmemory.hpp" +#include "mm/memory.h" + +#include "native/llni.h" + +#include "threads/mutex.hpp" + +#include "toolbox/hashtable.h" +#include "toolbox/logging.h" + +#include "vm/jit/builtin.hpp" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/package.hpp" +#include "vm/primitive.hpp" +#include "vm/resolve.h" +#include "vm/rt-timing.h" +#include "vm/string.hpp" +#include "vm/suck.hpp" +#include "vm/vm.hpp" + + +#if defined(ENABLE_JAVASE) +# include "vm/annotation.h" +# include "vm/stackmap.h" +#endif + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#if defined(ENABLE_ZLIB) +# include "vm/zip.h" +#endif + +#include "vm/jit/stubs.hpp" + +#if defined(ENABLE_JVMTI) +# include "native/jvmti/cacaodbg.h" +#endif + + +/* global variables ***********************************************************/ + +static hashtable *hashtable_classloader; + + +/* loader_preinit ************************************************************** + + Initializes the classpath list and loads classes required for the + primitive table. + + NOTE: Exceptions thrown during VM initialization are caught in the + exception functions themselves. + +*******************************************************************************/ + +void loader_preinit(void) +{ +#if defined(ENABLE_THREADS) + list_classpath_entry *lce; +#endif + + TRACESUBSYSTEMINITIALIZATION("loader_preinit"); + +#if defined(ENABLE_THREADS) + /* Initialize the monitor pointer for zip/jar file locking. */ + + for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL; + lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) { + if (lce->type == CLASSPATH_ARCHIVE) + lce->mutex = new Mutex(); + } +#endif + + /* initialize classloader hashtable, 10 entries should be enough */ + + hashtable_classloader = NEW(hashtable); + hashtable_create(hashtable_classloader, 10); + + /* Load the most basic classes. */ + + assert(VM::get_current()->is_initializing() == true); + + class_java_lang_Object = load_class_bootstrap(utf_java_lang_Object); + +#if defined(ENABLE_JAVASE) + class_java_lang_Cloneable = load_class_bootstrap(utf_java_lang_Cloneable); + class_java_io_Serializable = load_class_bootstrap(utf_java_io_Serializable); +#endif +} + + +/* loader_init ***************************************************************** + + Loads all classes required in the VM. + + NOTE: Exceptions thrown during VM initialization are caught in the + exception functions themselves. + +*******************************************************************************/ + +void loader_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("loader_init"); + + /* Load primitive-type wrapping classes. */ + + assert(VM::get_current()->is_initializing() == true); + +#if defined(ENABLE_JAVASE) + class_java_lang_Void = load_class_bootstrap(utf_java_lang_Void); +#endif + + class_java_lang_Boolean = load_class_bootstrap(utf_java_lang_Boolean); + class_java_lang_Byte = load_class_bootstrap(utf_java_lang_Byte); + class_java_lang_Character = load_class_bootstrap(utf_java_lang_Character); + class_java_lang_Short = load_class_bootstrap(utf_java_lang_Short); + class_java_lang_Integer = load_class_bootstrap(utf_java_lang_Integer); + class_java_lang_Long = load_class_bootstrap(utf_java_lang_Long); + class_java_lang_Float = load_class_bootstrap(utf_java_lang_Float); + class_java_lang_Double = load_class_bootstrap(utf_java_lang_Double); + + /* Load important system classes. */ + + class_java_lang_Class = load_class_bootstrap(utf_java_lang_Class); + class_java_lang_String = load_class_bootstrap(utf_java_lang_String); + +#if defined(ENABLE_JAVASE) + class_java_lang_ClassLoader = + load_class_bootstrap(utf_java_lang_ClassLoader); + + class_java_lang_SecurityManager = + load_class_bootstrap(utf_java_lang_SecurityManager); +#endif + + class_java_lang_System = + load_class_bootstrap(utf_new_char("java/lang/System")); + + class_java_lang_Thread = + load_class_bootstrap(utf_new_char("java/lang/Thread")); + +#if defined(ENABLE_JAVASE) + class_java_lang_ThreadGroup = + load_class_bootstrap(utf_java_lang_ThreadGroup); +#endif + + class_java_lang_Throwable = load_class_bootstrap(utf_java_lang_Throwable); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + class_java_lang_VMSystem = + load_class_bootstrap(utf_new_char("java/lang/VMSystem")); + + class_java_lang_VMThread = + load_class_bootstrap(utf_new_char("java/lang/VMThread")); + + class_java_lang_VMThrowable = + load_class_bootstrap(utf_new_char("java/lang/VMThrowable")); +#endif + + /* Important system exceptions. */ + + class_java_lang_Exception = load_class_bootstrap(utf_java_lang_Exception); + + class_java_lang_ClassNotFoundException = + load_class_bootstrap(utf_java_lang_ClassNotFoundException); + + class_java_lang_RuntimeException = + load_class_bootstrap(utf_java_lang_RuntimeException); + + /* Some classes which may be used often. */ + +#if defined(ENABLE_JAVASE) + class_java_lang_StackTraceElement = load_class_bootstrap(utf_java_lang_StackTraceElement); + + class_java_lang_reflect_Constructor = load_class_bootstrap(utf_java_lang_reflect_Constructor); + class_java_lang_reflect_Field = load_class_bootstrap(utf_java_lang_reflect_Field); + class_java_lang_reflect_Method = load_class_bootstrap(utf_java_lang_reflect_Method); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + class_java_lang_reflect_VMConstructor = load_class_bootstrap(utf_java_lang_reflect_VMConstructor); + class_java_lang_reflect_VMField = load_class_bootstrap(utf_java_lang_reflect_VMField); + class_java_lang_reflect_VMMethod = load_class_bootstrap(utf_java_lang_reflect_VMMethod); +# endif + + class_java_security_PrivilegedAction = load_class_bootstrap(utf_new_char("java/security/PrivilegedAction")); + + class_java_util_HashMap = load_class_bootstrap(utf_new_char("java/util/HashMap")); + class_java_util_Vector = load_class_bootstrap(utf_java_util_Vector); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + class_sun_misc_Signal = load_class_bootstrap(utf_new_char("sun/misc/Signal")); + class_sun_reflect_MagicAccessorImpl = load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl")); +# endif + + arrayclass_java_lang_Object = + load_class_bootstrap(utf_new_char("[Ljava/lang/Object;")); + +# if defined(ENABLE_ANNOTATIONS) + /* needed by annotation support */ + class_sun_reflect_ConstantPool = + load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool")); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + /* needed by GNU Classpaths annotation support */ + class_sun_reflect_annotation_AnnotationParser = + load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser")); +# endif +# endif +#endif +} + + +/* loader_hashtable_classloader_add ******************************************** + + Adds an entry to the classloader hashtable. + + REMEMBER: Also use this to register native loaders! + +*******************************************************************************/ + +classloader_t *loader_hashtable_classloader_add(java_handle_t *cl) +{ + hashtable_classloader_entry *cle; + u4 key; + u4 slot; + + if (cl == NULL) + return NULL; + + hashtable_classloader->mutex->lock(); + + LLNI_CRITICAL_START; + + /* key for entry is the hashcode of the classloader; + aligned to 16-byte boundaries */ + + key = heap_hashcode(LLNI_DIRECT(cl)) >> 4; + slot = key & (hashtable_classloader->size - 1); + cle = (hashtable_classloader_entry*) hashtable_classloader->ptr[slot]; + + /* search hashchain for existing entry */ + + while (cle) { + if (cle->object == LLNI_DIRECT(cl)) + break; + + cle = cle->hashlink; + } + + LLNI_CRITICAL_END; + + /* if no classloader was found, we create a new entry here */ + + if (cle == NULL) { + cle = NEW(hashtable_classloader_entry); + +#if defined(ENABLE_GC_CACAO) + /* register the classloader object with the GC */ + + gc_reference_register(&(cle->object), GC_REFTYPE_CLASSLOADER); +#endif + + LLNI_CRITICAL_START; + + cle->object = LLNI_DIRECT(cl); + + LLNI_CRITICAL_END; + +/*#define LOADER_DEBUG_CLASSLOADER*/ +#ifdef LOADER_DEBUG_CLASSLOADER + printf("CLASSLOADER: adding new classloader entry %p for %p: ", cle, cl); + class_print(LLNI_vftbl_direct(cl)->class); + printf("\n"); + fflush(stdout); +#endif + + /* insert entry into hashtable */ + + cle->hashlink = (hashtable_classloader_entry*) hashtable_classloader->ptr[slot]; + hashtable_classloader->ptr[slot] = cle; + + /* update number of entries */ + + hashtable_classloader->entries++; + } + + hashtable_classloader->mutex->unlock(); + +#if defined(ENABLE_HANDLES) + return cle; +#else + return cl; +#endif +} + + +/* loader_hashtable_classloader_find ******************************************* + + Find an entry in the classloader hashtable. + +*******************************************************************************/ + +classloader_t *loader_hashtable_classloader_find(java_handle_t *cl) +{ + hashtable_classloader_entry *cle; + u4 key; + u4 slot; + + if (cl == NULL) + return NULL; + + LLNI_CRITICAL_START; + + /* key for entry is the hashcode of the classloader; + aligned to 16-byte boundaries */ + + key = heap_hashcode(LLNI_DIRECT(cl)) >> 4; + slot = key & (hashtable_classloader->size - 1); + cle = (hashtable_classloader_entry*) hashtable_classloader->ptr[slot]; + + /* search hashchain for existing entry */ + + while (cle) { + if (cle->object == LLNI_DIRECT(cl)) + break; + + cle = cle->hashlink; + } + +#ifdef LOADER_DEBUG_CLASSLOADER + if (cle == NULL) { + printf("CLASSLOADER: unable to find classloader entry for %p: ", cl); + class_print(LLNI_vftbl_direct(cl)->class); + printf("\n"); + fflush(stdout); + } +#endif + + LLNI_CRITICAL_END; + +#if defined(ENABLE_HANDLES) + return cle; +#else + return cl; +#endif +} + + +/* loader_load_all_classes ***************************************************** + + Loads all classes specified in the BOOTCLASSPATH. + +*******************************************************************************/ + +void loader_load_all_classes(void) +{ + list_classpath_entry *lce; +#if defined(ENABLE_ZLIB) + hashtable *ht; + hashtable_zipfile_entry *htzfe; + utf *u; +#endif + + for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL; + lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) { +#if defined(ENABLE_ZLIB) + if (lce->type == CLASSPATH_ARCHIVE) { + /* get the classes hashtable */ + + ht = lce->htclasses; + + for (uint32_t slot = 0; slot < ht->size; slot++) { + htzfe = (hashtable_zipfile_entry *) ht->ptr[slot]; + + for (; htzfe; htzfe = htzfe->hashlink) { + u = htzfe->filename; + + /* skip all entries in META-INF and .properties, + .png files */ + + if (!strncmp(u->text, "META-INF", strlen("META-INF")) || + strstr(u->text, ".properties") || + strstr(u->text, ".png")) + continue; + + /* load class from bootstrap classloader */ + + if (!load_class_bootstrap(u)) { + fprintf(stderr, "Error loading: "); + utf_fprint_printable_ascii_classname(stderr, u); + fprintf(stderr, "\n"); + +#if !defined(NDEBUG) + /* print out exception and cause */ + + exceptions_print_current_exception(); +#endif + } + } + } + + } else { +#endif +#if defined(ENABLE_ZLIB) + } +#endif + } +} + + +/* loader_skip_attribute_body ************************************************** + + Skips an attribute the attribute_name_index has already been read. + + attribute_info { + u2 attribute_name_index; + u4 attribute_length; + u1 info[attribute_length]; + } + +*******************************************************************************/ + +bool loader_skip_attribute_body(classbuffer *cb) +{ + u4 attribute_length; + + if (!suck_check_classbuffer_size(cb, 4)) + return false; + + attribute_length = suck_u4(cb); + + if (!suck_check_classbuffer_size(cb, attribute_length)) + return false; + + suck_skip_nbytes(cb, attribute_length); + + return true; +} + + +/* load_constantpool *********************************************************** + + Loads the constantpool of a class, the entries are transformed into + a simpler format by resolving references (a detailed overview of + the compact structures can be found in global.h). + +*******************************************************************************/ + +static bool load_constantpool(classbuffer *cb, descriptor_pool *descpool) +{ + + /* The following structures are used to save information which cannot be + processed during the first pass. After the complete constantpool has + been traversed the references can be resolved. + (only in specific order) */ + + /* CONSTANT_Class entries */ + typedef struct forward_class { + struct forward_class *next; + u2 thisindex; + u2 name_index; + } forward_class; + + /* CONSTANT_String */ + typedef struct forward_string { + struct forward_string *next; + u2 thisindex; + u2 string_index; + } forward_string; + + /* CONSTANT_NameAndType */ + typedef struct forward_nameandtype { + struct forward_nameandtype *next; + u2 thisindex; + u2 name_index; + u2 sig_index; + } forward_nameandtype; + + /* CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref */ + typedef struct forward_fieldmethint { + struct forward_fieldmethint *next; + u2 thisindex; + u1 tag; + u2 class_index; + u2 nameandtype_index; + } forward_fieldmethint; + + + classinfo *c; + u4 idx; + + forward_class *forward_classes = NULL; + forward_string *forward_strings = NULL; + forward_nameandtype *forward_nameandtypes = NULL; + forward_fieldmethint *forward_fieldmethints = NULL; + + forward_class *nfc; + forward_string *nfs; + forward_nameandtype *nfn; + forward_fieldmethint *nff; + + u4 cpcount; + u1 *cptags; + void** cpinfos; + + c = cb->clazz; + + /* number of entries in the constant_pool table plus one */ + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + cpcount = c->cpcount = suck_u2(cb); + + /* allocate memory */ + cptags = c->cptags = MNEW(u1, cpcount); + cpinfos = c->cpinfos = MNEW(void*, cpcount); + + if (cpcount < 1) { + exceptions_throw_classformaterror(c, "Illegal constant pool size"); + return false; + } + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += (sizeof(u1) + sizeof(void*)) * cpcount; +#endif + + /* initialize constantpool */ + for (idx = 0; idx < cpcount; idx++) { + cptags[idx] = CONSTANT_UNUSED; + cpinfos[idx] = NULL; + } + + + /******* first pass *******/ + /* entries which cannot be resolved now are written into + temporary structures and traversed again later */ + + idx = 1; + while (idx < cpcount) { + u4 t; + + /* get constant type */ + if (!suck_check_classbuffer_size(cb, 1)) + return false; + + t = suck_u1(cb); + + switch (t) { + case CONSTANT_Class: +#warning Use list. + nfc = (forward_class*) DumpMemory::allocate(sizeof(forward_class)); + + nfc->next = forward_classes; + forward_classes = nfc; + + nfc->thisindex = idx; + /* reference to CONSTANT_NameAndType */ + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + nfc->name_index = suck_u2(cb); + + idx++; + break; + + case CONSTANT_String: +#warning Use list. + nfs = (forward_string*) DumpMemory::allocate(sizeof(forward_string)); + + nfs->next = forward_strings; + forward_strings = nfs; + + nfs->thisindex = idx; + + /* reference to CONSTANT_Utf8_info with string characters */ + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + nfs->string_index = suck_u2(cb); + + idx++; + break; + + case CONSTANT_NameAndType: +#warning Use list. + nfn = (forward_nameandtype*) DumpMemory::allocate(sizeof(forward_nameandtype)); + + nfn->next = forward_nameandtypes; + forward_nameandtypes = nfn; + + nfn->thisindex = idx; + + if (!suck_check_classbuffer_size(cb, 2 + 2)) + return false; + + /* reference to CONSTANT_Utf8_info containing simple name */ + nfn->name_index = suck_u2(cb); + + /* reference to CONSTANT_Utf8_info containing field or method + descriptor */ + nfn->sig_index = suck_u2(cb); + + idx++; + break; + + case CONSTANT_Fieldref: + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: +#warning Use list. + nff = (forward_fieldmethint*) DumpMemory::allocate(sizeof(forward_fieldmethint)); + + nff->next = forward_fieldmethints; + forward_fieldmethints = nff; + + nff->thisindex = idx; + /* constant type */ + nff->tag = t; + + if (!suck_check_classbuffer_size(cb, 2 + 2)) + return false; + + /* class or interface type that contains the declaration of the + field or method */ + nff->class_index = suck_u2(cb); + + /* name and descriptor of the field or method */ + nff->nameandtype_index = suck_u2(cb); + + idx++; + break; + + case CONSTANT_Integer: { + constant_integer *ci = NEW(constant_integer); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += sizeof(constant_integer); +#endif + + if (!suck_check_classbuffer_size(cb, 4)) + return false; + + ci->value = suck_s4(cb); + cptags[idx] = CONSTANT_Integer; + cpinfos[idx] = ci; + + idx++; + break; + } + + case CONSTANT_Float: { + constant_float *cf = NEW(constant_float); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += sizeof(constant_float); +#endif + + if (!suck_check_classbuffer_size(cb, 4)) + return false; + + cf->value = suck_float(cb); + cptags[idx] = CONSTANT_Float; + cpinfos[idx] = cf; + + idx++; + break; + } + + case CONSTANT_Long: { + constant_long *cl = NEW(constant_long); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += sizeof(constant_long); +#endif + + if (!suck_check_classbuffer_size(cb, 8)) + return false; + + cl->value = suck_s8(cb); + cptags[idx] = CONSTANT_Long; + cpinfos[idx] = cl; + idx += 2; + if (idx > cpcount) { + exceptions_throw_classformaterror(c, "Invalid constant pool entry"); + return false; + } + break; + } + + case CONSTANT_Double: { + constant_double *cd = NEW(constant_double); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += sizeof(constant_double); +#endif + + if (!suck_check_classbuffer_size(cb, 8)) + return false; + + cd->value = suck_double(cb); + cptags[idx] = CONSTANT_Double; + cpinfos[idx] = cd; + idx += 2; + if (idx > cpcount) { + exceptions_throw_classformaterror(c, "Invalid constant pool entry"); + return false; + } + break; + } + + case CONSTANT_Utf8: { + u4 length; + + /* number of bytes in the bytes array (not string-length) */ + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + length = suck_u2(cb); + cptags[idx] = CONSTANT_Utf8; + + /* validate the string */ + if (!suck_check_classbuffer_size(cb, length)) + return false; + +#ifdef ENABLE_VERIFIER + if (opt_verify && + !is_valid_utf((char *) cb->pos, (char *) (cb->pos + length))) + { + exceptions_throw_classformaterror(c, "Invalid UTF-8 string"); + return false; + } +#endif /* ENABLE_VERIFIER */ + /* insert utf-string into the utf-symboltable */ + cpinfos[idx] = utf_new((char *) cb->pos, length); + + /* skip bytes of the string (buffer size check above) */ + suck_skip_nbytes(cb, length); + idx++; + break; + } + + default: + exceptions_throw_classformaterror(c, "Illegal constant pool type"); + return false; + } /* end switch */ + } /* end while */ + + + /* resolve entries in temporary structures */ + + while (forward_classes) { + utf *name = (utf*) class_getconstant(c, forward_classes->name_index, CONSTANT_Utf8); + if (!name) + return false; + +#ifdef ENABLE_VERIFIER + if (opt_verify && !is_valid_name_utf(name)) { + exceptions_throw_classformaterror(c, "Class reference with invalid name"); + return false; + } +#endif /* ENABLE_VERIFIER */ + + /* add all class references to the descriptor_pool */ + + if (!descriptor_pool_add_class(descpool, name)) + return false; + + cptags[forward_classes->thisindex] = CONSTANT_Class; + + /* the classref is created later */ + cpinfos[forward_classes->thisindex] = name; + + nfc = forward_classes; + forward_classes = forward_classes->next; + } + + while (forward_strings) { + utf *text = (utf*) class_getconstant(c, forward_strings->string_index, CONSTANT_Utf8); + + if (!text) + return false; + + /* resolve utf-string */ + cptags[forward_strings->thisindex] = CONSTANT_String; + cpinfos[forward_strings->thisindex] = text; + + nfs = forward_strings; + forward_strings = forward_strings->next; + } + + while (forward_nameandtypes) { + constant_nameandtype *cn = NEW(constant_nameandtype); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += sizeof(constant_nameandtype); +#endif + + /* resolve simple name and descriptor */ + cn->name = (utf*) class_getconstant(c, + forward_nameandtypes->name_index, + CONSTANT_Utf8); + if (!cn->name) + return false; + + cn->descriptor = (utf*) class_getconstant(c, + forward_nameandtypes->sig_index, + CONSTANT_Utf8); + if (!cn->descriptor) + return false; + +#ifdef ENABLE_VERIFIER + if (opt_verify) { + /* check name */ + if (!is_valid_name_utf(cn->name)) { + exceptions_throw_classformaterror(c, + "Illegal Field name \"%s\"", + cn->name->text); + + return false; + } + + /* disallow referencing among others */ + if (cn->name->text[0] == '<' && cn->name != utf_init) { + exceptions_throw_classformaterror(c, "Illegal reference to special method"); + return false; + } + } +#endif /* ENABLE_VERIFIER */ + + cptags[forward_nameandtypes->thisindex] = CONSTANT_NameAndType; + cpinfos[forward_nameandtypes->thisindex] = cn; + + nfn = forward_nameandtypes; + forward_nameandtypes = forward_nameandtypes->next; + } + + while (forward_fieldmethints) { + constant_nameandtype *nat; + constant_FMIref *fmi = NEW(constant_FMIref); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_const_pool_len += sizeof(constant_FMIref); +#endif + /* resolve simple name and descriptor */ + + nat = (constant_nameandtype*) class_getconstant(c, + forward_fieldmethints->nameandtype_index, + CONSTANT_NameAndType); + + if (!nat) + return false; + + /* add all descriptors in {Field,Method}ref to the descriptor_pool */ + + if (!descriptor_pool_add(descpool, nat->descriptor, NULL)) + return false; + + /* the classref is created later */ + + fmi->p.index = forward_fieldmethints->class_index; + fmi->name = nat->name; + fmi->descriptor = nat->descriptor; + + cptags[forward_fieldmethints->thisindex] = forward_fieldmethints->tag; + cpinfos[forward_fieldmethints->thisindex] = fmi; + + nff = forward_fieldmethints; + forward_fieldmethints = forward_fieldmethints->next; + } + + /* everything was ok */ + + return true; +} + + +/* loader_load_attribute_signature ********************************************* + + Signature_attribute { + u2 attribute_name_index; + u4 atrribute_length; + u2 signature_index; + } + +*******************************************************************************/ + +#if defined(ENABLE_JAVASE) +bool loader_load_attribute_signature(classbuffer *cb, utf **signature) +{ + classinfo *c; + u4 attribute_length; + u2 signature_index; + + /* get classinfo */ + + c = cb->clazz; + + /* check remaining bytecode */ + + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* check attribute length */ + + attribute_length = suck_u4(cb); + + if (attribute_length != 2) { + exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); + return false; + } + + if (*signature != NULL) { + exceptions_throw_classformaterror(c, "Multiple Signature attributes"); + return false; + } + + /* get signature */ + + signature_index = suck_u2(cb); + + *signature = (utf*) class_getconstant(c, signature_index, CONSTANT_Utf8); + + if (*signature == NULL) + return false; + + return true; +} +#endif /* defined(ENABLE_JAVASE) */ + + +/* load_class_from_sysloader *************************************************** + + Load the class with the given name using the system class loader + + IN: + name.............the classname + + RETURN VALUE: + the loaded class, or + NULL if an exception has been thrown + +*******************************************************************************/ + +classinfo *load_class_from_sysloader(utf *name) +{ + methodinfo *m; + java_handle_t *clo; + classloader_t *cl; + classinfo *c; + + assert(class_java_lang_Object); + assert(class_java_lang_ClassLoader); + assert(class_java_lang_ClassLoader->state & CLASS_LINKED); + + m = class_resolveclassmethod(class_java_lang_ClassLoader, + utf_getSystemClassLoader, + utf_void__java_lang_ClassLoader, + class_java_lang_Object, + false); + + if (!m) + return false; + + clo = vm_call_method(m, NULL); + + if (!clo) + return false; + + cl = loader_hashtable_classloader_add(clo); + + c = load_class_from_classloader(name, cl); + + return c; +} + + +/* load_class_from_classloader ************************************************* + + Load the class with the given name using the given user-defined class loader. + + IN: + name.............the classname + cl...............user-defined class loader + + RETURN VALUE: + the loaded class, or + NULL if an exception has been thrown + +*******************************************************************************/ + +classinfo *load_class_from_classloader(utf *name, classloader_t *cl) +{ + java_handle_t *o; + classinfo *c; + classinfo *tmpc; + java_handle_t *string; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_lookup, time_prepare, time_java, + time_cache; +#endif + + RT_TIMING_GET_TIME(time_start); + + assert(name); + + /* lookup if this class has already been loaded */ + + c = classcache_lookup(cl, name); + + RT_TIMING_GET_TIME(time_lookup); + RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_CL_LOOKUP); + + if (c != NULL) + return c; + + /* if other class loader than bootstrap, call it */ + + if (cl != NULL) { + methodinfo *lc; + char *text; + s4 namelen; + + text = name->text; + namelen = name->blength; + + /* handle array classes */ + if (text[0] == '[') { + classinfo *comp; + utf *u; + + switch (text[1]) { + case 'L': + /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */ + if (namelen < 4 || text[2] == '[' || text[namelen - 1] != ';') { + exceptions_throw_classnotfoundexception(name); + return false; + } + + u = utf_new(text + 2, namelen - 3); + + if (!(comp = load_class_from_classloader(u, cl))) + return false; + + /* create the array class */ + + c = class_array_of(comp, false); + + tmpc = classcache_store(cl, c, true); + + if (tmpc == NULL) { + /* exception, free the loaded class */ + c->state &= ~CLASS_LOADING; + class_free(c); + } + + return tmpc; + + case '[': + /* load the component class */ + + u = utf_new(text + 1, namelen - 1); + + if (!(comp = load_class_from_classloader(u, cl))) + return false; + + /* create the array class */ + + c = class_array_of(comp, false); + + tmpc = classcache_store(cl, c, true); + + if (tmpc == NULL) { + /* exception, free the loaded class */ + c->state &= ~CLASS_LOADING; + class_free(c); + } + + return tmpc; + + default: + /* primitive array classes are loaded by the bootstrap loader */ + + c = load_class_bootstrap(name); + + return c; + } + } + + LLNI_class_get(cl, c); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + /* OpenJDK uses this internal function because it's + synchronized. */ + + lc = class_resolveclassmethod(c, + utf_loadClassInternal, + utf_java_lang_String__java_lang_Class, + NULL, + true); +#else + lc = class_resolveclassmethod(c, + utf_loadClass, + utf_java_lang_String__java_lang_Class, + NULL, + true); +#endif + + if (lc == NULL) + return false; /* exception */ + + /* move return value into `o' and cast it afterwards to a classinfo* */ + + string = javastring_new_slash_to_dot(name); + + RT_TIMING_GET_TIME(time_prepare); + + o = vm_call_method(lc, (java_handle_t *) cl, string); + + RT_TIMING_GET_TIME(time_java); + + c = LLNI_classinfo_unwrap(o); + + if (c != NULL) { + /* Store this class in the loaded class cache. If another + class with the same (initloader,name) pair has been + stored earlier it will be returned by classcache_store + In this case classcache_store may not free the class + because it has already been exposed to Java code which + may have kept references to that class. */ + + tmpc = classcache_store(cl, c, false); + + if (tmpc == NULL) { + /* exception, free the loaded class */ + c->state &= ~CLASS_LOADING; + class_free(c); + } + + c = tmpc; + } + + RT_TIMING_GET_TIME(time_cache); + + RT_TIMING_TIME_DIFF(time_lookup , time_prepare, RT_TIMING_LOAD_CL_PREPARE); + RT_TIMING_TIME_DIFF(time_prepare, time_java , RT_TIMING_LOAD_CL_JAVA); + RT_TIMING_TIME_DIFF(time_java , time_cache , RT_TIMING_LOAD_CL_CACHE); + + /* SUN compatible -verbose:class output */ + + if (opt_verboseclass && (c != NULL) && (c->classloader == cl)) { + printf("[Loaded "); + utf_display_printable_ascii_classname(name); + printf("]\n"); + } + +#if defined(ENABLE_JVMTI) + /* fire Class Load JVMTI event */ + if (jvmti) jvmti_ClassLoadPrepare(false, c); +#endif + + + return c; + } + + c = load_class_bootstrap(name); + + return c; +} + + +/* load_class_bootstrap ******************************************************** + + Load the class with the given name using the bootstrap class loader. + + IN: + name.............the classname + + RETURN VALUE: + loaded classinfo, or + NULL if an exception has been thrown + + SYNCHRONIZATION: + load_class_bootstrap is synchronized. It can be treated as an + atomic operation. + +*******************************************************************************/ + +classinfo *load_class_bootstrap(utf *name) +{ + classbuffer *cb; + classinfo *c; + classinfo *r; +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_lookup, time_array, time_suck, + time_load, time_cache; +#endif + + RT_TIMING_GET_TIME(time_start); + + /* for debugging */ + + assert(name); + + /* lookup if this class has already been loaded */ + + r = classcache_lookup(NULL, name); + + if (r != NULL) { + RT_TIMING_GET_TIME(time_lookup); + RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP); + + return r; + } + + RT_TIMING_GET_TIME(time_lookup); + RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP); + + /* create the classinfo */ + + c = class_create_classinfo(name); + + /* handle array classes */ + + if (name->text[0] == '[') { + c = load_newly_created_array(c, NULL); + + if (c == NULL) + return NULL; + + assert(c->state & CLASS_LOADED); + + RT_TIMING_GET_TIME(time_array); + RT_TIMING_TIME_DIFF(time_start,time_array,RT_TIMING_LOAD_BOOT_ARRAY); + + return c; + } + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getcompilingtime) + compilingtime_stop(); + + if (opt_getloadingtime) + loadingtime_start(); +#endif + + /* load classdata, throw exception on error */ + + cb = suck_start(c); + + if (cb == NULL) { + exceptions_throw_classnotfoundexception(name); + return NULL; + } + + RT_TIMING_GET_TIME(time_suck); + + /* load the class from the buffer */ + + r = load_class_from_classbuffer(cb); + + RT_TIMING_GET_TIME(time_load); + + if (r == NULL) { + /* the class could not be loaded, free the classinfo struct */ + + class_free(c); + } + else { + /* Store this class in the loaded class cache this step also + checks the loading constraints. If the class has been + loaded before, the earlier loaded class is returned. */ + + classinfo *res = classcache_store(NULL, c, true); + + if (res == NULL) { + /* exception */ + class_free(c); + } + else { + // Add the package name to the boot packages. + Package::add(c->packagename); + } + + r = res; + } + + RT_TIMING_GET_TIME(time_cache); + + /* SUN compatible -verbose:class output */ + + if (opt_verboseclass && r) { + printf("[Loaded "); + utf_display_printable_ascii_classname(name); + printf(" from %s]\n", cb->path); + } + + /* free memory */ + + suck_stop(cb); + +#if defined(ENABLE_STATISTICS) + /* measure time */ + + if (opt_getloadingtime) + loadingtime_stop(); + + if (opt_getcompilingtime) + compilingtime_start(); +#endif + + RT_TIMING_TIME_DIFF(time_lookup, time_suck , RT_TIMING_LOAD_BOOT_SUCK); + RT_TIMING_TIME_DIFF(time_suck , time_load , RT_TIMING_LOAD_BOOT_LOAD); + RT_TIMING_TIME_DIFF(time_load , time_cache, RT_TIMING_LOAD_BOOT_CACHE); + RT_TIMING_TIME_DIFF(time_lookup, time_cache, RT_TIMING_LOAD_BOOT_TOTAL); + + return r; +} + + +/* load_class_from_classbuffer_intern ****************************************** + + Loads a class from a classbuffer into a given classinfo structure. + Super-classes are also loaded at this point and some verfication + checks are done. + + SYNCHRONIZATION: + This function is NOT synchronized! + +*******************************************************************************/ + +static bool load_class_from_classbuffer_intern(classbuffer *cb) +{ + classinfo *c; + classinfo *tc; + utf *name; + utf *supername; + utf **interfacesnames; + utf *u; + constant_classref *cr; + int16_t index; + + u4 ma, mi; + descriptor_pool *descpool; +#if defined(ENABLE_STATISTICS) + u4 classrefsize; + u4 descsize; +#endif +#if defined(ENABLE_RT_TIMING) + struct timespec time_start, time_checks, time_ndpool, time_cpool, + time_setup, time_fields, time_methods, time_classrefs, + time_descs, time_setrefs, time_parsefds, time_parsemds, + time_parsecpool, time_verify, time_attrs; +#endif + + // Create new dump memory area. + DumpMemoryArea dma; + + RT_TIMING_GET_TIME(time_start); + + /* Get the classbuffer's class. */ + + c = cb->clazz; + + if (!suck_check_classbuffer_size(cb, 4 + 2 + 2)) + return false; + + /* check signature */ + + if (suck_u4(cb) != MAGIC) { + exceptions_throw_classformaterror(c, "Bad magic number"); + return false; + } + + /* check version */ + + mi = suck_u2(cb); + ma = suck_u2(cb); + + if (!(ma < MAJOR_VERSION || (ma == MAJOR_VERSION && mi <= MINOR_VERSION))) { + exceptions_throw_unsupportedclassversionerror(c, ma, mi); + return false; + } + + RT_TIMING_GET_TIME(time_checks); + + /* create a new descriptor pool */ + + descpool = descriptor_pool_new(c); + + RT_TIMING_GET_TIME(time_ndpool); + + /* load the constant pool */ + + if (!load_constantpool(cb, descpool)) + return false; + + RT_TIMING_GET_TIME(time_cpool); + + /* ACC flags */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* We OR the flags here, as we set already some flags in + class_create_classinfo. */ + + c->flags |= suck_u2(cb); + + /* check ACC flags consistency */ + + if (c->flags & ACC_INTERFACE) { + if (!(c->flags & ACC_ABSTRACT)) { + /* We work around this because interfaces in JDK 1.1 are + * not declared abstract. */ + + c->flags |= ACC_ABSTRACT; + } + + if (c->flags & ACC_FINAL) { + exceptions_throw_classformaterror(c, + "Illegal class modifiers: 0x%X", + c->flags); + return false; + } + + if (c->flags & ACC_SUPER) { + c->flags &= ~ACC_SUPER; /* kjc seems to set this on interfaces */ + } + } + + if ((c->flags & (ACC_ABSTRACT | ACC_FINAL)) == (ACC_ABSTRACT | ACC_FINAL)) { + exceptions_throw_classformaterror(c, + "Illegal class modifiers: 0x%X", + c->flags); + return false; + } + + if (!suck_check_classbuffer_size(cb, 2 + 2)) + return false; + + /* This class. */ + + index = suck_u2(cb); + + name = (utf *) class_getconstant(c, index, CONSTANT_Class); + + if (name == NULL) + return false; + + if (c->name == utf_not_named_yet) { + /* we finally have a name for this class */ + c->name = name; + class_set_packagename(c); + } + else if (name != c->name) { + exceptions_throw_noclassdeffounderror_wrong_name(c, name); + return false; + } + + /* Retrieve superclass. */ + + c->super = NULL; + + index = suck_u2(cb); + + if (index == 0) { + supername = NULL; + + /* This is only allowed for java.lang.Object. */ + + if (c->name != utf_java_lang_Object) { + exceptions_throw_classformaterror(c, "Bad superclass index"); + return false; + } + } + else { + supername = (utf *) class_getconstant(c, index, CONSTANT_Class); + + if (supername == NULL) + return false; + + /* java.lang.Object may not have a super class. */ + + if (c->name == utf_java_lang_Object) { + exceptions_throw_classformaterror(NULL, "java.lang.Object with superclass"); + return false; + } + + /* Detect circularity. */ + + if (supername == c->name) { + exceptions_throw_classcircularityerror(c); + return false; + } + + /* Interfaces must have java.lang.Object as super class. */ + + if ((c->flags & ACC_INTERFACE) && (supername != utf_java_lang_Object)) { + exceptions_throw_classformaterror(c, "Interfaces must have java.lang.Object as superclass"); + return false; + } + } + + /* Parse the super interfaces. */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + c->interfacescount = suck_u2(cb); + + if (!suck_check_classbuffer_size(cb, 2 * c->interfacescount)) + return false; + + c->interfaces = MNEW(classinfo*, c->interfacescount); + + /* Get the names of the super interfaces. */ + + interfacesnames = (utf**) DumpMemory::allocate(sizeof(utf*) * c->interfacescount); + + for (int32_t i = 0; i < c->interfacescount; i++) { + index = suck_u2(cb); + + u = (utf *) class_getconstant(c, index, CONSTANT_Class); + + if (u == NULL) + return false; + + interfacesnames[i] = u; + } + + RT_TIMING_GET_TIME(time_setup); + + /* Parse fields. */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + c->fieldscount = suck_u2(cb); + c->fields = MNEW(fieldinfo, c->fieldscount); + + MZERO(c->fields, fieldinfo, c->fieldscount); + + for (int32_t i = 0; i < c->fieldscount; i++) { + if (!field_load(cb, &(c->fields[i]), descpool)) + return false; + } + + RT_TIMING_GET_TIME(time_fields); + + /* Parse methods. */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + c->methodscount = suck_u2(cb); + c->methods = MNEW(methodinfo, c->methodscount); + + MZERO(c->methods, methodinfo, c->methodscount); + + for (int32_t i = 0; i < c->methodscount; i++) { + if (!method_load(cb, &(c->methods[i]), descpool)) + return false; + } + + RT_TIMING_GET_TIME(time_methods); + + /* create the class reference table */ + + c->classrefs = + descriptor_pool_create_classrefs(descpool, &(c->classrefcount)); + + RT_TIMING_GET_TIME(time_classrefs); + + /* allocate space for the parsed descriptors */ + + descriptor_pool_alloc_parsed_descriptors(descpool); + c->parseddescs = (u1*) descriptor_pool_get_parsed_descriptors(descpool, &(c->parseddescsize)); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + descriptor_pool_get_sizes(descpool, &classrefsize, &descsize); + count_classref_len += classrefsize; + count_parsed_desc_len += descsize; + } +#endif + + RT_TIMING_GET_TIME(time_descs); + + /* put the classrefs in the constant pool */ + + for (int32_t i = 0; i < c->cpcount; i++) { + if (c->cptags[i] == CONSTANT_Class) { + utf *name = (utf *) c->cpinfos[i]; + c->cpinfos[i] = descriptor_pool_lookup_classref(descpool, name); + } + } + + /* Resolve the super class. */ + + if (supername != NULL) { + cr = descriptor_pool_lookup_classref(descpool, supername); + + if (cr == NULL) + return false; + + /* XXX This should be done better. */ + tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false); + + if (tc == NULL) { + resolve_handle_pending_exception(true); + return false; + } + + /* Interfaces are not allowed as super classes. */ + + if (tc->flags & ACC_INTERFACE) { + exceptions_throw_incompatibleclasschangeerror(c, "class %s has interface %s as super class"); + return false; + } + + /* Don't allow extending final classes */ + + if (tc->flags & ACC_FINAL) { + exceptions_throw_verifyerror(NULL, + "Cannot inherit from final class"); + return false; + } + + /* Store the super class. */ + + c->super = tc; + } + + /* Resolve the super interfaces. */ + + for (int32_t i = 0; i < c->interfacescount; i++) { + u = interfacesnames[i]; + cr = descriptor_pool_lookup_classref(descpool, u); + + if (cr == NULL) + return false; + + /* XXX This should be done better. */ + tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false); + + if (tc == NULL) { + resolve_handle_pending_exception(true); + return false; + } + + /* Detect circularity. */ + + if (tc == c) { + exceptions_throw_classcircularityerror(c); + return false; + } + + if (!(tc->flags & ACC_INTERFACE)) { + exceptions_throw_incompatibleclasschangeerror(tc, + "Implementing class"); + return false; + } + + /* Store the super interface. */ + + c->interfaces[i] = tc; + } + + RT_TIMING_GET_TIME(time_setrefs); + + /* Parse the field descriptors. */ + + for (int32_t i = 0; i < c->fieldscount; i++) { + c->fields[i].parseddesc = + descriptor_pool_parse_field_descriptor(descpool, + c->fields[i].descriptor); + if (!c->fields[i].parseddesc) + return false; + } + + RT_TIMING_GET_TIME(time_parsefds); + + /* parse method descriptors */ + + for (int32_t i = 0; i < c->methodscount; i++) { + methodinfo *m = &c->methods[i]; + m->parseddesc = + descriptor_pool_parse_method_descriptor(descpool, m->descriptor, + m->flags, class_get_self_classref(m->clazz)); + if (!m->parseddesc) + return false; + + for (int32_t j = 0; j < m->rawexceptiontablelength; j++) { + if (!m->rawexceptiontable[j].catchtype.any) + continue; + + if ((m->rawexceptiontable[j].catchtype.ref = + descriptor_pool_lookup_classref(descpool, + (utf *) m->rawexceptiontable[j].catchtype.any)) == NULL) + return false; + } + + for (int32_t j = 0; j < m->thrownexceptionscount; j++) { + if (!m->thrownexceptions[j].any) + continue; + + if ((m->thrownexceptions[j].ref = descriptor_pool_lookup_classref(descpool, + (utf *) m->thrownexceptions[j].any)) == NULL) + return false; + } + } + + RT_TIMING_GET_TIME(time_parsemds); + + /* parse the loaded descriptors */ + + for (int32_t i = 0; i < c->cpcount; i++) { + constant_FMIref *fmi; + s4 index; + + switch (c->cptags[i]) { + case CONSTANT_Fieldref: + fmi = (constant_FMIref *) c->cpinfos[i]; + fmi->parseddesc.fd = + descriptor_pool_parse_field_descriptor(descpool, + fmi->descriptor); + if (!fmi->parseddesc.fd) + return false; + + index = fmi->p.index; + fmi->p.classref = + (constant_classref *) class_getconstant(c, index, + CONSTANT_Class); + if (!fmi->p.classref) + return false; + break; + case CONSTANT_Methodref: + case CONSTANT_InterfaceMethodref: + fmi = (constant_FMIref *) c->cpinfos[i]; + index = fmi->p.index; + fmi->p.classref = + (constant_classref *) class_getconstant(c, index, + CONSTANT_Class); + if (!fmi->p.classref) + return false; + fmi->parseddesc.md = + descriptor_pool_parse_method_descriptor(descpool, + fmi->descriptor, + ACC_UNDEF, + fmi->p.classref); + if (!fmi->parseddesc.md) + return false; + break; + } + } + + RT_TIMING_GET_TIME(time_parsecpool); + +#ifdef ENABLE_VERIFIER + /* Check if all fields and methods can be uniquely + * identified by (name,descriptor). */ + + if (opt_verify) { + /* We use a hash table here to avoid making the + * average case quadratic in # of methods, fields. + */ + static int shift = 0; + u2 *hashtab; + u2 *next; /* for chaining colliding hash entries */ + int32_t len; + int32_t hashlen; + u2 index; + u2 old; + + /* Allocate hashtable */ + len = c->methodscount; + if (len < c->fieldscount) len = c->fieldscount; + hashlen = 5 * len; + hashtab = MNEW(u2,(hashlen + len)); + next = hashtab + hashlen; + + /* Determine bitshift (to get good hash values) */ + if (!shift) { + len = sizeof(utf); + while (len) { + len >>= 1; + shift++; + } + } + + /* Check fields */ + memset(hashtab, 0, sizeof(u2) * (hashlen + len)); + + for (int32_t i = 0; i < c->fieldscount; ++i) { + fieldinfo *fi = c->fields + i; + + /* It's ok if we lose bits here */ + index = ((((size_t) fi->name) + + ((size_t) fi->descriptor)) >> shift) % hashlen; + + if ((old = hashtab[index])) { + old--; + next[i] = old; + do { + if (c->fields[old].name == fi->name && + c->fields[old].descriptor == fi->descriptor) { + exceptions_throw_classformaterror(c, "Repetitive field name/signature"); + return false; + } + } while ((old = next[old])); + } + hashtab[index] = i + 1; + } + + /* Check methods */ + memset(hashtab, 0, sizeof(u2) * (hashlen + hashlen/5)); + + for (int32_t i = 0; i < c->methodscount; ++i) { + methodinfo *mi = c->methods + i; + + /* It's ok if we lose bits here */ + index = ((((size_t) mi->name) + + ((size_t) mi->descriptor)) >> shift) % hashlen; + + if ((old = hashtab[index])) { + old--; + next[i] = old; + do { + if (c->methods[old].name == mi->name && + c->methods[old].descriptor == mi->descriptor) { + exceptions_throw_classformaterror(c, "Repetitive method name/signature"); + return false; + } + } while ((old = next[old])); + } + hashtab[index] = i + 1; + } + + MFREE(hashtab, u2, (hashlen + len)); + } +#endif /* ENABLE_VERIFIER */ + + RT_TIMING_GET_TIME(time_verify); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + size_classinfo += sizeof(classinfo*) * c->interfacescount; + size_fieldinfo += sizeof(fieldinfo) * c->fieldscount; + size_methodinfo += sizeof(methodinfo) * c->methodscount; + } +#endif + + /* load attribute structures */ + + if (!class_load_attributes(cb)) + return false; + + /* Pre Java 1.5 version don't check this. This implementation is + like Java 1.5 do it: for class file version 45.3 we don't check + it, older versions are checked. */ + + if (((ma == 45) && (mi > 3)) || (ma > 45)) { + /* check if all data has been read */ + s4 classdata_left = ((cb->data + cb->size) - cb->pos); + + if (classdata_left > 0) { + exceptions_throw_classformaterror(c, "Extra bytes at the end of class file"); + return false; + } + } + + RT_TIMING_GET_TIME(time_attrs); + + RT_TIMING_TIME_DIFF(time_start , time_checks , RT_TIMING_LOAD_CHECKS); + RT_TIMING_TIME_DIFF(time_checks , time_ndpool , RT_TIMING_LOAD_NDPOOL); + RT_TIMING_TIME_DIFF(time_ndpool , time_cpool , RT_TIMING_LOAD_CPOOL); + RT_TIMING_TIME_DIFF(time_cpool , time_setup , RT_TIMING_LOAD_SETUP); + RT_TIMING_TIME_DIFF(time_setup , time_fields , RT_TIMING_LOAD_FIELDS); + RT_TIMING_TIME_DIFF(time_fields , time_methods , RT_TIMING_LOAD_METHODS); + RT_TIMING_TIME_DIFF(time_methods , time_classrefs , RT_TIMING_LOAD_CLASSREFS); + RT_TIMING_TIME_DIFF(time_classrefs , time_descs , RT_TIMING_LOAD_DESCS); + RT_TIMING_TIME_DIFF(time_descs , time_setrefs , RT_TIMING_LOAD_SETREFS); + RT_TIMING_TIME_DIFF(time_setrefs , time_parsefds , RT_TIMING_LOAD_PARSEFDS); + RT_TIMING_TIME_DIFF(time_parsefds , time_parsemds , RT_TIMING_LOAD_PARSEMDS); + RT_TIMING_TIME_DIFF(time_parsemds , time_parsecpool, RT_TIMING_LOAD_PARSECP); + RT_TIMING_TIME_DIFF(time_parsecpool, time_verify , RT_TIMING_LOAD_VERIFY); + RT_TIMING_TIME_DIFF(time_verify , time_attrs , RT_TIMING_LOAD_ATTRS); + RT_TIMING_TIME_DIFF(time_start , time_attrs , RT_TIMING_LOAD_TOTAL); + + return true; +} + + +/* load_class_from_classbuffer ************************************************* + + Convenience wrapper for load_class_from_classbuffer. + + SYNCHRONIZATION: + This function is NOT synchronized! + +*******************************************************************************/ + +classinfo *load_class_from_classbuffer(classbuffer *cb) +{ + classinfo *c; + bool result; + + /* Get the classbuffer's class. */ + + c = cb->clazz; + + /* Check if the class is already loaded. */ + + if (c->state & CLASS_LOADED) + return c; + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_class_loads++; +#endif + +#if !defined(NDEBUG) + if (loadverbose) + log_message_class("Loading class: ", c); +#endif + + /* Class is currently loading. */ + + c->state |= CLASS_LOADING; + + /* Parse the classbuffer. */ + + result = load_class_from_classbuffer_intern(cb); + + /* An error occurred. */ + + if (result == false) { + /* Revert loading state. */ + + c->state = (c->state & ~CLASS_LOADING); + + return NULL; + } + + /* Revert loading state and set loaded. */ + + c->state = (c->state & ~CLASS_LOADING) | CLASS_LOADED; + +#if defined(ENABLE_JVMTI) + /* fire Class Prepare JVMTI event */ + + if (jvmti) + jvmti_ClassLoadPrepare(true, c); +#endif + +#if !defined(NDEBUG) + if (loadverbose) + log_message_class("Loading done class: ", c); +#endif + + return c; +} + + +/* load_newly_created_array **************************************************** + + Load a newly created array class. + + RETURN VALUE: + c....................the array class C has been loaded + other classinfo......the array class was found in the class cache, + C has been freed + NULL.................an exception has been thrown + + Note: + This is an internal function. Do not use it unless you know exactly + what you are doing! + + Use one of the load_class_... functions for general array class loading. + +*******************************************************************************/ + +classinfo *load_newly_created_array(classinfo *c, classloader_t *loader) +{ + classinfo *comp = NULL; + methodinfo *clone; + methoddesc *clonedesc; + constant_classref *classrefs; + char *text; + s4 namelen; + utf *u; + + text = c->name->text; + namelen = c->name->blength; + + /* Check array class name */ + + if ((namelen < 2) || (text[0] != '[')) { + exceptions_throw_classnotfoundexception(c->name); + return NULL; + } + + /* Check the element type */ + + switch (text[1]) { + case '[': + /* c is an array of arrays. We have to create the component class. */ + + u = utf_new(text + 1, namelen - 1); + + comp = load_class_from_classloader(u, loader); + + if (comp == NULL) + return NULL; + + assert(comp->state & CLASS_LOADED); + + /* the array's flags are that of the component class */ + c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT; + c->classloader = comp->classloader; + break; + + case 'L': + /* c is an array of objects. */ + + /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */ + if ((namelen < 4) || (text[2] == '[') || (text[namelen - 1] != ';')) { + exceptions_throw_classnotfoundexception(c->name); + return NULL; + } + + u = utf_new(text + 2, namelen - 3); + + if (!(comp = load_class_from_classloader(u, loader))) + return NULL; + + assert(comp->state & CLASS_LOADED); + + /* the array's flags are that of the component class */ + c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT; + c->classloader = comp->classloader; + break; + + default: + /* c is an array of a primitive type */ + + /* check for cases like `[II' and whether the character is a + valid primitive type */ + + if ((namelen > 2) || (Primitive::get_class_by_char(text[1]) == NULL)) { + exceptions_throw_classnotfoundexception(c->name); + return NULL; + } + + /* the accessibility of the array class is public (VM Spec 5.3.3) */ + c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT; + c->classloader = NULL; + } + + assert(class_java_lang_Object); +#if defined(ENABLE_JAVASE) + assert(class_java_lang_Cloneable); + assert(class_java_io_Serializable); +#endif + + /* Setup the array class. */ + + c->super = class_java_lang_Object; + +#if defined(ENABLE_JAVASE) + + c->interfacescount = 2; + c->interfaces = MNEW(classinfo*, 2); + c->interfaces[0] = class_java_lang_Cloneable; + c->interfaces[1] = class_java_io_Serializable; + +#elif defined(ENABLE_JAVAME_CLDC1_1) + + c->interfacescount = 0; + c->interfaces = NULL; + +#else +# error unknow Java configuration +#endif + + c->methodscount = 1; + c->methods = MNEW(methodinfo, c->methodscount); + + MZERO(c->methods, methodinfo, c->methodscount); + + classrefs = MNEW(constant_classref, 2); + + CLASSREF_INIT(classrefs[0], c, c->name); + CLASSREF_INIT(classrefs[1], c, utf_java_lang_Object); + + /* create descriptor for clone method */ + /* we need one paramslot which is reserved for the 'this' parameter */ + clonedesc = NEW(methoddesc); + clonedesc->returntype.type = TYPE_ADR; + clonedesc->returntype.classref = classrefs + 1; + clonedesc->returntype.arraydim = 0; + /* initialize params to "empty", add real params below in + descriptor_params_from_paramtypes */ + clonedesc->paramcount = 0; + clonedesc->paramslots = 0; + clonedesc->paramtypes[0].classref = classrefs + 0; + clonedesc->params = NULL; + + /* create methodinfo */ + + clone = c->methods; + MSET(clone, 0, methodinfo, 1); + + /* ATTENTION: if you delete the ACC_NATIVE below, set + clone->maxlocals=1 (interpreter related) */ + + clone->mutex = new Mutex(); + clone->flags = ACC_PUBLIC | ACC_NATIVE; + clone->name = utf_clone; + clone->descriptor = utf_void__java_lang_Object; + clone->parseddesc = clonedesc; + clone->clazz = c; + + /* parse the descriptor to get the register allocation */ + + if (!descriptor_params_from_paramtypes(clonedesc, clone->flags)) + return false; + + clone->code = NativeStub::generate(clone, BUILTIN_clone); + + /* XXX: field: length? */ + + /* array classes are not loaded from class files */ + + c->state |= CLASS_LOADED; + c->parseddescs = (u1 *) clonedesc; + c->parseddescsize = sizeof(methodinfo); + c->classrefs = classrefs; + c->classrefcount = 1; + + /* insert class into the loaded class cache */ + /* XXX free classinfo if NULL returned? */ + + return classcache_store(loader, c, true); +} + + +/* loader_close **************************************************************** + + Frees all resources. + +*******************************************************************************/ + +void loader_close(void) +{ + /* empty */ +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/loader.hpp b/src/vm/loader.hpp new file mode 100644 index 000000000..bbf5eeb31 --- /dev/null +++ b/src/vm/loader.hpp @@ -0,0 +1,191 @@ +/* src/vm/loader.hpp - class loader header + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _LOADER_HPP +#define _LOADER_HPP + +/* forward typedefs ***********************************************************/ + +typedef struct classbuffer classbuffer; + + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "vm/descriptor.h" +#include "vm/class.h" +#include "vm/global.h" +#include "vm/method.h" +#include "vm/references.h" +#include "vm/utf8.h" + + +/* constant pool entries ******************************************************* + + All constant pool entries need a data structure which contain the entrys + value. In some cases this structure exist already, in the remaining cases + this structure must be generated: + + kind structure generated? + ---------------------------------------------------------------------- + CONSTANT_Class constant_classref yes + CONSTANT_Fieldref constant_FMIref yes + CONSTANT_Methodref constant_FMIref yes + CONSTANT_InterfaceMethodref constant_FMIref yes + CONSTANT_String unicode no + CONSTANT_Integer constant_integer yes + CONSTANT_Float constant_float yes + CONSTANT_Long constant_long yes + CONSTANT_Double constant_double yes + CONSTANT_NameAndType constant_nameandtype yes + CONSTANT_Utf8 unicode no + CONSTANT_UNUSED - + +*******************************************************************************/ + +typedef struct { /* Integer */ + s4 value; +} constant_integer; + + +typedef struct { /* Float */ + float value; +} constant_float; + + +typedef struct { /* Long */ + s8 value; +} constant_long; + + +typedef struct { /* Double */ + double value; +} constant_double; + + +typedef struct { /* NameAndType (Field or Method) */ + utf *name; /* field/method name */ + utf *descriptor; /* field/method type descriptor string */ +} constant_nameandtype; + + +/* classbuffer ****************************************************************/ + +struct classbuffer { + classinfo *clazz; /* pointer to classinfo structure */ + uint8_t *data; /* pointer to byte code */ + int32_t size; /* size of the byte code */ + uint8_t *pos; /* current read position */ + char *path; /* path to file (for debugging) */ +}; + + +/* hashtable_classloader_entry ************************************************* + + ATTENTION: The pointer to the classloader object needs to be the + first field of the entry, so that it can be used as an indirection + cell. This is checked by gc_init() during startup. + +*******************************************************************************/ + +typedef struct hashtable_classloader_entry hashtable_classloader_entry; + +struct hashtable_classloader_entry { + java_object_t *object; + hashtable_classloader_entry *hashlink; +}; + + +/* classloader ***************************************************************** + + [!ENABLE_HANDLES]: The classloader is a Java Object which cannot move. + [ENABLE_HANDLES] : The classloader entry itself is a static handle for a + given classloader (use loader_hashtable_classloader_foo). + +*******************************************************************************/ + +#if defined(ENABLE_HANDLES) +typedef hashtable_classloader_entry classloader_t; +#else +typedef java_object_t classloader_t; +#endif + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +void loader_preinit(void); +void loader_init(void); + +/* classloader management functions */ +classloader_t *loader_hashtable_classloader_add(java_handle_t *cl); +classloader_t *loader_hashtable_classloader_find(java_handle_t *cl); + +void loader_load_all_classes(void); + +bool loader_skip_attribute_body(classbuffer *cb); + +#if defined(ENABLE_JAVASE) +bool loader_load_attribute_signature(classbuffer *cb, utf **signature); +#endif + +/* free resources */ +void loader_close(void); + +/* class loading functions */ +classinfo *load_class_from_sysloader(utf *name); +classinfo *load_class_from_classloader(utf *name, classloader_t *cl); +classinfo *load_class_bootstrap(utf *name); + +/* (don't use the following directly) */ +classinfo *load_class_from_classbuffer(classbuffer *cb); +classinfo *load_newly_created_array(classinfo *c, classloader_t *loader); + +#ifdef __cplusplus +} +#endif + +#endif // _LOADER_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/method.c b/src/vm/method.c new file mode 100644 index 000000000..814240698 --- /dev/null +++ b/src/vm/method.c @@ -0,0 +1,1219 @@ +/* src/vm/method.c - method functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "threads/mutex.hpp" + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/resolve.h" +#include "vm/suck.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + +#include "vm/jit/code.hpp" +#include "vm/jit/methodheader.h" +#include "vm/jit/stubs.hpp" + + +#if !defined(NDEBUG) && defined(ENABLE_INLINING) +#define INLINELOG(code) do { if (opt_TraceInlining) { code } } while (0) +#else +#define INLINELOG(code) +#endif + + +/* global variables ***********************************************************/ + +methodinfo *method_java_lang_reflect_Method_invoke; + + +/* method_init ***************************************************************** + + Initialize method subsystem. + +*******************************************************************************/ + +void method_init(void) +{ +#if defined(ENABLE_JAVASE) + /* Sanity check. */ + + if (class_java_lang_reflect_Method == NULL) + vm_abort("method_init: class_java_lang_reflect_Method is NULL"); + + /* Cache java.lang.reflect.Method.invoke() */ + + method_java_lang_reflect_Method_invoke = + class_findmethod(class_java_lang_reflect_Method, utf_invoke, NULL); + + if (method_java_lang_reflect_Method_invoke == NULL) + vm_abort("method_init: Could not resolve method java.lang.reflect.Method.invoke()."); +#endif +} + + +/* method_load ***************************************************************** + + Loads a method from the class file and fills an existing methodinfo + structure. + + method_info { + u2 access_flags; + u2 name_index; + u2 descriptor_index; + u2 attributes_count; + attribute_info attributes[attribute_count]; + } + + attribute_info { + u2 attribute_name_index; + u4 attribute_length; + u1 info[attribute_length]; + } + + LineNumberTable_attribute { + u2 attribute_name_index; + u4 attribute_length; + u2 line_number_table_length; + { + u2 start_pc; + u2 line_number; + } line_number_table[line_number_table_length]; + } + +*******************************************************************************/ + +bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool) +{ + classinfo *c; + int argcount; + s4 i, j, k, l; + utf *u; + u2 name_index; + u2 descriptor_index; + u2 attributes_count; + u2 attribute_name_index; + utf *attribute_name; + u2 code_attributes_count; + u2 code_attribute_name_index; + utf *code_attribute_name; + + /* get classinfo */ + + c = cb->clazz; + + m->mutex = Mutex_new(); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_all_methods++; +#endif + + /* all fields of m have been zeroed in load_class_from_classbuffer */ + + m->clazz = c; + + if (!suck_check_classbuffer_size(cb, 2 + 2 + 2)) + return false; + + /* access flags */ + + m->flags = suck_u2(cb); + + /* name */ + + name_index = suck_u2(cb); + + if (!(u = class_getconstant(c, name_index, CONSTANT_Utf8))) + return false; + + m->name = u; + + /* descriptor */ + + descriptor_index = suck_u2(cb); + + if (!(u = class_getconstant(c, descriptor_index, CONSTANT_Utf8))) + return false; + + m->descriptor = u; + + if (!descriptor_pool_add(descpool, u, &argcount)) + return false; + +#ifdef ENABLE_VERIFIER + if (opt_verify) { + if (!is_valid_name_utf(m->name)) { + exceptions_throw_classformaterror(c, "Method with invalid name"); + return false; + } + + if (m->name->text[0] == '<' && + m->name != utf_init && m->name != utf_clinit) { + exceptions_throw_classformaterror(c, "Method with invalid special name"); + return false; + } + } +#endif /* ENABLE_VERIFIER */ + + if (!(m->flags & ACC_STATIC)) + argcount++; /* count the 'this' argument */ + +#ifdef ENABLE_VERIFIER + if (opt_verify) { + if (argcount > 255) { + exceptions_throw_classformaterror(c, "Too many arguments in signature"); + return false; + } + + /* check flag consistency */ + if (m->name != utf_clinit) { + i = (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED)); + + if (i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) { + exceptions_throw_classformaterror(c, + "Illegal method modifiers: 0x%X", + m->flags); + return false; + } + + if (m->flags & ACC_ABSTRACT) { + if ((m->flags & (ACC_FINAL | ACC_NATIVE | ACC_PRIVATE | + ACC_STATIC | ACC_STRICT | ACC_SYNCHRONIZED))) { + exceptions_throw_classformaterror(c, + "Illegal method modifiers: 0x%X", + m->flags); + return false; + } + } + + if (c->flags & ACC_INTERFACE) { + if ((m->flags & (ACC_ABSTRACT | ACC_PUBLIC)) != (ACC_ABSTRACT | ACC_PUBLIC)) { + exceptions_throw_classformaterror(c, + "Illegal method modifiers: 0x%X", + m->flags); + return false; + } + } + + if (m->name == utf_init) { + if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED | + ACC_NATIVE | ACC_ABSTRACT)) { + exceptions_throw_classformaterror(c, "Instance initialization method has invalid flags set"); + return false; + } + } + } + } +#endif /* ENABLE_VERIFIER */ + + /* mark the method as monomorphic until further notice */ + + m->flags |= ACC_METHOD_MONOMORPHIC; + + /* non-abstract methods have an implementation in this class */ + + if (!(m->flags & ACC_ABSTRACT)) + m->flags |= ACC_METHOD_IMPLEMENTED; + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* attributes count */ + + attributes_count = suck_u2(cb); + + for (i = 0; i < attributes_count; i++) { + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* attribute name index */ + + attribute_name_index = suck_u2(cb); + + attribute_name = + class_getconstant(c, attribute_name_index, CONSTANT_Utf8); + + if (attribute_name == NULL) + return false; + + if (attribute_name == utf_Code) { + /* Code */ + + if (m->flags & (ACC_ABSTRACT | ACC_NATIVE)) { + exceptions_throw_classformaterror(c, "Code attribute in native or abstract methods"); + return false; + } + + if (m->jcode) { + exceptions_throw_classformaterror(c, "Multiple Code attributes"); + return false; + } + + if (!suck_check_classbuffer_size(cb, 4 + 2 + 2)) + return false; + + suck_u4(cb); + m->maxstack = suck_u2(cb); + m->maxlocals = suck_u2(cb); + + if (m->maxlocals < argcount) { + exceptions_throw_classformaterror(c, "Arguments can't fit into locals"); + return false; + } + + if (!suck_check_classbuffer_size(cb, 4)) + return false; + + m->jcodelength = suck_u4(cb); + + if (m->jcodelength == 0) { + exceptions_throw_classformaterror(c, "Code of a method has length 0"); + return false; + } + + if (m->jcodelength > 65535) { + exceptions_throw_classformaterror(c, "Code of a method longer than 65535 bytes"); + return false; + } + + if (!suck_check_classbuffer_size(cb, m->jcodelength)) + return false; + + m->jcode = MNEW(u1, m->jcodelength); + suck_nbytes(m->jcode, cb, m->jcodelength); + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + m->rawexceptiontablelength = suck_u2(cb); + if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * m->rawexceptiontablelength)) + return false; + + m->rawexceptiontable = MNEW(raw_exception_entry, m->rawexceptiontablelength); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + count_vmcode_len += m->jcodelength + 18; + count_extable_len += + m->rawexceptiontablelength * sizeof(raw_exception_entry); + } +#endif + + for (j = 0; j < m->rawexceptiontablelength; j++) { + u4 idx; + m->rawexceptiontable[j].startpc = suck_u2(cb); + m->rawexceptiontable[j].endpc = suck_u2(cb); + m->rawexceptiontable[j].handlerpc = suck_u2(cb); + + idx = suck_u2(cb); + + if (!idx) { + m->rawexceptiontable[j].catchtype.any = NULL; + } + else { + /* the classref is created later */ + if (!(m->rawexceptiontable[j].catchtype.any = + (utf *) class_getconstant(c, idx, CONSTANT_Class))) + return false; + } + } + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* code attributes count */ + + code_attributes_count = suck_u2(cb); + + for (k = 0; k < code_attributes_count; k++) { + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* code attribute name index */ + + code_attribute_name_index = suck_u2(cb); + + code_attribute_name = + class_getconstant(c, code_attribute_name_index, CONSTANT_Utf8); + + if (code_attribute_name == NULL) + return false; + + /* check which code attribute */ + + if (code_attribute_name == utf_LineNumberTable) { + /* LineNumberTable */ + + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* attribute length */ + + (void) suck_u4(cb); + + /* line number table length */ + + m->linenumbercount = suck_u2(cb); + + if (!suck_check_classbuffer_size(cb, + (2 + 2) * m->linenumbercount)) + return false; + + m->linenumbers = MNEW(lineinfo, m->linenumbercount); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_lineinfo += sizeof(lineinfo) * m->linenumbercount; +#endif + + for (l = 0; l < m->linenumbercount; l++) { + m->linenumbers[l].start_pc = suck_u2(cb); + m->linenumbers[l].line_number = suck_u2(cb); + } + } +#if defined(ENABLE_JAVASE) + else if (code_attribute_name == utf_StackMapTable) { + /* StackTableMap */ + + if (!stackmap_load_attribute_stackmaptable(cb, m)) + return false; + } +#endif + else { + /* unknown code attribute */ + + if (!loader_skip_attribute_body(cb)) + return false; + } + } + } + else if (attribute_name == utf_Exceptions) { + /* Exceptions */ + + if (m->thrownexceptions != NULL) { + exceptions_throw_classformaterror(c, "Multiple Exceptions attributes"); + return false; + } + + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* attribute length */ + + (void) suck_u4(cb); + + m->thrownexceptionscount = suck_u2(cb); + + if (!suck_check_classbuffer_size(cb, 2 * m->thrownexceptionscount)) + return false; + + m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount); + + for (j = 0; j < m->thrownexceptionscount; j++) { + /* the classref is created later */ + if (!((m->thrownexceptions)[j].any = + (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Class))) + return false; + } + } +#if defined(ENABLE_JAVASE) + else if (attribute_name == utf_Signature) { + /* Signature */ + + if (!loader_load_attribute_signature(cb, &(m->signature))) + return false; + } + +#if defined(ENABLE_ANNOTATIONS) + else if (attribute_name == utf_RuntimeVisibleAnnotations) { + /* RuntimeVisibleAnnotations */ + if (!annotation_load_method_attribute_runtimevisibleannotations(cb, m)) + return false; + } + else if (attribute_name == utf_RuntimeInvisibleAnnotations) { + /* RuntimeInvisibleAnnotations */ + if (!annotation_load_method_attribute_runtimeinvisibleannotations(cb, m)) + return false; + } + else if (attribute_name == utf_RuntimeVisibleParameterAnnotations) { + /* RuntimeVisibleParameterAnnotations */ + if (!annotation_load_method_attribute_runtimevisibleparameterannotations(cb, m)) + return false; + } + else if (attribute_name == utf_RuntimeInvisibleParameterAnnotations) { + /* RuntimeInvisibleParameterAnnotations */ + if (!annotation_load_method_attribute_runtimeinvisibleparameterannotations(cb, m)) + return false; + } + else if (attribute_name == utf_AnnotationDefault) { + /* AnnotationDefault */ + if (!annotation_load_method_attribute_annotationdefault(cb, m)) + return false; + } +#endif +#endif + else { + /* unknown attribute */ + + if (!loader_skip_attribute_body(cb)) + return false; + } + } + + if ((m->jcode == NULL) && !(m->flags & (ACC_ABSTRACT | ACC_NATIVE))) { + exceptions_throw_classformaterror(c, "Missing Code attribute"); + return false; + } + +#if defined(ENABLE_REPLACEMENT) + /* initialize the hit countdown field */ + + m->hitcountdown = METHOD_INITIAL_HIT_COUNTDOWN; +#endif + + /* everything was ok */ + + return true; +} + + +/* method_free ***************************************************************** + + Frees all memory that was allocated for this method. + +*******************************************************************************/ + +void method_free(methodinfo *m) +{ + if (m->mutex) + Mutex_delete(m->mutex); + + if (m->jcode) + MFREE(m->jcode, u1, m->jcodelength); + + if (m->rawexceptiontable) + MFREE(m->rawexceptiontable, raw_exception_entry, m->rawexceptiontablelength); + + code_free_code_of_method(m); + + if (m->stubroutine) { + if (m->flags & ACC_NATIVE) { + NativeStub_remove(m->stubroutine); + } + else { + CompilerStub_remove(m->stubroutine); + } + } +} + + +/* method_canoverwrite ********************************************************* + + Check if m and old are identical with respect to type and + name. This means that old can be overwritten with m. + +*******************************************************************************/ + +bool method_canoverwrite(methodinfo *m, methodinfo *old) +{ + if (m->name != old->name) + return false; + + if (m->descriptor != old->descriptor) + return false; + + if (m->flags & ACC_STATIC) + return false; + + return true; +} + + +/* method_new_builtin ********************************************************** + + Creates a minimal methodinfo structure for builtins. This comes handy + when dealing with builtin stubs or stacktraces. + +*******************************************************************************/ + +methodinfo *method_new_builtin(builtintable_entry *bte) +{ + methodinfo *m; + + /* allocate the methodinfo structure */ + + m = NEW(methodinfo); + + /* initialize methodinfo structure */ + + MZERO(m, methodinfo, 1); + + m->mutex = Mutex_new(); + m->flags = ACC_METHOD_BUILTIN; + m->parseddesc = bte->md; + m->name = bte->name; + m->descriptor = bte->descriptor; + + /* return the newly created methodinfo */ + + return m; +} + + +/* method_vftbl_lookup ********************************************************* + + Does a method lookup in the passed virtual function table. This + function does exactly the same thing as JIT, but additionally + relies on the fact, that the methodinfo pointer is at the first + data segment slot (even for compiler stubs). + +*******************************************************************************/ + +methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m) +{ + methodptr mptr; + methodptr *pmptr; + methodinfo *resm; /* pointer to new resolved method */ + + /* If the method is not an instance method, just return it. */ + + if (m->flags & ACC_STATIC) + return m; + + assert(vftbl); + + /* Get the method from the virtual function table. Is this an + interface method? */ + + if (m->clazz->flags & ACC_INTERFACE) { + pmptr = vftbl->interfacetable[-(m->clazz->index)]; + mptr = pmptr[(m - m->clazz->methods)]; + } + else { + mptr = vftbl->table[m->vftblindex]; + } + + /* and now get the codeinfo pointer from the first data segment slot */ + + resm = code_get_methodinfo_for_pv(mptr); + + return resm; +} + + +/* method_get_parametercount ************************************************** + + Use the descriptor of a method to determine the number of parameters + of the method. The this pointer of non-static methods is not counted. + + IN: + m........the method of which the parameters should be counted + + RETURN VALUE: + The parameter count or -1 on error. + +*******************************************************************************/ + +int32_t method_get_parametercount(methodinfo *m) +{ + methoddesc *md; /* method descriptor of m */ + int32_t paramcount = 0; /* the parameter count of m */ + + md = m->parseddesc; + + /* is the descriptor fully parsed? */ + + if (md->params == NULL) { + if (!descriptor_params_from_paramtypes(md, m->flags)) { + return -1; + } + } + + paramcount = md->paramcount; + + /* skip `this' pointer */ + + if (!(m->flags & ACC_STATIC)) { + --paramcount; + } + + return paramcount; +} + + +/* method_get_parametertypearray *********************************************** + + Use the descriptor of a method to generate a java.lang.Class array + which contains the classes of the parametertypes of the method. + + This function is called by java.lang.reflect.{Constructor,Method}. + +*******************************************************************************/ + +java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m) +{ + methoddesc *md; + typedesc *paramtypes; + int32_t paramcount; + java_handle_objectarray_t *oa; + int32_t i; + classinfo *c; + + md = m->parseddesc; + + /* is the descriptor fully parsed? */ + + if (m->parseddesc->params == NULL) + if (!descriptor_params_from_paramtypes(md, m->flags)) + return NULL; + + paramtypes = md->paramtypes; + paramcount = md->paramcount; + + /* skip `this' pointer */ + + if (!(m->flags & ACC_STATIC)) { + paramtypes++; + paramcount--; + } + + /* create class-array */ + + oa = builtin_anewarray(paramcount, class_java_lang_Class); + + if (oa == NULL) + return NULL; + + /* get classes */ + + for (i = 0; i < paramcount; i++) { + if (!resolve_class_from_typedesc(¶mtypes[i], true, false, &c)) + return NULL; + + LLNI_array_direct(oa, i) = (java_object_t *) c; + } + + return oa; +} + + +/* method_get_exceptionarray *************************************************** + + Get the exceptions which can be thrown by a method. + +*******************************************************************************/ + +java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m) +{ + java_handle_objectarray_t *oa; + classinfo *c; + s4 i; + + /* create class-array */ + + oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class); + + if (oa == NULL) + return NULL; + + /* iterate over all exceptions and store the class in the array */ + + for (i = 0; i < m->thrownexceptionscount; i++) { + c = resolve_classref_or_classinfo_eager(m->thrownexceptions[i], true); + + if (c == NULL) + return NULL; + + LLNI_array_direct(oa, i) = (java_object_t *) c; + } + + return oa; +} + + +/* method_returntype_get ******************************************************* + + Get the return type of the method. + +*******************************************************************************/ + +classinfo *method_returntype_get(methodinfo *m) +{ + typedesc *td; + classinfo *c; + + td = &(m->parseddesc->returntype); + + if (!resolve_class_from_typedesc(td, true, false, &c)) + return NULL; + + return c; +} + + +/* method_count_implementations ************************************************ + + Count the implementations of a method in a class cone (a class and all its + subclasses.) + + IN: + m................the method to count + c................class at which to start the counting (this class and + all its subclasses will be searched) + + OUT: + *found...........if found != NULL, *found receives the method + implementation that was found. This value is only + meaningful if the return value is 1. + + RETURN VALUE: + the number of implementations found + +*******************************************************************************/ + +s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found) +{ + s4 count; + methodinfo *mp; + methodinfo *mend; + classinfo *child; + + count = 0; + + mp = c->methods; + mend = mp + c->methodscount; + + for (; mp < mend; ++mp) { + if (method_canoverwrite(mp, m)) { + if (found) + *found = mp; + count++; + break; + } + } + + for (child = c->sub; child != NULL; child = child->nextsub) { + count += method_count_implementations(m, child, found); + } + + return count; +} + + +/* method_get_annotations ****************************************************** + + Get a methods' unparsed annotations in a byte array. + + IN: + m........the method of which the annotations should be returned + + RETURN VALUE: + The unparsed annotations in a byte array (or NULL if there aren't any). + +*******************************************************************************/ + +java_handle_bytearray_t *method_get_annotations(methodinfo *m) +{ +#if defined(ENABLE_ANNOTATIONS) + classinfo *c; /* methods' declaring class */ + int slot; /* methods' slot */ + java_handle_t *annotations; /* methods' unparsed annotations */ + java_handle_t *method_annotations; /* all methods' unparsed annotations */ + /* of the declaring class */ + + c = m->clazz; + slot = m - c->methods; + annotations = NULL; + + LLNI_classinfo_field_get(c, method_annotations, method_annotations); + + /* the method_annotations array might be shorter then the method + * count if the methods above a certain index have no annotations. + */ + if (method_annotations != NULL && + array_length_get(method_annotations) > slot) { + annotations = array_objectarray_element_get( + (java_handle_objectarray_t*)method_annotations, slot); + } + + return (java_handle_bytearray_t*)annotations; +#else + return NULL; +#endif +} + + +/* method_get_parameterannotations ******************************************** + + Get a methods' unparsed parameter annotations in an array of byte + arrays. + + IN: + m........the method of which the parameter annotations should be + returned + + RETURN VALUE: + The unparsed parameter annotations in a byte array (or NULL if + there aren't any). + +*******************************************************************************/ + +java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m) +{ +#if defined(ENABLE_ANNOTATIONS) + classinfo *c; /* methods' declaring class */ + int slot; /* methods' slot */ + java_handle_t *parameterAnnotations; /* methods' unparsed */ + /* parameter annotations */ + java_handle_t *method_parameterannotations; /* all methods' unparsed */ + /* parameter annotations of */ + /* the declaring class */ + + c = m->clazz; + slot = m - c->methods; + parameterAnnotations = NULL; + + LLNI_classinfo_field_get( + c, method_parameterannotations, method_parameterannotations); + + /* the method_annotations array might be shorter then the method + * count if the methods above a certain index have no annotations. + */ + if (method_parameterannotations != NULL && + array_length_get(method_parameterannotations) > slot) { + parameterAnnotations = array_objectarray_element_get( + (java_handle_objectarray_t*)method_parameterannotations, + slot); + } + + return (java_handle_bytearray_t*)parameterAnnotations; +#else + return NULL; +#endif +} + + +/* method_get_annotationdefault *********************************************** + + Get a methods' unparsed annotation default value in a byte array. + + IN: + m........the method of which the annotation default value should be + returned + + RETURN VALUE: + The unparsed annotation default value in a byte array (or NULL if + there isn't one). + +*******************************************************************************/ + +java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m) +{ +#if defined(ENABLE_ANNOTATIONS) + classinfo *c; /* methods' declaring class */ + int slot; /* methods' slot */ + java_handle_t *annotationDefault; /* methods' unparsed */ + /* annotation default value */ + java_handle_t *method_annotationdefaults; /* all methods' unparsed */ + /* annotation default values of */ + /* the declaring class */ + + c = m->clazz; + slot = m - c->methods; + annotationDefault = NULL; + + LLNI_classinfo_field_get( + c, method_annotationdefaults, method_annotationdefaults); + + /* the method_annotations array might be shorter then the method + * count if the methods above a certain index have no annotations. + */ + if (method_annotationdefaults != NULL && + array_length_get(method_annotationdefaults) > slot) { + annotationDefault = array_objectarray_element_get( + (java_handle_objectarray_t*)method_annotationdefaults, slot); + } + + return (java_handle_bytearray_t*)annotationDefault; +#else + return NULL; +#endif +} + + +/* method_add_to_worklist ****************************************************** + + Add the method to the given worklist. If the method already occurs in + the worklist, the worklist remains unchanged. + +*******************************************************************************/ + +static void method_add_to_worklist(methodinfo *m, method_worklist **wl) +{ + method_worklist *wi; + + for (wi = *wl; wi != NULL; wi = wi->next) + if (wi->m == m) + return; + + wi = NEW(method_worklist); + wi->next = *wl; + wi->m = m; + + *wl = wi; +} + + +/* method_add_assumption_monomorphic ******************************************* + + Record the assumption that the method is monomorphic. + + IN: + m.................the method + caller............the caller making the assumption + +*******************************************************************************/ + +void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller) +{ + method_assumption *as; + + /* XXX LOCKING FOR THIS FUNCTION? */ + + /* check if we already have registered this assumption */ + + for (as = m->assumptions; as != NULL; as = as->next) { + if (as->context == caller) + return; + } + + /* register the assumption */ + + as = NEW(method_assumption); + as->next = m->assumptions; + as->context = caller; + + m->assumptions = as; +} + +/* method_break_assumption_monomorphic ***************************************** + + Break the assumption that this method is monomorphic. All callers that + have registered this assumption are added to the worklist. + + IN: + m.................the method + wl................worklist where to add invalidated callers + +*******************************************************************************/ + +void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl) +{ + method_assumption *as; + + /* XXX LOCKING FOR THIS FUNCTION? */ + + for (as = m->assumptions; as != NULL; as = as->next) { + INLINELOG( + printf("ASSUMPTION BROKEN (monomorphism): "); + method_print(m); + printf(" in "); + method_println(as->context); + ); + + method_add_to_worklist(as->context, wl); + +#if defined(ENABLE_TLH) && 0 + /* XXX hack */ + method_assumption *as2; + as2 = m->assumptions; + m->assumptions = NULL; + method_break_assumption_monomorphic(as->context, wl); + /* + assert(m->assumptions == NULL); + m->assumptions = as2;*/ +#endif + + } +} + +/* method_printflags *********************************************************** + + Prints the flags of a method to stdout like. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void method_printflags(methodinfo *m) +{ + if (m == NULL) { + printf("NULL"); + return; + } + + if (m->flags & ACC_PUBLIC) printf(" PUBLIC"); + if (m->flags & ACC_PRIVATE) printf(" PRIVATE"); + if (m->flags & ACC_PROTECTED) printf(" PROTECTED"); + if (m->flags & ACC_STATIC) printf(" STATIC"); + if (m->flags & ACC_FINAL) printf(" FINAL"); + if (m->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED"); + if (m->flags & ACC_VOLATILE) printf(" VOLATILE"); + if (m->flags & ACC_TRANSIENT) printf(" TRANSIENT"); + if (m->flags & ACC_NATIVE) printf(" NATIVE"); + if (m->flags & ACC_INTERFACE) printf(" INTERFACE"); + if (m->flags & ACC_ABSTRACT) printf(" ABSTRACT"); + if (m->flags & ACC_METHOD_BUILTIN) printf(" (builtin)"); + if (m->flags & ACC_METHOD_MONOMORPHIC) printf(" (mono)"); + if (m->flags & ACC_METHOD_IMPLEMENTED) printf(" (impl)"); +} +#endif /* !defined(NDEBUG) */ + + +/* method_print **************************************************************** + + Prints a method to stdout like: + + java.lang.Object.()V + +*******************************************************************************/ + +#if !defined(NDEBUG) +void method_print(methodinfo *m) +{ + if (m == NULL) { + printf("NULL"); + return; + } + + if (m->clazz != NULL) + utf_display_printable_ascii_classname(m->clazz->name); + else + printf("NULL"); + printf("."); + utf_display_printable_ascii(m->name); + utf_display_printable_ascii(m->descriptor); + + method_printflags(m); +} +#endif /* !defined(NDEBUG) */ + + +/* method_println ************************************************************** + + Prints a method plus new line to stdout like: + + java.lang.Object.()V + +*******************************************************************************/ + +#if !defined(NDEBUG) +void method_println(methodinfo *m) +{ + if (opt_debugcolor) printf("\033[31m"); /* red */ + method_print(m); + if (opt_debugcolor) printf("\033[m"); + printf("\n"); +} +#endif /* !defined(NDEBUG) */ + + +/* method_methodref_print ****************************************************** + + Prints a method reference to stdout. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void method_methodref_print(constant_FMIref *mr) +{ + if (!mr) { + printf("(constant_FMIref *)NULL"); + return; + } + + if (IS_FMIREF_RESOLVED(mr)) { + printf(" "); + method_print(mr->p.method); + } + else { + printf(" "); + utf_display_printable_ascii_classname(mr->p.classref->name); + printf("."); + utf_display_printable_ascii(mr->name); + utf_display_printable_ascii(mr->descriptor); + } +} +#endif /* !defined(NDEBUG) */ + + +/* method_methodref_println **************************************************** + + Prints a method reference to stdout, followed by a newline. + +*******************************************************************************/ + +#if !defined(NDEBUG) +void method_methodref_println(constant_FMIref *mr) +{ + method_methodref_print(mr); + printf("\n"); +} +#endif /* !defined(NDEBUG) */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/method.h b/src/vm/method.h new file mode 100644 index 000000000..994a6c229 --- /dev/null +++ b/src/vm/method.h @@ -0,0 +1,231 @@ +/* src/vm/method.h - method functions header + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _METHOD_H +#define _METHOD_H + +/* forward typedefs ***********************************************************/ + +typedef struct methodinfo methodinfo; +typedef struct raw_exception_entry raw_exception_entry; +typedef struct lineinfo lineinfo; +typedef struct method_assumption method_assumption; +typedef struct method_worklist method_worklist; +typedef struct codeinfo codeinfo; + +#include "config.h" +#include "vm/types.h" + +#include "threads/mutex.hpp" + +#include "vm/jit/builtin.hpp" +#include "vm/descriptor.h" +#include "vm/global.h" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/references.h" + +#if defined(ENABLE_JAVASE) +# include "vm/stackmap.h" +#endif + +#include "vm/utf8.h" + + +#if defined(ENABLE_REPLACEMENT) +/* Initial value for the hit countdown field of each method. */ +#define METHOD_INITIAL_HIT_COUNTDOWN 1000 +#endif + + +/* methodinfo *****************************************************************/ + +struct methodinfo { /* method structure */ + Mutex *mutex; /* we need this in jit's locking */ + s4 flags; /* ACC flags */ + utf *name; /* name of method */ + utf *descriptor; /* JavaVM descriptor string of method */ +#if defined(ENABLE_JAVASE) + utf *signature; /* Signature attribute */ + stack_map_t *stack_map; /* StackMapTable attribute */ +#endif + + methoddesc *parseddesc; /* parsed descriptor */ + + classinfo *clazz; /* class, the method belongs to */ + s4 vftblindex; /* index of method in virtual function */ + /* table (if it is a virtual method) */ + s4 maxstack; /* maximum stack depth of method */ + s4 maxlocals; /* maximum number of local variables */ + s4 jcodelength; /* length of JavaVM code */ + u1 *jcode; /* pointer to JavaVM code */ + + s4 rawexceptiontablelength; /* exceptiontable length */ + raw_exception_entry *rawexceptiontable; /* the exceptiontable */ + + u2 thrownexceptionscount; /* number of exceptions attribute */ + classref_or_classinfo *thrownexceptions; /* except. a method may throw */ + + u2 linenumbercount; /* number of linenumber attributes */ + lineinfo *linenumbers; /* array of lineinfo items */ + + u1 *stubroutine; /* stub for compiling or calling natives */ + codeinfo *code; /* current code of this method */ + +#if defined(ENABLE_LSRA) + s4 maxlifetimes; /* helper for lsra */ +#endif + + methodinfo *overwrites; /* method that is directly overwritten */ + method_assumption *assumptions; /* list of assumptions about this method */ + +#if defined(ENABLE_REPLACEMENT) + s4 hitcountdown; /* decreased for each hit */ +#endif + +#if defined(ENABLE_DEBUG_FILTER) + u1 filtermatches; /* flags indicating which filters the method matches */ +#endif + +#if defined(ENABLE_ESCAPE) + u1 *paramescape; +#endif +}; + +/* method_assumption *********************************************************** + + This struct is used for registering assumptions about methods. + +*******************************************************************************/ + +struct method_assumption { + method_assumption *next; + methodinfo *context; +}; + + +/* method_worklist ************************************************************* + + List node used for method worklists. + +*******************************************************************************/ + +struct method_worklist { + method_worklist *next; + methodinfo *m; +}; + + +/* raw_exception_entry ********************************************************/ + +/* exception table entry read by the loader */ + +struct raw_exception_entry { /* exceptiontable entry in a method */ + classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall) */ + u2 startpc; /* start pc of guarded area (inclusive) */ + u2 endpc; /* end pc of guarded area (exklusive) */ + u2 handlerpc; /* pc of exception handler */ +}; + + +/* lineinfo *******************************************************************/ + +struct lineinfo { + u2 start_pc; + u2 line_number; +}; + + +/* global variables ***********************************************************/ + +extern methodinfo *method_java_lang_reflect_Method_invoke; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* inline functions ***********************************************************/ + +inline static bool method_is_builtin(methodinfo* m) +{ + return m->flags & ACC_METHOD_BUILTIN; +} + + +/* function prototypes ********************************************************/ + +void method_init(void); + +bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool); +void method_free(methodinfo *m); +bool method_canoverwrite(methodinfo *m, methodinfo *old); + +methodinfo *method_new_builtin(builtintable_entry *bte); + +methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m); + +int32_t method_get_parametercount(methodinfo *m); +java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m); +java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m); +classinfo *method_returntype_get(methodinfo *m); + +void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller); +void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl); + +s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found); + +java_handle_bytearray_t *method_get_annotations(methodinfo *m); +java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m); +java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m); + +#if !defined(NDEBUG) +void method_printflags(methodinfo *m); +void method_print(methodinfo *m); +void method_println(methodinfo *m); +void method_methodref_print(constant_FMIref *mr); +void method_methodref_println(constant_FMIref *mr); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _METHOD_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/options.c b/src/vm/options.c new file mode 100644 index 000000000..cb4fd010e --- /dev/null +++ b/src/vm/options.c @@ -0,0 +1,850 @@ +/* src/vm/options.c - contains global options + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include + +#include "mm/memory.h" + +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/vm.hpp" + + +/* command line option ********************************************************/ + +s4 opt_index = 0; /* index of processed arguments */ +char *opt_arg; /* this one exports the option argument */ + +bool opt_foo = false; /* option for development */ + +bool opt_jar = false; + +#if defined(ENABLE_JIT) +bool opt_jit = true; /* JIT mode execution (default) */ +bool opt_intrp = false; /* interpreter mode execution */ +#else +bool opt_jit = false; /* JIT mode execution */ +bool opt_intrp = true; /* interpreter mode execution (default) */ +#endif + +bool opt_run = true; + +s4 opt_heapmaxsize = 0; /* maximum heap size */ +s4 opt_heapstartsize = 0; /* initial heap size */ +s4 opt_stacksize = 0; /* thread stack size */ + +bool opt_verbose = false; +bool opt_debugcolor = false; /* use ANSI terminal sequences */ +bool compileall = false; + +bool loadverbose = false; +bool initverbose = false; + +bool opt_verboseclass = false; +bool opt_verbosegc = false; +bool opt_verbosejni = false; +bool opt_verbosecall = false; /* trace all method invocation */ + +bool showmethods = false; +bool showconstantpool = false; +bool showutf = false; + +char *opt_method = NULL; +char *opt_signature = NULL; + +bool compileverbose = false; /* trace compiler actions */ +bool showstack = false; + +bool opt_showdisassemble = false; /* generate disassembler listing */ +bool opt_showddatasegment = false; /* generate data segment listing */ +bool opt_showintermediate = false; /* generate intermediate code listing */ + +bool checkbounds = true; /* check array bounds */ +bool opt_noieee = false; /* don't implement ieee compliant floats */ +bool checksync = true; /* do synchronization */ +#if defined(ENABLE_LOOP) +bool opt_loops = false; /* optimize array accesses in loops */ +#endif + +bool makeinitializations = true; + +#if defined(ENABLE_STATISTICS) +bool opt_stat = false; +bool opt_getloadingtime = false; /* to measure the runtime */ +bool opt_getcompilingtime = false; /* compute compile time */ +#endif +#if defined(ENABLE_VERIFIER) +bool opt_verify = true; /* true if classfiles should be verified */ +#endif + +#if defined(ENABLE_PROFILING) +bool opt_prof = false; +bool opt_prof_bb = false; +#endif + +#if defined(ENABLE_OPAGENT) +bool opt_opagent = false; +#endif + +/* optimization options *******************************************************/ + +#if defined(ENABLE_IFCONV) +bool opt_ifconv = false; +#endif + +#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) +bool opt_lsra = false; +#endif +#if defined(ENABLE_SSA) +bool opt_ssa_dce = false; /* enable dead code elemination */ +bool opt_ssa_cp = false; /* enable copy propagation */ +#endif + + +/* interpreter options ********************************************************/ + +#if defined(ENABLE_INTRP) +bool opt_no_dynamic = false; /* suppress dynamic superinstructions */ +bool opt_no_replication = false; /* don't use replication in intrp */ +bool opt_no_quicksuper = false; /* instructions for quickening cannot be + part of dynamic superinstructions */ + +s4 opt_static_supers = 0x7fffffff; +bool vm_debug = false; /* XXX this should be called `opt_trace' */ +#endif + +#if defined(ENABLE_DEBUG_FILTER) +const char *opt_filter_verbosecall_include = 0; +const char *opt_filter_verbosecall_exclude = 0; +const char *opt_filter_show_method = 0; +#endif + + +/* -XX options ****************************************************************/ + +/* NOTE: For better readability keep these alpha-sorted. */ + +/* Options which must always be available (production options in + HotSpot). */ + +int64_t opt_MaxDirectMemorySize = -1; +int opt_MaxPermSize = 0; +int opt_PermSize = 0; +int opt_ThreadStackSize = 0; + +/* Debugging options which can be turned off. */ + +int opt_DebugExceptions = 0; +int opt_DebugFinalizer = 0; +int opt_DebugLocalReferences = 0; +int opt_DebugLocks = 0; +int opt_DebugPackage = 0; +int opt_DebugPatcher = 0; +int opt_DebugProperties = 0; +int opt_DebugStackFrameInfo = 0; +int opt_DebugStackTrace = 0; +int opt_DebugThreads = 0; +#if defined(ENABLE_DISASSEMBLER) +int opt_DisassembleStubs = 0; +#endif +#if defined(ENABLE_OPAGENT) +int opt_EnableOpagent = 0; +#endif +#if defined(ENABLE_GC_CACAO) +int opt_GCDebugRootSet = 0; +int opt_GCStress = 0; +#endif +#if defined(ENABLE_INLINING) +int opt_Inline = 0; +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) +int opt_InlineAll = 0; +int opt_InlineCount = INT_MAX; +int opt_InlineMaxSize = INT_MAX; +int opt_InlineMinSize = 0; +#endif +#endif +int opt_PrintConfig = 0; +int opt_ProfileGCMemoryUsage = 0; +int opt_ProfileMemoryUsage = 0; +FILE *opt_ProfileMemoryUsageGNUPlot = NULL; +#if defined(ENABLE_REPLACEMENT) +int opt_TestReplacement = 0; +#endif +int opt_TraceCompilerCalls = 0; +int opt_TraceExceptions = 0; +int opt_TraceHPI = 0; +#if defined(ENABLE_INLINING) && !defined(NDEBUG) +int opt_TraceInlining = 0; +#endif +int opt_TraceJavaCalls = 0; +int opt_TraceJNICalls = 0; +int opt_TraceJVMCalls = 0; +int opt_TraceJVMCallsVerbose = 0; +int opt_TraceLinkClass = 0; +#if defined(ENABLE_REPLACEMENT) +int opt_TraceReplacement = 0; +#endif +int opt_TraceSubsystemInitialization = 0; +int opt_TraceTraps = 0; + + +enum { + OPT_TYPE_BOOLEAN, + OPT_TYPE_VALUE +}; + +enum { + /* Options which must always be available (production options in + HotSpot). */ + + OPT_MaxDirectMemorySize, + OPT_MaxPermSize, + OPT_PermSize, + OPT_ThreadStackSize, + + /* Debugging options which can be turned off. */ + + OPT_DebugExceptions, + OPT_DebugFinalizer, + OPT_DebugLocalReferences, + OPT_DebugLocks, + OPT_DebugPackage, + OPT_DebugPatcher, + OPT_DebugProperties, + OPT_DebugStackFrameInfo, + OPT_DebugStackTrace, + OPT_DebugThreads, + OPT_DisassembleStubs, + OPT_EnableOpagent, + OPT_GCDebugRootSet, + OPT_GCStress, + OPT_Inline, + OPT_InlineAll, + OPT_InlineCount, + OPT_InlineMaxSize, + OPT_InlineMinSize, + OPT_PrintConfig, + OPT_ProfileGCMemoryUsage, + OPT_ProfileMemoryUsage, + OPT_ProfileMemoryUsageGNUPlot, + OPT_TestReplacement, + OPT_TraceCompilerCalls, + OPT_TraceExceptions, + OPT_TraceHPI, + OPT_TraceInlining, + OPT_TraceJavaCalls, + OPT_TraceJNICalls, + OPT_TraceJVMCalls, + OPT_TraceJVMCallsVerbose, + OPT_TraceLinkClass, + OPT_TraceReplacement, + OPT_TraceSubsystemInitialization, + OPT_TraceTraps, + OPT_Vmlog, + OPT_VmlogStrings, + OPT_VmlogIgnore +}; + + +option_t options_XX[] = { + /* Options which must always be available (production options in + HotSpot). */ + + { "MaxDirectMemorySize", OPT_MaxDirectMemorySize, OPT_TYPE_VALUE, "Maximum total size of NIO direct-buffer allocations" }, + { "MaxPermSize", OPT_MaxPermSize, OPT_TYPE_VALUE, "not implemented" }, + { "PermSize", OPT_PermSize, OPT_TYPE_VALUE, "not implemented" }, + { "ThreadStackSize", OPT_ThreadStackSize, OPT_TYPE_VALUE, "TODO" }, + + /* Debugging options which can be turned off. */ + + { "DebugExceptions", OPT_DebugExceptions, OPT_TYPE_BOOLEAN, "debug exceptions" }, + { "DebugFinalizer", OPT_DebugFinalizer, OPT_TYPE_BOOLEAN, "debug finalizer thread" }, + { "DebugLocalReferences", OPT_DebugLocalReferences, OPT_TYPE_BOOLEAN, "print debug information for local reference tables" }, + { "DebugLocks", OPT_DebugLocks, OPT_TYPE_BOOLEAN, "print debug information for locks" }, + { "DebugPackage", OPT_DebugPackage, OPT_TYPE_BOOLEAN, "debug Java boot-packages" }, + { "DebugPatcher", OPT_DebugPatcher, OPT_TYPE_BOOLEAN, "debug JIT code patching" }, + { "DebugProperties", OPT_DebugProperties, OPT_TYPE_BOOLEAN, "print debug information for properties" }, + { "DebugStackFrameInfo", OPT_DebugStackFrameInfo, OPT_TYPE_BOOLEAN, "TODO" }, + { "DebugStackTrace", OPT_DebugStackTrace, OPT_TYPE_BOOLEAN, "debug stacktrace creation" }, + { "DebugThreads", OPT_DebugThreads, OPT_TYPE_BOOLEAN, "print debug information for threads" }, +#if defined(ENABLE_DISASSEMBLER) + { "DisassembleStubs", OPT_DisassembleStubs, OPT_TYPE_BOOLEAN, "disassemble builtin and native stubs when generated" }, +#endif +#if defined(ENABLE_OPAGENT) + { "EnableOpagent", OPT_EnableOpagent, OPT_TYPE_BOOLEAN, "enable providing JIT output to Oprofile" }, +#endif +#if defined(ENABLE_GC_CACAO) + { "GCDebugRootSet", OPT_GCDebugRootSet, OPT_TYPE_BOOLEAN, "GC: print root-set at collection" }, + { "GCStress", OPT_GCStress, OPT_TYPE_BOOLEAN, "GC: forced collection at every allocation" }, +#endif +#if defined(ENABLE_INLINING) + { "Inline", OPT_Inline, OPT_TYPE_BOOLEAN, "enable method inlining" }, +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) + { "InlineAll", OPT_InlineAll, OPT_TYPE_BOOLEAN, "use inlining in all compilations" }, + { "InlineCount", OPT_InlineCount, OPT_TYPE_VALUE, "stop inlining after the given number of roots" }, + { "InlineMaxSize", OPT_InlineMaxSize, OPT_TYPE_VALUE, "maximum size for inlined result" }, + { "InlineMinSize", OPT_InlineMinSize, OPT_TYPE_VALUE, "minimum size for inlined result" }, +#endif +#endif + { "PrintConfig", OPT_PrintConfig, OPT_TYPE_BOOLEAN, "print VM configuration" }, + { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, OPT_TYPE_VALUE, "profiles GC memory usage in the given interval, is in seconds (default: 5)" }, + { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, OPT_TYPE_VALUE, "TODO" }, + { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, OPT_TYPE_VALUE, "TODO" }, +#if defined(ENABLE_REPLACEMENT) + { "TestReplacement", OPT_TestReplacement, OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" }, +#endif + { "TraceCompilerCalls", OPT_TraceCompilerCalls, OPT_TYPE_BOOLEAN, "trace JIT compiler calls" }, + { "TraceExceptions", OPT_TraceExceptions, OPT_TYPE_BOOLEAN, "trace Exception throwing" }, + { "TraceHPI", OPT_TraceHPI, OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" }, +#if defined(ENABLE_INLINING) && !defined(NDEBUG) + { "TraceInlining", OPT_TraceInlining, OPT_TYPE_VALUE, "trace method inlining with the given verbosity level (default: 1)" }, +#endif +#if !defined(ENABLE_VMLOG) + { "TraceJavaCalls", OPT_TraceJavaCalls, OPT_TYPE_BOOLEAN, "trace Java method calls" }, +#endif + { "TraceJNICalls", OPT_TraceJNICalls, OPT_TYPE_BOOLEAN, "trace JNI method calls" }, + { "TraceJVMCalls", OPT_TraceJVMCalls, OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" }, + { "TraceJVMCallsVerbose", OPT_TraceJVMCallsVerbose, OPT_TYPE_BOOLEAN, "trace all JVM method calls" }, + { "TraceLinkClass", OPT_TraceLinkClass, OPT_TYPE_BOOLEAN, "trace class linking" }, +#if defined(ENABLE_REPLACEMENT) + { "TraceReplacement", OPT_TraceReplacement, OPT_TYPE_VALUE, "trace on-stack replacement with the given verbosity level (default: 1)" }, +#endif + { "TraceSubsystemInitialization", OPT_TraceSubsystemInitialization, OPT_TYPE_BOOLEAN, "trace initialization of subsystems" }, + { "TraceTraps", OPT_TraceTraps, OPT_TYPE_BOOLEAN, "trace traps generated by JIT code" }, +#if defined(ENABLE_VMLOG) + { "Vmlog", OPT_Vmlog, OPT_TYPE_VALUE, "prefix for vmlog trace files (enables vmlog)" }, + { "VmlogStrings", OPT_VmlogStrings, OPT_TYPE_VALUE, "prefix of vmlog string file to load" }, + { "VmlogIgnore", OPT_VmlogIgnore, OPT_TYPE_VALUE, "prefix of vmlog ignore file to load" }, +#endif + + /* end marker */ + + { NULL, -1, -1, NULL } +}; + + +/* options_get ***************************************************************** + + DOCUMENT ME!!! + +*******************************************************************************/ + +int options_get(opt_struct *opts, JavaVMInitArgs *vm_args) +{ + char *option; + int i; + + if (opt_index >= vm_args->nOptions) + return OPT_DONE; + + /* get the current option */ + + option = vm_args->options[opt_index].optionString; + + if ((option == NULL) || (option[0] != '-')) + return OPT_DONE; + + for (i = 0; opts[i].name; i++) { + if (!opts[i].arg) { + /* boolean option found */ + + if (strcmp(option + 1, opts[i].name) == 0) { + opt_index++; + return opts[i].value; + } + + } else { + /* parameter option found */ + + /* with a space between */ + + if (strcmp(option + 1, opts[i].name) == 0) { + opt_index++; + + if (opt_index < vm_args->nOptions) { + opt_arg = os_strdup(vm_args->options[opt_index].optionString); + opt_index++; + return opts[i].value; + } + + return OPT_ERROR; + + } else { + /* parameter and option have no space between */ + + /* FIXME: this assumption is plain wrong, hits you if there is a + * parameter with no argument starting with same letter as param with argument + * but named after that one, ouch! */ + + size_t l = os_strlen(opts[i].name); + + if (os_strlen(option + 1) > l) { + if (memcmp(option + 1, opts[i].name, l) == 0) { + opt_index++; + opt_arg = os_strdup(option + 1 + l); + return opts[i].value; + } + } + } + } + } + + return OPT_ERROR; +} + + +/* options_xxusage ************************************************************* + + Print usage message for debugging options. + +*******************************************************************************/ + +static void options_xxusage(void) +{ + option_t *opt; + int length; + int i; + const char *c; + + /* Prevent compiler warning. */ + + length = 0; + + for (opt = options_XX; opt->name != NULL; opt++) { + printf(" -XX:"); + + switch (opt->type) { + case OPT_TYPE_BOOLEAN: + printf("+%s", opt->name); + length = os_strlen(" -XX:+") + os_strlen(opt->name); + break; + + case OPT_TYPE_VALUE: + printf("%s=", opt->name); + length = os_strlen(" -XX:") + os_strlen(opt->name) + + os_strlen("="); + break; + + default: + vm_abort("options_xxusage: unkown option type %d", opt->type); + } + + /* Check if the help fits into one 80-column line. + Documentation starts at column 29. */ + + if (length < (29 - 1)) { + /* Print missing spaces up to column 29. */ + + for (i = length; i < 29; i++) + printf(" "); + } + else { + printf("\n"); + printf(" "); /* 29 spaces */ + } + + /* Check documentation length. */ + + length = os_strlen(opt->doc); + + if (length < (80 - 29)) { + printf("%s", opt->doc); + } + else { + for (c = opt->doc, i = 29; *c != 0; c++, i++) { + /* If we are at the end of the line, break it. */ + + if (i == 80) { + printf("\n"); + printf(" "); /* 29 spaces */ + i = 29; + } + + printf("%c", *c); + } + } + + printf("\n"); + } + + /* exit with error code */ + + exit(1); +} + + +/* options_xx ****************************************************************** + + Handle -XX: options. + +*******************************************************************************/ + +void options_xx(JavaVMInitArgs *vm_args) +{ + const char *name; + const char *start; + char *end; + int length; + int enable; + char *value; + option_t *opt; + char *filename; + FILE *file; + int i; + + /* Iterate over all passed options. */ + + for (i = 0; i < vm_args->nOptions; i++) { + /* Get the current option. */ + + name = vm_args->options[i].optionString; + + /* Check for help (-XX). */ + + if (strcmp(name, "-XX") == 0) + options_xxusage(); + + /* Check if the option start with -XX. */ + + start = strstr(name, "-XX:"); + + if ((start == NULL) || (start != name)) + continue; + + /* Check if the option is a boolean option. */ + + if (name[4] == '+') { + start = name + 4 + 1; + enable = 1; + } + else if (name[4] == '-') { + start = name + 4 + 1; + enable = 0; + } + else { + start = name + 4; + enable = -1; + } + + /* Search for a '=' in the option name and get the option name + length and the value of the option. */ + + end = strchr(start, '='); + + if (end == NULL) { + length = os_strlen(start); + value = NULL; + } + else { + length = end - start; + value = end + 1; + } + + /* Search the option in the option array. */ + + for (opt = options_XX; opt->name != NULL; opt++) { + if (strncmp(opt->name, start, length) == 0) { + /* Check if the options passed fits to the type. */ + + switch (opt->type) { + case OPT_TYPE_BOOLEAN: + if ((enable == -1) || (value != NULL)) + options_xxusage(); + break; + case OPT_TYPE_VALUE: + if ((enable != -1) || (value == NULL)) + options_xxusage(); + break; + default: + vm_abort("options_xx: unknown option type %d for option %s", + opt->type, opt->name); + } + + break; + } + } + + /* Process the option. */ + + switch (opt->value) { + + /* Options which must always be available (production options + in HotSpot). */ + + case OPT_MaxDirectMemorySize: + opt_MaxDirectMemorySize = os_atoi(value); + break; + + case OPT_MaxPermSize: + /* Currently ignored. */ + break; + + case OPT_PermSize: + /* Currently ignored. */ + break; + + case OPT_ThreadStackSize: + /* currently ignored */ + break; + + /* Debugging options which can be turned off. */ + + case OPT_DebugExceptions: + opt_DebugExceptions = enable; + break; + + case OPT_DebugFinalizer: + opt_DebugFinalizer = enable; + break; + + case OPT_DebugLocalReferences: + opt_DebugLocalReferences = enable; + break; + + case OPT_DebugLocks: + opt_DebugLocks = enable; + break; + + case OPT_DebugPackage: + opt_DebugPackage = enable; + break; + + case OPT_DebugPatcher: + opt_DebugPatcher = enable; + break; + + case OPT_DebugProperties: + opt_DebugProperties = enable; + break; + + case OPT_DebugStackFrameInfo: + opt_DebugStackFrameInfo = enable; + break; + + case OPT_DebugStackTrace: + opt_DebugStackTrace = enable; + break; + + case OPT_DebugThreads: + opt_DebugThreads = enable; + break; + +#if defined(ENABLE_DISASSEMBLER) + case OPT_DisassembleStubs: + opt_DisassembleStubs = enable; + break; +#endif + +#if defined(ENABLE_OPAGENT) + case OPT_EnableOpagent: + opt_EnableOpagent = enable; + break; +#endif + +#if defined(ENABLE_GC_CACAO) + case OPT_GCDebugRootSet: + opt_GCDebugRootSet = enable; + break; + + case OPT_GCStress: + opt_GCStress = enable; + break; +#endif + +#if defined(ENABLE_INLINING) + case OPT_Inline: + opt_Inline = enable; + break; +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) + case OPT_InlineAll: + opt_InlineAll = enable; + break; + + case OPT_InlineCount: + if (value != NULL) + opt_InlineCount = os_atoi(value); + break; + + case OPT_InlineMaxSize: + if (value != NULL) + opt_InlineMaxSize = os_atoi(value); + break; + + case OPT_InlineMinSize: + if (value != NULL) + opt_InlineMinSize = os_atoi(value); + break; +#endif +#endif + + case OPT_PrintConfig: + opt_PrintConfig = enable; + break; + + case OPT_ProfileGCMemoryUsage: + if (value == NULL) + opt_ProfileGCMemoryUsage = 5; + else + opt_ProfileGCMemoryUsage = os_atoi(value); + break; + + case OPT_ProfileMemoryUsage: + if (value == NULL) + opt_ProfileMemoryUsage = 5; + else + opt_ProfileMemoryUsage = os_atoi(value); + +# if defined(ENABLE_STATISTICS) + /* we also need statistics */ + + opt_stat = true; +# endif + break; + + case OPT_ProfileMemoryUsageGNUPlot: + if (value == NULL) + filename = "profile.dat"; + else + filename = value; + + file = fopen(filename, "w"); + + if (file == NULL) + vm_abort_errno("options_xx: fopen failed"); + + opt_ProfileMemoryUsageGNUPlot = file; + break; + +#if defined(ENABLE_REPLACEMENT) + case OPT_TestReplacement: + opt_TestReplacement = enable; + break; +#endif + + case OPT_TraceCompilerCalls: + opt_TraceCompilerCalls = enable; + break; + + case OPT_TraceExceptions: + opt_TraceExceptions = enable; + break; + + case OPT_TraceHPI: + opt_TraceHPI = enable; + break; + +#if defined(ENABLE_INLINING) && !defined(NDEBUG) + case OPT_TraceInlining: + if (value == NULL) + opt_TraceInlining = 1; + else + opt_TraceInlining = os_atoi(value); + break; +#endif + + case OPT_TraceJavaCalls: + opt_verbosecall = enable; + opt_TraceJavaCalls = enable; + break; + + case OPT_TraceJNICalls: + opt_TraceJNICalls = enable; + break; + + case OPT_TraceJVMCalls: + opt_TraceJVMCalls = enable; + break; + + case OPT_TraceJVMCallsVerbose: + opt_TraceJVMCallsVerbose = enable; + break; + + case OPT_TraceLinkClass: + opt_TraceLinkClass = enable; + break; + +#if defined(ENABLE_REPLACEMENT) + case OPT_TraceReplacement: + if (value == NULL) + opt_TraceReplacement = 1; + else + opt_TraceReplacement = os_atoi(value); + break; +#endif + + case OPT_TraceSubsystemInitialization: + opt_TraceSubsystemInitialization = enable; + break; + + case OPT_TraceTraps: + opt_TraceTraps = enable; + break; + +#if defined(ENABLE_VMLOG) + case OPT_Vmlog: + if (value == NULL) + vmlog_cacao_set_prefix("vmlog"); + else + vmlog_cacao_set_prefix(value); + opt_verbosecall = 1; + opt_TraceJavaCalls = 1; + break; + + case OPT_VmlogStrings: + if (value != NULL) + vmlog_cacao_set_stringprefix(value); + break; + + case OPT_VmlogIgnore: + if (value != NULL) + vmlog_cacao_set_ignoreprefix(value); + break; +#endif + + default: + printf("Unknown -XX option: %s\n", name); + break; + } + } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/options.h b/src/vm/options.h new file mode 100644 index 000000000..b36130aec --- /dev/null +++ b/src/vm/options.h @@ -0,0 +1,277 @@ +/* src/vm/options.h - define global options extern + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _OPTIONS_H +#define _OPTIONS_H + +#include "config.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "vm/types.h" + +#include "native/jni.hpp" + +#include "vm/global.h" + + +/* reserved option numbers ****************************************************/ + +/* define these negative since the other options are an enum */ + +#define OPT_DONE -1 +#define OPT_ERROR -2 +#define OPT_IGNORE -3 + + +typedef struct opt_struct opt_struct; + +struct opt_struct { + const char *name; + bool arg; + int value; +}; + + +typedef struct option_t option_t; + +struct option_t { + const char *name; + int value; + int type; + const char *doc; +}; + + +/* global variables ***********************************************************/ + +extern s4 opt_index; +extern char *opt_arg; + +extern bool opt_foo; + +extern bool opt_jit; +extern bool opt_intrp; + +extern bool opt_jar; +extern bool opt_run; + +extern s4 opt_heapmaxsize; +extern s4 opt_heapstartsize; +extern s4 opt_stacksize; + +extern bool opt_verbose; +extern bool opt_debugcolor; +extern bool compileall; + +extern bool loadverbose; /* Print debug messages during loading */ +extern bool initverbose; /* Log class initialization */ + +extern bool opt_verboseclass; +extern bool opt_verbosegc; +extern bool opt_verbosejni; +extern bool opt_verbosecall; + +extern bool showmethods; +extern bool showconstantpool; +extern bool showutf; + +extern char *opt_method; +extern char *opt_signature; + +extern bool compileverbose; +extern bool showstack; + +extern bool opt_showdisassemble; +extern bool opt_showddatasegment; +extern bool opt_showintermediate; + +extern bool checkbounds; +extern bool opt_noieee; +extern bool checksync; +#if defined(ENABLE_LOOP) +extern bool opt_loops; +#endif + +extern bool makeinitializations; + +#if defined(ENABLE_STATISTICS) +extern bool opt_stat; +extern bool opt_getloadingtime; +extern bool opt_getcompilingtime; +#endif +#if defined(ENABLE_VERIFIER) +extern bool opt_verify; +#endif + +#if defined(ENABLE_PROFILING) +extern bool opt_prof; +extern bool opt_prof_bb; +#endif + +/* optimization options *******************************************************/ + +#if defined(ENABLE_IFCONV) +extern bool opt_ifconv; +#endif + +#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) +extern bool opt_lsra; +#endif +#if defined(ENABLE_SSA) +extern bool opt_ssa_dce; /* enable dead code elemination */ +extern bool opt_ssa_cp; /* enable copy propagation */ +#endif + +/* interpreter options ********************************************************/ + +#if defined(ENABLE_INTRP) +extern bool opt_no_dynamic; +extern bool opt_no_replication; +extern bool opt_no_quicksuper; + +extern s4 opt_static_supers; +extern bool vm_debug; +#endif + +/* debug output filtering options *********************************************/ + +#if defined(ENABLE_DEBUG_FILTER) +extern const char *opt_filter_verbosecall_include; +extern const char *opt_filter_verbosecall_exclude; +extern const char *opt_filter_show_method; +#endif + + +/* -XX options ****************************************************************/ + +/* NOTE: For better readability keep these alpha-sorted. */ + +/* Options which must always be available (production options in + HotSpot). */ + +extern int64_t opt_MaxDirectMemorySize; +extern int opt_MaxPermSize; +extern int opt_PermSize; +extern int opt_ThreadStackSize; + +/* Debugging options which can be turned off. */ + +extern int opt_DebugExceptions; +extern int opt_DebugFinalizer; +extern int opt_DebugLocalReferences; +extern int opt_DebugLocks; +extern int opt_DebugPatcher; +extern int opt_DebugPackage; +extern int opt_DebugProperties; +extern int opt_DebugStackFrameInfo; +extern int opt_DebugStackTrace; +extern int opt_DebugThreads; +#if defined(ENABLE_DISASSEMBLER) +extern int opt_DisassembleStubs; +#endif +#if defined(ENABLE_OPAGENT) +extern int opt_EnableOpagent; +#endif +#if defined(ENABLE_GC_CACAO) +extern int opt_GCDebugRootSet; +extern int opt_GCStress; +#endif +#if defined(ENABLE_INLINING) +extern int opt_Inline; +#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) +extern int opt_InlineAll; +extern int opt_InlineCount; +extern int opt_InlineMaxSize; +extern int opt_InlineMinSize; +#endif +#endif +extern int opt_PrintConfig; +extern int opt_ProfileGCMemoryUsage; +extern int opt_ProfileMemoryUsage; +extern FILE *opt_ProfileMemoryUsageGNUPlot; +#if defined(ENABLE_REPLACEMENT) +extern int opt_TestReplacement; +#endif +extern int opt_TraceCompilerCalls; +extern int opt_TraceExceptions; +extern int opt_TraceHPI; +#if defined(ENABLE_INLINING) && !defined(NDEBUG) +extern int opt_TraceInlining; +#endif +extern int opt_TraceJavaCalls; +extern int opt_TraceJNICalls; +extern int opt_TraceJVMCalls; +extern int opt_TraceJVMCallsVerbose; +extern int opt_TraceLinkClass; +#if defined(ENABLE_REPLACEMENT) +extern int opt_TraceReplacement; +#endif +extern int opt_TraceSubsystemInitialization; +extern int opt_TraceTraps; + + +/* function prototypes ********************************************************/ + +int options_get(opt_struct *opts, JavaVMInitArgs *vm_args); +void options_xx(JavaVMInitArgs *vm_args); + + +/* debug **********************************************************************/ + +#if !defined(NDEBUG) +# define TRACESUBSYSTEMINITIALIZATION(text) \ + do { \ + if (opt_TraceSubsystemInitialization) { \ + log_println("[Initializing subsystem: %s]", text); \ + } \ + } while (0) +#else +# define TRACESUBSYSTEMINITIALIZATION(text) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _OPTIONS_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/os.cpp b/src/vm/os.cpp new file mode 100644 index 000000000..b5e8592ae --- /dev/null +++ b/src/vm/os.cpp @@ -0,0 +1,230 @@ +/* src/vm/os.cpp - system (OS) functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +/* NOTE: In this file we check for all system headers, because we wrap + all system calls into functions for better portability. */ + +#if defined(HAVE_ERRNO_H) +# include +#endif + +#if defined(HAVE_STDINT_H) +# include +#endif + +#if defined(HAVE_STRING_H) +# include +#endif + +#if defined(HAVE_UNISTD_H) +# include +#endif + +#if defined(HAVE_SYS_MMAN_H) +# include +#endif + +#if defined(__DARWIN__) +# include +# include +# include +#endif + +/* this should work on BSD */ +/* #include */ + +#include "vm/vm.hpp" + + +/** + * Maps anonymous memory, even on systems not defining + * MAP_ANON(YMOUS). + * + * @param ... + */ +void* os::mmap_anonymous(void *addr, size_t len, int prot, int flags) +{ + void* p; + +#if defined(MAP_ANON) || defined(MAP_ANONYMOUS) + p = mmap(addr, len, prot, +# if defined(MAP_ANON) + MAP_ANON | flags, +# else + MAP_ANONYMOUS | flags, +# endif + -1, 0); +#else + int fd; + + fd = open("/dev/zero", O_RDONLY, 0); + + if (fd == -1) + VM::get_current()->abort_errno("os::mmap_anonymous: open failed"); + + p = mmap(addr, len, prot, flags, fd, 0); +#endif + +#if defined(MAP_FAILED) + if (p == MAP_FAILED) +#else + if (p == (void *) -1) +#endif + VM::get_current()->abort_errno("os::mmap_anonymous: mmap failed"); + + return p; +} + + +/** + * Print a C backtrace. + */ +void os::print_backtrace() +{ +#define BACKTRACE_SIZE 100 + void** array = new void*[SIZEOF_VOID_P * BACKTRACE_SIZE]; + + // Get the backtrace. + int size = backtrace(array, BACKTRACE_SIZE); + + // Resolve the symbols. + char** strings = backtrace_symbols(array, size); + + log_println("Backtrace (%d stack frames):", size); + + for (int i = 0; i < size; i++) + log_println("%s", strings[i]); + + // We have to free the strings. + free(strings); +} + + +/** + * Returns the number of online processors in the system. + * + * @return Number of online processors. + */ +int os::processors_online(void) +{ +#if defined(_SC_NPROC_ONLN) + + return (int) sysconf(_SC_NPROC_ONLN); + +#elif defined(_SC_NPROCESSORS_ONLN) + + return (int) sysconf(_SC_NPROCESSORS_ONLN); + +#elif defined(__DARWIN__) + + host_basic_info_data_t hinfo; + mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT; + kern_return_t rc; + + rc = host_info(mach_host_self(), HOST_BASIC_INFO, + (host_info_t) &hinfo, &hinfo_count); + + if (rc != KERN_SUCCESS) { + return -1; + } + + /* XXX michi: according to my infos this should be + hinfo.max_cpus, can someone please confirm or deny that? */ + return (int) hinfo.avail_cpus; + +#elif defined(__FREEBSD__) +# error IMPLEMENT ME! + + /* this should work in BSD */ + /* + int ncpu, mib[2], rc; + size_t len; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + len = sizeof(ncpu); + rc = sysctl(mib, 2, &ncpu, &len, NULL, 0); + + return (int32_t) ncpu; + */ + +#else + + return 1; + +#endif +} + + +// Legacy C interface. + +extern "C" { + void* os_mmap_anonymous(void *addr, size_t len, int prot, int flags) { return os::mmap_anonymous(addr, len, prot, flags); } + + void os_abort(void) { os::abort(); } + int os_access(const char* pathname, int mode) { return os::access(pathname, mode); } + int os_atoi(const char* nptr) { return os::atoi(nptr); } + void* os_calloc(size_t nmemb, size_t size) { return os::calloc(nmemb, size); } +#if defined(ENABLE_JRE_LAYOUT) + char* os_dirname(char* path) { return os::dirname(path); } +#endif + int os_dlclose(void* handle) { return os::dlclose(handle); } + char* os_dlerror(void) { return os::dlerror(); } + void* os_dlopen(const char* filename, int flag) { return os::dlopen(filename, flag); } + void* os_dlsym(void* handle, const char* symbol) { return os::dlsym(handle, symbol); } + int os_fclose(FILE* fp) { return os::fclose(fp); } + FILE* os_fopen(const char* path, const char* mode) { return os::fopen(path, mode); } + size_t os_fread(void* ptr, size_t size, size_t nmemb, FILE* stream) { return os::fread(ptr, size, nmemb, stream); } + void os_free(void* ptr) { os::free(ptr); } + int os_getpagesize(void) { return os::getpagesize(); } + void* os_memcpy(void* dest, const void* src, size_t n) { return os::memcpy(dest, src, n); } + void* os_memset(void* s, int c, size_t n) { return os::memset(s, c, n); } + int os_mprotect(void* addr, size_t len, int prot) { return os::mprotect(addr, len, prot); } + int os_scandir(const char* dir, struct dirent*** namelist, int(*filter)(const struct dirent*), int(*compar)(const void*, const void*)) { return os::scandir(dir, namelist, filter, compar); } + int os_stat(const char* path, struct stat* buf) { return os::stat(path, buf); } + char* os_strcat(char* dest, const char* src) { return os::strcat(dest, src); } + char* os_strcpy(char* dest, const char* src) { return os::strcpy(dest, src); } + char* os_strdup(const char* s) { return os::strdup(s); } + int os_strlen(const char* s) { return os::strlen(s); } + +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/os.hpp b/src/vm/os.hpp new file mode 100644 index 000000000..dd70c65c8 --- /dev/null +++ b/src/vm/os.hpp @@ -0,0 +1,680 @@ +/* src/vm/os.hpp - system (OS) functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + Copyright (C) 2008 Theobroma Systems Ltd. + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _OS_HPP +#define _OS_HPP + +#include "config.h" + +// NOTE: In this file we check for all system headers, because we wrap +// all system calls into inline functions for better portability. + +// Please don't include CACAO headers here as this header should be a +// very low-level one. + +#if defined(HAVE_DIRENT_H) +# include +#endif + +#if defined(HAVE_DLFCN_H) +# include +#endif + +#if defined(HAVE_ERRNO_H) +# include +#endif + +#if defined(HAVE_EXECINFO_H) +# include +#endif + +#if defined(HAVE_FCNTL_H) +# include +#endif + +#if defined(ENABLE_JRE_LAYOUT) +# if defined(HAVE_LIBGEN_H) +# include +# endif +#endif + +#if defined(HAVE_SIGNAL_H) +# include +#endif + +#if defined(HAVE_STDARG_H) +# include +#endif + +#if defined(HAVE_STDINT_H) +# include +#endif + +#if defined(HAVE_STDIO_H) +# include +#endif + +#if defined(HAVE_STDLIB_H) +# include +#endif + +#if defined(HAVE_STRING_H) +# include +#endif + +#if defined(HAVE_UNISTD_H) +# include +#endif + +#if defined(HAVE_SYS_MMAN_H) +# include +#endif + +#if defined(HAVE_SYS_SOCKET_H) +# include +#endif + +#if defined(HAVE_SYS_STAT_H) +# include +#endif + +#if defined(HAVE_SYS_TYPES_H) +# include +#endif + + +#ifdef __cplusplus + +// Class wrapping system (OS) functions. +class os { +public: + // Inline functions. + static inline void abort(); + static inline int accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen); + static inline int access(const char *pathname, int mode); + static inline int atoi(const char* nptr); + static inline int backtrace(void** array, int size); + static inline char** backtrace_symbols(void* const* array, int size) throw (); + static inline void* calloc(size_t nmemb, size_t size); + static inline int close(int fd); + static inline int connect(int sockfd, const struct sockaddr* serv_addr, socklen_t addrlen); +#if defined(ENABLE_JRE_LAYOUT) + static inline char* dirname(char* path); +#endif + static inline int dlclose(void* handle); + static inline char* dlerror(void); + static inline void* dlopen(const char* filename, int flag); + static inline void* dlsym(void* handle, const char* symbol); + static inline int fclose(FILE* fp); + static inline FILE* fopen(const char* path, const char* mode); + static inline int fprintf(FILE* stream, const char* format, ...); + static inline size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream); + static inline void free(void* ptr); + static inline char* getenv(const char* name); + static inline int gethostname(char* name, size_t len); + static inline int getpagesize(void); + static inline int getsockname(int s, struct sockaddr* name, socklen_t* namelen); + static inline int getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen); + static inline int listen(int sockfd, int backlog); + static inline void* malloc(size_t size); + static inline void* memcpy(void* dest, const void* src, size_t n); + static inline void* memset(void* s, int c, size_t n); + static inline int mprotect(void* addr, size_t len, int prot); + static inline ssize_t readlink(const char* path, char* buf, size_t bufsiz); + static inline int scandir(const char* dir, struct dirent*** namelist, int(*filter)(const struct dirent*), int(*compar)(const void*, const void*)); + static inline int setsockopt(int s, int level, int optname, const void* optval, socklen_t optlen); + static inline int shutdown(int s, int how); + static inline int socket(int domain, int type, int protocol); + static inline int stat(const char* path, struct stat* buf); +#if defined(__SOLARIS__) + static inline int str2sig(const char* str, int* signum); +#endif + static inline char* strcat(char* dest, const char* src); + static inline int strcmp(const char* s1, const char* s2); + static inline char* strcpy(char* dest, const char* src); + static inline char* strdup(const char* s); + static inline size_t strlen(const char* s); + static inline char* strerror(int errnum); + + // Convenience functions. + static void* mmap_anonymous(void *addr, size_t len, int prot, int flags); + static void print_backtrace(); + static int processors_online(); +}; + + +inline void os::abort(void) +{ +#if defined(HAVE_ABORT) + ::abort(); +#else +# error abort not available +#endif +} + +inline int os::accept(int sockfd, struct sockaddr* addr, socklen_t* addrlen) +{ +#if defined(HAVE_ACCEPT) + return ::accept(sockfd, addr, addrlen); +#else +# error accept not available +#endif +} + +inline int os::access(const char* pathname, int mode) +{ +#if defined(HAVE_ACCESS) + return ::access(pathname, mode); +#else +# error access not available +#endif +} + +inline int os::atoi(const char* nptr) +{ +#if defined(HAVE_ATOI) + return ::atoi(nptr); +#else +# error atoi not available +#endif +} + +inline int os::backtrace(void** array, int size) +{ +#if defined(HAVE_BACKTRACE) + return ::backtrace(array, size); +#else + fprintf(stderr, "os::backtrace: Not available."); + return 0; +#endif +} + +inline char** os::backtrace_symbols(void* const* array, int size) throw () +{ +#if defined(HAVE_BACKTRACE_SYMBOLS) + return ::backtrace_symbols(array, size); +#else + fprintf(stderr, "os::backtrace_symbols: Not available."); + return NULL; +#endif +} + +inline void* os::calloc(size_t nmemb, size_t size) +{ +#if defined(HAVE_CALLOC) + return ::calloc(nmemb, size); +#else +# error calloc not available +#endif +} + +inline int os::close(int fd) +{ +#if defined(HAVE_CLOSE) + return ::close(fd); +#else +# error close not available +#endif +} + +inline int os::connect(int sockfd, const struct sockaddr* serv_addr, socklen_t addrlen) +{ +#if defined(HAVE_CONNECT) + return ::connect(sockfd, serv_addr, addrlen); +#else +# error connect not available +#endif +} + +#if defined(ENABLE_JRE_LAYOUT) +inline char* os::dirname(char* path) +{ +#if defined(HAVE_DIRNAME) + return ::dirname(path); +#else +# error dirname not available +#endif +} +#endif + +inline int os::dlclose(void* handle) +{ +#if defined(HAVE_DLCLOSE) + return ::dlclose(handle); +#else +# error dlclose not available +#endif +} + +inline char* os::dlerror(void) +{ +#if defined(HAVE_DLERROR) + return ::dlerror(); +#else +# error dlerror not available +#endif +} + +inline void* os::dlopen(const char* filename, int flag) +{ +#if defined(HAVE_DLOPEN) + return ::dlopen(filename, flag); +#else +# error dlopen not available +#endif +} + +inline void* os::dlsym(void* handle, const char* symbol) +{ +#if defined(HAVE_DLSYM) + return ::dlsym(handle, symbol); +#else +# error dlsym not available +#endif +} + +inline int os::fclose(FILE* fp) +{ +#if defined(HAVE_FCLOSE) + return ::fclose(fp); +#else +# error fclose not available +#endif +} + +inline FILE* os::fopen(const char* path, const char* mode) +{ +#if defined(HAVE_FOPEN) + return ::fopen(path, mode); +#else +# error fopen not available +#endif +} + +inline int os::fprintf(FILE* stream, const char* format, ...) +{ +#if defined(HAVE_FPRINTF) + va_list ap; + va_start(ap, format); + int result = ::fprintf(stream, format, ap); + va_end(ap); + return result; +#else +# error fprintf not available +#endif +} + +inline size_t os::fread(void* ptr, size_t size, size_t nmemb, FILE* stream) +{ +#if defined(HAVE_FREAD) + return ::fread(ptr, size, nmemb, stream); +#else +# error fread not available +#endif +} + +inline void os::free(void* ptr) +{ +#if defined(HAVE_FREE) + ::free(ptr); +#else +# error free not available +#endif +} + +inline static int system_fsync(int fd) +{ +#if defined(HAVE_FSYNC) + return fsync(fd); +#else +# error fsync not available +#endif +} + +inline static int system_ftruncate(int fd, off_t length) +{ +#if defined(HAVE_FTRUNCATE) + return ftruncate(fd, length); +#else +# error ftruncate not available +#endif +} + +inline char* os::getenv(const char* name) +{ +#if defined(HAVE_GETENV) + return ::getenv(name); +#else +# error getenv not available +#endif +} + +inline int os::gethostname(char* name, size_t len) +{ +#if defined(HAVE_GETHOSTNAME) + return ::gethostname(name, len); +#else +# error gethostname not available +#endif +} + +inline int os::getpagesize(void) +{ +#if defined(HAVE_GETPAGESIZE) + return ::getpagesize(); +#else +# error getpagesize not available +#endif +} + +inline int os::getsockname(int s, struct sockaddr* name, socklen_t* namelen) +{ +#if defined(HAVE_GETSOCKNAME) + return ::getsockname(s, name, namelen); +#else +# error getsockname not available +#endif +} + +inline int os::getsockopt(int s, int level, int optname, void* optval, socklen_t* optlen) +{ +#if defined(HAVE_GETSOCKOPT) + return ::getsockopt(s, level, optname, optval, optlen); +#else +# error getsockopt not available +#endif +} + +inline int os::listen(int sockfd, int backlog) +{ +#if defined(HAVE_LISTEN) + return ::listen(sockfd, backlog); +#else +# error listen not available +#endif +} + +inline static off_t system_lseek(int fildes, off_t offset, int whence) +{ +#if defined(HAVE_LSEEK) + return lseek(fildes, offset, whence); +#else +# error lseek not available +#endif +} + +inline void* os::malloc(size_t size) +{ +#if defined(HAVE_MALLOC) + return ::malloc(size); +#else +# error malloc not available +#endif +} + +inline void* os::memcpy(void* dest, const void* src, size_t n) +{ +#if defined(HAVE_MEMCPY) + return ::memcpy(dest, src, n); +#else +# error memcpy not available +#endif +} + +inline void* os::memset(void* s, int c, size_t n) +{ +#if defined(HAVE_MEMSET) + return ::memset(s, c, n); +#else +# error memset not available +#endif +} + +inline int os::mprotect(void* addr, size_t len, int prot) +{ +#if defined(HAVE_MPROTECT) + return ::mprotect(addr, len, prot); +#else +# error mprotect not available +#endif +} + +inline static int system_open(const char *pathname, int flags, mode_t mode) +{ +#if defined(HAVE_OPEN) + return open(pathname, flags, mode); +#else +# error open not available +#endif +} + +inline static ssize_t system_read(int fd, void *buf, size_t count) +{ +#if defined(HAVE_READ) + return read(fd, buf, count); +#else +# error read not available +#endif +} + +inline ssize_t os::readlink(const char* path, char* buf, size_t bufsiz) +{ +#if defined(HAVE_READLINK) + return ::readlink(path, buf, bufsiz); +#else +# error readlink not available +#endif +} + +inline static void *system_realloc(void *ptr, size_t size) +{ +#if defined(HAVE_REALLOC) + return realloc(ptr, size); +#else +# error realloc not available +#endif +} + +inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *)) +/* +#elif defined(__SOLARIS__) +inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const struct dirent **, const struct dirent **)) +#elif defined(__IRIX__) +inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(dirent_t *), int(*compar)(dirent_t **, dirent_t **)) +#else +inline int os::scandir(const char *dir, struct dirent ***namelist, int(*filter)(struct dirent *), int(*compar)(const void *, const void *)) +#endif +*/ +{ +#if defined(HAVE_SCANDIR) +# if defined(__LINUX__) + return ::scandir(dir, namelist, filter, compar); +#elif defined(__SOLARIS__) + return ::scandir(dir, namelist, filter, (int (*)(const dirent**, const dirent**)) compar); +# else + return ::scandir(dir, namelist, (int (*)(struct dirent*)) filter, compar); +# endif +#else +# error scandir not available +#endif +} + +inline int os::setsockopt(int s, int level, int optname, const void* optval, socklen_t optlen) +{ +#if defined(HAVE_SETSOCKOPT) + return ::setsockopt(s, level, optname, optval, optlen); +#else +# error setsockopt not available +#endif +} + +inline int os::shutdown(int s, int how) +{ +#if defined(HAVE_SHUTDOWN) + return ::shutdown(s, how); +#else +# error shutdown not available +#endif +} + +inline int os::socket(int domain, int type, int protocol) +{ +#if defined(HAVE_SOCKET) + return ::socket(domain, type, protocol); +#else +# error socket not available +#endif +} + +inline int os::stat(const char* path, struct stat* buf) +{ +#if defined(HAVE_STAT) + return ::stat(path, buf); +#else +# error stat not available +#endif +} + +#if defined(__SOLARIS__) +inline int os::str2sig(const char* str, int* signum) +{ +#if defined(HAVE_STR2SIG) + return ::str2sig(str, signum); +#else +# error str2sig not available +#endif +} +#endif + +inline char* os::strcat(char* dest, const char* src) +{ +#if defined(HAVE_STRCAT) + return ::strcat(dest, src); +#else +# error strcat not available +#endif +} + +inline int os::strcmp(const char* s1, const char* s2) +{ +#if defined(HAVE_STRCMP) + return ::strcmp(s1, s2); +#else +# error strcmp not available +#endif +} + +inline char* os::strcpy(char* dest, const char* src) +{ +#if defined(HAVE_STRCPY) + return ::strcpy(dest, src); +#else +# error strcpy not available +#endif +} + +inline char* os::strdup(const char* s) +{ +#if defined(HAVE_STRDUP) + return ::strdup(s); +#else +# error strdup not available +#endif +} + +inline char* os::strerror(int errnum) +{ +#if defined(HAVE_STRERROR) + return ::strerror(errnum); +#else +# error strerror not available +#endif +} + +inline size_t os::strlen(const char* s) +{ +#if defined(HAVE_STRLEN) + return ::strlen(s); +#else +# error strlen not available +#endif +} + +inline static ssize_t system_write(int fd, const void *buf, size_t count) +{ +#if defined(HAVE_WRITE) + return write(fd, buf, count); +#else +# error write not available +#endif +} + +#else + +void* os_mmap_anonymous(void *addr, size_t len, int prot, int flags); + +void os_abort(void); +int os_access(const char* pathname, int mode); +int os_atoi(const char* nptr); +void* os_calloc(size_t nmemb, size_t size); +char* os_dirname(char* path); +int os_dlclose(void* handle); +char* os_dlerror(void); +void* os_dlopen(const char* filename, int flag); +void* os_dlsym(void* handle, const char* symbol); +int os_fclose(FILE* fp); +FILE* os_fopen(const char* path, const char* mode); +size_t os_fread(void* ptr, size_t size, size_t nmemb, FILE* stream); +void os_free(void* ptr); +int os_getpagesize(void); +void* os_memcpy(void* dest, const void* src, size_t n); +void* os_memset(void* s, int c, size_t n); +int os_mprotect(void* addr, size_t len, int prot); +int os_scandir(const char* dir, struct dirent*** namelist, int(*filter)(const struct dirent*), int(*compar)(const void*, const void*)); +int os_stat(const char* path, struct stat* buf); +char* os_strcat(char* dest, const char* src); +char* os_strcpy(char* dest, const char* src); +char* os_strdup(const char* s); +int os_strlen(const char* s); + +#endif + +#endif // _OS_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/package.c b/src/vm/package.c deleted file mode 100644 index c544b96fe..000000000 --- a/src/vm/package.c +++ /dev/null @@ -1,170 +0,0 @@ -/* src/vm/package.c - Java boot-package functions - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "toolbox/list.h" - -#include "mm/memory.h" - -#include "native/jni.h" - -#include "native/include/java_lang_String.h" - -#include "vm/package.h" -#include "vm/stringlocal.h" - -#include "vmcore/options.h" -#include "vmcore/utf8.h" - - -/* internal property structure ************************************************/ - -typedef struct list_package_entry_t list_package_entry_t; - -struct list_package_entry_t { -/* java_string_t *packagename; */ - utf *packagename; - listnode_t linkage; -}; - - -/* global variables ***********************************************************/ - -static list_t *list_package = NULL; - - -/* package_init **************************************************************** - - Initialize the package list. - -*******************************************************************************/ - -void package_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("package_init"); - - /* create the properties list */ - - list_package = list_create(OFFSET(list_package_entry_t, linkage)); -} - - -/* package_add ***************************************************************** - - Add a package to the boot-package list. - - IN: - packagename....package name as Java string - -*******************************************************************************/ - -/* void package_add(java_handle_t *packagename) */ -void package_add(utf *packagename) -{ -/* java_string_t *s; */ - list_package_entry_t *lpe; - - /* Intern the Java string to get a unique address. */ - -/* s = javastring_intern(packagename); */ - - /* Check if the package is already stored. */ - - if (package_find(packagename) != NULL) - return; - - /* Add the package. */ - -#if !defined(NDEBUG) - if (opt_DebugPackage) { - log_start(); - log_print("[package_add: packagename="); - utf_display_printable_ascii(packagename); - log_print("]"); - log_finish(); - } -#endif - - lpe = NEW(list_package_entry_t); - - lpe->packagename = packagename; - - list_add_last(list_package, lpe); -} - - -/* package_find **************************************************************** - - Find a package in the list. - - IN: - packagename....package name as Java string - - OUT: - package name as Java string - -*******************************************************************************/ - -/* java_handle_t *package_find(java_handle_t *packagename) */ -utf *package_find(utf *packagename) -{ -/* java_string_t *s; */ - list_t *l; - list_package_entry_t *lpe; - - /* Intern the Java string to get a unique address. */ - -/* s = javastring_intern(packagename); */ - - /* For convenience. */ - - l = list_package; - - for (lpe = list_first(l); lpe != NULL; lpe = list_next(l, lpe)) { -/* if (lpe->packagename == s) */ - if (lpe->packagename == packagename) - return lpe->packagename; - } - - return NULL; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/package.cpp b/src/vm/package.cpp new file mode 100644 index 000000000..a112aca2f --- /dev/null +++ b/src/vm/package.cpp @@ -0,0 +1,98 @@ +/* src/vm/package.cpp - Java boot-package functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "mm/memory.h" + +#include "vm/options.h" +#include "vm/package.hpp" +#include "vm/string.hpp" +#include "vm/utf8.h" + + +// Package list. + +std::set Package::_packages; + + +/** + * Add a package to the boot-package list. + * + * @param packagename Package name as Java string. + */ +void Package::add(utf* packagename) +{ + // Intern the Java string to get a unique address. +/* s = javastring_intern(packagename); */ + +#if !defined(NDEBUG) + if (opt_DebugPackage) { + log_start(); + log_print("[package_add: packagename="); + utf_display_printable_ascii(packagename); + log_print("]"); + log_finish(); + } +#endif + + // Add the package name. + _packages.insert(packagename); +} + + +/** + * Find a package in the list. + * + * @param packagename Package name as Java string. + * + * @return Package name as Java string. + */ +utf* Package::find(utf* packagename) +{ + std::set::iterator it = _packages.find(packagename); + + if (it == _packages.end()) + return NULL; + + return *it; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/package.h b/src/vm/package.h deleted file mode 100644 index 95fcd54e9..000000000 --- a/src/vm/package.h +++ /dev/null @@ -1,64 +0,0 @@ -/* src/vm/package.c - Java boot-package functions - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _VM_PACKAGE_H -#define _VM_PACKAGE_H - -#include "config.h" - -#include - -#include "native/jni.h" - -#include "vm/global.h" - - -/* function prototypes ********************************************************/ - -void package_init(void); - -/* void package_add(java_handle_t *packagename); */ -void package_add(utf *packagename); -/* java_handle_t *package_find(java_handle_t *packagename); */ -utf *package_find(utf *packagename); - -#endif /* _VM_PACKAGE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/package.hpp b/src/vm/package.hpp new file mode 100644 index 000000000..7e7669bd0 --- /dev/null +++ b/src/vm/package.hpp @@ -0,0 +1,65 @@ +/* src/vm/package.hpp - Java boot-package functions + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _VM_PACKAGE_HPP +#define _VM_PACKAGE_HPP + +#include "config.h" + +#include + +#include + +#include "vm/utf8.h" + + +/** + * + */ +class Package { +private: + static std::set _packages; + +public: + static void add (utf* packagename); + static utf* find(utf* packagename); +}; + +#endif // _VM_PACKAGE_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/primitive.c b/src/vm/primitive.c deleted file mode 100644 index ca55726f1..000000000 --- a/src/vm/primitive.c +++ /dev/null @@ -1,372 +0,0 @@ -/* src/vm/primitive.c - primitive types - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "native/jni.h" -#include "native/llni.h" - -#include "native/include/java_lang_Boolean.h" -#include "native/include/java_lang_Byte.h" -#include "native/include/java_lang_Short.h" -#include "native/include/java_lang_Character.h" -#include "native/include/java_lang_Integer.h" -#include "native/include/java_lang_Long.h" -#include "native/include/java_lang_Float.h" -#include "native/include/java_lang_Double.h" - -#include "vm/builtin.h" -#include "vm/global.h" -#include "vm/primitive.h" -#include "vm/vm.h" - -#include "vmcore/class.h" -#include "vmcore/utf8.h" - - -/* primitive_class_get_by_name ************************************************* - - Returns the primitive class of the given class name. - -*******************************************************************************/ - -classinfo *primitive_class_get_by_name(utf *name) -{ - int i; - - /* search table of primitive classes */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) - if (primitivetype_table[i].name == name) - return primitivetype_table[i].class_primitive; - - /* keep compiler happy */ - - return NULL; -} - - -/* primitive_class_get_by_type ************************************************* - - Returns the primitive class of the given type. - -*******************************************************************************/ - -classinfo *primitive_class_get_by_type(int type) -{ - return primitivetype_table[type].class_primitive; -} - - -/* primitive_class_get_by_char ************************************************* - - Returns the primitive class of the given type. - -*******************************************************************************/ - -classinfo *primitive_class_get_by_char(char ch) -{ - int index; - - switch (ch) { - case 'I': - index = PRIMITIVETYPE_INT; - break; - case 'J': - index = PRIMITIVETYPE_LONG; - break; - case 'F': - index = PRIMITIVETYPE_FLOAT; - break; - case 'D': - index = PRIMITIVETYPE_DOUBLE; - break; - case 'B': - index = PRIMITIVETYPE_BYTE; - break; - case 'C': - index = PRIMITIVETYPE_CHAR; - break; - case 'S': - index = PRIMITIVETYPE_SHORT; - break; - case 'Z': - index = PRIMITIVETYPE_BOOLEAN; - break; - case 'V': - index = PRIMITIVETYPE_VOID; - break; - default: - return NULL; - } - - return primitivetype_table[index].class_primitive; -} - - -/* primitive_arrayclass_get_by_name ******************************************** - - Returns the primitive array-class of the given primitive class - name. - -*******************************************************************************/ - -classinfo *primitive_arrayclass_get_by_name(utf *name) -{ - int i; - - /* search table of primitive classes */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) - if (primitivetype_table[i].name == name) - return primitivetype_table[i].arrayclass; - - /* keep compiler happy */ - - return NULL; -} - - -/* primitive_arrayclass_get_by_type ******************************************** - - Returns the primitive array-class of the given type. - -*******************************************************************************/ - -classinfo *primitive_arrayclass_get_by_type(int type) -{ - return primitivetype_table[type].arrayclass; -} - - -/* primitive_type_get_by_wrapperclass ****************************************** - - Returns the primitive type of the given wrapper-class. - -*******************************************************************************/ - -int primitive_type_get_by_wrapperclass(classinfo *c) -{ - int i; - - /* Search primitive table. */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) - if (primitivetype_table[i].class_wrap == c) - return i; - - /* Invalid primitive wrapper-class. */ - - return -1; -} - - -/* primitive_box *************************************************************** - - Box a primitive of the given type. If the type is an object, - simply return it. - -*******************************************************************************/ - -java_handle_t *primitive_box(int type, imm_union value) -{ - java_handle_t *o; - - switch (type) { - case PRIMITIVETYPE_BOOLEAN: - o = primitive_box_boolean(value.i); - break; - case PRIMITIVETYPE_BYTE: - o = primitive_box_byte(value.i); - break; - case PRIMITIVETYPE_CHAR: - o = primitive_box_char(value.i); - break; - case PRIMITIVETYPE_SHORT: - o = primitive_box_short(value.i); - break; - case PRIMITIVETYPE_INT: - o = primitive_box_int(value.i); - break; - case PRIMITIVETYPE_LONG: - o = primitive_box_long(value.l); - break; - case PRIMITIVETYPE_FLOAT: - o = primitive_box_float(value.f); - break; - case PRIMITIVETYPE_DOUBLE: - o = primitive_box_double(value.d); - break; - case PRIMITIVETYPE_VOID: - o = value.a; - break; - default: - o = NULL; - vm_abort("primitive_box: invalid primitive type %d", type); - } - - return o; -} - - -/* primitive_unbox ************************************************************* - - Unbox a primitive of the given type. If the type is an object, - simply return it. - -*******************************************************************************/ - -imm_union primitive_unbox(java_handle_t *o) -{ - classinfo *c; - int type; - imm_union value; - - if (o == NULL) { - value.a = NULL; - return value; - } - - LLNI_class_get(o, c); - - type = primitive_type_get_by_wrapperclass(c); - - switch (type) { - case PRIMITIVETYPE_BOOLEAN: - value.i = primitive_unbox_boolean(o); - break; - case PRIMITIVETYPE_BYTE: - value.i = primitive_unbox_byte(o); - break; - case PRIMITIVETYPE_CHAR: - value.i = primitive_unbox_char(o); - break; - case PRIMITIVETYPE_SHORT: - value.i = primitive_unbox_short(o); - break; - case PRIMITIVETYPE_INT: - value.i = primitive_unbox_int(o); - break; - case PRIMITIVETYPE_LONG: - value.l = primitive_unbox_long(o); - break; - case PRIMITIVETYPE_FLOAT: - value.f = primitive_unbox_float(o); - break; - case PRIMITIVETYPE_DOUBLE: - value.d = primitive_unbox_double(o); - break; - case -1: - /* If type is -1 the object is not a primitive box but a - normal object. */ - value.a = o; - break; - default: - vm_abort("primitive_unbox: invalid primitive type %d", type); - } - - return value; -} - - -/* primitive_box_xxx *********************************************************** - - Box a primitive type. - -*******************************************************************************/ - -#define PRIMITIVE_BOX_TYPE(name, object, type) \ -java_handle_t *primitive_box_##name(type value) \ -{ \ - java_handle_t *o; \ - java_lang_##object *jo; \ - \ - o = builtin_new(class_java_lang_##object); \ - \ - if (o == NULL) \ - return NULL; \ - \ - jo = (java_lang_##object *) o; \ - \ - LLNI_field_set_val(jo, value, value); \ - \ - return o; \ -} - -PRIMITIVE_BOX_TYPE(boolean, Boolean, int32_t) -PRIMITIVE_BOX_TYPE(byte, Byte, int32_t) -PRIMITIVE_BOX_TYPE(char, Character, int32_t) -PRIMITIVE_BOX_TYPE(short, Short, int32_t) -PRIMITIVE_BOX_TYPE(int, Integer, int32_t) -PRIMITIVE_BOX_TYPE(long, Long, int64_t) -PRIMITIVE_BOX_TYPE(float, Float, float) -PRIMITIVE_BOX_TYPE(double, Double, double) - - -/* primitive_unbox_xxx ********************************************************* - - Unbox a primitive type. - -*******************************************************************************/ - -#define PRIMITIVE_UNBOX_TYPE(name, object, type) \ -type primitive_unbox_##name(java_handle_t *o) \ -{ \ - java_lang_##object *jo; \ - type value; \ - \ - jo = (java_lang_##object *) o; \ - \ - LLNI_field_get_val(jo, value, value); \ - \ - return value; \ -} - -PRIMITIVE_UNBOX_TYPE(boolean, Boolean, int32_t) -PRIMITIVE_UNBOX_TYPE(byte, Byte, int32_t) -PRIMITIVE_UNBOX_TYPE(char, Character, int32_t) -PRIMITIVE_UNBOX_TYPE(short, Short, int32_t) -PRIMITIVE_UNBOX_TYPE(int, Integer, int32_t) -PRIMITIVE_UNBOX_TYPE(long, Long, int64_t) -PRIMITIVE_UNBOX_TYPE(float, Float, float) -PRIMITIVE_UNBOX_TYPE(double, Double, double) - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/primitive.cpp b/src/vm/primitive.cpp new file mode 100644 index 000000000..be03f75e0 --- /dev/null +++ b/src/vm/primitive.cpp @@ -0,0 +1,677 @@ +/* src/vm/primitive.cpp - primitive types + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "native/llni.h" + +#include "vm/jit/builtin.hpp" +#include "vm/class.h" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +/* primitivetype_table ********************************************************* + + Structure for primitive classes: contains the class for wrapping + the primitive type, the primitive class, the name of the class for + wrapping, the one character type signature and the name of the + primitive class. + + CAUTION: Don't change the order of the types. This table is indexed + by the ARRAYTYPE_ constants (except ARRAYTYPE_OBJECT). + +*******************************************************************************/ + +primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = { + { "int" , NULL, NULL, NULL, "java/lang/Integer", 'I', "[I", NULL }, + { "long" , NULL, NULL, NULL, "java/lang/Long", 'J', "[J", NULL }, + { "float" , NULL, NULL, NULL, "java/lang/Float", 'F', "[F", NULL }, + { "double" , NULL, NULL, NULL, "java/lang/Double", 'D', "[D", NULL }, + { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, + { "byte" , NULL, NULL, NULL, "java/lang/Byte", 'B', "[B", NULL }, + { "char" , NULL, NULL, NULL, "java/lang/Character", 'C', "[C", NULL }, + { "short" , NULL, NULL, NULL, "java/lang/Short", 'S', "[S", NULL }, + { "boolean" , NULL, NULL, NULL, "java/lang/Boolean", 'Z', "[Z", NULL }, + { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, +#if defined(ENABLE_JAVASE) + { "void" , NULL, NULL, NULL, "java/lang/Void", 'V', NULL, NULL } +#else + { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, +#endif +}; + + +/** + * Fill the primitive type table with the primitive-type classes, + * array-classes and wrapper classes. This is important in the VM + * startup. + * + * We split this primitive-type table initialization because of + * annotations in the bootstrap classes. + * + * But we may get a problem if we have annotations in: + * + * java/lang/Object + * java/lang/Cloneable + * java/io/Serializable + * + * Also see: loader_preinit and linker_preinit. + */ +void Primitive::initialize_table() +{ + utf *name; + classinfo *c; + utf *u; + classinfo *ac; + + TRACESUBSYSTEMINITIALIZATION("primitive_init"); + + /* Load and link primitive-type classes and array-classes. */ + + for (int i = 0; i < PRIMITIVETYPE_COUNT; i++) { + /* Skip dummy entries. */ + + if (primitivetype_table[i].cname == NULL) + continue; + + /* create UTF-8 name */ + + name = utf_new_char(primitivetype_table[i].cname); + + primitivetype_table[i].name = name; + + /* create primitive class */ + + c = class_create_classinfo(name); + + /* Primitive type classes don't have a super class. */ + + c->super = NULL; + + /* set flags and mark it as primitive class */ + + c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT | ACC_CLASS_PRIMITIVE; + + /* prevent loader from loading primitive class */ + + c->state |= CLASS_LOADED; + + /* INFO: don't put primitive classes into the classcache */ + + if (!link_class(c)) + vm_abort("linker_init: linking failed"); + + /* Just to be sure. */ + + assert(c->state & CLASS_LOADED); + assert(c->state & CLASS_LINKED); + + primitivetype_table[i].class_primitive = c; + + /* Create primitive array class. */ + + if (primitivetype_table[i].arrayname != NULL) { + u = utf_new_char(primitivetype_table[i].arrayname); + ac = class_create_classinfo(u); + ac = load_newly_created_array(ac, NULL); + + if (ac == NULL) + vm_abort("primitive_init: loading failed"); + + assert(ac->state & CLASS_LOADED); + + if (!link_class(ac)) + vm_abort("primitive_init: linking failed"); + + /* Just to be sure. */ + + assert(ac->state & CLASS_LOADED); + assert(ac->state & CLASS_LINKED); + + primitivetype_table[i].arrayclass = ac; + } + } + + /* We use two for-loops to have the array-classes already in the + primitive-type table (hint: annotations in wrapper-classes). */ + + for (int i = 0; i < PRIMITIVETYPE_COUNT; i++) { + /* Skip dummy entries. */ + + if (primitivetype_table[i].cname == NULL) + continue; + + /* Create class for wrapping the primitive type. */ + + u = utf_new_char(primitivetype_table[i].wrapname); + c = load_class_bootstrap(u); + + if (c == NULL) + vm_abort("primitive_init: loading failed"); + + if (!link_class(c)) + vm_abort("primitive_init: linking failed"); + + /* Just to be sure. */ + + assert(c->state & CLASS_LOADED); + assert(c->state & CLASS_LINKED); + + primitivetype_table[i].class_wrap = c; + } +} + + +/** + * Finish the primitive-type table initialization. In this step we + * set the vftbl of the primitive-type classes. + * + * This is necessary because java/lang/Class is loaded and linked + * after the primitive types have been linked. + * + * We have to do that in an extra function, as the primitive types are + * not stored in the classcache. + */ +void Primitive::post_initialize_table() +{ + classinfo *c; + int i; + + TRACESUBSYSTEMINITIALIZATION("primitive_postinit"); + + assert(class_java_lang_Class); + assert(class_java_lang_Class->vftbl); + + for (i = 0; i < PRIMITIVETYPE_COUNT; i++) { + /* Skip dummy entries. */ + + if (primitivetype_table[i].cname == NULL) + continue; + + c = primitivetype_table[i].class_primitive; + + c->object.header.vftbl = class_java_lang_Class->vftbl; + } +} + + +/** + * Returns the primitive class of the given class name. + * + * @param name Name of the class. + * + * @return Class structure. + */ +classinfo* Primitive::get_class_by_name(utf *name) +{ + int i; + + /* search table of primitive classes */ + + for (i = 0; i < PRIMITIVETYPE_COUNT; i++) + if (primitivetype_table[i].name == name) + return primitivetype_table[i].class_primitive; + + /* keep compiler happy */ + + return NULL; +} + + +/** + * Returns the primitive class of the given type. + * + * @param type Integer type of the class. + * + * @return Class structure. + */ +classinfo* Primitive::get_class_by_type(int type) +{ + return primitivetype_table[type].class_primitive; +} + + +/** + * Returns the primitive class of the given type. + * + * @param ch + * + * @return Class structure. + */ +classinfo* Primitive::get_class_by_char(char ch) +{ + int index; + + switch (ch) { + case 'I': + index = PRIMITIVETYPE_INT; + break; + case 'J': + index = PRIMITIVETYPE_LONG; + break; + case 'F': + index = PRIMITIVETYPE_FLOAT; + break; + case 'D': + index = PRIMITIVETYPE_DOUBLE; + break; + case 'B': + index = PRIMITIVETYPE_BYTE; + break; + case 'C': + index = PRIMITIVETYPE_CHAR; + break; + case 'S': + index = PRIMITIVETYPE_SHORT; + break; + case 'Z': + index = PRIMITIVETYPE_BOOLEAN; + break; + case 'V': + index = PRIMITIVETYPE_VOID; + break; + default: + return NULL; + } + + return primitivetype_table[index].class_primitive; +} + + +/** + * Returns the primitive array-class of the given primitive class + * name. + * + * @param name Name of the class. + * + * @return Class structure. + */ +classinfo* Primitive::get_arrayclass_by_name(utf *name) +{ + int i; + + /* search table of primitive classes */ + + for (i = 0; i < PRIMITIVETYPE_COUNT; i++) + if (primitivetype_table[i].name == name) + return primitivetype_table[i].arrayclass; + + /* keep compiler happy */ + + return NULL; +} + + +/** + * Returns the primitive array-class of the given type. + * + * @param type Integer type of the class. + * + * @return Class structure. + */ +classinfo* Primitive::get_arrayclass_by_type(int type) +{ + return primitivetype_table[type].arrayclass; +} + + +/** + * Returns the primitive type of the given wrapper-class. + * + * @param c Class structure. + * + * @return Integer type of the class. + */ +int Primitive::get_type_by_wrapperclass(classinfo *c) +{ + int i; + + /* Search primitive table. */ + + for (i = 0; i < PRIMITIVETYPE_COUNT; i++) + if (primitivetype_table[i].class_wrap == c) + return i; + + /* Invalid primitive wrapper-class. */ + + return -1; +} + + +/** + * Box a primitive of the given type. If the type is an object, + * simply return it. + * + * @param type Type of the passed value. + * @param value Value to box. + * + * @return Handle of the boxing Java object. + */ +java_handle_t* Primitive::box(int type, imm_union value) +{ + java_handle_t* o; + + switch (type) { + case PRIMITIVETYPE_BOOLEAN: + o = box((uint8_t) value.i); + break; + case PRIMITIVETYPE_BYTE: + o = box((int8_t) value.i); + break; + case PRIMITIVETYPE_CHAR: + o = box((uint16_t) value.i); + break; + case PRIMITIVETYPE_SHORT: + o = box((int16_t) value.i); + break; + case PRIMITIVETYPE_INT: + o = box(value.i); + break; + case PRIMITIVETYPE_LONG: + o = box(value.l); + break; + case PRIMITIVETYPE_FLOAT: + o = box(value.f); + break; + case PRIMITIVETYPE_DOUBLE: + o = box(value.d); + break; + case PRIMITIVETYPE_VOID: + o = (java_handle_t*) value.a; + break; + default: + o = NULL; + VM::get_current()->abort("primitive_box: invalid primitive type %d", type); + } + + return o; +} + + +/** + * Unbox a primitive of the given type. If the type is an object, + * simply return it. + * + * @param h Handle of the Java object. + * + * @return Unboxed value as union. + */ +imm_union Primitive::unbox(java_handle_t *h) +{ + classinfo *c; + int type; + imm_union value; + + if (h == NULL) { + value.a = NULL; + return value; + } + + LLNI_class_get(h, c); + + type = get_type_by_wrapperclass(c); + + switch (type) { + case PRIMITIVETYPE_BOOLEAN: + value.i = unbox_boolean(h); + break; + case PRIMITIVETYPE_BYTE: + value.i = unbox_byte(h); + break; + case PRIMITIVETYPE_CHAR: + value.i = unbox_char(h); + break; + case PRIMITIVETYPE_SHORT: + value.i = unbox_short(h); + break; + case PRIMITIVETYPE_INT: + value.i = unbox_int(h); + break; + case PRIMITIVETYPE_LONG: + value.l = unbox_long(h); + break; + case PRIMITIVETYPE_FLOAT: + value.f = unbox_float(h); + break; + case PRIMITIVETYPE_DOUBLE: + value.d = unbox_double(h); + break; + case -1: + /* If type is -1 the object is not a primitive box but a + normal object. */ + value.a = h; + break; + default: + VM::get_current()->abort("Primitive::unbox: invalid primitive type %d", type); + } + + return value; +} + + +/** + * Box a primitive type. + */ +java_handle_t* Primitive::box(uint8_t value) +{ + java_handle_t *h = builtin_new(class_java_lang_Boolean); + + if (h == NULL) + return NULL; + + java_lang_Boolean b(h); + b.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(int8_t value) +{ + java_handle_t *h = builtin_new(class_java_lang_Byte); + + if (h == NULL) + return NULL; + + java_lang_Byte b(h); + b.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(uint16_t value) +{ + java_handle_t *h = builtin_new(class_java_lang_Character); + + if (h == NULL) + return NULL; + + java_lang_Character c(h); + c.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(int16_t value) +{ + java_handle_t *h = builtin_new(class_java_lang_Short); + + if (h == NULL) + return NULL; + + java_lang_Short s(h); + s.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(int32_t value) +{ + java_handle_t *h = builtin_new(class_java_lang_Integer); + + if (h == NULL) + return NULL; + + java_lang_Integer i(h); + i.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(int64_t value) +{ + java_handle_t *h = builtin_new(class_java_lang_Long); + + if (h == NULL) + return NULL; + + java_lang_Long l(h); + l.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(float value) +{ + java_handle_t *h = builtin_new(class_java_lang_Float); + + if (h == NULL) + return NULL; + + java_lang_Float f(h); + f.set_value(value); + + return h; +} + +java_handle_t* Primitive::box(double value) +{ + java_handle_t *h = builtin_new(class_java_lang_Double); + + if (h == NULL) + return NULL; + + java_lang_Double d(h); + d.set_value(value); + + return h; +} + + + +/** + * Unbox a primitive type. + */ + +// template T Primitive::unbox(java_handle_t *h) +// { +// return java_lang_Boolean::get_value(h); +// } + +inline uint8_t Primitive::unbox_boolean(java_handle_t *h) +{ + java_lang_Boolean b(h); + return b.get_value(); +} + +inline int8_t Primitive::unbox_byte(java_handle_t *h) +{ + java_lang_Byte b(h); + return b.get_value(); +} + +inline uint16_t Primitive::unbox_char(java_handle_t *h) +{ + java_lang_Character c(h); + return c.get_value(); +} + +inline int16_t Primitive::unbox_short(java_handle_t *h) +{ + java_lang_Short s(h); + return s.get_value(); +} + +inline int32_t Primitive::unbox_int(java_handle_t *h) +{ + java_lang_Integer i(h); + return i.get_value(); +} + +inline int64_t Primitive::unbox_long(java_handle_t *h) +{ + java_lang_Long l(h); + return l.get_value(); +} + +inline float Primitive::unbox_float(java_handle_t *h) +{ + java_lang_Float f(h); + return f.get_value(); +} + +inline double Primitive::unbox_double(java_handle_t *h) +{ + java_lang_Double d(h); + return d.get_value(); +} + + + +// Legacy C interface. + +extern "C" { + + classinfo* Primitive_get_class_by_name(utf *name) { return Primitive::get_class_by_name(name); } +classinfo* Primitive_get_class_by_type(int type) { return Primitive::get_class_by_type(type); } +classinfo* Primitive_get_arrayclass_by_name(utf *name) { return Primitive::get_arrayclass_by_name(name); } +classinfo* Primitive_get_arrayclass_by_type(int type) { return Primitive::get_arrayclass_by_type(type); } +int Primitive_get_type_by_wrapperclass(classinfo *c) { return Primitive::get_type_by_wrapperclass(c); } +java_handle_t* Primitive_box(int type, imm_union value) { return Primitive::box(type, value); } +imm_union Primitive_unbox(java_handle_t *h) { return Primitive::unbox(h); } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/primitive.h b/src/vm/primitive.h deleted file mode 100644 index f5ce4d6b4..000000000 --- a/src/vm/primitive.h +++ /dev/null @@ -1,139 +0,0 @@ -/* src/vm/primitive.c - primitive types - - Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _PRIMITIVE_H -#define _PRIMITIVE_H - -#include "config.h" - -#include - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/linker.h" -#include "vmcore/utf8.h" - - -/* primitive data types *******************************************************/ - -/* These values are used in parsed descriptors and in some other - places were the different types handled internally as TYPE_INT have - to be distinguished. */ - -#define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */ - -/* CAUTION: Don't change the numerical values! These constants are - used as indices into the primitive type table. */ - -#define PRIMITIVETYPE_INT TYPE_INT -#define PRIMITIVETYPE_LONG TYPE_LNG -#define PRIMITIVETYPE_FLOAT TYPE_FLT -#define PRIMITIVETYPE_DOUBLE TYPE_DBL -#define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */ -#define PRIMITIVETYPE_BYTE 5 -#define PRIMITIVETYPE_CHAR 6 -#define PRIMITIVETYPE_SHORT 7 -#define PRIMITIVETYPE_BOOLEAN 8 -#define PRIMITIVETYPE_DUMMY2 9 /* not used! */ -#define PRIMITIVETYPE_VOID TYPE_VOID - - -/* primitivetypeinfo **********************************************************/ - -struct primitivetypeinfo { - char *cname; /* char name of primitive class */ - utf *name; /* name of primitive class */ - classinfo *class_wrap; /* class for wrapping primitive type */ - classinfo *class_primitive; /* primitive class */ - char *wrapname; /* name of class for wrapping */ - char typesig; /* one character type signature */ - char *arrayname; /* name of primitive array class */ - classinfo *arrayclass; /* primitive array class */ -}; - - -/* global variables ***********************************************************/ - -/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_ - constants (except ARRAYTYPE_OBJECT). */ - -extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT]; - - -/* function prototypes ********************************************************/ - -/* this function is in src/vmcore/primitivecore.c */ -void primitive_init(void); -void primitive_postinit(void); - -classinfo *primitive_class_get_by_name(utf *name); -classinfo *primitive_class_get_by_type(int type); -classinfo *primitive_class_get_by_char(char ch); - -classinfo *primitive_arrayclass_get_by_name(utf *name); -classinfo *primitive_arrayclass_get_by_type(int type); - -int primitive_type_get_by_wrapperclass(classinfo *c); - -java_handle_t *primitive_box(int type, imm_union value); -imm_union primitive_unbox(java_handle_t *o); - -java_handle_t *primitive_box_boolean(int32_t value); -java_handle_t *primitive_box_byte(int32_t value); -java_handle_t *primitive_box_char(int32_t value); -java_handle_t *primitive_box_short(int32_t value); -java_handle_t *primitive_box_int(int32_t value); -java_handle_t *primitive_box_long(int64_t value); -java_handle_t *primitive_box_float(float value); -java_handle_t *primitive_box_double(double value); - -int32_t primitive_unbox_boolean(java_handle_t *o); -int32_t primitive_unbox_byte(java_handle_t *o); -int32_t primitive_unbox_char(java_handle_t *o); -int32_t primitive_unbox_short(java_handle_t *o); -int32_t primitive_unbox_int(java_handle_t *o); -int64_t primitive_unbox_long(java_handle_t *o); -float primitive_unbox_float(java_handle_t *o); -double primitive_unbox_double(java_handle_t *o); - -#endif /* _PRIMITIVE_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/primitive.hpp b/src/vm/primitive.hpp new file mode 100644 index 000000000..10501c8c9 --- /dev/null +++ b/src/vm/primitive.hpp @@ -0,0 +1,157 @@ +/* src/vm/primitive.hpp - primitive types + + Copyright (C) 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _PRIMITIVE_HPP +#define _PRIMITIVE_HPP + +#include "config.h" + +#include + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/linker.h" +#include "vm/utf8.h" + + +#ifdef __cplusplus + +class Primitive { +public: + static void initialize_table(); + static void post_initialize_table(); + + static classinfo* get_class_by_name(utf *name); + static classinfo* get_class_by_type(int type); + static classinfo* get_class_by_char(char ch); + static classinfo* get_arrayclass_by_name(utf* name); + static classinfo* get_arrayclass_by_type(int type); + + static int get_type_by_wrapperclass(classinfo *c); + + static java_handle_t* box(int type, imm_union value); + + static java_handle_t* box(uint8_t value); + static java_handle_t* box(int8_t value); + static java_handle_t* box(uint16_t value); + static java_handle_t* box(int16_t value); + static java_handle_t* box(int32_t value); + static java_handle_t* box(int64_t value); + static java_handle_t* box(float value); + static java_handle_t* box(double value); + + static imm_union unbox(java_handle_t *o); + + static uint8_t unbox_boolean(java_handle_t* o); + static int8_t unbox_byte(java_handle_t* o); + static uint16_t unbox_char(java_handle_t* o); + static int16_t unbox_short(java_handle_t* o); + static int32_t unbox_int(java_handle_t* o); + static int64_t unbox_long(java_handle_t* o); + static float unbox_float(java_handle_t* o); + static double unbox_double(java_handle_t* o); +}; + +#endif + +/* primitive data types *******************************************************/ + +/* These values are used in parsed descriptors and in some other + places were the different types handled internally as TYPE_INT have + to be distinguished. */ + +#define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */ + +/* CAUTION: Don't change the numerical values! These constants are + used as indices into the primitive type table. */ + +#define PRIMITIVETYPE_INT TYPE_INT +#define PRIMITIVETYPE_LONG TYPE_LNG +#define PRIMITIVETYPE_FLOAT TYPE_FLT +#define PRIMITIVETYPE_DOUBLE TYPE_DBL +#define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */ +#define PRIMITIVETYPE_BYTE 5 +#define PRIMITIVETYPE_CHAR 6 +#define PRIMITIVETYPE_SHORT 7 +#define PRIMITIVETYPE_BOOLEAN 8 +#define PRIMITIVETYPE_DUMMY2 9 /* not used! */ +#define PRIMITIVETYPE_VOID TYPE_VOID + + +/* primitivetypeinfo **********************************************************/ + +struct primitivetypeinfo { + const char* cname; /* char name of primitive class */ + utf* name; /* name of primitive class */ + classinfo* class_wrap; /* class for wrapping primitive type */ + classinfo* class_primitive; /* primitive class */ + const char* wrapname; /* name of class for wrapping */ + const char typesig; /* one character type signature */ + const char* arrayname; /* name of primitive array class */ + classinfo* arrayclass; /* primitive array class */ +}; + + +/* global variables ***********************************************************/ + +/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_ + constants (except ARRAYTYPE_OBJECT). */ + +extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT]; + +/* this function is in src/vm/primitivecore.c */ +void primitive_init(void); +void primitive_postinit(void); + +#ifndef __cplusplus +// Legacy C interface. +classinfo *Primitive_get_class_by_name(utf *name); +classinfo *Primitive_get_class_by_type(int type); + +classinfo *Primitive_get_arrayclass_by_name(utf *name); +classinfo *Primitive_get_arrayclass_by_type(int type); + +int Primitive_get_type_by_wrapperclass(classinfo *c); + +java_handle_t *Primitive_box(int type, imm_union value); +imm_union Primitive_unbox(java_handle_t *h); +#endif + +#endif // _PRIMITIVE_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/properties.c b/src/vm/properties.c deleted file mode 100644 index ea986654d..000000000 --- a/src/vm/properties.c +++ /dev/null @@ -1,756 +0,0 @@ -/* src/vm/properties.c - handling commandline properties - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" - -#include "vm/global.h" /* required by java_lang_String.h */ -#include "native/include/java_lang_String.h" - -#include "toolbox/list.h" -#include "toolbox/util.h" - -#include "vm/properties.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/asmpart.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/system.h" - - -/* internal property structure ************************************************/ - -typedef struct list_properties_entry_t list_properties_entry_t; - -struct list_properties_entry_t { - char *key; - char *value; - listnode_t linkage; -}; - - -/* global variables ***********************************************************/ - -static list_t *list_properties = NULL; - - -/* properties_init ************************************************************* - - Initialize the properties list and fill the list with default - values. - -*******************************************************************************/ - -void properties_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("properties_init"); - - list_properties = list_create(OFFSET(list_properties_entry_t, linkage)); -} - - -/* properties_set ************************************************************** - - Fill the properties list with default values. - -*******************************************************************************/ - -void properties_set(void) -{ - int len; - char *p; - - char *java_home; - char *boot_class_path; - -#if defined(ENABLE_JAVASE) - char *class_path; - char *boot_library_path; - char *extdirs; - char *endorseddirs; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - char *cwd; - char *env_user; - char *env_home; - char *env_lang; - char *lang; - char *country; - struct utsname *utsnamebuf; - - char *java_library_path; -# endif -#endif - -#if defined(ENABLE_JRE_LAYOUT) - /* SUN also uses a buffer of 4096-bytes (strace is your friend). */ - - p = MNEW(char, 4096); - - if (readlink("/proc/self/exe", p, 4095) == -1) - vm_abort("properties_set: readlink failed: %s\n", strerror(errno)); - - /* We have a path like: - - /path/to/executable/bin/java - - or - - /path/to/executeable/jre/bin/java - - Now let's strip two levels. */ - - p = system_dirname(p); - p = system_dirname(p); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Set java.home. */ - - java_home = strdup(p); - - /* Set the path to Java core native libraries. */ - - len = strlen(java_home) + strlen("/lib/classpath") + strlen("0"); - - boot_library_path = MNEW(char, len); - - strcpy(boot_library_path, java_home); - strcat(boot_library_path, "/lib/classpath"); - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* Find correct java.home. We check if there is a JRE - co-located. */ - - /* NOTE: We use the server VM here as it should be available on - all architectures. */ - - len = - strlen(p) + - strlen("/jre/lib/"JAVA_ARCH"/server/libjvm.so") + - strlen("0"); - - java_home = MNEW(char, len); - - strcpy(java_home, p); - strcat(java_home, "/jre/lib/"JAVA_ARCH"/server/libjvm.so"); - - /* Check if that libjvm.so exists. */ - - if (system_access(java_home, F_OK) == 0) { - /* Yes, we add /jre to java.home. */ - - strcpy(java_home, p); - strcat(java_home, "/jre"); - } - else { - /* No, java.home is parent directory. */ - - strcpy(java_home, p); - } - - /* Set the path to Java core native libraries. */ - - len = strlen(java_home) + strlen("/lib/"JAVA_ARCH) + strlen("0"); - - boot_library_path = MNEW(char, len); - - strcpy(boot_library_path, java_home); - strcat(boot_library_path, "/lib/"JAVA_ARCH); - -# else -# error unknown classpath configuration -# endif - - /* Free path. */ - - MFREE(p, char, len); - -#else - java_home = CACAO_PREFIX; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR"/classpath"; - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR; - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - /* No boot_library_path required. */ - -# else -# error unknown classpath configuration -# endif -#endif - - properties_add("java.home", java_home); - - /* Set the bootclasspath. */ - - p = getenv("BOOTCLASSPATH"); - - if (p != NULL) { - boot_class_path = MNEW(char, strlen(p) + strlen("0")); - strcpy(boot_class_path, p); - } - else { -#if defined(ENABLE_JRE_LAYOUT) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - len = - strlen(java_home) + strlen("/share/cacao/vm.zip:") + - strlen(java_home) + strlen("/share/classpath/glibj.zip") + - strlen("0"); - - boot_class_path = MNEW(char, len); - - strcpy(boot_class_path, java_home); - strcat(boot_class_path, "/share/cacao/vm.zip"); - strcat(boot_class_path, ":"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/share/classpath/glibj.zip"); - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* This is the bootclasspath taken from HotSpot (see - hotspot/src/share/vm/runtime/os.cpp - (os::set_boot_path)). */ - - len = - strlen(java_home) + strlen("/lib/resources.jar:") + - strlen(java_home) + strlen("/lib/rt.jar:") + - strlen(java_home) + strlen("/lib/sunrsasign.jar:") + - strlen(java_home) + strlen("/lib/jsse.jar:") + - strlen(java_home) + strlen("/lib/jce.jar:") + - strlen(java_home) + strlen("/lib/charsets.jar:") + - strlen(java_home) + strlen("/classes") + - strlen("0"); - - boot_class_path = MNEW(char, len); - - strcpy(boot_class_path, java_home); - strcat(boot_class_path, "/lib/resources.jar:"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/lib/rt.jar:"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/lib/sunrsasign.jar:"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/lib/jsse.jar:"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/lib/jce.jar:"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/lib/charsets.jar:"); - strcat(boot_class_path, java_home); - strcat(boot_class_path, "/classes"); - -# else -# error unknown classpath configuration -# endif -#else -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - len = - strlen(CACAO_VM_ZIP) + - strlen(":") + - strlen(JAVA_RUNTIME_LIBRARY_CLASSES) + - strlen("0"); - - boot_class_path = MNEW(char, len); - - strcpy(boot_class_path, CACAO_VM_ZIP); - strcat(boot_class_path, ":"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES); - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* This is the bootclasspath taken from HotSpot (see - hotspot/src/share/vm/runtime/os.cpp - (os::set_boot_path)). */ - - len = - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:") + - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:") + - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:") + - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:") + - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:") + - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:") + - strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/classes") + - strlen("0"); - - boot_class_path = MNEW(char, len); - - strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:"); - strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/classes"); - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - - len = - strlen(JAVA_RUNTIME_LIBRARY_CLASSES) + - strlen("0"); - - boot_class_path = MNEW(char, len); - - strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES); - -# else -# error unknown classpath configuration -# endif -#endif - } - - properties_add("sun.boot.class.path", boot_class_path); - properties_add("java.boot.class.path", boot_class_path); - -#if defined(ENABLE_JAVASE) - - /* Set the classpath. */ - - p = getenv("CLASSPATH"); - - if (p != NULL) { - class_path = MNEW(char, strlen(p) + strlen("0")); - strcpy(class_path, p); - } - else { - class_path = MNEW(char, strlen(".") + strlen("0")); - strcpy(class_path, "."); - } - - properties_add("java.class.path", class_path); - - /* Add java.vm properties. */ - - properties_add("java.vm.specification.version", "1.0"); - properties_add("java.vm.specification.vendor", "Sun Microsystems Inc."); - properties_add("java.vm.specification.name", "Java Virtual Machine Specification"); - properties_add("java.vm.version", VERSION); - properties_add("java.vm.vendor", "CACAO Team"); - properties_add("java.vm.name", "CACAO"); - -# if defined(ENABLE_INTRP) - if (opt_intrp) { - /* XXX We don't support java.lang.Compiler */ -/* properties_add("java.compiler", "cacao.intrp"); */ - properties_add("java.vm.info", "interpreted mode"); - } - else -# endif - { - /* XXX We don't support java.lang.Compiler */ -/* properties_add("java.compiler", "cacao.jit"); */ - properties_add("java.vm.info", "JIT mode"); - } - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - - /* Get properties from system. */ - - cwd = _Jv_getcwd(); - - env_user = getenv("USER"); - env_home = getenv("HOME"); - env_lang = getenv("LANG"); - - utsnamebuf = NEW(struct utsname); - - uname(utsnamebuf); - - properties_add("java.runtime.version", VERSION); - properties_add("java.runtime.name", "CACAO"); - - properties_add("java.specification.version", "1.5"); - properties_add("java.specification.vendor", "Sun Microsystems Inc."); - properties_add("java.specification.name", "Java Platform API Specification"); - - properties_add("java.version", JAVA_VERSION); - properties_add("java.vendor", "GNU Classpath"); - properties_add("java.vendor.url", "http://www.gnu.org/software/classpath/"); - - properties_add("java.class.version", CLASS_VERSION); - - properties_add("gnu.classpath.boot.library.path", boot_library_path); - - /* Get and set java.library.path. */ - - java_library_path = getenv("LD_LIBRARY_PATH"); - - if (java_library_path == NULL) - java_library_path = ""; - - properties_add("java.library.path", java_library_path); - - properties_add("java.io.tmpdir", "/tmp"); - -# if defined(ENABLE_INTRP) - if (opt_intrp) { - properties_add("gnu.java.compiler.name", "cacao.intrp"); - } - else -# endif - { - properties_add("gnu.java.compiler.name", "cacao.jit"); - } - - /* Set the java.ext.dirs property. */ - - len = strlen(java_home) + strlen("/jre/lib/ext") + strlen("0"); - - extdirs = MNEW(char, len); - - sprintf(extdirs, "%s/jre/lib/ext", java_home); - - properties_add("java.ext.dirs", extdirs); - - /* Set the java.ext.endorsed property. */ - - len = strlen(java_home) + strlen("/jre/lib/endorsed") + strlen("0"); - - endorseddirs = MNEW(char, len); - - sprintf(endorseddirs, "%s/jre/lib/endorsed", java_home); - - properties_add("java.endorsed.dirs", endorseddirs); - -# if defined(DISABLE_GC) - /* When we disable the GC, we mmap the whole heap to a specific - address, so we can compare call traces. For this reason we have - to add the same properties on different machines, otherwise - more memory may be allocated (e.g. strlen("i386") - vs. strlen("alpha"). */ - - properties_add("os.arch", "unknown"); - properties_add("os.name", "unknown"); - properties_add("os.version", "unknown"); -# else - properties_add("os.arch", JAVA_ARCH); - properties_add("os.name", utsnamebuf->sysname); - properties_add("os.version", utsnamebuf->release); -# endif - -# if WORDS_BIGENDIAN == 1 - properties_add("gnu.cpu.endian", "big"); -# else - properties_add("gnu.cpu.endian", "little"); -# endif - - properties_add("file.separator", "/"); - properties_add("path.separator", ":"); - properties_add("line.separator", "\n"); - - properties_add("user.name", env_user ? env_user : "null"); - properties_add("user.home", env_home ? env_home : "null"); - properties_add("user.dir", cwd ? cwd : "null"); - - /* get locale */ - - if (env_lang != NULL) { - /* get the local stuff from the environment */ - - if (strlen(env_lang) <= 2) { - properties_add("user.language", env_lang); - } - else { - if ((env_lang[2] == '_') && (strlen(env_lang) >= 5)) { - lang = MNEW(char, 3); - strncpy(lang, (char *) &env_lang[0], 2); - lang[2] = '\0'; - - country = MNEW(char, 3); - strncpy(country, (char *) &env_lang[3], 2); - country[2] = '\0'; - - properties_add("user.language", lang); - properties_add("user.country", country); - } - } - } - else { - /* if no default locale was specified, use `en_US' */ - - properties_add("user.language", "en"); - properties_add("user.country", "US"); - } - -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - - /* Actually this property is set by OpenJDK, but we need it in - nativevm_preinit(). */ - - properties_add("sun.boot.library.path", boot_library_path); - - /* Set the java.ext.dirs property. */ - - len = - strlen(java_home) + strlen("/lib/ext") + - strlen(":") + - strlen("/usr/java/packages/lib/ext") + - strlen("0"); - - extdirs = MNEW(char, len); - - sprintf(extdirs, "%s/lib/ext:/usr/java/packages/lib/ext", java_home); - - properties_add("java.ext.dirs", extdirs); - - /* Set the java.ext.endorsed property. */ - - len = strlen(java_home) + strlen("/lib/endorsed") + strlen("0"); - - endorseddirs = MNEW(char, len); - - sprintf(endorseddirs, "%s/lib/endorsed", java_home); - - properties_add("java.endorsed.dirs", endorseddirs); - -# else - -# error unknown classpath configuration - -# endif - -#elif defined(ENABLE_JAVAME_CLDC1_1) - - properties_add("microedition.configuration", "CLDC-1.1"); - properties_add("microedition.platform", "generic"); - properties_add("microedition.encoding", "ISO8859_1"); - properties_add("microedition.profiles", ""); - -#else - -# error unknown Java configuration - -#endif -} - - -/* properties_add ************************************************************** - - Adds a property entry to the internal property list. If there's - already an entry with the same key, replace it. - -*******************************************************************************/ - -void properties_add(char *key, char *value) -{ - list_properties_entry_t *pe; - - /* search for the entry */ - - for (pe = list_first(list_properties); pe != NULL; - pe = list_next(list_properties, pe)) { - if (strcmp(pe->key, key) == 0) { - /* entry was found, replace the value */ - -#if !defined(NDEBUG) - if (opt_DebugProperties) { - printf("[properties_add: key=%s, old value=%s, new value=%s]\n", - key, pe->value, value); - } -#endif - - pe->value = value; - - return; - } - } - - /* entry was not found, insert a new one */ - -#if !defined(NDEBUG) - if (opt_DebugProperties) { - printf("[properties_add: key=%s, value=%s]\n", key, value); - } -#endif - - pe = NEW(list_properties_entry_t); - - pe->key = key; - pe->value = value; - - list_add_last(list_properties, pe); -} - - -/* properties_get ************************************************************** - - Get a property entry from the internal property list. - -*******************************************************************************/ - -char *properties_get(char *key) -{ - list_properties_entry_t *pe; - - for (pe = list_first(list_properties); pe != NULL; - pe = list_next(list_properties, pe)) { - if (strcmp(pe->key, key) == 0) - return pe->value; - } - - return NULL; -} - - -/* properties_system_add ******************************************************* - - Adds a given property to the Java system properties. - -*******************************************************************************/ - -void properties_system_add(java_handle_t *p, char *key, char *value) -{ - classinfo *c; - methodinfo *m; - java_handle_t *k; - java_handle_t *v; - - /* search for method to add properties */ - - LLNI_class_get(p, c); - - m = class_resolveclassmethod(c, - utf_put, - utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), - NULL, - true); - - if (m == NULL) - return; - - /* add to the Java system properties */ - - k = javastring_new_from_utf_string(key); - v = javastring_new_from_utf_string(value); - - (void) vm_call_method(m, p, k, v); -} - - -/* properties_system_add_all *************************************************** - - Adds all properties from the properties list to the Java system - properties. - - ARGUMENTS: - p.... is actually a java_util_Properties structure - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -void properties_system_add_all(java_handle_t *p) -{ - list_properties_entry_t *pe; - classinfo *c; - methodinfo *m; - java_handle_t *key; - java_handle_t *value; - - /* search for method to add properties */ - - LLNI_class_get(p, c); - - m = class_resolveclassmethod(c, - utf_put, - utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), - NULL, - true); - - if (m == NULL) - return; - - /* process all properties stored in the internal table */ - - for (pe = list_first(list_properties); pe != NULL; - pe = list_next(list_properties, pe)) { - /* add to the Java system properties */ - - key = javastring_new_from_utf_string(pe->key); - value = javastring_new_from_utf_string(pe->value); - - (void) vm_call_method(m, (java_handle_t *) p, key, value); - } -} -#endif /* defined(ENABLE_JAVASE) */ - - -/* properties_dump ************************************************************* - - Dump all property entries. - -*******************************************************************************/ - -void properties_dump(void) -{ - list_t *l; - list_properties_entry_t *pe; - - /* For convenience. */ - - l = list_properties; - - for (pe = list_first(l); pe != NULL; pe = list_next(l, pe)) { - log_println("[properties_dump: key=%s, value=%s]", pe->key, pe->value); - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vm/properties.cpp b/src/vm/properties.cpp new file mode 100644 index 000000000..b5868faa9 --- /dev/null +++ b/src/vm/properties.cpp @@ -0,0 +1,672 @@ +/* src/vm/properties.cpp - handling commandline properties + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include + +#include +#include +#include +#include + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "toolbox/util.h" + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/properties.hpp" +#include "vm/string.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/asmpart.h" + + +/** + * Constructor fills the properties list with default values. + */ +Properties::Properties() +{ + int len; + char *p; + + char *boot_class_path; + +#if defined(ENABLE_JAVASE) + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + struct utsname *utsnamebuf; +# endif +#endif + +#if defined(ENABLE_JRE_LAYOUT) + /* SUN also uses a buffer of 4096-bytes (strace is your friend). */ + + p = MNEW(char, 4096); + + if (os::readlink("/proc/self/exe", p, 4095) == -1) + VM::get_current()->abort_errno("readlink failed"); + + /* We have a path like: + + /path/to/executable/bin/java + + or + + /path/to/executeable/jre/bin/java + + Now let's strip two levels. */ + + p = os::dirname(p); + p = os::dirname(p); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + /* Set java.home. */ + + char* java_home = strdup(p); + + /* Set the path to Java core native libraries. */ + + len = strlen(java_home) + strlen("/lib/classpath") + strlen("0"); + + char* boot_library_path = MNEW(char, len); + + strcpy(boot_library_path, java_home); + strcat(boot_library_path, "/lib/classpath"); + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + /* Find correct java.home. We check if there is a JRE + co-located. */ + + /* NOTE: We use the server VM here as it should be available on + all architectures. */ + + len = + strlen(p) + + strlen("/jre/lib/"JAVA_ARCH"/server/libjvm.so") + + strlen("0"); + + char* java_home = MNEW(char, len); + + strcpy(java_home, p); + strcat(java_home, "/jre/lib/"JAVA_ARCH"/server/libjvm.so"); + + // Check if that libjvm.so exists. + if (os::access(java_home, F_OK) == 0) { + // Yes, we add /jre to java.home. + strcpy(java_home, p); + strcat(java_home, "/jre"); + } + else { + // No, java.home is parent directory. + strcpy(java_home, p); + } + + /* Set the path to Java core native libraries. */ + + len = strlen(java_home) + strlen("/lib/"JAVA_ARCH) + strlen("0"); + + char* boot_library_path = MNEW(char, len); + + strcpy(boot_library_path, java_home); + strcat(boot_library_path, "/lib/"JAVA_ARCH); + +# else +# error unknown classpath configuration +# endif + + /* Free path. */ + + MFREE(p, char, len); + +#else + const char* java_home = CACAO_PREFIX; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + const char* boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR"/classpath"; + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + const char* boot_library_path = JAVA_RUNTIME_LIBRARY_LIBDIR; + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + // No boot_library_path required. + +# else +# error unknown classpath configuration +# endif +#endif + + put("java.home", java_home); + + /* Set the bootclasspath. */ + + p = os::getenv("BOOTCLASSPATH"); + + if (p != NULL) { + boot_class_path = MNEW(char, strlen(p) + strlen("0")); + strcpy(boot_class_path, p); + } + else { +#if defined(ENABLE_JRE_LAYOUT) +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + len = + strlen(java_home) + strlen("/share/cacao/vm.zip:") + + strlen(java_home) + strlen("/share/classpath/glibj.zip") + + strlen("0"); + + boot_class_path = MNEW(char, len); + + strcpy(boot_class_path, java_home); + strcat(boot_class_path, "/share/cacao/vm.zip"); + strcat(boot_class_path, ":"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/share/classpath/glibj.zip"); + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + /* This is the bootclasspath taken from HotSpot (see + hotspot/src/share/vm/runtime/os.cpp + (os::set_boot_path)). */ + + len = + strlen(java_home) + strlen("/lib/resources.jar:") + + strlen(java_home) + strlen("/lib/rt.jar:") + + strlen(java_home) + strlen("/lib/sunrsasign.jar:") + + strlen(java_home) + strlen("/lib/jsse.jar:") + + strlen(java_home) + strlen("/lib/jce.jar:") + + strlen(java_home) + strlen("/lib/charsets.jar:") + + strlen(java_home) + strlen("/classes") + + strlen("0"); + + boot_class_path = MNEW(char, len); + + strcpy(boot_class_path, java_home); + strcat(boot_class_path, "/lib/resources.jar:"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/lib/rt.jar:"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/lib/sunrsasign.jar:"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/lib/jsse.jar:"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/lib/jce.jar:"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/lib/charsets.jar:"); + strcat(boot_class_path, java_home); + strcat(boot_class_path, "/classes"); + +# else +# error unknown classpath configuration +# endif +#else +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + len = + strlen(CACAO_VM_ZIP) + + strlen(":") + + strlen(JAVA_RUNTIME_LIBRARY_CLASSES) + + strlen("0"); + + boot_class_path = MNEW(char, len); + + strcpy(boot_class_path, CACAO_VM_ZIP); + strcat(boot_class_path, ":"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES); + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + /* This is the bootclasspath taken from HotSpot (see + hotspot/src/share/vm/runtime/os.cpp + (os::set_boot_path)). */ + + len = + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:") + + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:") + + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:") + + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:") + + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:") + + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:") + + strlen(JAVA_RUNTIME_LIBRARY_PREFIX"/classes") + + strlen("0"); + + boot_class_path = MNEW(char, len); + + strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/resources.jar:"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/rt.jar:"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/sunrsasign.jar:"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jsse.jar:"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/jce.jar:"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/lib/charsets.jar:"); + strcat(boot_class_path, JAVA_RUNTIME_LIBRARY_PREFIX"/classes"); + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) + + len = + strlen(JAVA_RUNTIME_LIBRARY_CLASSES) + + strlen("0"); + + boot_class_path = MNEW(char, len); + + strcpy(boot_class_path, JAVA_RUNTIME_LIBRARY_CLASSES); + +# else +# error unknown classpath configuration +# endif +#endif + } + + put("sun.boot.class.path", boot_class_path); + put("java.boot.class.path", boot_class_path); + +#if defined(ENABLE_JAVASE) + + /* Set the classpath. */ + + p = os::getenv("CLASSPATH"); + + char* class_path; + + if (p != NULL) { + class_path = MNEW(char, strlen(p) + strlen("0")); + strcpy(class_path, p); + } + else { + class_path = MNEW(char, strlen(".") + strlen("0")); + strcpy(class_path, "."); + } + + put("java.class.path", class_path); + + // Add java.vm properties. + put("java.vm.specification.version", "1.0"); + put("java.vm.specification.vendor", "Sun Microsystems Inc."); + put("java.vm.specification.name", "Java Virtual Machine Specification"); + put("java.vm.version", VERSION); + put("java.vm.vendor", "CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO"); + put("java.vm.name", "CACAO"); + +# if defined(ENABLE_INTRP) + if (opt_intrp) { + /* XXX We don't support java.lang.Compiler */ +/* put("java.compiler", "cacao.intrp"); */ + put("java.vm.info", "interpreted mode"); + } + else +# endif + { + /* XXX We don't support java.lang.Compiler */ +/* put("java.compiler", "cacao.jit"); */ + put("java.vm.info", "JIT mode"); + } + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + + /* Get properties from system. */ + + char* cwd = _Jv_getcwd(); + + char* env_user = os::getenv("USER"); + char* env_home = os::getenv("HOME"); + char* env_lang = os::getenv("LANG"); + + utsnamebuf = NEW(struct utsname); + + uname(utsnamebuf); + + put("java.runtime.version", VERSION); + put("java.runtime.name", "CACAO"); + + put("java.specification.version", "1.5"); + put("java.specification.vendor", "Sun Microsystems Inc."); + put("java.specification.name", "Java Platform API Specification"); + + put("java.version", JAVA_VERSION); + put("java.vendor", "GNU Classpath"); + put("java.vendor.url", "http://www.gnu.org/software/classpath/"); + + put("java.class.version", CLASS_VERSION); + + put("gnu.classpath.boot.library.path", boot_library_path); + + // Get and set java.library.path. + const char* java_library_path = os::getenv("LD_LIBRARY_PATH"); + + if (java_library_path == NULL) + java_library_path = ""; + + put("java.library.path", java_library_path); + + put("java.io.tmpdir", "/tmp"); + +# if defined(ENABLE_INTRP) + if (opt_intrp) { + put("gnu.java.compiler.name", "cacao.intrp"); + } + else +# endif + { + put("gnu.java.compiler.name", "cacao.jit"); + } + + /* Set the java.ext.dirs property. */ + + len = strlen(java_home) + strlen("/jre/lib/ext") + strlen("0"); + + char* extdirs = MNEW(char, len); + + sprintf(extdirs, "%s/jre/lib/ext", java_home); + + put("java.ext.dirs", extdirs); + + /* Set the java.ext.endorsed property. */ + + len = strlen(java_home) + strlen("/jre/lib/endorsed") + strlen("0"); + + char* endorseddirs = MNEW(char, len); + + sprintf(endorseddirs, "%s/jre/lib/endorsed", java_home); + + put("java.endorsed.dirs", endorseddirs); + +# if defined(DISABLE_GC) + /* When we disable the GC, we mmap the whole heap to a specific + address, so we can compare call traces. For this reason we have + to add the same properties on different machines, otherwise + more memory may be allocated (e.g. strlen("i386") + vs. strlen("alpha"). */ + + put("os.arch", "unknown"); + put("os.name", "unknown"); + put("os.version", "unknown"); +# else + put("os.arch", JAVA_ARCH); + put("os.name", utsnamebuf->sysname); + put("os.version", utsnamebuf->release); +# endif + +# if WORDS_BIGENDIAN == 1 + put("gnu.cpu.endian", "big"); +# else + put("gnu.cpu.endian", "little"); +# endif + + put("file.separator", "/"); + put("path.separator", ":"); + put("line.separator", "\n"); + + put("user.name", env_user ? env_user : "null"); + put("user.home", env_home ? env_home : "null"); + put("user.dir", cwd ? cwd : "null"); + + /* get locale */ + + if (env_lang != NULL) { + /* get the local stuff from the environment */ + + if (strlen(env_lang) <= 2) { + put("user.language", env_lang); + } + else { + if ((env_lang[2] == '_') && (strlen(env_lang) >= 5)) { + char* lang = MNEW(char, 3); + strncpy(lang, (char*) &env_lang[0], 2); + lang[2] = '\0'; + + char* country = MNEW(char, 3); + strncpy(country, (char*) &env_lang[3], 2); + country[2] = '\0'; + + put("user.language", lang); + put("user.country", country); + } + } + } + else { + /* if no default locale was specified, use `en_US' */ + + put("user.language", "en"); + put("user.country", "US"); + } + +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + + /* Actually this property is set by OpenJDK, but we need it in + nativevm_preinit(). */ + + put("sun.boot.library.path", boot_library_path); + + // Set the java.ext.dirs property. + len = + strlen(java_home) + strlen("/lib/ext") + + strlen(":") + + strlen("/usr/java/packages/lib/ext") + + strlen("0"); + + char* extdirs = MNEW(char, len); + + sprintf(extdirs, "%s/lib/ext:/usr/java/packages/lib/ext", java_home); + + put("java.ext.dirs", extdirs); + + // Set the java.ext.endorsed property. + len = strlen(java_home) + strlen("/lib/endorsed") + strlen("0"); + + char* endorseddirs = MNEW(char, len); + + sprintf(endorseddirs, "%s/lib/endorsed", java_home); + + put("java.endorsed.dirs", endorseddirs); + +# else + +# error unknown classpath configuration + +# endif + +#elif defined(ENABLE_JAVAME_CLDC1_1) + + put("microedition.configuration", "CLDC-1.1"); + put("microedition.platform", "generic"); + put("microedition.encoding", "ISO8859_1"); + put("microedition.profiles", ""); + +#else + +# error unknown Java configuration + +#endif +} + + +/** + * Add the given property to the given Java system properties. + * + * @param p Java properties object. + * @param key Key. + * @param value Value. + */ +void Properties::put(java_handle_t* p, const char* key, const char* value) +{ + // Get Properties.put() method to add properties. + classinfo* c; + LLNI_class_get(p, c); + + methodinfo* m = class_resolveclassmethod(c, + utf_put, + utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), + NULL, + true); + + if (m == NULL) + return; + + // Add to the Java system properties. + java_handle_t* k = javastring_new_from_utf_string(key); + java_handle_t* v = javastring_new_from_utf_string(value); + + (void) vm_call_method(m, p, k, v); +} + + +/** + * Put the given property into the internal property map. If there's + * already an entry with the same key, replace it. + * + * @param key Key. + * @param value Value. + */ +void Properties::put(const char* key, const char* value) +{ + // Try to find the key. + std::map::iterator it = _properties.find(key); + + // The key is already in the map. + if (it != _properties.end()) { +#if !defined(NDEBUG) + if (opt_DebugProperties) { + printf("[Properties::put: key=%s, old value=%s, new value=%s]\n", + key, it->second, value); + } +#endif + + // Replace the value in the current entry. + it->second = value; + + return; + } + + // The key was not found, insert the pair. +#if !defined(NDEBUG) + if (opt_DebugProperties) { + printf("[Properties::put: key=%s, value=%s]\n", key, value); + } +#endif + + _properties.insert(std::make_pair(key, value)); +} + + +/** + * Get a property entry from the internal property map. + * + * @param key Key. + * + * @return Value associated with the key or NULL when not found. + */ +const char* Properties::get(const char* key) +{ + // Try to find the key. + std::map::iterator it = _properties.find(key); + + // The key is not in the map. + if (it == _properties.end()) + return NULL; + + // Return the value. + return it->second; +} + + +/** + * Fill the given Java system properties with all properties from the + * internal properties map. + * + * @param p Java Properties object. + */ +#if defined(ENABLE_JAVASE) +void Properties::fill(java_handle_t* p) +{ + // Get Properties.put() method to add properties. + classinfo* c; + LLNI_class_get(p, c); + + methodinfo* m = class_resolveclassmethod(c, + utf_put, + utf_new_char("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), + NULL, + true); + + if (m == NULL) + return; + + // Iterator over all properties. + for (std::map::iterator it = _properties.begin(); it != _properties.end(); it++) { + // Put into the Java system properties. + java_handle_t* key = javastring_new_from_utf_string(it->first); + java_handle_t* value = javastring_new_from_utf_string(it->second); + + (void) vm_call_method(m, p, key, value); + } +} +#endif + + +/** + * Dump all property entries. + */ +#if !defined(NDEBUG) +void Properties::dump() +{ + for (std::map::iterator it = _properties.begin(); it != _properties.end(); it++) { + log_println("[Properties::dump: key=%s, value=%s]", it->first, it->second); + } +} +#endif + + +// Legacy C interface. +extern "C" { + void Properties_put(const char *key, const char *value) { VM::get_current()->get_properties().put(key, value); } + const char *Properties_get(const char *key) { return VM::get_current()->get_properties().get(key); } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/properties.h b/src/vm/properties.h deleted file mode 100644 index a468aec57..000000000 --- a/src/vm/properties.h +++ /dev/null @@ -1,68 +0,0 @@ -/* src/vm/properties.h - handling commandline properties - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _PROPERTIES_H -#define _PROPERTIES_H - -#include "config.h" - -#include - -#include "vm/global.h" - - -/* function prototypes ********************************************************/ - -void properties_init(void); -void properties_set(void); - -void properties_add(char *key, char *value); -char *properties_get(char *key); - -void properties_system_add(java_handle_t *p, char *key, char *value); - -#if defined(ENABLE_JAVASE) -void properties_system_add_all(java_handle_t *p); -#endif - -void properties_dump(void); - -#endif /* _PROPERTIES_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vm/properties.hpp b/src/vm/properties.hpp new file mode 100644 index 000000000..582099c0c --- /dev/null +++ b/src/vm/properties.hpp @@ -0,0 +1,94 @@ +/* src/vm/properties.hpp - handling commandline properties + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _PROPERTIES_HPP +#define _PROPERTIES_HPP + +#include "config.h" + +#include + +#ifdef __cplusplus + +#include + +#include "vm/os.hpp" + + +class ltstr { +public: + bool operator()(const char* s1, const char* s2) const + { + return os::strcmp(s1, s2) < 0; + } +}; + + +/** + * Commandline properties. + */ +class Properties { +private: + std::map _properties; + +public: + Properties(); + + // Static function. + static void put(java_handle_t* p, const char* key, const char* value); + + void put(const char* key, const char* value); + const char* get(const char* key); + void fill(java_handle_t* p); +#if !defined(NDEBUG) + void dump(); +#endif +}; + +#else + +typedef struct Properties Properties; + +void Properties_put(const char *key, const char *value); +const char *Properties_get(const char *key); + +#endif + +#endif // _PROPERTIES_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/references.h b/src/vm/references.h new file mode 100644 index 000000000..576a90496 --- /dev/null +++ b/src/vm/references.h @@ -0,0 +1,167 @@ +/* src/vm/references.h - references to classes/fields/methods + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + +#ifndef _REFERENCES_H_ +#define _REFERENCES_H_ + +/* forward typedefs ***********************************************************/ + +typedef struct constant_classref constant_classref; +typedef struct constant_FMIref constant_FMIref; + + +/* constant_classref **********************************************************/ + +struct constant_classref { + void *pseudo_vftbl; /* for distinguishing it from classinfo */ + struct classinfo *referer; /* class containing the reference */ + struct utf *name; /* name of the class refered to */ +}; + + +/* classref_or_classinfo ******************************************************/ + +typedef union classref_or_classinfo { + constant_classref *ref; /* a symbolic class reference */ + struct classinfo *cls; /* an already loaded class */ + void *any; /* used for general access (x != NULL,...) */ +} classref_or_classinfo; + + +/* parseddesc_t ***************************************************************/ + +typedef union parseddesc { + struct typedesc *fd; /* parsed field descriptor */ + struct methoddesc *md; /* parsed method descriptor */ + void *any; /* used for simple test against NULL */ +} parseddesc_t; + + +#include "config.h" +#include "vm/types.h" + +#include "vm/class.h" +#include "vm/descriptor.h" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/method.h" +#include "vm/utf8.h" + + +/*----------------------------------------------------------------------------*/ +/* References */ +/* */ +/* This header files defines the following types used for references to */ +/* classes/methods/fields and descriptors: */ +/* */ +/* classinfo * a loaded class */ +/* constant_classref a symbolic reference */ +/* classref_or_classinfo a loaded class or a symbolic reference */ +/* */ +/* constant_FMIref a symb. ref. to a field/method/intf.method */ +/* */ +/* typedesc * describes a field type */ +/* methoddesc * descrives a method type */ +/* parseddesc describes a field type or a method type */ +/*----------------------------------------------------------------------------*/ + +/* structs ********************************************************************/ + +/* constant_FMIref ************************************************************/ + +struct constant_FMIref{ /* Fieldref, Methodref and InterfaceMethodref */ + union { + s4 index; /* used only within the loader */ + constant_classref *classref; /* class having this field/meth./intfm. */ + fieldinfo *field; /* resolved field */ + methodinfo *method; /* resolved method */ + } p; + utf *name; /* field/method/interfacemethod name */ + utf *descriptor; /* field/method/intfmeth. type descriptor string */ + parseddesc_t parseddesc; /* parsed descriptor */ +}; + + +/* macros *********************************************************************/ + +/* a value that never occurrs in classinfo.header.vftbl */ +#define CLASSREF_PSEUDO_VFTBL ((void *) 1) + +/* macro for testing if a classref_or_classinfo is a classref */ +/* `reforinfo` is only evaluated once */ +#define IS_CLASSREF(reforinfo) \ + ((reforinfo).ref->pseudo_vftbl == CLASSREF_PSEUDO_VFTBL) + +/* macro for testing if a constant_FMIref has been resolved */ +/* `fmiref` is only evaluated once */ +#define IS_FMIREF_RESOLVED(fmiref) \ + ((fmiref)->p.classref->pseudo_vftbl != CLASSREF_PSEUDO_VFTBL) + +/* the same as IS_CLASSREF, but also check against NULL */ +#define IS_XCLASSREF(reforinfo) \ + ((reforinfo).any && IS_CLASSREF(reforinfo)) + +/* macro for casting a classref/classinfo * to a classref_or_classinfo */ +#define CLASSREF_OR_CLASSINFO(value) \ + (*((classref_or_classinfo *)(&(value)))) + +/* macro for accessing the name of a classref/classinfo */ +#define CLASSREF_OR_CLASSINFO_NAME(value) \ + (IS_CLASSREF(value) ? (value).ref->name : (value).cls->name) + +/* macro for accessing the class name of a method reference */ +#define METHODREF_CLASSNAME(fmiref) \ + (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.method->clazz->name \ + : (fmiref)->p.classref->name) + +/* macro for accessing the class name of a method reference */ +#define FIELDREF_CLASSNAME(fmiref) \ + (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.field->clazz->name \ + : (fmiref)->p.classref->name) + +/* initialize a constant_classref with referer `ref` and name `classname` */ + +#define CLASSREF_INIT(c,ref,classname) \ + do { \ + (c).pseudo_vftbl = CLASSREF_PSEUDO_VFTBL; \ + (c).referer = (ref); \ + (c).name = (classname); \ + } while (0) + +#endif /* _REFERENCES_H_ */ + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ + diff --git a/src/vm/resolve.c b/src/vm/resolve.c index b125bdefc..dc8e3e2c0 100644 --- a/src/vm/resolve.c +++ b/src/vm/resolve.c @@ -32,20 +32,20 @@ #include "mm/memory.h" #include "vm/access.h" -#include "vm/exceptions.h" +#include "vm/classcache.h" +#include "vm/descriptor.h" +#include "vm/exceptions.hpp" #include "vm/global.h" -#include "vm/primitive.h" +#include "vm/globals.hpp" +#include "vm/linker.h" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" #include "vm/resolve.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/verify/typeinfo.h" -#include "vmcore/classcache.h" -#include "vmcore/descriptor.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - /******************************************************************************/ /* DEBUG HELPERS */ @@ -500,7 +500,7 @@ bool resolve_class_from_typedesc(typedesc *d, bool checkaccess, bool link, class else { /* a primitive type */ - cls = primitive_class_get_by_type(d->decltype); + cls = Primitive_get_class_by_type(d->primitivetype); assert(cls->state & CLASS_LOADED); @@ -1329,7 +1329,7 @@ resolve_result_t resolve_field_lazy(methodinfo *refmethod, fi = class_resolvefield(container, fieldref->name, fieldref->descriptor, - referer, true); + referer); if (!fi) { /* The field does not exist. But since we were called lazily, */ /* this error must not be reported now. (It will be reported */ @@ -1427,7 +1427,7 @@ bool resolve_field(unresolved_field *ref, fi = class_resolvefield(container, ref->fieldref->name,ref->fieldref->descriptor, - referer,true); + referer); if (!fi) { if (mode == resolveLazy) { /* The field does not exist. But since we were called lazily, */ diff --git a/src/vm/resolve.h b/src/vm/resolve.h index 681382068..cfa0b9205 100644 --- a/src/vm/resolve.h +++ b/src/vm/resolve.h @@ -37,16 +37,17 @@ typedef struct unresolved_subtype_set unresolved_subtype_set; #include "config.h" #include "vm/types.h" +#include "vm/class.h" +#include "vm/field.hpp" #include "vm/global.h" +#include "vm/method.h" +#include "vm/references.h" -#include "vm/jit/jit.h" +#include "vm/jit/jit.hpp" #include "vm/jit/reg.h" -#include "vm/jit/verify/typeinfo.h" -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/method.h" -#include "vmcore/references.h" +#include "vm/jit/ir/instruction.hpp" +#include "vm/jit/verify/typeinfo.h" /* constants ******************************************************************/ @@ -115,6 +116,10 @@ struct unresolved_method { /* function prototypes ********************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + void resolve_handle_pending_exception(bool throwError); bool resolve_class_from_name(classinfo* referer,methodinfo *refmethod, @@ -256,6 +261,10 @@ void unresolved_field_debug_dump(unresolved_field *ref,FILE *file); void unresolved_method_debug_dump(unresolved_method *ref,FILE *file); void unresolved_subtype_set_debug_dump(unresolved_subtype_set *stset,FILE *file); #endif + +#ifdef __cplusplus +} +#endif #endif /* _RESOLVE_H */ diff --git a/src/vm/rt-timing.c b/src/vm/rt-timing.c new file mode 100644 index 000000000..2064de2d0 --- /dev/null +++ b/src/vm/rt-timing.c @@ -0,0 +1,203 @@ +/* src/vm/rt-timing.c - POSIX real-time timing utilities + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "vm/global.h" +#include "vm/rt-timing.h" + + +struct rt_timing_stat { + int index; + int totalindex; + const char *name; +}; + +static struct rt_timing_stat rt_timing_stat_defs[] = { + { RT_TIMING_JIT_CHECKS ,RT_TIMING_JIT_TOTAL , "checks at beginning" }, + { RT_TIMING_JIT_PARSE ,RT_TIMING_JIT_TOTAL , "parse" }, + { RT_TIMING_JIT_STACK ,RT_TIMING_JIT_TOTAL , "analyse_stack" }, + { RT_TIMING_JIT_TYPECHECK ,RT_TIMING_JIT_TOTAL , "typecheck" }, + { RT_TIMING_JIT_LOOP ,RT_TIMING_JIT_TOTAL , "loop" }, + { RT_TIMING_JIT_IFCONV ,RT_TIMING_JIT_TOTAL , "if conversion" }, + { RT_TIMING_JIT_ALLOC ,RT_TIMING_JIT_TOTAL , "register allocation" }, + { RT_TIMING_JIT_RPLPOINTS ,RT_TIMING_JIT_TOTAL , "replacement point generation" }, + { RT_TIMING_JIT_CODEGEN ,RT_TIMING_JIT_TOTAL , "codegen" }, + { RT_TIMING_JIT_TOTAL ,-1 , "total compile time" }, + { -1 ,-1 , "" }, + + { RT_TIMING_LINK_RESOLVE ,RT_TIMING_LINK_TOTAL, "link: resolve superclass/superinterfaces"}, + { RT_TIMING_LINK_C_VFTBL ,RT_TIMING_LINK_TOTAL, "link: compute vftbl length"}, + { RT_TIMING_LINK_ABSTRACT ,RT_TIMING_LINK_TOTAL, "link: handle abstract methods"}, + { RT_TIMING_LINK_C_IFTBL ,RT_TIMING_LINK_TOTAL, "link: compute interface table"}, + { RT_TIMING_LINK_F_VFTBL ,RT_TIMING_LINK_TOTAL, "link: fill vftbl"}, + { RT_TIMING_LINK_OFFSETS ,RT_TIMING_LINK_TOTAL, "link: set offsets"}, + { RT_TIMING_LINK_F_IFTBL ,RT_TIMING_LINK_TOTAL, "link: fill interface table"}, + { RT_TIMING_LINK_FINALIZER ,RT_TIMING_LINK_TOTAL, "link: set finalizer"}, + { RT_TIMING_LINK_EXCEPTS ,RT_TIMING_LINK_TOTAL, "link: resolve exception classes"}, + { RT_TIMING_LINK_SUBCLASS ,RT_TIMING_LINK_TOTAL, "link: re-calculate subclass indices"}, + { RT_TIMING_LINK_TOTAL ,-1 , "total link time" }, + { -1 ,-1 , "" }, + + { RT_TIMING_LOAD_CHECKS ,RT_TIMING_LOAD_TOTAL, "load: initial checks"}, + { RT_TIMING_LOAD_NDPOOL ,RT_TIMING_LOAD_TOTAL, "load: new descriptor pool"}, + { RT_TIMING_LOAD_CPOOL ,RT_TIMING_LOAD_TOTAL, "load: load constant pool"}, + { RT_TIMING_LOAD_SETUP ,RT_TIMING_LOAD_TOTAL, "load: class setup"}, + { RT_TIMING_LOAD_FIELDS ,RT_TIMING_LOAD_TOTAL, "load: load fields"}, + { RT_TIMING_LOAD_METHODS ,RT_TIMING_LOAD_TOTAL, "load: load methods"}, + { RT_TIMING_LOAD_CLASSREFS ,RT_TIMING_LOAD_TOTAL, "load: create classrefs"}, + { RT_TIMING_LOAD_DESCS ,RT_TIMING_LOAD_TOTAL, "load: allocate descriptors"}, + { RT_TIMING_LOAD_SETREFS ,RT_TIMING_LOAD_TOTAL, "load: set classrefs"}, + { RT_TIMING_LOAD_PARSEFDS ,RT_TIMING_LOAD_TOTAL, "load: parse field descriptors"}, + { RT_TIMING_LOAD_PARSEMDS ,RT_TIMING_LOAD_TOTAL, "load: parse method descriptors"}, + { RT_TIMING_LOAD_PARSECP ,RT_TIMING_LOAD_TOTAL, "load: parse descriptors in constant pool"}, + { RT_TIMING_LOAD_VERIFY ,RT_TIMING_LOAD_TOTAL, "load: verifier checks"}, + { RT_TIMING_LOAD_ATTRS ,RT_TIMING_LOAD_TOTAL, "load: load attributes"}, + { RT_TIMING_LOAD_TOTAL ,-1 , "total load time (from classbuffer)"}, + { -1 ,-1 , "" }, + + { RT_TIMING_LOAD_BOOT_LOOKUP,-1 , "boot: lookup in classcache"}, + { RT_TIMING_LOAD_BOOT_ARRAY ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load array classes"}, + { RT_TIMING_LOAD_BOOT_SUCK ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: suck class files"}, + { RT_TIMING_LOAD_BOOT_LOAD ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load from class buffer"}, + { RT_TIMING_LOAD_BOOT_CACHE ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: store in classcache"}, + { RT_TIMING_LOAD_BOOT_TOTAL ,-1 , "total bootstrap loader time"}, + { -1 ,-1 , "" }, + + { RT_TIMING_LOAD_CL_LOOKUP ,-1 , "classloader: lookup in classcache" }, + { RT_TIMING_LOAD_CL_PREPARE ,-1 , "classloader: prepare loader call" }, + { RT_TIMING_LOAD_CL_JAVA ,-1 , "classloader: loader Java code" }, + { RT_TIMING_LOAD_CL_CACHE ,-1 , "classloader: store in classcache" }, + { -1 ,-1 , "" }, + + { RT_TIMING_NEW_OBJECT ,-1 , "builtin_new time" }, + { RT_TIMING_NEW_ARRAY ,-1 , "builtin_newarray time" }, + { -1 ,-1 , "" }, + + { RT_TIMING_GC_ALLOC ,-1 , "heap allocation time" }, +#if defined(ENABLE_GC_CACAO) + { RT_TIMING_GC_SUSPEND ,RT_TIMING_GC_TOTAL , "gc: suspending threads" }, + { RT_TIMING_GC_ROOTSET1 ,RT_TIMING_GC_TOTAL , "gc: rootset finding" }, + { RT_TIMING_GC_MARK ,RT_TIMING_GC_TOTAL , "gc: marking phase" }, + { RT_TIMING_GC_COMPACT ,RT_TIMING_GC_TOTAL , "gc: compaction phase" }, + { RT_TIMING_GC_ROOTSET2 ,RT_TIMING_GC_TOTAL , "gc: rootset writeback" }, + { RT_TIMING_GC_TOTAL ,-1 , "total garbage collection time" }, +#endif + { -1 ,-1 , "" }, + +#if defined(ENABLE_REPLACEMENT) + { RT_TIMING_REPLACE ,-1 , "replacement" }, + { -1 ,-1 , "" }, +#endif + + { RT_TIMING_1 ,-1 , "temporary timer 1" }, + { RT_TIMING_2 ,-1 , "temporary timer 2" }, + { RT_TIMING_3 ,-1 , "temporary timer 3" }, + { RT_TIMING_4 ,-1 , "temporary timer 4" }, + { -1 ,-1 , "" }, + + { 0 ,-1 , NULL } +}; + +static long long rt_timing_sum[RT_TIMING_N] = { 0 }; + +void rt_timing_gettime(struct timespec *ts) +{ + if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,ts) != 0) { + fprintf(stderr,"could not get time by clock_gettime: %s\n",strerror(errno)); + abort(); + } +} + +long rt_timing_diff_usec(struct timespec *a,struct timespec *b) +{ + long diff; + time_t atime; + + diff = (b->tv_nsec - a->tv_nsec) / 1000; + atime = a->tv_sec; + while (atime < b->tv_sec) { + atime++; + diff += 1000000; + } + return diff; +} + +void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index) +{ + long diff; + + diff = rt_timing_diff_usec(a,b); + rt_timing_sum[index] += diff; +} + +void rt_timing_print_time_stats(FILE *file) +{ + struct rt_timing_stat *stats; + double total; + + for (stats = rt_timing_stat_defs; stats->name; ++stats) { + if (stats->index < 0) { + fprintf(file,"%s\n",stats->name); + continue; + } + + if (stats->totalindex >= 0) { + total = rt_timing_sum[stats->totalindex]; + fprintf(file,"%12lld usec %3.0f%% %s\n", + rt_timing_sum[stats->index], + (total != 0.0) ? rt_timing_sum[stats->index] / total * 100.0 : 0.0, + stats->name); + } + else { + fprintf(file,"%12lld usec %s\n", + rt_timing_sum[stats->index], + stats->name); + } + } +} + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/rt-timing.h b/src/vm/rt-timing.h new file mode 100644 index 000000000..26d31a41b --- /dev/null +++ b/src/vm/rt-timing.h @@ -0,0 +1,148 @@ +/* src/vm/rt-timing.h - POSIX real-time timing utilities + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _RT_TIMING_H +#define _RT_TIMING_H + +#include "config.h" + +#if defined(ENABLE_RT_TIMING) + +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "vm/global.h" + + +#define RT_TIMING_GET_TIME(ts) \ + rt_timing_gettime(&(ts)); + +#define RT_TIMING_TIME_DIFF(a,b,index) \ + rt_timing_time_diff(&(a),&(b),(index)); + +#define RT_TIMING_JIT_CHECKS 0 +#define RT_TIMING_JIT_PARSE 1 +#define RT_TIMING_JIT_STACK 2 +#define RT_TIMING_JIT_TYPECHECK 3 +#define RT_TIMING_JIT_LOOP 4 +#define RT_TIMING_JIT_IFCONV 5 +#define RT_TIMING_JIT_ALLOC 6 +#define RT_TIMING_JIT_RPLPOINTS 7 +#define RT_TIMING_JIT_CODEGEN 8 +#define RT_TIMING_JIT_TOTAL 9 + +#define RT_TIMING_LINK_RESOLVE 10 +#define RT_TIMING_LINK_C_VFTBL 11 +#define RT_TIMING_LINK_ABSTRACT 12 +#define RT_TIMING_LINK_C_IFTBL 13 +#define RT_TIMING_LINK_F_VFTBL 14 +#define RT_TIMING_LINK_OFFSETS 15 +#define RT_TIMING_LINK_F_IFTBL 16 +#define RT_TIMING_LINK_FINALIZER 17 +#define RT_TIMING_LINK_EXCEPTS 18 +#define RT_TIMING_LINK_SUBCLASS 19 +#define RT_TIMING_LINK_TOTAL 20 + +#define RT_TIMING_LOAD_CHECKS 21 +#define RT_TIMING_LOAD_NDPOOL 22 +#define RT_TIMING_LOAD_CPOOL 23 +#define RT_TIMING_LOAD_SETUP 24 +#define RT_TIMING_LOAD_FIELDS 25 +#define RT_TIMING_LOAD_METHODS 26 +#define RT_TIMING_LOAD_CLASSREFS 27 +#define RT_TIMING_LOAD_DESCS 28 +#define RT_TIMING_LOAD_SETREFS 29 +#define RT_TIMING_LOAD_PARSEFDS 30 +#define RT_TIMING_LOAD_PARSEMDS 31 +#define RT_TIMING_LOAD_PARSECP 32 +#define RT_TIMING_LOAD_VERIFY 33 +#define RT_TIMING_LOAD_ATTRS 34 +#define RT_TIMING_LOAD_TOTAL 35 + +#define RT_TIMING_LOAD_BOOT_LOOKUP 36 +#define RT_TIMING_LOAD_BOOT_ARRAY 37 +#define RT_TIMING_LOAD_BOOT_SUCK 38 +#define RT_TIMING_LOAD_BOOT_LOAD 39 +#define RT_TIMING_LOAD_BOOT_CACHE 40 +#define RT_TIMING_LOAD_BOOT_TOTAL 41 + +#define RT_TIMING_LOAD_CL_LOOKUP 42 +#define RT_TIMING_LOAD_CL_PREPARE 43 +#define RT_TIMING_LOAD_CL_JAVA 44 +#define RT_TIMING_LOAD_CL_CACHE 45 + +#define RT_TIMING_NEW_OBJECT 46 +#define RT_TIMING_NEW_ARRAY 47 + +#define RT_TIMING_GC_ALLOC 48 +#define RT_TIMING_GC_SUSPEND 49 +#define RT_TIMING_GC_ROOTSET1 50 +#define RT_TIMING_GC_MARK 51 +#define RT_TIMING_GC_COMPACT 52 +#define RT_TIMING_GC_ROOTSET2 53 +#define RT_TIMING_GC_TOTAL 54 + +#define RT_TIMING_REPLACE 55 + +#define RT_TIMING_1 56 +#define RT_TIMING_2 57 +#define RT_TIMING_3 58 +#define RT_TIMING_4 59 + +#define RT_TIMING_N 60 + +void rt_timing_gettime(struct timespec *ts); + +void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index); + +long rt_timing_diff_usec(struct timespec *a,struct timespec *b); + +void rt_timing_print_time_stats(FILE *file); + +#else /* !defined(ENABLE_RT_TIMING) */ + +#define RT_TIMING_GET_TIME(ts) +#define RT_TIMING_TIME_DIFF(a,b,index) + +#endif /* defined(ENABLE_RT_TIMING) */ + +#endif /* _RT_TIMING_H */ + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/signal.c b/src/vm/signal.c index f11a67bc6..5d83bcc51 100644 --- a/src/vm/signal.c +++ b/src/vm/signal.c @@ -39,16 +39,21 @@ #include "arch.h" -#include "threads/thread.h" +#if defined(ENABLE_GC_BOEHM) +# include "mm/memory.h" +#endif -#include "vm/exceptions.h" -#include "vm/signallocal.h" -#include "vm/vm.h" +#include "threads/thread.hpp" -#include "vmcore/options.h" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/signallocal.h" +#include "vm/vm.hpp" #if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" +# include "vm/statistics.h" #endif @@ -133,7 +138,7 @@ bool signal_init(void) SA_NODEFER | SA_SIGINFO); # endif -# if defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) +# if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) /* XXX use better defines for that (in arch.h) */ /* SIGILL handler */ @@ -185,7 +190,7 @@ bool signal_init(void) #if defined(ENABLE_THREADS) /* SIGHUP handler for threads_thread_interrupt */ - signal_register_signal(SIGHUP, (functionptr) signal_handler_sighup, 0); + signal_register_signal(Signal_INTERRUPT_SYSTEM_CALL, (functionptr) signal_handler_sighup, 0); #endif #if defined(ENABLE_THREADS) && defined(ENABLE_GC_CACAO) @@ -246,6 +251,7 @@ static void signal_thread(void) threadobject *t; sigset_t mask; int sig; + int result; t = THREADOBJECT; @@ -271,14 +277,14 @@ static void signal_thread(void) thread_set_state_waiting(t); #endif - /* XXX We don't check for an error here, although the man-page - states sigwait does not return an error (which is wrong!), - but it seems to make problems with Boehm-GC. We should - revisit this code with our new exact-GC. */ + // sigwait can return EINTR (unlike what the Linux man-page + // says). + do { + result = sigwait(&mask, &sig); + } while (result == EINTR); -/* if (sigwait(&mask, &sig) != 0) */ -/* vm_abort_errno("signal_thread: sigwait failed"); */ - (void) sigwait(&mask, &sig); + if (result != 0) + vm_abort_errnum(result, "signal_thread: sigwait failed"); #if defined(ENABLE_THREADS) thread_set_state_runnable(t); @@ -304,7 +310,7 @@ void signal_thread_handler(int sig) case SIGINT: /* exit the vm properly */ - vm_exit(0); + vm_exit(1); break; case SIGQUIT: @@ -318,6 +324,24 @@ void signal_thread_handler(int sig) statistics_print_memory_usage(); #endif break; + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + default: { + // For OpenJDK we dispatch all unknown signals to Java. + methodinfo* m = class_resolvemethod(class_sun_misc_Signal, utf_dispatch, utf_int__void); + (void) vm_call_method(m, NULL, sig); + + if (exceptions_get_exception()) { + log_println("signal_thread_handler: Java signal handler throw an exception while dispatching signal %d:", sig); + exceptions_print_stacktrace(); + vm_abort("signal_thread_handler: Aborting..."); + } + break; + } +#else + default: + vm_abort("signal_thread_handler: Unknown signal %d", sig); +#endif } } diff --git a/src/vm/signallocal.h b/src/vm/signallocal.h index 7d4e70e38..c94ba4c8d 100644 --- a/src/vm/signallocal.h +++ b/src/vm/signallocal.h @@ -1,9 +1,7 @@ /* src/vm/signallocal.h - machine independent signal functions - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -30,11 +28,26 @@ #include "config.h" +#ifdef __cplusplus +extern "C" { +#endif + #include #include "vm/global.h" +// Signal defines. + +#if defined(__LINUX__) +// See openjdk/jdk/src/solaris/native/java/net/linux_close.c (sigWakeup) +// See openjdk/jdk/src/solaris/native/sun/nio/ch/NativeThread.c (INTERRUPT_SIGNAL) +# define Signal_INTERRUPT_SYSTEM_CALL (__SIGRTMAX - 2) +#else +# define Signal_INTERRUPT_SYSTEM_CALL SIGHUP +#endif + + /* function prototypes ********************************************************/ bool signal_init(void); @@ -51,7 +64,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p); void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p); #endif -#if defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) +#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__S390__) || defined(__X86_64__) || defined(__M68K__) /* XXX use better defines for that (in arch.h) */ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p); #endif @@ -65,6 +78,10 @@ void md_signal_handler_sigusr1(int sig, siginfo_t *siginfo, void *_p); void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p); +#ifdef __cplusplus +} +#endif + #endif /* _CACAO_SIGNAL_H */ diff --git a/src/vm/stackmap.c b/src/vm/stackmap.c new file mode 100644 index 000000000..14ac1f801 --- /dev/null +++ b/src/vm/stackmap.c @@ -0,0 +1,519 @@ +/* src/vm/stackmap.c - class attribute StackMapTable + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" +#include "vm/types.h" + +#include "mm/memory.h" + +#include "vm/class.h" +#include "vm/exceptions.hpp" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/stackmap.h" +#include "vm/statistics.h" +#include "vm/suck.hpp" + + +/* stackmap_get_verification_type_info ***************************************** + + union verification_type_info { + Top_variable_info; + Integer_variable_info; + Float_variable_info; + Long_variable_info; + Double_variable_info; + Null_variable_info; + UninitializedThis_variable_info; + Object_variable_info; + Uninitialized_variable_info; + } + + Top_variable_info { + u1 tag = ITEM_Top; // 0 + } + + Integer_variable_info { + u1 tag = ITEM_Integer; // 1 + } + + Float_variable_info { + u1 tag = ITEM_Float; // 2 + } + + Long_variable_info { + u1 tag = ITEM_Long; // 4 + } + + Double_variable_info { + u1 tag = ITEM_Double; // 3 + } + + Null_variable_info { + u1 tag = ITEM_Null; // 5 + } + + UninitializedThis_variable_info { + u1 tag = ITEM_UninitializedThis; // 6 + } + + Object_variable_info { + u1 tag = ITEM_Object; // 7 + u2 cpool_index; + } + + Uninitialized_variable_info { + u1 tag = ITEM_Uninitialized; // 8 + u2 offset; + } + +*******************************************************************************/ + +static bool stackmap_get_verification_type_info(classbuffer *cb, verification_type_info_t *verification_type_info) +{ + /* get verification type */ + + if (!suck_check_classbuffer_size(cb, 1)) + return false; + + verification_type_info->tag = suck_u1(cb); + + /* process the tag */ + + switch (verification_type_info->tag) { + case ITEM_Top: + case ITEM_Integer: + case ITEM_Float: + case ITEM_Long: + case ITEM_Double: + case ITEM_Null: + case ITEM_UninitializedThis: + break; + + case ITEM_Object: + /* get constant pool index */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + verification_type_info->Object_variable_info.cpool_index = suck_u2(cb); + break; + + case ITEM_Uninitialized: + /* get offset */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + verification_type_info->Uninitialized_variable_info.offset = suck_u2(cb); + break; + } + + return true; +} + + +/* stackmap_get_same_locals_1_stack_item_frame ********************************* + + same_locals_1_stack_item_frame { + u1 frame_type = SAME_LOCALS_1_STACK_ITEM; // 64-127 + verification_type_info stack[1]; + } + +*******************************************************************************/ + +static bool stackmap_get_same_locals_1_stack_item_frame(classbuffer *cb, stack_map_frame_t *stack_map_frame) +{ + same_locals_1_stack_item_frame_t *same_locals_1_stack_item_frame; + + /* for convenience */ + + same_locals_1_stack_item_frame = + &(stack_map_frame->same_locals_1_stack_item_frame); + + if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame->stack[0]))) + return false; + + return true; +} + + +/* stackmap_get_same_locals_1_stack_item_frame_extended ************************ + + same_locals_1_stack_item_frame_extended { + u1 frame_type = SAME_LOCALS_1_STACK_ITEM_EXTENDED; // 247 + u2 offset_delta; + verification_type_info stack[1]; + } + +*******************************************************************************/ + +static bool stackmap_get_same_locals_1_stack_item_frame_extended(classbuffer *cb, stack_map_frame_t *stack_map_frame) +{ + same_locals_1_stack_item_frame_extended_t *same_locals_1_stack_item_frame_extended; + + /* for convenience */ + + same_locals_1_stack_item_frame_extended = + &(stack_map_frame->same_locals_1_stack_item_frame_extended); + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* get offset delta */ + + same_locals_1_stack_item_frame_extended->offset_delta = suck_u2(cb); + + /* process stack */ + + if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame_extended->stack[0]))) + return false; + + return true; +} + + +/* stackmap_get_chop_frame ***************************************************** + + chop_frame { + u1 frame_type = CHOP_FRAME; // 248-250 + u2 offset_delta; + } + +*******************************************************************************/ + +static bool stackmap_get_chop_frame(classbuffer *cb, + stack_map_frame_t *stack_map_frame) +{ + chop_frame_t *chop_frame; + + /* for convenience */ + + chop_frame = &(stack_map_frame->chop_frame); + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* get offset delta */ + + chop_frame->offset_delta = suck_u2(cb); + + return true; +} + + +/* stackmap_get_same_frame_extended ******************************************** + + same_frame_extended { + u1 frame_type = SAME_FRAME_EXTENDED; // 251 + u2 offset_delta; + } + +*******************************************************************************/ + +static bool stackmap_get_same_frame_extended(classbuffer *cb, + stack_map_frame_t *stack_map_frame) +{ + same_frame_extended_t *same_frame_extended; + + /* for convenience */ + + same_frame_extended = &(stack_map_frame->same_frame_extended); + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* get offset delta */ + + same_frame_extended->offset_delta = suck_u2(cb); + + return true; +} + + +/* stackmap_get_append_frame *************************************************** + + append_frame { + u1 frame_type = APPEND_FRAME; // 252-254 + u2 offset_delta; + verification_type_info locals[frame_Type - 251]; + } + +*******************************************************************************/ + +static bool stackmap_get_append_frame(classbuffer *cb, + stack_map_frame_t *stack_map_frame) +{ + append_frame_t *append_frame; + s4 number_of_locals; + s4 i; + + /* for convenience */ + + append_frame = &(stack_map_frame->append_frame); + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + /* get offset delta */ + + append_frame->offset_delta = suck_u2(cb); + + /* allocate locals array */ + + number_of_locals = append_frame->frame_type - 251; + + append_frame->locals = DMNEW(verification_type_info_t, number_of_locals); + + /* process all locals */ + + for (i = 0; i < number_of_locals; i++) + if (!stackmap_get_verification_type_info(cb, &(append_frame->locals[i]))) + return false; + + return true; +} + + +/* stackmap_get_full_frame ***************************************************** + + full_frame { + u1 frame_type = FULL_FRAME; + u2 offset_delta; + u2 number_of_locals; + verification_type_info locals[number_of_locals]; + u2 number_of_stack_items; + verification_type_info stack[number_of_stack_items]; + } + +*******************************************************************************/ + +static bool stackmap_get_full_frame(classbuffer *cb, + stack_map_frame_t *stack_map_frame) +{ + full_frame_t *full_frame; + s4 i; + + /* for convenience */ + + full_frame = &(stack_map_frame->full_frame); + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 2 + 2)) + return false; + + /* get offset delta */ + + stack_map_frame->full_frame.offset_delta = suck_u2(cb); + + /* get number of locals */ + + full_frame->number_of_locals = suck_u2(cb); + + /* allocate locals array */ + + full_frame->locals = + DMNEW(verification_type_info_t, full_frame->number_of_locals); + + /* process all locals */ + + for (i = 0; i < full_frame->number_of_locals; i++) + if (!stackmap_get_verification_type_info(cb, &(full_frame->locals[i]))) + return false; + + /* get number of stack items */ + + if (!suck_check_classbuffer_size(cb, 2)) + return false; + + full_frame->number_of_stack_items = suck_u2(cb); + + /* allocate stack array */ + + full_frame->stack = + DMNEW(verification_type_info_t, full_frame->number_of_stack_items); + + /* process all stack items */ + + for (i = 0; i < full_frame->number_of_stack_items; i++) + if (!stackmap_get_verification_type_info(cb, &(full_frame->stack[i]))) + return false; + + return true; +} + + +/* stackmap_load_attribute_stackmaptable *************************************** + + stack_map { + u2 attribute_name_index; + u4 attribute_length; + u2 number_of_entries; + stack_map_frame entries[number_of_entries]; + } + + union stack_map_frame { + same_frame; + same_locals_1_stack_item_frame; + same_locals_1_stack_item_frame_extended; + chop_frame; + same_frame_extended; + append_frame; + full_frame; + } + + same_frame { + u1 frame_type = SAME; // 0-63 + } + +*******************************************************************************/ + +bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m) +{ + classinfo *c; + stack_map_t *stack_map; + s4 i; + u1 frame_type; + + /* get classinfo */ + + c = cb->clazz; + + /* allocate stack map structure */ + + stack_map = DNEW(stack_map_t); + + STATISTICS(size_stack_map += sizeof(stack_map_t)); + + /* check buffer size */ + + if (!suck_check_classbuffer_size(cb, 4 + 2)) + return false; + + /* attribute_length */ + + stack_map->attribute_length = suck_u4(cb); + + if (!suck_check_classbuffer_size(cb, stack_map->attribute_length)) + return false; + + /* get number of entries */ + + stack_map->number_of_entries = suck_u2(cb); + + /* process all entries */ + + stack_map->entries = DMNEW(stack_map_frame_t, stack_map->number_of_entries); + + for (i = 0; i < stack_map->number_of_entries; i++) { + /* get the frame type */ + + frame_type = suck_u1(cb); + + stack_map->entries[i].frame_type = frame_type; + + /* process frame */ + + if (frame_type <= FRAME_TYPE_SAME) { + /* same_frame */ + } + else if (frame_type <= FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM) { + /* same_locals_1_stack_item_frame */ + + if (!stackmap_get_same_locals_1_stack_item_frame(cb, &(stack_map->entries[i]))) + return false; + } + else if (frame_type <= FRAME_TYPE_RESERVED) { + /* reserved */ + + exceptions_throw_classformaterror(c, "reserved frame type"); + return false; + } + else if (frame_type == FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED) { + /* same_locals_1_stack_item_frame_extended */ + + if (!stackmap_get_same_locals_1_stack_item_frame_extended(cb, &(stack_map->entries[i]))) + return false; + } + else if (frame_type <= FRAME_TYPE_CHOP) { + /* chop_frame */ + + if (!stackmap_get_chop_frame(cb, &(stack_map->entries[i]))) + return false; + } + else if (frame_type == FRAME_TYPE_SAME_FRAME_EXTENDED) { + /* same_frame_extended */ + + if (!stackmap_get_same_frame_extended(cb, &(stack_map->entries[i]))) + return false; + } + else if (frame_type <= FRAME_TYPE_APPEND) { + /* append_frame */ + + if (!stackmap_get_append_frame(cb, &(stack_map->entries[i]))) + return false; + } + else if (frame_type == FRAME_TYPE_FULL_FRAME) { + /* full_frame */ + + if (!stackmap_get_full_frame(cb, &(stack_map->entries[i]))) + return false; + } + } + + /* store stack map in method structure */ + +#if 0 + /* currently not used */ + + m->stack_map = stack_map; +#endif + + return true; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/stackmap.h b/src/vm/stackmap.h new file mode 100644 index 000000000..ff9c5e581 --- /dev/null +++ b/src/vm/stackmap.h @@ -0,0 +1,229 @@ +/* src/vm/stackmap.h - class attribute StackMapTable + + Copyright (C) 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _STACKMAP_H +#define _STACKMAP_H + +/* forward typedefs ***********************************************************/ + +typedef struct stack_map_t stack_map_t; +typedef union stack_map_frame_t stack_map_frame_t; +typedef struct same_locals_1_stack_item_frame_t same_locals_1_stack_item_frame_t; +typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t; +typedef struct chop_frame_t chop_frame_t; +typedef struct same_frame_extended_t same_frame_extended_t; +typedef struct append_frame_t append_frame_t; +typedef struct full_frame_t full_frame_t; + +typedef union verification_type_info_t verification_type_info_t; +typedef struct Top_variable_info_t Top_variable_info_t; +typedef struct Integer_variable_info_t Integer_variable_info_t; +typedef struct Float_variable_info_t Float_variable_info_t; +typedef struct Long_variable_info_t Long_variable_info_t; +typedef struct Double_variable_info_t Double_variable_info_t; +typedef struct Null_variable_info_t Null_variable_info_t; +typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t; +typedef struct Object_variable_info_t Object_variable_info_t; +typedef struct Uninitialized_variable_info_t Uninitialized_variable_info_t; + + +#include "config.h" +#include "vm/types.h" + +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/method.h" + + +/* verification_type_info *****************************************************/ + +#define ITEM_Top 0 +#define ITEM_Integer 1 +#define ITEM_Float 2 +#define ITEM_Double 3 +#define ITEM_Long 4 +#define ITEM_Null 5 +#define ITEM_UninitializedThis 6 +#define ITEM_Object 7 +#define ITEM_Uninitialized 8 + +struct Top_variable_info_t { + u1 tag; +}; + +struct Integer_variable_info_t { + u1 tag; +}; + +struct Float_variable_info_t { + u1 tag; +}; + +struct Long_variable_info_t { + u1 tag; +}; + +struct Double_variable_info_t { + u1 tag; +}; + +struct Null_variable_info_t { + u1 tag; +}; + +struct UninitializedThis_variable_info_t { + u1 tag; +}; + +struct Object_variable_info_t { + u1 tag; + u2 cpool_index; +}; + +struct Uninitialized_variable_info_t { + u1 tag; + u2 offset; +}; + +union verification_type_info_t { + u1 tag; + Top_variable_info_t Top_variable_info; + Integer_variable_info_t Integer_variable_info; + Float_variable_info_t Float_variable_info; + Long_variable_info_t Long_variable_info; + Double_variable_info_t Double_variable_info; + Null_variable_info_t Null_variable_info; + UninitializedThis_variable_info_t UninitializedThis_variable_info; + Object_variable_info_t Object_variable_info; + Uninitialized_variable_info_t Uninitialized_variable_info; +}; + + +/* stack_map_t ****************************************************************/ + +struct stack_map_t { + u2 attribute_name_index; + u4 attribute_length; + u2 number_of_entries; + stack_map_frame_t *entries; +}; + + +/* same_locals_1_stack_item_frame_t *******************************************/ + +struct same_locals_1_stack_item_frame_t { + u1 frame_type; + verification_type_info_t stack[1]; +}; + + +/* same_locals_1_stack_item_frame_extended_t **********************************/ + +struct same_locals_1_stack_item_frame_extended_t { + u1 frame_type; + u2 offset_delta; + verification_type_info_t stack[1]; +}; + + +/* chop_frame_t ***************************************************************/ + +struct chop_frame_t { + u1 frame_type; + u2 offset_delta; +}; + + +/* same_frame_extended_t ******************************************************/ + +struct same_frame_extended_t { + u1 frame_type; + u2 offset_delta; +}; + + +/* append_frame_t *************************************************************/ + +struct append_frame_t { + u1 frame_type; + u2 offset_delta; + verification_type_info_t *locals; +}; + + +/* full_frame_t ***************************************************************/ + +struct full_frame_t { + u1 frame_type; + u2 offset_delta; + u2 number_of_locals; + verification_type_info_t *locals; + u2 number_of_stack_items; + verification_type_info_t *stack; +}; + + +/* stack_map_frame_t **********************************************************/ + +#define FRAME_TYPE_SAME 63 /* 0-63 */ +#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM 127 /* 0-127 */ +#define FRAME_TYPE_RESERVED 246 /* 128-246 */ +#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED 247 /* 247 */ +#define FRAME_TYPE_CHOP 250 /* 248-250 */ +#define FRAME_TYPE_SAME_FRAME_EXTENDED 251 /* 251 */ +#define FRAME_TYPE_APPEND 254 /* 252-254 */ +#define FRAME_TYPE_FULL_FRAME 255 /* 255 */ + +union stack_map_frame_t { + u1 frame_type; + same_locals_1_stack_item_frame_t same_locals_1_stack_item_frame; + same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended; + chop_frame_t chop_frame; + same_frame_extended_t same_frame_extended; + append_frame_t append_frame; + full_frame_t full_frame; +}; + + +/* function prototypes ********************************************************/ + +bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m); + +#endif /* _STACKMAP_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/statistics.c b/src/vm/statistics.c new file mode 100644 index 000000000..878e8b822 --- /dev/null +++ b/src/vm/statistics.c @@ -0,0 +1,818 @@ +/* src/vm/statistics.c - global variables for statistics + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#if defined(HAVE_TIME_H) +# include +#endif + +#if defined(HAVE_SYS_TIME_H) +# include +#endif + +#if defined(HAVE_SYS_RESOURCE_H) +# include +#endif + +#include "vm/types.h" + +#include "mm/gc.hpp" + +#include "toolbox/logging.h" + +#include "vm/class.h" +#include "vm/field.hpp" +#include "vm/global.h" +#include "vm/method.h" +#include "vm/options.h" +#include "vm/statistics.h" + +#include "vm/jit/code.hpp" + + +/* global variables ***********************************************************/ + +static s8 loadingtime = 0; /* accumulated loading time */ +static s8 loadingstarttime = 0; +static s8 loadingstoptime = 0; +static s4 loadingtime_recursion = 0; + +static s8 compilingtime = 0; /* accumulated compile time */ +static s8 compilingstarttime = 0; +static s8 compilingstoptime = 0; +static s4 compilingtime_recursion = 0; + +s4 codememusage = 0; +s4 maxcodememusage = 0; + +s4 memoryusage = 0; +s4 maxmemusage = 0; + +s4 maxdumpsize = 0; + +s4 globalallocateddumpsize = 0; +s4 globaluseddumpsize = 0; + + +/* variables for measurements *************************************************/ + +s4 size_classinfo = 0; +s4 size_fieldinfo = 0; +s4 size_methodinfo = 0; +s4 size_lineinfo = 0; +s4 size_codeinfo = 0; + +s4 size_stub_native = 0; + +s4 size_stack_map = 0; +s4 size_string = 0; + +s4 size_threadobject = 0; +int32_t size_thread_index_t = 0; +int32_t size_stacksize = 0; + +s4 size_lock_record = 0; +s4 size_lock_hashtable = 0; +s4 size_lock_waiter = 0; + +int32_t count_linenumbertable = 0; +int32_t size_linenumbertable = 0; + +s4 size_patchref = 0; + +u8 count_calls_java_to_native = 0; +u8 count_calls_native_to_java = 0; + +int count_const_pool_len = 0; +int count_classref_len = 0; +int count_parsed_desc_len = 0; +int count_vftbl_len = 0; +int count_all_methods = 0; +int count_methods_marked_used = 0; /* RTA */ + +int count_vmcode_len = 0; +int count_extable_len = 0; +int count_class_loads = 0; +int count_class_inits = 0; + +int count_utf_len = 0; /* size of utf hash */ +int count_utf_new = 0; /* calls of utf_new */ +int count_utf_new_found = 0; /* calls of utf_new with fast return */ + +int count_locals_conflicts = 0; /* register allocator statistics */ +int count_locals_spilled = 0; +int count_locals_register = 0; +int count_ss_spilled = 0; +int count_ss_register = 0; +int count_methods_allocated_by_lsra = 0; +int count_mem_move_bb = 0; +int count_interface_size = 0; +int count_argument_mem_ss = 0; +int count_argument_reg_ss = 0; +int count_method_in_register = 0; +int count_mov_reg_reg = 0; +int count_mov_mem_reg = 0; +int count_mov_reg_mem = 0; +int count_mov_mem_mem = 0; + +int count_jit_calls = 0; +int count_methods = 0; +int count_spills_read_ila = 0; +int count_spills_read_flt = 0; +int count_spills_read_dbl = 0; +int count_spills_write_ila = 0; +int count_spills_write_flt = 0; +int count_spills_write_dbl = 0; +int count_pcmd_activ = 0; +int count_pcmd_drop = 0; +int count_pcmd_zero = 0; +int count_pcmd_const_store = 0; +int count_pcmd_const_alu = 0; +int count_pcmd_const_bra = 0; +int count_pcmd_load = 0; +int count_pcmd_move = 0; +int count_load_instruction = 0; +int count_pcmd_store = 0; +int count_pcmd_store_comb = 0; +int count_dup_instruction = 0; +int count_pcmd_op = 0; +int count_pcmd_mem = 0; +int count_pcmd_met = 0; +int count_pcmd_bra = 0; +int count_pcmd_table = 0; +int count_pcmd_return = 0; +int count_pcmd_returnx = 0; +int count_check_null = 0; +int count_check_bound = 0; +int count_max_basic_blocks = 0; +int count_basic_blocks = 0; +int count_javainstr = 0; +int count_max_javainstr = 0; +int count_javacodesize = 0; +int count_javaexcsize = 0; +int count_calls = 0; +int count_tryblocks = 0; +int count_code_len = 0; +int count_data_len = 0; +int count_cstub_len = 0; +int count_max_new_stack = 0; +int count_upper_bound_new_stack = 0; + +int count_emit_branch = 0; +int count_emit_branch_8bit = 0; +int count_emit_branch_16bit = 0; +int count_emit_branch_32bit = 0; +int count_emit_branch_64bit = 0; + +s4 count_branches_resolved = 0; +s4 count_branches_unresolved = 0; + +u8 count_jni_callXmethod_calls=0; +u8 count_jni_calls=0; + + +static int count_block_stack_init[11] = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0 +}; +int *count_block_stack = count_block_stack_init; +static int count_analyse_iterations_init[5] = { + 0, 0, 0, 0, 0 +}; +int *count_analyse_iterations = count_analyse_iterations_init; +static int count_method_bb_distribution_init[9] = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0 +}; +int *count_method_bb_distribution = count_method_bb_distribution_init; +static int count_block_size_distribution_init[18] = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0 +}; +int *count_block_size_distribution = count_block_size_distribution_init; +static int count_store_length_init[21] = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0 +}; +int *count_store_length = count_store_length_init; +static int count_store_depth_init[11] = { + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0 +}; +int *count_store_depth = count_store_depth_init; + + +/* instruction scheduler statistics *******************************************/ + +s4 count_schedule_basic_blocks = 0; +s4 count_schedule_nodes = 0; +s4 count_schedule_leaders = 0; +s4 count_schedule_max_leaders = 0; +s4 count_schedule_critical_path = 0; + + +/* jnicallXmethodinvokation *************************************************** + + increments the jni CallXMethod invokation count by one + +*******************************************************************************/ + +void jnicallXmethodnvokation(void) +{ + /* XXX do locking here */ + count_jni_callXmethod_calls++; +} + + +/* jniinvokation ************************************************************* + + increments the jni overall invokation count by one + +*******************************************************************************/ + +void jniinvokation(void) +{ + /* XXX do locking here */ + count_jni_calls++; +} + + +/* getcputime *********************************** ****************************** + + Returns the used CPU time in microseconds + +*******************************************************************************/ + +s8 getcputime(void) +{ +#if defined(HAVE_GETRUSAGE) + struct rusage ru; + int sec, usec; + + getrusage(RUSAGE_SELF, &ru); + + sec = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec; + usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec; + + return sec * 1000000 + usec; +#else + /* If we don't have getrusage, simply return 0. */ + + return 0; +#endif +} + + +/* loadingtime_stop ************************************************************ + + XXX + +*******************************************************************************/ + +void loadingtime_start(void) +{ + loadingtime_recursion++; + + if (loadingtime_recursion == 1) + loadingstarttime = getcputime(); +} + + +/* loadingtime_stop ************************************************************ + + XXX + +*******************************************************************************/ + +void loadingtime_stop(void) +{ + if (loadingtime_recursion == 1) { + loadingstoptime = getcputime(); + loadingtime += (loadingstoptime - loadingstarttime); + } + + loadingtime_recursion--; +} + + +/* compilingtime_stop ********************************************************** + + XXX + +*******************************************************************************/ + +void compilingtime_start(void) +{ + compilingtime_recursion++; + + if (compilingtime_recursion == 1) + compilingstarttime = getcputime(); +} + + +/* compilingtime_stop ********************************************************** + + XXX + +*******************************************************************************/ + +void compilingtime_stop(void) +{ + if (compilingtime_recursion == 1) { + compilingstoptime = getcputime(); + compilingtime += (compilingstoptime - compilingstarttime); + } + + compilingtime_recursion--; +} + + +/* print_times ***************************************************************** + + Prints a summary of CPU time usage. + +*******************************************************************************/ + +void print_times(void) +{ + s8 totaltime; + s8 runtime; + + totaltime = getcputime(); + runtime = totaltime - loadingtime - compilingtime; + +#if SIZEOF_VOID_P == 8 + dolog("Time for loading classes: %6ld ms", loadingtime / 1000); + dolog("Time for compiling code: %6ld ms", compilingtime / 1000); + dolog("Time for running program: %6ld ms", runtime / 1000); + dolog("Total time: %6ld ms", totaltime / 1000); +#else + dolog("Time for loading classes: %6lld ms", loadingtime / 1000); + dolog("Time for compiling code: %6lld ms", compilingtime / 1000); + dolog("Time for running program: %6lld ms", runtime / 1000); + dolog("Total time: %6lld ms", totaltime / 1000); +#endif +} + + +/* print_stats ***************************************************************** + + outputs detailed compiler statistics + +*******************************************************************************/ + +void print_stats(void) +{ + s4 i; + float f; + s4 sum; + + + dolog("Number of JIT compiler calls: %6d", count_jit_calls); + dolog("Number of compiled methods: %6d", count_methods); + + dolog("Number of compiled basic blocks: %6d", + count_basic_blocks); + dolog("Number of max. basic blocks per method: %6d", + count_max_basic_blocks); + + dolog("Number of compiled JavaVM instructions: %6d", + count_javainstr); + dolog("Number of max. JavaVM instructions per method: %6d", + count_max_javainstr); + dolog("Size of compiled JavaVM instructions: %6d(%d)", + count_javacodesize, count_javacodesize - count_methods * 18); + + dolog("Size of compiled Exception Tables: %d", count_javaexcsize); + dolog("Number of Machine-Instructions: %d", count_code_len >> 2); + dolog("Number of Spills (write to memory) : %d [%d|%d|%d]", + count_spills_write_ila + count_spills_write_flt + count_spills_write_dbl, + count_spills_write_ila, count_spills_write_flt, count_spills_write_dbl); + dolog("Number of Spills (read from memory) : %d [%d|%d|%d]", + count_spills_read_ila + count_spills_read_flt + count_spills_read_dbl, + count_spills_read_ila, count_spills_read_flt, count_spills_read_dbl); + dolog("Number of Activ Pseudocommands: %6d", count_pcmd_activ); + dolog("Number of Drop Pseudocommands: %6d", count_pcmd_drop); + dolog("Number of Const Pseudocommands: %6d (zero:%5d)", + count_pcmd_load, count_pcmd_zero); + dolog("Number of ConstAlu Pseudocommands: %6d (cmp: %5d, store:%5d)", + count_pcmd_const_alu, count_pcmd_const_bra, count_pcmd_const_store); + dolog("Number of Move Pseudocommands: %6d", count_pcmd_move); + dolog("Number of Load Pseudocommands: %6d", count_load_instruction); + dolog("Number of Store Pseudocommands: %6d (combined: %5d)", + count_pcmd_store, count_pcmd_store - count_pcmd_store_comb); + dolog("Number of OP Pseudocommands: %6d", count_pcmd_op); + dolog("Number of DUP Pseudocommands: %6d", count_dup_instruction); + dolog("Number of Mem Pseudocommands: %6d", count_pcmd_mem); + dolog("Number of Method Pseudocommands: %6d", count_pcmd_met); + dolog("Number of Branch Pseudocommands: %6d (rets:%5d, Xrets: %5d)", + count_pcmd_bra, count_pcmd_return, count_pcmd_returnx); + log_println(" resolved branches: %6d", count_branches_resolved); + log_println(" unresolved branches: %6d", count_branches_unresolved); + dolog("Number of Table Pseudocommands: %6d", count_pcmd_table); + dolog("Number of Useful Pseudocommands: %6d", count_pcmd_table + + count_pcmd_bra + count_pcmd_load + count_pcmd_mem + count_pcmd_op); + dolog("Number of Null Pointer Checks: %6d", count_check_null); + dolog("Number of Array Bound Checks: %6d", count_check_bound); + dolog("Number of Try-Blocks: %d", count_tryblocks); + + dolog("Number of branch_emit (total, 8bit/16bit/32bit/64bit offset): %d, %d/%d/%d/%d", + count_emit_branch, count_emit_branch_8bit, count_emit_branch_16bit, + count_emit_branch_32bit, count_emit_branch_64bit); + + dolog("Maximal count of stack elements: %d", count_max_new_stack); + dolog("Upper bound of max stack elements: %d", count_upper_bound_new_stack); + dolog("Distribution of stack sizes at block boundary"); + dolog(" 0 1 2 3 4 5 6 7 8 9 >=10"); + dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", + count_block_stack[0], count_block_stack[1], count_block_stack[2], + count_block_stack[3], count_block_stack[4], count_block_stack[5], + count_block_stack[6], count_block_stack[7], count_block_stack[8], + count_block_stack[9], count_block_stack[10]); + dolog("Distribution of store stack depth"); + dolog(" 0 1 2 3 4 5 6 7 8 9 >=10"); + dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", + count_store_depth[0], count_store_depth[1], count_store_depth[2], + count_store_depth[3], count_store_depth[4], count_store_depth[5], + count_store_depth[6], count_store_depth[7], count_store_depth[8], + count_store_depth[9], count_store_depth[10]); + dolog("Distribution of store creator chains first part"); + dolog(" 0 1 2 3 4 5 6 7 8 9"); + dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", + count_store_length[0], count_store_length[1], count_store_length[2], + count_store_length[3], count_store_length[4], count_store_length[5], + count_store_length[6], count_store_length[7], count_store_length[8], + count_store_length[9]); + dolog("Distribution of store creator chains second part"); + dolog(" 10 11 12 13 14 15 16 17 18 19 >=20"); + dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", + count_store_length[10], count_store_length[11], + count_store_length[12], count_store_length[13], + count_store_length[14], count_store_length[15], + count_store_length[16], count_store_length[17], + count_store_length[18], count_store_length[19], + count_store_length[20]); + dolog("Distribution of analysis iterations"); + dolog(" 1 2 3 4 >=5"); + dolog("%6d%6d%6d%6d%6d", + count_analyse_iterations[0], count_analyse_iterations[1], + count_analyse_iterations[2], count_analyse_iterations[3], + count_analyse_iterations[4]); + + + /* Distribution of basic blocks per method ********************************/ + + log_println("Distribution of basic blocks per method:"); + log_println(" <=5 <=10 <=15 <=20 <=30 <=40 <=50 <=75 >75"); + + log_start(); + for (i = 0; i <= 8; i++) + log_print("%6d", count_method_bb_distribution[i]); + log_finish(); + + /* print ratio */ + + f = (float) count_methods; + + log_start(); + for (i = 0; i <= 8; i++) + log_print("%6.2f", (float) count_method_bb_distribution[i] / f); + log_finish(); + + /* print cumulated ratio */ + + log_start(); + for (i = 0, sum = 0; i <= 8; i++) { + sum += count_method_bb_distribution[i]; + log_print("%6.2f", (float) sum / f); + } + log_finish(); + + + /* Distribution of basic block sizes **************************************/ + + log_println("Distribution of basic block sizes:"); + log_println(" 0 1 2 3 4 5 6 7 8 9 <13 <15 <17 <19 <21 <26 <31 >30"); + + /* print block sizes */ + + log_start(); + for (i = 0; i <= 17; i++) + log_print("%6d", count_block_size_distribution[i]); + log_finish(); + + /* print ratio */ + + f = (float) count_basic_blocks; + + log_start(); + for (i = 0; i <= 17; i++) + log_print("%6.2f", (float) count_block_size_distribution[i] / f); + log_finish(); + + /* print cumulated ratio */ + + log_start(); + for (i = 0, sum = 0; i <= 17; i++) { + sum += count_block_size_distribution[i]; + log_print("%6.2f", (float) sum / f); + } + log_finish(); + + statistics_print_memory_usage(); + + dolog("Number of class loads: %6d", count_class_loads); + dolog("Number of class inits: %6d", count_class_inits); + dolog("Number of loaded Methods: %6d\n", count_all_methods); + + dolog("Calls of utf_new: %6d", count_utf_new); + dolog("Calls of utf_new (element found): %6d\n", count_utf_new_found); + + + /* LSRA statistics ********************************************************/ + + dolog("Moves reg -> reg: %6d", count_mov_reg_reg); + dolog("Moves mem -> reg: %6d", count_mov_mem_reg); + dolog("Moves reg -> mem: %6d", count_mov_reg_mem); + dolog("Moves mem -> mem: %6d", count_mov_mem_mem); + + dolog("Methods allocated by LSRA: %6d", + count_methods_allocated_by_lsra); + dolog("Conflicts between local Variables: %6d", count_locals_conflicts); + dolog("Local Variables held in Memory: %6d", count_locals_spilled); + dolog("Local Variables held in Registers: %6d", count_locals_register); + dolog("Stackslots held in Memory: %6d", count_ss_spilled); + dolog("Stackslots held in Registers: %6d", count_ss_register); + dolog("Memory moves at BB Boundaries: %6d", count_mem_move_bb); + dolog("Number of interface slots: %6d\n", count_interface_size); + dolog("Number of Argument stack slots in register: %6d", + count_argument_reg_ss); + dolog("Number of Argument stack slots in memory: %6d\n", + count_argument_mem_ss); + dolog("Number of Methods kept in registers: %6d\n", + count_method_in_register); + + + /* instruction scheduler statistics ***************************************/ + +#if defined(USE_SCHEDULER) + dolog("Instruction scheduler statistics:"); + dolog("Number of basic blocks: %7d", count_schedule_basic_blocks); + dolog("Number of nodes: %7d", count_schedule_nodes); + dolog("Number of leaders nodes: %7d", count_schedule_leaders); + dolog("Number of max. leaders nodes: %7d", count_schedule_max_leaders); + dolog("Length of critical path: %7d\n", count_schedule_critical_path); +#endif + + + /* call statistics ********************************************************/ + + dolog("Function call statistics:"); + dolog("Number of jni->CallXMethod function invokations: %ld", + count_jni_callXmethod_calls); + dolog("Overall number of jni invokations: %ld", + count_jni_calls); + + log_println("java-to-native calls: %10ld", count_calls_java_to_native); + log_println("native-to-java calls: %10ld", count_calls_native_to_java); + + + /* now print other statistics ********************************************/ + +#if defined(ENABLE_INTRP) + print_dynamic_super_statistics(); +#endif +} + + +/* statistics_print_date ******************************************************* + + Print current date and time. + +*******************************************************************************/ + +void statistics_print_date(void) +{ + time_t t; + struct tm tm; + +#if defined(HAVE_TIME) + time(&t); +#else +# error !HAVE_TIME +#endif + +#if defined(HAVE_LOCALTIME_R) + localtime_r(&t, &tm); +#else +# error !HAVE_LOCALTIME_R +#endif + + log_println("%d-%02d-%02d %02d:%02d:%02d", + 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec); +} + + +/* statistics_print_memory_usage *********************************************** + + Print current memory usage. + +*******************************************************************************/ + +void statistics_print_memory_usage(void) +{ + s4 sum; + + log_println("memory usage ----------------------"); + log_println(""); + log_println("code: %10d", count_code_len); + log_println("data: %10d", count_data_len); + log_println(" ----------"); + + sum = + count_code_len + + count_data_len; + + log_println(" %10d", sum); + + log_println(""); + + log_println("classinfo (%3d B): %10d", (int) sizeof(classinfo), size_classinfo); + log_println("fieldinfo (%3d B): %10d", (int) sizeof(fieldinfo), size_fieldinfo); + log_println("methodinfo (%3d B): %10d", (int) sizeof(methodinfo), size_methodinfo); + log_println("lineinfo (%3d B): %10d", (int) sizeof(lineinfo), size_lineinfo); + log_println("codeinfo (%3d B): %10d", (int) sizeof(codeinfo), size_codeinfo); + log_println(" ----------"); + + sum = + size_classinfo + + size_fieldinfo + + size_methodinfo + + size_lineinfo + + size_codeinfo; + + log_println(" %10d", sum); + + log_println(""); + + log_println("linenumber tables (%5d): %10d", count_linenumbertable, size_linenumbertable); + log_println("exception tables: %10d", count_extable_len); + log_println("patcher references: %10d", size_patchref); + log_println(" ----------"); + + sum = + size_linenumbertable + + count_extable_len + + size_patchref; + + log_println(" %10d", sum); + + log_println(""); + + log_println("constant pool: %10d", count_const_pool_len); + log_println("classref: %10d", count_classref_len); + log_println("parsed descriptors: %10d", count_parsed_desc_len); + log_println("vftbl: %10d", count_vftbl_len); + log_println("compiler stubs: %10d", count_cstub_len); + log_println("native stubs: %10d", size_stub_native); + log_println("utf: %10d", count_utf_len); + log_println("vmcode: %10d", count_vmcode_len); + log_println("stack map: %10d", size_stack_map); + log_println("string: %10d", size_string); + log_println("threadobject: %10d", size_threadobject); + log_println("thread index: %10d", size_thread_index_t); + log_println("stack size: %10d", size_stacksize); + log_println("lock record: %10d", size_lock_record); + log_println("lock hashtable: %10d", size_lock_hashtable); + log_println("lock waiter: %10d", size_lock_waiter); + log_println(" ----------"); + + sum = + count_const_pool_len + + count_classref_len + + count_parsed_desc_len + + count_vftbl_len + + count_cstub_len + + size_stub_native + + count_utf_len + + count_vmcode_len + + size_stack_map + + size_string + + size_threadobject + + size_thread_index_t + + size_stacksize + + size_lock_record + + size_lock_hashtable + + size_lock_waiter; + + log_println(" %10d", sum); + + log_println(""); + + log_println("max. code memory: %10d", maxcodememusage); + log_println("max. heap memory: %10d", maxmemusage); + log_println("max. dump memory: %10d", maxdumpsize); + log_println(""); + log_println("heap memory not freed: %10d", (int32_t) memoryusage); + log_println("dump memory not freed: %10d", (int32_t) globalallocateddumpsize); + + log_println(""); +} + + +/* statistics_print_gc_memory_usage ******************************************** + + Print current GC memory usage. + +*******************************************************************************/ + +void statistics_print_gc_memory_usage(void) +{ + static int64_t count = 0; + int64_t max; + int64_t size; + int64_t free; + int64_t used; + int64_t total; + + count++; + + max = gc_get_max_heap_size(); + size = gc_get_heap_size(); + free = gc_get_free_bytes(); + used = size - free; + total = gc_get_total_bytes(); + + if (opt_ProfileMemoryUsageGNUPlot) { + if (count == 1) + fprintf(opt_ProfileMemoryUsageGNUPlot, "plot \"profile.dat\" using 1:2 with lines title \"max. Java heap size\", \"profile.dat\" using 1:3 with lines title \"Java heap size\", \"profile.dat\" using 1:4 with lines title \"used\", \"profile.dat\" using 1:5 with lines title \"free\"\n"); + +#if SIZEOF_VOID_P == 8 + fprintf(opt_ProfileMemoryUsageGNUPlot, "%ld %ld %ld %ld %ld\n", count, max, size, used, free); +#else + fprintf(opt_ProfileMemoryUsageGNUPlot, "%lld %lld %lld %lld %lld\n", count, max, size, used, free); +#endif + + fflush(opt_ProfileMemoryUsageGNUPlot); + } + else { + log_println("GC memory usage -------------------"); + log_println(""); + log_println("max. Java heap size: %10lld", max); + log_println(""); + log_println("Java heap size: %10lld", size); + log_println("used: %10lld", used); + log_println("free: %10lld", free); + log_println("totally used: %10lld", total); + log_println(""); + } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/statistics.h b/src/vm/statistics.h new file mode 100644 index 000000000..484fba15c --- /dev/null +++ b/src/vm/statistics.h @@ -0,0 +1,274 @@ +/* src/vm/statistics.h - exports global varables for statistics + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _STATISTICS_H +#define _STATISTICS_H + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "vm/global.h" + + +/* statistic macros ***********************************************************/ + +#if defined(ENABLE_STATISTICS) +#define STATISTICS(x) \ + do { \ + if (opt_stat) { \ + x; \ + } \ + } while (0) +#else +#define STATISTICS(x) /* nothing */ +#endif + +/* in_ inline statistics */ + +#define IN_MAX 9 +#define IN_UNIQUEVIRT 0x0000 +#define IN_UNIQUE_INTERFACE 0x0001 +#define IN_OUTSIDERS 0x0004 +#define IN_MAXDEPTH 0x0008 +#define IN_MAXCODE 0x0010 +#define IN_JCODELENGTH 0x0020 +#define IN_EXCEPTION 0x0040 +#define IN_NOT_UNIQUE_VIRT 0x0080 +#define IN_NOT_UNIQUE_INTERFACE 0x0100 + +#define N_UNIQUEVIRT 0 +#define N_UNIQUE_INTERFACE 1 +#define N_OUTSIDERS 2 +#define N_MAXDEPTH 3 +#define N_MAXCODE 4 +#define N_JCODELENGTH 5 +#define N_EXCEPTION 6 +#define N_NOT_UNIQUE_VIRT 7 +#define N_NOT_UNIQUE_INTERFACE 8 + + +/* global variables ***********************************************************/ + +extern s4 codememusage; +extern s4 maxcodememusage; + +extern s4 memoryusage; +extern s4 maxmemusage; + +extern s4 maxdumpsize; + +extern s4 globalallocateddumpsize; +extern s4 globaluseddumpsize; + + +/* variables for measurements *************************************************/ + +extern s4 size_classinfo; +extern s4 size_fieldinfo; +extern s4 size_methodinfo; +extern s4 size_lineinfo; +extern s4 size_codeinfo; + +extern s4 size_stub_native; + +extern s4 size_stack_map; +extern s4 size_string; + +extern s4 size_threadobject; +extern int32_t size_thread_index_t; +extern int32_t size_stacksize; + +extern s4 size_lock_record; +extern s4 size_lock_hashtable; +extern s4 size_lock_waiter; + +extern int32_t count_linenumbertable; +extern int32_t size_linenumbertable; + +extern s4 size_patchref; + +extern u8 count_calls_java_to_native; +extern u8 count_calls_native_to_java; + +extern int count_const_pool_len; +extern int count_classref_len; +extern int count_parsed_desc_len; +extern int count_vftbl_len; +extern int count_all_methods; +extern int count_methods_marked_used; /*RTA*/ +extern int count_vmcode_len; +extern int count_extable_len; +extern int count_class_loads; +extern int count_class_inits; + +extern int count_utf_len; /* size of utf hash */ +extern int count_utf_new; +extern int count_utf_new_found; + +extern int count_locals_conflicts; +extern int count_locals_spilled; +extern int count_locals_register; +extern int count_ss_spilled; +extern int count_ss_register; +extern int count_methods_allocated_by_lsra; +extern int count_mem_move_bb; +extern int count_interface_size; +extern int count_argument_mem_ss; +extern int count_argument_reg_ss; +extern int count_method_in_register; +extern int count_mov_reg_reg; +extern int count_mov_mem_reg; +extern int count_mov_reg_mem; +extern int count_mov_mem_mem; + +extern int count_jit_calls; +extern int count_methods; +extern int count_spills_read_ila; +extern int count_spills_read_flt; +extern int count_spills_read_dbl; +extern int count_spills_write_ila; +extern int count_spills_write_flt; +extern int count_spills_write_dbl; +extern int count_pcmd_activ; +extern int count_pcmd_drop; +extern int count_pcmd_zero; +extern int count_pcmd_const_store; +extern int count_pcmd_const_alu; +extern int count_pcmd_const_bra; +extern int count_pcmd_load; +extern int count_pcmd_move; +extern int count_load_instruction; +extern int count_pcmd_store; +extern int count_pcmd_store_comb; +extern int count_dup_instruction; +extern int count_pcmd_op; +extern int count_pcmd_mem; +extern int count_pcmd_met; +extern int count_pcmd_bra; +extern int count_pcmd_table; +extern int count_pcmd_return; +extern int count_pcmd_returnx; +extern int count_check_null; +extern int count_check_bound; +extern int count_max_basic_blocks; +extern int count_basic_blocks; +extern int count_max_javainstr; +extern int count_javainstr; +extern int count_javacodesize; +extern int count_javaexcsize; +extern int count_calls; +extern int count_tryblocks; +extern int count_code_len; +extern int count_data_len; +extern int count_cstub_len; +extern int count_max_new_stack; +extern int count_upper_bound_new_stack; + +extern int count_emit_branch; +extern int count_emit_branch_8bit; +extern int count_emit_branch_16bit; +extern int count_emit_branch_32bit; +extern int count_emit_branch_64bit; + +extern s4 count_branches_resolved; +extern s4 count_branches_unresolved; + +extern int *count_block_stack; +extern int *count_analyse_iterations; +extern int *count_method_bb_distribution; +extern int *count_block_size_distribution; +extern int *count_store_length; +extern int *count_store_depth; + /* in_ inline statistics */ +extern int count_in; +extern int count_in_uniqVirt; +extern int count_in_uniqIntf; +extern int count_in_rejected; +extern int count_in_rejected_mult; +extern int count_in_outsiders; +extern int count_in_uniqueVirt_not_inlined; +extern int count_in_uniqueInterface_not_inlined; +extern int count_in_maxDepth; +extern int count_in_maxMethods; + +extern u2 count_in_not [512]; + +/* instruction scheduler statistics *******************************************/ + +extern s4 count_schedule_basic_blocks; +extern s4 count_schedule_nodes; +extern s4 count_schedule_leaders; +extern s4 count_schedule_max_leaders; +extern s4 count_schedule_critical_path; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +s8 getcputime(void); + +void loadingtime_start(void); +void loadingtime_stop(void); +void compilingtime_start(void); +void compilingtime_stop(void); + +void print_times(void); +void print_stats(void); + +void statistics_print_date(void); +void statistics_print_memory_usage(void); +void statistics_print_gc_memory_usage(void); + +void mem_usagelog(bool givewarnings); + +void compiledinvokation(void); +void jnicallXmethodnvokation(void); +void jniinvokation(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _STATISTICS_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/string.c b/src/vm/string.c deleted file mode 100644 index f24e411e0..000000000 --- a/src/vm/string.c +++ /dev/null @@ -1,805 +0,0 @@ -/* src/vm/string.c - java.lang.String related functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vmcore/system.h" - -#include "vm/types.h" - -#include "vm/global.h" - -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" - -#include "native/include/java_lang_String.h" - -#include "threads/lock-common.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/options.h" -#include "vmcore/statistics.h" -#include "vmcore/utf8.h" - - -/* global variables ***********************************************************/ - -/* hashsize must be power of 2 */ - -#define HASHTABLE_STRING_SIZE 2048 /* initial size of javastring-hash */ - -hashtable hashtable_string; /* hashtable for javastrings */ - -#if defined(ENABLE_THREADS) -static java_object_t *lock_hashtable_string; -#endif - - -/* XXX preliminary typedef, will be removed once string.c and utf8.c are - unified. */ - -#if defined(ENABLE_HANDLES) -typedef heap_java_lang_String heapstring_t; -#else -typedef java_lang_String heapstring_t; -#endif - - -/* string_init ***************************************************************** - - Initialize the string hashtable lock. - -*******************************************************************************/ - -bool string_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("string_init"); - - /* create string (javastring) hashtable */ - - hashtable_create(&hashtable_string, HASHTABLE_STRING_SIZE); - -#if defined(ENABLE_THREADS) - /* create string hashtable lock object */ - - lock_hashtable_string = NEW(java_object_t); - - LOCK_INIT_OBJECT_LOCK(lock_hashtable_string); -#endif - - /* everything's ok */ - - return true; -} - - -/* stringtable_update ********************************************************** - - Traverses the javastring hashtable and sets the vftbl-entries of - javastrings which were temporarily set to NULL, because - java.lang.Object was not yet loaded. - -*******************************************************************************/ - -void stringtable_update(void) -{ - heapstring_t *js; - java_chararray_t *a; - literalstring *s; /* hashtable entry */ - int i; - - for (i = 0; i < hashtable_string.size; i++) { - s = hashtable_string.ptr[i]; - if (s) { - while (s) { - js = (heapstring_t *) s->string; - - if ((js == NULL) || (js->value == NULL)) { - /* error in hashtable found */ - - vm_abort("stringtable_update: invalid literalstring in hashtable"); - } - - a = js->value; - - if (!js->header.vftbl) - /* vftbl of javastring is NULL */ - js->header.vftbl = class_java_lang_String->vftbl; - - if (!a->header.objheader.vftbl) - /* vftbl of character-array is NULL */ - a->header.objheader.vftbl = - primitive_arrayclass_get_by_type(ARRAYTYPE_CHAR)->vftbl; - - /* follow link in external hash chain */ - s = s->hashlink; - } - } - } -} - - -/* javastring_new_from_utf_buffer ********************************************** - - Create a new object of type java/lang/String with the text from - the specified utf8 buffer. - - IN: - buffer.......points to first char in the buffer - blength......number of bytes to read from the buffer - - RETURN VALUE: - the java.lang.String object, or - NULL if an exception has been thrown - -*******************************************************************************/ - -static java_handle_t *javastring_new_from_utf_buffer(const char *buffer, - u4 blength) -{ - const char *utf_ptr; /* current utf character in utf string */ - u4 utflength; /* length of utf-string if uncompressed */ - java_handle_t *o; - java_lang_String *s; /* result-string */ - java_handle_chararray_t *a; - u4 i; - - assert(buffer); - - utflength = utf_get_number_of_u2s_for_buffer(buffer,blength); - - o = builtin_new(class_java_lang_String); - a = builtin_newarray_char(utflength); - - /* javastring or character-array could not be created */ - - if ((o == NULL) || (a == NULL)) - return NULL; - - /* decompress utf-string */ - - utf_ptr = buffer; - - for (i = 0; i < utflength; i++) - LLNI_array_direct(a, i) = utf_nextu2((char **) &utf_ptr); - - /* set fields of the javastring-object */ - - s = (java_lang_String *) o; - - LLNI_field_set_ref(s, value , a); - LLNI_field_set_val(s, offset, 0); - LLNI_field_set_val(s, count , utflength); - - return o; -} - - -/* javastring_safe_new_from_utf8 *********************************************** - - Create a new object of type java/lang/String with the text from - the specified UTF-8 string. This function is safe for invalid UTF-8. - (Invalid characters will be replaced by U+fffd.) - - IN: - text.........the UTF-8 string, zero-terminated. - - RETURN VALUE: - the java.lang.String object, or - NULL if an exception has been thrown - -*******************************************************************************/ - -java_handle_t *javastring_safe_new_from_utf8(const char *text) -{ - java_handle_t *o; - java_handle_chararray_t *a; - java_lang_String *s; - s4 nbytes; - s4 len; - - if (text == NULL) - return NULL; - - /* Get number of bytes. We need this to completely emulate the messy */ - /* behaviour of the RI. :( */ - - nbytes = strlen(text); - - /* calculate number of Java characters */ - - len = utf8_safe_number_of_u2s(text, nbytes); - - /* allocate the String object and the char array */ - - o = builtin_new(class_java_lang_String); - a = builtin_newarray_char(len); - - /* javastring or character-array could not be created? */ - - if ((o == NULL) || (a == NULL)) - return NULL; - - /* decompress UTF-8 string */ - - utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(a)); - - /* set fields of the String object */ - - s = (java_lang_String *) o; - - LLNI_field_set_ref(s, value , a); - LLNI_field_set_val(s, offset, 0); - LLNI_field_set_val(s, count , len); - - return o; -} - - -/* javastring_new_from_utf_string ********************************************** - - Create a new object of type java/lang/String with the text from - the specified zero-terminated utf8 string. - - IN: - buffer.......points to first char in the buffer - blength......number of bytes to read from the buffer - - RETURN VALUE: - the java.lang.String object, or - NULL if an exception has been thrown - -*******************************************************************************/ - -java_handle_t *javastring_new_from_utf_string(const char *utfstr) -{ - assert(utfstr); - - return javastring_new_from_utf_buffer(utfstr, strlen(utfstr)); -} - - -/* javastring_new ************************************************************** - - creates a new object of type java/lang/String with the text of - the specified utf8-string - - return: pointer to the string or NULL if memory is exhausted. - -*******************************************************************************/ - -java_handle_t *javastring_new(utf *u) -{ - char *utf_ptr; /* current utf character in utf string */ - u4 utflength; /* length of utf-string if uncompressed */ - java_handle_t *o; - java_handle_chararray_t *a; - java_lang_String *s; - s4 i; - - if (u == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - utf_ptr = u->text; - utflength = utf_get_number_of_u2s(u); - - o = builtin_new(class_java_lang_String); - a = builtin_newarray_char(utflength); - - /* javastring or character-array could not be created */ - - if ((o == NULL) || (a == NULL)) - return NULL; - - /* decompress utf-string */ - - for (i = 0; i < utflength; i++) - LLNI_array_direct(a, i) = utf_nextu2(&utf_ptr); - - /* set fields of the javastring-object */ - - s = (java_lang_String *) o; - - LLNI_field_set_ref(s, value , a); - LLNI_field_set_val(s, offset, 0); - LLNI_field_set_val(s, count , utflength); - - return o; -} - - -/* javastring_new_slash_to_dot ************************************************* - - creates a new object of type java/lang/String with the text of - the specified utf8-string with slashes changed to dots - - return: pointer to the string or NULL if memory is exhausted. - -*******************************************************************************/ - -java_handle_t *javastring_new_slash_to_dot(utf *u) -{ - char *utf_ptr; /* current utf character in utf string */ - u4 utflength; /* length of utf-string if uncompressed */ - java_handle_t *o; - java_handle_chararray_t *a; - java_lang_String *s; - s4 i; - u2 ch; - - if (u == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - utf_ptr = u->text; - utflength = utf_get_number_of_u2s(u); - - o = builtin_new(class_java_lang_String); - a = builtin_newarray_char(utflength); - - /* javastring or character-array could not be created */ - if ((o == NULL) || (a == NULL)) - return NULL; - - /* decompress utf-string */ - - for (i = 0; i < utflength; i++) { - ch = utf_nextu2(&utf_ptr); - if (ch == '/') - ch = '.'; - LLNI_array_direct(a, i) = ch; - } - - /* set fields of the javastring-object */ - - s = (java_lang_String *) o; - - LLNI_field_set_ref(s, value , a); - LLNI_field_set_val(s, offset, 0); - LLNI_field_set_val(s, count , utflength); - - return o; -} - - -/* javastring_new_from_ascii *************************************************** - - creates a new java/lang/String object which contains the given ASCII - C-string converted to UTF-16. - - IN: - text.........string of ASCII characters - - RETURN VALUE: - the java.lang.String object, or - NULL if an exception has been thrown. - -*******************************************************************************/ - -java_handle_t *javastring_new_from_ascii(const char *text) -{ - s4 i; - s4 len; /* length of the string */ - java_handle_t *o; - java_lang_String *s; - java_handle_chararray_t *a; - - if (text == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - len = strlen(text); - - o = builtin_new(class_java_lang_String); - a = builtin_newarray_char(len); - - /* javastring or character-array could not be created */ - - if ((o == NULL) || (a == NULL)) - return NULL; - - /* copy text */ - - for (i = 0; i < len; i++) - LLNI_array_direct(a, i) = text[i]; - - /* set fields of the javastring-object */ - - s = (java_lang_String *) o; - - LLNI_field_set_ref(s, value , a); - LLNI_field_set_val(s, offset, 0); - LLNI_field_set_val(s, count , len); - - return o; -} - - -/* javastring_tochar *********************************************************** - - converts a Java string into a C string. - - return: pointer to C string - - Caution: calling method MUST release the allocated memory! - -*******************************************************************************/ - -char *javastring_tochar(java_handle_t *so) -{ - java_lang_String *s = (java_lang_String *) so; - java_handle_chararray_t *a; - int32_t count; - int32_t offset; - char *buf; - s4 i; - - if (!s) - return ""; - - LLNI_field_get_ref(s, value, a); - - if (!a) - return ""; - - LLNI_field_get_val(s, count, count); - LLNI_field_get_val(s, offset, offset); - - buf = MNEW(char, count + 1); - - for (i = 0; i < count; i++) - buf[i] = LLNI_array_direct(a, offset + i); - - buf[i] = '\0'; - - return buf; -} - - -/* javastring_toutf ************************************************************ - - Make utf symbol from javastring. - -*******************************************************************************/ - -utf *javastring_toutf(java_handle_t *string, bool isclassname) -{ - java_lang_String *s; - java_handle_chararray_t *value; - int32_t count; - int32_t offset; - - s = (java_lang_String *) string; - - if (s == NULL) - return utf_null; - - LLNI_field_get_ref(s, value, value); - - if (value == NULL) - return utf_null; - - LLNI_field_get_val(s, count, count); - LLNI_field_get_val(s, offset, offset); - - return utf_new_u2(LLNI_array_data(value) + offset, count, isclassname); -} - - -/* literalstring_u2 ************************************************************ - - Searches for the literalstring with the specified u2-array in the - string hashtable, if there is no such string a new one is created. - - If copymode is true a copy of the u2-array is made. - -*******************************************************************************/ - -static java_object_t *literalstring_u2(java_chararray_t *a, u4 length, - u4 offset, bool copymode) -{ - literalstring *s; /* hashtable element */ - heapstring_t *js; /* u2-array wrapped in javastring */ - java_chararray_t *ca; /* copy of u2-array */ - u4 key; - u4 slot; - u2 i; - - LOCK_MONITOR_ENTER(lock_hashtable_string); - - /* find location in hashtable */ - - key = unicode_hashkey(a->data + offset, length); - slot = key & (hashtable_string.size - 1); - s = hashtable_string.ptr[slot]; - - while (s) { - js = (heapstring_t *) s->string; - - if (length == js->count) { - /* compare text */ - - for (i = 0; i < length; i++) - if (a->data[offset + i] != js->value->data[i]) - goto nomatch; - - /* string already in hashtable, free memory */ - - if (!copymode) - mem_free(a, sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10); - - LOCK_MONITOR_EXIT(lock_hashtable_string); - - return (java_object_t *) js; - } - - nomatch: - /* follow link in external hash chain */ - s = s->hashlink; - } - - if (copymode) { - /* create copy of u2-array for new javastring */ - u4 arraysize = sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10; - ca = mem_alloc(arraysize); -/* memcpy(ca, a, arraysize); */ - memcpy(&(ca->header), &(a->header), sizeof(java_array_t)); - memcpy(&(ca->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10); - - } else { - ca = a; - } - - /* location in hashtable found, complete arrayheader */ - - ca->header.objheader.vftbl = - primitive_arrayclass_get_by_type(ARRAYTYPE_CHAR)->vftbl; - ca->header.size = length; - - assert(class_java_lang_String); - assert(class_java_lang_String->state & CLASS_LOADED); - - /* create new javastring */ - - js = NEW(heapstring_t); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_string += sizeof(heapstring_t); -#endif - -#if defined(ENABLE_THREADS) - lock_init_object_lock(&js->header); -#endif - - js->header.vftbl = class_java_lang_String->vftbl; - js->value = ca; - js->offset = 0; - js->count = length; - - /* create new literalstring */ - - s = NEW(literalstring); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_string += sizeof(literalstring); -#endif - - s->hashlink = hashtable_string.ptr[slot]; - s->string = (java_object_t *) js; - hashtable_string.ptr[slot] = s; - - /* update number of hashtable entries */ - - hashtable_string.entries++; - - /* reorganization of hashtable */ - - if (hashtable_string.entries > (hashtable_string.size * 2)) { - /* reorganization of hashtable, average length of the external - chains is approx. 2 */ - - u4 i; - literalstring *s; - literalstring *nexts; - heapstring_t *tmpjs; - hashtable newhash; /* the new hashtable */ - - /* create new hashtable, double the size */ - - hashtable_create(&newhash, hashtable_string.size * 2); - newhash.entries = hashtable_string.entries; - - /* transfer elements to new hashtable */ - - for (i = 0; i < hashtable_string.size; i++) { - s = hashtable_string.ptr[i]; - - while (s) { - nexts = s->hashlink; - tmpjs = (heapstring_t *) s->string; - slot = unicode_hashkey(tmpjs->value->data, tmpjs->count) & (newhash.size - 1); - - s->hashlink = newhash.ptr[slot]; - newhash.ptr[slot] = s; - - /* follow link in external hash chain */ - s = nexts; - } - } - - /* dispose old table */ - - MFREE(hashtable_string.ptr, void*, hashtable_string.size); - hashtable_string = newhash; - } - - LOCK_MONITOR_EXIT(lock_hashtable_string); - - return (java_object_t *) js; -} - - -/* literalstring_new *********************************************************** - - Creates a new literalstring with the text of the utf-symbol and inserts - it into the string hashtable. - -*******************************************************************************/ - -java_object_t *literalstring_new(utf *u) -{ - char *utf_ptr; /* pointer to current unicode character */ - /* utf string */ - u4 utflength; /* length of utf-string if uncompressed */ - java_chararray_t *a; /* u2-array constructed from utf string */ - u4 i; - - utf_ptr = u->text; - utflength = utf_get_number_of_u2s(u); - - /* allocate memory */ - a = mem_alloc(sizeof(java_chararray_t) + sizeof(u2) * (utflength - 1) + 10); - - /* convert utf-string to u2-array */ - for (i = 0; i < utflength; i++) - a->data[i] = utf_nextu2(&utf_ptr); - - return literalstring_u2(a, utflength, 0, false); -} - - -/* literalstring_free ********************************************************** - - Removes a literalstring from memory. - -*******************************************************************************/ - -#if 0 -/* TWISTI This one is currently not used. */ - -static void literalstring_free(java_object_t* string) -{ - heapstring_t *s; - java_chararray_t *a; - - s = (heapstring_t *) string; - a = s->value; - - /* dispose memory of java.lang.String object */ - FREE(s, heapstring_t); - - /* dispose memory of java-characterarray */ - FREE(a, sizeof(java_chararray_t) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */ -} -#endif - - -/* javastring_intern *********************************************************** - - Intern the given Java string. - - XXX NOTE: Literal Strings are direct references since they are not placed - onto the GC-Heap. That's why this function looks so "different". - -*******************************************************************************/ - -java_handle_t *javastring_intern(java_handle_t *s) -{ - java_lang_String *so; - java_chararray_t *value; - int32_t count; - int32_t offset; -/* java_lang_String *o; */ - java_object_t *o; /* XXX see note above */ - - so = (java_lang_String *) s; - - value = LLNI_field_direct(so, value); /* XXX see note above */ - LLNI_field_get_val(so, count, count); - LLNI_field_get_val(so, offset, offset); - - o = literalstring_u2(value, count, offset, true); - - return LLNI_WRAP(o); /* XXX see note above */ -} - - -/* javastring_fprint *********************************************************** - - Print the given Java string to the given stream. - -*******************************************************************************/ - -void javastring_fprint(java_handle_t *s, FILE *stream) -{ - java_lang_String *so; - java_handle_chararray_t *value; - int32_t count; - int32_t offset; - uint16_t c; - int i; - - so = (java_lang_String *) s; - - LLNI_field_get_ref(so, value, value); - LLNI_field_get_val(so, count, count); - LLNI_field_get_val(so, offset, offset); - - for (i = offset; i < offset + count; i++) { - c = LLNI_array_direct(value, i); - fputc(c, stream); - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/string.cpp b/src/vm/string.cpp new file mode 100644 index 000000000..67f28268e --- /dev/null +++ b/src/vm/string.cpp @@ -0,0 +1,713 @@ +/* src/vm/string.cpp - java.lang.String related functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include "vm/os.hpp" + +#include "vm/types.h" + +#include "vm/global.h" + +#include "mm/memory.h" + +#include "native/llni.h" + +#include "threads/lock-common.h" + +#include "vm/array.h" +#include "vm/jit/builtin.hpp" +#include "vm/exceptions.hpp" +#include "vm/globals.hpp" +#include "vm/javaobjects.hpp" +#include "vm/options.h" +#include "vm/primitive.hpp" +#include "vm/statistics.h" +#include "vm/string.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" + + +/* global variables ***********************************************************/ + +/* hashsize must be power of 2 */ + +#define HASHTABLE_STRING_SIZE 2048 /* initial size of javastring-hash */ + +static hashtable hashtable_string; /* hashtable for javastrings */ +static Mutex* mutex; + + +/* string_init ***************************************************************** + + Initialize the string hashtable lock. + +*******************************************************************************/ + +bool string_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("string_init"); + + /* create string (javastring) hashtable */ + + hashtable_create(&hashtable_string, HASHTABLE_STRING_SIZE); + + mutex = new Mutex(); + + /* everything's ok */ + + return true; +} + + +/* stringtable_update ********************************************************** + + Traverses the javastring hashtable and sets the vftbl-entries of + javastrings which were temporarily set to NULL, because + java.lang.Object was not yet loaded. + +*******************************************************************************/ + +void stringtable_update(void) +{ + java_chararray_t *a; + literalstring *s; /* hashtable entry */ + + for (unsigned int i = 0; i < hashtable_string.size; i++) { + s = (literalstring*) hashtable_string.ptr[i]; + + if (s) { + while (s) { + // FIXME + java_lang_String js(LLNI_WRAP(s->string)); + + if (js.is_null() || (js.get_value() == NULL)) { + /* error in hashtable found */ + VM::get_current()->abort("stringtable_update: invalid literalstring in hashtable"); + } + + a = LLNI_UNWRAP(js.get_value()); + + if (js.get_vftbl() == NULL) + // FIXME + LLNI_UNWRAP(js.get_handle())->vftbl = class_java_lang_String->vftbl; + + if (a->header.objheader.vftbl == NULL) + a->header.objheader.vftbl = Primitive::get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl; + + /* follow link in external hash chain */ + s = s->hashlink; + } + } + } +} + + +/* javastring_new_from_utf_buffer ********************************************** + + Create a new object of type java/lang/String with the text from + the specified utf8 buffer. + + IN: + buffer.......points to first char in the buffer + blength......number of bytes to read from the buffer + + RETURN VALUE: + the java.lang.String object, or + NULL if an exception has been thrown + +*******************************************************************************/ + +static java_handle_t *javastring_new_from_utf_buffer(const char *buffer, u4 blength) +{ + const char *utf_ptr; /* current utf character in utf string */ + + assert(buffer); + + int32_t utflength = utf_get_number_of_u2s_for_buffer(buffer, blength); + + java_handle_t* h = builtin_new(class_java_lang_String); + java_handle_chararray_t* ca = builtin_newarray_char(utflength); + + /* javastring or character-array could not be created */ + + if ((h == NULL) || (ca == NULL)) + return NULL; + + /* decompress utf-string */ + + utf_ptr = buffer; + + for (int32_t i = 0; i < utflength; i++) + LLNI_array_direct(ca, i) = utf_nextu2((char **) &utf_ptr); + + /* set fields of the javastring-object */ + + java_lang_String jls(h, ca, utflength); + + return jls.get_handle(); +} + + +/* javastring_safe_new_from_utf8 *********************************************** + + Create a new object of type java/lang/String with the text from + the specified UTF-8 string. This function is safe for invalid UTF-8. + (Invalid characters will be replaced by U+fffd.) + + IN: + text.........the UTF-8 string, zero-terminated. + + RETURN VALUE: + the java.lang.String object, or + NULL if an exception has been thrown + +*******************************************************************************/ + +java_handle_t *javastring_safe_new_from_utf8(const char *text) +{ + if (text == NULL) + return NULL; + + /* Get number of bytes. We need this to completely emulate the messy */ + /* behaviour of the RI. :( */ + + int32_t nbytes = strlen(text); + + /* calculate number of Java characters */ + + int32_t len = utf8_safe_number_of_u2s(text, nbytes); + + /* allocate the String object and the char array */ + + java_handle_t* h = builtin_new(class_java_lang_String); + java_handle_chararray_t* ca = builtin_newarray_char(len); + + /* javastring or character-array could not be created? */ + + if ((h == NULL) || (ca == NULL)) + return NULL; + + /* decompress UTF-8 string */ + + utf8_safe_convert_to_u2s(text, nbytes, LLNI_array_data(ca)); + + /* set fields of the String object */ + + java_lang_String jls(h, ca, len); + + return jls.get_handle(); +} + + +/* javastring_new_from_utf_string ********************************************** + + Create a new object of type java/lang/String with the text from + the specified zero-terminated utf8 string. + + IN: + buffer.......points to first char in the buffer + blength......number of bytes to read from the buffer + + RETURN VALUE: + the java.lang.String object, or + NULL if an exception has been thrown + +*******************************************************************************/ + +java_handle_t *javastring_new_from_utf_string(const char *utfstr) +{ + assert(utfstr); + + return javastring_new_from_utf_buffer(utfstr, strlen(utfstr)); +} + + +/* javastring_new ************************************************************** + + creates a new object of type java/lang/String with the text of + the specified utf8-string + + return: pointer to the string or NULL if memory is exhausted. + +*******************************************************************************/ + +java_handle_t *javastring_new(utf *u) +{ + if (u == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + char* utf_ptr = u->text; + int32_t utflength = utf_get_number_of_u2s(u); + + java_handle_t* h = builtin_new(class_java_lang_String); + java_handle_chararray_t* ca = builtin_newarray_char(utflength); + + /* javastring or character-array could not be created */ + + if ((h == NULL) || (ca == NULL)) + return NULL; + + /* decompress utf-string */ + + for (int32_t i = 0; i < utflength; i++) + LLNI_array_direct(ca, i) = utf_nextu2(&utf_ptr); + + /* set fields of the javastring-object */ + + java_lang_String jls(h, ca, utflength); + + return jls.get_handle(); +} + + +/* javastring_new_slash_to_dot ************************************************* + + creates a new object of type java/lang/String with the text of + the specified utf8-string with slashes changed to dots + + return: pointer to the string or NULL if memory is exhausted. + +*******************************************************************************/ + +java_handle_t *javastring_new_slash_to_dot(utf *u) +{ + if (u == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + char* utf_ptr = u->text; + int32_t utflength = utf_get_number_of_u2s(u); + + java_handle_t* h = builtin_new(class_java_lang_String); + java_handle_chararray_t* ca = builtin_newarray_char(utflength); + + /* javastring or character-array could not be created */ + if ((h == NULL) || (ca == NULL)) + return NULL; + + /* decompress utf-string */ + + for (int32_t i = 0; i < utflength; i++) { + uint16_t ch = utf_nextu2(&utf_ptr); + + if (ch == '/') + ch = '.'; + + LLNI_array_direct(ca, i) = ch; + } + + /* set fields of the javastring-object */ + + java_lang_String jls(h, ca, utflength); + + return jls.get_handle(); +} + + +/* javastring_new_from_ascii *************************************************** + + creates a new java/lang/String object which contains the given ASCII + C-string converted to UTF-16. + + IN: + text.........string of ASCII characters + + RETURN VALUE: + the java.lang.String object, or + NULL if an exception has been thrown. + +*******************************************************************************/ + +java_handle_t *javastring_new_from_ascii(const char *text) +{ + if (text == NULL) { + exceptions_throw_nullpointerexception(); + return NULL; + } + + int32_t len = strlen(text); + + java_handle_t* h = builtin_new(class_java_lang_String); + java_handle_chararray_t* ca = builtin_newarray_char(len); + + /* javastring or character-array could not be created */ + + if ((h == NULL) || (ca == NULL)) + return NULL; + + /* copy text */ + + for (int32_t i = 0; i < len; i++) + LLNI_array_direct(ca, i) = text[i]; + + /* set fields of the javastring-object */ + + java_lang_String jls(h, ca, len); + + return jls.get_handle(); +} + + +/* javastring_tochar *********************************************************** + + converts a Java string into a C string. + + return: pointer to C string + + Caution: calling method MUST release the allocated memory! + +*******************************************************************************/ + +char* javastring_tochar(java_handle_t* h) +{ + java_lang_String jls(h); + + if (jls.is_null()) + return (char*) ""; + + java_handle_chararray_t* ca = jls.get_value(); + + if (ca == NULL) + return (char*) ""; + + int32_t count = jls.get_count(); + int32_t offset = jls.get_offset(); + + char* buf = MNEW(char, count + 1); + + int32_t i; + for (i = 0; i < count; i++) + buf[i] = LLNI_array_direct(ca, offset + i); + + buf[i] = '\0'; + + return buf; +} + + +/* javastring_toutf ************************************************************ + + Make utf symbol from javastring. + +*******************************************************************************/ + +utf *javastring_toutf(java_handle_t *string, bool isclassname) +{ + java_lang_String jls(string); + + if (jls.is_null()) + return utf_null; + + java_handle_chararray_t* value = jls.get_value(); + + if (jls.get_value() == NULL) + return utf_null; + + int32_t count = jls.get_count(); + int32_t offset = jls.get_offset(); + + return utf_new_u2(LLNI_array_data(value) + offset, count, isclassname); +} + + +/* literalstring_u2 ************************************************************ + + Searches for the literalstring with the specified u2-array in the + string hashtable, if there is no such string a new one is created. + + If copymode is true a copy of the u2-array is made. + +*******************************************************************************/ + +static java_object_t *literalstring_u2(java_chararray_t *a, int32_t length, + u4 offset, bool copymode) +{ + literalstring *s; /* hashtable element */ + java_chararray_t *ca; /* copy of u2-array */ + u4 key; + u4 slot; + u2 i; + + mutex->lock(); + + /* find location in hashtable */ + + key = unicode_hashkey(a->data + offset, length); + slot = key & (hashtable_string.size - 1); + s = (literalstring*) hashtable_string.ptr[slot]; + + while (s) { + // FIXME + java_lang_String js(LLNI_WRAP(s->string)); + + if (length == js.get_count()) { + /* compare text */ + + for (i = 0; i < length; i++) + // FIXME This is not handle capable! + + if (a->data[offset + i] != ((java_chararray_t*) LLNI_UNWRAP(js.get_value()))->data[i]) + goto nomatch; + + /* string already in hashtable, free memory */ + + if (!copymode) + mem_free(a, sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10); + + mutex->unlock(); + + return (java_object_t*) LLNI_UNWRAP(js.get_handle()); + } + + nomatch: + /* follow link in external hash chain */ + s = s->hashlink; + } + + if (copymode) { + /* create copy of u2-array for new javastring */ + u4 arraysize = sizeof(java_chararray_t) + sizeof(u2) * (length - 1) + 10; + ca = (java_chararray_t*) mem_alloc(arraysize); +/* memcpy(ca, a, arraysize); */ + memcpy(&(ca->header), &(a->header), sizeof(java_array_t)); + memcpy(&(ca->data), &(a->data) + offset, sizeof(u2) * (length - 1) + 10); + } + else { + ca = a; + } + + /* location in hashtable found, complete arrayheader */ + + ca->header.objheader.vftbl = Primitive::get_arrayclass_by_type(ARRAYTYPE_CHAR)->vftbl; + ca->header.size = length; + + assert(class_java_lang_String); + assert(class_java_lang_String->state & CLASS_LOADED); + + // Create a new java.lang.String object on the system heap. + java_object_t* o = (java_object_t*) MNEW(uint8_t, class_java_lang_String->instancesize); + // FIXME + java_handle_t* h = LLNI_WRAP(o); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_string += sizeof(class_java_lang_String->instancesize); +#endif + +#if defined(ENABLE_THREADS) + lock_init_object_lock(o); +#endif + + o->vftbl = class_java_lang_String->vftbl; + + // FIXME + java_lang_String jls(h, LLNI_WRAP(ca), length); + + /* create new literalstring */ + + s = NEW(literalstring); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + size_string += sizeof(literalstring); +#endif + + s->hashlink = (literalstring*) hashtable_string.ptr[slot]; + s->string = (java_object_t*) LLNI_UNWRAP(jls.get_handle()); + hashtable_string.ptr[slot] = s; + + /* update number of hashtable entries */ + + hashtable_string.entries++; + + /* reorganization of hashtable */ + + if (hashtable_string.entries > (hashtable_string.size * 2)) { + /* reorganization of hashtable, average length of the external + chains is approx. 2 */ + + u4 i; + literalstring *s; + literalstring *nexts; + hashtable newhash; /* the new hashtable */ + + /* create new hashtable, double the size */ + + hashtable_create(&newhash, hashtable_string.size * 2); + newhash.entries = hashtable_string.entries; + + /* transfer elements to new hashtable */ + + for (i = 0; i < hashtable_string.size; i++) { + s = (literalstring*) hashtable_string.ptr[i]; + + while (s) { + nexts = s->hashlink; + java_lang_String tmpjls(LLNI_WRAP(s->string)); + // FIXME This is not handle capable! + slot = unicode_hashkey(((java_chararray_t*) LLNI_UNWRAP(tmpjls.get_value()))->data, tmpjls.get_count()) & (newhash.size - 1); + + s->hashlink = (literalstring*) newhash.ptr[slot]; + newhash.ptr[slot] = s; + + /* follow link in external hash chain */ + s = nexts; + } + } + + /* dispose old table */ + + MFREE(hashtable_string.ptr, void*, hashtable_string.size); + hashtable_string = newhash; + } + + mutex->unlock(); + + return (java_object_t*) LLNI_UNWRAP(jls.get_handle()); +} + + +/* literalstring_new *********************************************************** + + Creates a new literalstring with the text of the utf-symbol and inserts + it into the string hashtable. + +*******************************************************************************/ + +java_object_t *literalstring_new(utf *u) +{ + char *utf_ptr; /* pointer to current unicode character */ + /* utf string */ + u4 utflength; /* length of utf-string if uncompressed */ + java_chararray_t *a; /* u2-array constructed from utf string */ + u4 i; + + utf_ptr = u->text; + utflength = utf_get_number_of_u2s(u); + + /* allocate memory */ + a = (java_chararray_t*) mem_alloc(sizeof(java_chararray_t) + sizeof(u2) * (utflength - 1) + 10); + + /* convert utf-string to u2-array */ + for (i = 0; i < utflength; i++) + a->data[i] = utf_nextu2(&utf_ptr); + + return literalstring_u2(a, utflength, 0, false); +} + + +/* literalstring_free ********************************************************** + + Removes a literalstring from memory. + +*******************************************************************************/ + +#if 0 +/* TWISTI This one is currently not used. */ + +static void literalstring_free(java_object_t* string) +{ + heapstring_t *s; + java_chararray_t *a; + + s = (heapstring_t *) string; + a = s->value; + + /* dispose memory of java.lang.String object */ + FREE(s, heapstring_t); + + /* dispose memory of java-characterarray */ + FREE(a, sizeof(java_chararray_t) + sizeof(u2) * (a->header.size - 1)); /* +10 ?? */ +} +#endif + + +/* javastring_intern *********************************************************** + + Intern the given Java string. + + XXX NOTE: Literal Strings are direct references since they are not placed + onto the GC-Heap. That's why this function looks so "different". + +*******************************************************************************/ + +java_handle_t *javastring_intern(java_handle_t *string) +{ + java_lang_String jls(string); + + java_handle_chararray_t* value = jls.get_value(); + // FIXME + java_chararray_t* ca = LLNI_UNWRAP(value); /* XXX see note above */ + + int32_t count = jls.get_count(); + int32_t offset = jls.get_offset(); + + java_object_t* o = literalstring_u2(ca, count, offset, true); /* XXX see note above */ + + return LLNI_WRAP(o); /* XXX see note above */ +} + + +/* javastring_fprint *********************************************************** + + Print the given Java string to the given stream. + +*******************************************************************************/ + +void javastring_fprint(java_handle_t *s, FILE *stream) +{ + java_lang_String jls(s); + + java_handle_chararray_t* value = jls.get_value(); + + int32_t count = jls.get_count(); + int32_t offset = jls.get_offset(); + + for (int32_t i = offset; i < offset + count; i++) { + uint16_t c = LLNI_array_direct(value, i); + fputc(c, stream); + } +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/string.hpp b/src/vm/string.hpp new file mode 100644 index 000000000..096f2193e --- /dev/null +++ b/src/vm/string.hpp @@ -0,0 +1,108 @@ +/* src/vm/string.hpp - string header + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _STRINGLOCAL_H +#define _STRINGLOCAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct literalstring literalstring; + + +#include "config.h" + +#include "vm/types.h" + +#include "toolbox/hashtable.h" + +#include "vm/global.h" +#include "vm/os.hpp" +#include "vm/utf8.h" + + +/* data structure of internal javastrings stored in global hashtable **********/ + +struct literalstring { + literalstring *hashlink; /* link for external hash chain */ + java_object_t *string; +}; + + +/* function prototypes ********************************************************/ + +/* initialize string subsystem */ +bool string_init(void); + +void stringtable_update(void); + +/* creates a new object of type java/lang/String from a utf-text */ +java_handle_t *javastring_new(utf *text); + +/* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */ +java_handle_t *javastring_new_slash_to_dot(utf *text); + +/* creates a new object of type java/lang/String from an ASCII c-string */ +java_handle_t *javastring_new_from_ascii(const char *text); + +/* creates a new object of type java/lang/String from UTF-8 */ +java_handle_t *javastring_new_from_utf_string(const char *utfstr); + +/* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */ +java_handle_t *javastring_safe_new_from_utf8(const char *text); + +/* make c-string from a javastring (debugging) */ +char *javastring_tochar(java_handle_t *string); + +/* make utf symbol from javastring */ +utf *javastring_toutf(java_handle_t *string, bool isclassname); + +/* creates a new javastring with the text of the utf-symbol */ +java_object_t *literalstring_new(utf *u); + +java_handle_t *javastring_intern(java_handle_t *s); +void javastring_fprint(java_handle_t *s, FILE *stream); + +#ifdef __cplusplus +} +#endif + +#endif /* _STRINGLOCAL_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/stringlocal.h b/src/vm/stringlocal.h deleted file mode 100644 index 74ffc2366..000000000 --- a/src/vm/stringlocal.h +++ /dev/null @@ -1,106 +0,0 @@ -/* src/vm/stringlocal.h - string header - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _STRINGLOCAL_H -#define _STRINGLOCAL_H - -typedef struct literalstring literalstring; - - -#include "config.h" - -#include "vmcore/system.h" - -#include "vm/types.h" - -#include "toolbox/hashtable.h" - -#include "vm/global.h" - -#include "vmcore/utf8.h" - - -/* data structure of internal javastrings stored in global hashtable **********/ - -struct literalstring { - literalstring *hashlink; /* link for external hash chain */ - java_object_t *string; -}; - - -/* javastring-hashtable */ -extern hashtable hashtable_string; - - -/* function prototypes ********************************************************/ - -/* initialize string subsystem */ -bool string_init(void); - -void stringtable_update(void); - -/* creates a new object of type java/lang/String from a utf-text */ -java_handle_t *javastring_new(utf *text); - -/* creates a new object of type java/lang/String from a utf-text, changes slashes to dots */ -java_handle_t *javastring_new_slash_to_dot(utf *text); - -/* creates a new object of type java/lang/String from an ASCII c-string */ -java_handle_t *javastring_new_from_ascii(const char *text); - -/* creates a new object of type java/lang/String from UTF-8 */ -java_handle_t *javastring_new_from_utf_string(const char *utfstr); - -/* creates a new object of type java/lang/String from (possibly invalid) UTF-8 */ -java_handle_t *javastring_safe_new_from_utf8(const char *text); - -/* make c-string from a javastring (debugging) */ -char *javastring_tochar(java_handle_t *string); - -/* make utf symbol from javastring */ -utf *javastring_toutf(java_handle_t *string, bool isclassname); - -/* creates a new javastring with the text of the utf-symbol */ -java_object_t *literalstring_new(utf *u); - -java_handle_t *javastring_intern(java_handle_t *s); -void javastring_fprint(java_handle_t *s, FILE *stream); - -#endif /* _STRINGLOCAL_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/suck.cpp b/src/vm/suck.cpp new file mode 100644 index 000000000..cf5122872 --- /dev/null +++ b/src/vm/suck.cpp @@ -0,0 +1,626 @@ +/* src/vm/suck.cpp - functions to read LE ordered types from a buffer + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "arch.h" + +#include "mm/memory.h" + +#include "threads/mutex.hpp" + +#include "toolbox/list.h" +#include "toolbox/logging.h" +#include "toolbox/util.h" + +#include "vm/exceptions.hpp" +#include "vm/loader.hpp" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/properties.hpp" +#include "vm/suck.hpp" +#include "vm/vm.hpp" +#include "vm/zip.h" + + +/* global variables ***********************************************************/ + +list_t *list_classpath_entries; + + +/* suck_init ******************************************************************* + + Initializes the suck subsystem like initializing the classpath + entries list. + +*******************************************************************************/ + +bool suck_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("suck_init"); + + list_classpath_entries = list_create(OFFSET(list_classpath_entry, linkage)); + + /* everything's ok */ + + return true; +} + + +/* scandir_filter ************************************************************** + + Filters for zip/jar files. + +*******************************************************************************/ + +static int scandir_filter(const struct dirent *a) +{ + s4 namlen; + +#if defined(_DIRENT_HAVE_D_NAMLEN) + namlen = a->d_namlen; +#else + namlen = strlen(a->d_name); +#endif + + if ((strncasecmp(a->d_name + namlen - 4, ".zip", 4) == 0) || + (strncasecmp(a->d_name + namlen - 4, ".jar", 4) == 0)) + return 1; + + return 0; +} + + +/* suck_add ******************************************************************** + + Adds a classpath to the global classpath entries list. + +*******************************************************************************/ + +void suck_add(char *classpath) +{ + list_classpath_entry *lce; + char *start; + char *end; + char *filename; + s4 filenamelen; + bool is_zip; + char *cwd; + s4 cwdlen; +#if defined(ENABLE_ZLIB) + hashtable *ht; +#endif + + /* parse the classpath string */ + + for (start = classpath; (*start) != '\0'; ) { + + /* search for ':' delimiter to get the end of the current entry */ + for (end = start; ((*end) != '\0') && ((*end) != ':'); end++); + + if (start != end) { + is_zip = false; + filenamelen = end - start; + + if (filenamelen > 4) { + if ((strncasecmp(end - 4, ".zip", 4) == 0) || + (strncasecmp(end - 4, ".jar", 4) == 0)) { + is_zip = true; + } + } + + /* save classpath entries as absolute pathnames */ + + cwd = NULL; + cwdlen = 0; + + if (*start != '/') { /* XXX fix me for win32 */ + cwd = _Jv_getcwd(); + cwdlen = strlen(cwd) + strlen("/"); + } + + /* allocate memory for filename and fill it */ + + filename = MNEW(char, filenamelen + cwdlen + strlen("/") + + strlen("0")); + + if (cwd) { + strcpy(filename, cwd); + strcat(filename, "/"); + strncat(filename, start, filenamelen); + + /* add cwd length to file length */ + filenamelen += cwdlen; + + } else { + strncpy(filename, start, filenamelen); + filename[filenamelen] = '\0'; + } + + lce = NULL; + + if (is_zip) { +#if defined(ENABLE_ZLIB) + ht = zip_open(filename); + + if (ht != NULL) { + lce = NEW(list_classpath_entry); + + lce->type = CLASSPATH_ARCHIVE; + lce->htclasses = ht; + lce->path = filename; + lce->pathlen = filenamelen; + + /* SUN compatible -verbose:class output */ + + if (opt_verboseclass) + printf("[Opened %s]\n", filename); + } + +#else + VM::get_current()->abort("suck_add: zip/jar files not supported"); +#endif + } + else { + if (filename[filenamelen - 1] != '/') {/* XXX fixme for win32 */ + filename[filenamelen] = '/'; + filename[filenamelen + 1] = '\0'; + filenamelen++; + } + + lce = NEW(list_classpath_entry); + + lce->type = CLASSPATH_PATH; + lce->path = filename; + lce->pathlen = filenamelen; + } + + /* add current classpath entry, if no error */ + + if (lce != NULL) + list_add_last(list_classpath_entries, lce); + } + + /* goto next classpath entry, skip ':' delimiter */ + + if ((*end) == ':') + start = end + 1; + else + start = end; + } +} + + +/* suck_add_from_property ****************************************************** + + Adds a classpath form a property entry to the global classpath + entries list. + +*******************************************************************************/ + +void suck_add_from_property(const char *key) +{ + const char *value; + const char *start; + const char *end; + s4 pathlen; + struct dirent **namelist; + s4 n; + s4 i; + s4 namlen; + char *p; + + /* get the property value */ + Properties properties = VM::get_current()->get_properties(); + value = properties.get(key); + + if (value == NULL) + return; + + /* get the directory entries of the property */ + + for (start = value; (*start) != '\0'; ) { + + /* search for ':' delimiter to get the end of the current entry */ + + for (end = start; ((*end) != '\0') && ((*end) != ':'); end++); + + /* found an entry */ + + if (start != end) { + /* allocate memory for the path entry */ + + pathlen = end - start; + char* path = MNEW(char, pathlen + strlen("0")); + + /* copy and terminate the string */ + + strncpy(path, start, pathlen); + path[pathlen] = '\0'; + + /* Reset namelist to NULL for the freeing in an error case + (see below). */ + + namelist = NULL; + + /* scan the directory found for zip/jar files */ + + n = os::scandir((const char*) path, &namelist, &scandir_filter, (int (*)(const void*, const void*)) &alphasort); + + /* On error, just continue, this should be ok. */ + + if (n > 0) { + for (i = 0; i < n; i++) { +#if defined(_DIRENT_HAVE_D_NAMLEN) + namlen = namelist[i]->d_namlen; +#else + namlen = strlen(namelist[i]->d_name); +#endif + + /* Allocate memory for bootclasspath. */ + + // FIXME Make boot_class_path const char*. + char* boot_class_path = (char*) properties.get("sun.boot.class.path"); + + p = MNEW(char, + pathlen + strlen("/") + namlen + + strlen(":") + + strlen(boot_class_path) + + strlen("0")); + + /* Prepend the file found to the bootclasspath. */ + + strcpy(p, path); + strcat(p, "/"); + strcat(p, namelist[i]->d_name); + strcat(p, ":"); + strcat(p, boot_class_path); + + properties.put("sun.boot.class.path", p); + properties.put("java.boot.class.path", p); + + MFREE(boot_class_path, char, strlen(boot_class_path)); + + /* free the memory allocated by scandir */ + /* (We use `free` as the memory came from the C library.) */ + + free(namelist[i]); + } + } + + /* On some systems (like Linux) when n == 0, then namelist + returned from scnadir is NULL, thus we don't have to + free it. + (Use `free` as the memory came from the C library.) */ + + if (namelist != NULL) + free(namelist); + + MFREE(path, char, pathlen + strlen("0")); + } + + /* goto next entry, skip ':' delimiter */ + + if ((*end) == ':') + start = end + 1; + else + start = end; + } +} + + +/* suck_check_classbuffer_size ************************************************* + + Assert that at least bytes are left to read is limited + to the range of non-negative s4 values. + +*******************************************************************************/ + +bool suck_check_classbuffer_size(classbuffer *cb, s4 len) +{ +#ifdef ENABLE_VERIFIER + if (len < 0 || ((cb->data + cb->size) - cb->pos) < len) { + exceptions_throw_classformaterror(cb->clazz, "Truncated class file"); + return false; + } +#endif /* ENABLE_VERIFIER */ + + return true; +} + + +u1 suck_u1(classbuffer *cb) +{ + u1 a; + + a = SUCK_BE_U1(cb->pos); + cb->pos++; + + return a; +} + + +u2 suck_u2(classbuffer *cb) +{ + u2 a; + + a = SUCK_BE_U2(cb->pos); + cb->pos += 2; + + return a; +} + + +u4 suck_u4(classbuffer *cb) +{ + u4 a; + + a = SUCK_BE_U4(cb->pos); + cb->pos += 4; + + return a; +} + + +u8 suck_u8(classbuffer *cb) +{ +#if U8_AVAILABLE == 1 + u8 a; + + a = SUCK_BE_U8(cb->pos); + cb->pos += 8; + + return a; +#else + u8 v; + + v.high = suck_u4(cb); + v.low = suck_u4(cb); + + return v; +#endif +} + + +float suck_float(classbuffer *cb) +{ + float f; + +#if WORDS_BIGENDIAN == 0 + u1 buffer[4]; + u2 i; + + for (i = 0; i < 4; i++) + buffer[3 - i] = suck_u1(cb); + + MCOPY((u1 *) (&f), buffer, u1, 4); +#else + suck_nbytes((u1*) (&f), cb, 4); +#endif + + assert(sizeof(float) == 4); + + return f; +} + + +double suck_double(classbuffer *cb) +{ + double d; + +#if WORDS_BIGENDIAN == 0 + u1 buffer[8]; + u2 i; + +# if defined(__ARM__) && defined(__ARMEL__) && !defined(__VFP_FP__) + /* + * On little endian ARM processors when using FPA, word order + * of doubles is still big endian. So take that into account + * here. When using VFP, word order of doubles follows byte + * order. (michi 2005/07/24) + */ + for (i = 0; i < 4; i++) + buffer[3 - i] = suck_u1(cb); + for (i = 0; i < 4; i++) + buffer[7 - i] = suck_u1(cb); +# else + for (i = 0; i < 8; i++) + buffer[7 - i] = suck_u1(cb); +# endif /* defined(__ARM__) && ... */ + + MCOPY((u1 *) (&d), buffer, u1, 8); +#else + suck_nbytes((u1*) (&d), cb, 8); +#endif + + assert(sizeof(double) == 8); + + return d; +} + + +/* suck_nbytes ***************************************************************** + + Transfer block of classfile data into a buffer. + +*******************************************************************************/ + +void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len) +{ + MCOPY(buffer, cb->pos, u1, len); + cb->pos += len; +} + + +/* suck_skip_nbytes ************************************************************ + + Skip block of classfile data. + +*******************************************************************************/ + +void suck_skip_nbytes(classbuffer *cb, s4 len) +{ + cb->pos += len; +} + + +/* suck_start ****************************************************************** + + Returns true if classbuffer is already loaded or a file for the + specified class has succussfully been read in. All directories of + the searchpath are used to find the classfile (.class). + Returns NULL if no classfile is found and writes an error message. + +*******************************************************************************/ + +classbuffer *suck_start(classinfo *c) +{ + list_classpath_entry *lce; + char *filename; + s4 filenamelen; + char *path; + FILE *classfile; + s4 len; + struct stat buffer; + classbuffer *cb; + + /* initialize return value */ + + cb = NULL; + + /* get the classname as char string (do it here for the warning at + the end of the function) */ + + filenamelen = utf_bytes(c->name) + strlen(".class") + strlen("0"); + filename = MNEW(char, filenamelen); + + utf_copy(filename, c->name); + strcat(filename, ".class"); + + /* walk through all classpath entries */ + + for (lce = (list_classpath_entry*) list_first(list_classpath_entries); lce != NULL && cb == NULL; + lce = (list_classpath_entry*) list_next(list_classpath_entries, lce)) { +#if defined(ENABLE_ZLIB) + if (lce->type == CLASSPATH_ARCHIVE) { + + /* enter a monitor on zip/jar archives */ + + lce->mutex->lock(); + + /* try to get the file in current archive */ + + cb = zip_get(lce, c); + + /* leave the monitor */ + + lce->mutex->unlock(); + + } else { +#endif /* defined(ENABLE_ZLIB) */ + path = MNEW(char, lce->pathlen + filenamelen); + strcpy(path, lce->path); + strcat(path, filename); + + classfile = os::fopen(path, "r"); + + if (classfile) { /* file exists */ + if (!os::stat(path, &buffer)) { /* read classfile data */ + cb = NEW(classbuffer); + cb->clazz = c; + cb->size = buffer.st_size; + cb->data = MNEW(u1, cb->size); + cb->pos = cb->data; + cb->path = lce->path; + + /* read class data */ + + len = os::fread((void *) cb->data, 1, cb->size, + classfile); + + if (len != buffer.st_size) { + suck_stop(cb); +/* if (ferror(classfile)) { */ +/* } */ + } + + /* close the class file */ + + os::fclose(classfile); + } + } + + MFREE(path, char, lce->pathlen + filenamelen); +#if defined(ENABLE_ZLIB) + } +#endif + } + + if (opt_verbose) + if (cb == NULL) + dolog("Warning: Can not open class file '%s'", filename); + + MFREE(filename, char, filenamelen); + + return cb; +} + + +/* suck_stop ******************************************************************* + + Frees memory for buffer with classfile data. + + CAUTION: This function may only be called if buffer has been + allocated by suck_start with reading a file. + +*******************************************************************************/ + +void suck_stop(classbuffer *cb) +{ + /* free memory */ + + MFREE(cb->data, u1, cb->size); + FREE(cb, classbuffer); +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/suck.hpp b/src/vm/suck.hpp new file mode 100644 index 000000000..de9317ec0 --- /dev/null +++ b/src/vm/suck.hpp @@ -0,0 +1,211 @@ +/* src/vm/suck.hpp - functions to read LE ordered types from a buffer + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _SUCK_HPP +#define _SUCK_HPP + +#include "config.h" + +#include "vm/types.h" + +#include "threads/mutex.hpp" + +#include "toolbox/hashtable.h" +#include "toolbox/list.h" + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/loader.hpp" + + +/* list_classpath_entry *******************************************************/ + +enum { + CLASSPATH_PATH, + CLASSPATH_ARCHIVE +}; + +typedef struct list_classpath_entry list_classpath_entry; + +struct list_classpath_entry { +#if defined(ENABLE_THREADS) + Mutex *mutex; /* mutex locking on zip/jar files */ +#endif + s4 type; + char *path; + s4 pathlen; +#if defined(ENABLE_ZLIB) + hashtable *htclasses; +#endif + listnode_t linkage; +}; + + +/* macros to read LE and BE types from a buffer ******************************** + + BE macros are for Java class file loading. + LE macros are for ZIP file loading. + +*******************************************************************************/ + +/* LE macros (for ZIP files ) *************************************************/ + +#if defined(__I386__) || defined(__X86_64__) + +/* we can optimize the LE access on little endian machines without alignment */ + +#define SUCK_LE_U1(p) *((u1 *) (p)) +#define SUCK_LE_U2(p) *((u2 *) (p)) +#define SUCK_LE_U4(p) *((u4 *) (p)) + +#if U8_AVAILABLE == 1 +#define SUCK_LE_U8(p) *((u8 *) (p)) +#endif + +#else /* defined(__I386__) || defined(__X86_64__) */ + +#define SUCK_LE_U1(p) \ + ((u1) (p)[0]) + +#define SUCK_LE_U2(p) \ + ((((u2) (p)[1]) << 8) + \ + ((u2) (p)[0])) + +#define SUCK_LE_U4(p) \ + ((((u4) (p)[3]) << 24) + \ + (((u4) (p)[2]) << 16) + \ + (((u4) (p)[1]) << 8) + \ + ((u4) (p)[0])) + +#if U8_AVAILABLE == 1 +#define SUCK_LE_U8(p) \ + ((((u8) (p)[7]) << 56) + \ + (((u8) (p)[6]) << 48) + \ + (((u8) (p)[5]) << 40) + \ + (((u8) (p)[4]) << 32) + \ + (((u8) (p)[3]) << 24) + \ + (((u8) (p)[2]) << 16) + \ + (((u8) (p)[1]) << 8) + \ + ((u8) (p)[0])) +#endif + +#endif /* defined(__I386__) || defined(__X86_64__) */ + + +/* BE macros (for Java class files ) ******************************************/ + +#define SUCK_BE_U1(p) \ + ((u1) (p)[0]) + +#define SUCK_BE_U2(p) \ + ((((u2) (p)[0]) << 8) + \ + ((u2) (p)[1])) + +#define SUCK_BE_U4(p) \ + ((((u4) (p)[0]) << 24) + \ + (((u4) (p)[1]) << 16) + \ + (((u4) (p)[2]) << 8) + \ + ((u4) (p)[3])) + +#if U8_AVAILABLE == 1 +#define SUCK_BE_U8(p) \ + ((((u8) (p)[0]) << 56) + \ + (((u8) (p)[1]) << 48) + \ + (((u8) (p)[2]) << 40) + \ + (((u8) (p)[3]) << 32) + \ + (((u8) (p)[4]) << 24) + \ + (((u8) (p)[5]) << 16) + \ + (((u8) (p)[6]) << 8) + \ + ((u8) (p)[7])) +#endif + + +#define SUCK_BE_S1(p) (s1) SUCK_BE_U1(p) +#define SUCK_BE_S2(p) (s2) SUCK_BE_U2(p) +#define SUCK_BE_S4(p) (s4) SUCK_BE_U4(p) +#define SUCK_BE_S8(p) (s8) SUCK_BE_U8(p) + + +/* signed suck defines ********************************************************/ + +#define suck_s1(a) (s1) suck_u1((a)) +#define suck_s2(a) (s2) suck_u2((a)) +#define suck_s4(a) (s4) suck_u4((a)) +#define suck_s8(a) (s8) suck_u8((a)) + + +/* export variables ***********************************************************/ + +extern list_t *list_classpath_entries; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +bool suck_init(void); + +void suck_add(char *classpath); +void suck_add_from_property(const char *key); + +bool suck_check_classbuffer_size(classbuffer *cb, s4 len); + +u1 suck_u1(classbuffer *cb); +u2 suck_u2(classbuffer *cb); +u4 suck_u4(classbuffer *cb); +u8 suck_u8(classbuffer *cb); + +float suck_float(classbuffer *cb); +double suck_double(classbuffer *cb); + +void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len); +void suck_skip_nbytes(classbuffer *cb, s4 len); + +classbuffer *suck_start(classinfo *c); + +void suck_stop(classbuffer *cb); + +#ifdef __cplusplus +} +#endif + +#endif // _SUCK_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/utf8.c b/src/vm/utf8.c new file mode 100644 index 000000000..1d7d7605f --- /dev/null +++ b/src/vm/utf8.c @@ -0,0 +1,1934 @@ +/* src/vm/utf8.c - utf8 string functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include + +#include "vm/types.h" + +#include "mm/memory.h" + +#include "threads/mutex.hpp" + +#include "toolbox/hashtable.h" + +#include "vm/exceptions.hpp" +#include "vm/options.h" + +#if defined(ENABLE_STATISTICS) +# include "vm/statistics.h" +#endif + +#include "vm/utf8.h" + + +/* global variables ***********************************************************/ + +/* hashsize must be power of 2 */ + +#define HASHTABLE_UTF_SIZE 16384 /* initial size of utf-hash */ + +hashtable *hashtable_utf; /* hashtable for utf8-symbols */ + + +/* utf-symbols for pointer comparison of frequently used strings **************/ + +utf *utf_java_lang_Object; + +utf *utf_java_lang_Class; +utf *utf_java_lang_ClassLoader; +utf *utf_java_lang_Cloneable; +utf *utf_java_lang_SecurityManager; +utf *utf_java_lang_String; +utf *utf_java_lang_ThreadGroup; +utf *utf_java_lang_ref_SoftReference; +utf *utf_java_lang_ref_WeakReference; +utf *utf_java_lang_ref_PhantomReference; +utf *utf_java_io_Serializable; + +utf *utf_java_lang_Throwable; +utf *utf_java_lang_Error; + +utf *utf_java_lang_AbstractMethodError; +utf *utf_java_lang_ClassCircularityError; +utf *utf_java_lang_ClassFormatError; +utf *utf_java_lang_ExceptionInInitializerError; +utf *utf_java_lang_IncompatibleClassChangeError; +utf *utf_java_lang_InstantiationError; +utf *utf_java_lang_InternalError; +utf *utf_java_lang_LinkageError; +utf *utf_java_lang_NoClassDefFoundError; +utf *utf_java_lang_NoSuchFieldError; +utf *utf_java_lang_NoSuchMethodError; +utf *utf_java_lang_OutOfMemoryError; +utf *utf_java_lang_UnsatisfiedLinkError; +utf *utf_java_lang_UnsupportedClassVersionError; +utf *utf_java_lang_VerifyError; +utf *utf_java_lang_VirtualMachineError; + +utf *utf_java_lang_Exception; + +utf *utf_java_lang_ArithmeticException; +utf *utf_java_lang_ArrayIndexOutOfBoundsException; +utf *utf_java_lang_ArrayStoreException; +utf *utf_java_lang_ClassCastException; +utf *utf_java_lang_ClassNotFoundException; +utf *utf_java_lang_CloneNotSupportedException; +utf *utf_java_lang_IllegalAccessException; +utf *utf_java_lang_IllegalArgumentException; +utf *utf_java_lang_IllegalMonitorStateException; +utf *utf_java_lang_InstantiationException; +utf *utf_java_lang_InterruptedException; +utf *utf_java_lang_NegativeArraySizeException; +utf *utf_java_lang_NullPointerException; +utf *utf_java_lang_RuntimeException; +utf *utf_java_lang_StringIndexOutOfBoundsException; + +utf *utf_java_lang_reflect_InvocationTargetException; + +utf *utf_java_security_PrivilegedActionException; + +#if defined(ENABLE_JAVASE) +utf* utf_java_lang_Void; +#endif + +utf* utf_java_lang_Boolean; +utf* utf_java_lang_Byte; +utf* utf_java_lang_Character; +utf* utf_java_lang_Short; +utf* utf_java_lang_Integer; +utf* utf_java_lang_Long; +utf* utf_java_lang_Float; +utf* utf_java_lang_Double; + +#if defined(ENABLE_JAVASE) +utf *utf_java_lang_StackTraceElement; +utf *utf_java_lang_reflect_Constructor; +utf *utf_java_lang_reflect_Field; +utf *utf_java_lang_reflect_Method; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +utf *utf_java_lang_reflect_VMConstructor; +utf *utf_java_lang_reflect_VMField; +utf *utf_java_lang_reflect_VMMethod; +# endif + +utf *utf_java_util_Vector; +#endif + +utf *utf_InnerClasses; /* InnerClasses */ +utf *utf_ConstantValue; /* ConstantValue */ +utf *utf_Code; /* Code */ +utf *utf_Exceptions; /* Exceptions */ +utf *utf_LineNumberTable; /* LineNumberTable */ +utf *utf_SourceFile; /* SourceFile */ + +#if defined(ENABLE_JAVASE) +utf *utf_EnclosingMethod; +utf *utf_Signature; +utf *utf_StackMapTable; + +#if defined(ENABLE_ANNOTATIONS) +utf *utf_RuntimeVisibleAnnotations; /* RuntimeVisibleAnnotations */ +utf *utf_RuntimeInvisibleAnnotations; /* RuntimeInvisibleAnnotations */ +utf *utf_RuntimeVisibleParameterAnnotations; /* RuntimeVisibleParameterAnnotations */ +utf *utf_RuntimeInvisibleParameterAnnotations; /* RuntimeInvisibleParameterAnnotations */ +utf *utf_AnnotationDefault; /* AnnotationDefault */ +#endif +#endif + +utf *utf_init; /* */ +utf *utf_clinit; /* */ +utf *utf_clone; /* clone */ +utf *utf_finalize; /* finalize */ +utf *utf_invoke; +utf *utf_main; +utf *utf_run; /* run */ + +utf *utf_add; +utf *utf_dispatch; +utf *utf_remove; +utf *utf_addThread; +utf *utf_removeThread; +utf *utf_put; +utf *utf_get; +utf *utf_uncaughtException; +utf *utf_value; + +utf *utf_fillInStackTrace; +utf *utf_findNative; +utf *utf_getSystemClassLoader; +utf *utf_initCause; +utf *utf_loadClass; +utf *utf_loadClassInternal; +utf *utf_printStackTrace; + +utf *utf_division_by_zero; + +utf *utf_Z; /* Z */ +utf *utf_B; /* B */ +utf *utf_C; /* C */ +utf *utf_S; /* S */ +utf *utf_I; /* I */ +utf *utf_J; /* J */ +utf *utf_F; /* F */ +utf *utf_D; /* D */ + +utf *utf_void__void; /* ()V */ +utf *utf_boolean__void; /* (Z)V */ +utf *utf_byte__void; /* (B)V */ +utf *utf_char__void; /* (C)V */ +utf *utf_short__void; /* (S)V */ +utf *utf_int__void; /* (I)V */ +utf *utf_long__void; /* (J)V */ +utf *utf_float__void; /* (F)V */ +utf *utf_double__void; /* (D)V */ + +utf *utf_void__java_lang_ClassLoader; /* ()Ljava/lang/ClassLoader; */ +utf *utf_void__java_lang_Object; /* ()Ljava/lang/Object; */ +utf *utf_void__java_lang_Throwable; /* ()Ljava/lang/Throwable; */ +utf *utf_java_lang_ClassLoader_java_lang_String__J; +utf *utf_java_lang_Exception__V; /* (Ljava/lang/Exception;)V */ +utf *utf_java_lang_Object__java_lang_Object; +utf *utf_java_lang_String__void; /* (Ljava/lang/String;)V */ +utf *utf_java_lang_String__java_lang_Class; +utf *utf_java_lang_Thread__V; /* (Ljava/lang/Thread;)V */ +utf *utf_java_lang_Thread_java_lang_Throwable__V; +utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V; +utf *utf_java_lang_Throwable__void; /* (Ljava/lang/Throwable;)V */ +utf *utf_java_lang_Throwable__java_lang_Throwable; + +utf *utf_not_named_yet; /* special name for unnamed classes */ +utf *utf_null; +utf *array_packagename; + + +/* utf_init ******************************************************************** + + Initializes the utf8 subsystem. + +*******************************************************************************/ + +void utf8_init(void) +{ + TRACESUBSYSTEMINITIALIZATION("utf8_init"); + + /* create utf8 hashtable */ + + hashtable_utf = NEW(hashtable); + + hashtable_create(hashtable_utf, HASHTABLE_UTF_SIZE); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_utf_len += sizeof(utf*) * hashtable_utf->size; +#endif + + /* create utf-symbols for pointer comparison of frequently used strings */ + + utf_java_lang_Object = utf_new_char("java/lang/Object"); + + utf_java_lang_Class = utf_new_char("java/lang/Class"); + utf_java_lang_ClassLoader = utf_new_char("java/lang/ClassLoader"); + utf_java_lang_Cloneable = utf_new_char("java/lang/Cloneable"); + utf_java_lang_SecurityManager = utf_new_char("java/lang/SecurityManager"); + utf_java_lang_String = utf_new_char("java/lang/String"); + utf_java_lang_ThreadGroup = utf_new_char("java/lang/ThreadGroup"); + + utf_java_lang_ref_SoftReference = + utf_new_char("java/lang/ref/SoftReference"); + + utf_java_lang_ref_WeakReference = + utf_new_char("java/lang/ref/WeakReference"); + + utf_java_lang_ref_PhantomReference = + utf_new_char("java/lang/ref/PhantomReference"); + + utf_java_io_Serializable = utf_new_char("java/io/Serializable"); + + utf_java_lang_Throwable = utf_new_char("java/lang/Throwable"); + utf_java_lang_Error = utf_new_char("java/lang/Error"); + + utf_java_lang_ClassCircularityError = + utf_new_char("java/lang/ClassCircularityError"); + + utf_java_lang_ClassFormatError = utf_new_char("java/lang/ClassFormatError"); + + utf_java_lang_ExceptionInInitializerError = + utf_new_char("java/lang/ExceptionInInitializerError"); + + utf_java_lang_IncompatibleClassChangeError = + utf_new_char("java/lang/IncompatibleClassChangeError"); + + utf_java_lang_InstantiationError = + utf_new_char("java/lang/InstantiationError"); + + utf_java_lang_InternalError = utf_new_char("java/lang/InternalError"); + utf_java_lang_LinkageError = utf_new_char("java/lang/LinkageError"); + + utf_java_lang_NoClassDefFoundError = + utf_new_char("java/lang/NoClassDefFoundError"); + + utf_java_lang_OutOfMemoryError = utf_new_char("java/lang/OutOfMemoryError"); + + utf_java_lang_UnsatisfiedLinkError = + utf_new_char("java/lang/UnsatisfiedLinkError"); + + utf_java_lang_UnsupportedClassVersionError = + utf_new_char("java/lang/UnsupportedClassVersionError"); + + utf_java_lang_VerifyError = utf_new_char("java/lang/VerifyError"); + + utf_java_lang_VirtualMachineError = + utf_new_char("java/lang/VirtualMachineError"); + +#if defined(ENABLE_JAVASE) + utf_java_lang_AbstractMethodError = + utf_new_char("java/lang/AbstractMethodError"); + + utf_java_lang_NoSuchFieldError = + utf_new_char("java/lang/NoSuchFieldError"); + + utf_java_lang_NoSuchMethodError = + utf_new_char("java/lang/NoSuchMethodError"); +#endif + + utf_java_lang_Exception = utf_new_char("java/lang/Exception"); + + utf_java_lang_ArithmeticException = + utf_new_char("java/lang/ArithmeticException"); + + utf_java_lang_ArrayIndexOutOfBoundsException = + utf_new_char("java/lang/ArrayIndexOutOfBoundsException"); + + utf_java_lang_ArrayStoreException = + utf_new_char("java/lang/ArrayStoreException"); + + utf_java_lang_ClassCastException = + utf_new_char("java/lang/ClassCastException"); + + utf_java_lang_ClassNotFoundException = + utf_new_char("java/lang/ClassNotFoundException"); + + utf_java_lang_CloneNotSupportedException = + utf_new_char("java/lang/CloneNotSupportedException"); + + utf_java_lang_IllegalAccessException = + utf_new_char("java/lang/IllegalAccessException"); + + utf_java_lang_IllegalArgumentException = + utf_new_char("java/lang/IllegalArgumentException"); + + utf_java_lang_IllegalMonitorStateException = + utf_new_char("java/lang/IllegalMonitorStateException"); + + utf_java_lang_InstantiationException = + utf_new_char("java/lang/InstantiationException"); + + utf_java_lang_InterruptedException = + utf_new_char("java/lang/InterruptedException"); + + utf_java_lang_NegativeArraySizeException = + utf_new_char("java/lang/NegativeArraySizeException"); + + utf_java_lang_NullPointerException = + utf_new_char("java/lang/NullPointerException"); + + utf_java_lang_RuntimeException = + utf_new_char("java/lang/RuntimeException"); + + utf_java_lang_StringIndexOutOfBoundsException = + utf_new_char("java/lang/StringIndexOutOfBoundsException"); + + utf_java_lang_reflect_InvocationTargetException = + utf_new_char("java/lang/reflect/InvocationTargetException"); + + utf_java_security_PrivilegedActionException = + utf_new_char("java/security/PrivilegedActionException"); + +#if defined(ENABLE_JAVASE) + utf_java_lang_Void = utf_new_char("java/lang/Void"); +#endif + + utf_java_lang_Boolean = utf_new_char("java/lang/Boolean"); + utf_java_lang_Byte = utf_new_char("java/lang/Byte"); + utf_java_lang_Character = utf_new_char("java/lang/Character"); + utf_java_lang_Short = utf_new_char("java/lang/Short"); + utf_java_lang_Integer = utf_new_char("java/lang/Integer"); + utf_java_lang_Long = utf_new_char("java/lang/Long"); + utf_java_lang_Float = utf_new_char("java/lang/Float"); + utf_java_lang_Double = utf_new_char("java/lang/Double"); + +#if defined(ENABLE_JAVASE) + utf_java_lang_StackTraceElement = + utf_new_char("java/lang/StackTraceElement"); + + utf_java_lang_reflect_Constructor = + utf_new_char("java/lang/reflect/Constructor"); + + utf_java_lang_reflect_Field = utf_new_char("java/lang/reflect/Field"); + utf_java_lang_reflect_Method = utf_new_char("java/lang/reflect/Method"); + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + utf_java_lang_reflect_VMConstructor = utf_new_char("java/lang/reflect/VMConstructor"); + utf_java_lang_reflect_VMField = utf_new_char("java/lang/reflect/VMField"); + utf_java_lang_reflect_VMMethod = utf_new_char("java/lang/reflect/VMMethod"); +# endif + + utf_java_util_Vector = utf_new_char("java/util/Vector"); +#endif + + utf_InnerClasses = utf_new_char("InnerClasses"); + utf_ConstantValue = utf_new_char("ConstantValue"); + utf_Code = utf_new_char("Code"); + utf_Exceptions = utf_new_char("Exceptions"); + utf_LineNumberTable = utf_new_char("LineNumberTable"); + utf_SourceFile = utf_new_char("SourceFile"); + +#if defined(ENABLE_JAVASE) + utf_EnclosingMethod = utf_new_char("EnclosingMethod"); + utf_Signature = utf_new_char("Signature"); + utf_StackMapTable = utf_new_char("StackMapTable"); + +# if defined(ENABLE_ANNOTATIONS) + utf_RuntimeVisibleAnnotations = utf_new_char("RuntimeVisibleAnnotations"); + utf_RuntimeInvisibleAnnotations = utf_new_char("RuntimeInvisibleAnnotations"); + utf_RuntimeVisibleParameterAnnotations = utf_new_char("RuntimeVisibleParameterAnnotations"); + utf_RuntimeInvisibleParameterAnnotations = utf_new_char("RuntimeInvisibleParameterAnnotations"); + utf_AnnotationDefault = utf_new_char("AnnotationDefault"); +# endif +#endif + + utf_init = utf_new_char(""); + utf_clinit = utf_new_char(""); + utf_clone = utf_new_char("clone"); + utf_finalize = utf_new_char("finalize"); + utf_invoke = utf_new_char("invoke"); + utf_main = utf_new_char("main"); + utf_run = utf_new_char("run"); + + utf_add = utf_new_char("add"); + utf_dispatch = utf_new_char("dispatch"); + utf_remove = utf_new_char("remove"); + utf_addThread = utf_new_char("addThread"); + utf_removeThread = utf_new_char("removeThread"); + utf_put = utf_new_char("put"); + utf_get = utf_new_char("get"); + utf_uncaughtException = utf_new_char("uncaughtException"); + utf_value = utf_new_char("value"); + + utf_fillInStackTrace = utf_new_char("fillInStackTrace"); + utf_findNative = utf_new_char("findNative"); + utf_getSystemClassLoader = utf_new_char("getSystemClassLoader"); + utf_initCause = utf_new_char("initCause"); + utf_loadClass = utf_new_char("loadClass"); + utf_loadClassInternal = utf_new_char("loadClassInternal"); + utf_printStackTrace = utf_new_char("printStackTrace"); + + utf_division_by_zero = utf_new_char("/ by zero"); + + utf_Z = utf_new_char("Z"); + utf_B = utf_new_char("B"); + utf_C = utf_new_char("C"); + utf_S = utf_new_char("S"); + utf_I = utf_new_char("I"); + utf_J = utf_new_char("J"); + utf_F = utf_new_char("F"); + utf_D = utf_new_char("D"); + + utf_void__void = utf_new_char("()V"); + utf_boolean__void = utf_new_char("(Z)V"); + utf_byte__void = utf_new_char("(B)V"); + utf_char__void = utf_new_char("(C)V"); + utf_short__void = utf_new_char("(S)V"); + utf_int__void = utf_new_char("(I)V"); + utf_long__void = utf_new_char("(J)V"); + utf_float__void = utf_new_char("(F)V"); + utf_double__void = utf_new_char("(D)V"); + utf_void__java_lang_Object = utf_new_char("()Ljava/lang/Object;"); + utf_void__java_lang_Throwable = utf_new_char("()Ljava/lang/Throwable;"); + + utf_void__java_lang_ClassLoader = + utf_new_char("()Ljava/lang/ClassLoader;"); + + utf_java_lang_ClassLoader_java_lang_String__J = + utf_new_char("(Ljava/lang/ClassLoader;Ljava/lang/String;)J"); + + utf_java_lang_Exception__V = utf_new_char("(Ljava/lang/Exception;)V"); + + utf_java_lang_Object__java_lang_Object = + utf_new_char("(Ljava/lang/Object;)Ljava/lang/Object;"); + + utf_java_lang_String__void = utf_new_char("(Ljava/lang/String;)V"); + + utf_java_lang_String__java_lang_Class = + utf_new_char("(Ljava/lang/String;)Ljava/lang/Class;"); + + utf_java_lang_Thread__V = utf_new_char("(Ljava/lang/Thread;)V"); + + utf_java_lang_Thread_java_lang_Throwable__V = + utf_new_char("(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); + + utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V = + utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"); + + utf_java_lang_Throwable__void = utf_new_char("(Ljava/lang/Throwable;)V"); + + utf_java_lang_Throwable__java_lang_Throwable = + utf_new_char("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"); + + utf_null = utf_new_char("null"); + utf_not_named_yet = utf_new_char("\t"); + array_packagename = utf_new_char("\t"); +} + + +/* utf_hashkey ***************************************************************** + + The hashkey is computed from the utf-text by using up to 8 + characters. For utf-symbols longer than 15 characters 3 characters + are taken from the beginning and the end, 2 characters are taken + from the middle. + +*******************************************************************************/ + +#define nbs(val) ((u4) *(++text) << val) /* get next byte, left shift by val */ +#define fbs(val) ((u4) *( text) << val) /* get first byte, left shift by val */ + +u4 utf_hashkey(const char *text, u4 length) +{ + const char *start_pos = text; /* pointer to utf text */ + u4 a; + + switch (length) { + case 0: /* empty string */ + return 0; + + case 1: return fbs(0); + case 2: return fbs(0) ^ nbs(3); + case 3: return fbs(0) ^ nbs(3) ^ nbs(5); + case 4: return fbs(0) ^ nbs(2) ^ nbs(4) ^ nbs(6); + case 5: return fbs(0) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(6); + case 6: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(5) ^ nbs(6); + case 7: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6); + case 8: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7); + + case 9: + a = fbs(0); + a ^= nbs(1); + a ^= nbs(2); + text++; + return a ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7) ^ nbs(8); + + case 10: + a = fbs(0); + text++; + a ^= nbs(2); + a ^= nbs(3); + a ^= nbs(4); + text++; + return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9); + + case 11: + a = fbs(0); + text++; + a ^= nbs(2); + a ^= nbs(3); + a ^= nbs(4); + text++; + return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9) ^ nbs(10); + + case 12: + a = fbs(0); + text += 2; + a ^= nbs(2); + a ^= nbs(3); + text++; + a ^= nbs(5); + a ^= nbs(6); + a ^= nbs(7); + text++; + return a ^ nbs(9) ^ nbs(10); + + case 13: + a = fbs(0); + a ^= nbs(1); + text++; + a ^= nbs(3); + a ^= nbs(4); + text += 2; + a ^= nbs(7); + a ^= nbs(8); + text += 2; + return a ^ nbs(9) ^ nbs(10); + + case 14: + a = fbs(0); + text += 2; + a ^= nbs(3); + a ^= nbs(4); + text += 2; + a ^= nbs(7); + a ^= nbs(8); + text += 2; + return a ^ nbs(9) ^ nbs(10) ^ nbs(11); + + case 15: + a = fbs(0); + text += 2; + a ^= nbs(3); + a ^= nbs(4); + text += 2; + a ^= nbs(7); + a ^= nbs(8); + text += 2; + return a ^ nbs(9) ^ nbs(10) ^ nbs(11); + + default: /* 3 characters from beginning */ + a = fbs(0); + text += 2; + a ^= nbs(3); + a ^= nbs(4); + + /* 2 characters from middle */ + text = start_pos + (length / 2); + a ^= fbs(5); + text += 2; + a ^= nbs(6); + + /* 3 characters from end */ + text = start_pos + length - 4; + + a ^= fbs(7); + text++; + + return a ^ nbs(10) ^ nbs(11); + } +} + +/* utf_full_hashkey ************************************************************ + + This function computes a hash value using all bytes in the string. + + The algorithm is the "One-at-a-time" algorithm as published + by Bob Jenkins on http://burtleburtle.net/bob/hash/doobs.html. + +*******************************************************************************/ + +u4 utf_full_hashkey(const char *text, u4 length) +{ + register const unsigned char *p = (const unsigned char *) text; + register u4 hash; + register u4 i; + + hash = 0; + for (i=length; i--;) + { + hash += *p++; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + + return hash; +} + +/* unicode_hashkey ************************************************************* + + Compute the hashkey of a unicode string. + +*******************************************************************************/ + +u4 unicode_hashkey(u2 *text, u2 len) +{ + return utf_hashkey((char *) text, len); +} + + +/* utf_new ********************************************************************* + + Creates a new utf-symbol, the text of the symbol is passed as a + u1-array. The function searches the utf-hashtable for a utf-symbol + with this text. On success the element returned, otherwise a new + hashtable element is created. + + If the number of entries in the hashtable exceeds twice the size of + the hashtable slots a reorganization of the hashtable is done and + the utf symbols are copied to a new hashtable with doubled size. + +*******************************************************************************/ + +utf *utf_new(const char *text, u2 length) +{ + u4 key; /* hashkey computed from utf-text */ + u4 slot; /* slot in hashtable */ + utf *u; /* hashtable element */ + u2 i; + + Mutex_lock(hashtable_utf->mutex); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_utf_new++; +#endif + + key = utf_hashkey(text, length); + slot = key & (hashtable_utf->size - 1); + u = hashtable_utf->ptr[slot]; + + /* search external hash chain for utf-symbol */ + + while (u) { + if (u->blength == length) { + /* compare text of hashtable elements */ + + for (i = 0; i < length; i++) + if (text[i] != u->text[i]) + goto nomatch; + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_utf_new_found++; +#endif + + /* symbol found in hashtable */ + + Mutex_unlock(hashtable_utf->mutex); + + return u; + } + + nomatch: + u = u->hashlink; /* next element in external chain */ + } + + /* location in hashtable found, create new utf element */ + + u = NEW(utf); + + u->blength = length; /* length in bytes of utfstring */ + u->hashlink = hashtable_utf->ptr[slot]; /* link in external hashchain */ + u->text = mem_alloc(length + 1);/* allocate memory for utf-text */ + + memcpy(u->text, text, length); /* copy utf-text */ + u->text[length] = '\0'; + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_utf_len += sizeof(utf) + length + 1; +#endif + + hashtable_utf->ptr[slot] = u; /* insert symbol into table */ + hashtable_utf->entries++; /* update number of entries */ + + if (hashtable_utf->entries > (hashtable_utf->size * 2)) { + + /* reorganization of hashtable, average length of the external + chains is approx. 2 */ + + hashtable *newhash; /* the new hashtable */ + u4 i; + utf *u; + utf *nextu; + u4 slot; + + /* create new hashtable, double the size */ + + newhash = hashtable_resize(hashtable_utf, hashtable_utf->size * 2); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) + count_utf_len += sizeof(utf*) * hashtable_utf->size; +#endif + + /* transfer elements to new hashtable */ + + for (i = 0; i < hashtable_utf->size; i++) { + u = hashtable_utf->ptr[i]; + + while (u) { + nextu = u->hashlink; + slot = utf_hashkey(u->text, u->blength) & (newhash->size - 1); + + u->hashlink = (utf *) newhash->ptr[slot]; + newhash->ptr[slot] = u; + + /* follow link in external hash chain */ + + u = nextu; + } + } + + /* dispose old table */ + + hashtable_free(hashtable_utf); + + hashtable_utf = newhash; + } + + Mutex_unlock(hashtable_utf->mutex); + + return u; +} + + +/* utf_new_u2 ****************************************************************** + + Make utf symbol from u2 array, if isclassname is true '.' is + replaced by '/'. + +*******************************************************************************/ + +utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname) +{ + char *buffer; /* memory buffer for unicode characters */ + char *pos; /* pointer to current position in buffer */ + u4 left; /* unicode characters left */ + u4 buflength; /* utf length in bytes of the u2 array */ + utf *result; /* resulting utf-string */ + int i; + + /* determine utf length in bytes and allocate memory */ + + buflength = u2_utflength(unicode_pos, unicode_length); + buffer = MNEW(char, buflength); + + left = buflength; + pos = buffer; + + for (i = 0; i++ < unicode_length; unicode_pos++) { + /* next unicode character */ + u2 c = *unicode_pos; + + if ((c != 0) && (c < 0x80)) { + /* 1 character */ + left--; + if ((int) left < 0) break; + /* convert classname */ + if (isclassname && c == '.') + *pos++ = '/'; + else + *pos++ = (char) c; + + } else if (c < 0x800) { + /* 2 characters */ + unsigned char high = c >> 6; + unsigned char low = c & 0x3F; + left = left - 2; + if ((int) left < 0) break; + *pos++ = high | 0xC0; + *pos++ = low | 0x80; + + } else { + /* 3 characters */ + char low = c & 0x3f; + char mid = (c >> 6) & 0x3F; + char high = c >> 12; + left = left - 3; + if ((int) left < 0) break; + *pos++ = high | 0xE0; + *pos++ = mid | 0x80; + *pos++ = low | 0x80; + } + } + + /* insert utf-string into symbol-table */ + result = utf_new(buffer,buflength); + + MFREE(buffer, char, buflength); + + return result; +} + + +/* utf_new_char **************************************************************** + + Creates a new utf symbol, the text for this symbol is passed as a + c-string ( = char* ). + +*******************************************************************************/ + +utf *utf_new_char(const char *text) +{ + return utf_new(text, strlen(text)); +} + + +/* utf_new_char_classname ****************************************************** + + Creates a new utf symbol, the text for this symbol is passed as a + c-string ( = char* ) "." characters are going to be replaced by + "/". Since the above function is used often, this is a separte + function, instead of an if. + +*******************************************************************************/ + +utf *utf_new_char_classname(const char *text) +{ + if (strchr(text, '.')) { + char *txt = strdup(text); + char *end = txt + strlen(txt); + char *c; + utf *tmpRes; + + for (c = txt; c < end; c++) + if (*c == '.') *c = '/'; + + tmpRes = utf_new(txt, strlen(txt)); + FREE(txt, 0); + + return tmpRes; + + } else + return utf_new(text, strlen(text)); +} + + +/* utf_nextu2 ****************************************************************** + + Read the next unicode character from the utf string and increment + the utf-string pointer accordingly. + + CAUTION: This function is unsafe for input that was not checked + by is_valid_utf! + +*******************************************************************************/ + +u2 utf_nextu2(char **utf_ptr) +{ + /* uncompressed unicode character */ + u2 unicode_char = 0; + /* current position in utf text */ + unsigned char *utf = (unsigned char *) (*utf_ptr); + /* bytes representing the unicode character */ + unsigned char ch1, ch2, ch3; + /* number of bytes used to represent the unicode character */ + int len = 0; + + switch ((ch1 = utf[0]) >> 4) { + default: /* 1 byte */ + (*utf_ptr)++; + return (u2) ch1; + case 0xC: + case 0xD: /* 2 bytes */ + if (((ch2 = utf[1]) & 0xC0) == 0x80) { + unsigned char high = ch1 & 0x1F; + unsigned char low = ch2 & 0x3F; + unicode_char = (high << 6) + low; + len = 2; + } + break; + + case 0xE: /* 2 or 3 bytes */ + if (((ch2 = utf[1]) & 0xC0) == 0x80) { + if (((ch3 = utf[2]) & 0xC0) == 0x80) { + unsigned char low = ch3 & 0x3f; + unsigned char mid = ch2 & 0x3f; + unsigned char high = ch1 & 0x0f; + unicode_char = (((high << 6) + mid) << 6) + low; + len = 3; + } else + len = 2; + } + break; + } + + /* update position in utf-text */ + *utf_ptr = (char *) (utf + len); + + return unicode_char; +} + + +/* utf_bytes ******************************************************************* + + Determine number of bytes (aka. octets) in the utf string. + + IN: + u............utf string + + OUT: + The number of octets of this utf string. + There is _no_ terminating zero included in this count. + +*******************************************************************************/ + +u4 utf_bytes(utf *u) +{ + return u->blength; +} + + +/* utf_get_number_of_u2s_for_buffer ******************************************** + + Determine number of UTF-16 u2s in the given UTF-8 buffer + + CAUTION: This function is unsafe for input that was not checked + by is_valid_utf! + + CAUTION: Use this function *only* when you want to convert an UTF-8 buffer + to an array of u2s (UTF-16) and want to know how many of them you will get. + All other uses of this function are probably wrong. + + IN: + buffer........points to first char in buffer + blength.......number of _bytes_ in the buffer + + OUT: + the number of u2s needed to hold this string in UTF-16 encoding. + There is _no_ terminating zero included in this count. + + NOTE: Unlike utf_get_number_of_u2s, this function never throws an + exception. + +*******************************************************************************/ + +u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength) +{ + const char *endpos; /* points behind utf string */ + const char *utf_ptr; /* current position in utf text */ + u4 len = 0; /* number of unicode characters */ + + utf_ptr = buffer; + endpos = utf_ptr + blength; + + while (utf_ptr < endpos) { + len++; + /* next unicode character */ + utf_nextu2((char **)&utf_ptr); + } + + assert(utf_ptr == endpos); + + return len; +} + + +/* utf_get_number_of_u2s ******************************************************* + + Determine number of UTF-16 u2s in the utf string. + + CAUTION: This function is unsafe for input that was not checked + by is_valid_utf! + + CAUTION: Use this function *only* when you want to convert a utf string + to an array of u2s and want to know how many of them you will get. + All other uses of this function are probably wrong. + + IN: + u............utf string + + OUT: + the number of u2s needed to hold this string in UTF-16 encoding. + There is _no_ terminating zero included in this count. + XXX 0 if a NullPointerException has been thrown (see below) + +*******************************************************************************/ + +u4 utf_get_number_of_u2s(utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + u4 len = 0; /* number of unicode characters */ + + /* XXX this is probably not checked by most callers! Review this after */ + /* the invalid uses of this function have been eliminated */ + if (u == NULL) { + exceptions_throw_nullpointerexception(); + return 0; + } + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) { + len++; + /* next unicode character */ + utf_nextu2(&utf_ptr); + } + + if (utf_ptr != endpos) { + /* string ended abruptly */ + exceptions_throw_internalerror("Illegal utf8 string"); + return 0; + } + + return len; +} + + +/* utf8_safe_number_of_u2s ***************************************************** + + Determine number of UTF-16 u2s needed for decoding the given UTF-8 string. + (For invalid UTF-8 the U+fffd replacement character will be counted.) + + This function is safe even for invalid UTF-8 strings. + + IN: + text..........zero-terminated(!) UTF-8 string (may be invalid) + must NOT be NULL + nbytes........strlen(text). (This is needed to completely emulate + the RI). + + OUT: + the number of u2s needed to hold this string in UTF-16 encoding. + There is _no_ terminating zero included in this count. + +*******************************************************************************/ + +s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes) { + register const unsigned char *t; + register s4 byte; + register s4 len; + register const unsigned char *tlimit; + s4 byte1; + s4 byte2; + s4 byte3; + s4 value; + s4 skip; + + assert(text); + assert(nbytes >= 0); + + len = 0; + t = (const unsigned char *) text; + tlimit = t + nbytes; + + /* CAUTION: Keep this code in sync with utf8_safe_convert_to_u2s! */ + + while (1) { + byte = *t++; + + if (byte & 0x80) { + /* highest bit set, non-ASCII character */ + + if ((byte & 0xe0) == 0xc0) { + /* 2-byte: should be 110..... 10...... ? */ + + if ((*t++ & 0xc0) == 0x80) + ; /* valid 2-byte */ + else + t--; /* invalid */ + } + else if ((byte & 0xf0) == 0xe0) { + /* 3-byte: should be 1110.... 10...... 10...... */ + /* ^t */ + + if (t + 2 > tlimit) + return len + 1; /* invalid, stop here */ + + if ((*t++ & 0xc0) == 0x80) { + if ((*t++ & 0xc0) == 0x80) + ; /* valid 3-byte */ + else + t--; /* invalid */ + } + else + t--; /* invalid */ + } + else if ((byte & 0xf8) == 0xf0) { + /* 4-byte: should be 11110... 10...... 10...... 10...... */ + /* ^t */ + + if (t + 3 > tlimit) + return len + 1; /* invalid, stop here */ + + if (((byte1 = *t++) & 0xc0) == 0x80) { + if (((byte2 = *t++) & 0xc0) == 0x80) { + if (((byte3 = *t++) & 0xc0) == 0x80) { + /* valid 4-byte UTF-8? */ + value = ((byte & 0x07) << 18) + | ((byte1 & 0x3f) << 12) + | ((byte2 & 0x3f) << 6) + | ((byte3 & 0x3f) ); + + if (value > 0x10FFFF) + ; /* invalid */ + else if (value > 0xFFFF) + len += 1; /* we need surrogates */ + else + ; /* 16bit suffice */ + } + else + t--; /* invalid */ + } + else + t--; /* invalid */ + } + else + t--; /* invalid */ + } + else if ((byte & 0xfc) == 0xf8) { + /* invalid 5-byte */ + if (t + 4 > tlimit) + return len + 1; /* invalid, stop here */ + + skip = 4; + for (; skip && ((*t & 0xc0) == 0x80); --skip) + t++; + } + else if ((byte & 0xfe) == 0xfc) { + /* invalid 6-byte */ + if (t + 5 > tlimit) + return len + 1; /* invalid, stop here */ + + skip = 5; + for (; skip && ((*t & 0xc0) == 0x80); --skip) + t++; + } + else + ; /* invalid */ + } + else { + /* NUL */ + + if (byte == 0) + break; + + /* ASCII character, common case */ + } + + len++; + } + + return len; +} + + +/* utf8_safe_convert_to_u2s **************************************************** + + Convert the given UTF-8 string to UTF-16 into a pre-allocated buffer. + (Invalid UTF-8 will be replaced with the U+fffd replacement character.) + Use utf8_safe_number_of_u2s to determine the number of u2s to allocate. + + This function is safe even for invalid UTF-8 strings. + + IN: + text..........zero-terminated(!) UTF-8 string (may be invalid) + must NOT be NULL + nbytes........strlen(text). (This is needed to completely emulate + the RI). + buffer........a preallocated array of u2s to receive the decoded + string. Use utf8_safe_number_of_u2s to get the + required number of u2s for allocating this. + +*******************************************************************************/ + +#define UNICODE_REPLACEMENT 0xfffd + +void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer) { + register const unsigned char *t; + register s4 byte; + register const unsigned char *tlimit; + s4 byte1; + s4 byte2; + s4 byte3; + s4 value; + s4 skip; + + assert(text); + assert(nbytes >= 0); + + t = (const unsigned char *) text; + tlimit = t + nbytes; + + /* CAUTION: Keep this code in sync with utf8_safe_number_of_u2s! */ + + while (1) { + byte = *t++; + + if (byte & 0x80) { + /* highest bit set, non-ASCII character */ + + if ((byte & 0xe0) == 0xc0) { + /* 2-byte: should be 110..... 10...... */ + + if (((byte1 = *t++) & 0xc0) == 0x80) { + /* valid 2-byte UTF-8 */ + *buffer++ = ((byte & 0x1f) << 6) + | ((byte1 & 0x3f) ); + } + else { + *buffer++ = UNICODE_REPLACEMENT; + t--; + } + } + else if ((byte & 0xf0) == 0xe0) { + /* 3-byte: should be 1110.... 10...... 10...... */ + + if (t + 2 > tlimit) { + *buffer++ = UNICODE_REPLACEMENT; + return; + } + + if (((byte1 = *t++) & 0xc0) == 0x80) { + if (((byte2 = *t++) & 0xc0) == 0x80) { + /* valid 3-byte UTF-8 */ + *buffer++ = ((byte & 0x0f) << 12) + | ((byte1 & 0x3f) << 6) + | ((byte2 & 0x3f) ); + } + else { + *buffer++ = UNICODE_REPLACEMENT; + t--; + } + } + else { + *buffer++ = UNICODE_REPLACEMENT; + t--; + } + } + else if ((byte & 0xf8) == 0xf0) { + /* 4-byte: should be 11110... 10...... 10...... 10...... */ + + if (t + 3 > tlimit) { + *buffer++ = UNICODE_REPLACEMENT; + return; + } + + if (((byte1 = *t++) & 0xc0) == 0x80) { + if (((byte2 = *t++) & 0xc0) == 0x80) { + if (((byte3 = *t++) & 0xc0) == 0x80) { + /* valid 4-byte UTF-8? */ + value = ((byte & 0x07) << 18) + | ((byte1 & 0x3f) << 12) + | ((byte2 & 0x3f) << 6) + | ((byte3 & 0x3f) ); + + if (value > 0x10FFFF) { + *buffer++ = UNICODE_REPLACEMENT; + } + else if (value > 0xFFFF) { + /* we need surrogates */ + *buffer++ = 0xd800 | ((value >> 10) - 0x40); + *buffer++ = 0xdc00 | (value & 0x03ff); + } + else + *buffer++ = value; /* 16bit suffice */ + } + else { + *buffer++ = UNICODE_REPLACEMENT; + t--; + } + } + else { + *buffer++ = UNICODE_REPLACEMENT; + t--; + } + } + else { + *buffer++ = UNICODE_REPLACEMENT; + t--; + } + } + else if ((byte & 0xfc) == 0xf8) { + if (t + 4 > tlimit) { + *buffer++ = UNICODE_REPLACEMENT; + return; + } + + skip = 4; + for (; skip && ((*t & 0xc0) == 0x80); --skip) + t++; + *buffer++ = UNICODE_REPLACEMENT; + } + else if ((byte & 0xfe) == 0xfc) { + if (t + 5 > tlimit) { + *buffer++ = UNICODE_REPLACEMENT; + return; + } + + skip = 5; + for (; skip && ((*t & 0xc0) == 0x80); --skip) + t++; + *buffer++ = UNICODE_REPLACEMENT; + } + else + *buffer++ = UNICODE_REPLACEMENT; + } + else { + /* NUL */ + + if (byte == 0) + break; + + /* ASCII character, common case */ + + *buffer++ = byte; + } + } +} + + +/* u2_utflength **************************************************************** + + Returns the utf length in bytes of a u2 array. + +*******************************************************************************/ + +u4 u2_utflength(u2 *text, u4 u2_length) +{ + u4 result_len = 0; /* utf length in bytes */ + u2 ch; /* current unicode character */ + u4 len; + + for (len = 0; len < u2_length; len++) { + /* next unicode character */ + ch = *text++; + + /* determine bytes required to store unicode character as utf */ + if (ch && (ch < 0x80)) + result_len++; + else if (ch < 0x800) + result_len += 2; + else + result_len += 3; + } + + return result_len; +} + + +/* utf_copy ******************************************************************** + + Copy the given utf string byte-for-byte to a buffer. + + IN: + buffer.......the buffer + u............the utf string + +*******************************************************************************/ + +void utf_copy(char *buffer, utf *u) +{ + /* our utf strings are zero-terminated (done by utf_new) */ + MCOPY(buffer, u->text, char, u->blength + 1); +} + + +/* utf_cat ********************************************************************* + + Append the given utf string byte-for-byte to a buffer. + + IN: + buffer.......the buffer + u............the utf string + +*******************************************************************************/ + +void utf_cat(char *buffer, utf *u) +{ + /* our utf strings are zero-terminated (done by utf_new) */ + MCOPY(buffer + strlen(buffer), u->text, char, u->blength + 1); +} + + +/* utf_copy_classname ********************************************************** + + Copy the given utf classname byte-for-byte to a buffer. + '/' is replaced by '.' + + IN: + buffer.......the buffer + u............the utf string + +*******************************************************************************/ + +void utf_copy_classname(char *buffer, utf *u) +{ + char *bufptr; + char *srcptr; + char *endptr; + char ch; + + bufptr = buffer; + srcptr = u->text; + endptr = UTF_END(u) + 1; /* utfs are zero-terminared by utf_new */ + + while (srcptr != endptr) { + ch = *srcptr++; + if (ch == '/') + ch = '.'; + *bufptr++ = ch; + } +} + + +/* utf_cat ********************************************************************* + + Append the given utf classname byte-for-byte to a buffer. + '/' is replaced by '.' + + IN: + buffer.......the buffer + u............the utf string + +*******************************************************************************/ + +void utf_cat_classname(char *buffer, utf *u) +{ + utf_copy_classname(buffer + strlen(buffer), u); +} + +/* utf_display_printable_ascii ************************************************* + + Write utf symbol to stdout (for debugging purposes). + Non-printable and non-ASCII characters are printed as '?'. + +*******************************************************************************/ + +void utf_display_printable_ascii(utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + + if (u == NULL) { + printf("NULL"); + fflush(stdout); + return; + } + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) { + /* read next unicode character */ + + u2 c = utf_nextu2(&utf_ptr); + + if ((c >= 32) && (c <= 127)) + printf("%c", c); + else + printf("?"); + } + + fflush(stdout); +} + + +/* utf_display_printable_ascii_classname *************************************** + + Write utf symbol to stdout with `/' converted to `.' (for debugging + purposes). + Non-printable and non-ASCII characters are printed as '?'. + +*******************************************************************************/ + +void utf_display_printable_ascii_classname(utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + + if (u == NULL) { + printf("NULL"); + fflush(stdout); + return; + } + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) { + /* read next unicode character */ + + u2 c = utf_nextu2(&utf_ptr); + + if (c == '/') + c = '.'; + + if ((c >= 32) && (c <= 127)) + printf("%c", c); + else + printf("?"); + } + + fflush(stdout); +} + + +/* utf_sprint_convert_to_latin1 ************************************************ + + Write utf symbol into c-string (for debugging purposes). + Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield + invalid results. + +*******************************************************************************/ + +void utf_sprint_convert_to_latin1(char *buffer, utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + u2 pos = 0; /* position in c-string */ + + if (!u) { + strcpy(buffer, "NULL"); + return; + } + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) + /* copy next unicode character */ + buffer[pos++] = utf_nextu2(&utf_ptr); + + /* terminate string */ + buffer[pos] = '\0'; +} + + +/* utf_sprint_convert_to_latin1_classname ************************************** + + Write utf symbol into c-string with `/' converted to `.' (for debugging + purposes). + Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield + invalid results. + +*******************************************************************************/ + +void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + u2 pos = 0; /* position in c-string */ + + if (!u) { + strcpy(buffer, "NULL"); + return; + } + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) { + /* copy next unicode character */ + u2 c = utf_nextu2(&utf_ptr); + if (c == '/') c = '.'; + buffer[pos++] = c; + } + + /* terminate string */ + buffer[pos] = '\0'; +} + + +/* utf_strcat_convert_to_latin1 ************************************************ + + Like libc strcat, but uses an utf8 string. + Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield + invalid results. + +*******************************************************************************/ + +void utf_strcat_convert_to_latin1(char *buffer, utf *u) +{ + utf_sprint_convert_to_latin1(buffer + strlen(buffer), u); +} + + +/* utf_strcat_convert_to_latin1_classname ************************************** + + Like libc strcat, but uses an utf8 string. + Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield + invalid results. + +*******************************************************************************/ + +void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u) +{ + utf_sprint_convert_to_latin1_classname(buffer + strlen(buffer), u); +} + + +/* utf_fprint_printable_ascii ************************************************** + + Write utf symbol into file. + Non-printable and non-ASCII characters are printed as '?'. + +*******************************************************************************/ + +void utf_fprint_printable_ascii(FILE *file, utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + + if (!u) + return; + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) { + /* read next unicode character */ + u2 c = utf_nextu2(&utf_ptr); + + if (c >= 32 && c <= 127) fprintf(file, "%c", c); + else fprintf(file, "?"); + } +} + + +/* utf_fprint_printable_ascii_classname **************************************** + + Write utf symbol into file with `/' converted to `.'. + Non-printable and non-ASCII characters are printed as '?'. + +*******************************************************************************/ + +void utf_fprint_printable_ascii_classname(FILE *file, utf *u) +{ + char *endpos; /* points behind utf string */ + char *utf_ptr; /* current position in utf text */ + + if (!u) + return; + + endpos = UTF_END(u); + utf_ptr = u->text; + + while (utf_ptr < endpos) { + /* read next unicode character */ + u2 c = utf_nextu2(&utf_ptr); + if (c == '/') c = '.'; + + if (c >= 32 && c <= 127) fprintf(file, "%c", c); + else fprintf(file, "?"); + } +} + + +/* is_valid_utf **************************************************************** + + Return true if the given string is a valid UTF-8 string. + + utf_ptr...points to first character + end_pos...points after last character + +*******************************************************************************/ + +/* static unsigned long min_codepoint[6] = {0,1L<<7,1L<<11,1L<<16,1L<<21,1L<<26}; */ + +bool is_valid_utf(char *utf_ptr, char *end_pos) +{ + int bytes; + int len,i; + char c; + unsigned long v; + + if (end_pos < utf_ptr) return false; + bytes = end_pos - utf_ptr; + while (bytes--) { + c = *utf_ptr++; + + if (!c) return false; /* 0x00 is not allowed */ + if ((c & 0x80) == 0) continue; /* ASCII */ + + if ((c & 0xe0) == 0xc0) len = 1; /* 110x xxxx */ + else if ((c & 0xf0) == 0xe0) len = 2; /* 1110 xxxx */ + else if ((c & 0xf8) == 0xf0) len = 3; /* 1111 0xxx */ + else if ((c & 0xfc) == 0xf8) len = 4; /* 1111 10xx */ + else if ((c & 0xfe) == 0xfc) len = 5; /* 1111 110x */ + else return false; /* invalid leading byte */ + + if (len > 2) return false; /* Java limitation */ + + v = (unsigned long)c & (0x3f >> len); + + if ((bytes -= len) < 0) return false; /* missing bytes */ + + for (i = len; i--; ) { + c = *utf_ptr++; + if ((c & 0xc0) != 0x80) /* 10xx xxxx */ + return false; + v = (v << 6) | (c & 0x3f); + } + + if (v == 0) { + if (len != 1) return false; /* Java special */ + + } else { + /* Sun Java seems to allow overlong UTF-8 encodings */ + + /* if (v < min_codepoint[len]) */ + /* XXX throw exception? */ + } + + /* surrogates in UTF-8 seem to be allowed in Java classfiles */ + /* if (v >= 0xd800 && v <= 0xdfff) return false; */ /* surrogates */ + + /* even these seem to be allowed */ + /* if (v == 0xfffe || v == 0xffff) return false; */ /* invalid codepoints */ + } + + return true; +} + + +/* is_valid_name *************************************************************** + + Return true if the given string may be used as a class/field/method + name. (Currently this only disallows empty strings and control + characters.) + + NOTE: The string is assumed to have passed is_valid_utf! + + utf_ptr...points to first character + end_pos...points after last character + +*******************************************************************************/ + +bool is_valid_name(char *utf_ptr, char *end_pos) +{ + if (end_pos <= utf_ptr) return false; /* disallow empty names */ + + while (utf_ptr < end_pos) { + unsigned char c = *utf_ptr++; + + if (c < 0x20) return false; /* disallow control characters */ + if (c == 0xc0 && (unsigned char) *utf_ptr == 0x80) /* disallow zero */ + return false; + } + + return true; +} + +bool is_valid_name_utf(utf *u) +{ + return is_valid_name(u->text, UTF_END(u)); +} + + +/* utf_show ******************************************************************** + + Writes the utf symbols in the utfhash to stdout and displays the + number of external hash chains grouped according to the chainlength + (for debugging purposes). + +*******************************************************************************/ + +#if !defined(NDEBUG) +void utf_show(void) +{ + +#define CHAIN_LIMIT 20 /* limit for seperated enumeration */ + + u4 chain_count[CHAIN_LIMIT]; /* numbers of chains */ + u4 max_chainlength = 0; /* maximum length of the chains */ + u4 sum_chainlength = 0; /* sum of the chainlengths */ + u4 beyond_limit = 0; /* number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */ + u4 i; + + printf("UTF-HASH:\n"); + + /* show element of utf-hashtable */ + + for (i = 0; i < hashtable_utf->size; i++) { + utf *u = hashtable_utf->ptr[i]; + + if (u) { + printf("SLOT %d: ", (int) i); + + while (u) { + printf("'"); + utf_display_printable_ascii(u); + printf("' "); + u = u->hashlink; + } + printf("\n"); + } + } + + printf("UTF-HASH: %d slots for %d entries\n", + (int) hashtable_utf->size, (int) hashtable_utf->entries ); + + if (hashtable_utf->entries == 0) + return; + + printf("chains:\n chainlength number of chains %% of utfstrings\n"); + + for (i=0;isize; i++) { + + utf *u = (utf*) hashtable_utf->ptr[i]; + u4 chain_length = 0; + + /* determine chainlength */ + while (u) { + u = u->hashlink; + chain_length++; + } + + /* update sum of all chainlengths */ + sum_chainlength+=chain_length; + + /* determine the maximum length of the chains */ + if (chain_length>max_chainlength) + max_chainlength = chain_length; + + /* update number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */ + if (chain_length>=CHAIN_LIMIT) { + beyond_limit+=chain_length; + chain_length=CHAIN_LIMIT-1; + } + + /* update number of hashchains of current length */ + chain_count[chain_length]++; + } + + /* display results */ + for (i=1;ientries)); + + printf(" >=%2d %17d %18.2f%%\n",CHAIN_LIMIT-1,chain_count[CHAIN_LIMIT-1],((float) beyond_limit*100)/hashtable_utf->entries); + + + printf("max. chainlength:%5d\n",max_chainlength); + + /* avg. chainlength = sum of chainlengths / number of chains */ + printf("avg. chainlength:%5.2f\n",(float) sum_chainlength / (hashtable_utf->size-chain_count[0])); +} +#endif /* !defined(NDEBUG) */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/utf8.h b/src/vm/utf8.h new file mode 100644 index 000000000..8a1197ebf --- /dev/null +++ b/src/vm/utf8.h @@ -0,0 +1,315 @@ +/* src/vm/utf8.h - utf8 string functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _UTF_H +#define _UTF_H + +/* forward typedefs ***********************************************************/ + +typedef struct utf utf; + +#include "config.h" + +#include + +#include "vm/types.h" + +#include "vm/global.h" + + +/* data structure for utf8 symbols ********************************************/ + +struct utf { + utf *hashlink; /* link for external hash chain */ + s4 blength; /* text length in bytes */ + char *text; /* pointer to text */ +}; + +/* to determine the end of utf strings */ + +#define UTF_END(u) ((char *) u->text + u->blength) + + +/* utf-symbols for pointer comparison of frequently used strings **************/ + +extern utf *utf_java_lang_Object; + +extern utf *utf_java_lang_Class; +extern utf *utf_java_lang_ClassLoader; +extern utf *utf_java_lang_Cloneable; +extern utf *utf_java_lang_SecurityManager; +extern utf *utf_java_lang_String; +extern utf *utf_java_lang_ThreadGroup; +extern utf *utf_java_lang_ref_SoftReference; +extern utf *utf_java_lang_ref_WeakReference; +extern utf *utf_java_lang_ref_PhantomReference; +extern utf *utf_java_io_Serializable; + +extern utf *utf_java_lang_Throwable; +extern utf *utf_java_lang_Error; + +extern utf *utf_java_lang_AbstractMethodError; +extern utf *utf_java_lang_ClassCircularityError; +extern utf *utf_java_lang_ClassFormatError; +extern utf *utf_java_lang_ExceptionInInitializerError; +extern utf *utf_java_lang_IncompatibleClassChangeError; +extern utf *utf_java_lang_InstantiationError; +extern utf *utf_java_lang_InternalError; +extern utf *utf_java_lang_LinkageError; +extern utf *utf_java_lang_NoClassDefFoundError; +extern utf *utf_java_lang_NoSuchFieldError; +extern utf *utf_java_lang_NoSuchMethodError; +extern utf *utf_java_lang_OutOfMemoryError; +extern utf *utf_java_lang_UnsatisfiedLinkError; +extern utf *utf_java_lang_UnsupportedClassVersionError; +extern utf *utf_java_lang_VerifyError; +extern utf *utf_java_lang_VirtualMachineError; + +extern utf *utf_java_lang_Exception; + +extern utf *utf_java_lang_ArithmeticException; +extern utf *utf_java_lang_ArrayIndexOutOfBoundsException; +extern utf *utf_java_lang_ArrayStoreException; +extern utf *utf_java_lang_ClassCastException; +extern utf *utf_java_lang_ClassNotFoundException; +extern utf *utf_java_lang_CloneNotSupportedException; +extern utf *utf_java_lang_IllegalAccessException; +extern utf *utf_java_lang_IllegalArgumentException; +extern utf *utf_java_lang_IllegalMonitorStateException; +extern utf *utf_java_lang_InstantiationException; +extern utf *utf_java_lang_InterruptedException; +extern utf *utf_java_lang_NegativeArraySizeException; +extern utf *utf_java_lang_NullPointerException; +extern utf *utf_java_lang_RuntimeException; +extern utf *utf_java_lang_StringIndexOutOfBoundsException; + +extern utf *utf_java_lang_reflect_InvocationTargetException; + +extern utf *utf_java_security_PrivilegedActionException; + +#if defined(ENABLE_JAVASE) +extern utf* utf_java_lang_Void; +#endif + +extern utf* utf_java_lang_Boolean; +extern utf* utf_java_lang_Byte; +extern utf* utf_java_lang_Character; +extern utf* utf_java_lang_Short; +extern utf* utf_java_lang_Integer; +extern utf* utf_java_lang_Long; +extern utf* utf_java_lang_Float; +extern utf* utf_java_lang_Double; + +#if defined(ENABLE_JAVASE) +extern utf *utf_java_lang_StackTraceElement; +extern utf *utf_java_lang_reflect_Constructor; +extern utf *utf_java_lang_reflect_Field; +extern utf *utf_java_lang_reflect_Method; + +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) +extern utf *utf_java_lang_reflect_VMConstructor; +extern utf *utf_java_lang_reflect_VMField; +extern utf *utf_java_lang_reflect_VMMethod; +# endif + +extern utf *utf_java_util_Vector; +#endif + +extern utf *utf_InnerClasses; +extern utf *utf_ConstantValue; +extern utf *utf_Code; +extern utf *utf_Exceptions; +extern utf *utf_LineNumberTable; +extern utf *utf_SourceFile; + +#if defined(ENABLE_JAVASE) +extern utf *utf_EnclosingMethod; +extern utf *utf_Signature; +extern utf *utf_StackMapTable; + +#if defined(ENABLE_ANNOTATIONS) +extern utf *utf_RuntimeVisibleAnnotations; +extern utf *utf_RuntimeInvisibleAnnotations; +extern utf *utf_RuntimeVisibleParameterAnnotations; +extern utf *utf_RuntimeInvisibleParameterAnnotations; +extern utf *utf_AnnotationDefault; +#endif +#endif + +extern utf *utf_init; +extern utf *utf_clinit; +extern utf *utf_clone; +extern utf *utf_finalize; +extern utf *utf_invoke; +extern utf *utf_main; +extern utf *utf_run; + +extern utf *utf_add; +extern utf *utf_dispatch; +extern utf *utf_remove; +extern utf *utf_addThread; +extern utf *utf_removeThread; +extern utf *utf_put; +extern utf *utf_get; +extern utf *utf_uncaughtException; +extern utf *utf_value; + +extern utf *utf_fillInStackTrace; +extern utf *utf_findNative; +extern utf *utf_getSystemClassLoader; +extern utf *utf_initCause; +extern utf *utf_loadClass; +extern utf *utf_loadClassInternal; +extern utf *utf_printStackTrace; + +extern utf *utf_division_by_zero; + +extern utf *utf_Z; +extern utf *utf_B; +extern utf *utf_C; +extern utf *utf_S; +extern utf *utf_I; +extern utf *utf_J; +extern utf *utf_F; +extern utf *utf_D; + +extern utf *utf_void__void; +extern utf *utf_boolean__void; +extern utf *utf_byte__void; +extern utf *utf_char__void; +extern utf *utf_short__void; +extern utf *utf_int__void; +extern utf *utf_long__void; +extern utf *utf_float__void; +extern utf *utf_double__void; + +extern utf *utf_void__java_lang_ClassLoader; +extern utf *utf_void__java_lang_Object; +extern utf *utf_void__java_lang_Throwable; +extern utf *utf_java_lang_ClassLoader_java_lang_String__J; +extern utf *utf_java_lang_Exception__V; +extern utf *utf_java_lang_Object__java_lang_Object; +extern utf *utf_java_lang_String__void; +extern utf *utf_java_lang_String__java_lang_Class; +extern utf *utf_java_lang_Thread__V; +extern utf *utf_java_lang_Thread_java_lang_Throwable__V; +extern utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V; +extern utf *utf_java_lang_Throwable__void; +extern utf *utf_java_lang_Throwable__java_lang_Throwable; + +extern utf *utf_not_named_yet; +extern utf *utf_null; +extern utf *array_packagename; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* initialize the utf8 subsystem */ +void utf8_init(void); + +u4 utf_hashkey(const char *text, u4 length); +u4 utf_full_hashkey(const char *text, u4 length); + +/* determine hashkey of a unicode-symbol */ +u4 unicode_hashkey(u2 *text, u2 length); + +/* create new utf-symbol */ +utf *utf_new(const char *text, u2 length); + +/* make utf symbol from u2 array */ +utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname); + +utf *utf_new_char(const char *text); +utf *utf_new_char_classname(const char *text); + +/* get number of bytes */ +u4 utf_bytes(utf *u); + +/* get next unicode character of a utf-string */ +u2 utf_nextu2(char **utf); + +/* get (number of) unicode characters of a utf string (safe) */ +s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes); +void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer); + +/* get (number of) unicode characters of a utf string (UNSAFE!) */ +u4 utf_get_number_of_u2s(utf *u); +u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength); + +/* determine utf length in bytes of a u2 array */ +u4 u2_utflength(u2 *text, u4 u2_length); + +void utf_copy(char *buffer, utf *u); +void utf_cat(char *buffer, utf *u); +void utf_copy_classname(char *buffer, utf *u); +void utf_cat_classname(char *buffer, utf *u); + +/* write utf symbol to file/buffer */ +void utf_display_printable_ascii(utf *u); +void utf_display_printable_ascii_classname(utf *u); + +void utf_sprint_convert_to_latin1(char *buffer, utf *u); +void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u); + +void utf_strcat_convert_to_latin1(char *buffer, utf *u); +void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u); + +void utf_fprint_printable_ascii(FILE *file, utf *u); +void utf_fprint_printable_ascii_classname(FILE *file, utf *u); + +/* check if a UTF-8 string is valid */ +bool is_valid_utf(char *utf_ptr, char *end_pos); + +/* check if a UTF-8 string may be used as a class/field/method name */ +bool is_valid_name(char *utf_ptr, char *end_pos); +bool is_valid_name_utf(utf *u); + +/* show utf-table */ +void utf_show(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _UTF_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/vm.c b/src/vm/vm.c deleted file mode 100644 index 0a6536aa9..000000000 --- a/src/vm/vm.c +++ /dev/null @@ -1,2668 +0,0 @@ -/* src/vm/vm.c - VM startup and shutdown functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include - -#include "vm/types.h" - -#include "arch.h" -#include "md-abi.h" - -#include "vm/jit/abi-asm.h" - -#include "mm/codememory.h" -#include "mm/gc-common.h" -#include "mm/memory.h" - -#include "native/jni.h" -#include "native/llni.h" -#include "native/localref.h" -#include "native/native.h" - -#include "native/include/java_lang_Object.h" /* required by j.l.C */ -#include "native/include/java_lang_String.h" /* required by j.l.C */ - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -# include "native/include/java_nio_ByteBuffer.h" /* required by j.l.CL */ -# include "native/include/java_lang_ClassLoader.h" /* required by j.l.C */ -#endif - -#include "native/include/java_lang_Class.h" - -#include "native/vm/nativevm.h" - -#include "threads/lock-common.h" -#include "threads/mutex.h" -#include "threads/threadlist.h" -#include "threads/thread.h" - -#include "toolbox/logging.h" - -#include "vm/array.h" - -#if defined(ENABLE_ASSERTION) -#include "vm/assertion.h" -#endif - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/finalizer.h" -#include "vm/global.h" -#include "vm/initialize.h" -#include "vm/package.h" -#include "vm/primitive.h" -#include "vm/properties.h" -#include "vm/signallocal.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit/argument.h" -#include "vm/jit/asmpart.h" -#include "vm/jit/code.h" - -#if defined(ENABLE_DISASSEMBLER) -# include "vm/jit/disass.h" -#endif - -#include "vm/jit/jit.h" -#include "vm/jit/methodtree.h" - -#if defined(ENABLE_PROFILING) -# include "vm/jit/optimizing/profile.h" -#endif - -#include "vm/jit/optimizing/recompile.h" - -#if defined(ENABLE_PYTHON) -# include "vm/jit/python.h" -#endif - -#include "vm/jit/trap.h" - -#include "vmcore/classcache.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" -#include "vmcore/suck.h" -#include "vmcore/system.h" - -#if defined(ENABLE_JVMTI) -# include "native/jvmti/cacaodbg.h" -#endif - -#if defined(ENABLE_VMLOG) -#include -#endif - - -/* Invocation API variables ***************************************************/ - -_Jv_JavaVM *_Jv_jvm; /* denotes a Java VM */ -_Jv_JNIEnv *_Jv_env; /* pointer to native method interface */ - - -/* global variables ***********************************************************/ - -s4 vms = 0; /* number of VMs created */ - -bool vm_initializing = false; -bool vm_created = false; -bool vm_exiting = false; - -static classinfo *mainclass = NULL; - -#if defined(ENABLE_INTRP) -u1 *intrp_main_stack = NULL; -#endif - - -/* define heap sizes **********************************************************/ - -#define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */ -#define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */ -#define STACK_SIZE 128 * 1024 /* default 64kB */ - - -/* define command line options ************************************************/ - -enum { - OPT_FOO, - - /* Java options */ - - OPT_JAR, - - OPT_D32, - OPT_D64, - - OPT_CLASSPATH, - OPT_D, - - OPT_VERBOSE, - - OPT_VERSION, - OPT_SHOWVERSION, - OPT_FULLVERSION, - - OPT_HELP, - OPT_X, - OPT_XX, - - OPT_EA, - OPT_DA, - OPT_EA_NOARG, - OPT_DA_NOARG, - - - OPT_ESA, - OPT_DSA, - - /* Java non-standard options */ - - OPT_JIT, - OPT_INTRP, - - OPT_BOOTCLASSPATH, - OPT_BOOTCLASSPATH_A, - OPT_BOOTCLASSPATH_P, - - OPT_BOOTCLASSPATH_C, - -#if defined(ENABLE_PROFILING) - OPT_PROF, - OPT_PROF_OPTION, -#endif - - OPT_MS, - OPT_MX, - - /* CACAO options */ - - OPT_VERBOSE1, - OPT_NOIEEE, - -#if defined(ENABLE_STATISTICS) - OPT_TIME, - OPT_STAT, -#endif - - OPT_LOG, - OPT_CHECK, - OPT_LOAD, - OPT_SHOW, - OPT_DEBUGCOLOR, - -#if !defined(NDEBUG) - OPT_ALL, - OPT_METHOD, - OPT_SIGNATURE, -#endif - -#if defined(ENABLE_VERIFIER) - OPT_NOVERIFY, -#if defined(TYPECHECK_VERBOSE) - OPT_VERBOSETC, -#endif -#endif /* defined(ENABLE_VERIFIER) */ - - /* optimization options */ - -#if defined(ENABLE_LOOP) - OPT_OLOOP, -#endif - -#if defined(ENABLE_IFCONV) - OPT_IFCONV, -#endif - -#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) - OPT_LSRA, -#endif - -#if defined(ENABLE_INTRP) - /* interpreter options */ - - OPT_NO_DYNAMIC, - OPT_NO_REPLICATION, - OPT_NO_QUICKSUPER, - OPT_STATIC_SUPERS, - OPT_TRACE, -#endif - - OPT_SS, - -#ifdef ENABLE_JVMTI - OPT_DEBUG, - OPT_XRUNJDWP, - OPT_NOAGENT, - OPT_AGENTLIB, - OPT_AGENTPATH, -#endif - -#if defined(ENABLE_DEBUG_FILTER) - OPT_FILTER_VERBOSECALL_INCLUDE, - OPT_FILTER_VERBOSECALL_EXCLUDE, - OPT_FILTER_SHOW_METHOD, -#endif - - DUMMY -}; - - -opt_struct opts[] = { - { "foo", false, OPT_FOO }, - - /* Java options */ - - { "jar", false, OPT_JAR }, - - { "d32", false, OPT_D32 }, - { "d64", false, OPT_D64 }, - { "client", false, OPT_IGNORE }, - { "server", false, OPT_IGNORE }, - { "jvm", false, OPT_IGNORE }, - { "hotspot", false, OPT_IGNORE }, - - { "classpath", true, OPT_CLASSPATH }, - { "cp", true, OPT_CLASSPATH }, - { "D", true, OPT_D }, - { "version", false, OPT_VERSION }, - { "showversion", false, OPT_SHOWVERSION }, - { "fullversion", false, OPT_FULLVERSION }, - { "help", false, OPT_HELP }, - { "?", false, OPT_HELP }, - { "X", false, OPT_X }, - { "XX:", true, OPT_XX }, - - { "ea:", true, OPT_EA }, - { "da:", true, OPT_DA }, - { "ea", false, OPT_EA_NOARG }, - { "da", false, OPT_DA_NOARG }, - - { "enableassertions:", true, OPT_EA }, - { "disableassertions:", true, OPT_DA }, - { "enableassertions", false, OPT_EA_NOARG }, - { "disableassertions", false, OPT_DA_NOARG }, - - { "esa", false, OPT_ESA }, - { "enablesystemassertions", false, OPT_ESA }, - { "dsa", false, OPT_DSA }, - { "disablesystemassertions", false, OPT_DSA }, - - { "noasyncgc", false, OPT_IGNORE }, -#if defined(ENABLE_VERIFIER) - { "noverify", false, OPT_NOVERIFY }, - { "Xverify:none", false, OPT_NOVERIFY }, -#endif - { "v", false, OPT_VERBOSE1 }, - { "verbose:", true, OPT_VERBOSE }, - -#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE) - { "verbosetc", false, OPT_VERBOSETC }, -#endif -#if defined(__ALPHA__) - { "noieee", false, OPT_NOIEEE }, -#endif -#if defined(ENABLE_STATISTICS) - { "time", false, OPT_TIME }, - { "stat", false, OPT_STAT }, -#endif - { "log", true, OPT_LOG }, - { "c", true, OPT_CHECK }, - { "l", false, OPT_LOAD }, - -#if !defined(NDEBUG) - { "all", false, OPT_ALL }, - { "sig", true, OPT_SIGNATURE }, -#endif - -#if defined(ENABLE_LOOP) - { "oloop", false, OPT_OLOOP }, -#endif -#if defined(ENABLE_IFCONV) - { "ifconv", false, OPT_IFCONV }, -#endif -#if defined(ENABLE_LSRA) - { "lsra", false, OPT_LSRA }, -#endif -#if defined(ENABLE_SSA) - { "lsra", true, OPT_LSRA }, -#endif - -#if defined(ENABLE_INTRP) - /* interpreter options */ - - { "trace", false, OPT_TRACE }, - { "static-supers", true, OPT_STATIC_SUPERS }, - { "no-dynamic", false, OPT_NO_DYNAMIC }, - { "no-replication", false, OPT_NO_REPLICATION }, - { "no-quicksuper", false, OPT_NO_QUICKSUPER }, -#endif - - /* JVMTI Agent Command Line Options */ -#ifdef ENABLE_JVMTI - { "agentlib:", true, OPT_AGENTLIB }, - { "agentpath:", true, OPT_AGENTPATH }, -#endif - - /* Java non-standard options */ - - { "Xjit", false, OPT_JIT }, - { "Xint", false, OPT_INTRP }, - { "Xbootclasspath:", true, OPT_BOOTCLASSPATH }, - { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A }, - { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P }, - { "Xbootclasspath/c:", true, OPT_BOOTCLASSPATH_C }, - -#ifdef ENABLE_JVMTI - { "Xdebug", false, OPT_DEBUG }, - { "Xnoagent", false, OPT_NOAGENT }, - { "Xrunjdwp", true, OPT_XRUNJDWP }, -#endif - - { "Xms", true, OPT_MS }, - { "ms", true, OPT_MS }, - { "Xmx", true, OPT_MX }, - { "mx", true, OPT_MX }, - { "Xss", true, OPT_SS }, - { "ss", true, OPT_SS }, - -#if defined(ENABLE_PROFILING) - { "Xprof:", true, OPT_PROF_OPTION }, - { "Xprof", false, OPT_PROF }, -#endif - - /* keep these at the end of the list */ - -#if !defined(NDEBUG) - { "m", true, OPT_METHOD }, -#endif - - { "s", true, OPT_SHOW }, - { "debug-color", false, OPT_DEBUGCOLOR }, - -#if defined(ENABLE_DEBUG_FILTER) - { "XXfi", true, OPT_FILTER_VERBOSECALL_INCLUDE }, - { "XXfx", true, OPT_FILTER_VERBOSECALL_EXCLUDE }, - { "XXfm", true, OPT_FILTER_SHOW_METHOD }, -#endif - - { NULL, false, 0 } -}; - - -/* usage *********************************************************************** - - Prints the correct usage syntax to stdout. - -*******************************************************************************/ - -void usage(void) -{ - puts("Usage: cacao [-options] classname [arguments]"); - puts(" (to run a class file)"); - puts(" or cacao [-options] -jar jarfile [arguments]"); - puts(" (to run a standalone jar file)\n"); - - puts("where options include:"); - puts(" -d32 use 32-bit data model if available"); - puts(" -d64 use 64-bit data model if available"); - puts(" -client compatibility (currently ignored)"); - puts(" -server compatibility (currently ignored)"); - puts(" -jvm compatibility (currently ignored)"); - puts(" -hotspot compatibility (currently ignored)\n"); - - puts(" -cp specify a path to look for classes"); - puts(" -classpath specify a path to look for classes"); - puts(" -D= add an entry to the property list"); - puts(" -verbose[:class|gc|jni] enable specific verbose output"); - puts(" -version print product version and exit"); - puts(" -fullversion print jpackage-compatible product version and exit"); - puts(" -showversion print product version and continue"); - puts(" -help, -? print this help message"); - puts(" -X print help on non-standard Java options"); - puts(" -XX print help on debugging options"); - puts(" -ea[:...|:]"); - puts(" -enableassertions[:...|:]"); - puts(" enable assertions with specified granularity"); - puts(" -da[:...|:]"); - puts(" -disableassertions[:...|:]"); - puts(" disable assertions with specified granularity"); - puts(" -esa | -enablesystemassertions"); - puts(" enable system assertions"); - puts(" -dsa | -disablesystemassertions"); - puts(" disable system assertions"); - -#ifdef ENABLE_JVMTI - puts(" -agentlib:= library to load containg JVMTI agent"); - puts (" for jdwp help use: -agentlib:jdwp=help"); - puts(" -agentpath:= path to library containg JVMTI agent"); -#endif - - /* exit with error code */ - - exit(1); -} - - -static void Xusage(void) -{ -#if defined(ENABLE_JIT) - puts(" -Xjit JIT mode execution (default)"); -#endif -#if defined(ENABLE_INTRP) - puts(" -Xint interpreter mode execution"); -#endif - puts(" -Xbootclasspath:"); - puts(" value is set as bootstrap class path"); - puts(" -Xbootclasspath/a:"); - puts(" value is appended to the bootstrap class path"); - puts(" -Xbootclasspath/p:"); - puts(" value is prepended to the bootstrap class path"); - puts(" -Xbootclasspath/c:"); - puts(" value is used as Java core library, but the"); - puts(" hardcoded VM interface classes are prepended"); - printf(" -Xms set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024); - printf(" -Xmx set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024); - printf(" -Xss set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024); - -#if defined(ENABLE_PROFILING) - puts(" -Xprof[:bb] collect and print profiling data"); -#endif - -#if defined(ENABLE_JVMTI) - /* -Xdebug option depend on gnu classpath JDWP options. options: - transport=dt_socket,address=,server=(y|n),suspend(y|n) */ - puts(" -Xdebug enable remote debugging\n"); - puts(" -Xrunjdwp transport=[dt_socket|...],address=,server=[y|n],suspend=[y|n]\n"); - puts(" enable remote debugging\n"); -#endif - - /* exit with error code */ - - exit(1); -} - - -#if 0 -static void XXusage(void) -{ - puts(" -v write state-information"); -#if !defined(NDEBUG) - puts(" -verbose:jit enable specific verbose output"); - puts(" -debug-color colored output for ANSI terms"); -#endif -#ifdef TYPECHECK_VERBOSE - puts(" -verbosetc write debug messages while typechecking"); -#endif -#if defined(__ALPHA__) - puts(" -noieee don't use ieee compliant arithmetic"); -#endif -#if defined(ENABLE_VERIFIER) - puts(" -noverify don't verify classfiles"); -#endif -#if defined(ENABLE_STATISTICS) - puts(" -time measure the runtime"); - puts(" -stat detailed compiler statistics"); -#endif - puts(" -log logfile specify a name for the logfile"); - puts(" -c(heck)b(ounds) don't check array bounds"); - puts(" s(ync) don't check for synchronization"); -#if defined(ENABLE_LOOP) - puts(" -oloop optimize array accesses in loops"); -#endif - puts(" -l don't start the class after loading"); -#if !defined(NDEBUG) - puts(" -all compile all methods, no execution"); - puts(" -m compile only a specific method"); - puts(" -sig specify signature for a specific method"); -#endif - - puts(" -s... show..."); - puts(" (c)onstants the constant pool"); - puts(" (m)ethods class fields and methods"); - puts(" (u)tf the utf - hash"); - puts(" (i)ntermediate intermediate representation"); -#if defined(ENABLE_DISASSEMBLER) - puts(" (a)ssembler disassembled listing"); - puts(" n(o)ps show NOPs in disassembler output"); -#endif - puts(" (d)atasegment data segment listing"); - -#if defined(ENABLE_IFCONV) - puts(" -ifconv use if-conversion"); -#endif -#if defined(ENABLE_LSRA) - puts(" -lsra use linear scan register allocation"); -#endif -#if defined(ENABLE_SSA) - puts(" -lsra:... use linear scan register allocation (with SSA)"); - puts(" (d)ead code elimination"); - puts(" (c)opy propagation"); -#endif -#if defined(ENABLE_DEBUG_FILTER) - puts(" -XXfi begin of dynamic scope for verbosecall filter"); - puts(" -XXfx end of dynamic scope for verbosecall filter"); - puts(" -XXfm filter for show options"); -#endif - /* exit with error code */ - - exit(1); -} -#endif - - -/* version ********************************************************************* - - Only prints cacao version information. - -*******************************************************************************/ - -static void version(bool opt_exit) -{ - puts("java version \""JAVA_VERSION"\""); - puts("CACAO version "VERSION"\n"); - - puts("Copyright (C) 1996-2005, 2006, 2007, 2008"); - puts("CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO"); - puts("This is free software; see the source for copying conditions. There is NO"); - puts("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); - - /* exit normally, if requested */ - - if (opt_exit) - exit(0); -} - - -/* fullversion ***************************************************************** - - Prints a Sun compatible version information (required e.g. by - jpackage, www.jpackage.org). - -*******************************************************************************/ - -static void fullversion(void) -{ - puts("java full version \"cacao-"JAVA_VERSION"\""); - - /* exit normally */ - - exit(0); -} - - -static void vm_printconfig(void) -{ - puts("Configure/Build options:\n"); - puts(" ./configure: "VERSION_CONFIGURE_ARGS""); -#if defined(__VERSION__) - puts(" CC : "VERSION_CC" ("__VERSION__")"); -#else - puts(" CC : "VERSION_CC""); -#endif - puts(" CFLAGS : "VERSION_CFLAGS"\n"); - - puts("Default variables:\n"); - printf(" maximum heap size : %d\n", HEAP_MAXSIZE); - printf(" initial heap size : %d\n", HEAP_STARTSIZE); - printf(" stack size : %d\n", STACK_SIZE); - -#if defined(ENABLE_JRE_LAYOUT) - /* When we're building with JRE-layout, the default paths are the - same as the runtime paths. */ -#else -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - puts(" gnu.classpath.boot.library.path: "JAVA_RUNTIME_LIBRARY_LIBDIR); - puts(" java.boot.class.path : "CACAO_VM_ZIP":"JAVA_RUNTIME_LIBRARY_CLASSES""); -# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - puts(" sun.boot.library.path : "JAVA_RUNTIME_LIBRARY_LIBDIR); - puts(" java.boot.class.path : "JAVA_RUNTIME_LIBRARY_CLASSES); -# endif -#endif - - puts(""); - - puts("Runtime variables:\n"); - printf(" maximum heap size : %d\n", opt_heapmaxsize); - printf(" initial heap size : %d\n", opt_heapstartsize); - printf(" stack size : %d\n", opt_stacksize); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - printf(" gnu.classpath.boot.library.path: %s\n", properties_get("gnu.classpath.boot.library.path")); -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - printf(" sun.boot.library.path : %s\n", properties_get("sun.boot.library.path")); -#endif - - printf(" java.boot.class.path : %s\n", properties_get("java.boot.class.path")); - printf(" java.class.path : %s\n", properties_get("java.class.path")); -} - - -/* forward declarations *******************************************************/ - -static char *vm_get_mainclass_from_jar(char *mainstring); -#if !defined(NDEBUG) -static void vm_compile_all(void); -static void vm_compile_method(char* mainname); -#endif - - -/* vm_createjvm **************************************************************** - - Implementation for JNI_CreateJavaVM. - -*******************************************************************************/ - -bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args) -{ - JavaVMInitArgs *_vm_args; - _Jv_JNIEnv *env; - _Jv_JavaVM *vm; - - /* get the arguments for the new JVM */ - - _vm_args = (JavaVMInitArgs *) vm_args; - - /* get the VM and Env tables (must be set before vm_create) */ - - env = NEW(_Jv_JNIEnv); - -#if defined(ENABLE_JNI) - env->env = &_Jv_JNINativeInterface; -#endif - - /* XXX Set the global variable. Maybe we should do that differently. */ - - _Jv_env = env; - - /* create and fill a JavaVM structure */ - - vm = NEW(_Jv_JavaVM); - -#if defined(ENABLE_JNI) - vm->functions = &_Jv_JNIInvokeInterface; -#endif - - /* XXX Set the global variable. Maybe we should do that differently. */ - /* XXX JVMTI Agents needs a JavaVM */ - - _Jv_jvm = vm; - - /* actually create the JVM */ - - if (!vm_create(_vm_args)) - goto error; - - /* now return the values */ - - *p_vm = (JavaVM *) vm; - *p_env = (void *) env; - - return true; - - error: - /* release allocated memory */ - - FREE(env, _Jv_JNIEnv); - FREE(vm, _Jv_JavaVM); - - return false; -} - - -/* vm_create ******************************************************************* - - Creates a JVM. Called by vm_createjvm. - -*******************************************************************************/ - -bool vm_create(JavaVMInitArgs *vm_args) -{ - int len; - char *p; - char *boot_class_path; - char *class_path; - int opt; - int i, j; - bool opt_version; - bool opt_exit; - -#if defined(ENABLE_JVMTI) - lt_dlhandle handle; - char *libname, *agentarg; - bool jdwp,agentbypath; - jdwp = agentbypath = false; -#endif - -#if defined(ENABLE_JNI) - /* Check the JNI version requested. */ - - if (!jni_version_check(vm_args->version)) - return false; -#endif - - /* We only support 1 JVM instance. */ - - if (vms > 0) - return false; - - /* Install the exit handler. */ - - if (atexit(vm_exit_handler)) - vm_abort("atexit failed: %s\n", strerror(errno)); - - /* Set some options. */ - - opt_version = false; - opt_exit = false; - - opt_noieee = false; - - opt_heapmaxsize = HEAP_MAXSIZE; - opt_heapstartsize = HEAP_STARTSIZE; - opt_stacksize = STACK_SIZE; - - /* Initialize the properties list before command-line handling. - Otherwise -XX:+PrintConfig crashes. */ - - properties_init(); - - /* First of all, parse the -XX options. */ - -#if defined(ENABLE_VMLOG) - vmlog_cacao_init_options(); -#endif - - options_xx(vm_args); - -#if defined(ENABLE_VMLOG) - vmlog_cacao_init(); -#endif - - /* We need to check if the actual size of a java.lang.Class object - is smaller or equal than the assumption made in - src/vmcore/class.h. */ - - if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class)) - vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class)); - - /* set the VM starttime */ - - _Jv_jvm->starttime = builtin_currenttimemillis(); - -#if defined(ENABLE_JVMTI) - /* initialize JVMTI related **********************************************/ - jvmti = false; -#endif - - /* Fill the properties before command-line handling. */ - - properties_set(); - - /* iterate over all passed options */ - - while ((opt = options_get(opts, vm_args)) != OPT_DONE) { - switch (opt) { - case OPT_FOO: - opt_foo = true; - break; - - case OPT_IGNORE: - break; - - case OPT_JAR: - opt_jar = true; - break; - - case OPT_D32: -#if SIZEOF_VOID_P == 8 - puts("Running a 32-bit JVM is not supported on this platform."); - exit(1); -#endif - break; - - case OPT_D64: -#if SIZEOF_VOID_P == 4 - puts("Running a 64-bit JVM is not supported on this platform."); - exit(1); -#endif - break; - - case OPT_CLASSPATH: - /* Forget old classpath and set the argument as new - classpath. */ - - class_path = properties_get("java.class.path"); - - p = MNEW(char, strlen(opt_arg) + strlen("0")); - - strcpy(p, opt_arg); - -#if defined(ENABLE_JAVASE) - properties_add("java.class.path", p); -#endif - - MFREE(class_path, char, strlen(class_path)); - break; - - case OPT_D: - for (i = 0; i < strlen(opt_arg); i++) { - if (opt_arg[i] == '=') { - opt_arg[i] = '\0'; - properties_add(opt_arg, opt_arg + i + 1); - goto opt_d_done; - } - } - - /* if no '=' is given, just create an empty property */ - - properties_add(opt_arg, ""); - - opt_d_done: - break; - - case OPT_BOOTCLASSPATH: - /* Forget default bootclasspath and set the argument as - new boot classpath. */ - - boot_class_path = properties_get("sun.boot.class.path"); - - p = MNEW(char, strlen(opt_arg) + strlen("0")); - - strcpy(p, opt_arg); - - properties_add("sun.boot.class.path", p); - properties_add("java.boot.class.path", p); - - MFREE(boot_class_path, char, strlen(boot_class_path)); - break; - - case OPT_BOOTCLASSPATH_A: - /* Append to bootclasspath. */ - - boot_class_path = properties_get("sun.boot.class.path"); - - len = strlen(boot_class_path); - - p = MREALLOC(boot_class_path, - char, - len + strlen("0"), - len + strlen(":") + - strlen(opt_arg) + strlen("0")); - - strcat(p, ":"); - strcat(p, opt_arg); - - properties_add("sun.boot.class.path", p); - properties_add("java.boot.class.path", p); - break; - - case OPT_BOOTCLASSPATH_P: - /* Prepend to bootclasspath. */ - - boot_class_path = properties_get("sun.boot.class.path"); - - len = strlen(boot_class_path); - - p = MNEW(char, strlen(opt_arg) + strlen(":") + len + strlen("0")); - - strcpy(p, opt_arg); - strcat(p, ":"); - strcat(p, boot_class_path); - - properties_add("sun.boot.class.path", p); - properties_add("java.boot.class.path", p); - - MFREE(boot_class_path, char, len); - break; - - case OPT_BOOTCLASSPATH_C: - /* Use as Java core library, but prepend VM interface - classes. */ - - boot_class_path = properties_get("sun.boot.class.path"); - - len = - strlen(CACAO_VM_ZIP) + - strlen(":") + - strlen(opt_arg) + - strlen("0"); - - p = MNEW(char, len); - - strcpy(p, CACAO_VM_ZIP); - strcat(p, ":"); - strcat(p, opt_arg); - - properties_add("sun.boot.class.path", p); - properties_add("java.boot.class.path", p); - - MFREE(boot_class_path, char, strlen(boot_class_path)); - break; - -#if defined(ENABLE_JVMTI) - case OPT_DEBUG: - /* this option exists only for compatibility reasons */ - break; - - case OPT_NOAGENT: - /* I don't know yet what Xnoagent should do. This is only for - compatiblity with eclipse - motse */ - break; - - case OPT_XRUNJDWP: - agentbypath = true; - jvmti = true; - jdwp = true; - - len = - strlen(CACAO_LIBDIR) + - strlen("/libjdwp.so=") + - strlen(opt_arg) + - strlen("0"); - - agentarg = MNEW(char, len); - - strcpy(agentarg, CACAO_LIBDIR); - strcat(agentarg, "/libjdwp.so="); - strcat(agentarg, &opt_arg[1]); - break; - - case OPT_AGENTPATH: - agentbypath = true; - - case OPT_AGENTLIB: - jvmti = true; - agentarg = opt_arg; - break; -#endif - - case OPT_MX: - case OPT_MS: - case OPT_SS: - { - char c; - c = opt_arg[strlen(opt_arg) - 1]; - - if ((c == 'k') || (c == 'K')) { - j = atoi(opt_arg) * 1024; - - } else if ((c == 'm') || (c == 'M')) { - j = atoi(opt_arg) * 1024 * 1024; - - } else - j = atoi(opt_arg); - - if (opt == OPT_MX) - opt_heapmaxsize = j; - else if (opt == OPT_MS) - opt_heapstartsize = j; - else - opt_stacksize = j; - } - break; - - case OPT_VERBOSE1: - opt_verbose = true; - break; - - case OPT_VERBOSE: - if (strcmp("class", opt_arg) == 0) { - opt_verboseclass = true; - } - else if (strcmp("gc", opt_arg) == 0) { - opt_verbosegc = true; - } - else if (strcmp("jni", opt_arg) == 0) { - opt_verbosejni = true; - } -#if !defined(NDEBUG) - else if (strcmp("jit", opt_arg) == 0) { - opt_verbose = true; - loadverbose = true; - initverbose = true; - compileverbose = true; - } -#endif - else { - printf("Unknown -verbose option: %s\n", opt_arg); - usage(); - } - break; - - case OPT_DEBUGCOLOR: - opt_debugcolor = true; - break; - -#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE) - case OPT_VERBOSETC: - opt_typecheckverbose = true; - break; -#endif - - case OPT_VERSION: - opt_version = true; - opt_exit = true; - break; - - case OPT_FULLVERSION: - fullversion(); - break; - - case OPT_SHOWVERSION: - opt_version = true; - break; - - case OPT_NOIEEE: - opt_noieee = true; - break; - -#if defined(ENABLE_VERIFIER) - case OPT_NOVERIFY: - opt_verify = false; - break; -#endif - -#if defined(ENABLE_STATISTICS) - case OPT_TIME: - opt_getcompilingtime = true; - opt_getloadingtime = true; - break; - - case OPT_STAT: - opt_stat = true; - break; -#endif - - case OPT_LOG: - log_init(opt_arg); - break; - - case OPT_CHECK: - for (i = 0; i < strlen(opt_arg); i++) { - switch (opt_arg[i]) { - case 'b': - checkbounds = false; - break; - case 's': - checksync = false; - break; - default: - usage(); - } - } - break; - - case OPT_LOAD: - opt_run = false; - makeinitializations = false; - break; - -#if !defined(NDEBUG) - case OPT_ALL: - compileall = true; - opt_run = false; - makeinitializations = false; - break; - - case OPT_METHOD: - opt_run = false; - opt_method = opt_arg; - makeinitializations = false; - break; - - case OPT_SIGNATURE: - opt_signature = opt_arg; - break; -#endif - - case OPT_SHOW: /* Display options */ - for (i = 0; i < strlen(opt_arg); i++) { - switch (opt_arg[i]) { - case 'c': - showconstantpool = true; - break; - - case 'u': - showutf = true; - break; - - case 'm': - showmethods = true; - break; - - case 'i': - opt_showintermediate = true; - compileverbose = true; - break; - -#if defined(ENABLE_DISASSEMBLER) - case 'a': - opt_showdisassemble = true; - compileverbose = true; - break; - - case 'o': - opt_shownops = true; - break; -#endif - - case 'd': - opt_showddatasegment = true; - break; - - default: - usage(); - } - } - break; - -#if defined(ENABLE_LOOP) - case OPT_OLOOP: - opt_loops = true; - break; -#endif - -#if defined(ENABLE_IFCONV) - case OPT_IFCONV: - opt_ifconv = true; - break; -#endif - -#if defined(ENABLE_LSRA) - case OPT_LSRA: - opt_lsra = true; - break; -#endif -#if defined(ENABLE_SSA) - case OPT_LSRA: - opt_lsra = true; - for (i = 0; i < strlen(opt_arg); i++) { - switch (opt_arg[i]) { - case 'c': - opt_ssa_cp = true; - break; - - case 'd': - opt_ssa_dce = true; - break; - - case ':': - break; - - default: - usage(); - } - } - break; -#endif - - case OPT_HELP: - usage(); - break; - - case OPT_X: - Xusage(); - break; - - case OPT_XX: - /* Already parsed. */ - break; - - case OPT_EA: -#if defined(ENABLE_ASSERTION) - assertion_ea_da(opt_arg, true); -#endif - break; - - case OPT_DA: -#if defined(ENABLE_ASSERTION) - assertion_ea_da(opt_arg, false); -#endif - break; - - case OPT_EA_NOARG: -#if defined(ENABLE_ASSERTION) - assertion_user_enabled = true; -#endif - break; - - case OPT_DA_NOARG: -#if defined(ENABLE_ASSERTION) - assertion_user_enabled = false; -#endif - break; - - case OPT_ESA: -#if defined(ENABLE_ASSERTION) - assertion_system_enabled = true; -#endif - break; - - case OPT_DSA: -#if defined(ENABLE_ASSERTION) - assertion_system_enabled = false; -#endif - break; - -#if defined(ENABLE_PROFILING) - case OPT_PROF_OPTION: - /* use <= to get the last \0 too */ - - for (i = 0, j = 0; i <= strlen(opt_arg); i++) { - if (opt_arg[i] == ',') - opt_arg[i] = '\0'; - - if (opt_arg[i] == '\0') { - if (strcmp("bb", opt_arg + j) == 0) - opt_prof_bb = true; - - else { - printf("Unknown option: -Xprof:%s\n", opt_arg + j); - usage(); - } - - /* set k to next char */ - - j = i + 1; - } - } - /* fall through */ - - case OPT_PROF: - opt_prof = true; - break; -#endif - - case OPT_JIT: -#if defined(ENABLE_JIT) - opt_jit = true; -#else - printf("-Xjit option not enabled.\n"); - exit(1); -#endif - break; - - case OPT_INTRP: -#if defined(ENABLE_INTRP) - opt_intrp = true; -#else - printf("-Xint option not enabled.\n"); - exit(1); -#endif - break; - -#if defined(ENABLE_INTRP) - case OPT_STATIC_SUPERS: - opt_static_supers = atoi(opt_arg); - break; - - case OPT_NO_DYNAMIC: - opt_no_dynamic = true; - break; - - case OPT_NO_REPLICATION: - opt_no_replication = true; - break; - - case OPT_NO_QUICKSUPER: - opt_no_quicksuper = true; - break; - - case OPT_TRACE: - vm_debug = true; - break; -#endif - -#if defined(ENABLE_DEBUG_FILTER) - case OPT_FILTER_VERBOSECALL_INCLUDE: - opt_filter_verbosecall_include = opt_arg; - break; - - case OPT_FILTER_VERBOSECALL_EXCLUDE: - opt_filter_verbosecall_exclude = opt_arg; - break; - - case OPT_FILTER_SHOW_METHOD: - opt_filter_show_method = opt_arg; - break; - -#endif - default: - printf("Unknown option: %s\n", - vm_args->options[opt_index].optionString); - usage(); - } - } - -#if defined(ENABLE_JVMTI) - if (jvmti) { - jvmti_set_phase(JVMTI_PHASE_ONLOAD); - jvmti_agentload(agentarg, agentbypath, &handle, &libname); - - if (jdwp) - MFREE(agentarg, char, strlen(agentarg)); - - jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL); - } -#endif - - /* initialize this JVM ****************************************************/ - - vm_initializing = true; - - /* initialize the garbage collector */ - - gc_init(opt_heapmaxsize, opt_heapstartsize); - -#if defined(ENABLE_THREADS) - /* BEFORE: threads_preinit */ - - threadlist_init(); - - /* AFTER: gc_init (directly after, as this initializes the - stopworldlock lock */ - - threads_preinit(); - lock_init(); - critical_init(); -#endif - - /* install architecture dependent signal handlers */ - - if (!signal_init()) - vm_abort("vm_create: signal_init failed"); - -#if defined(ENABLE_INTRP) - /* Allocate main thread stack on the Java heap. */ - - if (opt_intrp) { - intrp_main_stack = GCMNEW(u1, opt_stacksize); - MSET(intrp_main_stack, 0, u1, opt_stacksize); - } -#endif - - /* AFTER: threads_preinit */ - - if (!string_init()) - vm_abort("vm_create: string_init failed"); - - /* AFTER: threads_preinit */ - - utf8_init(); - - /* AFTER: thread_preinit */ - - if (!suck_init()) - vm_abort("vm_create: suck_init failed"); - - suck_add_from_property("java.endorsed.dirs"); - - /* Now we have all options handled and we can print the version - information. - - AFTER: suck_add_from_property("java.endorsed.dirs"); */ - - if (opt_version) - version(opt_exit); - - /* AFTER: utf8_init */ - - boot_class_path = properties_get("sun.boot.class.path"); - suck_add(boot_class_path); - - /* initialize the classcache hashtable stuff: lock, hashtable - (must be done _after_ threads_preinit) */ - - if (!classcache_init()) - vm_abort("vm_create: classcache_init failed"); - - /* Initialize the code memory management. */ - /* AFTER: threads_preinit */ - - codememory_init(); - - /* initialize the finalizer stuff (must be done _after_ - threads_preinit) */ - - if (!finalizer_init()) - vm_abort("vm_create: finalizer_init failed"); - - /* Initialize the JIT compiler. */ - - jit_init(); - code_init(); - methodtree_init(); - -#if defined(ENABLE_PYTHON) - pythonpass_init(); -#endif - - /* BEFORE: loader_preinit */ - - package_init(); - - /* AFTER: utf8_init, classcache_init */ - - loader_preinit(); - linker_preinit(); - - /* AFTER: loader_preinit, linker_preinit */ - - primitive_init(); - - loader_init(); - linker_init(); - - /* AFTER: loader_init, linker_init */ - - primitive_postinit(); - method_init(); - -#if defined(ENABLE_JIT) - trap_init(); -#endif - - if (!builtin_init()) - vm_abort("vm_create: builtin_init failed"); - - /* Initialize the native subsystem. */ - /* BEFORE: threads_init */ - - if (!native_init()) - vm_abort("vm_create: native_init failed"); - - /* Register the native methods implemented in the VM. */ - /* BEFORE: threads_init */ - - nativevm_preinit(); - -#if defined(ENABLE_JNI) - /* Initialize the JNI subsystem (must be done _before_ - threads_init, as threads_init can call JNI methods - (e.g. NewGlobalRef). */ - - if (!jni_init()) - vm_abort("vm_create: jni_init failed"); -#endif - -#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES) - /* Initialize the local reference table for the main thread. */ - /* BEFORE: threads_init */ - - if (!localref_table_init()) - vm_abort("vm_create: localref_table_init failed"); -#endif - - /* Iinitialize some important system classes. */ - /* BEFORE: threads_init */ - - initialize_init(); - -#if defined(ENABLE_THREADS) - threads_init(); -#endif - - /* Initialize the native VM subsystem. */ - /* AFTER: threads_init (at least for SUN's classes) */ - - nativevm_init(); - -#if defined(ENABLE_PROFILING) - /* initialize profiling */ - - if (!profile_init()) - vm_abort("vm_create: profile_init failed"); -#endif - -#if defined(ENABLE_THREADS) - /* initialize recompilation */ - - if (!recompile_init()) - vm_abort("vm_create: recompile_init failed"); - - /* start the signal handler thread */ - -#if defined(__LINUX__) - /* XXX Remove for exact-GC. */ - if (threads_pthreads_implementation_nptl) -#endif - if (!signal_start_thread()) - vm_abort("vm_create: signal_start_thread failed"); - - /* finally, start the finalizer thread */ - - if (!finalizer_start_thread()) - vm_abort("vm_create: finalizer_start_thread failed"); - -# if !defined(NDEBUG) - /* start the memory profiling thread */ - - if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage) - if (!memory_start_thread()) - vm_abort("vm_create: memory_start_thread failed"); -# endif - - /* start the recompilation thread (must be done before the - profiling thread) */ - - if (!recompile_start_thread()) - vm_abort("vm_create: recompile_start_thread failed"); - -# if defined(ENABLE_PROFILING) - /* start the profile sampling thread */ - -/* if (opt_prof) */ -/* if (!profile_start_thread()) */ -/* vm_abort("vm_create: profile_start_thread failed"); */ -# endif -#endif - -#if defined(ENABLE_JVMTI) -# if defined(ENABLE_GC_CACAO) - /* XXX this will not work with the new indirection cells for classloaders!!! */ - assert(0); -# endif - if (jvmti) { - /* add agent library to native library hashtable */ - native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle); - } -#endif - - /* Increment the number of VMs. */ - - vms++; - - /* Initialization is done, VM is created.. */ - - vm_created = true; - vm_initializing = false; - - /* Print the VM configuration after all stuff is set and the VM is - initialized. */ - - if (opt_PrintConfig) - vm_printconfig(); - - /* everything's ok */ - - return true; -} - - -/* vm_run ********************************************************************** - - Runs the main-method of the passed class. - -*******************************************************************************/ - -void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args) -{ - char* option; - char* mainname; - char* p; - utf *mainutf; - classinfo *mainclass; - java_handle_t *e; - methodinfo *m; - java_handle_objectarray_t *oa; - s4 oalength; - utf *u; - java_handle_t *s; - int status; - int i; - -#if defined(ENABLE_THREADS) - threadobject *t; -#endif - -#if !defined(NDEBUG) - if (compileall) { - vm_compile_all(); - return; - } -#endif - - /* Get the main class plus it's arguments. */ - - mainname = NULL; - - if (opt_index < vm_args->nOptions) { - /* Get main-class argument. */ - - mainname = vm_args->options[opt_index].optionString; - - /* If the main class argument is a jar file, put it into the - classpath. */ - - if (opt_jar == true) { - p = MNEW(char, strlen(mainname) + strlen("0")); - - strcpy(p, mainname); - -#if defined(ENABLE_JAVASE) - properties_add("java.class.path", p); -#endif - } - else { - /* Replace dots with slashes in the class name. */ - - for (i = 0; i < strlen(mainname); i++) - if (mainname[i] == '.') - mainname[i] = '/'; - } - - /* Build argument array. Move index to first argument. */ - - opt_index++; - - oalength = vm_args->nOptions - opt_index; - - oa = builtin_anewarray(oalength, class_java_lang_String); - - for (i = 0; i < oalength; i++) { - option = vm_args->options[opt_index + i].optionString; - - u = utf_new_char(option); - s = javastring_new(u); - - array_objectarray_element_set(oa, i, s); - } - } - - /* Do we have a main-class argument? */ - - if (mainname == NULL) - usage(); - -#if !defined(NDEBUG) - if (opt_method != NULL) { - vm_compile_method(mainname); - return; - } -#endif - - /* set return value to OK */ - - status = 0; - - if (opt_jar == true) { - /* open jar file with java.util.jar.JarFile */ - - mainname = vm_get_mainclass_from_jar(mainname); - - if (mainname == NULL) - vm_exit(1); - } - - /* load the main class */ - - mainutf = utf_new_char(mainname); - -#if defined(ENABLE_JAVAME_CLDC1_1) - mainclass = load_class_bootstrap(mainutf); -#else - mainclass = load_class_from_sysloader(mainutf); -#endif - - /* error loading class */ - - e = exceptions_get_and_clear_exception(); - - if ((e != NULL) || (mainclass == NULL)) { - exceptions_throw_noclassdeffounderror_cause(e); - exceptions_print_stacktrace(); - vm_exit(1); - } - - if (!link_class(mainclass)) { - exceptions_print_stacktrace(); - vm_exit(1); - } - - /* find the `main' method of the main class */ - - m = class_resolveclassmethod(mainclass, - utf_new_char("main"), - utf_new_char("([Ljava/lang/String;)V"), - class_java_lang_Object, - false); - - if (exceptions_get_exception()) { - exceptions_print_stacktrace(); - vm_exit(1); - } - - /* there is no main method or it isn't static */ - - if ((m == NULL) || !(m->flags & ACC_STATIC)) { - exceptions_clear_exception(); - exceptions_throw_nosuchmethoderror(mainclass, - utf_new_char("main"), - utf_new_char("([Ljava/lang/String;)V")); - - exceptions_print_stacktrace(); - vm_exit(1); - } - -#ifdef TYPEINFO_DEBUG_TEST - /* test the typeinfo system */ - typeinfo_test(); -#endif - -#if defined(ENABLE_JVMTI) - jvmti_set_phase(JVMTI_PHASE_LIVE); -#endif - - /* set ThreadMXBean variables */ - - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; - _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; - - if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) - _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = - _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; - - /* start the main thread */ - - (void) vm_call_method(m, NULL, oa); - - /* exception occurred? */ - - if (exceptions_get_exception()) { - exceptions_print_stacktrace(); - status = 1; - } - -#if defined(ENABLE_THREADS) - /* Detach the main thread so that it appears to have ended when - the application's main method exits. */ - - t = thread_get_current(); - - if (!threads_detach_thread(t)) - vm_abort("vm_run: Could not detach main thread."); -#endif - - /* Destroy the JavaVM. */ - - (void) vm_destroy(vm); - - /* And exit. */ - - vm_exit(status); -} - - -/* vm_destroy ****************************************************************** - - Unloads a Java VM and reclaims its resources. - -*******************************************************************************/ - -int vm_destroy(JavaVM *vm) -{ -#if defined(ENABLE_THREADS) - /* Create a a trivial new Java waiter thread called - "DestroyJavaVM". */ - - JavaVMAttachArgs args; - - args.name = "DestroyJavaVM"; - args.group = NULL; - - if (!threads_attach_current_thread(&args, false)) - return 1; - - /* Wait until we are the last non-daemon thread. */ - - threads_join_all_threads(); -#endif - - /* VM is gone. */ - - vm_created = false; - - /* Everything is ok. */ - - return 0; -} - - -/* vm_exit ********************************************************************* - - Calls java.lang.System.exit(I)V to exit the JavaVM correctly. - -*******************************************************************************/ - -void vm_exit(s4 status) -{ - methodinfo *m; - - /* signal that we are exiting */ - - vm_exiting = true; - - assert(class_java_lang_System); - assert(class_java_lang_System->state & CLASS_LOADED); - -#if defined(ENABLE_JVMTI) - if (jvmti || (dbgcom!=NULL)) { - jvmti_set_phase(JVMTI_PHASE_DEAD); - if (jvmti) jvmti_agentunload(); - } -#endif - - if (!link_class(class_java_lang_System)) { - exceptions_print_stacktrace(); - exit(1); - } - - /* call java.lang.System.exit(I)V */ - - m = class_resolveclassmethod(class_java_lang_System, - utf_new_char("exit"), - utf_int__void, - class_java_lang_Object, - true); - - if (m == NULL) { - exceptions_print_stacktrace(); - exit(1); - } - - /* call the exit function with passed exit status */ - - (void) vm_call_method(m, NULL, status); - - /* If we had an exception, just ignore the exception and exit with - the proper code. */ - - vm_shutdown(status); -} - - -/* vm_shutdown ***************************************************************** - - Terminates the system immediately without freeing memory explicitly - (to be used only for abnormal termination). - -*******************************************************************************/ - -void vm_shutdown(s4 status) -{ - if (opt_verbose -#if defined(ENABLE_STATISTICS) - || opt_getcompilingtime || opt_stat -#endif - ) - { - log_text("CACAO terminated by shutdown"); - dolog("Exit status: %d\n", (s4) status); - - } - -#if defined(ENABLE_JVMTI) - /* terminate cacaodbgserver */ - if (dbgcom!=NULL) { - mutex_lock(&dbgcomlock); - dbgcom->running=1; - mutex_unlock(&dbgcomlock); - jvmti_cacaodbgserver_quit(); - } -#endif - - exit(status); -} - - -/* vm_exit_handler ************************************************************* - - The exit_handler function is called upon program termination. - - ATTENTION: Don't free system resources here! Some threads may still - be running as this is called from VMRuntime.exit(). The OS does the - cleanup for us. - -*******************************************************************************/ - -void vm_exit_handler(void) -{ -#if !defined(NDEBUG) - if (showmethods) - class_showmethods(mainclass); - - if (showconstantpool) - class_showconstantpool(mainclass); - - if (showutf) - utf_show(); - -# if defined(ENABLE_PROFILING) - if (opt_prof) - profile_printstats(); -# endif -#endif /* !defined(NDEBUG) */ - -#if defined(ENABLE_RT_TIMING) - rt_timing_print_time_stats(stderr); -#endif - -#if defined(ENABLE_CYCLES_STATS) - builtin_print_cycles_stats(stderr); - stacktrace_print_cycles_stats(stderr); -#endif - - if (opt_verbose -#if defined(ENABLE_STATISTICS) - || opt_getcompilingtime || opt_stat -#endif - ) - { - log_text("CACAO terminated"); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) { - print_stats(); -#ifdef TYPECHECK_STATISTICS - typecheck_print_statistics(get_logfile()); -#endif - } - - if (opt_getcompilingtime) - print_times(); -#endif /* defined(ENABLE_STATISTICS) */ - } - /* vm_print_profile(stderr);*/ -} - - -/* vm_abort ******************************************************************** - - Prints an error message and aborts the VM. - - IN: - text ... error message to print - -*******************************************************************************/ - -void vm_abort(const char *text, ...) -{ - va_list ap; - - /* Print the log message. */ - - log_start(); - - va_start(ap, text); - log_vprint(text, ap); - va_end(ap); - - log_finish(); - - /* Now abort the VM. */ - - system_abort(); -} - - -/* vm_abort_errnum ************************************************************* - - Prints an error message, appends ":" plus the strerror-message of - errnum and aborts the VM. - - IN: - errnum ... error number - text ..... error message to print - -*******************************************************************************/ - -void vm_abort_errnum(int errnum, const char *text, ...) -{ - va_list ap; - - /* Print the log message. */ - - log_start(); - - va_start(ap, text); - log_vprint(text, ap); - va_end(ap); - - /* Print the strerror-message of errnum. */ - - log_print(": %s", system_strerror(errnum)); - - log_finish(); - - /* Now abort the VM. */ - - system_abort(); -} - - -/* vm_abort_errno ************************************************************** - - Equal to vm_abort_errnum, but uses errno to get the error number. - - IN: - text ... error message to print - -*******************************************************************************/ - -void vm_abort_errno(const char *text, ...) -{ - va_list ap; - - va_start(ap, text); - vm_abort_errnum(errno, text, ap); - va_end(ap); -} - - -/* vm_abort_disassemble ******************************************************** - - Prints an error message, disassemble the given code range (if - enabled) and aborts the VM. - - IN: - pc.......PC to disassemble - count....number of instructions to disassemble - -*******************************************************************************/ - -void vm_abort_disassemble(void *pc, int count, const char *text, ...) -{ - va_list ap; -#if defined(ENABLE_DISASSEMBLER) - int i; -#endif - - /* Print debug message. */ - - log_start(); - - va_start(ap, text); - log_vprint(text, ap); - va_end(ap); - - log_finish(); - - /* Print the PC. */ - -#if SIZEOF_VOID_P == 8 - log_println("PC=0x%016lx", pc); -#else - log_println("PC=0x%08x", pc); -#endif - -#if defined(ENABLE_DISASSEMBLER) - log_println("machine instructions at PC:"); - - /* Disassemble the given number of instructions. */ - - for (i = 0; i < count; i++) - pc = disassinstr(pc); -#endif - - vm_abort("Aborting..."); -} - - -/* vm_get_mainclass_from_jar *************************************************** - - Gets the name of the main class from a JAR's manifest file. - -*******************************************************************************/ - -static char *vm_get_mainclass_from_jar(char *mainname) -{ - classinfo *c; - java_handle_t *o; - methodinfo *m; - java_handle_t *s; - - c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile")); - - if (c == NULL) { - exceptions_print_stacktrace(); - return NULL; - } - - /* create JarFile object */ - - o = builtin_new(c); - - if (o == NULL) { - exceptions_print_stacktrace(); - return NULL; - } - - m = class_resolveclassmethod(c, - utf_init, - utf_java_lang_String__void, - class_java_lang_Object, - true); - - if (m == NULL) { - exceptions_print_stacktrace(); - return NULL; - } - - s = javastring_new_from_ascii(mainname); - - (void) vm_call_method(m, o, s); - - if (exceptions_get_exception()) { - exceptions_print_stacktrace(); - return NULL; - } - - /* get manifest object */ - - m = class_resolveclassmethod(c, - utf_new_char("getManifest"), - utf_new_char("()Ljava/util/jar/Manifest;"), - class_java_lang_Object, - true); - - if (m == NULL) { - exceptions_print_stacktrace(); - return NULL; - } - - o = vm_call_method(m, o); - - if (o == NULL) { - fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainname); - return NULL; - } - - - /* get Main Attributes */ - - LLNI_class_get(o, c); - - m = class_resolveclassmethod(c, - utf_new_char("getMainAttributes"), - utf_new_char("()Ljava/util/jar/Attributes;"), - class_java_lang_Object, - true); - - if (m == NULL) { - exceptions_print_stacktrace(); - return NULL; - } - - o = vm_call_method(m, o); - - if (o == NULL) { - fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainname); - return NULL; - } - - - /* get property Main-Class */ - - LLNI_class_get(o, c); - - m = class_resolveclassmethod(c, - utf_new_char("getValue"), - utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"), - class_java_lang_Object, - true); - - if (m == NULL) { - exceptions_print_stacktrace(); - return NULL; - } - - s = javastring_new_from_ascii("Main-Class"); - - o = vm_call_method(m, o, s); - - if (o == NULL) { - fprintf(stderr, "Failed to load Main-Class manifest attribute from\n"); - fprintf(stderr, "%s\n", mainname); - return NULL; - } - - return javastring_tochar(o); -} - - -/* vm_compile_all ************************************************************** - - Compile all methods found in the bootclasspath. - -*******************************************************************************/ - -#if !defined(NDEBUG) -static void vm_compile_all(void) -{ - classinfo *c; - methodinfo *m; - u4 slot; - classcache_name_entry *nmen; - classcache_class_entry *clsen; - s4 i; - - /* create all classes found in the bootclasspath */ - /* XXX currently only works with zip/jar's */ - - loader_load_all_classes(); - - /* link all classes */ - - for (slot = 0; slot < hashtable_classcache.size; slot++) { - nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot]; - - for (; nmen; nmen = nmen->hashlink) { - /* iterate over all class entries */ - - for (clsen = nmen->classes; clsen; clsen = clsen->next) { - c = clsen->classobj; - - if (c == NULL) - continue; - - if (!(c->state & CLASS_LINKED)) { - if (!link_class(c)) { - fprintf(stderr, "Error linking: "); - utf_fprint_printable_ascii_classname(stderr, c->name); - fprintf(stderr, "\n"); - - /* print out exception and cause */ - - exceptions_print_current_exception(); - - /* goto next class */ - - continue; - } - } - - /* compile all class methods */ - - for (i = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (m->jcode != NULL) { - if (!jit_compile(m)) { - fprintf(stderr, "Error compiling: "); - utf_fprint_printable_ascii_classname(stderr, c->name); - fprintf(stderr, "."); - utf_fprint_printable_ascii(stderr, m->name); - utf_fprint_printable_ascii(stderr, m->descriptor); - fprintf(stderr, "\n"); - - /* print out exception and cause */ - - exceptions_print_current_exception(); - } - } - } - } - } - } -} -#endif /* !defined(NDEBUG) */ - - -/* vm_compile_method *********************************************************** - - Compile a specific method. - -*******************************************************************************/ - -#if !defined(NDEBUG) -static void vm_compile_method(char* mainname) -{ - methodinfo *m; - - /* create, load and link the main class */ - - mainclass = load_class_bootstrap(utf_new_char(mainname)); - - if (mainclass == NULL) - exceptions_print_stacktrace(); - - if (!link_class(mainclass)) - exceptions_print_stacktrace(); - - if (opt_signature != NULL) { - m = class_resolveclassmethod(mainclass, - utf_new_char(opt_method), - utf_new_char(opt_signature), - mainclass, - false); - } - else { - m = class_resolveclassmethod(mainclass, - utf_new_char(opt_method), - NULL, - mainclass, - false); - } - - if (m == NULL) - vm_abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s", - opt_method, opt_signature ? opt_signature : ""); - - jit_compile(m); -} -#endif /* !defined(NDEBUG) */ - - -/* vm_call_array *************************************************************** - - Calls a Java method with a variable number of arguments, passed via - an argument array. - - ATTENTION: This function has to be used outside the nativeworld. - -*******************************************************************************/ - -#define VM_CALL_ARRAY(name, type) \ -static type vm_call##name##_array(methodinfo *m, uint64_t *array) \ -{ \ - methoddesc *md; \ - void *pv; \ - type value; \ - \ - assert(m->code != NULL); \ - \ - md = m->parseddesc; \ - pv = m->code->entrypoint; \ - \ - STATISTICS(count_calls_native_to_java++); \ - \ - value = asm_vm_call_method##name(pv, array, md->memuse); \ - \ - return value; \ -} - -static java_handle_t *vm_call_array(methodinfo *m, uint64_t *array) -{ - methoddesc *md; - void *pv; - java_object_t *o; - - assert(m->code != NULL); - - md = m->parseddesc; - pv = m->code->entrypoint; - - STATISTICS(count_calls_native_to_java++); - - o = asm_vm_call_method(pv, array, md->memuse); - - if (md->returntype.type == TYPE_VOID) - o = NULL; - - return LLNI_WRAP(o); -} - -VM_CALL_ARRAY(_int, int32_t) -VM_CALL_ARRAY(_long, int64_t) -VM_CALL_ARRAY(_float, float) -VM_CALL_ARRAY(_double, double) - - -/* vm_call_method ************************************************************** - - Calls a Java method with a variable number of arguments. - -*******************************************************************************/ - -#define VM_CALL_METHOD(name, type) \ -type vm_call_method##name(methodinfo *m, java_handle_t *o, ...) \ -{ \ - va_list ap; \ - type value; \ - \ - va_start(ap, o); \ - value = vm_call_method##name##_valist(m, o, ap); \ - va_end(ap); \ - \ - return value; \ -} - -VM_CALL_METHOD(, java_handle_t *) -VM_CALL_METHOD(_int, int32_t) -VM_CALL_METHOD(_long, int64_t) -VM_CALL_METHOD(_float, float) -VM_CALL_METHOD(_double, double) - - -/* vm_call_method_valist ******************************************************* - - Calls a Java method with a variable number of arguments, passed via - a va_list. - -*******************************************************************************/ - -#define VM_CALL_METHOD_VALIST(name, type) \ -type vm_call_method##name##_valist(methodinfo *m, java_handle_t *o, \ - va_list ap) \ -{ \ - uint64_t *array; \ - type value; \ - int32_t dumpmarker; \ - \ - if (m->code == NULL) \ - if (!jit_compile(m)) \ - return 0; \ - \ - THREAD_NATIVEWORLD_EXIT; \ - DMARKER; \ - \ - array = argument_vmarray_from_valist(m, o, ap); \ - value = vm_call##name##_array(m, array); \ - \ - DRELEASE; \ - THREAD_NATIVEWORLD_ENTER; \ - \ - return value; \ -} - -VM_CALL_METHOD_VALIST(, java_handle_t *) -VM_CALL_METHOD_VALIST(_int, int32_t) -VM_CALL_METHOD_VALIST(_long, int64_t) -VM_CALL_METHOD_VALIST(_float, float) -VM_CALL_METHOD_VALIST(_double, double) - - -/* vm_call_method_jvalue ******************************************************* - - Calls a Java method with a variable number of arguments, passed via - a jvalue array. - -*******************************************************************************/ - -#define VM_CALL_METHOD_JVALUE(name, type) \ -type vm_call_method##name##_jvalue(methodinfo *m, java_handle_t *o, \ - const jvalue *args) \ -{ \ - uint64_t *array; \ - type value; \ - int32_t dumpmarker; \ - \ - if (m->code == NULL) \ - if (!jit_compile(m)) \ - return 0; \ - \ - THREAD_NATIVEWORLD_EXIT; \ - DMARKER; \ - \ - array = argument_vmarray_from_jvalue(m, o, args); \ - value = vm_call##name##_array(m, array); \ - \ - DRELEASE; \ - THREAD_NATIVEWORLD_ENTER; \ - \ - return value; \ -} - -VM_CALL_METHOD_JVALUE(, java_handle_t *) -VM_CALL_METHOD_JVALUE(_int, int32_t) -VM_CALL_METHOD_JVALUE(_long, int64_t) -VM_CALL_METHOD_JVALUE(_float, float) -VM_CALL_METHOD_JVALUE(_double, double) - - -/* vm_call_method_objectarray ************************************************** - - Calls a Java method with a variable number if arguments, passed via - an objectarray of boxed values. Returns a boxed value. - -*******************************************************************************/ - -java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, - java_handle_objectarray_t *params) -{ - uint64_t *array; - java_handle_t *xptr; - java_handle_t *ro; - imm_union value; - int32_t dumpmarker; - - /* Prevent compiler warnings. */ - - ro = NULL; - - /* compile methods which are not yet compiled */ - - if (m->code == NULL) - if (!jit_compile(m)) - return NULL; - - /* leave the nativeworld */ - - THREAD_NATIVEWORLD_EXIT; - - /* mark start of dump memory area */ - - DMARKER; - - /* Fill the argument array from a object-array. */ - - array = argument_vmarray_from_objectarray(m, o, params); - - if (array == NULL) { - /* release dump area */ - - DRELEASE; - - /* enter the nativeworld again */ - - THREAD_NATIVEWORLD_ENTER; - - exceptions_throw_illegalargumentexception(); - - return NULL; - } - - switch (m->parseddesc->returntype.decltype) { - case PRIMITIVETYPE_VOID: - value.a = vm_call_array(m, array); - break; - - case PRIMITIVETYPE_BOOLEAN: - case PRIMITIVETYPE_BYTE: - case PRIMITIVETYPE_CHAR: - case PRIMITIVETYPE_SHORT: - case PRIMITIVETYPE_INT: - value.i = vm_call_int_array(m, array); - break; - - case PRIMITIVETYPE_LONG: - value.l = vm_call_long_array(m, array); - break; - - case PRIMITIVETYPE_FLOAT: - value.f = vm_call_float_array(m, array); - break; - - case PRIMITIVETYPE_DOUBLE: - value.d = vm_call_double_array(m, array); - break; - - case TYPE_ADR: - ro = vm_call_array(m, array); - break; - - default: - vm_abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.decltype); - } - - /* release dump area */ - - DRELEASE; - - /* enter the nativeworld again */ - - THREAD_NATIVEWORLD_ENTER; - - /* box the return value if necesarry */ - - if (m->parseddesc->returntype.decltype != TYPE_ADR) - ro = primitive_box(m->parseddesc->returntype.decltype, value); - - /* check for an exception */ - - xptr = exceptions_get_exception(); - - if (xptr != NULL) { - /* clear exception pointer, we are calling JIT code again */ - - exceptions_clear_exception(); - - exceptions_throw_invocationtargetexception(xptr); - } - - return ro; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/vm.cpp b/src/vm/vm.cpp new file mode 100644 index 000000000..c82eac8ce --- /dev/null +++ b/src/vm/vm.cpp @@ -0,0 +1,2691 @@ +/* src/vm/vm.cpp - VM startup and shutdown functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include + +#include + +#include +#include +#include + +#include "vm/types.h" + +#include "arch.h" +#include "md-abi.h" + +#include "vm/jit/abi-asm.h" + +#include "mm/codememory.h" +#include "mm/dumpmemory.hpp" +#include "mm/gc.hpp" +#include "mm/memory.h" + +#include "native/jni.hpp" +#include "native/llni.h" +#include "native/localref.h" +#include "native/native.h" + +#include "native/vm/nativevm.h" + +#include "threads/lock-common.h" +#include "threads/threadlist.h" +#include "threads/thread.hpp" + +#include "toolbox/logging.h" + +#include "vm/array.h" + +#if defined(ENABLE_ASSERTION) +#include "vm/assertion.h" +#endif + +#include "vm/jit/builtin.hpp" +#include "vm/classcache.h" +#include "vm/exceptions.hpp" +#include "vm/finalizer.h" +#include "vm/global.h" +#include "vm/globals.hpp" +#include "vm/initialize.h" +#include "vm/options.h" +#include "vm/os.hpp" +#include "vm/primitive.hpp" +#include "vm/properties.hpp" +#include "vm/signallocal.h" +#include "vm/statistics.h" +#include "vm/string.hpp" +#include "vm/suck.hpp" +#include "vm/vm.hpp" + +#include "vm/jit/argument.h" +#include "vm/jit/asmpart.h" +#include "vm/jit/code.hpp" + +#if defined(ENABLE_DISASSEMBLER) +# include "vm/jit/disass.h" +#endif + +#include "vm/jit/jit.hpp" +#include "vm/jit/methodtree.h" + +#if defined(ENABLE_PROFILING) +# include "vm/jit/optimizing/profile.h" +#endif + +#include "vm/jit/optimizing/recompile.h" + +#if defined(ENABLE_PYTHON) +# include "vm/jit/python.h" +#endif + +#include "vm/jit/trap.h" + +#if defined(ENABLE_JVMTI) +# include "native/jvmti/cacaodbg.h" +#endif + +#if defined(ENABLE_VMLOG) +#include +#endif + + +/** + * This is _the_ VM instance. + */ +VM* VM::_vm = NULL; + + +/* global variables ***********************************************************/ + +s4 vms = 0; /* number of VMs created */ + +static classinfo *mainclass = NULL; + +#if defined(ENABLE_INTRP) +u1 *intrp_main_stack = NULL; +#endif + + +/* define heap sizes **********************************************************/ + +#define HEAP_MAXSIZE 128 * 1024 * 1024 /* default 128MB */ +#define HEAP_STARTSIZE 2 * 1024 * 1024 /* default 2MB */ +#define STACK_SIZE 128 * 1024 /* default 64kB */ + + +/* define command line options ************************************************/ + +enum { + OPT_FOO, + + /* Java options */ + + OPT_JAR, + + OPT_D32, + OPT_D64, + + OPT_CLASSPATH, + OPT_D, + + OPT_VERBOSE, + + OPT_VERSION, + OPT_SHOWVERSION, + OPT_FULLVERSION, + + OPT_HELP, + OPT_X, + OPT_XX, + + OPT_EA, + OPT_DA, + OPT_EA_NOARG, + OPT_DA_NOARG, + + + OPT_ESA, + OPT_DSA, + + /* Java non-standard options */ + + OPT_JIT, + OPT_INTRP, + + OPT_BOOTCLASSPATH, + OPT_BOOTCLASSPATH_A, + OPT_BOOTCLASSPATH_P, + + OPT_BOOTCLASSPATH_C, + +#if defined(ENABLE_PROFILING) + OPT_PROF, + OPT_PROF_OPTION, +#endif + + OPT_MS, + OPT_MX, + + /* CACAO options */ + + OPT_VERBOSE1, + OPT_NOIEEE, + +#if defined(ENABLE_STATISTICS) + OPT_TIME, + OPT_STAT, +#endif + + OPT_LOG, + OPT_CHECK, + OPT_LOAD, + OPT_SHOW, + OPT_DEBUGCOLOR, + +#if !defined(NDEBUG) + OPT_ALL, + OPT_METHOD, + OPT_SIGNATURE, +#endif + +#if defined(ENABLE_VERIFIER) + OPT_NOVERIFY, +#if defined(TYPECHECK_VERBOSE) + OPT_VERBOSETC, +#endif +#endif /* defined(ENABLE_VERIFIER) */ + + /* optimization options */ + +#if defined(ENABLE_LOOP) + OPT_OLOOP, +#endif + +#if defined(ENABLE_IFCONV) + OPT_IFCONV, +#endif + +#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) + OPT_LSRA, +#endif + +#if defined(ENABLE_INTRP) + /* interpreter options */ + + OPT_NO_DYNAMIC, + OPT_NO_REPLICATION, + OPT_NO_QUICKSUPER, + OPT_STATIC_SUPERS, + OPT_TRACE, +#endif + + OPT_SS, + +#ifdef ENABLE_JVMTI + OPT_DEBUG, + OPT_XRUNJDWP, + OPT_NOAGENT, + OPT_AGENTLIB, + OPT_AGENTPATH, +#endif + +#if defined(ENABLE_DEBUG_FILTER) + OPT_FILTER_VERBOSECALL_INCLUDE, + OPT_FILTER_VERBOSECALL_EXCLUDE, + OPT_FILTER_SHOW_METHOD, +#endif + + DUMMY +}; + + +opt_struct opts[] = { + { "foo", false, OPT_FOO }, + + /* Java options */ + + { "jar", false, OPT_JAR }, + + { "d32", false, OPT_D32 }, + { "d64", false, OPT_D64 }, + { "client", false, OPT_IGNORE }, + { "server", false, OPT_IGNORE }, + { "jvm", false, OPT_IGNORE }, + { "hotspot", false, OPT_IGNORE }, + + { "classpath", true, OPT_CLASSPATH }, + { "cp", true, OPT_CLASSPATH }, + { "D", true, OPT_D }, + { "version", false, OPT_VERSION }, + { "showversion", false, OPT_SHOWVERSION }, + { "fullversion", false, OPT_FULLVERSION }, + { "help", false, OPT_HELP }, + { "?", false, OPT_HELP }, + { "X", false, OPT_X }, + { "XX:", true, OPT_XX }, + + { "ea:", true, OPT_EA }, + { "da:", true, OPT_DA }, + { "ea", false, OPT_EA_NOARG }, + { "da", false, OPT_DA_NOARG }, + + { "enableassertions:", true, OPT_EA }, + { "disableassertions:", true, OPT_DA }, + { "enableassertions", false, OPT_EA_NOARG }, + { "disableassertions", false, OPT_DA_NOARG }, + + { "esa", false, OPT_ESA }, + { "enablesystemassertions", false, OPT_ESA }, + { "dsa", false, OPT_DSA }, + { "disablesystemassertions", false, OPT_DSA }, + + { "noasyncgc", false, OPT_IGNORE }, +#if defined(ENABLE_VERIFIER) + { "noverify", false, OPT_NOVERIFY }, + { "Xverify:none", false, OPT_NOVERIFY }, +#endif + { "v", false, OPT_VERBOSE1 }, + { "verbose:", true, OPT_VERBOSE }, + +#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE) + { "verbosetc", false, OPT_VERBOSETC }, +#endif +#if defined(__ALPHA__) + { "noieee", false, OPT_NOIEEE }, +#endif +#if defined(ENABLE_STATISTICS) + { "time", false, OPT_TIME }, + { "stat", false, OPT_STAT }, +#endif + { "log", true, OPT_LOG }, + { "c", true, OPT_CHECK }, + { "l", false, OPT_LOAD }, + +#if !defined(NDEBUG) + { "all", false, OPT_ALL }, + { "sig", true, OPT_SIGNATURE }, +#endif + +#if defined(ENABLE_LOOP) + { "oloop", false, OPT_OLOOP }, +#endif +#if defined(ENABLE_IFCONV) + { "ifconv", false, OPT_IFCONV }, +#endif +#if defined(ENABLE_LSRA) + { "lsra", false, OPT_LSRA }, +#endif +#if defined(ENABLE_SSA) + { "lsra", true, OPT_LSRA }, +#endif + +#if defined(ENABLE_INTRP) + /* interpreter options */ + + { "trace", false, OPT_TRACE }, + { "static-supers", true, OPT_STATIC_SUPERS }, + { "no-dynamic", false, OPT_NO_DYNAMIC }, + { "no-replication", false, OPT_NO_REPLICATION }, + { "no-quicksuper", false, OPT_NO_QUICKSUPER }, +#endif + + /* JVMTI Agent Command Line Options */ +#ifdef ENABLE_JVMTI + { "agentlib:", true, OPT_AGENTLIB }, + { "agentpath:", true, OPT_AGENTPATH }, +#endif + + /* Java non-standard options */ + + { "Xjit", false, OPT_JIT }, + { "Xint", false, OPT_INTRP }, + { "Xbootclasspath:", true, OPT_BOOTCLASSPATH }, + { "Xbootclasspath/a:", true, OPT_BOOTCLASSPATH_A }, + { "Xbootclasspath/p:", true, OPT_BOOTCLASSPATH_P }, + { "Xbootclasspath/c:", true, OPT_BOOTCLASSPATH_C }, + +#ifdef ENABLE_JVMTI + { "Xdebug", false, OPT_DEBUG }, + { "Xnoagent", false, OPT_NOAGENT }, + { "Xrunjdwp", true, OPT_XRUNJDWP }, +#endif + + { "Xms", true, OPT_MS }, + { "ms", true, OPT_MS }, + { "Xmx", true, OPT_MX }, + { "mx", true, OPT_MX }, + { "Xss", true, OPT_SS }, + { "ss", true, OPT_SS }, + +#if defined(ENABLE_PROFILING) + { "Xprof:", true, OPT_PROF_OPTION }, + { "Xprof", false, OPT_PROF }, +#endif + + /* keep these at the end of the list */ + +#if !defined(NDEBUG) + { "m", true, OPT_METHOD }, +#endif + + { "s", true, OPT_SHOW }, + { "debug-color", false, OPT_DEBUGCOLOR }, + +#if defined(ENABLE_DEBUG_FILTER) + { "XXfi", true, OPT_FILTER_VERBOSECALL_INCLUDE }, + { "XXfx", true, OPT_FILTER_VERBOSECALL_EXCLUDE }, + { "XXfm", true, OPT_FILTER_SHOW_METHOD }, +#endif + + { NULL, false, 0 } +}; + + +/* usage *********************************************************************** + + Prints the correct usage syntax to stdout. + +*******************************************************************************/ + +void usage(void) +{ + puts("Usage: cacao [-options] classname [arguments]"); + puts(" (to run a class file)"); + puts(" or cacao [-options] -jar jarfile [arguments]"); + puts(" (to run a standalone jar file)\n"); + + puts("where options include:"); + puts(" -d32 use 32-bit data model if available"); + puts(" -d64 use 64-bit data model if available"); + puts(" -client compatibility (currently ignored)"); + puts(" -server compatibility (currently ignored)"); + puts(" -jvm compatibility (currently ignored)"); + puts(" -hotspot compatibility (currently ignored)\n"); + + puts(" -cp specify a path to look for classes"); + puts(" -classpath specify a path to look for classes"); + puts(" -D= add an entry to the property list"); + puts(" -verbose[:class|gc|jni] enable specific verbose output"); + puts(" -version print product version and exit"); + puts(" -fullversion print jpackage-compatible product version and exit"); + puts(" -showversion print product version and continue"); + puts(" -help, -? print this help message"); + puts(" -X print help on non-standard Java options"); + puts(" -XX print help on debugging options"); + puts(" -ea[:...|:]"); + puts(" -enableassertions[:...|:]"); + puts(" enable assertions with specified granularity"); + puts(" -da[:...|:]"); + puts(" -disableassertions[:...|:]"); + puts(" disable assertions with specified granularity"); + puts(" -esa | -enablesystemassertions"); + puts(" enable system assertions"); + puts(" -dsa | -disablesystemassertions"); + puts(" disable system assertions"); + +#ifdef ENABLE_JVMTI + puts(" -agentlib:= library to load containg JVMTI agent"); + puts (" for jdwp help use: -agentlib:jdwp=help"); + puts(" -agentpath:= path to library containg JVMTI agent"); +#endif + + /* exit with error code */ + + exit(1); +} + + +static void Xusage(void) +{ +#if defined(ENABLE_JIT) + puts(" -Xjit JIT mode execution (default)"); +#endif +#if defined(ENABLE_INTRP) + puts(" -Xint interpreter mode execution"); +#endif + puts(" -Xbootclasspath:"); + puts(" value is set as bootstrap class path"); + puts(" -Xbootclasspath/a:"); + puts(" value is appended to the bootstrap class path"); + puts(" -Xbootclasspath/p:"); + puts(" value is prepended to the bootstrap class path"); + puts(" -Xbootclasspath/c:"); + puts(" value is used as Java core library, but the"); + puts(" hardcoded VM interface classes are prepended"); + printf(" -Xms set the initial size of the heap (default: %dMB)\n", HEAP_STARTSIZE / 1024 / 1024); + printf(" -Xmx set the maximum size of the heap (default: %dMB)\n", HEAP_MAXSIZE / 1024 / 1024); + printf(" -Xss set the thread stack size (default: %dkB)\n", STACK_SIZE / 1024); + +#if defined(ENABLE_PROFILING) + puts(" -Xprof[:bb] collect and print profiling data"); +#endif + +#if defined(ENABLE_JVMTI) + /* -Xdebug option depend on gnu classpath JDWP options. options: + transport=dt_socket,address=,server=(y|n),suspend(y|n) */ + puts(" -Xdebug enable remote debugging\n"); + puts(" -Xrunjdwp transport=[dt_socket|...],address=,server=[y|n],suspend=[y|n]\n"); + puts(" enable remote debugging\n"); +#endif + + /* exit with error code */ + + exit(1); +} + + +#if 0 +static void XXusage(void) +{ + puts(" -v write state-information"); +#if !defined(NDEBUG) + puts(" -verbose:jit enable specific verbose output"); + puts(" -debug-color colored output for ANSI terms"); +#endif +#ifdef TYPECHECK_VERBOSE + puts(" -verbosetc write debug messages while typechecking"); +#endif +#if defined(__ALPHA__) + puts(" -noieee don't use ieee compliant arithmetic"); +#endif +#if defined(ENABLE_VERIFIER) + puts(" -noverify don't verify classfiles"); +#endif +#if defined(ENABLE_STATISTICS) + puts(" -time measure the runtime"); + puts(" -stat detailed compiler statistics"); +#endif + puts(" -log logfile specify a name for the logfile"); + puts(" -c(heck)b(ounds) don't check array bounds"); + puts(" s(ync) don't check for synchronization"); +#if defined(ENABLE_LOOP) + puts(" -oloop optimize array accesses in loops"); +#endif + puts(" -l don't start the class after loading"); +#if !defined(NDEBUG) + puts(" -all compile all methods, no execution"); + puts(" -m compile only a specific method"); + puts(" -sig specify signature for a specific method"); +#endif + + puts(" -s... show..."); + puts(" (c)onstants the constant pool"); + puts(" (m)ethods class fields and methods"); + puts(" (u)tf the utf - hash"); + puts(" (i)ntermediate intermediate representation"); +#if defined(ENABLE_DISASSEMBLER) + puts(" (a)ssembler disassembled listing"); + puts(" n(o)ps show NOPs in disassembler output"); +#endif + puts(" (d)atasegment data segment listing"); + +#if defined(ENABLE_IFCONV) + puts(" -ifconv use if-conversion"); +#endif +#if defined(ENABLE_LSRA) + puts(" -lsra use linear scan register allocation"); +#endif +#if defined(ENABLE_SSA) + puts(" -lsra:... use linear scan register allocation (with SSA)"); + puts(" (d)ead code elimination"); + puts(" (c)opy propagation"); +#endif +#if defined(ENABLE_DEBUG_FILTER) + puts(" -XXfi begin of dynamic scope for verbosecall filter"); + puts(" -XXfx end of dynamic scope for verbosecall filter"); + puts(" -XXfm filter for show options"); +#endif + /* exit with error code */ + + exit(1); +} +#endif + + +/* version ********************************************************************* + + Only prints cacao version information. + +*******************************************************************************/ + +static void version(bool opt_exit) +{ + puts("java version \""JAVA_VERSION"\""); + puts("CACAO version "VERSION"\n"); + + puts("Copyright (C) 1996-2005, 2006, 2007, 2008"); + puts("CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO"); + puts("This is free software; see the source for copying conditions. There is NO"); + puts("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); + + /* exit normally, if requested */ + + if (opt_exit) + exit(0); +} + + +/* fullversion ***************************************************************** + + Prints a Sun compatible version information (required e.g. by + jpackage, www.jpackage.org). + +*******************************************************************************/ + +static void fullversion(void) +{ + puts("java full version \"cacao-"JAVA_VERSION"\""); + + /* exit normally */ + + exit(0); +} + + +/* forward declarations *******************************************************/ + +static char *vm_get_mainclass_from_jar(char *mainstring); +#if !defined(NDEBUG) +static void vm_compile_all(void); +static void vm_compile_method(char* mainname); +#endif + + +/** + * Implementation for JNI_CreateJavaVM. This function creates a VM + * object. + * + * @param p_vm + * @param p_env + * @param vm_args + * + * @return true on success, false otherwise. + */ +bool VM::create(JavaVM** p_vm, void** p_env, void* vm_args) +{ + JavaVMInitArgs* _vm_args; + + // Get the arguments for the new JVM. + _vm_args = (JavaVMInitArgs *) vm_args; + + // Instantiate a new VM. + try { + _vm = new VM(_vm_args); + } + catch (std::exception e) { + // FIXME How can we delete the resources allocated? +// /* release allocated memory */ +// FREE(env, _Jv_JNIEnv); +// FREE(vm, _Jv_JavaVM); + + _vm = NULL; + + return false; + } + + // Return the values. + + *p_vm = _vm->get_javavm(); + *p_env = _vm->get_jnienv(); + + return true; +} + + +/** + * C wrapper for VM::create. + */ +extern "C" { + bool VM_create(JavaVM** p_vm, void** p_env, void* vm_args) + { + return VM::create(p_vm, p_env, vm_args); + } +} + + +/** + * VM constructor. + */ +VM::VM(JavaVMInitArgs* vm_args) +{ + // Very first thing to do: we are initializing. + _initializing = true; + + // Make ourself globally visible. + // XXX Is this a good idea? + _vm = this; + + /* create and fill a JavaVM structure */ + + _javavm = new JavaVM(); + +#if defined(ENABLE_JNI) + _javavm->functions = &_Jv_JNIInvokeInterface; +#endif + + /* get the VM and Env tables (must be set before vm_create) */ + /* XXX JVMTI Agents needs a JavaVM */ + + _jnienv = new JNIEnv(); + +#if defined(ENABLE_JNI) + _jnienv->functions = &_Jv_JNINativeInterface; +#endif + + /* actually create the JVM */ + + int len; + char *p; + char *boot_class_path; + char *class_path; + int opt; + bool opt_version; + bool opt_exit; + +#if defined(ENABLE_JVMTI) + lt_dlhandle handle; + char *libname, *agentarg; + bool jdwp,agentbypath; + jdwp = agentbypath = false; +#endif + +#if defined(ENABLE_JNI) + /* Check the JNI version requested. */ + + if (!jni_version_check(vm_args->version)) + throw std::exception(); +#endif + + /* We only support 1 JVM instance. */ + + if (vms > 0) + throw std::exception(); + + /* Install the exit handler. */ + + if (atexit(vm_exit_handler)) + VM::get_current()->abort("atexit failed: %s\n", strerror(errno)); + + /* Set some options. */ + + opt_version = false; + opt_exit = false; + + opt_noieee = false; + + opt_heapmaxsize = HEAP_MAXSIZE; + opt_heapstartsize = HEAP_STARTSIZE; + opt_stacksize = STACK_SIZE; + + // First of all, parse the -XX options. + +#if defined(ENABLE_VMLOG) + vmlog_cacao_init_options(); +#endif + + options_xx(vm_args); + + // After -XX options are parsed, print the build-time + // configuration, if requested. + if (opt_PrintConfig) + print_build_time_config(); + +#if defined(ENABLE_VMLOG) + vmlog_cacao_init(); +#endif + + /* We need to check if the actual size of a java.lang.Class object + is smaller or equal than the assumption made in + src/vm/class.h. */ + +#warning FIXME We need to check the size of java.lang.Class!!! +// if (sizeof(java_lang_Class) > sizeof(dummy_java_lang_Class)) +// vm_abort("vm_create: java_lang_Class structure is bigger than classinfo.object (%d > %d)", sizeof(java_lang_Class), sizeof(dummy_java_lang_Class)); + + /* set the VM starttime */ + + _starttime = builtin_currenttimemillis(); + +#if defined(ENABLE_JVMTI) + /* initialize JVMTI related **********************************************/ + jvmti = false; +#endif + + /* iterate over all passed options */ + + while ((opt = options_get(opts, vm_args)) != OPT_DONE) { + switch (opt) { + case OPT_FOO: + opt_foo = true; + break; + + case OPT_IGNORE: + break; + + case OPT_JAR: + opt_jar = true; + break; + + case OPT_D32: +#if SIZEOF_VOID_P == 8 + puts("Running a 32-bit JVM is not supported on this platform."); + exit(1); +#endif + break; + + case OPT_D64: +#if SIZEOF_VOID_P == 4 + puts("Running a 64-bit JVM is not supported on this platform."); + exit(1); +#endif + break; + + case OPT_CLASSPATH: + /* Forget old classpath and set the argument as new + classpath. */ + + // FIXME Make class_path const char*. + class_path = (char*) _properties.get("java.class.path"); + + p = MNEW(char, strlen(opt_arg) + strlen("0")); + + strcpy(p, opt_arg); + +#if defined(ENABLE_JAVASE) + _properties.put("java.class.path", p); +#endif + + MFREE(class_path, char, strlen(class_path)); + break; + + case OPT_D: + for (unsigned int i = 0; i < strlen(opt_arg); i++) { + if (opt_arg[i] == '=') { + opt_arg[i] = '\0'; + _properties.put(opt_arg, opt_arg + i + 1); + goto opt_d_done; + } + } + + /* if no '=' is given, just create an empty property */ + + _properties.put(opt_arg, ""); + + opt_d_done: + break; + + case OPT_BOOTCLASSPATH: + /* Forget default bootclasspath and set the argument as + new boot classpath. */ + + // FIXME Make boot_class_path const char*. + boot_class_path = (char*) _properties.get("sun.boot.class.path"); + + p = MNEW(char, strlen(opt_arg) + strlen("0")); + + strcpy(p, opt_arg); + + _properties.put("sun.boot.class.path", p); + _properties.put("java.boot.class.path", p); + + MFREE(boot_class_path, char, strlen(boot_class_path)); + break; + + case OPT_BOOTCLASSPATH_A: + /* Append to bootclasspath. */ + + // FIXME Make boot_class_path const char*. + boot_class_path = (char*) _properties.get("sun.boot.class.path"); + + len = strlen(boot_class_path); + + // XXX (char*) quick hack + p = (char*) MREALLOC(boot_class_path, + char, + len + strlen("0"), + len + strlen(":") + + strlen(opt_arg) + strlen("0")); + + strcat(p, ":"); + strcat(p, opt_arg); + + _properties.put("sun.boot.class.path", p); + _properties.put("java.boot.class.path", p); + break; + + case OPT_BOOTCLASSPATH_P: + /* Prepend to bootclasspath. */ + + // FIXME Make boot_class_path const char*. + boot_class_path = (char*) _properties.get("sun.boot.class.path"); + + len = strlen(boot_class_path); + + p = MNEW(char, strlen(opt_arg) + strlen(":") + len + strlen("0")); + + strcpy(p, opt_arg); + strcat(p, ":"); + strcat(p, boot_class_path); + + _properties.put("sun.boot.class.path", p); + _properties.put("java.boot.class.path", p); + + MFREE(boot_class_path, char, len); + break; + + case OPT_BOOTCLASSPATH_C: + /* Use as Java core library, but prepend VM interface + classes. */ + + // FIXME Make boot_class_path const char*. + boot_class_path = (char*) _properties.get("sun.boot.class.path"); + + len = + strlen(CACAO_VM_ZIP) + + strlen(":") + + strlen(opt_arg) + + strlen("0"); + + p = MNEW(char, len); + + strcpy(p, CACAO_VM_ZIP); + strcat(p, ":"); + strcat(p, opt_arg); + + _properties.put("sun.boot.class.path", p); + _properties.put("java.boot.class.path", p); + + MFREE(boot_class_path, char, strlen(boot_class_path)); + break; + +#if defined(ENABLE_JVMTI) + case OPT_DEBUG: + /* this option exists only for compatibility reasons */ + break; + + case OPT_NOAGENT: + /* I don't know yet what Xnoagent should do. This is only for + compatiblity with eclipse - motse */ + break; + + case OPT_XRUNJDWP: + agentbypath = true; + jvmti = true; + jdwp = true; + + len = + strlen(CACAO_LIBDIR) + + strlen("/libjdwp.so=") + + strlen(opt_arg) + + strlen("0"); + + agentarg = MNEW(char, len); + + strcpy(agentarg, CACAO_LIBDIR); + strcat(agentarg, "/libjdwp.so="); + strcat(agentarg, &opt_arg[1]); + break; + + case OPT_AGENTPATH: + agentbypath = true; + + case OPT_AGENTLIB: + jvmti = true; + agentarg = opt_arg; + break; +#endif + + case OPT_MX: + case OPT_MS: + case OPT_SS: + { + char c; + int j; + + c = opt_arg[strlen(opt_arg) - 1]; + + if ((c == 'k') || (c == 'K')) { + j = atoi(opt_arg) * 1024; + + } else if ((c == 'm') || (c == 'M')) { + j = atoi(opt_arg) * 1024 * 1024; + + } else + j = atoi(opt_arg); + + if (opt == OPT_MX) + opt_heapmaxsize = j; + else if (opt == OPT_MS) + opt_heapstartsize = j; + else + opt_stacksize = j; + } + break; + + case OPT_VERBOSE1: + opt_verbose = true; + break; + + case OPT_VERBOSE: + if (strcmp("class", opt_arg) == 0) { + opt_verboseclass = true; + } + else if (strcmp("gc", opt_arg) == 0) { + opt_verbosegc = true; + } + else if (strcmp("jni", opt_arg) == 0) { + opt_verbosejni = true; + } +#if !defined(NDEBUG) + else if (strcmp("jit", opt_arg) == 0) { + opt_verbose = true; + loadverbose = true; + initverbose = true; + compileverbose = true; + } +#endif + else { + printf("Unknown -verbose option: %s\n", opt_arg); + usage(); + } + break; + + case OPT_DEBUGCOLOR: + opt_debugcolor = true; + break; + +#if defined(ENABLE_VERIFIER) && defined(TYPECHECK_VERBOSE) + case OPT_VERBOSETC: + opt_typecheckverbose = true; + break; +#endif + + case OPT_VERSION: + opt_version = true; + opt_exit = true; + break; + + case OPT_FULLVERSION: + fullversion(); + break; + + case OPT_SHOWVERSION: + opt_version = true; + break; + + case OPT_NOIEEE: + opt_noieee = true; + break; + +#if defined(ENABLE_VERIFIER) + case OPT_NOVERIFY: + opt_verify = false; + break; +#endif + +#if defined(ENABLE_STATISTICS) + case OPT_TIME: + opt_getcompilingtime = true; + opt_getloadingtime = true; + break; + + case OPT_STAT: + opt_stat = true; + break; +#endif + + case OPT_LOG: + log_init(opt_arg); + break; + + case OPT_CHECK: + for (unsigned int i = 0; i < strlen(opt_arg); i++) { + switch (opt_arg[i]) { + case 'b': + checkbounds = false; + break; + case 's': + checksync = false; + break; + default: + usage(); + } + } + break; + + case OPT_LOAD: + opt_run = false; + makeinitializations = false; + break; + +#if !defined(NDEBUG) + case OPT_ALL: + compileall = true; + opt_run = false; + makeinitializations = false; + break; + + case OPT_METHOD: + opt_run = false; + opt_method = opt_arg; + makeinitializations = false; + break; + + case OPT_SIGNATURE: + opt_signature = opt_arg; + break; +#endif + + case OPT_SHOW: /* Display options */ + for (unsigned int i = 0; i < strlen(opt_arg); i++) { + switch (opt_arg[i]) { + case 'c': + showconstantpool = true; + break; + + case 'u': + showutf = true; + break; + + case 'm': + showmethods = true; + break; + + case 'i': + opt_showintermediate = true; + compileverbose = true; + break; + +#if defined(ENABLE_DISASSEMBLER) + case 'a': + opt_showdisassemble = true; + compileverbose = true; + break; +#endif + + case 'd': + opt_showddatasegment = true; + break; + + default: + usage(); + } + } + break; + +#if defined(ENABLE_LOOP) + case OPT_OLOOP: + opt_loops = true; + break; +#endif + +#if defined(ENABLE_IFCONV) + case OPT_IFCONV: + opt_ifconv = true; + break; +#endif + +#if defined(ENABLE_LSRA) + case OPT_LSRA: + opt_lsra = true; + break; +#endif +#if defined(ENABLE_SSA) + case OPT_LSRA: + opt_lsra = true; + for (unsigned int i = 0; i < strlen(opt_arg); i++) { + switch (opt_arg[i]) { + case 'c': + opt_ssa_cp = true; + break; + + case 'd': + opt_ssa_dce = true; + break; + + case ':': + break; + + default: + usage(); + } + } + break; +#endif + + case OPT_HELP: + usage(); + break; + + case OPT_X: + Xusage(); + break; + + case OPT_XX: + /* Already parsed. */ + break; + + case OPT_EA: +#if defined(ENABLE_ASSERTION) + assertion_ea_da(opt_arg, true); +#endif + break; + + case OPT_DA: +#if defined(ENABLE_ASSERTION) + assertion_ea_da(opt_arg, false); +#endif + break; + + case OPT_EA_NOARG: +#if defined(ENABLE_ASSERTION) + assertion_user_enabled = true; +#endif + break; + + case OPT_DA_NOARG: +#if defined(ENABLE_ASSERTION) + assertion_user_enabled = false; +#endif + break; + + case OPT_ESA: +#if defined(ENABLE_ASSERTION) + assertion_system_enabled = true; +#endif + break; + + case OPT_DSA: +#if defined(ENABLE_ASSERTION) + assertion_system_enabled = false; +#endif + break; + +#if defined(ENABLE_PROFILING) + case OPT_PROF_OPTION: + /* use <= to get the last \0 too */ + + for (unsigned int i = 0, j = 0; i <= strlen(opt_arg); i++) { + if (opt_arg[i] == ',') + opt_arg[i] = '\0'; + + if (opt_arg[i] == '\0') { + if (strcmp("bb", opt_arg + j) == 0) + opt_prof_bb = true; + + else { + printf("Unknown option: -Xprof:%s\n", opt_arg + j); + usage(); + } + + /* set k to next char */ + + j = i + 1; + } + } + /* fall through */ + + case OPT_PROF: + opt_prof = true; + break; +#endif + + case OPT_JIT: +#if defined(ENABLE_JIT) + opt_jit = true; +#else + printf("-Xjit option not enabled.\n"); + exit(1); +#endif + break; + + case OPT_INTRP: +#if defined(ENABLE_INTRP) + opt_intrp = true; +#else + printf("-Xint option not enabled.\n"); + exit(1); +#endif + break; + +#if defined(ENABLE_INTRP) + case OPT_STATIC_SUPERS: + opt_static_supers = atoi(opt_arg); + break; + + case OPT_NO_DYNAMIC: + opt_no_dynamic = true; + break; + + case OPT_NO_REPLICATION: + opt_no_replication = true; + break; + + case OPT_NO_QUICKSUPER: + opt_no_quicksuper = true; + break; + + case OPT_TRACE: + vm_debug = true; + break; +#endif + +#if defined(ENABLE_DEBUG_FILTER) + case OPT_FILTER_VERBOSECALL_INCLUDE: + opt_filter_verbosecall_include = opt_arg; + break; + + case OPT_FILTER_VERBOSECALL_EXCLUDE: + opt_filter_verbosecall_exclude = opt_arg; + break; + + case OPT_FILTER_SHOW_METHOD: + opt_filter_show_method = opt_arg; + break; + +#endif + default: + printf("Unknown option: %s\n", + vm_args->options[opt_index].optionString); + usage(); + } + } + + // Print the preliminary run-time VM configuration after options + // are parsed. + if (opt_PrintConfig) + print_run_time_config(); + +#if defined(ENABLE_JVMTI) + if (jvmti) { + jvmti_set_phase(JVMTI_PHASE_ONLOAD); + jvmti_agentload(agentarg, agentbypath, &handle, &libname); + + if (jdwp) + MFREE(agentarg, char, strlen(agentarg)); + + jvmti_set_phase(JVMTI_PHASE_PRIMORDIAL); + } +#endif + + /* initialize the garbage collector */ + + gc_init(opt_heapmaxsize, opt_heapstartsize); + +#if defined(ENABLE_THREADS) + /* BEFORE: threads_preinit */ + + threadlist_init(); + + /* AFTER: gc_init */ + + threads_preinit(); + lock_init(); +#endif + + /* install architecture dependent signal handlers */ + + if (!signal_init()) + VM::get_current()->abort("vm_create: signal_init failed"); + +#if defined(ENABLE_INTRP) + /* Allocate main thread stack on the Java heap. */ + + if (opt_intrp) { + intrp_main_stack = GCMNEW(u1, opt_stacksize); + MSET(intrp_main_stack, 0, u1, opt_stacksize); + } +#endif + + /* AFTER: threads_preinit */ + + if (!string_init()) + VM::get_current()->abort("vm_create: string_init failed"); + + /* AFTER: threads_preinit */ + + utf8_init(); + + /* AFTER: thread_preinit */ + + if (!suck_init()) + VM::get_current()->abort("vm_create: suck_init failed"); + + suck_add_from_property("java.endorsed.dirs"); + + /* Now we have all options handled and we can print the version + information. + + AFTER: suck_add_from_property("java.endorsed.dirs"); */ + + if (opt_version) + version(opt_exit); + + /* AFTER: utf8_init */ + + // FIXME Make boot_class_path const char*. + boot_class_path = (char*) _properties.get("sun.boot.class.path"); + suck_add(boot_class_path); + + /* initialize the classcache hashtable stuff: lock, hashtable + (must be done _after_ threads_preinit) */ + + if (!classcache_init()) + VM::get_current()->abort("vm_create: classcache_init failed"); + + /* Initialize the code memory management. */ + /* AFTER: threads_preinit */ + + codememory_init(); + + /* initialize the finalizer stuff (must be done _after_ + threads_preinit) */ + + if (!finalizer_init()) + VM::get_current()->abort("vm_create: finalizer_init failed"); + + /* Initialize the JIT compiler. */ + + jit_init(); + code_init(); + methodtree_init(); + +#if defined(ENABLE_PYTHON) + pythonpass_init(); +#endif + + /* AFTER: utf8_init, classcache_init */ + + loader_preinit(); + linker_preinit(); + + // AFTER: loader_preinit, linker_preinit + Primitive::initialize_table(); + + loader_init(); + linker_init(); + + // AFTER: loader_init, linker_init + Primitive::post_initialize_table(); + method_init(); + +#if defined(ENABLE_JIT) + trap_init(); +#endif + + if (!builtin_init()) + VM::get_current()->abort("vm_create: builtin_init failed"); + + /* Initialize the native subsystem. */ + /* BEFORE: threads_init */ + + if (!native_init()) + VM::get_current()->abort("vm_create: native_init failed"); + + /* Register the native methods implemented in the VM. */ + /* BEFORE: threads_init */ + + nativevm_preinit(); + +#if defined(ENABLE_JNI) + /* Initialize the JNI subsystem (must be done _before_ + threads_init, as threads_init can call JNI methods + (e.g. NewGlobalRef). */ + + if (!jni_init()) + VM::get_current()->abort("vm_create: jni_init failed"); +#endif + +#if defined(ENABLE_JNI) || defined(ENABLE_HANDLES) + /* Initialize the local reference table for the main thread. */ + /* BEFORE: threads_init */ + + if (!localref_table_init()) + VM::get_current()->abort("vm_create: localref_table_init failed"); +#endif + + /* Iinitialize some important system classes. */ + /* BEFORE: threads_init */ + + initialize_init(); + +#if defined(ENABLE_THREADS) + threads_init(); +#endif + + /* Initialize the native VM subsystem. */ + /* AFTER: threads_init (at least for SUN's classes) */ + + nativevm_init(); + +#if defined(ENABLE_PROFILING) + /* initialize profiling */ + + if (!profile_init()) + VM::get_current()->abort("vm_create: profile_init failed"); +#endif + +#if defined(ENABLE_THREADS) + /* initialize recompilation */ + + if (!recompile_init()) + VM::get_current()->abort("vm_create: recompile_init failed"); + + /* start the signal handler thread */ + +#if defined(__LINUX__) + /* XXX Remove for exact-GC. */ + if (threads_pthreads_implementation_nptl) +#endif + if (!signal_start_thread()) + VM::get_current()->abort("vm_create: signal_start_thread failed"); + + /* finally, start the finalizer thread */ + + if (!finalizer_start_thread()) + VM::get_current()->abort("vm_create: finalizer_start_thread failed"); + +# if !defined(NDEBUG) + /* start the memory profiling thread */ + + if (opt_ProfileMemoryUsage || opt_ProfileGCMemoryUsage) + if (!memory_start_thread()) + VM::get_current()->abort("vm_create: memory_start_thread failed"); +# endif + + /* start the recompilation thread (must be done before the + profiling thread) */ + + if (!recompile_start_thread()) + VM::get_current()->abort("vm_create: recompile_start_thread failed"); + +# if defined(ENABLE_PROFILING) + /* start the profile sampling thread */ + +/* if (opt_prof) */ +/* if (!profile_start_thread()) */ +/* VM::get_current()->abort("vm_create: profile_start_thread failed"); */ +# endif +#endif + +#if defined(ENABLE_JVMTI) +# if defined(ENABLE_GC_CACAO) + /* XXX this will not work with the new indirection cells for classloaders!!! */ + assert(0); +# endif + if (jvmti) { + /* add agent library to native library hashtable */ + native_hashtable_library_add(utf_new_char(libname), class_java_lang_Object->classloader, handle); + } +#endif + + /* Increment the number of VMs. */ + + vms++; + + // Initialization is done, VM is created. + _created = true; + _initializing = false; + + // Print the run-time VM configuration after all stuff is set and + // the VM is initialized. + if (opt_PrintConfig) + print_run_time_config(); +} + + +/** + * Print build-time (default) VM configuration. + */ +void VM::print_build_time_config(void) +{ + puts("CACAO "VERSION" configure/build options:"); + puts(""); + puts(" ./configure: "VERSION_CONFIGURE_ARGS""); +#if defined(__VERSION__) + puts(" CC : "VERSION_CC" ("__VERSION__")"); + puts(" CXX : "VERSION_CXX" ("__VERSION__")"); +#else + puts(" CC : "VERSION_CC""); + puts(" CXX : "VERSION_CXX""); +#endif + puts(" CFLAGS : "VERSION_CFLAGS""); + puts(" CXXFLAGS : "VERSION_CXXFLAGS""); + + puts(""); + + puts("Build-time (default) variables:\n"); + printf(" maximum heap size : %d\n", HEAP_MAXSIZE); + printf(" initial heap size : %d\n", HEAP_STARTSIZE); + printf(" stack size : %d\n", STACK_SIZE); + +#if defined(ENABLE_JRE_LAYOUT) + // When we're building with JRE-layout, the default paths are the + // same as the runtime paths. +#else +# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + puts(" gnu.classpath.boot.library.path: "JAVA_RUNTIME_LIBRARY_LIBDIR); + puts(" java.boot.class.path : "CACAO_VM_ZIP":"JAVA_RUNTIME_LIBRARY_CLASSES""); +# elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + puts(" sun.boot.library.path : "JAVA_RUNTIME_LIBRARY_LIBDIR); + puts(" java.boot.class.path : "JAVA_RUNTIME_LIBRARY_CLASSES); +# endif +#endif + + puts(""); +} + + +/** + * Print run-time VM configuration. + */ +void VM::print_run_time_config() +{ + puts("Run-time variables:\n"); + printf(" maximum heap size : %d\n", opt_heapmaxsize); + printf(" initial heap size : %d\n", opt_heapstartsize); + printf(" stack size : %d\n", opt_stacksize); + +#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) + printf(" gnu.classpath.boot.library.path: %s\n", _properties.get("gnu.classpath.boot.library.path")); +#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) + printf(" sun.boot.library.path : %s\n", _properties.get("sun.boot.library.path")); +#endif + + printf(" java.boot.class.path : %s\n", _properties.get("java.boot.class.path")); + printf(" java.class.path : %s\n", _properties.get("java.class.path")); + + puts(""); +} + + +/* vm_run ********************************************************************** + + Runs the main-method of the passed class. + +*******************************************************************************/ + +void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args) +{ + char* option; + char* mainname; + char* p; + utf *mainutf; + classinfo *mainclass; + java_handle_t *e; + methodinfo *m; + java_handle_objectarray_t *oa; + s4 oalength; + utf *u; + java_handle_t *s; + int status; + + // Prevent compiler warnings. + oa = NULL; + +#if !defined(NDEBUG) + if (compileall) { + vm_compile_all(); + return; + } +#endif + + /* Get the main class plus it's arguments. */ + + mainname = NULL; + + if (opt_index < vm_args->nOptions) { + /* Get main-class argument. */ + + mainname = vm_args->options[opt_index].optionString; + + /* If the main class argument is a jar file, put it into the + classpath. */ + + if (opt_jar == true) { + p = MNEW(char, strlen(mainname) + strlen("0")); + + strcpy(p, mainname); + +#if defined(ENABLE_JAVASE) + VM::get_current()->get_properties().put("java.class.path", p); +#endif + } + else { + /* Replace dots with slashes in the class name. */ + + for (unsigned int i = 0; i < strlen(mainname); i++) + if (mainname[i] == '.') + mainname[i] = '/'; + } + + /* Build argument array. Move index to first argument. */ + + opt_index++; + + oalength = vm_args->nOptions - opt_index; + + oa = builtin_anewarray(oalength, class_java_lang_String); + + for (int i = 0; i < oalength; i++) { + option = vm_args->options[opt_index + i].optionString; + + u = utf_new_char(option); + s = javastring_new(u); + + array_objectarray_element_set(oa, i, s); + } + } + + /* Do we have a main-class argument? */ + + if (mainname == NULL) + usage(); + +#if !defined(NDEBUG) + if (opt_method != NULL) { + vm_compile_method(mainname); + return; + } +#endif + + /* set return value to OK */ + + status = 0; + + if (opt_jar == true) { + /* open jar file with java.util.jar.JarFile */ + + mainname = vm_get_mainclass_from_jar(mainname); + + if (mainname == NULL) + vm_exit(1); + } + + /* load the main class */ + + mainutf = utf_new_char(mainname); + +#if defined(ENABLE_JAVAME_CLDC1_1) + mainclass = load_class_bootstrap(mainutf); +#else + mainclass = load_class_from_sysloader(mainutf); +#endif + + /* error loading class */ + + e = exceptions_get_and_clear_exception(); + + if ((e != NULL) || (mainclass == NULL)) { + exceptions_throw_noclassdeffounderror_cause(e); + exceptions_print_stacktrace(); + vm_exit(1); + } + + if (!link_class(mainclass)) { + exceptions_print_stacktrace(); + vm_exit(1); + } + + /* find the `main' method of the main class */ + + m = class_resolveclassmethod(mainclass, + utf_new_char("main"), + utf_new_char("([Ljava/lang/String;)V"), + class_java_lang_Object, + false); + + if (exceptions_get_exception()) { + exceptions_print_stacktrace(); + vm_exit(1); + } + + /* there is no main method or it isn't static */ + + if ((m == NULL) || !(m->flags & ACC_STATIC)) { + exceptions_clear_exception(); + exceptions_throw_nosuchmethoderror(mainclass, + utf_new_char("main"), + utf_new_char("([Ljava/lang/String;)V")); + + exceptions_print_stacktrace(); + vm_exit(1); + } + +#ifdef TYPEINFO_DEBUG_TEST + /* test the typeinfo system */ + typeinfo_test(); +#endif + +#if defined(ENABLE_JVMTI) + jvmti_set_phase(JVMTI_PHASE_LIVE); +#endif + + /* set ThreadMXBean variables */ + +// _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++; +// _Jv_jvm->java_lang_management_ThreadMXBean_TotalStartedThreadCount++; + +// if (_Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount > +// _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount) +// _Jv_jvm->java_lang_management_ThreadMXBean_PeakThreadCount = +// _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount; +#warning Move to C++ + + /* start the main thread */ + + (void) vm_call_method(m, NULL, oa); + + /* exception occurred? */ + + if (exceptions_get_exception()) { + exceptions_print_stacktrace(); + status = 1; + } + +#if defined(ENABLE_THREADS) + /* Detach the main thread so that it appears to have ended when + the application's main method exits. */ + + if (!thread_detach_current_thread()) + VM::get_current()->abort("vm_run: Could not detach main thread."); +#endif + + /* Destroy the JavaVM. */ + + (void) vm_destroy(vm); + + /* And exit. */ + + vm_exit(status); +} + + +/* vm_destroy ****************************************************************** + + Unloads a Java VM and reclaims its resources. + +*******************************************************************************/ + +int vm_destroy(JavaVM *vm) +{ +#if defined(ENABLE_THREADS) + /* Create a a trivial new Java waiter thread called + "DestroyJavaVM". */ + + JavaVMAttachArgs args; + + args.name = (char*) "DestroyJavaVM"; + args.group = NULL; + + if (!thread_attach_current_thread(&args, false)) + return 1; + + /* Wait until we are the last non-daemon thread. */ + + threads_join_all_threads(); +#endif + + /* VM is gone. */ + +// _created = false; +#warning Move to C++ + + /* Everything is ok. */ + + return 0; +} + + +/* vm_exit ********************************************************************* + + Calls java.lang.System.exit(I)V to exit the JavaVM correctly. + +*******************************************************************************/ + +void vm_exit(s4 status) +{ + methodinfo *m; + + /* signal that we are exiting */ + +// _exiting = true; +#warning Move to C++ + + assert(class_java_lang_System); + assert(class_java_lang_System->state & CLASS_LOADED); + +#if defined(ENABLE_JVMTI) + if (jvmti || (dbgcom!=NULL)) { + jvmti_set_phase(JVMTI_PHASE_DEAD); + if (jvmti) jvmti_agentunload(); + } +#endif + + if (!link_class(class_java_lang_System)) { + exceptions_print_stacktrace(); + exit(1); + } + + /* call java.lang.System.exit(I)V */ + + m = class_resolveclassmethod(class_java_lang_System, + utf_new_char("exit"), + utf_int__void, + class_java_lang_Object, + true); + + if (m == NULL) { + exceptions_print_stacktrace(); + exit(1); + } + + /* call the exit function with passed exit status */ + + (void) vm_call_method(m, NULL, status); + + /* If we had an exception, just ignore the exception and exit with + the proper code. */ + + vm_shutdown(status); +} + + +/* vm_shutdown ***************************************************************** + + Terminates the system immediately without freeing memory explicitly + (to be used only for abnormal termination). + +*******************************************************************************/ + +void vm_shutdown(s4 status) +{ + if (opt_verbose +#if defined(ENABLE_STATISTICS) + || opt_getcompilingtime || opt_stat +#endif + ) + { + log_text("CACAO terminated by shutdown"); + dolog("Exit status: %d\n", (s4) status); + + } + +#if defined(ENABLE_JVMTI) + /* terminate cacaodbgserver */ + if (dbgcom!=NULL) { + mutex_lock(&dbgcomlock); + dbgcom->running=1; + mutex_unlock(&dbgcomlock); + jvmti_cacaodbgserver_quit(); + } +#endif + + exit(status); +} + + +/* vm_exit_handler ************************************************************* + + The exit_handler function is called upon program termination. + + ATTENTION: Don't free system resources here! Some threads may still + be running as this is called from VMRuntime.exit(). The OS does the + cleanup for us. + +*******************************************************************************/ + +void vm_exit_handler(void) +{ +#if !defined(NDEBUG) + if (showmethods) + class_showmethods(mainclass); + + if (showconstantpool) + class_showconstantpool(mainclass); + + if (showutf) + utf_show(); + +# if defined(ENABLE_PROFILING) + if (opt_prof) + profile_printstats(); +# endif +#endif /* !defined(NDEBUG) */ + +#if defined(ENABLE_RT_TIMING) + rt_timing_print_time_stats(stderr); +#endif + +#if defined(ENABLE_CYCLES_STATS) + builtin_print_cycles_stats(stderr); + stacktrace_print_cycles_stats(stderr); +#endif + + if (opt_verbose +#if defined(ENABLE_STATISTICS) + || opt_getcompilingtime || opt_stat +#endif + ) + { + log_text("CACAO terminated"); + +#if defined(ENABLE_STATISTICS) + if (opt_stat) { + print_stats(); +#ifdef TYPECHECK_STATISTICS + typecheck_print_statistics(get_logfile()); +#endif + } + + if (opt_getcompilingtime) + print_times(); +#endif /* defined(ENABLE_STATISTICS) */ + } + /* vm_print_profile(stderr);*/ +} + + +/** + * Prints an error message and aborts the VM. + * + * @param text Error message to print. + */ +void VM::abort(const char* text, ...) +{ + va_list ap; + + // Print the log message. + log_start(); + + va_start(ap, text); + log_vprint(text, ap); + va_end(ap); + + log_finish(); + + // Print a backtrace. + os::print_backtrace(); + + // Now abort the VM. + os::abort(); +} + + +/** + * Prints an error message, appends ":" plus the strerror-message of + * errnum and aborts the VM. + * + * @param errnum Error number. + * @param text Error message to print. + */ +void VM::abort_errnum(int errnum, const char* text, ...) +{ + va_list ap; + + // Print the log message. + log_start(); + + va_start(ap, text); + log_vprint(text, ap); + va_end(ap); + + // Print the strerror-message of errnum. + log_print(": %s", os::strerror(errnum)); + + log_finish(); + + // Print a backtrace. + os::print_backtrace(); + + // Now abort the VM. + os::abort(); +} + + +/** + * Equal to VM::abort_errnum, but uses errno to get the error number. + * + * @param text Error message to print. + */ +void VM::abort_errno(const char* text, ...) +{ + va_list ap; + + va_start(ap, text); + abort_errnum(errno, text, ap); + va_end(ap); +} + + +/* vm_abort_disassemble ******************************************************** + + Prints an error message, disassemble the given code range (if + enabled) and aborts the VM. + + IN: + pc.......PC to disassemble + count....number of instructions to disassemble + +*******************************************************************************/ + +void vm_abort_disassemble(void *pc, int count, const char *text, ...) +{ + va_list ap; +#if defined(ENABLE_DISASSEMBLER) + int i; +#endif + + /* Print debug message. */ + + log_start(); + + va_start(ap, text); + log_vprint(text, ap); + va_end(ap); + + log_finish(); + + /* Print the PC. */ + +#if SIZEOF_VOID_P == 8 + log_println("PC=0x%016lx", pc); +#else + log_println("PC=0x%08x", pc); +#endif + +#if defined(ENABLE_DISASSEMBLER) + log_println("machine instructions at PC:"); + + /* Disassemble the given number of instructions. */ + + for (i = 0; i < count; i++) + // FIXME disassinstr should use void*. + pc = disassinstr((u1*) pc); +#endif + + VM::get_current()->abort("Aborting..."); +} + + +/* vm_get_mainclass_from_jar *************************************************** + + Gets the name of the main class from a JAR's manifest file. + +*******************************************************************************/ + +static char *vm_get_mainclass_from_jar(char *mainname) +{ + classinfo *c; + java_handle_t *o; + methodinfo *m; + java_handle_t *s; + + c = load_class_from_sysloader(utf_new_char("java/util/jar/JarFile")); + + if (c == NULL) { + exceptions_print_stacktrace(); + return NULL; + } + + /* create JarFile object */ + + o = builtin_new(c); + + if (o == NULL) { + exceptions_print_stacktrace(); + return NULL; + } + + m = class_resolveclassmethod(c, + utf_init, + utf_java_lang_String__void, + class_java_lang_Object, + true); + + if (m == NULL) { + exceptions_print_stacktrace(); + return NULL; + } + + s = javastring_new_from_ascii(mainname); + + (void) vm_call_method(m, o, s); + + if (exceptions_get_exception()) { + exceptions_print_stacktrace(); + return NULL; + } + + /* get manifest object */ + + m = class_resolveclassmethod(c, + utf_new_char("getManifest"), + utf_new_char("()Ljava/util/jar/Manifest;"), + class_java_lang_Object, + true); + + if (m == NULL) { + exceptions_print_stacktrace(); + return NULL; + } + + o = vm_call_method(m, o); + + if (o == NULL) { + fprintf(stderr, "Could not get manifest from %s (invalid or corrupt jarfile?)\n", mainname); + return NULL; + } + + + /* get Main Attributes */ + + LLNI_class_get(o, c); + + m = class_resolveclassmethod(c, + utf_new_char("getMainAttributes"), + utf_new_char("()Ljava/util/jar/Attributes;"), + class_java_lang_Object, + true); + + if (m == NULL) { + exceptions_print_stacktrace(); + return NULL; + } + + o = vm_call_method(m, o); + + if (o == NULL) { + fprintf(stderr, "Could not get main attributes from %s (invalid or corrupt jarfile?)\n", mainname); + return NULL; + } + + + /* get property Main-Class */ + + LLNI_class_get(o, c); + + m = class_resolveclassmethod(c, + utf_new_char("getValue"), + utf_new_char("(Ljava/lang/String;)Ljava/lang/String;"), + class_java_lang_Object, + true); + + if (m == NULL) { + exceptions_print_stacktrace(); + return NULL; + } + + s = javastring_new_from_ascii("Main-Class"); + + o = vm_call_method(m, o, s); + + if (o == NULL) { + fprintf(stderr, "Failed to load Main-Class manifest attribute from\n"); + fprintf(stderr, "%s\n", mainname); + return NULL; + } + + return javastring_tochar(o); +} + + +/* vm_compile_all ************************************************************** + + Compile all methods found in the bootclasspath. + +*******************************************************************************/ + +#if !defined(NDEBUG) +static void vm_compile_all(void) +{ + classinfo *c; + methodinfo *m; + u4 slot; + classcache_name_entry *nmen; + classcache_class_entry *clsen; + s4 i; + + /* create all classes found in the bootclasspath */ + /* XXX currently only works with zip/jar's */ + + loader_load_all_classes(); + + /* link all classes */ + + for (slot = 0; slot < hashtable_classcache.size; slot++) { + nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot]; + + for (; nmen; nmen = nmen->hashlink) { + /* iterate over all class entries */ + + for (clsen = nmen->classes; clsen; clsen = clsen->next) { + c = clsen->classobj; + + if (c == NULL) + continue; + + if (!(c->state & CLASS_LINKED)) { + if (!link_class(c)) { + fprintf(stderr, "Error linking: "); + utf_fprint_printable_ascii_classname(stderr, c->name); + fprintf(stderr, "\n"); + + /* print out exception and cause */ + + exceptions_print_current_exception(); + + /* goto next class */ + + continue; + } + } + + /* compile all class methods */ + + for (i = 0; i < c->methodscount; i++) { + m = &(c->methods[i]); + + if (m->jcode != NULL) { + if (!jit_compile(m)) { + fprintf(stderr, "Error compiling: "); + utf_fprint_printable_ascii_classname(stderr, c->name); + fprintf(stderr, "."); + utf_fprint_printable_ascii(stderr, m->name); + utf_fprint_printable_ascii(stderr, m->descriptor); + fprintf(stderr, "\n"); + + /* print out exception and cause */ + + exceptions_print_current_exception(); + } + } + } + } + } + } +} +#endif /* !defined(NDEBUG) */ + + +/* vm_compile_method *********************************************************** + + Compile a specific method. + +*******************************************************************************/ + +#if !defined(NDEBUG) +static void vm_compile_method(char* mainname) +{ + methodinfo *m; + + /* create, load and link the main class */ + + mainclass = load_class_bootstrap(utf_new_char(mainname)); + + if (mainclass == NULL) + exceptions_print_stacktrace(); + + if (!link_class(mainclass)) + exceptions_print_stacktrace(); + + if (opt_signature != NULL) { + m = class_resolveclassmethod(mainclass, + utf_new_char(opt_method), + utf_new_char(opt_signature), + mainclass, + false); + } + else { + m = class_resolveclassmethod(mainclass, + utf_new_char(opt_method), + NULL, + mainclass, + false); + } + + if (m == NULL) + VM::get_current()->abort("vm_compile_method: java.lang.NoSuchMethodException: %s.%s", + opt_method, opt_signature ? opt_signature : ""); + + jit_compile(m); +} +#endif /* !defined(NDEBUG) */ + + +/* vm_call_array *************************************************************** + + Calls a Java method with a variable number of arguments, passed via + an argument array. + + ATTENTION: This function has to be used outside the nativeworld. + +*******************************************************************************/ + +#define VM_CALL_ARRAY(name, type) \ +static type vm_call##name##_array(methodinfo *m, uint64_t *array) \ +{ \ + methoddesc *md; \ + void *pv; \ + type value; \ + \ + assert(m->code != NULL); \ + \ + md = m->parseddesc; \ + pv = m->code->entrypoint; \ + \ + STATISTICS(count_calls_native_to_java++); \ + \ + value = asm_vm_call_method##name(pv, array, md->memuse); \ + \ + return value; \ +} + +static java_handle_t *vm_call_array(methodinfo *m, uint64_t *array) +{ + methoddesc *md; + void *pv; + java_object_t *o; + + assert(m->code != NULL); + + md = m->parseddesc; + pv = m->code->entrypoint; + + STATISTICS(count_calls_native_to_java++); + + o = asm_vm_call_method(pv, array, md->memuse); + + if (md->returntype.type == TYPE_VOID) + o = NULL; + + return LLNI_WRAP(o); +} + +VM_CALL_ARRAY(_int, int32_t) +VM_CALL_ARRAY(_long, int64_t) +VM_CALL_ARRAY(_float, float) +VM_CALL_ARRAY(_double, double) + + +/* vm_call_method ************************************************************** + + Calls a Java method with a variable number of arguments. + +*******************************************************************************/ + +#define VM_CALL_METHOD(name, type) \ +type vm_call_method##name(methodinfo *m, java_handle_t *o, ...) \ +{ \ + va_list ap; \ + type value; \ + \ + va_start(ap, o); \ + value = vm_call_method##name##_valist(m, o, ap); \ + va_end(ap); \ + \ + return value; \ +} + +VM_CALL_METHOD(, java_handle_t *) +VM_CALL_METHOD(_int, int32_t) +VM_CALL_METHOD(_long, int64_t) +VM_CALL_METHOD(_float, float) +VM_CALL_METHOD(_double, double) + + +/* vm_call_method_valist ******************************************************* + + Calls a Java method with a variable number of arguments, passed via + a va_list. + +*******************************************************************************/ + +#define VM_CALL_METHOD_VALIST(name, type) \ +type vm_call_method##name##_valist(methodinfo *m, java_handle_t *o, \ + va_list ap) \ +{ \ + uint64_t *array; \ + type value; \ + \ + if (m->code == NULL) \ + if (!jit_compile(m)) \ + return 0; \ + \ + THREAD_NATIVEWORLD_EXIT; \ + \ + DumpMemoryArea dma; \ + \ + array = argument_vmarray_from_valist(m, o, ap); \ + value = vm_call##name##_array(m, array); \ + \ + THREAD_NATIVEWORLD_ENTER; \ + \ + return value; \ +} + +VM_CALL_METHOD_VALIST(, java_handle_t *) +VM_CALL_METHOD_VALIST(_int, int32_t) +VM_CALL_METHOD_VALIST(_long, int64_t) +VM_CALL_METHOD_VALIST(_float, float) +VM_CALL_METHOD_VALIST(_double, double) + + +/* vm_call_method_jvalue ******************************************************* + + Calls a Java method with a variable number of arguments, passed via + a jvalue array. + +*******************************************************************************/ + +#define VM_CALL_METHOD_JVALUE(name, type) \ +type vm_call_method##name##_jvalue(methodinfo *m, java_handle_t *o, \ + const jvalue *args) \ +{ \ + uint64_t *array; \ + type value; \ + \ + if (m->code == NULL) \ + if (!jit_compile(m)) \ + return 0; \ + \ + THREAD_NATIVEWORLD_EXIT; \ + \ + DumpMemoryArea dma; \ + \ + array = argument_vmarray_from_jvalue(m, o, args); \ + value = vm_call##name##_array(m, array); \ + \ + THREAD_NATIVEWORLD_ENTER; \ + \ + return value; \ +} + +VM_CALL_METHOD_JVALUE(, java_handle_t *) +VM_CALL_METHOD_JVALUE(_int, int32_t) +VM_CALL_METHOD_JVALUE(_long, int64_t) +VM_CALL_METHOD_JVALUE(_float, float) +VM_CALL_METHOD_JVALUE(_double, double) + + +/* vm_call_method_objectarray ************************************************** + + Calls a Java method with a variable number if arguments, passed via + an objectarray of boxed values. Returns a boxed value. + +*******************************************************************************/ + +java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, + java_handle_objectarray_t *params) +{ + uint64_t *array; + java_handle_t *xptr; + java_handle_t *ro; + imm_union value; + + /* Prevent compiler warnings. */ + + ro = NULL; + + /* compile methods which are not yet compiled */ + + if (m->code == NULL) + if (!jit_compile(m)) + return NULL; + + /* leave the nativeworld */ + + THREAD_NATIVEWORLD_EXIT; + + // Create new dump memory area. + DumpMemoryArea dma; + + /* Fill the argument array from a object-array. */ + + array = argument_vmarray_from_objectarray(m, o, params); + + if (array == NULL) { + /* enter the nativeworld again */ + + THREAD_NATIVEWORLD_ENTER; + + exceptions_throw_illegalargumentexception(); + + return NULL; + } + + switch (m->parseddesc->returntype.primitivetype) { + case PRIMITIVETYPE_VOID: + value.a = vm_call_array(m, array); + break; + + case PRIMITIVETYPE_BOOLEAN: + case PRIMITIVETYPE_BYTE: + case PRIMITIVETYPE_CHAR: + case PRIMITIVETYPE_SHORT: + case PRIMITIVETYPE_INT: + value.i = vm_call_int_array(m, array); + break; + + case PRIMITIVETYPE_LONG: + value.l = vm_call_long_array(m, array); + break; + + case PRIMITIVETYPE_FLOAT: + value.f = vm_call_float_array(m, array); + break; + + case PRIMITIVETYPE_DOUBLE: + value.d = vm_call_double_array(m, array); + break; + + case TYPE_ADR: + ro = vm_call_array(m, array); + break; + + default: + VM::get_current()->abort("vm_call_method_objectarray: invalid return type %d", m->parseddesc->returntype.primitivetype); + } + + /* enter the nativeworld again */ + + THREAD_NATIVEWORLD_ENTER; + + /* box the return value if necesarry */ + + if (m->parseddesc->returntype.primitivetype != TYPE_ADR) + ro = Primitive::box(m->parseddesc->returntype.primitivetype, value); + + /* check for an exception */ + + xptr = exceptions_get_exception(); + + if (xptr != NULL) { + /* clear exception pointer, we are calling JIT code again */ + + exceptions_clear_exception(); + + exceptions_throw_invocationtargetexception(xptr); + } + + return ro; +} + + +/* Legacy C interface *********************************************************/ + +extern "C" { + +JavaVM* VM_get_javavm() { return VM::get_current()->get_javavm(); } +JNIEnv* VM_get_jnienv() { return VM::get_current()->get_jnienv(); } +bool VM_is_initializing() { return VM::get_current()->is_initializing(); } +bool VM_is_created() { return VM::get_current()->is_created(); } +int64_t VM_get_starttime() { return VM::get_current()->get_starttime(); } + +void vm_abort(const char* text, ...) +{ + va_list ap; + + va_start(ap, text); + VM::get_current()->abort(text, ap); + va_end(ap); +} + +void vm_abort_errnum(int errnum, const char* text, ...) +{ + va_list ap; + + va_start(ap, text); + VM::get_current()->abort_errnum(errnum, text, ap); + va_end(ap); +} + +void vm_abort_errno(const char* text, ...) +{ + va_list ap; + + va_start(ap, text); + VM::get_current()->abort_errno(text, ap); + va_end(ap); +} + +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/vm.h b/src/vm/vm.h deleted file mode 100644 index 6c5fe4e18..000000000 --- a/src/vm/vm.h +++ /dev/null @@ -1,116 +0,0 @@ -/* src/vm/vm.h - basic JVM functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _VM_H -#define _VM_H - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "native/jni.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" - - -/* export global variables ****************************************************/ - -extern _Jv_JavaVM *_Jv_jvm; -extern _Jv_JNIEnv *_Jv_env; - -extern bool vm_initializing; -extern bool vm_created; -extern bool vm_exiting; - -#if defined(ENABLE_INTRP) -extern u1 *intrp_main_stack; -#endif - - -/* function prototypes ********************************************************/ - -void usage(void); - -bool vm_createjvm(JavaVM **p_vm, void **p_env, void *vm_args); -bool vm_create(JavaVMInitArgs *vm_args); -void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args); -s4 vm_destroy(JavaVM *vm); -void vm_exit(s4 status); -void vm_shutdown(s4 status); - -void vm_exit_handler(void); - -void vm_abort(const char *text, ...); -void vm_abort_errnum(int errnum, const char *text, ...); -void vm_abort_errno(const char *text, ...); -void vm_abort_disassemble(void *pc, int count, const char *text, ...); - -/* Java method calling functions */ - -java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...); -java_handle_t *vm_call_method_valist(methodinfo *m, java_handle_t *o, - va_list ap); -java_handle_t *vm_call_method_jvalue(methodinfo *m, java_handle_t *o, - const jvalue *args); - -int32_t vm_call_method_int(methodinfo *m, java_handle_t *o, ...); -int32_t vm_call_method_int_valist(methodinfo *m, java_handle_t *o, va_list ap); -int32_t vm_call_method_int_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); - -int64_t vm_call_method_long(methodinfo *m, java_handle_t *o, ...); -int64_t vm_call_method_long_valist(methodinfo *m, java_handle_t *o, va_list ap); -int64_t vm_call_method_long_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); - -float vm_call_method_float(methodinfo *m, java_handle_t *o, ...); -float vm_call_method_float_valist(methodinfo *m, java_handle_t *o, va_list ap); -float vm_call_method_float_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); - -double vm_call_method_double(methodinfo *m, java_handle_t *o, ...); -double vm_call_method_double_valist(methodinfo *m, java_handle_t *o, va_list ap); -double vm_call_method_double_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); - -java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params); - -#endif /* _VM_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vm/vm.hpp b/src/vm/vm.hpp new file mode 100644 index 000000000..3fd13dea7 --- /dev/null +++ b/src/vm/vm.hpp @@ -0,0 +1,196 @@ +/* src/vm/vm.hpp - basic JVM functions + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _VM_HPP +#define _VM_HPP + +#include "config.h" + +#include +#include + +// We need the JNI types for the VM class. +#include "native/jni.hpp" + +#include "vm/properties.hpp" + + +#ifdef __cplusplus + +/** + * Represent an instance of a VM. + */ +class VM { +private: + // This is _the_ VM instance. + static VM* _vm; + + // JNI variables. + JavaVM* _javavm; + JNIEnv* _jnienv; + + // VM variables. + bool _initializing; + bool _created; + bool _exiting; + int64_t _starttime; + + // Subsystems. + Properties _properties; ///< Commandline properties. + +public: + // Constructor, Destructor. + VM(JavaVMInitArgs*); + ~VM(); + + // Static methods. + static bool create(JavaVM** p_vm, void** p_env, void* vm_args); + static VM* get_current() { return _vm; } + + static void print_build_time_config(); + void print_run_time_config(); + + // Getters for private members. + JavaVM* get_javavm() { return _javavm; } + JNIEnv* get_jnienv() { return _jnienv; } + bool is_initializing() { return _initializing; } + bool is_created() { return _created; } + bool is_exiting() { return _exiting; } + int64_t get_starttime() { return _starttime; } + + Properties& get_properties() { return _properties; } + + // Instance functions. + void abort(const char* text, ...); + void abort_errnum(int errnum, const char* text, ...); + void abort_errno(const char* text, ...); +}; + +#else + +JavaVM* VM_get_javavm(); +JNIEnv* VM_get_jnienv(); +bool VM_is_initializing(); +bool VM_is_created(); +int64_t VM_get_starttime(); + +#endif + + +// Includes. +#include "vm/global.h" +#include "vm/method.h" + + +/* These C methods are the exported interface. ********************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +bool VM_create(JavaVM** p_vm, void** p_env, void* vm_args); + +#ifdef __cplusplus +} +#endif + + +/* export global variables ****************************************************/ + +#if defined(ENABLE_INTRP) +extern uint8_t* intrp_main_stack; +#endif + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +void usage(void); + +bool vm_create(JavaVMInitArgs *vm_args); +void vm_run(JavaVM *vm, JavaVMInitArgs *vm_args); +int32_t vm_destroy(JavaVM *vm); +void vm_exit(int32_t status); +void vm_shutdown(int32_t status); + +void vm_exit_handler(void); + +void vm_abort_disassemble(void *pc, int count, const char *text, ...); + +/* Java method calling functions */ + +java_handle_t *vm_call_method(methodinfo *m, java_handle_t *o, ...); +java_handle_t *vm_call_method_valist(methodinfo *m, java_handle_t *o, + va_list ap); +java_handle_t *vm_call_method_jvalue(methodinfo *m, java_handle_t *o, + const jvalue *args); + +int32_t vm_call_method_int(methodinfo *m, java_handle_t *o, ...); +int32_t vm_call_method_int_valist(methodinfo *m, java_handle_t *o, va_list ap); +int32_t vm_call_method_int_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +int64_t vm_call_method_long(methodinfo *m, java_handle_t *o, ...); +int64_t vm_call_method_long_valist(methodinfo *m, java_handle_t *o, va_list ap); +int64_t vm_call_method_long_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +float vm_call_method_float(methodinfo *m, java_handle_t *o, ...); +float vm_call_method_float_valist(methodinfo *m, java_handle_t *o, va_list ap); +float vm_call_method_float_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +double vm_call_method_double(methodinfo *m, java_handle_t *o, ...); +double vm_call_method_double_valist(methodinfo *m, java_handle_t *o, va_list ap); +double vm_call_method_double_jvalue(methodinfo *m, java_handle_t *o, const jvalue *args); + +java_handle_t *vm_call_method_objectarray(methodinfo *m, java_handle_t *o, java_handle_objectarray_t *params); + + +// Legacy C interface. +void vm_abort(const char* text, ...); +void vm_abort_errnum(int errnum, const char* text, ...); +void vm_abort_errno(const char* text, ...); + +#ifdef __cplusplus +} +#endif + +#endif // _VM_HPP + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c++ + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/zip.c b/src/vm/zip.c new file mode 100644 index 000000000..109156079 --- /dev/null +++ b/src/vm/zip.c @@ -0,0 +1,460 @@ +/* src/vm/zip.c - ZIP file handling for bootstrap classloader + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include +#include + +#include "vm/types.h" + +#include "vm/descriptor.h" /* needed to prevent circular dependency */ +#include "toolbox/hashtable.h" + +#include "mm/memory.h" + +#include "vm/global.h" +#include "vm/suck.hpp" +#include "vm/utf8.h" +#include "vm/vm.hpp" +#include "vm/zip.h" + + +/* start size for classes hashtable *******************************************/ + +#define HASHTABLE_CLASSES_SIZE (1 << 10) + + +/* info taken from: + http://www.pkware.com/business_and_developers/developer/popups/appnote.txt +*/ + +/* all signatures in the ZIP file have a length of 4 bytes ********************/ + +#define SIGNATURE_LENGTH 4 + +/* Central directory structure ************************************************* + + [file header 1] + . + . + . + [file header n] + [digital signature] + + File header: + + central file header signature 4 bytes (0x02014b50) + version made by 2 bytes + version needed to extract 2 bytes + general purpose bit flag 2 bytes + compression method 2 bytes + last mod file time 2 bytes + last mod file date 2 bytes + crc-32 4 bytes + compressed size 4 bytes + uncompressed size 4 bytes + file name length 2 bytes + extra field length 2 bytes + file comment length 2 bytes + disk number start 2 bytes + internal file attributes 2 bytes + external file attributes 4 bytes + relative offset of local header 4 bytes + + file name (variable size) + extra field (variable size) + file comment (variable size) + + Digital signature: + + header signature 4 bytes (0x05054b50) + size of data 2 bytes + signature data (variable size) + +*******************************************************************************/ + +#define CDSFH_HEADER_SIZE 46 + +#define CDSFH_SIGNATURE 0x02014b50 +#define CDSFH_COMPRESSION_METHOD 10 +#define CDSFH_COMPRESSED_SIZE 20 +#define CDSFH_UNCOMPRESSED_SIZE 24 +#define CDSFH_FILE_NAME_LENGTH 28 +#define CDSFH_EXTRA_FIELD_LENGTH 30 +#define CDSFH_FILE_COMMENT_LENGTH 32 +#define CDSFH_RELATIVE_OFFSET 42 +#define CDSFH_FILENAME 46 + +typedef struct cdsfh cdsfh; + +struct cdsfh { + u2 compressionmethod; + u4 compressedsize; + u4 uncompressedsize; + u2 filenamelength; + u2 extrafieldlength; + u2 filecommentlength; + u4 relativeoffset; +}; + + +/* End of central directory record ********************************************* + + end of central dir signature 4 bytes (0x06054b50) + number of this disk 2 bytes + number of the disk with the + start of the central directory 2 bytes + total number of entries in the + central directory on this disk 2 bytes + total number of entries in + the central directory 2 bytes + size of the central directory 4 bytes + offset of start of central + directory with respect to + the starting disk number 4 bytes + .ZIP file comment length 2 bytes + .ZIP file comment (variable size) + +*******************************************************************************/ + +#define EOCDR_SIGNATURE 0x06054b50 +#define EOCDR_ENTRIES 10 +#define EOCDR_OFFSET 16 + +typedef struct eocdr eocdr; + +struct eocdr { + u2 entries; + u4 offset; +}; + + +/* zip_open ******************************************************************** + + XXX + +*******************************************************************************/ + +hashtable *zip_open(char *path) +{ + hashtable *ht; + hashtable_zipfile_entry *htzfe; + int fd; + u1 lfh_signature[SIGNATURE_LENGTH]; + off_t len; + u1 *filep; + s4 i; + u1 *p; + eocdr eocdr; + cdsfh cdsfh; + const char *filename; + const char *classext; + utf *u; + u4 key; /* hashkey computed from utf-text */ + u4 slot; /* slot in hashtable */ + + /* first of all, open the file */ + + if ((fd = open(path, O_RDONLY)) == -1) + return NULL; + + /* check for signature in first local file header */ + + if (read(fd, lfh_signature, SIGNATURE_LENGTH) != SIGNATURE_LENGTH) + return NULL; + + if (SUCK_LE_U4(lfh_signature) != LFH_SIGNATURE) + return NULL; + + /* get the file length */ + + if ((len = lseek(fd, 0, SEEK_END)) == -1) + return NULL; + + /* we better mmap the file */ + + filep = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0); + + /* some older compilers, like DEC OSF cc, don't like comparisons + on void* types */ + + if ((ptrint) filep == (ptrint) MAP_FAILED) + return NULL; + + /* find end of central directory record */ + + for (p = filep + len; p >= filep; p--) + if (SUCK_LE_U4(p) == EOCDR_SIGNATURE) + break; + + /* get number of entries in central directory */ + + eocdr.entries = SUCK_LE_U2(p + EOCDR_ENTRIES); + eocdr.offset = SUCK_LE_U4(p + EOCDR_OFFSET); + + /* create hashtable for filenames */ + + ht = NEW(hashtable); + + hashtable_create(ht, HASHTABLE_CLASSES_SIZE); + + /* add all file entries into the hashtable */ + + for (i = 0, p = filep + eocdr.offset; i < eocdr.entries; i++) { + /* check file header signature */ + + if (SUCK_LE_U4(p) != CDSFH_SIGNATURE) + return NULL; + + /* we found an entry */ + + cdsfh.compressionmethod = SUCK_LE_U2(p + CDSFH_COMPRESSION_METHOD); + cdsfh.compressedsize = SUCK_LE_U4(p + CDSFH_COMPRESSED_SIZE); + cdsfh.uncompressedsize = SUCK_LE_U4(p + CDSFH_UNCOMPRESSED_SIZE); + cdsfh.filenamelength = SUCK_LE_U2(p + CDSFH_FILE_NAME_LENGTH); + cdsfh.extrafieldlength = SUCK_LE_U2(p + CDSFH_EXTRA_FIELD_LENGTH); + cdsfh.filecommentlength = SUCK_LE_U2(p + CDSFH_FILE_COMMENT_LENGTH); + cdsfh.relativeoffset = SUCK_LE_U4(p + CDSFH_RELATIVE_OFFSET); + + /* create utf8 string of filename, strip .class from classes */ + + filename = (const char *) (p + CDSFH_FILENAME); + classext = filename + cdsfh.filenamelength - strlen(".class"); + + /* skip directory entries */ + + if (filename[cdsfh.filenamelength - 1] != '/') { + if (strncmp(classext, ".class", strlen(".class")) == 0) + u = utf_new(filename, cdsfh.filenamelength - strlen(".class")); + else + u = utf_new(filename, cdsfh.filenamelength); + + /* insert class into hashtable */ + + htzfe = NEW(hashtable_zipfile_entry); + + htzfe->filename = u; + htzfe->compressionmethod = cdsfh.compressionmethod; + htzfe->compressedsize = cdsfh.compressedsize; + htzfe->uncompressedsize = cdsfh.uncompressedsize; + htzfe->data = filep + cdsfh.relativeoffset; + + /* get hashtable slot */ + + key = utf_hashkey(u->text, u->blength); + slot = key & (ht->size - 1); + + /* insert into external chain */ + + htzfe->hashlink = ht->ptr[slot]; + + /* insert hashtable zipfile entry */ + + ht->ptr[slot] = htzfe; + ht->entries++; + } + + /* move to next central directory structure file header */ + + p = p + + CDSFH_HEADER_SIZE + + cdsfh.filenamelength + + cdsfh.extrafieldlength + + cdsfh.filecommentlength; + } + + /* return pointer to hashtable */ + + return ht; +} + + +/* zip_find ******************************************************************** + + Search for the given filename in the classpath entries of a zip file. + + NOTE: The '.class' extension is stripped when reading a zip file, so if + you want to find a .class file, you must search for its name _without_ + the '.class' extension. + XXX I dont like that, it makes foo and foo.class ambiguous. -Edwin + + IN: + lce..........the classpath entries for the zip file + u............the filename to look for + + RETURN VALUE: + hashtable_zipfile_entry * of the entry if found, or + NULL if not found + +*******************************************************************************/ + +hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u) +{ + hashtable *ht; + u4 key; /* hashkey computed from utf-text */ + u4 slot; /* slot in hashtable */ + hashtable_zipfile_entry *htzfe; /* hashtable element */ + + /* get classes hashtable from the classpath entry */ + + ht = lce->htclasses; + + /* get the hashtable slot of the name searched */ + + key = utf_hashkey(u->text, u->blength); + slot = key & (ht->size - 1); + htzfe = ht->ptr[slot]; + + /* search external hash chain for utf-symbol */ + + while (htzfe) { + if (htzfe->filename == u) + return htzfe; + + /* next element in external chain */ + + htzfe = htzfe->hashlink; + } + + /* file not found in this archive */ + + return NULL; +} + + +/* zip_get ******************************************************************** + + XXX + +*******************************************************************************/ + +classbuffer *zip_get(list_classpath_entry *lce, classinfo *c) +{ + hashtable_zipfile_entry *htzfe; + lfh lfh; + u1 *indata; + u1 *outdata; + z_stream zs; + int err; + classbuffer *cb; + + /* try to find the class in the current archive */ + + htzfe = zip_find(lce, c->name); + + if (htzfe == NULL) + return NULL; + + /* read stuff from local file header */ + + lfh.filenamelength = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH); + lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH); + + indata = htzfe->data + + LFH_HEADER_SIZE + + lfh.filenamelength + + lfh.extrafieldlength; + + /* allocate buffer for uncompressed data */ + + outdata = MNEW(u1, htzfe->uncompressedsize); + + /* how is the file stored? */ + + switch (htzfe->compressionmethod) { + case Z_DEFLATED: + /* fill z_stream structure */ + + zs.next_in = indata; + zs.avail_in = htzfe->compressedsize; + zs.next_out = outdata; + zs.avail_out = htzfe->uncompressedsize; + + zs.zalloc = Z_NULL; + zs.zfree = Z_NULL; + zs.opaque = Z_NULL; + + /* initialize this inflate run */ + + if (inflateInit2(&zs, -MAX_WBITS) != Z_OK) + vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno)); + + /* decompress the file into buffer */ + + err = inflate(&zs, Z_SYNC_FLUSH); + + if ((err != Z_STREAM_END) && (err != Z_OK)) + vm_abort("zip_get: inflate failed: %s", strerror(errno)); + + /* finish this inflate run */ + + if (inflateEnd(&zs) != Z_OK) + vm_abort("zip_get: inflateEnd failed: %s", strerror(errno)); + break; + + case 0: + /* uncompressed file, just copy the data */ + MCOPY(outdata, indata, u1, htzfe->compressedsize); + break; + + default: + vm_abort("zip_get: unknown compression method %d", + htzfe->compressionmethod); + } + + /* allocate classbuffer */ + + cb = NEW(classbuffer); + + cb->clazz = c; + cb->size = htzfe->uncompressedsize; + cb->data = outdata; + cb->pos = outdata; + cb->path = lce->path; + + /* return the filled classbuffer structure */ + + return cb; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + * vim:noexpandtab:sw=4:ts=4: + */ diff --git a/src/vm/zip.h b/src/vm/zip.h new file mode 100644 index 000000000..f36382f06 --- /dev/null +++ b/src/vm/zip.h @@ -0,0 +1,118 @@ +/* src/vm/zip.c - ZIP file handling for bootstrap classloader + + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +#ifndef _ZIP_H +#define _ZIP_H + +#include "config.h" +#include "vm/types.h" + +#include "toolbox/hashtable.h" + +#include "vm/class.h" +#include "vm/global.h" +#include "vm/loader.hpp" +#include "vm/suck.hpp" +#include "vm/utf8.h" + + +/* Local file header *********************************************************** + + local file header signature 4 bytes (0x04034b50) + version needed to extract 2 bytes + general purpose bit flag 2 bytes + compression method 2 bytes + last mod file time 2 bytes + last mod file date 2 bytes + crc-32 4 bytes + compressed size 4 bytes + uncompressed size 4 bytes + file name length 2 bytes + extra field length 2 bytes + + file name (variable size) + extra field (variable size) + +*******************************************************************************/ + +#define LFH_HEADER_SIZE 30 + +#define LFH_SIGNATURE 0x04034b50 +#define LFH_FILE_NAME_LENGTH 26 +#define LFH_EXTRA_FIELD_LENGTH 28 + +typedef struct lfh lfh; + +struct lfh { + u2 compressionmethod; + u4 compressedsize; + u4 uncompressedsize; + u2 filenamelength; + u2 extrafieldlength; +}; + +/* hashtable_zipfile_entry ****************************************************/ + +typedef struct hashtable_zipfile_entry hashtable_zipfile_entry; + +struct hashtable_zipfile_entry { + utf *filename; + u2 compressionmethod; + u4 compressedsize; + u4 uncompressedsize; + u1 *data; + hashtable_zipfile_entry *hashlink; +}; + + +/* function prototypes ********************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +hashtable *zip_open(char *path); +hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u); +classbuffer *zip_get(list_classpath_entry *lce, classinfo *c); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZIP_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vmcore/Makefile.am b/src/vmcore/Makefile.am deleted file mode 100644 index 1b288f401..000000000 --- a/src/vmcore/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ -## src/vmcore/Makefile.am -## -## Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel, -## C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, -## E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, -## J. Wenninger, Institut f. Computersprachen - TU Wien -## -## This file is part of CACAO. -## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 2, or (at -## your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - - -AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR) -I$(top_srcdir)/src/vm/jit/$(ARCH_DIR)/$(OS_DIR) - -LIBS = - -if ENABLE_JAVASE -if ENABLE_ANNOTATIONS -ANNOTATION_SOURCES = \ - annotation.c \ - annotation.h -endif - -STACKMAP_SOURCES = \ - stackmap.c \ - stackmap.h -endif - -if ENABLE_RT_TIMING -RT_TIMING_SOURCES = \ - rt-timing.c \ - rt-timing.h -endif - -if ENABLE_STATISTICS -STATISTICS_SOURCES = \ - statistics.c \ - statistics.h -endif - -if ENABLE_ZLIB -ZLIB_SOURCES = \ - zip.c \ - zip.h -endif - -noinst_LTLIBRARIES = \ - libvmcore.la - -libvmcore_la_SOURCES = \ - $(ANNOTATION_SOURCES) \ - class.c \ - class.h \ - classcache.c \ - classcache.h \ - descriptor.c \ - descriptor.h \ - field.c \ - field.h \ - linker.c \ - linker.h \ - loader.c \ - loader.h \ - method.c \ - method.h \ - options.c \ - options.h \ - primitivecore.c \ - references.h \ - $(RT_TIMING_SOURCES) \ - $(STACKMAP_SOURCES) \ - $(STATISTICS_SOURCES) \ - suck.c \ - suck.h \ - system.c \ - system.h \ - utf8.c \ - utf8.h \ - $(ZLIB_SOURCES) - - -## Local variables: -## mode: Makefile -## indent-tabs-mode: t -## c-basic-offset: 4 -## tab-width: 8 -## compile-command: "automake --add-missing" -## End: diff --git a/src/vmcore/annotation.c b/src/vmcore/annotation.c deleted file mode 100644 index 4d7021d4d..000000000 --- a/src/vmcore/annotation.c +++ /dev/null @@ -1,615 +0,0 @@ -/* src/vmcore/annotation.c - class annotations - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "native/llni.h" - -#include "vm/types.h" -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/primitive.h" - -#include "mm/memory.h" - -#include "toolbox/logging.h" - -#include "vmcore/annotation.h" -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/suck.h" - -#if !defined(ENABLE_ANNOTATIONS) -# error annotation support has to be enabled when compling this file! -#endif - - -/* annotation_bytearrays_resize *********************************************** - - Resize an array of bytearrays. - - IN: - bytearrays.....array of bytearrays - size...........new size of the refered array - - RETURN VALUE: - The new array if a resize was neccessarry, the old if the given size - equals the current size or NULL if an error occured. - -*******************************************************************************/ - -static java_handle_objectarray_t *annotation_bytearrays_resize( - java_handle_objectarray_t *bytearrays, uint32_t size) -{ - java_handle_objectarray_t *newbas = NULL; /* new array */ - uint32_t minsize = 0; /* count of object refs to copy */ - uint32_t oldsize = 0; /* size of old array */ - - if (bytearrays != NULL) { - oldsize = array_length_get((java_handle_t*)bytearrays); - - /* if the size already fits do nothing */ - if (size == oldsize) { - return bytearrays; - } - } - - newbas = builtin_anewarray(size, - primitive_arrayclass_get_by_type(PRIMITIVETYPE_BYTE)); - - /* is there a old byte array array? */ - if (newbas != NULL && bytearrays != NULL) { - minsize = size < oldsize ? size : oldsize; - - LLNI_CRITICAL_START; - MCOPY( - LLNI_array_data(newbas), LLNI_array_data(bytearrays), - java_object_t*, minsize); - LLNI_CRITICAL_END; - } - - return newbas; -} - - -/* annotation_bytearrays_insert *********************************************** - - Insert a bytearray into an array of bytearrays. - - IN: - bytearrays........array of bytearrays where 'bytearray' has to be - inserted at position 'index'. - index.............position where 'ba' has to be inserted into - 'bytearrays'. - bytearray.........byte array which has to be inserted into - 'bytearrays'. - - RETURN VALUE: - The new array if a resize was neccessarry, the old if the given size - equals the current size or NULL if an error occured. - -*******************************************************************************/ - -static java_handle_t *annotation_bytearrays_insert( - java_handle_t *bytearrays, uint32_t index, - java_handle_bytearray_t *bytearray) -{ - java_handle_objectarray_t *bas; /* bytearrays */ - uint32_t size = 0; /* current size of the array */ - - /* do nothing if NULL is inserted but no array exists */ - if (bytearray == NULL && bytearrays == NULL) { - return NULL; - } - - /* get lengths if array exists */ - if (bytearrays != NULL) { - size = array_length_get(bytearrays); - } - - bas = (java_handle_objectarray_t*)bytearrays; - - if (bytearray == NULL) { - /* insert NULL only if array is big enough */ - if (size > index) { - array_objectarray_element_set(bas, index, NULL); - } - } - else { - /* resize array if it's not enough for inserted value */ - if (size <= index) { - bas = annotation_bytearrays_resize(bas, index + 1); - - if (bas == NULL) { - /* out of memory */ - return NULL; - } - } - - array_objectarray_element_set(bas, index, (java_handle_t*)bytearray); - } - - return (java_handle_t*)bas; -} - - -/* annotation_load_attribute_body ********************************************* - - This function loads the body of a generic attribute. - - XXX: Maybe this function should be called loader_load_attribute_body and - located in vmcore/loader.c? - - attribute_info { - u2 attribute_name_index; - u4 attribute_length; - u1 info[attribute_length]; - } - - IN: - cb.................classbuffer from which to read the data. - errormsg_prefix....prefix for error messages (if any). - - OUT: - attribute..........bytearray-pointer which will be set to the read data. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -static bool annotation_load_attribute_body(classbuffer *cb, - java_handle_bytearray_t **attribute, const char *errormsg_prefix) -{ - uint32_t size = 0; /* size of the attribute */ - java_handle_bytearray_t *ba = NULL; /* the raw attributes' bytes */ - - assert(cb != NULL); - assert(attribute != NULL); - - if (!suck_check_classbuffer_size(cb, 4)) { - log_println("%s: size missing", errormsg_prefix); - return false; - } - - /* load attribute_length */ - size = suck_u4(cb); - - if (!suck_check_classbuffer_size(cb, size)) { - log_println("%s: invalid size", errormsg_prefix); - return false; - } - - /* if attribute_length == 0 then NULL is - * the right value for this attribute */ - if (size > 0) { - ba = builtin_newarray_byte(size); - - if (ba == NULL) { - /* out of memory */ - return false; - } - - /* load data */ - LLNI_CRITICAL_START; - - suck_nbytes((uint8_t*)LLNI_array_data(ba), cb, size); - - LLNI_CRITICAL_END; - - /* return data */ - *attribute = ba; - } - - return true; -} - - -/* annotation_load_method_attribute_annotationdefault ************************* - - Load annotation default value. - - AnnotationDefault_attribute { - u2 attribute_name_index; - u4 attribute_length; - element_value default_value; - } - - IN: - cb.................classbuffer from which to read the data. - m..................methodinfo for the method of which the annotation - default value is read and into which the value is - stored into. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_method_attribute_annotationdefault( - classbuffer *cb, methodinfo *m) -{ - int slot = 0; - /* the slot of the method */ - java_handle_bytearray_t *annotationdefault = NULL; - /* unparsed annotation defalut value */ - java_handle_t *annotationdefaults = NULL; - /* array of unparsed annotation default values */ - - assert(cb != NULL); - assert(m != NULL); - - LLNI_classinfo_field_get( - m->clazz, method_annotationdefaults, annotationdefaults); - - if (!annotation_load_attribute_body( - cb, &annotationdefault, - "invalid annotation default method attribute")) { - return false; - } - - if (annotationdefault != NULL) { - slot = m - m->clazz->methods; - annotationdefaults = annotation_bytearrays_insert( - annotationdefaults, slot, annotationdefault); - - if (annotationdefaults == NULL) { - return false; - } - - LLNI_classinfo_field_set( - m->clazz, method_annotationdefaults, annotationdefaults); - } - - return true; -} - - -/* annotation_load_method_attribute_runtimevisibleparameterannotations ******** - - Load runtime visible parameter annotations. - - RuntimeVisibleParameterAnnotations_attribute { - u2 attribute_name_index; - u4 attribute_length; - u1 num_parameters; - { - u2 num_annotations; - annotation annotations[num_annotations]; - } parameter_annotations[num_parameters]; - } - - IN: - cb.................classbuffer from which to read the data. - m..................methodinfo for the method of which the parameter - annotations are read and into which the parameter - annotations are stored into. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_method_attribute_runtimevisibleparameterannotations( - classbuffer *cb, methodinfo *m) -{ - int slot = 0; - /* the slot of the method */ - java_handle_bytearray_t *annotations = NULL; - /* unparsed parameter annotations */ - java_handle_t *parameterannotations = NULL; - /* array of unparsed parameter annotations */ - - assert(cb != NULL); - assert(m != NULL); - - LLNI_classinfo_field_get( - m->clazz, method_parameterannotations, parameterannotations); - - if (!annotation_load_attribute_body( - cb, &annotations, - "invalid runtime visible parameter annotations method attribute")) { - return false; - } - - if (annotations != NULL) { - slot = m - m->clazz->methods; - parameterannotations = annotation_bytearrays_insert( - parameterannotations, slot, annotations); - - if (parameterannotations == NULL) { - return false; - } - - LLNI_classinfo_field_set( - m->clazz, method_parameterannotations, parameterannotations); - } - - return true; -} - - -/* annotation_load_method_attribute_runtimeinvisibleparameterannotations ****** - - Load runtime invisible parameter annotations. - - - The RuntimeInvisibleParameterAnnotations attribute is similar to the - RuntimeVisibleParameterAnnotations attribute, except that the annotations - represented by a RuntimeInvisibleParameterAnnotations attribute must not be - made available for return by reflective APIs, unless the the JVM has - specifically been instructed to retain these annotations via some - implementation-specific mechanism such as a command line flag. In the - absence of such instructions, the JVM ignores this attribute. - - - Hotspot loads them into the same bytearray as the runtime visible parameter - annotations (after the runtime visible parameter annotations). But in J2SE - the bytearray will only be parsed as if there is only one annotation - structure in it, so the runtime invisible parameter annotatios will be - ignored. - - Therefore I do not even bother to read them. - - RuntimeInvisibleParameterAnnotations_attribute { - u2 attribute_name_index; - u4 attribute_length; - u1 num_parameters; - { - u2 num_annotations; - annotation annotations[num_annotations]; - } parameter_annotations[num_parameters]; - } - - IN: - cb.................classbuffer from which to read the data. - m..................methodinfo for the method of which the parameter - annotations are read and into which the parameter - annotations are stored into. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_method_attribute_runtimeinvisibleparameterannotations( - classbuffer *cb, methodinfo *m) -{ - return loader_skip_attribute_body(cb); -} - - -/* annotation_load_class_attribute_runtimevisibleannotations ****************** - - Load runtime visible annotations of a class. - - IN: - cb........the classbuffer from which the attribute has to be loaded. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_class_attribute_runtimevisibleannotations( - classbuffer *cb) -{ - java_handle_bytearray_t *annotations = NULL; /* unparsed annotations */ - - if (!annotation_load_attribute_body( - cb, &annotations, - "invalid runtime visible annotations class attribute")) { - return false; - } - - LLNI_classinfo_field_set(cb->clazz, annotations, (java_handle_t*)annotations); - - return true; -} - - -/* annotation_load_class_attribute_runtimeinvisibleannotations **************** - - Load runtime invisible annotations of a class (just skip them). - - IN: - cb........the classbuffer from which the attribute has to be loaded. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_class_attribute_runtimeinvisibleannotations( - classbuffer *cb) -{ - return loader_skip_attribute_body(cb); -} - - -/* annotation_load_method_attribute_runtimevisibleannotations ***************** - - Load runtime visible annotations of a method. - - IN: - cb........the classbuffer from which the attribute has to be loaded. - m.........the method of which the runtime visible annotations have - to be loaded. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_method_attribute_runtimevisibleannotations( - classbuffer *cb, methodinfo *m) -{ - int slot = 0; - /* slot of the method */ - java_handle_bytearray_t *annotations = NULL; - /* unparsed annotations */ - java_handle_t *method_annotations = NULL; - /* array of unparsed method annotations */ - - assert(cb != NULL); - assert(m != NULL); - - LLNI_classinfo_field_get( - m->clazz, method_annotations, method_annotations); - - if (!annotation_load_attribute_body( - cb, &annotations, - "invalid runtime visible annotations method attribute")) { - return false; - } - - if (annotations != NULL) { - slot = m - m->clazz->methods; - method_annotations = annotation_bytearrays_insert( - method_annotations, slot, annotations); - - if (method_annotations == NULL) { - return false; - } - - LLNI_classinfo_field_set( - m->clazz, method_annotations, method_annotations); - } - - return true; -} - - -/* annotation_load_method_attribute_runtimeinvisibleannotations **************** - - Load runtime invisible annotations of a method (just skip them). - - IN: - cb........the classbuffer from which the attribute has to be loaded. - m.........the method of which the runtime invisible annotations have - to be loaded. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_method_attribute_runtimeinvisibleannotations( - classbuffer *cb, methodinfo *m) -{ - return loader_skip_attribute_body(cb); -} - - -/* annotation_load_field_attribute_runtimevisibleannotations ****************** - - Load runtime visible annotations of a field. - - IN: - cb........the classbuffer from which the attribute has to be loaded. - f.........the field of which the runtime visible annotations have - to be loaded. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_field_attribute_runtimevisibleannotations( - classbuffer *cb, fieldinfo *f) -{ - int slot = 0; - /* slot of the field */ - java_handle_bytearray_t *annotations = NULL; - /* unparsed annotations */ - java_handle_t *field_annotations = NULL; - /* array of unparsed field annotations */ - - assert(cb != NULL); - assert(f != NULL); - - LLNI_classinfo_field_get( - f->clazz, field_annotations, field_annotations); - - if (!annotation_load_attribute_body( - cb, &annotations, - "invalid runtime visible annotations field attribute")) { - return false; - } - - if (annotations != NULL) { - slot = f - f->clazz->fields; - field_annotations = annotation_bytearrays_insert( - field_annotations, slot, annotations); - - if (field_annotations == NULL) { - return false; - } - - LLNI_classinfo_field_set( - f->clazz, field_annotations, field_annotations); - } - - return true; -} - - -/* annotation_load_field_attribute_runtimeinvisibleannotations **************** - - Load runtime invisible annotations of a field (just skip them). - - IN: - cb........the classbuffer from which the attribute has to be loaded. - f.........the field of which the runtime invisible annotations have - to be loaded. - - RETURN VALUE: - true if all went good. false otherwhise. - -*******************************************************************************/ - -bool annotation_load_field_attribute_runtimeinvisibleannotations( - classbuffer *cb, fieldinfo *f) -{ - return loader_skip_attribute_body(cb); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/annotation.h b/src/vmcore/annotation.h deleted file mode 100644 index 7ec071d3d..000000000 --- a/src/vmcore/annotation.h +++ /dev/null @@ -1,87 +0,0 @@ -/* src/vmcore/annotation.h - class annotations - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _ANNOTATION_H -#define _ANNOTATION_H - - -#include "config.h" - -#include "vm/types.h" -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" - - -/* function prototypes ********************************************************/ - -bool annotation_load_class_attribute_runtimevisibleannotations( - classbuffer *cb); - -bool annotation_load_class_attribute_runtimeinvisibleannotations( - classbuffer *cb); - -bool annotation_load_method_attribute_runtimevisibleannotations( - classbuffer *cb, methodinfo *m); - -bool annotation_load_method_attribute_runtimeinvisibleannotations( - classbuffer *cb, methodinfo *m); - -bool annotation_load_field_attribute_runtimevisibleannotations( - classbuffer *cb, fieldinfo *f); - -bool annotation_load_field_attribute_runtimeinvisibleannotations( - classbuffer *cb, fieldinfo *f); - -bool annotation_load_method_attribute_annotationdefault( - classbuffer *cb, methodinfo *m); - -bool annotation_load_method_attribute_runtimevisibleparameterannotations( - classbuffer *cb, methodinfo *m); - -bool annotation_load_method_attribute_runtimeinvisibleparameterannotations( - classbuffer *cb, methodinfo *m); - -#endif /* _ANNOTATION_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/class.c b/src/vmcore/class.c deleted file mode 100644 index c680d0a0f..000000000 --- a/src/vmcore/class.c +++ /dev/null @@ -1,2592 +0,0 @@ -/* src/vmcore/class.c - class related functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include - -#include "vm/types.h" - -#include "arch.h" - -#include "mm/memory.h" - -#include "native/llni.h" - -#include "threads/lock-common.h" - -#include "toolbox/logging.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/resolve.h" - -#include "vm/jit/asmpart.h" - -#include "vmcore/class.h" -#include "vmcore/classcache.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#include "vmcore/suck.h" -#include "vmcore/utf8.h" - - -#if defined(ENABLE_JAVASE) -/* We need to define some reflection functions here since we cannot - include native/vm/reflect.h as it includes generated header - files. */ - -java_object_t *reflect_constructor_new(methodinfo *m); -java_object_t *reflect_field_new(fieldinfo *f); -java_object_t *reflect_method_new(methodinfo *m); -#endif - - -/* global variables ***********************************************************/ - -/* frequently used classes ****************************************************/ - -/* Important system classes. */ - -classinfo *class_java_lang_Object; -classinfo *class_java_lang_Class; -classinfo *class_java_lang_ClassLoader; -classinfo *class_java_lang_Cloneable; -classinfo *class_java_lang_SecurityManager; -classinfo *class_java_lang_String; -classinfo *class_java_lang_System; -classinfo *class_java_lang_Thread; -classinfo *class_java_lang_ThreadGroup; -classinfo *class_java_lang_Throwable; -classinfo *class_java_io_Serializable; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -classinfo *class_java_lang_VMSystem; -classinfo *class_java_lang_VMThread; -classinfo *class_java_lang_VMThrowable; -#endif - -/* Important system exceptions. */ - -classinfo *class_java_lang_Exception; -classinfo *class_java_lang_ClassNotFoundException; -classinfo *class_java_lang_RuntimeException; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -classinfo *class_sun_reflect_MagicAccessorImpl; -#endif - -#if defined(ENABLE_JAVASE) -classinfo *class_java_lang_Void; -#endif -classinfo *class_java_lang_Boolean; -classinfo *class_java_lang_Byte; -classinfo *class_java_lang_Character; -classinfo *class_java_lang_Short; -classinfo *class_java_lang_Integer; -classinfo *class_java_lang_Long; -classinfo *class_java_lang_Float; -classinfo *class_java_lang_Double; - -/* some classes which may be used more often */ - -#if defined(ENABLE_JAVASE) -classinfo *class_java_lang_StackTraceElement; -classinfo *class_java_lang_reflect_Constructor; -classinfo *class_java_lang_reflect_Field; -classinfo *class_java_lang_reflect_Method; -classinfo *class_java_security_PrivilegedAction; -classinfo *class_java_util_Vector; -classinfo *class_java_util_HashMap; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -classinfo *class_java_lang_reflect_VMConstructor; -classinfo *class_java_lang_reflect_VMField; -classinfo *class_java_lang_reflect_VMMethod; -# endif - -classinfo *arrayclass_java_lang_Object; - -# if defined(ENABLE_ANNOTATIONS) -classinfo *class_sun_reflect_ConstantPool; -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -classinfo *class_sun_reflect_annotation_AnnotationParser; -# endif -# endif -#endif - -/* pseudo classes for the typechecker */ - -classinfo *pseudo_class_Arraystub; -classinfo *pseudo_class_Null; -classinfo *pseudo_class_New; - - -/* class_set_packagename ******************************************************* - - Derive the package name from the class name and store it in the - struct. - - An internal package name consists of the package name plus the - trailing '/', e.g. "java/lang/". - - For classes in the unnamed package, the package name is set to - NULL. - -*******************************************************************************/ - -void class_set_packagename(classinfo *c) -{ - char *p; - char *start; - - p = UTF_END(c->name) - 1; - start = c->name->text; - - if (c->name->text[0] == '[') { - /* Set packagename of arrays to the element's package. */ - - for (; *start == '['; start++); - - /* Skip the 'L' in arrays of references. */ - - if (*start == 'L') - start++; - } - - /* Search for last '/'. */ - - for (; (p > start) && (*p != '/'); --p); - - /* If we found a '/' we set the package name plus the trailing - '/'. Otherwise we set the packagename to NULL. */ - - if (p > start) - c->packagename = utf_new(start, p - start + 1); - else - c->packagename = NULL; -} - - -/* class_create_classinfo ****************************************************** - - Create a new classinfo struct. The class name is set to the given utf *, - most other fields are initialized to zero. - - Note: classname may be NULL. In this case a not-yet-named classinfo is - created. The name must be filled in later and class_set_packagename - must be called after that. - -*******************************************************************************/ - -classinfo *class_create_classinfo(utf *classname) -{ - classinfo *c; - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_classinfo += sizeof(classinfo); -#endif - - /* we use a safe name for temporarily unnamed classes */ - - if (classname == NULL) - classname = utf_not_named_yet; - -#if !defined(NDEBUG) - if (initverbose) - log_message_utf("Creating class: ", classname); -#endif - -#if !defined(ENABLE_GC_BOEHM) - c = (classinfo *) heap_alloc_uncollectable(sizeof(classinfo)); - /*c = NEW(classinfo); - MZERO(c, classinfo, 1);*/ -#else - c = GCNEW_UNCOLLECTABLE(classinfo, 1); - /* GCNEW_UNCOLLECTABLE clears the allocated memory */ -#endif - - c->name = classname; - - /* Set the header.vftbl of all loaded classes to the one of - java.lang.Class, so Java code can use a class as object. */ - - if (class_java_lang_Class != NULL) - if (class_java_lang_Class->vftbl != NULL) - c->object.header.vftbl = class_java_lang_Class->vftbl; - -#if defined(ENABLE_JAVASE) - /* check if the class is a reference class and flag it */ - - if (classname == utf_java_lang_ref_SoftReference) { - c->flags |= ACC_CLASS_REFERENCE_SOFT; - } - else if (classname == utf_java_lang_ref_WeakReference) { - c->flags |= ACC_CLASS_REFERENCE_WEAK; - } - else if (classname == utf_java_lang_ref_PhantomReference) { - c->flags |= ACC_CLASS_REFERENCE_PHANTOM; - } -#endif - - if (classname != utf_not_named_yet) - class_set_packagename(c); - - LOCK_INIT_OBJECT_LOCK(&c->object.header); - - return c; -} - - -/* class_postset_header_vftbl ************************************************** - - Set the header.vftbl of all classes created before java.lang.Class - was linked. This is necessary that Java code can use a class as - object. - -*******************************************************************************/ - -void class_postset_header_vftbl(void) -{ - classinfo *c; - u4 slot; - classcache_name_entry *nmen; - classcache_class_entry *clsen; - - assert(class_java_lang_Class); - - for (slot = 0; slot < hashtable_classcache.size; slot++) { - nmen = (classcache_name_entry *) hashtable_classcache.ptr[slot]; - - for (; nmen; nmen = nmen->hashlink) { - /* iterate over all class entries */ - - for (clsen = nmen->classes; clsen; clsen = clsen->next) { - c = clsen->classobj; - - /* now set the the vftbl */ - - if (c->object.header.vftbl == NULL) - c->object.header.vftbl = class_java_lang_Class->vftbl; - } - } - } -} - -/* class_define **************************************************************** - - Calls the loader and defines a class in the VM. - -*******************************************************************************/ - -classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd) -{ - classinfo *c; - classinfo *r; - classbuffer *cb; - - if (name != NULL) { - /* check if this class has already been defined */ - - c = classcache_lookup_defined_or_initiated(cl, name); - - if (c != NULL) { - exceptions_throw_linkageerror("duplicate class definition: ", c); - return NULL; - } - } - - /* create a new classinfo struct */ - - c = class_create_classinfo(name); - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getloadingtime) - loadingtime_start(); -#endif - - /* build a classbuffer with the given data */ - - cb = NEW(classbuffer); - - cb->clazz = c; - cb->size = length; - cb->data = data; - cb->pos = cb->data; - - /* preset the defining classloader */ - - c->classloader = cl; - - /* load the class from this buffer */ - - r = load_class_from_classbuffer(cb); - - /* free memory */ - - FREE(cb, classbuffer); - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getloadingtime) - loadingtime_stop(); -#endif - - if (r == NULL) { - /* If return value is NULL, we had a problem and the class is - not loaded. Now free the allocated memory, otherwise we - could run into a DOS. */ - - class_free(c); - - return NULL; - } - -#if defined(ENABLE_JAVASE) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - /* Store the protection domain. */ - - c->protectiondomain = pd; -# endif -#endif - - /* Store the newly defined class in the class cache. This call - also checks whether a class of the same name has already been - defined by the same defining loader, and if so, replaces the - newly created class by the one defined earlier. */ - - /* Important: The classinfo given to classcache_store must be - fully prepared because another thread may return - this pointer after the lookup at to top of this - function directly after the class cache lock has - been released. */ - - c = classcache_store(cl, c, true); - - return c; -} - - -/* class_load_attribute_sourcefile ********************************************* - - SourceFile_attribute { - u2 attribute_name_index; - u4 attribute_length; - u2 sourcefile_index; - } - -*******************************************************************************/ - -static bool class_load_attribute_sourcefile(classbuffer *cb) -{ - classinfo *c; - u4 attribute_length; - u2 sourcefile_index; - utf *sourcefile; - - /* get classinfo */ - - c = cb->clazz; - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* check attribute length */ - - attribute_length = suck_u4(cb); - - if (attribute_length != 2) { - exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); - return false; - } - - /* there can be no more than one SourceFile attribute */ - - if (c->sourcefile != NULL) { - exceptions_throw_classformaterror(c, "Multiple SourceFile attributes"); - return false; - } - - /* get sourcefile */ - - sourcefile_index = suck_u2(cb); - sourcefile = class_getconstant(c, sourcefile_index, CONSTANT_Utf8); - - if (sourcefile == NULL) - return false; - - /* store sourcefile */ - - c->sourcefile = sourcefile; - - return true; -} - - -/* class_load_attribute_enclosingmethod **************************************** - - EnclosingMethod_attribute { - u2 attribute_name_index; - u4 attribute_length; - u2 class_index; - u2 method_index; - } - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -static bool class_load_attribute_enclosingmethod(classbuffer *cb) -{ - classinfo *c; - u4 attribute_length; - u2 class_index; - u2 method_index; - classref_or_classinfo cr; - constant_nameandtype *cn; - - /* get classinfo */ - - c = cb->clazz; - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 4 + 2 + 2)) - return false; - - /* check attribute length */ - - attribute_length = suck_u4(cb); - - if (attribute_length != 4) { - exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); - return false; - } - - /* there can be no more than one EnclosingMethod attribute */ - - if (c->enclosingmethod != NULL) { - exceptions_throw_classformaterror(c, "Multiple EnclosingMethod attributes"); - return false; - } - - /* get class index */ - - class_index = suck_u2(cb); - cr.ref = innerclass_getconstant(c, class_index, CONSTANT_Class); - - /* get method index */ - - method_index = suck_u2(cb); - cn = innerclass_getconstant(c, method_index, CONSTANT_NameAndType); - - /* store info in classinfo */ - - c->enclosingclass.any = cr.any; - c->enclosingmethod = cn; - - return true; -} -#endif /* defined(ENABLE_JAVASE) */ - - -/* class_load_attributes ******************************************************* - - Read attributes from ClassFile. - - attribute_info { - u2 attribute_name_index; - u4 attribute_length; - u1 info[attribute_length]; - } - - InnerClasses_attribute { - u2 attribute_name_index; - u4 attribute_length; - } - -*******************************************************************************/ - -bool class_load_attributes(classbuffer *cb) -{ - classinfo *c; - uint16_t attributes_count; - uint16_t attribute_name_index; - utf *attribute_name; - innerclassinfo *info; - classref_or_classinfo inner; - classref_or_classinfo outer; - utf *name; - uint16_t flags; - int i, j; - - c = cb->clazz; - - /* get attributes count */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - attributes_count = suck_u2(cb); - - for (i = 0; i < attributes_count; i++) { - /* get attribute name */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - attribute_name_index = suck_u2(cb); - attribute_name = - class_getconstant(c, attribute_name_index, CONSTANT_Utf8); - - if (attribute_name == NULL) - return false; - - if (attribute_name == utf_InnerClasses) { - /* InnerClasses */ - - if (c->innerclass != NULL) { - exceptions_throw_classformaterror(c, "Multiple InnerClasses attributes"); - return false; - } - - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* skip attribute length */ - suck_u4(cb); - - /* number of records */ - c->innerclasscount = suck_u2(cb); - - if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * c->innerclasscount)) - return false; - - /* allocate memory for innerclass structure */ - c->innerclass = MNEW(innerclassinfo, c->innerclasscount); - - for (j = 0; j < c->innerclasscount; j++) { - /* The innerclass structure contains a class with an encoded - name, its defining scope, its simple name and a bitmask of - the access flags. */ - - info = c->innerclass + j; - - inner.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class); - outer.ref = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Class); - name = innerclass_getconstant(c, suck_u2(cb), CONSTANT_Utf8); - flags = suck_u2(cb); - - /* If the current inner-class is the currently loaded - class check for some special flags. */ - - if (inner.ref->name == c->name) { - /* If an inner-class is not a member, its - outer-class is NULL. */ - - if (outer.ref != NULL) { - c->flags |= ACC_CLASS_MEMBER; - - /* A member class doesn't have an - EnclosingMethod attribute, so set the - enclosing-class to be the same as the - declaring-class. */ - - c->declaringclass = outer; - c->enclosingclass = outer; - } - - /* If an inner-class is anonymous, its name is - NULL. */ - - if (name == NULL) - c->flags |= ACC_CLASS_ANONYMOUS; - } - - info->inner_class = inner; - info->outer_class = outer; - info->name = name; - info->flags = flags; - } - } - else if (attribute_name == utf_SourceFile) { - /* SourceFile */ - - if (!class_load_attribute_sourcefile(cb)) - return false; - } -#if defined(ENABLE_JAVASE) - else if (attribute_name == utf_EnclosingMethod) { - /* EnclosingMethod */ - - if (!class_load_attribute_enclosingmethod(cb)) - return false; - } - else if (attribute_name == utf_Signature) { - /* Signature */ - - if (!loader_load_attribute_signature(cb, &(c->signature))) - return false; - } -#endif - -#if defined(ENABLE_ANNOTATIONS) - else if (attribute_name == utf_RuntimeVisibleAnnotations) { - /* RuntimeVisibleAnnotations */ - if (!annotation_load_class_attribute_runtimevisibleannotations(cb)) - return false; - } - else if (attribute_name == utf_RuntimeInvisibleAnnotations) { - /* RuntimeInvisibleAnnotations */ - if (!annotation_load_class_attribute_runtimeinvisibleannotations(cb)) - return false; - } -#endif - - else { - /* unknown attribute */ - - if (!loader_skip_attribute_body(cb)) - return false; - } - } - - return true; -} - - -/* class_freepool ************************************************************** - - Frees all resources used by this classes Constant Pool. - -*******************************************************************************/ - -static void class_freecpool(classinfo *c) -{ - u4 idx; - u4 tag; - voidptr info; - - if (c->cptags && c->cpinfos) { - for (idx = 0; idx < c->cpcount; idx++) { - tag = c->cptags[idx]; - info = c->cpinfos[idx]; - - if (info != NULL) { - switch (tag) { - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - FREE(info, constant_FMIref); - break; - case CONSTANT_Integer: - FREE(info, constant_integer); - break; - case CONSTANT_Float: - FREE(info, constant_float); - break; - case CONSTANT_Long: - FREE(info, constant_long); - break; - case CONSTANT_Double: - FREE(info, constant_double); - break; - case CONSTANT_NameAndType: - FREE(info, constant_nameandtype); - break; - } - } - } - } - - if (c->cptags) - MFREE(c->cptags, u1, c->cpcount); - - if (c->cpinfos) - MFREE(c->cpinfos, voidptr, c->cpcount); -} - - -/* class_getconstant *********************************************************** - - Retrieves the value at position 'pos' of the constantpool of a - class. If the type of the value is other than 'ctype', an error is - thrown. - -*******************************************************************************/ - -voidptr class_getconstant(classinfo *c, u4 pos, u4 ctype) -{ - /* check index and type of constantpool entry */ - /* (pos == 0 is caught by type comparison) */ - - if ((pos >= c->cpcount) || (c->cptags[pos] != ctype)) { - exceptions_throw_classformaterror(c, "Illegal constant pool index"); - return NULL; - } - - return c->cpinfos[pos]; -} - - -/* innerclass_getconstant ****************************************************** - - Like class_getconstant, but if cptags is ZERO, null is returned. - -*******************************************************************************/ - -voidptr innerclass_getconstant(classinfo *c, u4 pos, u4 ctype) -{ - /* invalid position in constantpool */ - - if (pos >= c->cpcount) { - exceptions_throw_classformaterror(c, "Illegal constant pool index"); - return NULL; - } - - /* constantpool entry of type 0 */ - - if (c->cptags[pos] == 0) - return NULL; - - /* check type of constantpool entry */ - - if (c->cptags[pos] != ctype) { - exceptions_throw_classformaterror(c, "Illegal constant pool index"); - return NULL; - } - - return c->cpinfos[pos]; -} - - -/* class_free ****************************************************************** - - Frees all resources used by the class. - -*******************************************************************************/ - -void class_free(classinfo *c) -{ - s4 i; - vftbl_t *v; - - class_freecpool(c); - - if (c->interfaces != NULL) - MFREE(c->interfaces, classinfo*, c->interfacescount); - - if (c->fields) { - for (i = 0; i < c->fieldscount; i++) - field_free(&(c->fields[i])); - MFREE(c->fields, fieldinfo, c->fieldscount); - } - - if (c->methods) { - for (i = 0; i < c->methodscount; i++) - method_free(&(c->methods[i])); - MFREE(c->methods, methodinfo, c->methodscount); - } - - if ((v = c->vftbl) != NULL) { - if (v->arraydesc) - mem_free(v->arraydesc,sizeof(arraydescriptor)); - - for (i = 0; i < v->interfacetablelength; i++) { - MFREE(v->interfacetable[-i], methodptr, v->interfacevftbllength[i]); - } - MFREE(v->interfacevftbllength, s4, v->interfacetablelength); - - i = sizeof(vftbl_t) + sizeof(methodptr) * (v->vftbllength - 1) + - sizeof(methodptr*) * (v->interfacetablelength - - (v->interfacetablelength > 0)); - v = (vftbl_t*) (((methodptr*) v) - - (v->interfacetablelength - 1) * (v->interfacetablelength > 1)); - mem_free(v, i); - } - - if (c->innerclass) - MFREE(c->innerclass, innerclassinfo, c->innerclasscount); - - /* if (c->classvftbl) - mem_free(c->header.vftbl, sizeof(vftbl) + sizeof(methodptr)*(c->vftbl->vftbllength-1)); */ - -/* GCFREE(c); */ -} - - -/* get_array_class ************************************************************* - - Returns the array class with the given name for the given - classloader, or NULL if an exception occurred. - - Note: This function does eager loading. - -*******************************************************************************/ - -static classinfo *get_array_class(utf *name,classloader_t *initloader, - classloader_t *defloader,bool link) -{ - classinfo *c; - - /* lookup this class in the classcache */ - c = classcache_lookup(initloader,name); - if (!c) - c = classcache_lookup_defined(defloader,name); - - if (!c) { - /* we have to create it */ - c = class_create_classinfo(name); - c = load_newly_created_array(c,initloader); - if (c == NULL) - return NULL; - } - - assert(c); - assert(c->state & CLASS_LOADED); - assert(c->classloader == defloader); - - if (link && !(c->state & CLASS_LINKED)) - if (!link_class(c)) - return NULL; - - assert(!link || (c->state & CLASS_LINKED)); - - return c; -} - - -/* class_array_of ************************************************************** - - Returns an array class with the given component class. The array - class is dynamically created if neccessary. - -*******************************************************************************/ - -classinfo *class_array_of(classinfo *component, bool link) -{ - classloader_t *cl; - s4 namelen; - char *namebuf; - utf *u; - classinfo *c; - int32_t dumpmarker; - - cl = component->classloader; - - DMARKER; - - /* Assemble the array class name */ - namelen = component->name->blength; - - if (component->name->text[0] == '[') { - /* the component is itself an array */ - namebuf = DMNEW(char, namelen + 1); - namebuf[0] = '['; - MCOPY(namebuf + 1, component->name->text, char, namelen); - namelen++; - } - else { - /* the component is a non-array class */ - namebuf = DMNEW(char, namelen + 3); - namebuf[0] = '['; - namebuf[1] = 'L'; - MCOPY(namebuf + 2, component->name->text, char, namelen); - namebuf[2 + namelen] = ';'; - namelen += 3; - } - - u = utf_new(namebuf, namelen); - - c = get_array_class(u, cl, cl, link); - - DRELEASE; - - return c; -} - - -/* class_multiarray_of ********************************************************* - - Returns an array class with the given dimension and element class. - The array class is dynamically created if neccessary. - -*******************************************************************************/ - -classinfo *class_multiarray_of(s4 dim, classinfo *element, bool link) -{ - s4 namelen; - char *namebuf; - classinfo *c; - int32_t dumpmarker; - - DMARKER; - - if (dim < 1) { - log_text("Invalid array dimension requested"); - assert(0); - } - - /* Assemble the array class name */ - namelen = element->name->blength; - - if (element->name->text[0] == '[') { - /* the element is itself an array */ - namebuf = DMNEW(char, namelen + dim); - memcpy(namebuf + dim, element->name->text, namelen); - namelen += dim; - } - else { - /* the element is a non-array class */ - namebuf = DMNEW(char, namelen + 2 + dim); - namebuf[dim] = 'L'; - memcpy(namebuf + dim + 1, element->name->text, namelen); - namelen += (2 + dim); - namebuf[namelen - 1] = ';'; - } - memset(namebuf, '[', dim); - - c = get_array_class(utf_new(namebuf, namelen), - element->classloader, - element->classloader, - link); - - DRELEASE; - - return c; -} - - -/* class_lookup_classref ******************************************************* - - Looks up the constant_classref for a given classname in the classref - tables of a class. - - IN: - cls..............the class containing the reference - name.............the name of the class refered to - - RETURN VALUE: - a pointer to a constant_classref, or - NULL if the reference was not found - -*******************************************************************************/ - -constant_classref *class_lookup_classref(classinfo *cls, utf *name) -{ - constant_classref *ref; - extra_classref *xref; - int count; - - assert(cls); - assert(name); - assert(!cls->classrefcount || cls->classrefs); - - /* first search the main classref table */ - count = cls->classrefcount; - ref = cls->classrefs; - for (; count; --count, ++ref) - if (ref->name == name) - return ref; - - /* next try the list of extra classrefs */ - for (xref = cls->extclassrefs; xref; xref = xref->next) { - if (xref->classref.name == name) - return &(xref->classref); - } - - /* not found */ - return NULL; -} - - -/* class_get_classref ********************************************************** - - Returns the constant_classref for a given classname. - - IN: - cls..............the class containing the reference - name.............the name of the class refered to - - RETURN VALUE: - a pointer to a constant_classref (never NULL) - - NOTE: - The given name is not checked for validity! - -*******************************************************************************/ - -constant_classref *class_get_classref(classinfo *cls, utf *name) -{ - constant_classref *ref; - extra_classref *xref; - - assert(cls); - assert(name); - - ref = class_lookup_classref(cls,name); - if (ref) - return ref; - - xref = NEW(extra_classref); - CLASSREF_INIT(xref->classref,cls,name); - - xref->next = cls->extclassrefs; - cls->extclassrefs = xref; - - return &(xref->classref); -} - - -/* class_get_self_classref ***************************************************** - - Returns the constant_classref to the class itself. - - IN: - cls..............the class containing the reference - - RETURN VALUE: - a pointer to a constant_classref (never NULL) - -*******************************************************************************/ - -constant_classref *class_get_self_classref(classinfo *cls) -{ - /* XXX this should be done in a faster way. Maybe always make */ - /* the classref of index 0 a self reference. */ - return class_get_classref(cls,cls->name); -} - -/* class_get_classref_multiarray_of ******************************************** - - Returns an array type reference with the given dimension and element class - reference. - - IN: - dim..............the requested dimension - dim must be in [1;255]. This is NOT checked! - ref..............the component class reference - - RETURN VALUE: - a pointer to the class reference for the array type - - NOTE: - The referer of `ref` is used as the referer for the new classref. - -*******************************************************************************/ - -constant_classref *class_get_classref_multiarray_of(s4 dim, constant_classref *ref) -{ - s4 namelen; - char *namebuf; - constant_classref *cr; - int32_t dumpmarker; - - assert(ref); - assert(dim >= 1 && dim <= 255); - - DMARKER; - - /* Assemble the array class name */ - namelen = ref->name->blength; - - if (ref->name->text[0] == '[') { - /* the element is itself an array */ - namebuf = DMNEW(char, namelen + dim); - memcpy(namebuf + dim, ref->name->text, namelen); - namelen += dim; - } - else { - /* the element is a non-array class */ - namebuf = DMNEW(char, namelen + 2 + dim); - namebuf[dim] = 'L'; - memcpy(namebuf + dim + 1, ref->name->text, namelen); - namelen += (2 + dim); - namebuf[namelen - 1] = ';'; - } - memset(namebuf, '[', dim); - - cr = class_get_classref(ref->referer,utf_new(namebuf, namelen)); - - DRELEASE; - - return cr; -} - - -/* class_get_classref_component_of ********************************************* - - Returns the component classref of a given array type reference - - IN: - ref..............the array type reference - - RETURN VALUE: - a reference to the component class, or - NULL if `ref` is not an object array type reference - - NOTE: - The referer of `ref` is used as the referer for the new classref. - -*******************************************************************************/ - -constant_classref *class_get_classref_component_of(constant_classref *ref) -{ - s4 namelen; - char *name; - - assert(ref); - - name = ref->name->text; - if (*name++ != '[') - return NULL; - - namelen = ref->name->blength - 1; - if (*name == 'L') { - name++; - namelen -= 2; - } - else if (*name != '[') { - return NULL; - } - - return class_get_classref(ref->referer, utf_new(name, namelen)); -} - - -/* class_findmethod ************************************************************ - - Searches a 'classinfo' structure for a method having the given name - and descriptor. If descriptor is NULL, it is ignored. - -*******************************************************************************/ - -methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc) -{ - methodinfo *m; - s4 i; - - for (i = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if ((m->name == name) && ((desc == NULL) || (m->descriptor == desc))) - return m; - } - - return NULL; -} - - -/* class_resolvemethod ********************************************************* - - Searches a class and it's super classes for a method. - - Superinterfaces are *not* searched. - -*******************************************************************************/ - -methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *desc) -{ - methodinfo *m; - - while (c) { - m = class_findmethod(c, name, desc); - - if (m) - return m; - - /* JVM Specification bug: - - It is important NOT to resolve special and - methods to super classes or interfaces; yet, this is not - explicited in the specification. Section 5.4.3.3 should be - updated appropriately. */ - - if (name == utf_init || name == utf_clinit) - return NULL; - - c = c->super; - } - - return NULL; -} - - -/* class_resolveinterfacemethod_intern ***************************************** - - Internally used helper function. Do not use this directly. - -*******************************************************************************/ - -static methodinfo *class_resolveinterfacemethod_intern(classinfo *c, - utf *name, utf *desc) -{ - methodinfo *m; - s4 i; - - /* try to find the method in the class */ - - m = class_findmethod(c, name, desc); - - if (m != NULL) - return m; - - /* No method found? Try the super interfaces. */ - - for (i = 0; i < c->interfacescount; i++) { - m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc); - - if (m != NULL) - return m; - } - - /* no method found */ - - return NULL; -} - - -/* class_resolveclassmethod **************************************************** - - Resolves a reference from REFERER to a method with NAME and DESC in - class C. - - If the method cannot be resolved the return value is NULL. If - EXCEPT is true *exceptionptr is set, too. - -*******************************************************************************/ - -methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *desc, - classinfo *referer, bool throwexception) -{ - classinfo *cls; - methodinfo *m; - s4 i; - -/* if (c->flags & ACC_INTERFACE) { */ -/* if (throwexception) */ -/* *exceptionptr = */ -/* new_exception(string_java_lang_IncompatibleClassChangeError); */ -/* return NULL; */ -/* } */ - - /* try class c and its superclasses */ - - cls = c; - - m = class_resolvemethod(cls, name, desc); - - if (m != NULL) - goto found; - - /* Try the super interfaces. */ - - for (i = 0; i < c->interfacescount; i++) { - m = class_resolveinterfacemethod_intern(c->interfaces[i], name, desc); - - if (m != NULL) - goto found; - } - - if (throwexception) - exceptions_throw_nosuchmethoderror(c, name, desc); - - return NULL; - - found: - if ((m->flags & ACC_ABSTRACT) && !(c->flags & ACC_ABSTRACT)) { - if (throwexception) - exceptions_throw_abstractmethoderror(); - - return NULL; - } - - /* XXX check access rights */ - - return m; -} - - -/* class_resolveinterfacemethod ************************************************ - - Resolves a reference from REFERER to a method with NAME and DESC in - interface C. - - If the method cannot be resolved the return value is NULL. If - EXCEPT is true *exceptionptr is set, too. - -*******************************************************************************/ - -methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *desc, - classinfo *referer, bool throwexception) -{ - methodinfo *mi; - - if (!(c->flags & ACC_INTERFACE)) { - if (throwexception) - exceptions_throw_incompatibleclasschangeerror(c, "Not an interface"); - - return NULL; - } - - mi = class_resolveinterfacemethod_intern(c, name, desc); - - if (mi != NULL) - return mi; - - /* try class java.lang.Object */ - - mi = class_findmethod(class_java_lang_Object, name, desc); - - if (mi != NULL) - return mi; - - if (throwexception) - exceptions_throw_nosuchmethoderror(c, name, desc); - - return NULL; -} - - -/* class_findfield ************************************************************* - - Searches for field with specified name and type in a classinfo - structure. If no such field is found NULL is returned. - -*******************************************************************************/ - -fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc) -{ - s4 i; - - for (i = 0; i < c->fieldscount; i++) - if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) - return &(c->fields[i]); - - if (c->super != NULL) - return class_findfield(c->super, name, desc); - - return NULL; -} - - -/* class_findfield_approx ****************************************************** - - Searches in 'classinfo'-structure for a field with the specified - name. - -*******************************************************************************/ - -fieldinfo *class_findfield_by_name(classinfo *c, utf *name) -{ - s4 i; - - /* get field index */ - - i = class_findfield_index_by_name(c, name); - - /* field was not found, return */ - - if (i == -1) - return NULL; - - /* return field address */ - - return &(c->fields[i]); -} - - -s4 class_findfield_index_by_name(classinfo *c, utf *name) -{ - s4 i; - - for (i = 0; i < c->fieldscount; i++) { - /* compare field names */ - - if ((c->fields[i].name == name)) - return i; - } - - /* field was not found, raise exception */ - - exceptions_throw_nosuchfielderror(c, name); - - return -1; -} - - -/****************** Function: class_resolvefield_int *************************** - - This is an internally used helper function. Do not use this directly. - - Tries to resolve a field having the given name and type. - If the field cannot be resolved, NULL is returned. - -*******************************************************************************/ - -static fieldinfo *class_resolvefield_int(classinfo *c, utf *name, utf *desc) -{ - fieldinfo *fi; - s4 i; - - /* search for field in class c */ - - for (i = 0; i < c->fieldscount; i++) { - if ((c->fields[i].name == name) && (c->fields[i].descriptor == desc)) { - return &(c->fields[i]); - } - } - - /* Try super interfaces recursively. */ - - for (i = 0; i < c->interfacescount; i++) { - fi = class_resolvefield_int(c->interfaces[i], name, desc); - - if (fi != NULL) - return fi; - } - - /* Try super class. */ - - if (c->super != NULL) - return class_resolvefield_int(c->super, name, desc); - - /* not found */ - - return NULL; -} - - -/********************* Function: class_resolvefield *************************** - - Resolves a reference from REFERER to a field with NAME and DESC in class C. - - If the field cannot be resolved the return value is NULL. If EXCEPT is - true *exceptionptr is set, too. - -*******************************************************************************/ - -fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, - classinfo *referer, bool throwexception) -{ - fieldinfo *fi; - - fi = class_resolvefield_int(c, name, desc); - - if (!fi) { - if (throwexception) - exceptions_throw_nosuchfielderror(c, name); - - return NULL; - } - - /* XXX check access rights */ - - return fi; -} - - -/* class_issubclass ************************************************************ - - Checks if sub is a descendant of super. - -*******************************************************************************/ - -bool class_issubclass(classinfo *sub, classinfo *super) -{ - classinfo *c; - - c = sub; - - for (;;) { - /* We reached java/lang/Object and did not find the requested - super class. */ - - if (c == NULL) - return false; - - /* We found the requested super class. */ - - if (c == super) - return true; - - c = c->super; - } -} - - -/* class_isanysubclass ********************************************************* - - Checks a subclass relation between two classes. Implemented - interfaces are interpreted as super classes. - - Return value: 1 ... sub is subclass of super - 0 ... otherwise - -*******************************************************************************/ - -bool class_isanysubclass(classinfo *sub, classinfo *super) -{ - uint32_t diffval; - bool result; - - /* This is the trivial case. */ - - if (sub == super) - return true; - - /* Primitive classes are only subclasses of themselves. */ - - if (class_is_primitive(sub) || class_is_primitive(super)) - return false; - - /* Check for interfaces. */ - - if (super->flags & ACC_INTERFACE) { - result = (sub->vftbl->interfacetablelength > super->index) && - (sub->vftbl->interfacetable[-super->index] != NULL); - } - else { - /* java.lang.Object is the only super class of any - interface. */ - - if (sub->flags & ACC_INTERFACE) - return (super == class_java_lang_Object); - - result = fast_subtype_check(sub->vftbl, super->vftbl); - } - - return result; -} - - -/* class_is_assignable_from **************************************************** - - Return whether an instance of the "from" class parameter would be - an instance of this class "to" as well. - - ARGUMENTS: - to ..... class - from ... class - - RETURN: - true .... is assignable - false ... is not assignable - -*******************************************************************************/ - -bool class_is_assignable_from(classinfo *to, classinfo *from) -{ - if (!(to->state & CLASS_LINKED)) - if (!link_class(to)) - return false; - - if (!(from->state & CLASS_LINKED)) - if (!link_class(from)) - return false; - - return class_isanysubclass(from, to); -} - - -/* class_is_instance *********************************************************** - - Return if the given Java object is an instance of the given class. - - ARGUMENTS: - c ... class - h ... Java object - - RETURN: - true .... is instance - false ... is not instance - -*******************************************************************************/ - -bool class_is_instance(classinfo *c, java_handle_t *h) -{ - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - return false; - - return builtin_instanceof(h, c); -} - - -/* class_get_componenttype ***************************************************** - - Return the component class of the given class. If the given class - is not an array, return NULL. - -*******************************************************************************/ - -classinfo *class_get_componenttype(classinfo *c) -{ - classinfo *component; - arraydescriptor *ad; - - /* XXX maybe we could find a way to do this without linking. */ - /* This way should be safe and easy, however. */ - - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - return NULL; - - ad = c->vftbl->arraydesc; - - if (ad == NULL) - return NULL; - - if (ad->arraytype == ARRAYTYPE_OBJECT) - component = ad->componentvftbl->clazz; - else - component = primitive_class_get_by_type(ad->arraytype); - - return component; -} - - -/* class_get_declaredclasses *************************************************** - - Return an array of declared classes of the given class. - -*******************************************************************************/ - -java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly) -{ - classref_or_classinfo inner; - classref_or_classinfo outer; - utf *outername; - int declaredclasscount; /* number of declared classes */ - int pos; /* current declared class */ - java_handle_objectarray_t *oa; /* array of declared classes */ - int i; - classinfo *ic; - - declaredclasscount = 0; - - if (!class_is_primitive(c) && !class_is_array(c)) { - /* Determine number of declared classes. */ - - for (i = 0; i < c->innerclasscount; i++) { - /* Get outer-class. If the inner-class is not a member - class, the outer-class is NULL. */ - - outer = c->innerclass[i].outer_class; - - if (outer.any == NULL) - continue; - - /* Check if outer-class is a classref or a real class and - get the class name from the structure. */ - - outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name; - - /* Outer class is this class. */ - - if ((outername == c->name) && - ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) - declaredclasscount++; - } - } - - /* Allocate Class[] and check for OOM. */ - - oa = builtin_anewarray(declaredclasscount, class_java_lang_Class); - - if (oa == NULL) - return NULL; - - for (i = 0, pos = 0; i < c->innerclasscount; i++) { - inner = c->innerclass[i].inner_class; - outer = c->innerclass[i].outer_class; - - /* Get outer-class. If the inner-class is not a member class, - the outer-class is NULL. */ - - if (outer.any == NULL) - continue; - - /* Check if outer_class is a classref or a real class and get - the class name from the structure. */ - - outername = IS_CLASSREF(outer) ? outer.ref->name : outer.cls->name; - - /* Outer class is this class. */ - - if ((outername == c->name) && - ((publicOnly == 0) || (c->innerclass[i].flags & ACC_PUBLIC))) { - - ic = resolve_classref_or_classinfo_eager(inner, false); - - if (ic == NULL) - return NULL; - - if (!(ic->state & CLASS_LINKED)) - if (!link_class(ic)) - return NULL; - - LLNI_array_direct(oa, pos++) = (java_object_t *) ic; - } - } - - return oa; -} - - -/** - * Return an array of declared constructors of the given class. - * - * @param c class to get the constructors of - * @param publicOnly show only public fields - * - * @return array of java.lang.reflect.Constructor - */ -#if defined(ENABLE_JAVASE) -java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly) -{ - methodinfo* m; - java_handle_objectarray_t* oa; - java_handle_t* rc; - int count; - int index; - int i; - - /* Determine number of constructors. */ - - count = 0; - - for (i = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) && - (m->name == utf_init)) - count++; - } - - /* Create array of constructors. */ - - oa = builtin_anewarray(count, class_java_lang_reflect_Constructor); - - if (oa == NULL) - return NULL; - - /* Get the constructors and store them in the array. */ - - for (i = 0, index = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (((m->flags & ACC_PUBLIC) || (publicOnly == 0)) && - (m->name == utf_init)) { - /* Create Constructor object. This is actualy a - java_lang_reflect_Constructor pointer, but we use a - java_handle_t here, because we don't have the header - available when building vmcore. */ - - rc = reflect_constructor_new(m); - - /* Store object into array. */ - - array_objectarray_element_set(oa, index, rc); - index++; - } - } - - return oa; -} -#endif - - -/* class_get_declaredfields **************************************************** - - Return an array of declared fields of the given class. - - ARGUMENTS: - c ............ class to get the fields of - publicOnly ... show only public fields - - RETURN: - array of java.lang.reflect.Field - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly) -{ - java_handle_objectarray_t *oa; - fieldinfo *f; - java_handle_t *h; - int count; - int index; - int i; - - /* Determine number of fields. */ - - count = 0; - - for (i = 0; i < c->fieldscount; i++) - if ((c->fields[i].flags & ACC_PUBLIC) || (publicOnly == 0)) - count++; - - /* Create array of fields. */ - - oa = builtin_anewarray(count, class_java_lang_reflect_Field); - - if (oa == NULL) - return NULL; - - /* Get the fields and store them in the array. */ - - for (i = 0, index = 0; i < c->fieldscount; i++) { - f = &(c->fields[i]); - - if ((f->flags & ACC_PUBLIC) || (publicOnly == 0)) { - /* Create Field object. This is actualy a - java_lang_reflect_Field pointer, but we use a - java_handle_t here, because we don't have the header - available when building vmcore. */ - - h = reflect_field_new(f); - - /* Store object into array. */ - - array_objectarray_element_set(oa, index, h); - index++; - } - } - - return oa; -} -#endif - - -/* class_get_declaredmethods *************************************************** - - Return an array of declared methods of the given class. - - ARGUMENTS: - c ............ class to get the methods of - publicOnly ... show only public methods - - RETURN: - array of java.lang.reflect.Method - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly) -{ - java_handle_objectarray_t *oa; /* result: array of Method-objects */ - methodinfo *m; /* the current method to be represented */ - java_handle_t *h; - int count; - int index; - int i; - - /* JOWENN: array classes do not declare methods according to mauve - test. It should be considered, if we should return to my old - clone method overriding instead of declaring it as a member - function. */ - - if (class_is_array(c)) - return builtin_anewarray(0, class_java_lang_reflect_Method); - - /* Determine number of methods. */ - - count = 0; - - for (i = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && - ((m->name != utf_init) && (m->name != utf_clinit)) && - !(m->flags & ACC_MIRANDA)) - count++; - } - - /* Create array of methods. */ - - oa = builtin_anewarray(count, class_java_lang_reflect_Method); - - if (oa == NULL) - return NULL; - - /* Get the methods and store them in the array. */ - - for (i = 0, index = 0; i < c->methodscount; i++) { - m = &(c->methods[i]); - - if (((m->flags & ACC_PUBLIC) || (publicOnly == false)) && - ((m->name != utf_init) && (m->name != utf_clinit)) && - !(m->flags & ACC_MIRANDA)) { - /* Create method object. This is actualy a - java_lang_reflect_Method pointer, but we use a - java_handle_t here, because we don't have the header - available when building vmcore. */ - - h = reflect_method_new(m); - - /* Store object into array. */ - - array_objectarray_element_set(oa, index, h); - index++; - } - } - - return oa; -} -#endif - - -/* class_get_declaringclass **************************************************** - - If the class or interface given is a member of another class, - return the declaring class. For array and primitive classes return - NULL. - -*******************************************************************************/ - -classinfo *class_get_declaringclass(classinfo *c) -{ - classref_or_classinfo cr; - classinfo *dc; - - /* Get declaring class. */ - - cr = c->declaringclass; - - if (cr.any == NULL) - return NULL; - - /* Resolve the class if necessary. */ - - if (IS_CLASSREF(cr)) { -/* dc = resolve_classref_eager(cr.ref); */ - dc = resolve_classref_or_classinfo_eager(cr, true); - - if (dc == NULL) - return NULL; - - /* Store the resolved class in the class structure. */ - - cr.cls = dc; - } - - dc = cr.cls; - - return dc; -} - - -/* class_get_enclosingclass **************************************************** - - Return the enclosing class for the given class. - -*******************************************************************************/ - -classinfo *class_get_enclosingclass(classinfo *c) -{ - classref_or_classinfo cr; - classinfo *ec; - - /* Get enclosing class. */ - - cr = c->enclosingclass; - - if (cr.any == NULL) - return NULL; - - /* Resolve the class if necessary. */ - - if (IS_CLASSREF(cr)) { -/* ec = resolve_classref_eager(cr.ref); */ - ec = resolve_classref_or_classinfo_eager(cr, true); - - if (ec == NULL) - return NULL; - - /* Store the resolved class in the class structure. */ - - cr.cls = ec; - } - - ec = cr.cls; - - return ec; -} - - -/** - * Return the enclosing constructor as java.lang.reflect.Constructor - * object for the given class. - * - * @param c class to return the enclosing constructor for - * - * @return java.lang.reflect.Constructor object of the enclosing - * constructor - */ -#if defined(ENABLE_JAVASE) -java_handle_t* class_get_enclosingconstructor(classinfo *c) -{ - methodinfo* m; - java_handle_t* rc; - - m = class_get_enclosingmethod_raw(c); - - if (m == NULL) - return NULL; - - /* Check for . */ - - if (m->name != utf_init) - return NULL; - - /* Create Constructor object. */ - - rc = reflect_constructor_new(m); - - return rc; -} -#endif - - -/* class_get_enclosingmethod *************************************************** - - Return the enclosing method for the given class. - - IN: - c ... class to return the enclosing method for - - RETURN: - methodinfo of the enclosing method - -*******************************************************************************/ - -methodinfo *class_get_enclosingmethod_raw(classinfo *c) -{ - constant_nameandtype *cn; - classinfo *ec; - methodinfo *m; - - /* get enclosing class and method */ - - ec = class_get_enclosingclass(c); - cn = c->enclosingmethod; - - /* check for enclosing class and method */ - - if (ec == NULL) - return NULL; - - if (cn == NULL) - return NULL; - - /* find method in enclosing class */ - - m = class_findmethod(ec, cn->name, cn->descriptor); - - if (m == NULL) { - exceptions_throw_internalerror("Enclosing method doesn't exist"); - return NULL; - } - - return m; -} - - -/** - * Return the enclosing method as java.lang.reflect.Method object for - * the given class. - * - * @param c class to return the enclosing method for - * - * @return java.lang.reflect.Method object of the enclosing method - */ -#if defined(ENABLE_JAVASE) -java_handle_t* class_get_enclosingmethod(classinfo *c) -{ - methodinfo* m; - java_handle_t* rm; - - m = class_get_enclosingmethod_raw(c); - - if (m == NULL) - return NULL; - - /* check for */ - - if (m->name == utf_init) - return NULL; - - /* create java.lang.reflect.Method object */ - - rm = reflect_method_new(m); - - return rm; -} -#endif - - -/* class_get_interfaces ******************************************************** - - Return an array of interfaces of the given class. - -*******************************************************************************/ - -java_handle_objectarray_t *class_get_interfaces(classinfo *c) -{ - classinfo *ic; - java_handle_objectarray_t *oa; - u4 i; - - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - return NULL; - - oa = builtin_anewarray(c->interfacescount, class_java_lang_Class); - - if (oa == NULL) - return NULL; - - for (i = 0; i < c->interfacescount; i++) { - ic = c->interfaces[i]; - - LLNI_array_direct(oa, i) = (java_object_t *) ic; - } - - return oa; -} - - -/* class_get_annotations ******************************************************* - - Get the unparsed declared annotations in a byte array - of the given class. - - IN: - c........the class of which the annotations should be returned - - RETURN VALUE: - The unparsed declared annotations in a byte array - (or NULL if there aren't any). - -*******************************************************************************/ - -java_handle_bytearray_t *class_get_annotations(classinfo *c) -{ -#if defined(ENABLE_ANNOTATIONS) - java_handle_t *annotations; /* unparsed annotations */ - - LLNI_classinfo_field_get(c, annotations, annotations); - - return (java_handle_bytearray_t*)annotations; -#else - return NULL; -#endif -} - - -/* class_get_modifiers ********************************************************* - - Get the modifier flags of the given class. - - IN: - c....the class of which the modifier flags should be returned - ignoreInnerClassesAttrib - RETURN VALUE: - modifier flags - -*******************************************************************************/ - -int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib) -{ - classref_or_classinfo inner; - classref_or_classinfo outer; - utf *innername; - int i; - - if (!ignoreInnerClassesAttrib && (c->innerclasscount != 0)) { - /* search for passed class as inner class */ - - for (i = 0; i < c->innerclasscount; i++) { - inner = c->innerclass[i].inner_class; - outer = c->innerclass[i].outer_class; - - /* Check if inner is a classref or a real class and get - the name of the structure */ - - innername = IS_CLASSREF(inner) ? inner.ref->name : inner.cls->name; - - /* innerclass is this class */ - - if (innername == c->name) { - /* has the class actually an outer class? */ - - if (outer.any) - /* return flags got from the outer class file */ - return c->innerclass[i].flags & ACC_CLASS_REFLECT_MASK; - else - return c->flags & ACC_CLASS_REFLECT_MASK; - } - } - } - - /* passed class is no inner class or it was not requested */ - - return c->flags & ACC_CLASS_REFLECT_MASK; -} - - -/* class_get_signature ********************************************************* - - Return the signature of the given class. For array and primitive - classes return NULL. - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -utf *class_get_signature(classinfo *c) -{ - /* For array and primitive classes return NULL. */ - - if (class_is_array(c) || class_is_primitive(c)) - return NULL; - - return c->signature; -} -#endif - - -/* class_printflags ************************************************************ - - Prints flags of a class. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_printflags(classinfo *c) -{ - if (c == NULL) { - printf("NULL"); - return; - } - - if (c->flags & ACC_PUBLIC) printf(" PUBLIC"); - if (c->flags & ACC_PRIVATE) printf(" PRIVATE"); - if (c->flags & ACC_PROTECTED) printf(" PROTECTED"); - if (c->flags & ACC_STATIC) printf(" STATIC"); - if (c->flags & ACC_FINAL) printf(" FINAL"); - if (c->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED"); - if (c->flags & ACC_VOLATILE) printf(" VOLATILE"); - if (c->flags & ACC_TRANSIENT) printf(" TRANSIENT"); - if (c->flags & ACC_NATIVE) printf(" NATIVE"); - if (c->flags & ACC_INTERFACE) printf(" INTERFACE"); - if (c->flags & ACC_ABSTRACT) printf(" ABSTRACT"); -} -#endif - - -/* class_print ***************************************************************** - - Prints classname plus flags. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_print(classinfo *c) -{ - if (c == NULL) { - printf("NULL"); - return; - } - - utf_display_printable_ascii(c->name); - class_printflags(c); -} -#endif - - -/* class_classref_print ******************************************************** - - Prints classname plus referer class. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_classref_print(constant_classref *cr) -{ - if (cr == NULL) { - printf("NULL"); - return; - } - - utf_display_printable_ascii(cr->name); - printf("(ref.by "); - if (cr->referer) - class_print(cr->referer); - else - printf("NULL"); - printf(")"); -} -#endif - - -/* class_println *************************************************************** - - Prints classname plus flags and new line. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_println(classinfo *c) -{ - class_print(c); - printf("\n"); -} -#endif - - -/* class_classref_println ****************************************************** - - Prints classname plus referer class and new line. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_classref_println(constant_classref *cr) -{ - class_classref_print(cr); - printf("\n"); -} -#endif - - -/* class_classref_or_classinfo_print ******************************************* - - Prints classname plus referer class. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_classref_or_classinfo_print(classref_or_classinfo c) -{ - if (c.any == NULL) { - printf("(classref_or_classinfo) NULL"); - return; - } - if (IS_CLASSREF(c)) - class_classref_print(c.ref); - else - class_print(c.cls); -} -#endif - - -/* class_classref_or_classinfo_println ***************************************** - - Prints classname plus referer class and a newline. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_classref_or_classinfo_println(classref_or_classinfo c) -{ - class_classref_or_classinfo_print(c); - printf("\n"); -} -#endif - - -/* class_showconstantpool ****************************************************** - - Dump the constant pool of the given class to stdout. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_showconstantpool (classinfo *c) -{ - u4 i; - voidptr e; - - printf ("---- dump of constant pool ----\n"); - - for (i=0; icpcount; i++) { - printf ("#%d: ", (int) i); - - e = c -> cpinfos [i]; - if (e) { - - switch (c -> cptags [i]) { - case CONSTANT_Class: - printf ("Classreference -> "); - utf_display_printable_ascii ( ((constant_classref*)e) -> name ); - break; - case CONSTANT_Fieldref: - printf ("Fieldref -> "); - field_fieldref_print((constant_FMIref *) e); - break; - case CONSTANT_Methodref: - printf ("Methodref -> "); - method_methodref_print((constant_FMIref *) e); - break; - case CONSTANT_InterfaceMethodref: - printf ("InterfaceMethod -> "); - method_methodref_print((constant_FMIref *) e); - break; - case CONSTANT_String: - printf ("String -> "); - utf_display_printable_ascii (e); - break; - case CONSTANT_Integer: - printf ("Integer -> %d", (int) ( ((constant_integer*)e) -> value) ); - break; - case CONSTANT_Float: - printf ("Float -> %f", ((constant_float*)e) -> value); - break; - case CONSTANT_Double: - printf ("Double -> %f", ((constant_double*)e) -> value); - break; - case CONSTANT_Long: - { - u8 v = ((constant_long*)e) -> value; -#if U8_AVAILABLE - printf ("Long -> %ld", (long int) v); -#else - printf ("Long -> HI: %ld, LO: %ld\n", - (long int) v.high, (long int) v.low); -#endif - } - break; - case CONSTANT_NameAndType: - { - constant_nameandtype *cnt = e; - printf ("NameAndType: "); - utf_display_printable_ascii (cnt->name); - printf (" "); - utf_display_printable_ascii (cnt->descriptor); - } - break; - case CONSTANT_Utf8: - printf ("Utf8 -> "); - utf_display_printable_ascii (e); - break; - default: - log_text("Invalid type of ConstantPool-Entry"); - assert(0); - } - } - - printf ("\n"); - } -} -#endif /* !defined(NDEBUG) */ - - -/* class_showmethods *********************************************************** - - Dump info about the fields and methods of the given class to stdout. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void class_showmethods (classinfo *c) -{ - s4 i; - - printf("--------- Fields and Methods ----------------\n"); - printf("Flags: "); - class_printflags(c); - printf("\n"); - - printf("This: "); - utf_display_printable_ascii(c->name); - printf("\n"); - - if (c->super) { - printf("Super: "); - utf_display_printable_ascii(c->super->name); - printf ("\n"); - } - - printf("Index: %d\n", c->index); - - printf("Interfaces:\n"); - for (i = 0; i < c->interfacescount; i++) { - printf(" "); - utf_display_printable_ascii(c->interfaces[i]->name); - printf (" (%d)\n", c->interfaces[i]->index); - } - - printf("Fields:\n"); - for (i = 0; i < c->fieldscount; i++) - field_println(&(c->fields[i])); - - printf("Methods:\n"); - for (i = 0; i < c->methodscount; i++) { - methodinfo *m = &(c->methods[i]); - - if (!(m->flags & ACC_STATIC)) - printf("vftblindex: %d ", m->vftblindex); - - method_println(m); - } - - printf ("Virtual function table:\n"); - for (i = 0; i < c->vftbl->vftbllength; i++) - printf ("entry: %d, %ld\n", i, (long int) (c->vftbl->table[i])); -} -#endif /* !defined(NDEBUG) */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/class.h b/src/vmcore/class.h deleted file mode 100644 index 13c85d817..000000000 --- a/src/vmcore/class.h +++ /dev/null @@ -1,569 +0,0 @@ -/* src/vmcore/class.h - class related functions header - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _CLASS_H -#define _CLASS_H - -/* forward typedefs ***********************************************************/ - -typedef struct classinfo classinfo; -typedef struct innerclassinfo innerclassinfo; -typedef struct extra_classref extra_classref; -typedef struct castinfo castinfo; - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "toolbox/list.h" - -#include "vm/global.h" -#include "vm/stringlocal.h" - -#if defined(ENABLE_JAVASE) -# include "vmcore/annotation.h" -#endif - -#include "vmcore/field.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/references.h" -#include "vmcore/utf8.h" - - -/* class state defines ********************************************************/ - -#define CLASS_LOADING 0x0001 -#define CLASS_LOADED 0x0002 -#define CLASS_LINKING 0x0004 -#define CLASS_LINKED 0x0008 -#define CLASS_INITIALIZING 0x0010 -#define CLASS_INITIALIZED 0x0020 -#define CLASS_ERROR 0x0040 - - -/* some macros ****************************************************************/ - -#define CLASS_IS_OR_ALMOST_INITIALIZED(c) \ - (((c)->state & CLASS_INITIALIZING) || ((c)->state & CLASS_INITIALIZED)) - - -/* classinfo ******************************************************************/ - -/* We define this dummy structure of java_lang_Class so we can - bootstrap cacaoh without needing a java_lang_Class.h file. Whether - the size of the dummy structure is big enough is checked during - runtime in vm_create. */ - -typedef struct { - java_object_t header; -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - intptr_t padding[4]; -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - intptr_t padding[19]; -#elif defined(WITH_JAVA_RUNTIME_LIBRARY_CLDC1_1) - intptr_t padding[3]; -#else -# error unknown classpath configuration -#endif -} dummy_java_lang_Class; - -struct classinfo { /* class structure */ - dummy_java_lang_Class object; - - s4 flags; /* ACC flags */ - utf *name; /* class name */ - - s4 cpcount; /* number of entries in constant pool */ - u1 *cptags; /* constant pool tags */ - voidptr *cpinfos; /* pointer to constant pool info structures */ - - s4 classrefcount; /* number of symbolic class references */ - constant_classref *classrefs; /* table of symbolic class references */ - extra_classref *extclassrefs; /* additional classrefs */ - s4 parseddescsize; /* size of the parsed descriptors block */ - u1 *parseddescs; /* parsed descriptors */ - - classinfo *super; /* super class */ - classinfo *sub; /* sub class pointer */ - classinfo *nextsub; /* pointer to next class in sub class list */ - - int32_t interfacescount; /* number of interfaces */ - classinfo **interfaces; /* super interfaces */ - - int32_t fieldscount; /* number of fields */ - fieldinfo *fields; /* field table */ - - int32_t methodscount; /* number of methods */ - methodinfo *methods; /* method table */ - - s4 state; /* current class state */ - s4 index; /* hierarchy depth (classes) or index */ - /* (interfaces) */ - s4 instancesize; /* size of an instance of this class */ - - vftbl_t *vftbl; /* pointer to virtual function table */ - - methodinfo *finalizer; /* finalizer method */ - - u2 innerclasscount; /* number of inner classes */ - innerclassinfo *innerclass; - - classref_or_classinfo declaringclass; - classref_or_classinfo enclosingclass; /* enclosing class */ - constant_nameandtype *enclosingmethod; /* enclosing method */ - - utf *packagename; /* full name of the package */ - utf *sourcefile; /* SourceFile attribute */ -#if defined(ENABLE_JAVASE) - utf *signature; /* Signature attribute */ -#if defined(ENABLE_ANNOTATIONS) - /* All the annotation attributes are NULL (and not a zero length array) */ - /* if there is nothing. */ - java_object_t *annotations; /* annotations of this class */ - - java_object_t *method_annotations; /* array of annotations of the methods */ - java_object_t *method_parameterannotations; /* array of parameter */ - /* annotations of the methods */ - java_object_t *method_annotationdefaults; /* array of annotation default */ - /* values of the methods */ - - java_object_t *field_annotations; /* array of annotations of the fields */ - -#endif -#endif - classloader_t *classloader; /* NULL for bootstrap classloader */ - -#if defined(ENABLE_JAVASE) -# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - java_object_t *protectiondomain; - java_objectarray_t *signers; -# endif -#endif -}; - - -/* innerclassinfo *************************************************************/ - -struct innerclassinfo { - classref_or_classinfo inner_class; /* inner class pointer */ - classref_or_classinfo outer_class; /* outer class pointer */ - utf *name; /* innerclass name */ - s4 flags; /* ACC flags */ -}; - - -/* extra_classref ************************************************************** - - for classrefs not occurring within descriptors - -*******************************************************************************/ - -struct extra_classref { - extra_classref *next; - constant_classref classref; -}; - - -/* castinfo *******************************************************************/ - -struct castinfo { - s4 super_baseval; - s4 super_diffval; - s4 sub_baseval; -}; - - -/* global variables ***********************************************************/ - -/* frequently used classes ****************************************************/ - -/* Important system classes. */ - -extern classinfo *class_java_lang_Object; -extern classinfo *class_java_lang_Class; -extern classinfo *class_java_lang_ClassLoader; -extern classinfo *class_java_lang_Cloneable; -extern classinfo *class_java_lang_SecurityManager; -extern classinfo *class_java_lang_String; -extern classinfo *class_java_lang_System; -extern classinfo *class_java_lang_Thread; -extern classinfo *class_java_lang_ThreadGroup; -extern classinfo *class_java_lang_Throwable; -extern classinfo *class_java_io_Serializable; - -/* Important system exceptions. */ - -extern classinfo *class_java_lang_Exception; -extern classinfo *class_java_lang_ClassNotFoundException; -extern classinfo *class_java_lang_RuntimeException; - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -extern classinfo *class_java_lang_VMSystem; -extern classinfo *class_java_lang_VMThread; -extern classinfo *class_java_lang_VMThrowable; -#endif - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) -extern classinfo *class_sun_reflect_MagicAccessorImpl; -#endif - -#if defined(ENABLE_JAVASE) -extern classinfo *class_java_lang_Void; -#endif - -extern classinfo *class_java_lang_Boolean; -extern classinfo *class_java_lang_Byte; -extern classinfo *class_java_lang_Character; -extern classinfo *class_java_lang_Short; -extern classinfo *class_java_lang_Integer; -extern classinfo *class_java_lang_Long; -extern classinfo *class_java_lang_Float; -extern classinfo *class_java_lang_Double; - -/* some classes which may be used more often */ - -#if defined(ENABLE_JAVASE) -extern classinfo *class_java_lang_StackTraceElement; -extern classinfo *class_java_lang_reflect_Constructor; -extern classinfo *class_java_lang_reflect_Field; -extern classinfo *class_java_lang_reflect_Method; -extern classinfo *class_java_security_PrivilegedAction; -extern classinfo *class_java_util_Vector; -extern classinfo *class_java_util_HashMap; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -extern classinfo *class_java_lang_reflect_VMConstructor; -extern classinfo *class_java_lang_reflect_VMField; -extern classinfo *class_java_lang_reflect_VMMethod; -# endif - -extern classinfo *arrayclass_java_lang_Object; - -# if defined(ENABLE_ANNOTATIONS) -extern classinfo *class_sun_reflect_ConstantPool; -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -extern classinfo *class_sun_reflect_annotation_AnnotationParser; -# endif -# endif -#endif - - -/* pseudo classes for the type checker ****************************************/ - -/* - * pseudo_class_Arraystub - * (extends Object implements Cloneable, java.io.Serializable) - * - * If two arrays of incompatible component types are merged, - * the resulting reference has no accessible components. - * The result does, however, implement the interfaces Cloneable - * and java.io.Serializable. This pseudo class is used internally - * to represent such results. (They are *not* considered arrays!) - * - * pseudo_class_Null - * - * This pseudo class is used internally to represent the - * null type. - * - * pseudo_class_New - * - * This pseudo class is used internally to represent the - * the 'uninitialized object' type. - */ - -extern classinfo *pseudo_class_Arraystub; -extern classinfo *pseudo_class_Null; -extern classinfo *pseudo_class_New; - - -/* inline functions ***********************************************************/ - -/** - * Returns the classname of the class, where slashes ('/') are - * replaced by dots ('.'). - * - * @param c class to get name of - * @return classname - */ -inline static java_handle_t* class_get_classname(classinfo* c) -{ - java_handle_t *s; - - /* Create a java string. */ - - s = javastring_new_slash_to_dot(c->name); - - return s; -} - - -/* class_is_primitive ********************************************************** - - Checks if the given class is a primitive class. - -*******************************************************************************/ - -static inline bool class_is_primitive(classinfo *c) -{ - if (c->flags & ACC_CLASS_PRIMITIVE) - return true; - - return false; -} - - -/* class_is_anonymousclass ***************************************************** - - Checks if the given class is an anonymous class. - -*******************************************************************************/ - -static inline bool class_is_anonymousclass(classinfo *c) -{ - if (c->flags & ACC_CLASS_ANONYMOUS) - return true; - - return false; -} - - -/* class_is_array ************************************************************** - - Checks if the given class is an array class. - -*******************************************************************************/ - -static inline bool class_is_array(classinfo *c) -{ - if (!(c->state & CLASS_LINKED)) - if (!link_class(c)) - return false; - - return (c->vftbl->arraydesc != NULL); -} - - -/* class_is_interface ********************************************************** - - Checks if the given class is an interface. - -*******************************************************************************/ - -static inline bool class_is_interface(classinfo *c) -{ - if (c->flags & ACC_INTERFACE) - return true; - - return false; -} - - -/* class_is_localclass ********************************************************* - - Checks if the given class is a local class. - -*******************************************************************************/ - -static inline bool class_is_localclass(classinfo *c) -{ - if ((c->enclosingmethod != NULL) && !class_is_anonymousclass(c)) - return true; - - return false; -} - - -/* class_is_memberclass ******************************************************** - - Checks if the given class is a member class. - -*******************************************************************************/ - -static inline bool class_is_memberclass(classinfo *c) -{ - if (c->flags & ACC_CLASS_MEMBER) - return true; - - return false; -} - - -/* class_get_classloader ******************************************************* - - Return the classloader of the given class. - -*******************************************************************************/ - -static inline classloader_t *class_get_classloader(classinfo *c) -{ - classloader_t *cl; - - cl = c->classloader; - - /* The classloader may be NULL. */ - - return cl; -} - - -/* class_get_superclass ******************************************************** - - Return the super class of the given class. - -*******************************************************************************/ - -static inline classinfo *class_get_superclass(classinfo *c) -{ - /* For interfaces we return NULL. */ - - if (c->flags & ACC_INTERFACE) - return NULL; - - /* For java/lang/Object, primitive-type and Void classes c->super - is NULL and we return NULL. */ - - return c->super; -} - - -/* function prototypes ********************************************************/ - -classinfo *class_create_classinfo(utf *u); -void class_postset_header_vftbl(void); -classinfo *class_define(utf *name, classloader_t *cl, int32_t length, uint8_t *data, java_handle_t *pd); -void class_set_packagename(classinfo *c); - -bool class_load_attributes(classbuffer *cb); - -/* retrieve constantpool element */ -voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype); -voidptr innerclass_getconstant(classinfo *c, u4 pos, u4 ctype); - -/* frees all resources used by the class */ -void class_free(classinfo *); - -/* return an array class with the given component class */ -classinfo *class_array_of(classinfo *component,bool link); - -/* return an array class with the given dimension and element class */ -classinfo *class_multiarray_of(s4 dim, classinfo *element,bool link); - -/* return a classref for the given class name */ -/* (does a linear search!) */ -constant_classref *class_lookup_classref(classinfo *cls,utf *name); - -/* return a classref for the given class name */ -/* (does a linear search!) */ -constant_classref *class_get_classref(classinfo *cls,utf *name); - -/* return a classref to the class itself */ -/* (does a linear search!) */ -constant_classref *class_get_self_classref(classinfo *cls); - -/* return a classref for an array with the given dimension of with the */ -/* given component type */ -constant_classref *class_get_classref_multiarray_of(s4 dim,constant_classref *ref); - -/* return a classref for the component type of the given array type */ -constant_classref *class_get_classref_component_of(constant_classref *ref); - -/* get a class' field by name and descriptor */ -fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc); - -/* search 'classinfo'-structure for a field with the specified name */ -fieldinfo *class_findfield_by_name(classinfo *c, utf *name); -s4 class_findfield_index_by_name(classinfo *c, utf *name); - -/* search class for a field */ -fieldinfo *class_resolvefield(classinfo *c, utf *name, utf *desc, classinfo *referer, bool throwexception); - -/* search for a method with a specified name and descriptor */ -methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc); -methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest); -methodinfo *class_resolveclassmethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception); -methodinfo *class_resolveinterfacemethod(classinfo *c, utf *name, utf *dest, classinfo *referer, bool throwexception); - -bool class_issubclass(classinfo *sub, classinfo *super); -bool class_isanysubclass(classinfo *sub, classinfo *super); -bool class_is_assignable_from(classinfo *to, classinfo *from); -bool class_is_instance(classinfo *c, java_handle_t *h); - -classloader_t *class_get_classloader(classinfo *c); -classinfo *class_get_superclass(classinfo *c); -classinfo *class_get_componenttype(classinfo *c); -java_handle_objectarray_t *class_get_declaredclasses(classinfo *c, bool publicOnly); -java_handle_objectarray_t *class_get_declaredconstructors(classinfo *c, bool publicOnly); -java_handle_objectarray_t *class_get_declaredfields(classinfo *c, bool publicOnly); -java_handle_objectarray_t *class_get_declaredmethods(classinfo *c, bool publicOnly); -classinfo *class_get_declaringclass(classinfo *c); -classinfo *class_get_enclosingclass(classinfo *c); -java_handle_t* class_get_enclosingconstructor(classinfo *c); -methodinfo* class_get_enclosingmethod_raw(classinfo *c); -java_handle_t* class_get_enclosingmethod(classinfo *c); -java_handle_objectarray_t *class_get_interfaces(classinfo *c); -java_handle_bytearray_t *class_get_annotations(classinfo *c); -int32_t class_get_modifiers(classinfo *c, bool ignoreInnerClassesAttrib); -java_handle_t *class_get_name(classinfo *c); - -#if defined(ENABLE_JAVASE) -utf *class_get_signature(classinfo *c); -#endif - -/* some debugging functions */ - -#if !defined(NDEBUG) -void class_printflags(classinfo *c); -void class_print(classinfo *c); -void class_println(classinfo *c); -void class_classref_print(constant_classref *cr); -void class_classref_println(constant_classref *cr); -void class_classref_or_classinfo_print(classref_or_classinfo c); -void class_classref_or_classinfo_println(classref_or_classinfo c); -#endif - -/* debug purposes */ -void class_showmethods(classinfo *c); -void class_showconstantpool(classinfo *c); - -#endif /* _CLASS_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/classcache.c b/src/vmcore/classcache.c deleted file mode 100644 index 76fc8255f..000000000 --- a/src/vmcore/classcache.c +++ /dev/null @@ -1,1588 +0,0 @@ -/* src/vmcore/classcache.c - loaded class cache and loading constraints - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "threads/lock-common.h" - -#include "toolbox/hashtable.h" -#include "toolbox/logging.h" - -#include "vm/exceptions.h" - -#include "vmcore/classcache.h" -#include "vmcore/options.h" -#include "vmcore/utf8.h" - - -/************************************************************************* - - Class Cache - - The classcache has two functions: - - 1) caching the resolution of class references - 2) storing and checking loading constraints - - We will use the following terms in this description: - - N a class name: a utf string - (N,L) a class reference with initiating loader L and class name N - C a class (object): the result of resolving a reference (N,L) - We will write resultion as - C = *(N,L) - (N,L1,L2) a loading constraint indicating that (N,L1) and (N,L2) must - resolve to the same class C. So (N,L1,L2) means - *(N,L1) = *(N,L2) - - The functions of the classcache require: - - 1) a mapping (N,L) |--> C for looking up prior resolution results. - 2) storing the current set of loading constraints { (N,L1,L2) } - - These functions can be rearranged like that: - - a mapping N |--> (a mapping L |--> C or NULL, - a set of constraints {(L1,L2)}) - - Thus we can treat the mapping and constraints for each name N - separately. The implementation does this by keeping a hash table - mapping a name N to a `classcache_name_entry` which contains all - info with respect to N. - - For a class name N we can define an equivalence relation ~N~ on - class loaders: - - L1 ~N~ L2 <==> *(N,L1) = *(N,L2) - - A loading constraint (N,L1,L2) implies L1 ~N~ L2. - - Also, if two references (N,L1) and (N,L2) resolve to the same class C - we have L1 ~N~ L2 because class loaders are required to return - consistent resolutions for a name N [XXX]. - - A `classcache_name_entry` keeps a set of tuples { (Cx,IL,CL) }, - where - Cx...is a class C or NULL - IL...is the set of initiating loaders - CL...is the set of constrained loaders - - Such a tuple is called `classcache_class_entry` in the source code. - - The following holds for each tuple (Cx,IL,CL): - - . (Cx is NULL) implies IL = {}. - - . If Cx is a class, IL is the set of loaders that have been - recorded as initiating loaders for Cx. IL may be the - empty set {} in case Cx has already been defined but no - initiating loader has been recorded, yet. - - . (IL u CL) is a subset of an equivalence class of ~N~. - - (This means that all loaders in IL and CL must resolve - the name N to the same class.) - - The following holds for the set of tuples { (Cx,IL,CL) }: - - . For a given class C there is at most one tuple with Cx = C - in the set. (There may be an arbitrary number of tuples - with Cx = NULL, however.) - - . For a given loader L there is at most one tuple with - L in (IL u CL). - - The implementation stores sets of loaders as linked lists of - `classcache_loader_entry`s. - - Comments about manipulating the classcache can be found in the - individual functions below. - -*************************************************************************/ - - -/* initial number of slots in the classcache hash table */ -#define CLASSCACHE_INIT_SIZE 2048 - -/*============================================================================*/ -/* DEBUG HELPERS */ -/*============================================================================*/ - -/* #define CLASSCACHE_VERBOSE */ - -/*============================================================================*/ -/* STATISTICS */ -/*============================================================================*/ - -/*#define CLASSCACHE_STATS*/ - -#ifdef CLASSCACHE_STATS -static int stat_classnames_stored = 0; -static int stat_classes_stored = 0; -static int stat_trivial_constraints = 0; -static int stat_nontriv_constraints = 0; -static int stat_nontriv_constraints_both = 0; -static int stat_nontriv_constraints_merged = 0; -static int stat_nontriv_constraints_one = 0; -static int stat_nontriv_constraints_none = 0; -static int stat_new_loader_entry = 0; -static int stat_merge_class_entries = 0; -static int stat_merge_loader_entries = 0; -static int stat_lookup = 0; -static int stat_lookup_class_entry_checked = 0; -static int stat_lookup_loader_checked = 0; -static int stat_lookup_name = 0; -static int stat_lookup_name_entry = 0; -static int stat_lookup_name_notfound = 0; -static int stat_lookup_new_name = 0; -static int stat_lookup_new_name_entry = 0; -static int stat_lookup_new_name_collisions = 0; -static int stat_rehash_names = 0; -static int stat_rehash_names_collisions = 0; - -#define CLASSCACHE_COUNT(cnt) (cnt)++ -#define CLASSCACHE_COUNTIF(cond,cnt) do{if(cond) (cnt)++;} while(0) - -void classcache_print_statistics(FILE *file) { - fprintf(file,"classnames stored : %8d\n",stat_classnames_stored); - fprintf(file,"classes stored : %8d\n",stat_classes_stored); - fprintf(file,"trivial constraints : %8d\n",stat_trivial_constraints); - fprintf(file,"non-triv constraints: %8d\n",stat_nontriv_constraints); - fprintf(file," both loaders rec.: %8d\n",stat_nontriv_constraints_both); - fprintf(file," merged : %8d\n",stat_nontriv_constraints_merged); - fprintf(file," one loader rec. : %8d\n",stat_nontriv_constraints_one); - fprintf(file," no loaders rec. : %8d\n",stat_nontriv_constraints_none); - fprintf(file,"new loader entries : %8d\n",stat_new_loader_entry); - fprintf(file,"merge class entries : %8d\n",stat_merge_class_entries); - fprintf(file,"merge loader entries: %8d\n",stat_merge_loader_entries); - fprintf(file,"lookups : %8d\n",stat_lookup); - fprintf(file," class entries ckd: %8d\n",stat_lookup_class_entry_checked); - fprintf(file," loader checked : %8d\n",stat_lookup_loader_checked); - fprintf(file,"lookup name : %8d\n",stat_lookup_name); - fprintf(file," entries checked : %8d\n",stat_lookup_name_entry); - fprintf(file," not found : %8d\n",stat_lookup_name_notfound); - fprintf(file,"lookup (new) name : %8d\n",stat_lookup_new_name); - fprintf(file," entries checked : %8d\n",stat_lookup_new_name_entry); - fprintf(file," new collisions : %8d\n",stat_lookup_new_name_collisions); - fprintf(file,"names rehashed : %8d times\n",stat_rehash_names); - fprintf(file," collisions : %8d\n",stat_rehash_names_collisions); -} -#else -#define CLASSCACHE_COUNT(cnt) -#define CLASSCACHE_COUNTIF(cond,cnt) -#endif - -/*============================================================================*/ -/* THREAD-SAFE LOCKING */ -/*============================================================================*/ - - /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - /* CAUTION: The static functions below are */ - /* NOT synchronized! */ - /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -#if defined(ENABLE_THREADS) -# define CLASSCACHE_LOCK() LOCK_MONITOR_ENTER(lock_hashtable_classcache) -# define CLASSCACHE_UNLOCK() LOCK_MONITOR_EXIT(lock_hashtable_classcache) -#else -# define CLASSCACHE_LOCK() -# define CLASSCACHE_UNLOCK() -#endif - -/*============================================================================*/ -/* GLOBAL VARIABLES */ -/*============================================================================*/ - -hashtable hashtable_classcache; - -#if defined(ENABLE_THREADS) -static java_object_t *lock_hashtable_classcache; -#endif - - -/*============================================================================*/ -/* */ -/*============================================================================*/ - -/* prototypes */ - -static void classcache_free_class_entry(classcache_class_entry *clsen); -static void classcache_remove_class_entry(classcache_name_entry *en, - classcache_class_entry *clsen); - -/* hash function to use */ - -#define CLASSCACHE_HASH utf_full_hashkey - -/* classcache_init ************************************************************* - - Initialize the class cache - - Note: NOT synchronized! - -*******************************************************************************/ - -bool classcache_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("classcache_init"); - - /* create the hashtable */ - - hashtable_create(&hashtable_classcache, CLASSCACHE_INIT_SIZE); - -#if defined(ENABLE_THREADS) - /* create utf hashtable lock object */ - - lock_hashtable_classcache = NEW(java_object_t); - - LOCK_INIT_OBJECT_LOCK(lock_hashtable_classcache); -#endif - - /* everything's ok */ - - return true; -} - -/* classcache_new_loader_entry ************************************************* - - Create a new classcache_loader_entry struct - (internally used helper function) - - IN: - loader...........the ClassLoader object - next.............the next classcache_loader_entry - - RETURN VALUE: - the new classcache_loader_entry - -*******************************************************************************/ - -static classcache_loader_entry * classcache_new_loader_entry( - classloader_t * loader, - classcache_loader_entry * next) -{ - classcache_loader_entry *lden; - - lden = NEW(classcache_loader_entry); - lden->loader = loader; - lden->next = next; - CLASSCACHE_COUNT(stat_new_loader_entry); - - return lden; -} - -/* classcache_merge_loaders **************************************************** - - Merge two lists of loaders into one - (internally used helper function) - - IN: - lista............first list (may be NULL) - listb............second list (may be NULL) - - RETURN VALUE: - the merged list (may be NULL) - - NOTE: - The lists given as arguments are destroyed! - -*******************************************************************************/ - -static classcache_loader_entry * classcache_merge_loaders( - classcache_loader_entry * lista, - classcache_loader_entry * listb) -{ - classcache_loader_entry *result; - classcache_loader_entry *ldenA; - classcache_loader_entry *ldenB; - classcache_loader_entry **chain; - - CLASSCACHE_COUNT(stat_merge_loader_entries); - - /* XXX This is a quadratic algorithm. If this ever - * becomes a problem, the loader lists should be - * stored as sorted lists and merged in linear time. */ - - result = NULL; - chain = &result; - - for (ldenA = lista; ldenA; ldenA = ldenA->next) { - - for (ldenB = listb; ldenB; ldenB = ldenB->next) { - if (ldenB->loader == ldenA->loader) - goto common_element; - } - - /* this loader is only in lista */ - *chain = ldenA; - chain = &(ldenA->next); - - common_element: - /* XXX free the duplicated element */ - ; - } - - /* concat listb to the result */ - *chain = listb; - - return result; -} - -/* classcache_merge_class_entries ********************************************** - - Merge two `classcache_class_entry`s into one. - (internally used helper function) - - IN: - en...............the classcache_name_entry containing both class entries - clsenA...........first class entry, will receive the result - clsenB...........second class entry - - PRE-CONDITION: - Either both entries must have the same classobj, or one of them has - classobj == NULL. - - NOTE: - clsenB is freed by this function! - -*******************************************************************************/ - -static void classcache_merge_class_entries(classcache_name_entry *en, - classcache_class_entry *clsenA, - classcache_class_entry *clsenB) -{ -#ifdef CLASSCACHE_VERBOSE - char logbuffer[1024]; -#endif - - assert(en); - assert(clsenA); - assert(clsenB); - assert(!clsenA->classobj || !clsenB->classobj || clsenA->classobj == clsenB->classobj); - -#ifdef CLASSCACHE_VERBOSE - sprintf(logbuffer,"classcache_merge_class_entries(%p,%p->%p,%p->%p) ", - (void*)en,(void*)clsenA,(void*)clsenA->classobj,(void*)clsenB,(void*)clsenB->classobj); - if (clsenA->classobj) - utf_cat_classname(logbuffer, clsenA->classobj->name); - if (clsenB->classobj) - utf_cat_classname(logbuffer, clsenB->classobj->name); - log_println(logbuffer); -#endif - - CLASSCACHE_COUNT(stat_merge_class_entries); - - /* clsenB will be merged into clsenA */ - clsenA->loaders = classcache_merge_loaders(clsenA->loaders, clsenB->loaders); - clsenB->loaders = NULL; /* these have been freed or reused */ - - clsenA->constraints = classcache_merge_loaders(clsenA->constraints, - clsenB->constraints); - clsenB->constraints = NULL; /* these have been freed or reused */ - - if (!clsenA->classobj) - clsenA->classobj = clsenB->classobj; - - /* remove clsenB from the list of class entries */ - classcache_remove_class_entry(en, clsenB); -} - - -/* classcache_lookup_name ****************************************************** - - Lookup a name in the first level of the cache - (internally used helper function) - - IN: - name.............the name to look up - - RETURN VALUE: - a pointer to the classcache_name_entry for this name, or - null if no entry was found. - -*******************************************************************************/ - -static classcache_name_entry *classcache_lookup_name(utf *name) -{ - classcache_name_entry *c; /* hash table element */ - u4 key; /* hashkey computed from classname */ - u4 slot; /* slot in hashtable */ - - CLASSCACHE_COUNT(stat_lookup_name); - - key = CLASSCACHE_HASH(name->text, (u4) name->blength); - slot = key & (hashtable_classcache.size - 1); - c = hashtable_classcache.ptr[slot]; - - /* search external hash chain for the entry */ - - while (c) { - /* entry found in hashtable */ - CLASSCACHE_COUNT(stat_lookup_name_entry); - - if (c->name == name) - return c; - - c = c->hashlink; /* next element in external chain */ - } - - /* not found */ - - CLASSCACHE_COUNT(stat_lookup_name_notfound); - return NULL; -} - - -/* classcache_new_name ********************************************************* - - Return a classcache_name_entry for the given name. The entry is created - if it is not already in the cache. - (internally used helper function) - - IN: - name.............the name to look up / create an entry for - - RETURN VALUE: - a pointer to the classcache_name_entry for this name - -*******************************************************************************/ - -static classcache_name_entry *classcache_new_name(utf *name) -{ - classcache_name_entry *c; /* hash table element */ - u4 key; /* hashkey computed from classname */ - u4 slot; /* slot in hashtable */ - u4 i; - - CLASSCACHE_COUNT(stat_lookup_new_name); - - key = CLASSCACHE_HASH(name->text, (u4) name->blength); - slot = key & (hashtable_classcache.size - 1); - c = hashtable_classcache.ptr[slot]; - - /* search external hash chain for the entry */ - - while (c) { - /* entry found in hashtable */ - CLASSCACHE_COUNT(stat_lookup_new_name_entry); - - if (c->name == name) - return c; - - c = c->hashlink; /* next element in external chain */ - } - - /* location in hashtable found, create new entry */ - - c = NEW(classcache_name_entry); - - c->name = name; - c->classes = NULL; - - /* insert entry into hashtable */ - c->hashlink = (classcache_name_entry *) hashtable_classcache.ptr[slot]; - CLASSCACHE_COUNTIF(c->hashlink,stat_lookup_new_name_collisions); - hashtable_classcache.ptr[slot] = c; - - /* update number of hashtable-entries */ - hashtable_classcache.entries++; - CLASSCACHE_COUNT(stat_classnames_stored); - - if ((hashtable_classcache.entries*2) > hashtable_classcache.size) { - /* reorganization of hashtable */ - - classcache_name_entry *c2; - hashtable newhash; /* the new hashtable */ - - CLASSCACHE_COUNT(stat_rehash_names); - - /* create new hashtable, double the size */ - - hashtable_create(&newhash, hashtable_classcache.size * 2); - newhash.entries = hashtable_classcache.entries; - - /* transfer elements to new hashtable */ - - for (i = 0; i < hashtable_classcache.size; i++) { - c2 = (classcache_name_entry *) hashtable_classcache.ptr[i]; - while (c2) { - classcache_name_entry *nextc = c2->hashlink; - u4 newslot = - (CLASSCACHE_HASH(c2->name->text, (u4) c2->name->blength)) & (newhash.size - 1); - - c2->hashlink = (classcache_name_entry *) newhash.ptr[newslot]; - CLASSCACHE_COUNTIF(c2->hashlink,stat_rehash_names_collisions); - newhash.ptr[newslot] = c2; - - c2 = nextc; - } - } - - /* dispose old table */ - - MFREE(hashtable_classcache.ptr, void *, hashtable_classcache.size); - hashtable_classcache = newhash; - } - - return c; -} - - -/* classcache_lookup *********************************************************** - - Lookup a possibly loaded class - - IN: - initloader.......initiating loader for resolving the class name - classname........class name to look up - - RETURN VALUE: - The return value is a pointer to the cached class object, - or NULL, if the class is not in the cache. - - Note: synchronized with global tablelock - -*******************************************************************************/ - -classinfo *classcache_lookup(classloader_t *initloader, utf *classname) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; - classcache_loader_entry *lden; - classinfo *cls = NULL; - - CLASSCACHE_LOCK(); - - CLASSCACHE_COUNT(stat_lookup); - en = classcache_lookup_name(classname); - - if (en) { - /* iterate over all class entries */ - - for (clsen = en->classes; clsen; clsen = clsen->next) { - CLASSCACHE_COUNT(stat_lookup_class_entry_checked); - /* check if this entry has been loaded by initloader */ - - for (lden = clsen->loaders; lden; lden = lden->next) { - CLASSCACHE_COUNT(stat_lookup_loader_checked); - if (lden->loader == initloader) { - /* found the loaded class entry */ - - assert(clsen->classobj); - cls = clsen->classobj; - goto found; - } - } - } - } - - found: - CLASSCACHE_UNLOCK(); - return cls; -} - - -/* classcache_lookup_defined *************************************************** - - Lookup a class with the given name and defining loader - - IN: - defloader........defining loader - classname........class name - - RETURN VALUE: - The return value is a pointer to the cached class object, - or NULL, if the class is not in the cache. - -*******************************************************************************/ - -classinfo *classcache_lookup_defined(classloader_t *defloader, utf *classname) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; - classinfo *cls = NULL; - - CLASSCACHE_LOCK(); - - en = classcache_lookup_name(classname); - - if (en) { - /* iterate over all class entries */ - for (clsen = en->classes; clsen; clsen = clsen->next) { - if (!clsen->classobj) - continue; - - /* check if this entry has been defined by defloader */ - if (clsen->classobj->classloader == defloader) { - cls = clsen->classobj; - goto found; - } - } - } - - found: - CLASSCACHE_UNLOCK(); - return cls; -} - - -/* classcache_lookup_defined_or_initiated ************************************** - - Lookup a class that has been defined or initiated by the given loader - - IN: - loader...........defining or initiating loader - classname........class name to look up - - RETURN VALUE: - The return value is a pointer to the cached class object, - or NULL, if the class is not in the cache. - - Note: synchronized with global tablelock - -*******************************************************************************/ - -classinfo *classcache_lookup_defined_or_initiated(classloader_t *loader, - utf *classname) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; - classcache_loader_entry *lden; - classinfo *cls = NULL; - - CLASSCACHE_LOCK(); - - en = classcache_lookup_name(classname); - - if (en) { - /* iterate over all class entries */ - - for (clsen = en->classes; clsen; clsen = clsen->next) { - - /* check if this entry has been defined by loader */ - if (clsen->classobj && clsen->classobj->classloader == loader) { - cls = clsen->classobj; - goto found; - } - - /* check if this entry has been initiated by loader */ - for (lden = clsen->loaders; lden; lden = lden->next) { - if (lden->loader == loader) { - /* found the loaded class entry */ - - assert(clsen->classobj); - cls = clsen->classobj; - goto found; - } - } - } - } - - found: - CLASSCACHE_UNLOCK(); - return cls; -} - - -/* classcache_store ************************************************************ - - Store a loaded class. If a class of the same name has already been stored - with the same initiating loader, then the given class CLS is freed (if - possible) and the previously stored class is returned. - - IN: - initloader.......initiating loader used to load the class - (may be NULL indicating the bootstrap loader) - cls..............class object to cache - mayfree..........true if CLS may be freed in case another class is - returned - - RETURN VALUE: - cls..............everything ok, the class was stored in the cache, - other classinfo..another class with the same (initloader,name) has been - stored earlier. CLS has been freed[1] and the earlier - stored class is returned. - NULL.............an exception has been thrown. - - Note: synchronized with global tablelock - - [1]...in case MAYFREE is true - -*******************************************************************************/ - -classinfo *classcache_store(classloader_t *initloader, classinfo *cls, - bool mayfree) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; - classcache_class_entry *clsenB; - classcache_loader_entry *lden; -#ifdef CLASSCACHE_VERBOSE - char logbuffer[1024]; -#endif - - assert(cls); - assert(cls->state & CLASS_LOADED); - - CLASSCACHE_LOCK(); - -#ifdef CLASSCACHE_VERBOSE - sprintf(logbuffer,"classcache_store (%p,%d,%p=", (void*)initloader,mayfree,(void*)cls); - utf_cat_classname(logbuffer, cls->name); - strcat(logbuffer,")"); - log_println(logbuffer); -#endif - - en = classcache_new_name(cls->name); - - assert(en); - - /* iterate over all class entries */ - for (clsen = en->classes; clsen; clsen = clsen->next) { - - /* check if this entry has already been loaded by initloader */ - for (lden = clsen->loaders; lden; lden = lden->next) { - if (lden->loader == initloader) { - if (clsen->classobj != cls) { - /* A class with the same (initloader,name) pair has been stored already. */ - /* We free the given class and return the earlier one. */ -#ifdef CLASSCACHE_VERBOSE - log_println("replacing %p with earlier loaded class %p",cls,clsen->classobj); -#endif - assert(clsen->classobj); - if (mayfree) - class_free(cls); - cls = clsen->classobj; - } - goto return_success; - } - } - - /* {This entry has not been resolved with initloader} */ - - /* check if initloader is constrained to this entry */ - for (lden = clsen->constraints; lden; lden = lden->next) { - if (lden->loader == initloader) { - /* we have to use this entry. check if it has been resolved */ - if (clsen->classobj) { - /* check if is has already been resolved to another class */ - if (clsen->classobj != cls) { - /* a loading constraint is violated */ - exceptions_throw_linkageerror("loading constraint violated: ", cls); - goto return_exception; - } - - /* record initloader as initiating loader */ - clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders); - goto return_success; - } - - /* {this is the first resolution for this entry} */ - /* record initloader as initiating loader */ - clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders); - - /* maybe we can merge this entry with another one */ - for (clsenB = en->classes; clsenB; clsenB = clsenB->next) { - /* we dont want the entry that we have already */ - if (clsenB->classobj == cls) { - /* this entry has the same classobj. let's merge them */ - classcache_merge_class_entries(en,clsen,clsenB); - goto return_success; - } - } - - /* record the loaded class object */ - clsen->classobj = cls; - CLASSCACHE_COUNT(stat_classes_stored); - - /* done */ - goto return_success; - } - } - - } - - /* {There is no class entry containing initloader as initiating - * or constrained loader.} */ - - /* we look for a class entry with the same classobj we want to store */ - for (clsen = en->classes; clsen; clsen = clsen->next) { - if (clsen->classobj == cls) { - /* this entry is about the same classobj. let's use it */ - /* check if this entry has already been loaded by initloader */ - for (lden = clsen->loaders; lden; lden = lden->next) { - if (lden->loader == initloader) - goto return_success; - } - clsen->loaders = classcache_new_loader_entry(initloader, clsen->loaders); - goto return_success; - } - } - - /* create a new class entry for this class object with */ - /* initiating loader initloader */ - - clsen = NEW(classcache_class_entry); - clsen->classobj = cls; - clsen->loaders = classcache_new_loader_entry(initloader, NULL); - clsen->constraints = NULL; - - clsen->next = en->classes; - en->classes = clsen; - CLASSCACHE_COUNT(stat_classes_stored); - - return_success: -#ifdef CLASSCACHE_VERBOSE - classcache_debug_dump(stdout,cls->name); -#endif - CLASSCACHE_UNLOCK(); - return cls; - - return_exception: - CLASSCACHE_UNLOCK(); - return NULL; /* exception */ -} - -/* classcache_store_unique ***************************************************** - - Store a loaded class as loaded by the bootstrap loader. This is a wrapper - aroung classcache_store that throws an exception if a class with the same - name has already been loaded by the bootstrap loader. - - This function is used to register a few special classes during startup. - It should not be used otherwise. - - IN: - cls..............class object to cache - - RETURN VALUE: - true.............everything ok, the class was stored. - false............an exception has been thrown. - - Note: synchronized with global tablelock - -*******************************************************************************/ - -bool classcache_store_unique(classinfo *cls) -{ - classinfo *result; - - result = classcache_store(NULL,cls,false); - if (result == NULL) - return false; - - if (result != cls) { - exceptions_throw_internalerror("class already stored in the class cache"); - return false; - } - - return true; -} - -/* classcache_store_defined **************************************************** - - Store a loaded class after it has been defined. If the class has already - been defined by the same defining loader in another thread, free the given - class and returned the one which has been defined earlier. - - IN: - cls..............class object to store. classloader must be set - (classloader may be NULL, for bootloader) - - RETURN VALUE: - cls..............everything ok, the class was stored the cache, - other classinfo..the class had already been defined, CLS was freed, the - class which was defined earlier is returned, - NULL.............an exception has been thrown. - -*******************************************************************************/ - -classinfo *classcache_store_defined(classinfo *cls) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; -#ifdef CLASSCACHE_VERBOSE - char logbuffer[1024]; -#endif - - assert(cls); - assert(cls->state & CLASS_LOADED); - - CLASSCACHE_LOCK(); - -#ifdef CLASSCACHE_VERBOSE - sprintf(logbuffer,"classcache_store_defined (%p,", (void*)cls->classloader); - utf_cat_classname(logbuffer, cls->name); - strcat(logbuffer,")"); - log_println(logbuffer); -#endif - - en = classcache_new_name(cls->name); - - assert(en); - - /* iterate over all class entries */ - for (clsen = en->classes; clsen; clsen = clsen->next) { - - /* check if this class has been defined by the same classloader */ - if (clsen->classobj && clsen->classobj->classloader == cls->classloader) { - /* we found an earlier definition, delete the newer one */ - /* (if it is a different classinfo) */ - if (clsen->classobj != cls) { -#ifdef CLASSCACHE_VERBOSE - log_println("replacing %p with earlier defined class %p",cls,clsen->classobj); -#endif - class_free(cls); - cls = clsen->classobj; - } - goto return_success; - } - } - - /* create a new class entry for this class object */ - /* the list of initiating loaders is empty at this point */ - - clsen = NEW(classcache_class_entry); - clsen->classobj = cls; - clsen->loaders = NULL; - clsen->constraints = NULL; - - clsen->next = en->classes; - en->classes = clsen; - CLASSCACHE_COUNT(stat_classes_stored); - -return_success: -#ifdef CLASSCACHE_VERBOSE - classcache_debug_dump(stdout,cls->name); -#endif - CLASSCACHE_UNLOCK(); - return cls; -} - -/* classcache_find_loader ****************************************************** - - Find the class entry loaded by or constrained to a given loader - (internally used helper function) - - IN: - entry............the classcache_name_entry - loader...........the loader to look for - - RETURN VALUE: - the classcache_class_entry for the given loader, or - NULL if no entry was found - -*******************************************************************************/ - -static classcache_class_entry * classcache_find_loader( - classcache_name_entry * entry, - classloader_t * loader) -{ - classcache_class_entry *clsen; - classcache_loader_entry *lden; - - assert(entry); - - /* iterate over all class entries */ - for (clsen = entry->classes; clsen; clsen = clsen->next) { - - /* check if this entry has already been loaded by initloader */ - for (lden = clsen->loaders; lden; lden = lden->next) { - if (lden->loader == loader) - return clsen; /* found */ - } - - /* check if loader is constrained to this entry */ - for (lden = clsen->constraints; lden; lden = lden->next) { - if (lden->loader == loader) - return clsen; /* found */ - } - } - - /* not found */ - return NULL; -} - -/* classcache_free_class_entry ************************************************* - - Free the memory used by a class entry - - IN: - clsen............the classcache_class_entry to free - -*******************************************************************************/ - -static void classcache_free_class_entry(classcache_class_entry * clsen) -{ - classcache_loader_entry *lden; - classcache_loader_entry *next; - - assert(clsen); - - for (lden = clsen->loaders; lden; lden = next) { - next = lden->next; - FREE(lden, classcache_loader_entry); - } - for (lden = clsen->constraints; lden; lden = next) { - next = lden->next; - FREE(lden, classcache_loader_entry); - } - - FREE(clsen, classcache_class_entry); -} - -/* classcache_remove_class_entry *********************************************** - - Remove a classcache_class_entry from the list of possible resolution of - a name entry - (internally used helper function) - - IN: - entry............the classcache_name_entry - clsen............the classcache_class_entry to remove - -*******************************************************************************/ - -static void classcache_remove_class_entry(classcache_name_entry * entry, - classcache_class_entry * clsen) -{ - classcache_class_entry **chain; - - assert(entry); - assert(clsen); - - chain = &(entry->classes); - while (*chain) { - if (*chain == clsen) { - *chain = clsen->next; - classcache_free_class_entry(clsen); - return; - } - chain = &((*chain)->next); - } -} - -/* classcache_free_name_entry ************************************************** - - Free the memory used by a name entry - - IN: - entry............the classcache_name_entry to free - -*******************************************************************************/ - -static void classcache_free_name_entry(classcache_name_entry * entry) -{ - classcache_class_entry *clsen; - classcache_class_entry *next; - - assert(entry); - - for (clsen = entry->classes; clsen; clsen = next) { - next = clsen->next; - classcache_free_class_entry(clsen); - } - - FREE(entry, classcache_name_entry); -} - -/* classcache_free ************************************************************* - - Free the memory used by the class cache - - NOTE: - The class cache may not be used any more after this call, except - when it is reinitialized with classcache_init. - - Note: NOT synchronized! - -*******************************************************************************/ - -void classcache_free(void) -{ - u4 slot; - classcache_name_entry *entry; - classcache_name_entry *next; - - for (slot = 0; slot < hashtable_classcache.size; ++slot) { - for (entry = (classcache_name_entry *) hashtable_classcache.ptr[slot]; entry; entry = next) { - next = entry->hashlink; - classcache_free_name_entry(entry); - } - } - - MFREE(hashtable_classcache.ptr, voidptr, hashtable_classcache.size); - hashtable_classcache.size = 0; - hashtable_classcache.entries = 0; - hashtable_classcache.ptr = NULL; -} - -/* classcache_add_constraint *************************************************** - - Add a loading constraint - - IN: - a................first initiating loader - b................second initiating loader - classname........class name - - RETURN VALUE: - true.............everything ok, the constraint has been added, - false............an exception has been thrown. - - Note: synchronized with global tablelock - -*******************************************************************************/ - -#if defined(ENABLE_VERIFIER) -bool classcache_add_constraint(classloader_t * a, - classloader_t * b, - utf * classname) -{ - classcache_name_entry *en; - classcache_class_entry *clsenA; - classcache_class_entry *clsenB; - - assert(classname); - -#ifdef CLASSCACHE_VERBOSE - log_start(); - log_print("classcache_add_constraint(%p,%p,", (void *) a, (void *) b); - utf_fprint_printable_ascii_classname(stdout, classname); - log_print(")\n"); - log_finish(); -#endif - - /* a constraint with a == b is trivially satisfied */ - if (a == b) { - CLASSCACHE_COUNT(stat_trivial_constraints); - return true; - } - - CLASSCACHE_LOCK(); - - en = classcache_new_name(classname); - - assert(en); - CLASSCACHE_COUNT(stat_nontriv_constraints); - - /* find the entry loaded by / constrained to each loader */ - clsenA = classcache_find_loader(en, a); - clsenB = classcache_find_loader(en, b); - - if (clsenA && clsenB) { - /* { both loaders have corresponding entries } */ - CLASSCACHE_COUNT(stat_nontriv_constraints_both); - - /* if the entries are the same, the constraint is already recorded */ - if (clsenA == clsenB) - goto return_success; - - /* check if the entries can be merged */ - if (clsenA->classobj && clsenB->classobj - && clsenA->classobj != clsenB->classobj) { - /* no, the constraint is violated */ - exceptions_throw_linkageerror("loading constraint violated: ", - clsenA->classobj); - goto return_exception; - } - - /* yes, merge the entries */ - classcache_merge_class_entries(en,clsenA,clsenB); - CLASSCACHE_COUNT(stat_nontriv_constraints_merged); - } - else { - /* { at most one of the loaders has a corresponding entry } */ - - /* set clsenA to the single class entry we have */ - if (!clsenA) - clsenA = clsenB; - - if (!clsenA) { - /* { no loader has a corresponding entry } */ - CLASSCACHE_COUNT(stat_nontriv_constraints_none); - - /* create a new class entry with the constraint (a,b,en->name) */ - clsenA = NEW(classcache_class_entry); - clsenA->classobj = NULL; - clsenA->loaders = NULL; - clsenA->constraints = classcache_new_loader_entry(b, NULL); - clsenA->constraints = classcache_new_loader_entry(a, clsenA->constraints); - - clsenA->next = en->classes; - en->classes = clsenA; - } - else { - CLASSCACHE_COUNT(stat_nontriv_constraints_one); - - /* make b the loader that has no corresponding entry */ - if (clsenB) - b = a; - - /* loader b must be added to entry clsenA */ - clsenA->constraints = classcache_new_loader_entry(b, clsenA->constraints); - } - } - - return_success: - CLASSCACHE_UNLOCK(); - return true; - - return_exception: - CLASSCACHE_UNLOCK(); - return false; /* exception */ -} -#endif /* defined(ENABLE_VERIFIER) */ - -/* classcache_add_constraints_for_params *************************************** - - Add loading constraints for the parameters and return type of - the given method. - - IN: - a................first initiating loader - b................second initiating loader - m................methodinfo - - RETURN VALUE: - true.............everything ok, the constraints have been added, - false............an exception has been thrown. - - Note: synchronized with global tablelock - -*******************************************************************************/ - -#if defined(ENABLE_VERIFIER) -bool classcache_add_constraints_for_params(classloader_t * a, - classloader_t * b, - methodinfo *m) -{ - methoddesc *md; - typedesc *td; - s4 i; - - /* a constraint with a == b is trivially satisfied */ - - if (a == b) { - return true; - } - - /* get the parsed descriptor */ - - assert(m); - md = m->parseddesc; - assert(md); - - /* constrain the return type */ - - if (md->returntype.type == TYPE_ADR) { - if (!classcache_add_constraint(a, b, md->returntype.classref->name)) - return false; /* exception */ - } - - /* constrain each reference type used in the parameters */ - - td = md->paramtypes; - i = md->paramcount; - for (; i--; td++) { - if (td->type != TYPE_ADR) - continue; - - if (!classcache_add_constraint(a, b, td->classref->name)) - return false; /* exception */ - } - - /* everything ok */ - return true; -} -#endif /* defined(ENABLE_VERIFIER) */ - - -/* classcache_number_of_loaded_classes ***************************************** - - Counts the number of loaded classes and returns it. - - Note: This function assumes that the CLASSCACHE_LOCK is held by the - caller! - -*******************************************************************************/ - -static s4 classcache_number_of_loaded_classes(void) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; - s4 number; - s4 i; - - /* initialize class counter */ - - number = 0; - - for (i = 0; i < hashtable_classcache.size; i++) { - /* iterate over hashlink */ - - for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) { - /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */ - - if (en->name->text[0] == '$') - continue; - - /* iterate over classes with same name */ - - for (clsen = en->classes; clsen != NULL; clsen = clsen->next) { - /* get only loaded classes */ - - if (clsen->classobj != NULL) - number++; - } - } - } - - return number; -} - - -/* classcache_get_loaded_class_count ******************************************* - - Counts the number of loaded classes and returns it. - -*******************************************************************************/ - -s4 classcache_get_loaded_class_count(void) -{ - s4 count; - - CLASSCACHE_LOCK(); - - count = classcache_number_of_loaded_classes(); - - CLASSCACHE_UNLOCK(); - - return count; -} - - -/* classcache_get_loaded_classes *********************************************** - - Returns an array of all loaded classes as array. The array is - allocaed on the Java heap. - -*******************************************************************************/ - -#if defined(ENABLE_JVMTI) -void classcache_get_loaded_classes(s4 *class_count_ptr, - classinfo ***classes_ptr) -{ - classinfo **classes; - s4 class_count; - classcache_name_entry *en; - classcache_class_entry *clsen; - s4 i; - s4 j; - - CLASSCACHE_LOCK(); - - /* get the number of loaded classes and allocate the array */ - - class_count = classcache_number_of_loaded_classes(); - - classes = GCMNEW(classinfo*, class_count); - - /* look in every slot of the hashtable */ - - for (i = 0, j = 0; i < hashtable_classcache.size; i++) { - /* iterate over hashlink */ - - for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) { - /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */ - - if (en->name->text[0] == '$') - continue; - - /* iterate over classes with same name */ - - for (clsen = en->classes; clsen != NULL; clsen = clsen->next) { - /* get only loaded classes */ - - if (clsen->classobj != NULL) { - classes[j] = clsen->classobj; - j++; - } - } - } - } - - /* pass the return values */ - - *class_count_ptr = class_count; - *classes_ptr = classes; - - CLASSCACHE_UNLOCK(); -} -#endif /* defined(ENABLE_JVMTI) */ - - -/* classcache_foreach_loaded_class ********************************************* - - Calls the given function for each loaded class. - -*******************************************************************************/ - -void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func, - void *data) -{ - classcache_name_entry *en; - classcache_class_entry *clsen; - s4 i; - - CLASSCACHE_LOCK(); - - /* look in every slot of the hashtable */ - - for (i = 0; i < hashtable_classcache.size; i++) { - /* iterate over hashlink */ - - for (en = hashtable_classcache.ptr[i]; en != NULL; en = en->hashlink) { - /* filter pseudo classes $NEW$, $NULL$, $ARRAYSTUB$ out */ - - if (en->name->text[0] == '$') - continue; - - /* iterate over classes with same name */ - - for (clsen = en->classes; clsen != NULL; clsen = clsen->next) { - /* get only loaded classes */ - - if (clsen->classobj != NULL) { - (*func)(clsen->classobj, data); - } - } - } - } - - CLASSCACHE_UNLOCK(); -} - - -/*============================================================================*/ -/* DEBUG DUMPS */ -/*============================================================================*/ - -/* classcache_debug_dump ******************************************************* - - Print the contents of the loaded class cache to a stream - - IN: - file.............output stream - only.............if != NULL, only print entries for this name - (Currently we print also the rest of the hash chain to - get a feel for the average length of hash chains.) - - Note: synchronized with global tablelock - -*******************************************************************************/ - -#ifndef NDEBUG -void classcache_debug_dump(FILE * file,utf *only) -{ - classcache_name_entry *c; - classcache_class_entry *clsen; - classcache_loader_entry *lden; - u4 slot; - - CLASSCACHE_LOCK(); - - log_println("=== [loaded class cache] ====================================="); - log_println("hash size : %d", (int) hashtable_classcache.size); - log_println("hash entries: %d", (int) hashtable_classcache.entries); - log_println(""); - - if (only) { - c = classcache_lookup_name(only); - slot = 0; /* avoid compiler warning */ - goto dump_it; - } - - for (slot = 0; slot < hashtable_classcache.size; ++slot) { - c = (classcache_name_entry *) hashtable_classcache.ptr[slot]; - -dump_it: - for (; c; c = c->hashlink) { - utf_fprint_printable_ascii_classname(file, c->name); - fprintf(file, "\n"); - - /* iterate over all class entries */ - for (clsen = c->classes; clsen; clsen = clsen->next) { - if (clsen->classobj) { - log_println(" loaded %p", (void *) clsen->classobj); - } - else { - log_println(" unresolved"); - } - - log_start(); - log_print(" loaders: "); - for (lden = clsen->loaders; lden; lden = lden->next) { - log_print("<%p> %p ", (void *) lden, (void *) lden->loader); - } - log_finish(); - - log_start(); - log_print(" constraints: "); - for (lden = clsen->constraints; lden; lden = lden->next) { - log_print("<%p> %p ", (void *) lden, (void *) lden->loader); - } - log_finish(); - } - } - - if (only) - break; - } - fprintf(file, "\n==============================================================\n\n"); - - CLASSCACHE_UNLOCK(); -} -#endif /* NDEBUG */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/classcache.h b/src/vmcore/classcache.h deleted file mode 100644 index bbdba5c52..000000000 --- a/src/vmcore/classcache.h +++ /dev/null @@ -1,173 +0,0 @@ -/* src/vmcore/classcache.h - loaded class cache and loading constraints - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _CLASSCACHE_H -#define _CLASSCACHE_H - -#include "config.h" -#include "vm/types.h" - -#include /* for FILE */ - -#if defined(ENABLE_JVMTI) -# include "native/jni.h" -#endif - -#include "toolbox/hashtable.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/references.h" - - -/* forward declarations *******************************************************/ - -typedef struct classcache_name_entry classcache_name_entry; -typedef struct classcache_class_entry classcache_class_entry; -typedef struct classcache_loader_entry classcache_loader_entry; - -/* global variables ***********************************************************/ - -extern hashtable hashtable_classcache; - - -/* structs ********************************************************************/ - -/*----------------------------------------------------------------------------*/ -/* The Loaded Class Cache */ -/* */ -/* The loaded class cache is implemented as a two-level data structure. */ -/* */ -/* The first level is a hash table indexed by class names. For each class */ -/* name in the cache there is a classcache_name_entry, which collects all */ -/* information about classes with this class name. */ -/* */ -/* Second level: For each classcache_name_entry there is a list of */ -/* classcache_class_entry:s representing the possible different resolutions */ -/* of the class name. */ -/* */ -/* A classcache_class_entry records the following: */ -/* */ -/* - the loaded class object, if this entry has been resolved, otherwise NULL */ -/* - the list of initiating loaders which have resolved the class name to */ -/* this class object */ -/* - the list of initiating loaders which are constrained to resolve this */ -/* class name to this class object in the future */ -/* */ -/* The classcache_class_entry:s approximate the equivalence classes created */ -/* by the loading constraints and the equivalence of loaded classes. */ -/* */ -/* When a loading constraint (loaderA,loaderB,NAME) is added, then the */ -/* classcache_class_entry:s for NAME containing loaderA and loaderB resp. */ -/* must be merged into one entry. If this is impossible, because the entries */ -/* have already been resolved to different class objects, then the constraint */ -/* is violated and an expception must be thrown. */ -/*----------------------------------------------------------------------------*/ - - -/* classcache_name_entry - * - * For each classname a classcache_name_entry struct is created. - */ - -struct classcache_name_entry -{ - utf *name; /* class name */ - classcache_name_entry *hashlink; /* link for external chaining */ - classcache_class_entry *classes; /* equivalence classes for this name*/ -}; - -struct classcache_class_entry -{ - classinfo *classobj; /* the loaded class object, or NULL */ - classcache_loader_entry *loaders; - classcache_loader_entry *constraints; - classcache_class_entry *next; /* next class entry for same name */ -}; - -struct classcache_loader_entry -{ - classloader_t *loader; /* class loader object */ - classcache_loader_entry *next; /* next loader entry in the list */ -}; - - -/* callback function type for classcache_foreach_loaded_class */ - -typedef void (*classcache_foreach_functionptr_t)(classinfo *, void *); - - -/* function prototypes ********************************************************/ - -/* initialize the loaded class cache */ -bool classcache_init(void); -void classcache_free(void); - -classinfo * classcache_lookup(classloader_t *initloader,utf *classname); -classinfo * classcache_lookup_defined(classloader_t *defloader,utf *classname); -classinfo * classcache_lookup_defined_or_initiated(classloader_t *loader,utf *classname); - -bool classcache_store_unique(classinfo *cls); -classinfo * classcache_store(classloader_t *initloader,classinfo *cls,bool mayfree); -classinfo * classcache_store_defined(classinfo *cls); - -#if defined(ENABLE_VERIFIER) -bool classcache_add_constraint(classloader_t *a,classloader_t *b,utf *classname); -bool classcache_add_constraints_for_params(classloader_t *a,classloader_t *b, - methodinfo *m); -#endif - -s4 classcache_get_loaded_class_count(void); - -void classcache_foreach_loaded_class(classcache_foreach_functionptr_t func, - void *data); - -#if defined(ENABLE_JVMTI) -void classcache_get_loaded_classes(s4 *class_count_ptr, - classinfo ***classes_ptr); -#endif - -#ifndef NDEBUG -void classcache_debug_dump(FILE *file,utf *only); -#endif - -#endif /* _CLASSCACHE_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ - diff --git a/src/vmcore/descriptor.c b/src/vmcore/descriptor.c deleted file mode 100644 index f49e05012..000000000 --- a/src/vmcore/descriptor.c +++ /dev/null @@ -1,1398 +0,0 @@ -/* src/vmcore/descriptor.c - checking and parsing of field / method descriptors - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "md-abi.h" - -#include "mm/memory.h" - -#include "vm/exceptions.h" -#include "vm/jit_interface.h" -#include "vm/primitive.h" -#include "vm/vm.h" - -#include "vmcore/descriptor.h" -#include "vmcore/options.h" - - -/* constants (private to descriptor.c) ****************************************/ - -/* initial number of entries for the classrefhash of a descriptor_pool */ -/* (currently the hash is never grown!) */ -#define CLASSREFHASH_INIT_SIZE 64 - -/* initial number of entries for the descriptorhash of a descriptor_pool */ -/* (currently the hash is never grown!) */ -#define DESCRIPTORHASH_INIT_SIZE 128 - -/* data structures (private to descriptor.c) **********************************/ - -typedef struct classref_hash_entry classref_hash_entry; -typedef struct descriptor_hash_entry descriptor_hash_entry; - -/* entry struct for the classrefhash of descriptor_pool */ -struct classref_hash_entry { - classref_hash_entry *hashlink; /* for hash chaining */ - utf *name; /* name of the class refered to */ - u2 index; /* index into classref table */ -}; - -/* entry struct for the descriptorhash of descriptor_pool */ -struct descriptor_hash_entry { - descriptor_hash_entry *hashlink; - utf *desc; - parseddesc_t parseddesc; - s2 paramslots; /* number of params, LONG/DOUBLE counted as 2 */ -}; - - -/****************************************************************************/ -/* MACROS FOR DESCRIPTOR PARSING (private to descriptor.c) */ -/****************************************************************************/ - -/* SKIP_FIELDDESCRIPTOR: - * utf_ptr must point to the first character of a field descriptor. - * After the macro call utf_ptr points to the first character after - * the field descriptor. - * - * CAUTION: This macro does not check for an unexpected end of the - * descriptor. Better use SKIP_FIELDDESCRIPTOR_SAFE. - */ -#define SKIP_FIELDDESCRIPTOR(utf_ptr) \ - do { while (*(utf_ptr)=='[') (utf_ptr)++; \ - if (*(utf_ptr)++=='L') \ - while(*(utf_ptr)++ != ';') /* skip */; } while(0) - -/* SKIP_FIELDDESCRIPTOR_SAFE: - * utf_ptr must point to the first character of a field descriptor. - * After the macro call utf_ptr points to the first character after - * the field descriptor. - * - * Input: - * utf_ptr....points to first char of descriptor - * end_ptr....points to first char after the end of the string - * errorflag..must be initialized (to false) by the caller! - * Output: - * utf_ptr....points to first char after the descriptor - * errorflag..set to true if the string ended unexpectedly - */ -#define SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr,end_ptr,errorflag) \ - do { while ((utf_ptr) != (end_ptr) && *(utf_ptr)=='[') (utf_ptr)++; \ - if ((utf_ptr) == (end_ptr)) \ - (errorflag) = true; \ - else \ - if (*(utf_ptr)++=='L') { \ - while((utf_ptr) != (end_ptr) && *(utf_ptr)++ != ';') \ - /* skip */; \ - if ((utf_ptr)[-1] != ';') \ - (errorflag) = true; }} while(0) - - -/****************************************************************************/ -/* DEBUG HELPERS */ -/****************************************************************************/ - -/*#define DESCRIPTOR_VERBOSE*/ - -/****************************************************************************/ -/* FUNCTIONS */ -/****************************************************************************/ - -/* descriptor_to_basic_type **************************************************** - - Return the basic type to use for a value with this descriptor. - - IN: - utf..............descriptor utf string - - OUT: - A TYPE_* constant. - - PRECONDITIONS: - This function assumes that the descriptor has passed - descriptor_pool_add checks and that it does not start with '('. - -*******************************************************************************/ - -int descriptor_to_basic_type(utf *descriptor) -{ - assert(descriptor->blength >= 1); - - switch (descriptor->text[0]) { - case 'Z': - case 'B': - case 'C': - case 'S': - case 'I': - return TYPE_INT; - - case 'J': - return TYPE_LNG; - - case 'F': - return TYPE_FLT; - - case 'D': - return TYPE_DBL; - - case 'L': - case '[': - return TYPE_ADR; - - default: - vm_abort("descriptor_to_basic_type: invalid type %c", - descriptor->text[0]); - } - - /* keep the compiler happy */ - - return 0; -} - - -/* descriptor_typesize ********************************************************* - - Return the size in bytes needed for the given type. - - IN: - td..............typedesc describing the type - - OUT: - The number of bytes - -*******************************************************************************/ - -int descriptor_typesize(typedesc *td) -{ - assert(td); - - switch (td->type) { - case TYPE_INT: - case TYPE_FLT: - return 4; - - case TYPE_LNG: - case TYPE_DBL: - return 8; - - case TYPE_ADR: - return SIZEOF_VOID_P; - - default: - vm_abort("descriptor_typesize: invalid type %d", td->type); - } - - /* keep the compiler happy */ - - return 0; -} - - -/* name_from_descriptor ******************************************************** - - Return the class name indicated by the given descriptor - (Internally used helper function) - - IN: - c................class containing the descriptor - utf_ptr..........first character of descriptor - end_ptr..........first character after the end of the string - mode.............a combination (binary or) of the following flags: - - (Flags marked with * are the default settings.) - - How to handle "V" descriptors: - - * DESCRIPTOR_VOID.....handle it like other primitive types - DESCRIPTOR_NOVOID...treat it as an error - - How to deal with extra characters after the end of the - descriptor: - - * DESCRIPTOR_NOCHECKEND...ignore (useful for parameter lists) - DESCRIPTOR_CHECKEND.....treat them as an error - - OUT: - *next............if non-NULL, *next is set to the first character after - the descriptor. (Undefined if an error occurs.) - *name............set to the utf name of the class - - RETURN VALUE: - true.............descriptor parsed successfully - false............an exception has been thrown - -*******************************************************************************/ - -#define DESCRIPTOR_VOID 0 /* default */ -#define DESCRIPTOR_NOVOID 0x0040 -#define DESCRIPTOR_NOCHECKEND 0 /* default */ -#define DESCRIPTOR_CHECKEND 0x1000 - -static bool -name_from_descriptor(classinfo *c, - char *utf_ptr, char *end_ptr, - char **next, int mode, utf **name) -{ - char *start = utf_ptr; - bool error = false; - - assert(c); - assert(utf_ptr); - assert(end_ptr); - assert(name); - - *name = NULL; - SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr, end_ptr, error); - - if (mode & DESCRIPTOR_CHECKEND) - error |= (utf_ptr != end_ptr); - - if (!error) { - if (next) *next = utf_ptr; - - switch (*start) { - case 'V': - if (mode & DESCRIPTOR_NOVOID) - break; - /* FALLTHROUGH! */ - case 'I': - case 'J': - case 'F': - case 'D': - case 'B': - case 'C': - case 'S': - case 'Z': - return true; - - case 'L': - start++; - utf_ptr--; - /* FALLTHROUGH! */ - case '[': - *name = utf_new(start, utf_ptr - start); - return true; - } - } - - exceptions_throw_classformaterror(c, "Invalid descriptor"); - return false; -} - - -/* descriptor_to_typedesc ****************************************************** - - Parse the given type descriptor and fill a typedesc struct - (Internally used helper function) - - IN: - pool.............the descriptor pool - utf_ptr..........points to first character of type descriptor - end_pos..........points after last character of the whole descriptor - - OUT: - *next............set to next character after type descriptor - *d...............filled with parsed information - - RETURN VALUE: - true.............parsing succeeded - false............an exception has been thrown - -*******************************************************************************/ - -static bool -descriptor_to_typedesc(descriptor_pool *pool, char *utf_ptr, char *end_pos, - char **next, typedesc *td) -{ - utf *name; - - if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, next, 0, &name)) - return false; - - if (name) { - /* a reference type */ - td->type = TYPE_ADR; - td->decltype = TYPE_ADR; - td->arraydim = 0; - for (utf_ptr = name->text; *utf_ptr == '['; ++utf_ptr) - td->arraydim++; - td->classref = descriptor_pool_lookup_classref(pool, name); - - } else { - /* a primitive type */ - switch (*utf_ptr) { - case 'B': - td->decltype = PRIMITIVETYPE_BYTE; - td->type = TYPE_INT; - break; - case 'C': - td->decltype = PRIMITIVETYPE_CHAR; - td->type = TYPE_INT; - break; - case 'S': - td->decltype = PRIMITIVETYPE_SHORT; - td->type = TYPE_INT; - break; - case 'Z': - td->decltype = PRIMITIVETYPE_BOOLEAN; - td->type = TYPE_INT; - break; - case 'I': - td->decltype = PRIMITIVETYPE_INT; - td->type = TYPE_INT; - break; - case 'D': - td->decltype = PRIMITIVETYPE_DOUBLE; - td->type = TYPE_DBL; - break; - case 'F': - td->decltype = PRIMITIVETYPE_FLOAT; - td->type = TYPE_FLT; - break; - case 'J': - td->decltype = PRIMITIVETYPE_LONG; - td->type = TYPE_LNG; - break; - case 'V': - td->decltype = PRIMITIVETYPE_VOID; - td->type = TYPE_VOID; - break; - default: - assert(false); - } - - td->arraydim = 0; - td->classref = NULL; - } - - return true; -} - - -/* descriptor_pool_new ********************************************************* - - Allocate a new descriptor_pool - - IN: - referer..........class for which to create the pool - - RETURN VALUE: - a pointer to the new descriptor_pool - -*******************************************************************************/ - -descriptor_pool * -descriptor_pool_new(classinfo *referer) -{ - descriptor_pool *pool; - u4 hashsize; - u4 slot; - - pool = DNEW(descriptor_pool); - assert(pool); - - pool->referer = referer; - pool->fieldcount = 0; - pool->methodcount = 0; - pool->paramcount = 0; - pool->descriptorsize = 0; - pool->descriptors = NULL; - pool->descriptors_next = NULL; - pool->classrefs = NULL; - pool->descriptor_kind = NULL; - pool->descriptor_kind_next = NULL; - - hashsize = CLASSREFHASH_INIT_SIZE; - pool->classrefhash.size = hashsize; - pool->classrefhash.entries = 0; - pool->classrefhash.ptr = DMNEW(voidptr,hashsize); - for (slot=0; slotclassrefhash.ptr[slot] = NULL; - - hashsize = DESCRIPTORHASH_INIT_SIZE; - pool->descriptorhash.size = hashsize; - pool->descriptorhash.entries = 0; - pool->descriptorhash.ptr = DMNEW(voidptr,hashsize); - for (slot=0; slotdescriptorhash.ptr[slot] = NULL; - - return pool; -} - - -/* descriptor_pool_add_class *************************************************** - - Add the given class reference to the pool - - IN: - pool.............the descriptor_pool - name.............the class reference to add - - RETURN VALUE: - true.............reference has been added - false............an exception has been thrown - -*******************************************************************************/ - -bool -descriptor_pool_add_class(descriptor_pool *pool, utf *name) -{ - u4 key,slot; - classref_hash_entry *c; - - assert(pool); - assert(name); - -#ifdef DESCRIPTOR_VERBOSE - fprintf(stderr,"descriptor_pool_add_class(%p,",(void*)pool); - utf_fprint_printable_ascii(stderr,name);fprintf(stderr,")\n"); -#endif - - /* find a place in the hashtable */ - - key = utf_hashkey(name->text, name->blength); - slot = key & (pool->classrefhash.size - 1); - c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; - - while (c) { - if (c->name == name) - return true; /* already stored */ - c = c->hashlink; - } - - /* check if the name is a valid classname */ - - if (!is_valid_name(name->text,UTF_END(name))) { - exceptions_throw_classformaterror(pool->referer, "Invalid class name"); - return false; /* exception */ - } - - /* XXX check maximum array dimension */ - - c = DNEW(classref_hash_entry); - c->name = name; - c->index = pool->classrefhash.entries++; - c->hashlink = (classref_hash_entry *) pool->classrefhash.ptr[slot]; - pool->classrefhash.ptr[slot] = c; - - return true; -} - - -/* descriptor_pool_add ********************************************************* - - Check the given descriptor and add it to the pool - - IN: - pool.............the descriptor_pool - desc.............the descriptor to add. Maybe a field or method desc. - - OUT: - *paramslots......if non-NULL, set to the number of parameters. - LONG and DOUBLE are counted twice - - RETURN VALUE: - true.............descriptor has been added - false............an exception has been thrown - -*******************************************************************************/ - -bool -descriptor_pool_add(descriptor_pool *pool, utf *desc, int *paramslots) -{ - u4 key,slot; - descriptor_hash_entry *d; - char *utf_ptr; - char *end_pos; - utf *name; - s4 argcount = 0; - -#ifdef DESCRIPTOR_VERBOSE - fprintf(stderr,"descriptor_pool_add(%p,",(void*)pool); - utf_fprint_printable_ascii(stderr,desc);fprintf(stderr,")\n"); -#endif - - assert(pool); - assert(desc); - - /* find a place in the hashtable */ - - key = utf_hashkey(desc->text, desc->blength); - slot = key & (pool->descriptorhash.size - 1); - d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; - - /* Save all method descriptors in the hashtable, since the parsed */ - /* descriptor may vary between differenf methods (static vs. non-static). */ - - utf_ptr = desc->text; - - if (*utf_ptr != '(') { - while (d) { - if (d->desc == desc) { - if (paramslots) - *paramslots = d->paramslots; - return true; /* already stored */ - } - d = d->hashlink; - } - } - - /* add the descriptor to the pool */ - - d = DNEW(descriptor_hash_entry); - d->desc = desc; - d->parseddesc.any = NULL; - d->hashlink = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; - pool->descriptorhash.ptr[slot] = d; - - /* now check the descriptor */ - - end_pos = UTF_END(desc); - - if (*utf_ptr == '(') { - /* a method descriptor */ - - pool->methodcount++; - utf_ptr++; - - /* check arguments */ - - while ((utf_ptr != end_pos) && (*utf_ptr != ')')) { - pool->paramcount++; - - /* We cannot count the `this' argument here because - * we don't know if the method is static. */ - - if (*utf_ptr == 'J' || *utf_ptr == 'D') - argcount += 2; - else - argcount++; - - if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, &utf_ptr, - DESCRIPTOR_NOVOID, &name)) - return false; - - if (name) - if (!descriptor_pool_add_class(pool, name)) - return false; - } - - if (utf_ptr == end_pos) { - exceptions_throw_classformaterror(pool->referer, - "Missing ')' in method descriptor"); - return false; - } - - utf_ptr++; /* skip ')' */ - - if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL, - DESCRIPTOR_CHECKEND, &name)) - return false; - - if (name) - if (!descriptor_pool_add_class(pool,name)) - return false; - - if (argcount > 255) { - exceptions_throw_classformaterror(pool->referer, - "Too many arguments in signature"); - return false; - } - - } else { - /* a field descriptor */ - - pool->fieldcount++; - - if (!name_from_descriptor(pool->referer, utf_ptr, end_pos, NULL, - DESCRIPTOR_NOVOID | DESCRIPTOR_CHECKEND, - &name)) - return false; - - if (name) - if (!descriptor_pool_add_class(pool,name)) - return false; - } - - d->paramslots = argcount; - - if (paramslots) - *paramslots = argcount; - - return true; -} - - -/* descriptor_pool_create_classrefs ******************************************** - - Create a table containing all the classrefs which were added to the pool - - IN: - pool.............the descriptor_pool - - OUT: - *count...........if count is non-NULL, this is set to the number - of classrefs in the table - - RETURN VALUE: - a pointer to the constant_classref table - -*******************************************************************************/ - -constant_classref * -descriptor_pool_create_classrefs(descriptor_pool *pool, s4 *count) -{ - u4 nclasses; - u4 slot; - classref_hash_entry *c; - constant_classref *ref; - - assert(pool); - - nclasses = pool->classrefhash.entries; - pool->classrefs = MNEW(constant_classref,nclasses); - - /* fill the constant_classref structs */ - - for (slot = 0; slot < pool->classrefhash.size; ++slot) { - c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; - while (c) { - ref = pool->classrefs + c->index; - CLASSREF_INIT(*ref, pool->referer, c->name); - c = c->hashlink; - } - } - - if (count) - *count = nclasses; - - return pool->classrefs; -} - - -/* descriptor_pool_lookup_classref ********************************************* - - Return the constant_classref for the given class name - - IN: - pool.............the descriptor_pool - classname........name of the class to look up - - RETURN VALUE: - a pointer to the constant_classref, or - NULL if an exception has been thrown - -*******************************************************************************/ - -constant_classref * -descriptor_pool_lookup_classref(descriptor_pool *pool, utf *classname) -{ - u4 key,slot; - classref_hash_entry *c; - - assert(pool); - assert(pool->classrefs); - assert(classname); - - key = utf_hashkey(classname->text, classname->blength); - slot = key & (pool->classrefhash.size - 1); - c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; - - while (c) { - if (c->name == classname) - return pool->classrefs + c->index; - c = c->hashlink; - } - - exceptions_throw_internalerror("Class reference not found in descriptor pool"); - return NULL; -} - - -/* descriptor_pool_alloc_parsed_descriptors ************************************ - - Allocate space for the parsed descriptors - - IN: - pool.............the descriptor_pool - - NOTE: - This function must be called after all descriptors have been added - with descriptor_pool_add. - -*******************************************************************************/ - -void -descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool) -{ - u4 size; - - assert(pool); - - /* TWISTI: paramcount + 1: we don't know if the method is static or */ - /* not, i have no better solution yet. */ - - size = - pool->fieldcount * sizeof(typedesc) + - pool->methodcount * (sizeof(methoddesc) - sizeof(typedesc)) + - pool->paramcount * sizeof(typedesc) + - pool->methodcount * sizeof(typedesc); /* possible `this' pointer */ - - pool->descriptorsize = size; - if (size) { - pool->descriptors = MNEW(u1, size); - pool->descriptors_next = pool->descriptors; - } - - size = pool->fieldcount + pool->methodcount; - if (size) { - pool->descriptor_kind = DMNEW(u1, size); - pool->descriptor_kind_next = pool->descriptor_kind; - } -} - - -/* descriptor_pool_parse_field_descriptor ************************************** - - Parse the given field descriptor - - IN: - pool.............the descriptor_pool - desc.............the field descriptor - - RETURN VALUE: - a pointer to the parsed field descriptor, or - NULL if an exception has been thrown - - NOTE: - descriptor_pool_alloc_parsed_descriptors must be called (once) - before this function is used. - -*******************************************************************************/ - -typedesc * -descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc) -{ - u4 key,slot; - descriptor_hash_entry *d; - typedesc *td; - - assert(pool); - assert(pool->descriptors); - assert(pool->descriptors_next); - - /* lookup the descriptor in the hashtable */ - - key = utf_hashkey(desc->text, desc->blength); - slot = key & (pool->descriptorhash.size - 1); - d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; - - while (d) { - if (d->desc == desc) { - /* found */ - if (d->parseddesc.fd) - return d->parseddesc.fd; - break; - } - d = d->hashlink; - } - - assert(d); - - if (desc->text[0] == '(') { - exceptions_throw_classformaterror(pool->referer, - "Method descriptor used in field reference"); - return NULL; - } - - td = (typedesc *) pool->descriptors_next; - pool->descriptors_next += sizeof(typedesc); - - if (!descriptor_to_typedesc(pool, desc->text, UTF_END(desc), NULL, td)) - return NULL; - - *(pool->descriptor_kind_next++) = 'f'; - - d->parseddesc.fd = td; - - return td; -} - - -/* descriptor_pool_parse_method_descriptor ************************************* - - Parse the given method descriptor - - IN: - pool.............the descriptor_pool - desc.............the method descriptor - mflags...........the method flags - thisclass........classref to the class containing the method. - This is ignored if mflags contains ACC_STATIC. - The classref is stored for inserting the 'this' argument. - - RETURN VALUE: - a pointer to the parsed method descriptor, or - NULL if an exception has been thrown - - NOTE: - descriptor_pool_alloc_parsed_descriptors must be called - (once) before this function is used. - -*******************************************************************************/ - -methoddesc * -descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc, - s4 mflags,constant_classref *thisclass) -{ - u4 key, slot; - descriptor_hash_entry *d; - methoddesc *md; - typedesc *td; - char *utf_ptr; - char *end_pos; - s2 paramcount = 0; - s2 paramslots = 0; - -#ifdef DESCRIPTOR_VERBOSE - fprintf(stderr,"descriptor_pool_parse_method_descriptor(%p,%d,%p,", - (void*)pool,(int)mflags,(void*)thisclass); - utf_fprint_printable_ascii(stderr,desc); fprintf(stderr,")\n"); -#endif - - assert(pool); - assert(pool->descriptors); - assert(pool->descriptors_next); - - /* check that it is a method descriptor */ - - if (desc->text[0] != '(') { - exceptions_throw_classformaterror(pool->referer, - "Field descriptor used in method reference"); - return NULL; - } - - /* lookup the descriptor in the hashtable */ - - key = utf_hashkey(desc->text, desc->blength); - slot = key & (pool->descriptorhash.size - 1); - d = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; - - /* find an un-parsed descriptor */ - - while (d) { - if (d->desc == desc) - if (!d->parseddesc.md) - break; - d = d->hashlink; - } - - assert(d); - - md = (methoddesc *) pool->descriptors_next; - pool->descriptors_next += sizeof(methoddesc) - sizeof(typedesc); - - utf_ptr = desc->text + 1; /* skip '(' */ - end_pos = UTF_END(desc); - - td = md->paramtypes; - - /* count the `this' pointer */ - - if ((mflags != ACC_UNDEF) && !(mflags & ACC_STATIC)) { - td->type = TYPE_ADR; - td->decltype = TYPE_ADR; - td->arraydim = 0; - td->classref = thisclass; - - td++; - pool->descriptors_next += sizeof(typedesc); - paramcount++; - paramslots++; - } - - while (*utf_ptr != ')') { - /* parse a parameter type */ - - if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, &utf_ptr, td)) - return NULL; - - if (IS_2_WORD_TYPE(td->type)) - paramslots++; - - td++; - pool->descriptors_next += sizeof(typedesc); - paramcount++; - paramslots++; - } - utf_ptr++; /* skip ')' */ - - /* Skip possible `this' pointer in paramtypes array to allow a possible */ - /* memory move later in parse. */ - /* We store the thisclass reference, so we can later correctly fill in */ - /* the parameter slot of the 'this' argument. */ - - if (mflags == ACC_UNDEF) { - td->classref = thisclass; - td++; - pool->descriptors_next += sizeof(typedesc); - } - - /* parse return type */ - - if (!descriptor_to_typedesc(pool, utf_ptr, end_pos, NULL, - &(md->returntype))) - return NULL; - - md->paramcount = paramcount; - md->paramslots = paramslots; - - /* If mflags != ACC_UNDEF we parse a real loaded method, so do - param prealloc. Otherwise we do this in stack analysis. */ - - if (mflags != ACC_UNDEF) { - if (md->paramcount > 0) { - /* allocate memory for params */ - - md->params = MNEW(paramdesc, md->paramcount); - } - else { - md->params = METHODDESC_NOPARAMS; - } - - /* fill the paramdesc */ - /* md_param_alloc has to be called if md->paramcount == 0, - too, so it can make the reservation for the Linkage Area, - Return Register... */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) -# endif - { - /* As builtin-functions are native functions, we have - to pre-allocate for the native ABI. */ - - if (mflags & ACC_METHOD_BUILTIN) - md_param_alloc_native(md); - else - md_param_alloc(md); - } -#endif - } - else { - /* params will be allocated later by - descriptor_params_from_paramtypes if necessary */ - - md->params = NULL; - } - - *(pool->descriptor_kind_next++) = 'm'; - - d->parseddesc.md = md; - - return md; -} - -/* descriptor_params_from_paramtypes ******************************************* - - Create the paramdescs for a method descriptor. This function is called - when we know whether the method is static or not. This function may only - be called once for each methoddesc, and only if md->params == NULL. - - IN: - md...............the parsed method descriptor - md->params MUST be NULL. - mflags...........the ACC_* access flags of the method. Only the - ACC_STATIC bit is checked. - The value ACC_UNDEF is NOT allowed. - - RETURN VALUE: - true.............the paramdescs were created successfully - false............an exception has been thrown - - POSTCONDITION: - md->parms != NULL - -*******************************************************************************/ - -bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags) -{ - typedesc *td; - - assert(md); - assert(md->params == NULL); - assert(mflags != ACC_UNDEF); - - td = md->paramtypes; - - /* check for `this' pointer */ - - if (!(mflags & ACC_STATIC)) { - constant_classref *thisclass; - - /* fetch class reference from reserved param slot */ - thisclass = td[md->paramcount].classref; - assert(thisclass); - - if (md->paramcount > 0) { - /* shift param types by 1 argument */ - MMOVE(td + 1, td, typedesc, md->paramcount); - } - - /* fill in first argument `this' */ - - td->type = TYPE_ADR; - td->decltype = TYPE_ADR; - td->arraydim = 0; - td->classref = thisclass; - - md->paramcount++; - md->paramslots++; - } - - /* if the method has params, process them */ - - if (md->paramcount > 0) { - /* allocate memory for params */ - - md->params = MNEW(paramdesc, md->paramcount); - - } else { - md->params = METHODDESC_NOPARAMS; - } - - /* fill the paramdesc */ - /* md_param_alloc has to be called if md->paramcount == 0, too, so - it can make the reservation for the Linkage Area, Return - Register.. */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (!opt_intrp) -# endif - { - /* As builtin-functions are native functions, we have to - pre-allocate for the native ABI. */ - - if (mflags & ACC_METHOD_BUILTIN) - md_param_alloc_native(md); - else - md_param_alloc(md); - } -#endif - - return true; -} - - -/* descriptor_pool_get_parsed_descriptors ************************************** - - Return a pointer to the block of parsed descriptors - - IN: - pool.............the descriptor_pool - - OUT: - *size............if size is non-NULL, this is set to the size of the - parsed descriptor block (in u1) - - RETURN VALUE: - a pointer to the block of parsed descriptors - - NOTE: - descriptor_pool_alloc_parsed_descriptors must be called (once) - before this function is used. - -*******************************************************************************/ - -void * -descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size) -{ - assert(pool); - assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors); - - if (size) - *size = pool->descriptorsize; - - return pool->descriptors; -} - - -/* descriptor_pool_get_sizes *************************************************** - - Get the sizes of the class reference table and the parsed descriptors - - IN: - pool.............the descriptor_pool - - OUT: - *classrefsize....set to size of the class reference table - *descsize........set to size of the parsed descriptors - - NOTE: - This function may only be called after both - descriptor_pool_create_classrefs, and - descriptor_pool_alloc_parsed_descriptors - have been called. - -*******************************************************************************/ - -void -descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize, u4 *descsize) -{ - assert(pool); - assert((!pool->fieldcount && !pool->methodcount) || pool->descriptors); - assert(pool->classrefs); - assert(classrefsize); - assert(descsize); - - *classrefsize = pool->classrefhash.entries * sizeof(constant_classref); - *descsize = pool->descriptorsize; -} - - -/****************************************************************************/ -/* DEBUG HELPERS */ -/****************************************************************************/ - -#ifndef NDEBUG -/* descriptor_debug_print_typedesc ********************************************* - - Print the given typedesc to the given stream - - IN: - file.............stream to print to - d................the parsed descriptor - -*******************************************************************************/ - -void -descriptor_debug_print_typedesc(FILE *file,typedesc *d) -{ - int ch; - - if (!d) { - fprintf(file,"(typedesc *)NULL"); - return; - } - - if (d->type == TYPE_ADR) { - if (d->classref) - utf_fprint_printable_ascii(file,d->classref->name); - else - fprintf(file,""); - } - else { - switch (d->decltype) { - case PRIMITIVETYPE_INT : ch='I'; break; - case PRIMITIVETYPE_CHAR : ch='C'; break; - case PRIMITIVETYPE_BYTE : ch='B'; break; - case PRIMITIVETYPE_SHORT : ch='S'; break; - case PRIMITIVETYPE_BOOLEAN: ch='Z'; break; - case PRIMITIVETYPE_LONG : ch='J'; break; - case PRIMITIVETYPE_FLOAT : ch='F'; break; - case PRIMITIVETYPE_DOUBLE : ch='D'; break; - case PRIMITIVETYPE_VOID : ch='V'; break; - default : ch='!'; - } - fputc(ch,file); - } - if (d->arraydim) - fprintf(file,"[%d]",d->arraydim); -} - -/* descriptor_debug_print_paramdesc ******************************************** - - Print the given paramdesc to the given stream - - IN: - file.............stream to print to - d................the parameter descriptor - -*******************************************************************************/ - -void -descriptor_debug_print_paramdesc(FILE *file,paramdesc *d) -{ - if (!d) { - fprintf(file,"(paramdesc *)NULL"); - return; - } - - if (d->inmemory) { - fprintf(file,"",d->regoff); - } - else { - fprintf(file,"",d->regoff); - } -} - -/* descriptor_debug_print_methoddesc ******************************************* - - Print the given methoddesc to the given stream - - IN: - file.............stream to print to - d................the parsed descriptor - -*******************************************************************************/ - -void -descriptor_debug_print_methoddesc(FILE *file,methoddesc *d) -{ - int i; - - if (!d) { - fprintf(file,"(methoddesc *)NULL"); - return; - } - - fputc('(',file); - for (i=0; iparamcount; ++i) { - if (i) - fputc(',',file); - descriptor_debug_print_typedesc(file,d->paramtypes + i); - if (d->params) { - descriptor_debug_print_paramdesc(file,d->params + i); - } - } - if (d->params == METHODDESC_NOPARAMS) - fputs("",file); - fputc(')',file); - descriptor_debug_print_typedesc(file,&(d->returntype)); -} - -/* descriptor_pool_debug_dump ************************************************** - - Print the state of the descriptor_pool to the given stream - - IN: - pool.............the descriptor_pool - file.............stream to print to - -*******************************************************************************/ - -void -descriptor_pool_debug_dump(descriptor_pool *pool,FILE *file) -{ - u4 slot; - u1 *pos; - u1 *kind; - u4 size; - - fprintf(file,"======[descriptor_pool for "); - utf_fprint_printable_ascii(file,pool->referer->name); - fprintf(file,"]======\n"); - - fprintf(file,"fieldcount: %d\n",pool->fieldcount); - fprintf(file,"methodcount: %d\n",pool->methodcount); - fprintf(file,"paramcount: %d\n",pool->paramcount); - fprintf(file,"classrefcount: %d\n",pool->classrefhash.entries); - fprintf(file,"descriptorsize: %d bytes\n",pool->descriptorsize); - fprintf(file,"classrefsize: %d bytes\n", - (int)(pool->classrefhash.entries * sizeof(constant_classref))); - - fprintf(file,"class references:\n"); - for (slot=0; slotclassrefhash.size; ++slot) { - classref_hash_entry *c = (classref_hash_entry *) pool->classrefhash.ptr[slot]; - while (c) { - fprintf(file," %4d: ",c->index); - utf_fprint_printable_ascii(file,c->name); - fprintf(file,"\n"); - c = c->hashlink; - } - } - - fprintf(file,"hashed descriptors:\n"); - for (slot=0; slotdescriptorhash.size; ++slot) { - descriptor_hash_entry *c = (descriptor_hash_entry *) pool->descriptorhash.ptr[slot]; - while (c) { - fprintf(file," %p: ",c->parseddesc.any); - utf_fprint_printable_ascii(file,c->desc); - fprintf(file,"\n"); - c = c->hashlink; - } - } - - fprintf(file,"descriptors:\n"); - if (pool->descriptors) { - pos = pool->descriptors; - size = pool->descriptors_next - pool->descriptors; - fprintf(file," size: %d bytes\n",size); - - if (pool->descriptor_kind) { - kind = pool->descriptor_kind; - - while (pos < (pool->descriptors + size)) { - fprintf(file," %p: ",pos); - switch (*kind++) { - case 'f': - descriptor_debug_print_typedesc(file,(typedesc*)pos); - pos += sizeof(typedesc); - break; - case 'm': - descriptor_debug_print_methoddesc(file,(methoddesc*)pos); - pos += ((methoddesc*)pos)->paramcount * sizeof(typedesc); - pos += sizeof(methoddesc) - sizeof(typedesc); - break; - default: - fprintf(file,"INVALID KIND"); - } - fputc('\n',file); - } - } - else { - while (size >= sizeof(voidptr)) { - fprintf(file," %p\n",*((voidptr*)pos)); - pos += sizeof(voidptr); - size -= sizeof(voidptr); - } - } - } - - fprintf(file,"==========================================================\n"); -} -#endif /* !defined(NDEBUG) */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ - diff --git a/src/vmcore/descriptor.h b/src/vmcore/descriptor.h deleted file mode 100644 index dae43e721..000000000 --- a/src/vmcore/descriptor.h +++ /dev/null @@ -1,202 +0,0 @@ -/* src/vmcore/descriptor.h - checking and parsing of field / method descriptors - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _DESCRIPTOR_H -#define _DESCRIPTOR_H - -/* forward typedefs ***********************************************************/ - -typedef struct descriptor_pool descriptor_pool; -typedef struct typedesc typedesc; -typedef struct paramdesc paramdesc; -typedef struct methoddesc methoddesc; - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "toolbox/hashtable.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/references.h" -#include "vmcore/utf8.h" - -#include "arch.h" /* needed for HAS_ADDRESS_REGISTER_FILE */ - -/* data structures ************************************************************/ - -/*----------------------------------------------------------------------------*/ -/* Descriptor Pools */ -/* */ -/* A descriptor_pool is a temporary data structure used during loading of */ -/* a class. The descriptor_pool is used to allocate the table of */ -/* constant_classrefs the class uses, and for parsing the field and method */ -/* descriptors which occurr within the class. The inner workings of */ -/* descriptor_pool are not important for outside code. */ -/* */ -/* You use a descriptor_pool as follows: */ -/* */ -/* 1. create one with descriptor_pool_new */ -/* 2. add all explicit class references with descriptor_pool_add_class */ -/* 3. add all field/method descriptors with descriptor_pool_add */ -/* 4. call descriptor_pool_create_classrefs */ -/* You can now lookup classrefs with descriptor_pool_lookup_classref */ -/* 5. call descriptor_pool_alloc_parsed_descriptors */ -/* 6. for each field descriptor call descriptor_pool_parse_field_descriptor */ -/* for each method descriptor call descriptor_pool_parse_method_descriptor */ -/* 7. call descriptor_pool_get_parsed_descriptors */ -/* */ -/* IMPORTANT: The descriptor_pool functions use DNEW and DMNEW for allocating */ -/* memory which can be thrown away when the steps above have been */ -/* done. */ -/*----------------------------------------------------------------------------*/ - -struct descriptor_pool { - classinfo *referer; - u4 fieldcount; - u4 methodcount; - u4 paramcount; - u4 descriptorsize; - u1 *descriptors; - u1 *descriptors_next; - hashtable descriptorhash; - constant_classref *classrefs; - hashtable classrefhash; - u1 *descriptor_kind; /* useful for debugging */ - u1 *descriptor_kind_next; /* useful for debugging */ -}; - - -/* data structures for parsed field/method descriptors ************************/ - -struct typedesc { - constant_classref *classref; /* class reference for TYPE_ADR types */ - u1 type; /* TYPE_??? constant [1] */ - u1 decltype; /* (PRIMITIVE)TYPE_??? constant [2] */ - u1 arraydim; /* array dimension (0 if no array) */ -}; - -/* [1]...the type field contains the basic type used within the VM. So ints, */ -/* shorts, chars, bytes, booleans all have TYPE_INT. */ -/* [2]...the decltype field contains the declared type. */ -/* So short is PRIMITIVETYPE_SHORT, char is PRIMITIVETYPE_CHAR. */ -/* For non-primitive types decltype is TYPE_ADR. */ - -struct paramdesc { -#if defined(__MIPS__) - u1 type; /* TYPE_??? of the register allocated */ -#endif - bool inmemory; /* argument in register or on stack */ - uint32_t index; /* index into argument register array */ - uint32_t regoff; /* register index or stack offset */ -}; - -struct methoddesc { - s2 paramcount; /* number of parameters */ - s2 paramslots; /* like above but LONG,DOUBLE count twice */ - s4 argintreguse; /* number of used integer argument registers */ - s4 argfltreguse; /* number of used float argument registers */ -#if defined(HAS_ADDRESS_REGISTER_FILE) - s4 argadrreguse; /* number of used address registers */ -#endif - s4 memuse; /* number of stack slots used */ - paramdesc *params; /* allocated parameter descriptions [3] */ - typedesc returntype; /* parsed descriptor of the return type */ - typedesc paramtypes[1]; /* parameter types, variable length! */ -}; - -/* [3]...If params is NULL, the parameter descriptions have not yet been */ -/* allocated. In this case ___the possible 'this' pointer of the method */ -/* is NOT counted in paramcount/paramslots and it is NOT included in */ -/* the paramtypes array___. */ -/* If params != NULL, the parameter descriptions have been */ -/* allocated, and the 'this' pointer of the method, if any, IS included.*/ -/* In case the method has no parameters at all, the special value */ -/* METHODDESC_NO_PARAMS is used (see below). */ - -/* METHODDESC_NO_PARAMS is a special value for the methoddesc.params field */ -/* indicating that the method is a static method without any parameters. */ -/* This special value must be != NULL and it may only be set if */ -/* md->paramcount == 0. */ - -#define METHODDESC_NOPARAMS ((paramdesc*)1) - -/* function prototypes ********************************************************/ - -descriptor_pool * descriptor_pool_new(classinfo *referer); - -bool descriptor_pool_add_class(descriptor_pool *pool,utf *name); -bool descriptor_pool_add(descriptor_pool *pool,utf *desc,int *paramslots); - -int descriptor_to_basic_type(utf *desc); -int descriptor_typesize(typedesc *td); - -constant_classref * descriptor_pool_create_classrefs(descriptor_pool *pool, - s4 *count); -constant_classref * descriptor_pool_lookup_classref(descriptor_pool *pool,utf *classname); - -void descriptor_pool_alloc_parsed_descriptors(descriptor_pool *pool); - -typedesc *descriptor_pool_parse_field_descriptor(descriptor_pool *pool, utf *desc); -methoddesc *descriptor_pool_parse_method_descriptor(descriptor_pool *pool, utf *desc, s4 mflags, - constant_classref *thisclass); - -bool descriptor_params_from_paramtypes(methoddesc *md, s4 mflags); - -void *descriptor_pool_get_parsed_descriptors(descriptor_pool *pool, s4 *size); -void descriptor_pool_get_sizes(descriptor_pool *pool, u4 *classrefsize, - u4 *descsize); - -#ifndef NDEBUG -void descriptor_debug_print_typedesc(FILE *file,typedesc *d); -void descriptor_debug_print_methoddesc(FILE *file,methoddesc *d); -void descriptor_debug_print_paramdesc(FILE *file,paramdesc *d); -void descriptor_pool_debug_dump(descriptor_pool *pool, FILE *file); -#endif /* !defined(NDEBUG) */ - -#endif /* _DESCRIPTOR_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/field.c b/src/vmcore/field.c deleted file mode 100644 index 00c0680e9..000000000 --- a/src/vmcore/field.c +++ /dev/null @@ -1,562 +0,0 @@ -/* src/vmcore/field.c - field functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "mm/memory.h" - -#include "native/llni.h" - -#include "vm/types.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vmcore/annotation.h" -#include "vmcore/class.h" -#include "vmcore/descriptor.h" -#include "vmcore/field.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/references.h" -#include "vmcore/suck.h" -#include "vmcore/utf8.h" - - -/* field_load ****************************************************************** - - Load everything about a class field from the class file and fill a - fieldinfo structure. - -*******************************************************************************/ - -#define field_load_NOVALUE 0xffffffff /* must be bigger than any u2 value! */ - -bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool) -{ - classinfo *c; - u4 attrnum, i; - u4 pindex = field_load_NOVALUE; /* constantvalue_index */ - utf *u; - - /* Get class. */ - - c = cb->clazz; - - f->clazz = c; - - /* Get access flags. */ - - if (!suck_check_classbuffer_size(cb, 2 + 2 + 2)) - return false; - - f->flags = suck_u2(cb); - - /* Get name. */ - - if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) - return false; - - f->name = u; - - /* Get descriptor. */ - - if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) - return false; - - f->descriptor = u; - f->parseddesc = NULL; - - if (!descriptor_pool_add(descpool, u, NULL)) - return false; - - /* descriptor_pool_add accepts method descriptors, so we have to - check against them here before the call of - descriptor_to_basic_type below. */ - - if (u->text[0] == '(') { - exceptions_throw_classformaterror(c, "Method descriptor used for field"); - return false; - } - -#ifdef ENABLE_VERIFIER - if (opt_verify) { - /* check name */ - if (!is_valid_name_utf(f->name) || f->name->text[0] == '<') { - exceptions_throw_classformaterror(c, - "Illegal Field name \"%s\"", - f->name->text); - return false; - } - - /* check flag consistency */ - i = f->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED); - - if ((i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) || - ((f->flags & (ACC_FINAL | ACC_VOLATILE)) == (ACC_FINAL | ACC_VOLATILE))) { - exceptions_throw_classformaterror(c, - "Illegal field modifiers: 0x%X", - f->flags); - return false; - } - - if (c->flags & ACC_INTERFACE) { - if (((f->flags & (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) - != (ACC_STATIC | ACC_PUBLIC | ACC_FINAL)) || - f->flags & ACC_TRANSIENT) { - exceptions_throw_classformaterror(c, - "Illegal field modifiers: 0x%X", - f->flags); - return false; - } - } - } -#endif /* ENABLE_VERIFIER */ - - /* data type */ - - f->type = descriptor_to_basic_type(f->descriptor); - - /* For static-fields allocate memory for the value and set the - value to 0. */ - - if (f->flags & ACC_STATIC) { - switch (f->type) { - case TYPE_INT: - case TYPE_LNG: - case TYPE_FLT: - case TYPE_DBL: - f->value = NEW(imm_union); - break; - - case TYPE_ADR: -#if !defined(ENABLE_GC_BOEHM) - f->value = NEW(imm_union); -#else - f->value = GCNEW_UNCOLLECTABLE(imm_union, 1); -#endif - break; - - default: - vm_abort("field_load: invalid field type %d", f->type); - } - - /* Set the field to zero, for float and double fields set the - correct 0.0 value. */ - - switch (f->type) { - case TYPE_INT: - case TYPE_LNG: - case TYPE_ADR: - f->value->l = 0; - break; - - case TYPE_FLT: - f->value->f = 0.0; - break; - - case TYPE_DBL: - f->value->d = 0.0; - break; - } - } - else { - /* For instance-fields set the offset to 0. */ - - f->offset = 0; - - /* For final fields, which are not static, we need a value - structure. */ - - if (f->flags & ACC_FINAL) { - f->value = NEW(imm_union); - /* XXX hack */ - f->value->l = 0; - } - - switch (f->type) { - case TYPE_ADR: - c->flags |= ACC_CLASS_HAS_POINTERS; - break; - } - } - - /* read attributes */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - attrnum = suck_u2(cb); - - for (i = 0; i < attrnum; i++) { - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - if (!(u = class_getconstant(c, suck_u2(cb), CONSTANT_Utf8))) - return false; - - if (u == utf_ConstantValue) { - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* check attribute length */ - - if (suck_u4(cb) != 2) { - exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); - return false; - } - - /* constant value attribute */ - - if (pindex != field_load_NOVALUE) { - exceptions_throw_classformaterror(c, "Multiple ConstantValue attributes"); - return false; - } - - /* index of value in constantpool */ - - pindex = suck_u2(cb); - - /* initialize field with value from constantpool */ - - switch (f->type) { - case TYPE_INT: { - constant_integer *ci; - - if (!(ci = class_getconstant(c, pindex, CONSTANT_Integer))) - return false; - - f->value->i = ci->value; - } - break; - - case TYPE_LNG: { - constant_long *cl; - - if (!(cl = class_getconstant(c, pindex, CONSTANT_Long))) - return false; - - f->value->l = cl->value; - } - break; - - case TYPE_FLT: { - constant_float *cf; - - if (!(cf = class_getconstant(c, pindex, CONSTANT_Float))) - return false; - - f->value->f = cf->value; - } - break; - - case TYPE_DBL: { - constant_double *cd; - - if (!(cd = class_getconstant(c, pindex, CONSTANT_Double))) - return false; - - f->value->d = cd->value; - } - break; - - case TYPE_ADR: - if (!(u = class_getconstant(c, pindex, CONSTANT_String))) - return false; - - /* Create Java-string from compressed UTF8-string. */ - - f->value->a = literalstring_new(u); - break; - - default: - vm_abort("field_load: invalid field type %d", f->type); - } - } -#if defined(ENABLE_JAVASE) - else if (u == utf_Signature) { - /* Signature */ - - if (!loader_load_attribute_signature(cb, &(f->signature))) - return false; - } - -#if defined(ENABLE_ANNOTATIONS) - else if (u == utf_RuntimeVisibleAnnotations) { - /* RuntimeVisibleAnnotations */ - if (!annotation_load_field_attribute_runtimevisibleannotations(cb, f)) - return false; - } - else if (u == utf_RuntimeInvisibleAnnotations) { - /* RuntimeInvisibleAnnotations */ - if (!annotation_load_field_attribute_runtimeinvisibleannotations(cb, f)) - return false; - } -#endif -#endif - else { - /* unknown attribute */ - - if (!loader_skip_attribute_body(cb)) - return false; - } - } - - /* everything was ok */ - - return true; -} - - -/* field_get_type ************************************************************** - - Returns the type of the field as class. - -*******************************************************************************/ - -classinfo *field_get_type(fieldinfo *f) -{ - typedesc *td; - utf *u; - classinfo *c; - - td = f->parseddesc; - - if (td->type == TYPE_ADR) { - assert(td->classref); - - u = td->classref->name; - - /* load the class of the field-type with the field's - classloader */ - - c = load_class_from_classloader(u, f->clazz->classloader); - } - else { - c = primitive_class_get_by_type(td->decltype); - } - - return c; -} - - -/* field_free ****************************************************************** - - Frees a fields' resources. - -*******************************************************************************/ - -void field_free(fieldinfo *f) -{ - /* free memory for fields which have a value */ - - if (f->value) -#if defined(ENABLE_GC_BOEHM) - if (f->type != TYPE_ADR) -#endif - FREE(f->value, imm_union); -} - - -/* field_get_annotations ****************************************************** - - Get a fields' unparsed annotations in a byte array. - - IN: - f........the field of which the annotations should be returned - - RETURN VALUE: - The unparsed annotations in a byte array (or NULL if there aren't any). - -*******************************************************************************/ - -java_handle_bytearray_t *field_get_annotations(fieldinfo *f) -{ -#if defined(ENABLE_ANNOTATIONS) - classinfo *c; /* declaring class */ - int slot; /* slot of this field */ - java_handle_bytearray_t *annotations; /* unparsed annotations */ - java_handle_t *field_annotations; /* array of unparsed */ - /* annotations of all fields of the declaring class */ - - c = f->clazz; - slot = f - c->fields; - annotations = NULL; - - LLNI_classinfo_field_get(c, field_annotations, field_annotations); - - /* the field_annotations array might be shorter then the field - * count if the fields above a certain index have no annotations. - */ - if (field_annotations != NULL && - array_length_get(field_annotations) > slot) { - annotations = (java_handle_bytearray_t*)array_objectarray_element_get( - (java_handle_objectarray_t*)field_annotations, slot); - } - - return annotations; -#else - return NULL; -#endif -} - - -/* field_printflags ************************************************************ - - (debugging only) - -*******************************************************************************/ - -#if !defined(NDEBUG) -void field_printflags(fieldinfo *f) -{ - if (f == NULL) { - printf("NULL"); - return; - } - - if (f->flags & ACC_PUBLIC) printf(" PUBLIC"); - if (f->flags & ACC_PRIVATE) printf(" PRIVATE"); - if (f->flags & ACC_PROTECTED) printf(" PROTECTED"); - if (f->flags & ACC_STATIC) printf(" STATIC"); - if (f->flags & ACC_FINAL) printf(" FINAL"); - if (f->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED"); - if (f->flags & ACC_VOLATILE) printf(" VOLATILE"); - if (f->flags & ACC_TRANSIENT) printf(" TRANSIENT"); - if (f->flags & ACC_NATIVE) printf(" NATIVE"); - if (f->flags & ACC_INTERFACE) printf(" INTERFACE"); - if (f->flags & ACC_ABSTRACT) printf(" ABSTRACT"); -} -#endif - - -/* field_print ***************************************************************** - - (debugging only) - -*******************************************************************************/ - -#if !defined(NDEBUG) -void field_print(fieldinfo *f) -{ - if (f == NULL) { - printf("(fieldinfo*)NULL"); - return; - } - - utf_display_printable_ascii_classname(f->clazz->name); - printf("."); - utf_display_printable_ascii(f->name); - printf(" "); - utf_display_printable_ascii(f->descriptor); - - field_printflags(f); - - if (!(f->flags & ACC_STATIC)) { - printf(", offset: %d", f->offset); - } -} -#endif - - -/* field_println *************************************************************** - - (debugging only) - -*******************************************************************************/ - -#if !defined(NDEBUG) -void field_println(fieldinfo *f) -{ - field_print(f); - printf("\n"); -} -#endif - -/* field_fieldref_print ******************************************************** - - (debugging only) - -*******************************************************************************/ - -#if !defined(NDEBUG) -void field_fieldref_print(constant_FMIref *fr) -{ - if (fr == NULL) { - printf("(constant_FMIref *)NULL"); - return; - } - - if (IS_FMIREF_RESOLVED(fr)) { - printf(" "); - field_print(fr->p.field); - } - else { - printf(" "); - utf_display_printable_ascii_classname(fr->p.classref->name); - printf("."); - utf_display_printable_ascii(fr->name); - printf(" "); - utf_display_printable_ascii(fr->descriptor); - } -} -#endif - -/* field_fieldref_println ****************************************************** - - (debugging only) - -*******************************************************************************/ - -#if !defined(NDEBUG) -void field_fieldref_println(constant_FMIref *fr) -{ - field_fieldref_print(fr); - printf("\n"); -} -#endif - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/field.h b/src/vmcore/field.h deleted file mode 100644 index 32c3871c4..000000000 --- a/src/vmcore/field.h +++ /dev/null @@ -1,100 +0,0 @@ -/* src/vmcore/field.h - field functions header - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _FIELD_H -#define _FIELD_H - -/* forward typedefs ***********************************************************/ - -typedef struct fieldinfo fieldinfo; - - -#include "config.h" -#include "vm/types.h" - -#include "vm/global.h" - -#include "vmcore/descriptor.h" -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/references.h" -#include "vmcore/utf8.h" - - -/* fieldinfo ******************************************************************/ - -struct fieldinfo { /* field of a class */ - - /* CAUTION: The first field must be a pointer that is never the same */ - /* value as CLASSREF_PSEUDO_VFTBL! This is used to check whether */ - /* a constant_FMIref has been resolved. */ - - classinfo *clazz; /* needed by typechecker. Could be optimized */ - /* away by using constant_FMIref instead of */ - /* fieldinfo throughout the compiler. */ - - s4 flags; /* ACC flags */ - s4 type; /* basic data type */ - utf *name; /* name of field */ - utf *descriptor;/* JavaVM descriptor string of field */ - utf *signature; /* Signature attribute string */ - typedesc *parseddesc;/* parsed descriptor */ - - int32_t offset; /* offset from start of object (instance variables) */ - imm_union *value; /* storage for static values (class variables) */ -}; - - -/* function prototypes ********************************************************/ - -bool field_load(classbuffer *cb, fieldinfo *f, descriptor_pool *descpool); -classinfo *field_get_type(fieldinfo *f); -void field_free(fieldinfo *f); - -java_handle_bytearray_t *field_get_annotations(fieldinfo *f); - -#if !defined(NDEBUG) -void field_printflags(fieldinfo *f); -void field_print(fieldinfo *f); -void field_println(fieldinfo *f); -void field_fieldref_print(constant_FMIref *fr); -void field_fieldref_println(constant_FMIref *fr); -#endif - -#endif /* _FIELD_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/linker.c b/src/vmcore/linker.c deleted file mode 100644 index 08589bfdb..000000000 --- a/src/vmcore/linker.c +++ /dev/null @@ -1,1431 +0,0 @@ -/* src/vmcore/linker.c - class linker functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/native.h" - -#include "threads/lock-common.h" - -#include "toolbox/logging.h" - -#include "vm/access.h" -#include "vm/array.h" -#include "vm/exceptions.h" -#include "vm/primitive.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit_interface.h" - -#include "vmcore/class.h" -#include "vmcore/classcache.h" -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/rt-timing.h" - - -/* debugging macros ***********************************************************/ - -#if !defined(NDEBUG) -# define TRACELINKCLASS(c) \ - do { \ - if (opt_TraceLinkClass) { \ - log_start(); \ - log_print("[Linking "); \ - class_print((c)); \ - log_print("]"); \ - log_finish(); \ - } \ - } while (0) -#else -# define TRACELINKCLASS(c) -#endif - - -/* #include "vm/resolve.h" */ -/* copied prototype to avoid bootstrapping problem: */ -classinfo *resolve_classref_or_classinfo_eager(classref_or_classinfo cls, bool checkaccess); - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#if !defined(NDEBUG) && defined(ENABLE_INLINING) -#define INLINELOG(code) do { if (opt_TraceInlining) { code } } while (0) -#else -#define INLINELOG(code) -#endif - - -/* global variables ***********************************************************/ - -static s4 interfaceindex; /* sequential numbering of interfaces */ -static s4 classvalue; - - -/* private functions **********************************************************/ - -static classinfo *link_class_intern(classinfo *c); -static arraydescriptor *link_array(classinfo *c); -static void linker_compute_class_values(classinfo *c); -static void linker_compute_subclasses(classinfo *c); -static bool linker_addinterface(classinfo *c, classinfo *ic); -static s4 class_highestinterface(classinfo *c); - - -/* dummy structures for alinment checks ***************************************/ - -typedef struct dummy_alignment_long_t dummy_alignment_long_t; -typedef struct dummy_alignment_double_t dummy_alignment_double_t; - -struct dummy_alignment_long_t { - int32_t i; - int64_t l; -}; - -struct dummy_alignment_double_t { - int32_t i; - double d; -}; - - -/* linker_init ***************************************************************** - - Initializes the linker subsystem and links classes required for the - primitive table. - -*******************************************************************************/ - -void linker_preinit(void) -{ - TRACESUBSYSTEMINITIALIZATION("linker_preinit"); - - /* Check for if alignment for long and double matches what we - assume for the current architecture. */ - -#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) || defined(__M68K__) - /* Define a define here which is later checked when we use this - offset. */ - -# define LINKER_ALIGNMENT_LONG_DOUBLE 4 - - if (OFFSET(dummy_alignment_long_t, l) != 4) - vm_abort("linker_preinit: long alignment is different from what assumed: %d != %d", - OFFSET(dummy_alignment_long_t, l), 4); - - if (OFFSET(dummy_alignment_double_t, d) != 4) - vm_abort("linker_preinit: double alignment is different from what assumed: %d != %d", - OFFSET(dummy_alignment_double_t, d), 4); -#else - -# define LINKER_ALIGNMENT_LONG_DOUBLE 8 - - if (OFFSET(dummy_alignment_long_t, l) != 8) - vm_abort("linker_preinit: long alignment is different from what assumed: %d != %d", - OFFSET(dummy_alignment_long_t, l), 8); - - if (OFFSET(dummy_alignment_double_t, d) != 8) - vm_abort("linker_preinit: double alignment is different from what assumed: %d != %d", - OFFSET(dummy_alignment_double_t, d), 8); -#endif - - /* Reset interface index. */ - - interfaceindex = 0; - - /* Link the most basic classes. */ - - if (!link_class(class_java_lang_Object)) - vm_abort("linker_preinit: linking java/lang/Object failed"); - -#if defined(ENABLE_JAVASE) - if (!link_class(class_java_lang_Cloneable)) - vm_abort("linker_preinit: linking java/lang/Cloneable failed"); - - if (!link_class(class_java_io_Serializable)) - vm_abort("linker_preinit: linking java/io/Serializable failed"); -#endif -} - - -/* linker_init ***************************************************************** - - Links all classes required in the VM. - -*******************************************************************************/ - -void linker_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("linker_init"); - - /* Link java.lang.Class as first class of the system, because we - need it's vftbl for all other classes so we can use a class as - object. */ - - if (!link_class(class_java_lang_Class)) - vm_abort("linker_init: linking java/lang/Class failed"); - - /* Now set the header.vftbl of all classes which were created - before java.lang.Class was linked. */ - - class_postset_header_vftbl(); - - /* Link primitive-type wrapping classes. */ - -#if defined(ENABLE_JAVASE) - if (!link_class(class_java_lang_Void)) - vm_abort("linker_init: linking failed"); -#endif - - if (!link_class(class_java_lang_Boolean)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Byte)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Character)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Short)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Integer)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Long)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Float)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Double)) - vm_abort("linker_init: linking failed"); - - /* Link important system classes. */ - - if (!link_class(class_java_lang_String)) - vm_abort("linker_init: linking java/lang/String failed"); - -#if defined(ENABLE_JAVASE) - if (!link_class(class_java_lang_ClassLoader)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_SecurityManager)) - vm_abort("linker_init: linking failed"); -#endif - - if (!link_class(class_java_lang_System)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_Thread)) - vm_abort("linker_init: linking failed"); - -#if defined(ENABLE_JAVASE) - if (!link_class(class_java_lang_ThreadGroup)) - vm_abort("linker_init: linking failed"); -#endif - - if (!link_class(class_java_lang_Throwable)) - vm_abort("linker_init: linking failed"); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - if (!link_class(class_java_lang_VMSystem)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_VMThread)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_VMThrowable)) - vm_abort("linker_init: linking failed"); -#endif - - /* Important system exceptions. */ - - if (!link_class(class_java_lang_Exception)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_ClassNotFoundException)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_RuntimeException)) - vm_abort("linker_init: linking failed"); - - /* some classes which may be used more often */ - -#if defined(ENABLE_JAVASE) - if (!link_class(class_java_lang_StackTraceElement)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_reflect_Constructor)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_reflect_Field)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_reflect_Method)) - vm_abort("linker_init: linking failed"); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - if (!link_class(class_java_lang_reflect_VMConstructor)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_reflect_VMField)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_lang_reflect_VMMethod)) - vm_abort("linker_init: linking failed"); -# endif - - if (!link_class(class_java_security_PrivilegedAction)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_util_Vector)) - vm_abort("linker_init: linking failed"); - - if (!link_class(class_java_util_HashMap)) - vm_abort("linker_init: linking failed"); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - if (!link_class(class_sun_reflect_MagicAccessorImpl)) - vm_abort("linker_init: linking failed"); -# endif - - if (!link_class(arrayclass_java_lang_Object)) - vm_abort("linker_init: linking failed"); -#endif - - - /* create pseudo classes used by the typechecker */ - - /* pseudo class for Arraystubs (extends java.lang.Object) */ - - pseudo_class_Arraystub = - class_create_classinfo(utf_new_char("$ARRAYSTUB$")); - pseudo_class_Arraystub->state |= CLASS_LOADED; - pseudo_class_Arraystub->super = class_java_lang_Object; - -#if defined(ENABLE_JAVASE) - - pseudo_class_Arraystub->interfacescount = 2; - pseudo_class_Arraystub->interfaces = MNEW(classinfo*, 2); - pseudo_class_Arraystub->interfaces[0] = class_java_lang_Cloneable; - pseudo_class_Arraystub->interfaces[1] = class_java_io_Serializable; - -#elif defined(ENABLE_JAVAME_CLDC1_1) - - pseudo_class_Arraystub->interfacescount = 0; - pseudo_class_Arraystub->interfaces = NULL; - -#else -# error unknown Java configuration -#endif - - if (!classcache_store_unique(pseudo_class_Arraystub)) - vm_abort("linker_init: could not cache pseudo_class_Arraystub"); - - if (!link_class(pseudo_class_Arraystub)) - vm_abort("linker_init: linking pseudo_class_Arraystub failed"); - - /* pseudo class representing the null type */ - - pseudo_class_Null = class_create_classinfo(utf_new_char("$NULL$")); - pseudo_class_Null->state |= CLASS_LOADED; - pseudo_class_Null->super = class_java_lang_Object; - - if (!classcache_store_unique(pseudo_class_Null)) - vm_abort("linker_init: could not cache pseudo_class_Null"); - - if (!link_class(pseudo_class_Null)) - vm_abort("linker_init: linking failed"); - - /* pseudo class representing new uninitialized objects */ - - pseudo_class_New = class_create_classinfo(utf_new_char("$NEW$")); - pseudo_class_New->state |= CLASS_LOADED; - pseudo_class_New->state |= CLASS_LINKED; /* XXX is this allright? */ - pseudo_class_New->super = class_java_lang_Object; - - if (!classcache_store_unique(pseudo_class_New)) - vm_abort("linker_init: could not cache pseudo_class_New"); - - /* Correct vftbl-entries (retarded loading and linking of class - java/lang/String). */ - - stringtable_update(); -} - - -/* link_class ****************************************************************** - - Wrapper function for link_class_intern to ease monitor enter/exit - and exception handling. - -*******************************************************************************/ - -classinfo *link_class(classinfo *c) -{ - classinfo *r; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_end; -#endif - - RT_TIMING_GET_TIME(time_start); - - if (c == NULL) { - exceptions_throw_nullpointerexception(); - return NULL; - } - - LOCK_MONITOR_ENTER(c); - - /* Maybe the class is currently linking or is already linked.*/ - - if ((c->state & CLASS_LINKING) || (c->state & CLASS_LINKED)) { - LOCK_MONITOR_EXIT(c); - - return c; - } - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getcompilingtime) - compilingtime_stop(); - - if (opt_getloadingtime) - loadingtime_start(); -#endif - - /* call the internal function */ - - r = link_class_intern(c); - - /* If return value is NULL, we had a problem and the class is not - linked. */ - - if (r == NULL) - c->state &= ~CLASS_LINKING; - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getloadingtime) - loadingtime_stop(); - - if (opt_getcompilingtime) - compilingtime_start(); -#endif - - LOCK_MONITOR_EXIT(c); - - RT_TIMING_GET_TIME(time_end); - - RT_TIMING_TIME_DIFF(time_start,time_end,RT_TIMING_LINK_TOTAL); - - return r; -} - - -/* linker_overwrite_method ***************************************************** - - Overwrite a method with another one, update method flags and check - assumptions. - - IN: - mg................the general method being overwritten - ms................the overwriting (more specialized) method - wl................worklist where to add invalidated methods - - RETURN VALUE: - true..............everything ok - false.............an exception has been thrown - -*******************************************************************************/ - -static bool linker_overwrite_method(methodinfo *mg, - methodinfo *ms, - method_worklist **wl) -{ - classinfo *cg; - classinfo *cs; - - cg = mg->clazz; - cs = ms->clazz; - - /* overriding a final method is illegal */ - - if (mg->flags & ACC_FINAL) { - exceptions_throw_verifyerror(mg, "Overriding final method"); - return false; - } - - /* method ms overwrites method mg */ - -#if defined(ENABLE_VERIFIER) - /* Add loading constraints (for the more general types of method mg). */ - /* Not for , as it is not invoked virtually. */ - - if ((ms->name != utf_init) - && !classcache_add_constraints_for_params( - cs->classloader, cg->classloader, mg)) - { - return false; - } -#endif - - /* inherit the vftbl index, and record the overwriting */ - - ms->vftblindex = mg->vftblindex; - ms->overwrites = mg; - - /* update flags and check assumptions */ - /* methods are a special case, as they are never dispatched dynamically */ - - if ((ms->flags & ACC_METHOD_IMPLEMENTED) && ms->name != utf_init) { - do { - if (mg->flags & ACC_METHOD_IMPLEMENTED) { - /* this adds another implementation */ - - mg->flags &= ~ACC_METHOD_MONOMORPHIC; - - INLINELOG( printf("becomes polymorphic: "); method_println(mg); ); - - method_break_assumption_monomorphic(mg, wl); - } - else { - /* this is the first implementation */ - - mg->flags |= ACC_METHOD_IMPLEMENTED; - - INLINELOG( printf("becomes implemented: "); method_println(mg); ); - } - - ms = mg; - mg = mg->overwrites; - } while (mg != NULL); - } - - return true; -} - - -/* link_class_intern *********************************************************** - - Tries to link a class. The function calculates the length in bytes - that an instance of this class requires as well as the VTBL for - methods and interface methods. - -*******************************************************************************/ - -static int build_display_inner(classinfo *topc, classinfo *c, int i) -{ - int depth; - if (!c) - return 0; - do { - if (c->vftbl->arraydesc) - { - arraydescriptor *a = c->vftbl->arraydesc; - if (a->elementvftbl && a->elementvftbl->clazz->super) - { - classinfo *cls = a->elementvftbl->clazz->super; - int n; - for (n=0; ndimension; n++) - cls = class_array_of(cls, true); - depth = build_display_inner(topc, cls, i+1); - break; - } - if (a->componentvftbl && a->elementvftbl) - { - depth = build_display_inner(topc, a->componentvftbl->clazz, i+1); - break; - } - } - depth = build_display_inner(topc, c->super, i+1); - } while (false); - if (depth >= DISPLAY_SIZE) - { - if (depth == DISPLAY_SIZE) - { - topc->vftbl->subtype_overflow = malloc(sizeof(void*) * (i+1)); -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_vftbl_len += sizeof(void*) * (i+1); -#endif - } - topc->vftbl->subtype_overflow[depth - DISPLAY_SIZE] = c->vftbl; - return depth + 1; - } - topc->vftbl->subtype_display[depth] = c->vftbl; - return depth + 1; -} - -static void build_display(classinfo *c) -{ - int depth; - int i; - - depth = build_display_inner(c, c, 0) - 1; - c->vftbl->subtype_depth = depth; - if (depth >= DISPLAY_SIZE) - { - c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[DISPLAY_SIZE]); - } - else - { - c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[0]) + sizeof(void*) * depth; - for (i=depth+1; i<=DISPLAY_SIZE; i++) - c->vftbl->subtype_display[i] = NULL; - } -} - -static classinfo *link_class_intern(classinfo *c) -{ - classinfo *super; /* super class */ - classinfo *tc; /* temporary class variable */ - s4 supervftbllength; /* vftbllegnth of super class */ - s4 vftbllength; /* vftbllength of current class */ - s4 interfacetablelength; /* interface table length */ - vftbl_t *v; /* vftbl of current class */ - s4 i; /* interface/method/field counter */ - arraydescriptor *arraydesc; /* descriptor for array classes */ - method_worklist *worklist; /* worklist for recompilation */ -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_resolving, time_compute_vftbl, - time_abstract, time_compute_iftbl, time_fill_vftbl, - time_offsets, time_fill_iftbl, time_finalizer, - time_subclasses; -#endif - - RT_TIMING_GET_TIME(time_start); - - TRACELINKCLASS(c); - - /* the class must be loaded */ - - /* XXX should this be a specific exception? */ - assert(c->state & CLASS_LOADED); - - /* This is check in link_class. */ - - assert(!(c->state & CLASS_LINKED)); - - /* cache the self-reference of this class */ - /* we do this for cases where the defining loader of the class */ - /* has not yet been recorded as an initiating loader for the class */ - /* this is needed so subsequent code can assume that self-refs */ - /* will always resolve lazily */ - /* No need to do it for the bootloader - it is always registered */ - /* as initiating loader for the classes it loads. */ - if (c->classloader) - classcache_store(c->classloader,c,false); - - /* this class is currently linking */ - - c->state |= CLASS_LINKING; - - arraydesc = NULL; - worklist = NULL; - - /* Link the super interfaces. */ - - for (i = 0; i < c->interfacescount; i++) { - tc = c->interfaces[i]; - - if (!(tc->state & CLASS_LINKED)) - if (!link_class(tc)) - return NULL; - } - - /* check super class */ - - super = NULL; - - /* Check for java/lang/Object. */ - - if (c->super == NULL) { - c->index = 0; - c->instancesize = sizeof(java_object_t); - - vftbllength = supervftbllength = 0; - - c->finalizer = NULL; - } - else { - /* Get super class. */ - - super = c->super; - - /* Link the super class if necessary. */ - - if (!(super->state & CLASS_LINKED)) - if (!link_class(super)) - return NULL; - - /* OR the ACC_CLASS_HAS_POINTERS and the ACC_CLASS_REFERENCE_* - flags. */ - - c->flags |= (super->flags & - (ACC_CLASS_HAS_POINTERS | ACC_CLASS_REFERENCE_MASK)); - - /* handle array classes */ - - if (c->name->text[0] == '[') - if (!(arraydesc = link_array(c))) - return NULL; - - if (c->flags & ACC_INTERFACE) - c->index = interfaceindex++; - else - c->index = super->index + 1; - - c->instancesize = super->instancesize; - - vftbllength = supervftbllength = super->vftbl->vftbllength; - - c->finalizer = super->finalizer; - } - RT_TIMING_GET_TIME(time_resolving); - - - /* compute vftbl length */ - - for (i = 0; i < c->methodscount; i++) { - methodinfo *m = &(c->methods[i]); - - if (!(m->flags & ACC_STATIC)) { /* is instance method */ - tc = super; - - while (tc) { - s4 j; - - for (j = 0; j < tc->methodscount; j++) { - if (method_canoverwrite(m, &(tc->methods[j]))) { - if (tc->methods[j].flags & ACC_PRIVATE) - goto notfoundvftblindex; - - /* package-private methods in other packages */ - /* must not be overridden */ - /* (see Java Language Specification 8.4.8.1) */ - if ( !(tc->methods[j].flags & (ACC_PUBLIC | ACC_PROTECTED)) - && !SAME_PACKAGE(c,tc) ) - { - goto notfoundvftblindex; - } - - if (!linker_overwrite_method(&(tc->methods[j]), m, &worklist)) - return NULL; - - goto foundvftblindex; - } - } - - tc = tc->super; - } - - notfoundvftblindex: - m->vftblindex = (vftbllength++); - foundvftblindex: - ; - } - } - RT_TIMING_GET_TIME(time_compute_vftbl); - - - /* Check all interfaces of an abstract class (maybe be an - interface too) for unimplemented methods. Such methods are - called miranda-methods and are marked with the ACC_MIRANDA - flag. VMClass.getDeclaredMethods does not return such - methods. */ - - if (c->flags & ACC_ABSTRACT) { - classinfo *ic; - methodinfo *im; - s4 abstractmethodscount; - s4 j; - s4 k; - - abstractmethodscount = 0; - - /* check all interfaces of the abstract class */ - - for (i = 0; i < c->interfacescount; i++) { - ic = c->interfaces[i]; - - for (j = 0; j < ic->methodscount; j++) { - im = &(ic->methods[j]); - - /* skip `' and `' */ - - if ((im->name == utf_clinit) || (im->name == utf_init)) - continue; - - for (tc = c; tc != NULL; tc = tc->super) { - for (k = 0; k < tc->methodscount; k++) { - if (method_canoverwrite(im, &(tc->methods[k]))) - goto noabstractmethod; - } - } - - abstractmethodscount++; - - noabstractmethod: - ; - } - } - - if (abstractmethodscount > 0) { - methodinfo *am; - - /* reallocate methods memory */ - - c->methods = MREALLOC(c->methods, methodinfo, c->methodscount, - c->methodscount + abstractmethodscount); - - for (i = 0; i < c->interfacescount; i++) { - ic = c->interfaces[i]; - - for (j = 0; j < ic->methodscount; j++) { - im = &(ic->methods[j]); - - /* skip `' and `' */ - - if ((im->name == utf_clinit) || (im->name == utf_init)) - continue; - - for (tc = c; tc != NULL; tc = tc->super) { - for (k = 0; k < tc->methodscount; k++) { - if (method_canoverwrite(im, &(tc->methods[k]))) - goto noabstractmethod2; - } - } - - /* Copy the method found into the new c->methods - array and tag it as miranda-method. */ - - am = &(c->methods[c->methodscount]); - c->methodscount++; - - MCOPY(am, im, methodinfo, 1); - - am->vftblindex = (vftbllength++); - am->clazz = c; - am->flags |= ACC_MIRANDA; - - noabstractmethod2: - ; - } - } - } - } - RT_TIMING_GET_TIME(time_abstract); - - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_vftbl_len += - sizeof(vftbl_t) + (sizeof(methodptr) * (vftbllength - 1)); -#endif - - /* compute interfacetable length */ - - interfacetablelength = 0; - - for (tc = c; tc != NULL; tc = tc->super) { - for (i = 0; i < tc->interfacescount; i++) { - s4 h = class_highestinterface(tc->interfaces[i]) + 1; - - if (h > interfacetablelength) - interfacetablelength = h; - } - } - RT_TIMING_GET_TIME(time_compute_iftbl); - - /* allocate virtual function table */ - - v = (vftbl_t *) mem_alloc(sizeof(vftbl_t) + - sizeof(methodptr) * (vftbllength - 1) + - sizeof(methodptr*) * (interfacetablelength - (interfacetablelength > 0))); - v = (vftbl_t *) (((methodptr *) v) + - (interfacetablelength - 1) * (interfacetablelength > 1)); - - c->vftbl = v; - v->clazz = c; - v->vftbllength = vftbllength; - v->interfacetablelength = interfacetablelength; - v->arraydesc = arraydesc; - - /* store interface index in vftbl */ - - if (c->flags & ACC_INTERFACE) - v->baseval = -(c->index); - - /* copy virtual function table of super class */ - - for (i = 0; i < supervftbllength; i++) - v->table[i] = super->vftbl->table[i]; - - /* Fill the remaining vftbl slots with the AbstractMethodError - stub (all after the super class slots, because they are already - initialized). */ - - for (; i < vftbllength; i++) { -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror; - else -# endif - v->table[i] = (methodptr) (ptrint) &asm_abstractmethoderror; -#else - v->table[i] = (methodptr) (ptrint) &intrp_asm_abstractmethoderror; -#endif - } - - /* add method stubs into virtual function table */ - - for (i = 0; i < c->methodscount; i++) { - methodinfo *m = &(c->methods[i]); - - assert(m->stubroutine == NULL); - - /* Don't create a compiler stub for abstract methods as they - throw an AbstractMethodError with the default stub in the - vftbl. This entry is simply copied by sub-classes. */ - - if (m->flags & ACC_ABSTRACT) - continue; - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - m->stubroutine = intrp_createcompilerstub(m); - else -#endif - m->stubroutine = codegen_generate_stub_compiler(m); -#else - m->stubroutine = intrp_createcompilerstub(m); -#endif - - /* static methods are not in the vftbl */ - - if (m->flags & ACC_STATIC) - continue; - - /* insert the stubroutine into the vftbl */ - - v->table[m->vftblindex] = (methodptr) (ptrint) m->stubroutine; - } - RT_TIMING_GET_TIME(time_fill_vftbl); - - /* compute instance size and offset of each field */ - - for (i = 0; i < c->fieldscount; i++) { - s4 dsize; - fieldinfo *f = &(c->fields[i]); - - if (!(f->flags & ACC_STATIC)) { - dsize = descriptor_typesize(f->parseddesc); - -#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__)) || defined(__M68K__) - /* On some architectures and configurations we need to - align long (int64_t) and double fields to 4-bytes to - match what GCC does for struct members. We must do the - same as GCC here because the offsets in native header - structs like java_lang_Double must match the offsets of - the Java fields (eg. java.lang.Double.value). */ - -# if LINKER_ALIGNMENT_LONG_DOUBLE != 4 -# error alignment of long and double is not 4 -# endif - - c->instancesize = MEMORY_ALIGN(c->instancesize, 4); -#else - -# if LINKER_ALIGNMENT_LONG_DOUBLE != 8 -# error alignment of long and double is not 8 -# endif - - c->instancesize = MEMORY_ALIGN(c->instancesize, dsize); -#endif - - f->offset = c->instancesize; - c->instancesize += dsize; - } - } - RT_TIMING_GET_TIME(time_offsets); - - /* initialize interfacetable and interfacevftbllength */ - - v->interfacevftbllength = MNEW(s4, interfacetablelength); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_vftbl_len += (4 + sizeof(s4)) * v->interfacetablelength; -#endif - - for (i = 0; i < interfacetablelength; i++) { - v->interfacevftbllength[i] = 0; - v->interfacetable[-i] = NULL; - } - - /* add interfaces */ - - for (tc = c; tc != NULL; tc = tc->super) - for (i = 0; i < tc->interfacescount; i++) - if (!linker_addinterface(c, tc->interfaces[i])) - return NULL; - - RT_TIMING_GET_TIME(time_fill_iftbl); - - /* add finalizer method (not for java.lang.Object) */ - - if (super) { - methodinfo *fi; - - fi = class_findmethod(c, utf_finalize, utf_void__void); - - if (fi) - if (!(fi->flags & ACC_STATIC)) - c->finalizer = fi; - } - RT_TIMING_GET_TIME(time_finalizer); - - /* final tasks */ - - linker_compute_subclasses(c); - - /* FIXME: this is completely useless now */ - RT_TIMING_GET_TIME(time_subclasses); - - build_display(c); - - /* revert the linking state and class is linked */ - - c->state = (c->state & ~CLASS_LINKING) | CLASS_LINKED; - - /* check worklist */ - - /* XXX must this also be done in case of exception? */ - - while (worklist != NULL) { - method_worklist *wi = worklist; - - worklist = worklist->next; - - INLINELOG( printf("MUST BE RECOMPILED: "); method_println(wi->m); ); - jit_invalidate_code(wi->m); - - /* XXX put worklist into dump memory? */ - FREE(wi, method_worklist); - } - - RT_TIMING_TIME_DIFF(time_start ,time_resolving ,RT_TIMING_LINK_RESOLVE); - RT_TIMING_TIME_DIFF(time_resolving ,time_compute_vftbl,RT_TIMING_LINK_C_VFTBL); - RT_TIMING_TIME_DIFF(time_compute_vftbl,time_abstract ,RT_TIMING_LINK_ABSTRACT); - RT_TIMING_TIME_DIFF(time_abstract ,time_compute_iftbl,RT_TIMING_LINK_C_IFTBL); - RT_TIMING_TIME_DIFF(time_compute_iftbl,time_fill_vftbl ,RT_TIMING_LINK_F_VFTBL); - RT_TIMING_TIME_DIFF(time_fill_vftbl ,time_offsets ,RT_TIMING_LINK_OFFSETS); - RT_TIMING_TIME_DIFF(time_offsets ,time_fill_iftbl ,RT_TIMING_LINK_F_IFTBL); - RT_TIMING_TIME_DIFF(time_fill_iftbl ,time_finalizer ,RT_TIMING_LINK_FINALIZER); - RT_TIMING_TIME_DIFF(time_finalizer ,time_subclasses ,RT_TIMING_LINK_SUBCLASS); - - /* just return c to show that we didn't had a problem */ - - return c; -} - - -/* link_array ****************************************************************** - - This function is called by link_class to create the arraydescriptor - for an array class. - - This function returns NULL if the array cannot be linked because - the component type has not been linked yet. - -*******************************************************************************/ - -static arraydescriptor *link_array(classinfo *c) -{ - classinfo *comp; - s4 namelen; - arraydescriptor *desc; - vftbl_t *compvftbl; - utf *u; - - comp = NULL; - namelen = c->name->blength; - - /* Check the component type */ - - switch (c->name->text[1]) { - case '[': - /* c is an array of arrays. */ - u = utf_new(c->name->text + 1, namelen - 1); - if (!(comp = load_class_from_classloader(u, c->classloader))) - return NULL; - break; - - case 'L': - /* c is an array of objects. */ - u = utf_new(c->name->text + 2, namelen - 3); - if (!(comp = load_class_from_classloader(u, c->classloader))) - return NULL; - break; - } - - /* If the component type has not been linked, link it now */ - - assert(!comp || (comp->state & CLASS_LOADED)); - - if (comp && !(comp->state & CLASS_LINKED)) - if (!link_class(comp)) - return NULL; - - /* Allocate the arraydescriptor */ - - desc = NEW(arraydescriptor); - - if (comp) { - /* c is an array of references */ - desc->arraytype = ARRAYTYPE_OBJECT; - desc->componentsize = sizeof(void*); - desc->dataoffset = OFFSET(java_objectarray_t, data); - - compvftbl = comp->vftbl; - - if (!compvftbl) { - log_text("Component class has no vftbl"); - assert(0); - } - - desc->componentvftbl = compvftbl; - - if (compvftbl->arraydesc) { - desc->elementvftbl = compvftbl->arraydesc->elementvftbl; - - if (compvftbl->arraydesc->dimension >= 255) { - log_text("Creating array of dimension >255"); - assert(0); - } - - desc->dimension = compvftbl->arraydesc->dimension + 1; - desc->elementtype = compvftbl->arraydesc->elementtype; - - } else { - desc->elementvftbl = compvftbl; - desc->dimension = 1; - desc->elementtype = ARRAYTYPE_OBJECT; - } - - } else { - /* c is an array of a primitive type */ - switch (c->name->text[1]) { - case 'Z': - desc->arraytype = ARRAYTYPE_BOOLEAN; - desc->dataoffset = OFFSET(java_booleanarray_t,data); - desc->componentsize = sizeof(u1); - break; - - case 'B': - desc->arraytype = ARRAYTYPE_BYTE; - desc->dataoffset = OFFSET(java_bytearray_t,data); - desc->componentsize = sizeof(u1); - break; - - case 'C': - desc->arraytype = ARRAYTYPE_CHAR; - desc->dataoffset = OFFSET(java_chararray_t,data); - desc->componentsize = sizeof(u2); - break; - - case 'D': - desc->arraytype = ARRAYTYPE_DOUBLE; - desc->dataoffset = OFFSET(java_doublearray_t,data); - desc->componentsize = sizeof(double); - break; - - case 'F': - desc->arraytype = ARRAYTYPE_FLOAT; - desc->dataoffset = OFFSET(java_floatarray_t,data); - desc->componentsize = sizeof(float); - break; - - case 'I': - desc->arraytype = ARRAYTYPE_INT; - desc->dataoffset = OFFSET(java_intarray_t,data); - desc->componentsize = sizeof(s4); - break; - - case 'J': - desc->arraytype = ARRAYTYPE_LONG; - desc->dataoffset = OFFSET(java_longarray_t,data); - desc->componentsize = sizeof(s8); - break; - - case 'S': - desc->arraytype = ARRAYTYPE_SHORT; - desc->dataoffset = OFFSET(java_shortarray_t,data); - desc->componentsize = sizeof(s2); - break; - - default: - exceptions_throw_noclassdeffounderror(c->name); - return NULL; - } - - desc->componentvftbl = NULL; - desc->elementvftbl = NULL; - desc->dimension = 1; - desc->elementtype = desc->arraytype; - } - - return desc; -} - - -/* linker_compute_subclasses *************************************************** - - XXX - - ATTENTION: DO NOT REMOVE ANY OF THE LOCKING MECHANISMS BELOW: - This function needs to take the class renumber lock and stop the - world during class renumbering. The lock is used in C code which - is not that performance critical. Whereas JIT code uses critical - sections to atomically access the class values. - -*******************************************************************************/ - -static void linker_compute_subclasses(classinfo *c) -{ -#if 0 && defined(ENABLE_THREADS) && !defined(DISABLE_GC) - threads_stopworld(); -#endif - - if (!(c->flags & ACC_INTERFACE)) { - c->nextsub = NULL; - c->sub = NULL; - c->vftbl->baseval = 1; /* so it does not look like an interface */ - } - - if (!(c->flags & ACC_INTERFACE) && (c->super != NULL)) { - c->nextsub = c->super->sub; - c->super->sub = c; - } - - classvalue = 0; - -#if 0 && defined(ENABLE_THREADS) && !defined(DISABLE_GC) - threads_startworld(); -#endif -} - - -/* linker_compute_class_values ************************************************* - - XXX - -*******************************************************************************/ - -static void linker_compute_class_values(classinfo *c) -{ - classinfo *subs; - - c->vftbl->baseval = ++classvalue; - - subs = c->sub; - - while (subs) { - linker_compute_class_values(subs); - - subs = subs->nextsub; - } - - c->vftbl->diffval = classvalue - c->vftbl->baseval; -} - - -/* linker_addinterface ********************************************************* - - Is needed by link_class for adding a VTBL to a class. All - interfaces implemented by ic are added as well. - - RETURN VALUE: - true.........everything ok - false........an exception has been thrown - -*******************************************************************************/ - -static bool linker_addinterface(classinfo *c, classinfo *ic) -{ - s4 j, k; - vftbl_t *v; - s4 i; - classinfo *sc; - methodinfo *m; - - v = c->vftbl; - i = ic->index; - - if (i >= v->interfacetablelength) - vm_abort("Internal error: interfacetable overflow"); - - /* if this interface has already been added, return immediately */ - - if (v->interfacetable[-i] != NULL) - return true; - - if (ic->methodscount == 0) { /* fake entry needed for subtype test */ - v->interfacevftbllength[i] = 1; - v->interfacetable[-i] = MNEW(methodptr, 1); - v->interfacetable[-i][0] = NULL; - } - else { - v->interfacevftbllength[i] = ic->methodscount; - v->interfacetable[-i] = MNEW(methodptr, ic->methodscount); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_vftbl_len += sizeof(methodptr) * - (ic->methodscount + (ic->methodscount == 0)); -#endif - - for (j = 0; j < ic->methodscount; j++) { - for (sc = c; sc != NULL; sc = sc->super) { - for (k = 0; k < sc->methodscount; k++) { - m = &(sc->methods[k]); - - if (method_canoverwrite(m, &(ic->methods[j]))) { - /* method m overwrites the (abstract) method */ -#if defined(ENABLE_VERIFIER) - /* Add loading constraints (for the more - general types of the method - ic->methods[j]). */ - if (!classcache_add_constraints_for_params( - c->classloader, ic->classloader, - &(ic->methods[j]))) - { - return false; - } -#endif - - /* XXX taken from gcj */ - /* check for ACC_STATIC: IncompatibleClassChangeError */ - - /* check for !ACC_PUBLIC: IllegalAccessError */ - - /* check for ACC_ABSTRACT: AbstracMethodError, - not sure about that one */ - - v->interfacetable[-i][j] = v->table[m->vftblindex]; - goto foundmethod; - } - } - } - - /* If no method was found, insert the AbstractMethodError - stub. */ - -#if defined(ENABLE_JIT) -# if defined(ENABLE_INTRP) - if (opt_intrp) - v->interfacetable[-i][j] = - (methodptr) (ptrint) &intrp_asm_abstractmethoderror; - else -# endif - v->interfacetable[-i][j] = - (methodptr) (ptrint) &asm_abstractmethoderror; -#else - v->interfacetable[-i][j] = - (methodptr) (ptrint) &intrp_asm_abstractmethoderror; -#endif - - foundmethod: - ; - } - } - - /* add superinterfaces of this interface */ - - for (j = 0; j < ic->interfacescount; j++) - if (!linker_addinterface(c, ic->interfaces[j])) - return false; - - /* everything ok */ - - return true; -} - - -/* class_highestinterface ****************************************************** - - Used by the function link_class to determine the amount of memory - needed for the interface table. - -*******************************************************************************/ - -static s4 class_highestinterface(classinfo *c) -{ - s4 h; - s4 h2; - s4 i; - - /* check for ACC_INTERFACE bit already done in link_class_intern */ - - h = c->index; - - for (i = 0; i < c->interfacescount; i++) { - h2 = class_highestinterface(c->interfaces[i]); - - if (h2 > h) - h = h2; - } - - return h; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/linker.h b/src/vmcore/linker.h deleted file mode 100644 index 83a6e90a0..000000000 --- a/src/vmcore/linker.h +++ /dev/null @@ -1,164 +0,0 @@ -/* src/vmcore/linker.h - class linker header - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _LINKER_H -#define _LINKER_H - -/* forward typedefs ***********************************************************/ - -typedef struct _vftbl vftbl_t; -typedef struct arraydescriptor arraydescriptor; -typedef struct primitivetypeinfo primitivetypeinfo; - - -#include "config.h" -#include "vm/types.h" - -#include "vmcore/class.h" -#include "vmcore/references.h" - - -/* virtual function table ****************************************************** - - The vtbl has a bidirectional layout with open ends at both sides. - interfacetablelength gives the number of entries of the interface - table at the start of the vftbl. The vftbl pointer points to - &interfacetable[0]. vftbllength gives the number of entries of - table at the end of the vftbl. - - runtime type check (checkcast): - - Different methods are used for runtime type check depending on the - argument of checkcast/instanceof. - - A check against a class is implemented via relative numbering on - the class hierachy tree. The tree is numbered in a depth first - traversal setting the base field and the diff field. The diff field - gets the result of (high - base) so that a range check can be - implemented by an unsigned compare. A sub type test is done by - checking the inclusion of base of the sub class in the range of the - superclass. - - A check against an interface is implemented via the - interfacevftbl. If the interfacevftbl contains a nonnull value a - class is a subclass of this interface. - - interfacetable: - - Like standard virtual methods interface methods are called using - virtual function tables. All interfaces are numbered sequentially - (starting with zero). For each class there exist an interface table - of virtual function tables for each implemented interface. The - length of the interface table is determined by the highest number - of an implemented interface. - - The following example assumes a class which implements interface 0 and 3: - - interfacetablelength = 4 - - | ... | +----------+ - +-----------+ | method 2 |---> method z - | class | | method 1 |---> method y - +-----------+ | method 0 |---> method x - | ivftbl 0 |----------> +----------+ - vftblptr ---> +-----------+ - | ivftbl -1 |--> NULL +----------+ - | ivftbl -2 |--> NULL | method 1 |---> method x - | ivftbl -3 |-----+ | method 0 |---> method a - +-----------+ +----> +----------+ - - +---------------+ - | length 3 = 2 | - | length 2 = 0 | - | length 1 = 0 | - | length 0 = 3 | - interfacevftbllength ---> +---------------+ - -*******************************************************************************/ - -#define DISPLAY_SIZE 4 - -struct _vftbl { - methodptr *interfacetable[1]; /* interface table (access via macro) */ - classinfo *clazz; /* class, the vtbl belongs to */ - arraydescriptor *arraydesc; /* for array classes, otherwise NULL */ - s4 vftbllength; /* virtual function table length */ - s4 interfacetablelength; /* interface table length */ - s4 baseval; /* base for runtime type check */ - /* (-index for interfaces) */ - s4 diffval; /* high - base for runtime type check */ - - s4 subtype_depth; - s4 subtype_offset; - struct _vftbl *subtype_display[DISPLAY_SIZE+1]; /* the last one is cache */ - struct _vftbl **subtype_overflow; - - s4 *interfacevftbllength; /* length of interface vftbls */ - methodptr table[1]; /* class vftbl */ -}; - - -/* arraydescriptor ************************************************************* - - For every array class an arraydescriptor is allocated which - describes the array class. The arraydescriptor is referenced from - the vftbl of the array class. - -*******************************************************************************/ - -struct arraydescriptor { - vftbl_t *componentvftbl; /* vftbl of the component type, NULL for primit. */ - vftbl_t *elementvftbl; /* vftbl of the element type, NULL for primitive */ - s2 arraytype; /* ARRAYTYPE_* constant */ - s2 dimension; /* dimension of the array (always >= 1) */ - s4 dataoffset; /* offset of the array data from object pointer */ - s4 componentsize; /* size of a component in bytes */ - s2 elementtype; /* ARRAYTYPE_* constant */ -}; - - -/* function prototypes ********************************************************/ - -void linker_preinit(void); -void linker_init(void); -classinfo *link_class(classinfo *c); - -#endif /* _LINKER_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/loader.c b/src/vmcore/loader.c deleted file mode 100644 index a1d730ccc..000000000 --- a/src/vmcore/loader.c +++ /dev/null @@ -1,2228 +0,0 @@ -/* src/vmcore/loader.c - class loader functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/llni.h" - -#include "threads/lock-common.h" - -#include "toolbox/hashtable.h" -#include "toolbox/logging.h" - -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/package.h" -#include "vm/primitive.h" -#include "vm/resolve.h" -#include "vm/stringlocal.h" -#include "vm/vm.h" - -#include "vm/jit_interface.h" - -#if defined(ENABLE_JAVASE) -# include "vmcore/annotation.h" -# include "vmcore/stackmap.h" -#endif - -#include "vmcore/classcache.h" -#include "vmcore/field.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/rt-timing.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#include "vmcore/suck.h" - -#if defined(ENABLE_ZLIB) -# include "vmcore/zip.h" -#endif - -#if defined(ENABLE_JVMTI) -# include "native/jvmti/cacaodbg.h" -#endif - - -/* global variables ***********************************************************/ - -static hashtable *hashtable_classloader; - - -/* loader_preinit ************************************************************** - - Initializes the classpath list and loads classes required for the - primitive table. - - NOTE: Exceptions thrown during VM initialization are caught in the - exception functions themselves. - -*******************************************************************************/ - -void loader_preinit(void) -{ -#if defined(ENABLE_THREADS) - list_classpath_entry *lce; -#endif - - TRACESUBSYSTEMINITIALIZATION("loader_preinit"); - -#if defined(ENABLE_THREADS) - /* Initialize the monitor pointer for zip/jar file locking. */ - - for (lce = list_first(list_classpath_entries); lce != NULL; - lce = list_next(list_classpath_entries, lce)) { - if (lce->type == CLASSPATH_ARCHIVE) - LOCK_INIT_OBJECT_LOCK(lce); - } -#endif - - /* initialize classloader hashtable, 10 entries should be enough */ - - hashtable_classloader = NEW(hashtable); - hashtable_create(hashtable_classloader, 10); - - /* Load the most basic classes. */ - - assert(vm_initializing == true); - - class_java_lang_Object = load_class_bootstrap(utf_java_lang_Object); - -#if defined(ENABLE_JAVASE) - class_java_lang_Cloneable = load_class_bootstrap(utf_java_lang_Cloneable); - class_java_io_Serializable = load_class_bootstrap(utf_java_io_Serializable); -#endif -} - - -/* loader_init ***************************************************************** - - Loads all classes required in the VM. - - NOTE: Exceptions thrown during VM initialization are caught in the - exception functions themselves. - -*******************************************************************************/ - -void loader_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("loader_init"); - - /* Load primitive-type wrapping classes. */ - - assert(vm_initializing == true); - -#if defined(ENABLE_JAVASE) - class_java_lang_Void = load_class_bootstrap(utf_java_lang_Void); -#endif - - class_java_lang_Boolean = load_class_bootstrap(utf_java_lang_Boolean); - class_java_lang_Byte = load_class_bootstrap(utf_java_lang_Byte); - class_java_lang_Character = load_class_bootstrap(utf_java_lang_Character); - class_java_lang_Short = load_class_bootstrap(utf_java_lang_Short); - class_java_lang_Integer = load_class_bootstrap(utf_java_lang_Integer); - class_java_lang_Long = load_class_bootstrap(utf_java_lang_Long); - class_java_lang_Float = load_class_bootstrap(utf_java_lang_Float); - class_java_lang_Double = load_class_bootstrap(utf_java_lang_Double); - - /* Load important system classes. */ - - class_java_lang_Class = load_class_bootstrap(utf_java_lang_Class); - class_java_lang_String = load_class_bootstrap(utf_java_lang_String); - -#if defined(ENABLE_JAVASE) - class_java_lang_ClassLoader = - load_class_bootstrap(utf_java_lang_ClassLoader); - - class_java_lang_SecurityManager = - load_class_bootstrap(utf_java_lang_SecurityManager); -#endif - - class_java_lang_System = - load_class_bootstrap(utf_new_char("java/lang/System")); - - class_java_lang_Thread = - load_class_bootstrap(utf_new_char("java/lang/Thread")); - -#if defined(ENABLE_JAVASE) - class_java_lang_ThreadGroup = - load_class_bootstrap(utf_java_lang_ThreadGroup); -#endif - - class_java_lang_Throwable = load_class_bootstrap(utf_java_lang_Throwable); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - class_java_lang_VMSystem = - load_class_bootstrap(utf_new_char("java/lang/VMSystem")); - - class_java_lang_VMThread = - load_class_bootstrap(utf_new_char("java/lang/VMThread")); - - class_java_lang_VMThrowable = - load_class_bootstrap(utf_new_char("java/lang/VMThrowable")); -#endif - - /* Important system exceptions. */ - - class_java_lang_Exception = load_class_bootstrap(utf_java_lang_Exception); - - class_java_lang_ClassNotFoundException = - load_class_bootstrap(utf_java_lang_ClassNotFoundException); - - class_java_lang_RuntimeException = - load_class_bootstrap(utf_java_lang_RuntimeException); - - /* Some classes which may be used often. */ - -#if defined(ENABLE_JAVASE) - class_java_lang_StackTraceElement = load_class_bootstrap(utf_java_lang_StackTraceElement); - - class_java_lang_reflect_Constructor = load_class_bootstrap(utf_java_lang_reflect_Constructor); - class_java_lang_reflect_Field = load_class_bootstrap(utf_java_lang_reflect_Field); - class_java_lang_reflect_Method = load_class_bootstrap(utf_java_lang_reflect_Method); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - class_java_lang_reflect_VMConstructor = load_class_bootstrap(utf_java_lang_reflect_VMConstructor); - class_java_lang_reflect_VMField = load_class_bootstrap(utf_java_lang_reflect_VMField); - class_java_lang_reflect_VMMethod = load_class_bootstrap(utf_java_lang_reflect_VMMethod); -# endif - - class_java_security_PrivilegedAction = load_class_bootstrap(utf_new_char("java/security/PrivilegedAction")); - - class_java_util_HashMap = load_class_bootstrap(utf_new_char("java/util/HashMap")); - class_java_util_Vector = load_class_bootstrap(utf_java_util_Vector); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - class_sun_reflect_MagicAccessorImpl = - load_class_bootstrap(utf_new_char("sun/reflect/MagicAccessorImpl")); -# endif - - arrayclass_java_lang_Object = - load_class_bootstrap(utf_new_char("[Ljava/lang/Object;")); - -# if defined(ENABLE_ANNOTATIONS) - /* needed by annotation support */ - class_sun_reflect_ConstantPool = - load_class_bootstrap(utf_new_char("sun/reflect/ConstantPool")); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - /* needed by GNU Classpaths annotation support */ - class_sun_reflect_annotation_AnnotationParser = - load_class_bootstrap(utf_new_char("sun/reflect/annotation/AnnotationParser")); -# endif -# endif -#endif -} - - -/* loader_hashtable_classloader_add ******************************************** - - Adds an entry to the classloader hashtable. - - REMEMBER: Also use this to register native loaders! - -*******************************************************************************/ - -classloader_t *loader_hashtable_classloader_add(java_handle_t *cl) -{ - hashtable_classloader_entry *cle; - u4 key; - u4 slot; - - if (cl == NULL) - return NULL; - - LOCK_MONITOR_ENTER(hashtable_classloader->header); - - LLNI_CRITICAL_START; - - /* key for entry is the hashcode of the classloader; - aligned to 16-byte boundaries */ - - key = heap_hashcode(LLNI_DIRECT(cl)) >> 4; - slot = key & (hashtable_classloader->size - 1); - cle = hashtable_classloader->ptr[slot]; - - /* search hashchain for existing entry */ - - while (cle) { - if (cle->object == LLNI_DIRECT(cl)) - break; - - cle = cle->hashlink; - } - - LLNI_CRITICAL_END; - - /* if no classloader was found, we create a new entry here */ - - if (cle == NULL) { - cle = NEW(hashtable_classloader_entry); - -#if defined(ENABLE_GC_CACAO) - /* register the classloader object with the GC */ - - gc_reference_register(&(cle->object), GC_REFTYPE_CLASSLOADER); -#endif - - LLNI_CRITICAL_START; - - cle->object = LLNI_DIRECT(cl); - - LLNI_CRITICAL_END; - -/*#define LOADER_DEBUG_CLASSLOADER*/ -#ifdef LOADER_DEBUG_CLASSLOADER - printf("CLASSLOADER: adding new classloader entry %p for %p: ", cle, cl); - class_print(LLNI_vftbl_direct(cl)->class); - printf("\n"); - fflush(stdout); -#endif - - /* insert entry into hashtable */ - - cle->hashlink = hashtable_classloader->ptr[slot]; - hashtable_classloader->ptr[slot] = cle; - - /* update number of entries */ - - hashtable_classloader->entries++; - } - - - LOCK_MONITOR_EXIT(hashtable_classloader->header); - -#if defined(ENABLE_HANDLES) - return cle; -#else - return cl; -#endif -} - - -/* loader_hashtable_classloader_find ******************************************* - - Find an entry in the classloader hashtable. - -*******************************************************************************/ - -classloader_t *loader_hashtable_classloader_find(java_handle_t *cl) -{ - hashtable_classloader_entry *cle; - u4 key; - u4 slot; - - if (cl == NULL) - return NULL; - - LLNI_CRITICAL_START; - - /* key for entry is the hashcode of the classloader; - aligned to 16-byte boundaries */ - - key = heap_hashcode(LLNI_DIRECT(cl)) >> 4; - slot = key & (hashtable_classloader->size - 1); - cle = hashtable_classloader->ptr[slot]; - - /* search hashchain for existing entry */ - - while (cle) { - if (cle->object == LLNI_DIRECT(cl)) - break; - - cle = cle->hashlink; - } - -#ifdef LOADER_DEBUG_CLASSLOADER - if (cle == NULL) { - printf("CLASSLOADER: unable to find classloader entry for %p: ", cl); - class_print(LLNI_vftbl_direct(cl)->class); - printf("\n"); - fflush(stdout); - } -#endif - - LLNI_CRITICAL_END; - -#if defined(ENABLE_HANDLES) - return cle; -#else - return cl; -#endif -} - - -/* loader_load_all_classes ***************************************************** - - Loads all classes specified in the BOOTCLASSPATH. - -*******************************************************************************/ - -void loader_load_all_classes(void) -{ - list_classpath_entry *lce; -#if defined(ENABLE_ZLIB) - hashtable *ht; - s4 slot; - hashtable_zipfile_entry *htzfe; - utf *u; -#endif - - for (lce = list_first(list_classpath_entries); lce != NULL; - lce = list_next(list_classpath_entries, lce)) { -#if defined(ENABLE_ZLIB) - if (lce->type == CLASSPATH_ARCHIVE) { - /* get the classes hashtable */ - - ht = lce->htclasses; - - for (slot = 0; slot < ht->size; slot++) { - htzfe = (hashtable_zipfile_entry *) ht->ptr[slot]; - - for (; htzfe; htzfe = htzfe->hashlink) { - u = htzfe->filename; - - /* skip all entries in META-INF and .properties, - .png files */ - - if (!strncmp(u->text, "META-INF", strlen("META-INF")) || - strstr(u->text, ".properties") || - strstr(u->text, ".png")) - continue; - - /* load class from bootstrap classloader */ - - if (!load_class_bootstrap(u)) { - fprintf(stderr, "Error loading: "); - utf_fprint_printable_ascii_classname(stderr, u); - fprintf(stderr, "\n"); - -#if !defined(NDEBUG) - /* print out exception and cause */ - - exceptions_print_current_exception(); -#endif - } - } - } - - } else { -#endif -#if defined(ENABLE_ZLIB) - } -#endif - } -} - - -/* loader_skip_attribute_body ************************************************** - - Skips an attribute the attribute_name_index has already been read. - - attribute_info { - u2 attribute_name_index; - u4 attribute_length; - u1 info[attribute_length]; - } - -*******************************************************************************/ - -bool loader_skip_attribute_body(classbuffer *cb) -{ - u4 attribute_length; - - if (!suck_check_classbuffer_size(cb, 4)) - return false; - - attribute_length = suck_u4(cb); - - if (!suck_check_classbuffer_size(cb, attribute_length)) - return false; - - suck_skip_nbytes(cb, attribute_length); - - return true; -} - - -/* load_constantpool *********************************************************** - - Loads the constantpool of a class, the entries are transformed into - a simpler format by resolving references (a detailed overview of - the compact structures can be found in global.h). - -*******************************************************************************/ - -static bool load_constantpool(classbuffer *cb, descriptor_pool *descpool) -{ - - /* The following structures are used to save information which cannot be - processed during the first pass. After the complete constantpool has - been traversed the references can be resolved. - (only in specific order) */ - - /* CONSTANT_Class entries */ - typedef struct forward_class { - struct forward_class *next; - u2 thisindex; - u2 name_index; - } forward_class; - - /* CONSTANT_String */ - typedef struct forward_string { - struct forward_string *next; - u2 thisindex; - u2 string_index; - } forward_string; - - /* CONSTANT_NameAndType */ - typedef struct forward_nameandtype { - struct forward_nameandtype *next; - u2 thisindex; - u2 name_index; - u2 sig_index; - } forward_nameandtype; - - /* CONSTANT_Fieldref, CONSTANT_Methodref or CONSTANT_InterfaceMethodref */ - typedef struct forward_fieldmethint { - struct forward_fieldmethint *next; - u2 thisindex; - u1 tag; - u2 class_index; - u2 nameandtype_index; - } forward_fieldmethint; - - - classinfo *c; - u4 idx; - - forward_class *forward_classes = NULL; - forward_string *forward_strings = NULL; - forward_nameandtype *forward_nameandtypes = NULL; - forward_fieldmethint *forward_fieldmethints = NULL; - - forward_class *nfc; - forward_string *nfs; - forward_nameandtype *nfn; - forward_fieldmethint *nff; - - u4 cpcount; - u1 *cptags; - voidptr *cpinfos; - - c = cb->clazz; - - /* number of entries in the constant_pool table plus one */ - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - cpcount = c->cpcount = suck_u2(cb); - - /* allocate memory */ - cptags = c->cptags = MNEW(u1, cpcount); - cpinfos = c->cpinfos = MNEW(voidptr, cpcount); - - if (cpcount < 1) { - exceptions_throw_classformaterror(c, "Illegal constant pool size"); - return false; - } - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += (sizeof(u1) + sizeof(voidptr)) * cpcount; -#endif - - /* initialize constantpool */ - for (idx = 0; idx < cpcount; idx++) { - cptags[idx] = CONSTANT_UNUSED; - cpinfos[idx] = NULL; - } - - - /******* first pass *******/ - /* entries which cannot be resolved now are written into - temporary structures and traversed again later */ - - idx = 1; - while (idx < cpcount) { - u4 t; - - /* get constant type */ - if (!suck_check_classbuffer_size(cb, 1)) - return false; - - t = suck_u1(cb); - - switch (t) { - case CONSTANT_Class: - nfc = DNEW(forward_class); - - nfc->next = forward_classes; - forward_classes = nfc; - - nfc->thisindex = idx; - /* reference to CONSTANT_NameAndType */ - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - nfc->name_index = suck_u2(cb); - - idx++; - break; - - case CONSTANT_String: - nfs = DNEW(forward_string); - - nfs->next = forward_strings; - forward_strings = nfs; - - nfs->thisindex = idx; - - /* reference to CONSTANT_Utf8_info with string characters */ - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - nfs->string_index = suck_u2(cb); - - idx++; - break; - - case CONSTANT_NameAndType: - nfn = DNEW(forward_nameandtype); - - nfn->next = forward_nameandtypes; - forward_nameandtypes = nfn; - - nfn->thisindex = idx; - - if (!suck_check_classbuffer_size(cb, 2 + 2)) - return false; - - /* reference to CONSTANT_Utf8_info containing simple name */ - nfn->name_index = suck_u2(cb); - - /* reference to CONSTANT_Utf8_info containing field or method - descriptor */ - nfn->sig_index = suck_u2(cb); - - idx++; - break; - - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - nff = DNEW(forward_fieldmethint); - - nff->next = forward_fieldmethints; - forward_fieldmethints = nff; - - nff->thisindex = idx; - /* constant type */ - nff->tag = t; - - if (!suck_check_classbuffer_size(cb, 2 + 2)) - return false; - - /* class or interface type that contains the declaration of the - field or method */ - nff->class_index = suck_u2(cb); - - /* name and descriptor of the field or method */ - nff->nameandtype_index = suck_u2(cb); - - idx++; - break; - - case CONSTANT_Integer: { - constant_integer *ci = NEW(constant_integer); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += sizeof(constant_integer); -#endif - - if (!suck_check_classbuffer_size(cb, 4)) - return false; - - ci->value = suck_s4(cb); - cptags[idx] = CONSTANT_Integer; - cpinfos[idx] = ci; - - idx++; - break; - } - - case CONSTANT_Float: { - constant_float *cf = NEW(constant_float); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += sizeof(constant_float); -#endif - - if (!suck_check_classbuffer_size(cb, 4)) - return false; - - cf->value = suck_float(cb); - cptags[idx] = CONSTANT_Float; - cpinfos[idx] = cf; - - idx++; - break; - } - - case CONSTANT_Long: { - constant_long *cl = NEW(constant_long); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += sizeof(constant_long); -#endif - - if (!suck_check_classbuffer_size(cb, 8)) - return false; - - cl->value = suck_s8(cb); - cptags[idx] = CONSTANT_Long; - cpinfos[idx] = cl; - idx += 2; - if (idx > cpcount) { - exceptions_throw_classformaterror(c, "Invalid constant pool entry"); - return false; - } - break; - } - - case CONSTANT_Double: { - constant_double *cd = NEW(constant_double); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += sizeof(constant_double); -#endif - - if (!suck_check_classbuffer_size(cb, 8)) - return false; - - cd->value = suck_double(cb); - cptags[idx] = CONSTANT_Double; - cpinfos[idx] = cd; - idx += 2; - if (idx > cpcount) { - exceptions_throw_classformaterror(c, "Invalid constant pool entry"); - return false; - } - break; - } - - case CONSTANT_Utf8: { - u4 length; - - /* number of bytes in the bytes array (not string-length) */ - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - length = suck_u2(cb); - cptags[idx] = CONSTANT_Utf8; - - /* validate the string */ - if (!suck_check_classbuffer_size(cb, length)) - return false; - -#ifdef ENABLE_VERIFIER - if (opt_verify && - !is_valid_utf((char *) cb->pos, (char *) (cb->pos + length))) - { - exceptions_throw_classformaterror(c, "Invalid UTF-8 string"); - return false; - } -#endif /* ENABLE_VERIFIER */ - /* insert utf-string into the utf-symboltable */ - cpinfos[idx] = utf_new((char *) cb->pos, length); - - /* skip bytes of the string (buffer size check above) */ - suck_skip_nbytes(cb, length); - idx++; - break; - } - - default: - exceptions_throw_classformaterror(c, "Illegal constant pool type"); - return false; - } /* end switch */ - } /* end while */ - - - /* resolve entries in temporary structures */ - - while (forward_classes) { - utf *name = - class_getconstant(c, forward_classes->name_index, CONSTANT_Utf8); - if (!name) - return false; - -#ifdef ENABLE_VERIFIER - if (opt_verify && !is_valid_name_utf(name)) { - exceptions_throw_classformaterror(c, "Class reference with invalid name"); - return false; - } -#endif /* ENABLE_VERIFIER */ - - /* add all class references to the descriptor_pool */ - - if (!descriptor_pool_add_class(descpool, name)) - return false; - - cptags[forward_classes->thisindex] = CONSTANT_Class; - - /* the classref is created later */ - cpinfos[forward_classes->thisindex] = name; - - nfc = forward_classes; - forward_classes = forward_classes->next; - } - - while (forward_strings) { - utf *text = - class_getconstant(c, forward_strings->string_index, CONSTANT_Utf8); - if (!text) - return false; - - /* resolve utf-string */ - cptags[forward_strings->thisindex] = CONSTANT_String; - cpinfos[forward_strings->thisindex] = text; - - nfs = forward_strings; - forward_strings = forward_strings->next; - } - - while (forward_nameandtypes) { - constant_nameandtype *cn = NEW(constant_nameandtype); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += sizeof(constant_nameandtype); -#endif - - /* resolve simple name and descriptor */ - cn->name = class_getconstant(c, - forward_nameandtypes->name_index, - CONSTANT_Utf8); - if (!cn->name) - return false; - - cn->descriptor = class_getconstant(c, - forward_nameandtypes->sig_index, - CONSTANT_Utf8); - if (!cn->descriptor) - return false; - -#ifdef ENABLE_VERIFIER - if (opt_verify) { - /* check name */ - if (!is_valid_name_utf(cn->name)) { - exceptions_throw_classformaterror(c, - "Illegal Field name \"%s\"", - cn->name->text); - - return false; - } - - /* disallow referencing among others */ - if (cn->name->text[0] == '<' && cn->name != utf_init) { - exceptions_throw_classformaterror(c, "Illegal reference to special method"); - return false; - } - } -#endif /* ENABLE_VERIFIER */ - - cptags[forward_nameandtypes->thisindex] = CONSTANT_NameAndType; - cpinfos[forward_nameandtypes->thisindex] = cn; - - nfn = forward_nameandtypes; - forward_nameandtypes = forward_nameandtypes->next; - } - - while (forward_fieldmethints) { - constant_nameandtype *nat; - constant_FMIref *fmi = NEW(constant_FMIref); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_const_pool_len += sizeof(constant_FMIref); -#endif - /* resolve simple name and descriptor */ - - nat = class_getconstant(c, - forward_fieldmethints->nameandtype_index, - CONSTANT_NameAndType); - if (!nat) - return false; - - /* add all descriptors in {Field,Method}ref to the descriptor_pool */ - - if (!descriptor_pool_add(descpool, nat->descriptor, NULL)) - return false; - - /* the classref is created later */ - - fmi->p.index = forward_fieldmethints->class_index; - fmi->name = nat->name; - fmi->descriptor = nat->descriptor; - - cptags[forward_fieldmethints->thisindex] = forward_fieldmethints->tag; - cpinfos[forward_fieldmethints->thisindex] = fmi; - - nff = forward_fieldmethints; - forward_fieldmethints = forward_fieldmethints->next; - } - - /* everything was ok */ - - return true; -} - - -/* loader_load_attribute_signature ********************************************* - - Signature_attribute { - u2 attribute_name_index; - u4 atrribute_length; - u2 signature_index; - } - -*******************************************************************************/ - -#if defined(ENABLE_JAVASE) -bool loader_load_attribute_signature(classbuffer *cb, utf **signature) -{ - classinfo *c; - u4 attribute_length; - u2 signature_index; - - /* get classinfo */ - - c = cb->clazz; - - /* check remaining bytecode */ - - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* check attribute length */ - - attribute_length = suck_u4(cb); - - if (attribute_length != 2) { - exceptions_throw_classformaterror(c, "Wrong size for VALUE attribute"); - return false; - } - - if (*signature != NULL) { - exceptions_throw_classformaterror(c, "Multiple Signature attributes"); - return false; - } - - /* get signature */ - - signature_index = suck_u2(cb); - - if (!(*signature = class_getconstant(c, signature_index, CONSTANT_Utf8))) - return false; - - return true; -} -#endif /* defined(ENABLE_JAVASE) */ - - -/* load_class_from_sysloader *************************************************** - - Load the class with the given name using the system class loader - - IN: - name.............the classname - - RETURN VALUE: - the loaded class, or - NULL if an exception has been thrown - -*******************************************************************************/ - -classinfo *load_class_from_sysloader(utf *name) -{ - methodinfo *m; - java_handle_t *clo; - classloader_t *cl; - classinfo *c; - - assert(class_java_lang_Object); - assert(class_java_lang_ClassLoader); - assert(class_java_lang_ClassLoader->state & CLASS_LINKED); - - m = class_resolveclassmethod(class_java_lang_ClassLoader, - utf_getSystemClassLoader, - utf_void__java_lang_ClassLoader, - class_java_lang_Object, - false); - - if (!m) - return false; - - clo = vm_call_method(m, NULL); - - if (!clo) - return false; - - cl = loader_hashtable_classloader_add(clo); - - c = load_class_from_classloader(name, cl); - - return c; -} - - -/* load_class_from_classloader ************************************************* - - Load the class with the given name using the given user-defined class loader. - - IN: - name.............the classname - cl...............user-defined class loader - - RETURN VALUE: - the loaded class, or - NULL if an exception has been thrown - -*******************************************************************************/ - -classinfo *load_class_from_classloader(utf *name, classloader_t *cl) -{ - java_handle_t *o; - classinfo *c; - classinfo *tmpc; - java_handle_t *string; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_lookup, time_prepare, time_java, - time_cache; -#endif - - RT_TIMING_GET_TIME(time_start); - - assert(name); - - /* lookup if this class has already been loaded */ - - c = classcache_lookup(cl, name); - - RT_TIMING_GET_TIME(time_lookup); - RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_CL_LOOKUP); - - if (c != NULL) - return c; - - /* if other class loader than bootstrap, call it */ - - if (cl != NULL) { - methodinfo *lc; - char *text; - s4 namelen; - - text = name->text; - namelen = name->blength; - - /* handle array classes */ - if (text[0] == '[') { - classinfo *comp; - utf *u; - - switch (text[1]) { - case 'L': - /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */ - if (namelen < 4 || text[2] == '[' || text[namelen - 1] != ';') { - exceptions_throw_classnotfoundexception(name); - return false; - } - - u = utf_new(text + 2, namelen - 3); - - if (!(comp = load_class_from_classloader(u, cl))) - return false; - - /* create the array class */ - - c = class_array_of(comp, false); - - tmpc = classcache_store(cl, c, true); - - if (tmpc == NULL) { - /* exception, free the loaded class */ - c->state &= ~CLASS_LOADING; - class_free(c); - } - - return tmpc; - - case '[': - /* load the component class */ - - u = utf_new(text + 1, namelen - 1); - - if (!(comp = load_class_from_classloader(u, cl))) - return false; - - /* create the array class */ - - c = class_array_of(comp, false); - - tmpc = classcache_store(cl, c, true); - - if (tmpc == NULL) { - /* exception, free the loaded class */ - c->state &= ~CLASS_LOADING; - class_free(c); - } - - return tmpc; - - default: - /* primitive array classes are loaded by the bootstrap loader */ - - c = load_class_bootstrap(name); - - return c; - } - } - - LLNI_class_get(cl, c); - -#if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK) - /* OpenJDK uses this internal function because it's - synchronized. */ - - lc = class_resolveclassmethod(c, - utf_loadClassInternal, - utf_java_lang_String__java_lang_Class, - NULL, - true); -#else - lc = class_resolveclassmethod(c, - utf_loadClass, - utf_java_lang_String__java_lang_Class, - NULL, - true); -#endif - - if (lc == NULL) - return false; /* exception */ - - /* move return value into `o' and cast it afterwards to a classinfo* */ - - string = javastring_new_slash_to_dot(name); - - RT_TIMING_GET_TIME(time_prepare); - - o = vm_call_method(lc, (java_handle_t *) cl, string); - - RT_TIMING_GET_TIME(time_java); - - c = LLNI_classinfo_unwrap(o); - - if (c != NULL) { - /* Store this class in the loaded class cache. If another - class with the same (initloader,name) pair has been - stored earlier it will be returned by classcache_store - In this case classcache_store may not free the class - because it has already been exposed to Java code which - may have kept references to that class. */ - - tmpc = classcache_store(cl, c, false); - - if (tmpc == NULL) { - /* exception, free the loaded class */ - c->state &= ~CLASS_LOADING; - class_free(c); - } - - c = tmpc; - } - - RT_TIMING_GET_TIME(time_cache); - - RT_TIMING_TIME_DIFF(time_lookup , time_prepare, RT_TIMING_LOAD_CL_PREPARE); - RT_TIMING_TIME_DIFF(time_prepare, time_java , RT_TIMING_LOAD_CL_JAVA); - RT_TIMING_TIME_DIFF(time_java , time_cache , RT_TIMING_LOAD_CL_CACHE); - - /* SUN compatible -verbose:class output */ - - if (opt_verboseclass && (c != NULL) && (c->classloader == cl)) { - printf("[Loaded "); - utf_display_printable_ascii_classname(name); - printf("]\n"); - } - -#if defined(ENABLE_JVMTI) - /* fire Class Load JVMTI event */ - if (jvmti) jvmti_ClassLoadPrepare(false, c); -#endif - - - return c; - } - - c = load_class_bootstrap(name); - - return c; -} - - -/* load_class_bootstrap ******************************************************** - - Load the class with the given name using the bootstrap class loader. - - IN: - name.............the classname - - RETURN VALUE: - loaded classinfo, or - NULL if an exception has been thrown - - SYNCHRONIZATION: - load_class_bootstrap is synchronized. It can be treated as an - atomic operation. - -*******************************************************************************/ - -classinfo *load_class_bootstrap(utf *name) -{ - classbuffer *cb; - classinfo *c; - classinfo *r; -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_lookup, time_array, time_suck, - time_load, time_cache; -#endif - - RT_TIMING_GET_TIME(time_start); - - /* for debugging */ - - assert(name); - - /* lookup if this class has already been loaded */ - - r = classcache_lookup(NULL, name); - - if (r != NULL) { - RT_TIMING_GET_TIME(time_lookup); - RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP); - - return r; - } - - RT_TIMING_GET_TIME(time_lookup); - RT_TIMING_TIME_DIFF(time_start,time_lookup,RT_TIMING_LOAD_BOOT_LOOKUP); - - /* create the classinfo */ - - c = class_create_classinfo(name); - - /* handle array classes */ - - if (name->text[0] == '[') { - c = load_newly_created_array(c, NULL); - - if (c == NULL) - return NULL; - - assert(c->state & CLASS_LOADED); - - RT_TIMING_GET_TIME(time_array); - RT_TIMING_TIME_DIFF(time_start,time_array,RT_TIMING_LOAD_BOOT_ARRAY); - - return c; - } - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getcompilingtime) - compilingtime_stop(); - - if (opt_getloadingtime) - loadingtime_start(); -#endif - - /* load classdata, throw exception on error */ - - cb = suck_start(c); - - if (cb == NULL) { - exceptions_throw_classnotfoundexception(name); - return NULL; - } - - RT_TIMING_GET_TIME(time_suck); - - /* load the class from the buffer */ - - r = load_class_from_classbuffer(cb); - - RT_TIMING_GET_TIME(time_load); - - if (r == NULL) { - /* the class could not be loaded, free the classinfo struct */ - - class_free(c); - } - else { - /* Store this class in the loaded class cache this step also - checks the loading constraints. If the class has been - loaded before, the earlier loaded class is returned. */ - - classinfo *res = classcache_store(NULL, c, true); - - if (res == NULL) { - /* exception */ - class_free(c); - } - else { - /* Add the package name to the boot packages. */ - - package_add(c->packagename); - } - - r = res; - } - - RT_TIMING_GET_TIME(time_cache); - - /* SUN compatible -verbose:class output */ - - if (opt_verboseclass && r) { - printf("[Loaded "); - utf_display_printable_ascii_classname(name); - printf(" from %s]\n", cb->path); - } - - /* free memory */ - - suck_stop(cb); - -#if defined(ENABLE_STATISTICS) - /* measure time */ - - if (opt_getloadingtime) - loadingtime_stop(); - - if (opt_getcompilingtime) - compilingtime_start(); -#endif - - RT_TIMING_TIME_DIFF(time_lookup, time_suck , RT_TIMING_LOAD_BOOT_SUCK); - RT_TIMING_TIME_DIFF(time_suck , time_load , RT_TIMING_LOAD_BOOT_LOAD); - RT_TIMING_TIME_DIFF(time_load , time_cache, RT_TIMING_LOAD_BOOT_CACHE); - RT_TIMING_TIME_DIFF(time_lookup, time_cache, RT_TIMING_LOAD_BOOT_TOTAL); - - return r; -} - - -/* load_class_from_classbuffer_intern ****************************************** - - Loads a class from a classbuffer into a given classinfo structure. - Super-classes are also loaded at this point and some verfication - checks are done. - - SYNCHRONIZATION: - This function is NOT synchronized! - -*******************************************************************************/ - -static bool load_class_from_classbuffer_intern(classbuffer *cb) -{ - classinfo *c; - classinfo *tc; - utf *name; - utf *supername; - utf **interfacesnames; - utf *u; - constant_classref *cr; - int16_t index; - - u4 i,j; - u4 ma, mi; - descriptor_pool *descpool; -#if defined(ENABLE_STATISTICS) - u4 classrefsize; - u4 descsize; -#endif -#if defined(ENABLE_RT_TIMING) - struct timespec time_start, time_checks, time_ndpool, time_cpool, - time_setup, time_fields, time_methods, time_classrefs, - time_descs, time_setrefs, time_parsefds, time_parsemds, - time_parsecpool, time_verify, time_attrs; -#endif - - RT_TIMING_GET_TIME(time_start); - - /* Get the classbuffer's class. */ - - c = cb->clazz; - - if (!suck_check_classbuffer_size(cb, 4 + 2 + 2)) - return false; - - /* check signature */ - - if (suck_u4(cb) != MAGIC) { - exceptions_throw_classformaterror(c, "Bad magic number"); - return false; - } - - /* check version */ - - mi = suck_u2(cb); - ma = suck_u2(cb); - - if (!(ma < MAJOR_VERSION || (ma == MAJOR_VERSION && mi <= MINOR_VERSION))) { - exceptions_throw_unsupportedclassversionerror(c, ma, mi); - return false; - } - - RT_TIMING_GET_TIME(time_checks); - - /* create a new descriptor pool */ - - descpool = descriptor_pool_new(c); - - RT_TIMING_GET_TIME(time_ndpool); - - /* load the constant pool */ - - if (!load_constantpool(cb, descpool)) - return false; - - RT_TIMING_GET_TIME(time_cpool); - - /* ACC flags */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* We OR the flags here, as we set already some flags in - class_create_classinfo. */ - - c->flags |= suck_u2(cb); - - /* check ACC flags consistency */ - - if (c->flags & ACC_INTERFACE) { - if (!(c->flags & ACC_ABSTRACT)) { - /* We work around this because interfaces in JDK 1.1 are - * not declared abstract. */ - - c->flags |= ACC_ABSTRACT; - } - - if (c->flags & ACC_FINAL) { - exceptions_throw_classformaterror(c, - "Illegal class modifiers: 0x%X", - c->flags); - return false; - } - - if (c->flags & ACC_SUPER) { - c->flags &= ~ACC_SUPER; /* kjc seems to set this on interfaces */ - } - } - - if ((c->flags & (ACC_ABSTRACT | ACC_FINAL)) == (ACC_ABSTRACT | ACC_FINAL)) { - exceptions_throw_classformaterror(c, - "Illegal class modifiers: 0x%X", - c->flags); - return false; - } - - if (!suck_check_classbuffer_size(cb, 2 + 2)) - return false; - - /* This class. */ - - index = suck_u2(cb); - - name = (utf *) class_getconstant(c, index, CONSTANT_Class); - - if (name == NULL) - return false; - - if (c->name == utf_not_named_yet) { - /* we finally have a name for this class */ - c->name = name; - class_set_packagename(c); - } - else if (name != c->name) { - exceptions_throw_noclassdeffounderror_wrong_name(c, name); - return false; - } - - /* Retrieve superclass. */ - - c->super = NULL; - - index = suck_u2(cb); - - if (index == 0) { - supername = NULL; - - /* This is only allowed for java.lang.Object. */ - - if (c->name != utf_java_lang_Object) { - exceptions_throw_classformaterror(c, "Bad superclass index"); - return false; - } - } - else { - supername = (utf *) class_getconstant(c, index, CONSTANT_Class); - - if (supername == NULL) - return false; - - /* java.lang.Object may not have a super class. */ - - if (c->name == utf_java_lang_Object) { - exceptions_throw_classformaterror(NULL, "java.lang.Object with superclass"); - return false; - } - - /* Detect circularity. */ - - if (supername == c->name) { - exceptions_throw_classcircularityerror(c); - return false; - } - - /* Interfaces must have java.lang.Object as super class. */ - - if ((c->flags & ACC_INTERFACE) && (supername != utf_java_lang_Object)) { - exceptions_throw_classformaterror(c, "Interfaces must have java.lang.Object as superclass"); - return false; - } - } - - /* Parse the super interfaces. */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - c->interfacescount = suck_u2(cb); - - if (!suck_check_classbuffer_size(cb, 2 * c->interfacescount)) - return false; - - c->interfaces = MNEW(classinfo*, c->interfacescount); - - /* Get the names of the super interfaces. */ - - interfacesnames = DMNEW(utf*, c->interfacescount); - - for (i = 0; i < c->interfacescount; i++) { - index = suck_u2(cb); - - u = (utf *) class_getconstant(c, index, CONSTANT_Class); - - if (u == NULL) - return false; - - interfacesnames[i] = u; - } - - RT_TIMING_GET_TIME(time_setup); - - /* Parse fields. */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - c->fieldscount = suck_u2(cb); - c->fields = MNEW(fieldinfo, c->fieldscount); - - MZERO(c->fields, fieldinfo, c->fieldscount); - - for (i = 0; i < c->fieldscount; i++) { - if (!field_load(cb, &(c->fields[i]), descpool)) - return false; - } - - RT_TIMING_GET_TIME(time_fields); - - /* Parse methods. */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - c->methodscount = suck_u2(cb); - c->methods = MNEW(methodinfo, c->methodscount); - - MZERO(c->methods, methodinfo, c->methodscount); - - for (i = 0; i < c->methodscount; i++) { - if (!method_load(cb, &(c->methods[i]), descpool)) - return false; - } - - RT_TIMING_GET_TIME(time_methods); - - /* create the class reference table */ - - c->classrefs = - descriptor_pool_create_classrefs(descpool, &(c->classrefcount)); - - RT_TIMING_GET_TIME(time_classrefs); - - /* allocate space for the parsed descriptors */ - - descriptor_pool_alloc_parsed_descriptors(descpool); - c->parseddescs = - descriptor_pool_get_parsed_descriptors(descpool, &(c->parseddescsize)); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) { - descriptor_pool_get_sizes(descpool, &classrefsize, &descsize); - count_classref_len += classrefsize; - count_parsed_desc_len += descsize; - } -#endif - - RT_TIMING_GET_TIME(time_descs); - - /* put the classrefs in the constant pool */ - - for (i = 0; i < c->cpcount; i++) { - if (c->cptags[i] == CONSTANT_Class) { - utf *name = (utf *) c->cpinfos[i]; - c->cpinfos[i] = descriptor_pool_lookup_classref(descpool, name); - } - } - - /* Resolve the super class. */ - - if (supername != NULL) { - cr = descriptor_pool_lookup_classref(descpool, supername); - - if (cr == NULL) - return false; - - /* XXX This should be done better. */ - tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false); - - if (tc == NULL) { - resolve_handle_pending_exception(true); - return false; - } - - /* Interfaces are not allowed as super classes. */ - - if (tc->flags & ACC_INTERFACE) { - exceptions_throw_incompatibleclasschangeerror(c, "class %s has interface %s as super class"); - return false; - } - - /* Don't allow extending final classes */ - - if (tc->flags & ACC_FINAL) { - exceptions_throw_verifyerror(NULL, - "Cannot inherit from final class"); - return false; - } - - /* Store the super class. */ - - c->super = tc; - } - - /* Resolve the super interfaces. */ - - for (i = 0; i < c->interfacescount; i++) { - u = interfacesnames[i]; - cr = descriptor_pool_lookup_classref(descpool, u); - - if (cr == NULL) - return false; - - /* XXX This should be done better. */ - tc = resolve_classref_or_classinfo_eager(CLASSREF_OR_CLASSINFO(cr), false); - - if (tc == NULL) { - resolve_handle_pending_exception(true); - return false; - } - - /* Detect circularity. */ - - if (tc == c) { - exceptions_throw_classcircularityerror(c); - return false; - } - - if (!(tc->flags & ACC_INTERFACE)) { - exceptions_throw_incompatibleclasschangeerror(tc, - "Implementing class"); - return false; - } - - /* Store the super interface. */ - - c->interfaces[i] = tc; - } - - RT_TIMING_GET_TIME(time_setrefs); - - /* Parse the field descriptors. */ - - for (i = 0; i < c->fieldscount; i++) { - c->fields[i].parseddesc = - descriptor_pool_parse_field_descriptor(descpool, - c->fields[i].descriptor); - if (!c->fields[i].parseddesc) - return false; - } - - RT_TIMING_GET_TIME(time_parsefds); - - /* parse method descriptors */ - - for (i = 0; i < c->methodscount; i++) { - methodinfo *m = &c->methods[i]; - m->parseddesc = - descriptor_pool_parse_method_descriptor(descpool, m->descriptor, - m->flags, class_get_self_classref(m->clazz)); - if (!m->parseddesc) - return false; - - for (j = 0; j < m->rawexceptiontablelength; j++) { - if (!m->rawexceptiontable[j].catchtype.any) - continue; - - if ((m->rawexceptiontable[j].catchtype.ref = - descriptor_pool_lookup_classref(descpool, - (utf *) m->rawexceptiontable[j].catchtype.any)) == NULL) - return false; - } - - for (j = 0; j < m->thrownexceptionscount; j++) { - if (!m->thrownexceptions[j].any) - continue; - - if ((m->thrownexceptions[j].ref = descriptor_pool_lookup_classref(descpool, - (utf *) m->thrownexceptions[j].any)) == NULL) - return false; - } - } - - RT_TIMING_GET_TIME(time_parsemds); - - /* parse the loaded descriptors */ - - for (i = 0; i < c->cpcount; i++) { - constant_FMIref *fmi; - s4 index; - - switch (c->cptags[i]) { - case CONSTANT_Fieldref: - fmi = (constant_FMIref *) c->cpinfos[i]; - fmi->parseddesc.fd = - descriptor_pool_parse_field_descriptor(descpool, - fmi->descriptor); - if (!fmi->parseddesc.fd) - return false; - - index = fmi->p.index; - fmi->p.classref = - (constant_classref *) class_getconstant(c, index, - CONSTANT_Class); - if (!fmi->p.classref) - return false; - break; - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: - fmi = (constant_FMIref *) c->cpinfos[i]; - index = fmi->p.index; - fmi->p.classref = - (constant_classref *) class_getconstant(c, index, - CONSTANT_Class); - if (!fmi->p.classref) - return false; - fmi->parseddesc.md = - descriptor_pool_parse_method_descriptor(descpool, - fmi->descriptor, - ACC_UNDEF, - fmi->p.classref); - if (!fmi->parseddesc.md) - return false; - break; - } - } - - RT_TIMING_GET_TIME(time_parsecpool); - -#ifdef ENABLE_VERIFIER - /* Check if all fields and methods can be uniquely - * identified by (name,descriptor). */ - - if (opt_verify) { - /* We use a hash table here to avoid making the - * average case quadratic in # of methods, fields. - */ - static int shift = 0; - u2 *hashtab; - u2 *next; /* for chaining colliding hash entries */ - size_t len; - size_t hashlen; - u2 index; - u2 old; - - /* Allocate hashtable */ - len = c->methodscount; - if (len < c->fieldscount) len = c->fieldscount; - hashlen = 5 * len; - hashtab = MNEW(u2,(hashlen + len)); - next = hashtab + hashlen; - - /* Determine bitshift (to get good hash values) */ - if (!shift) { - len = sizeof(utf); - while (len) { - len >>= 1; - shift++; - } - } - - /* Check fields */ - memset(hashtab, 0, sizeof(u2) * (hashlen + len)); - - for (i = 0; i < c->fieldscount; ++i) { - fieldinfo *fi = c->fields + i; - - /* It's ok if we lose bits here */ - index = ((((size_t) fi->name) + - ((size_t) fi->descriptor)) >> shift) % hashlen; - - if ((old = hashtab[index])) { - old--; - next[i] = old; - do { - if (c->fields[old].name == fi->name && - c->fields[old].descriptor == fi->descriptor) { - exceptions_throw_classformaterror(c, "Repetitive field name/signature"); - return false; - } - } while ((old = next[old])); - } - hashtab[index] = i + 1; - } - - /* Check methods */ - memset(hashtab, 0, sizeof(u2) * (hashlen + hashlen/5)); - - for (i = 0; i < c->methodscount; ++i) { - methodinfo *mi = c->methods + i; - - /* It's ok if we lose bits here */ - index = ((((size_t) mi->name) + - ((size_t) mi->descriptor)) >> shift) % hashlen; - - if ((old = hashtab[index])) { - old--; - next[i] = old; - do { - if (c->methods[old].name == mi->name && - c->methods[old].descriptor == mi->descriptor) { - exceptions_throw_classformaterror(c, "Repetitive method name/signature"); - return false; - } - } while ((old = next[old])); - } - hashtab[index] = i + 1; - } - - MFREE(hashtab, u2, (hashlen + len)); - } -#endif /* ENABLE_VERIFIER */ - - RT_TIMING_GET_TIME(time_verify); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) { - size_classinfo += sizeof(classinfo*) * c->interfacescount; - size_fieldinfo += sizeof(fieldinfo) * c->fieldscount; - size_methodinfo += sizeof(methodinfo) * c->methodscount; - } -#endif - - /* load attribute structures */ - - if (!class_load_attributes(cb)) - return false; - - /* Pre Java 1.5 version don't check this. This implementation is - like Java 1.5 do it: for class file version 45.3 we don't check - it, older versions are checked. */ - - if (((ma == 45) && (mi > 3)) || (ma > 45)) { - /* check if all data has been read */ - s4 classdata_left = ((cb->data + cb->size) - cb->pos); - - if (classdata_left > 0) { - exceptions_throw_classformaterror(c, "Extra bytes at the end of class file"); - return false; - } - } - - RT_TIMING_GET_TIME(time_attrs); - - RT_TIMING_TIME_DIFF(time_start , time_checks , RT_TIMING_LOAD_CHECKS); - RT_TIMING_TIME_DIFF(time_checks , time_ndpool , RT_TIMING_LOAD_NDPOOL); - RT_TIMING_TIME_DIFF(time_ndpool , time_cpool , RT_TIMING_LOAD_CPOOL); - RT_TIMING_TIME_DIFF(time_cpool , time_setup , RT_TIMING_LOAD_SETUP); - RT_TIMING_TIME_DIFF(time_setup , time_fields , RT_TIMING_LOAD_FIELDS); - RT_TIMING_TIME_DIFF(time_fields , time_methods , RT_TIMING_LOAD_METHODS); - RT_TIMING_TIME_DIFF(time_methods , time_classrefs , RT_TIMING_LOAD_CLASSREFS); - RT_TIMING_TIME_DIFF(time_classrefs , time_descs , RT_TIMING_LOAD_DESCS); - RT_TIMING_TIME_DIFF(time_descs , time_setrefs , RT_TIMING_LOAD_SETREFS); - RT_TIMING_TIME_DIFF(time_setrefs , time_parsefds , RT_TIMING_LOAD_PARSEFDS); - RT_TIMING_TIME_DIFF(time_parsefds , time_parsemds , RT_TIMING_LOAD_PARSEMDS); - RT_TIMING_TIME_DIFF(time_parsemds , time_parsecpool, RT_TIMING_LOAD_PARSECP); - RT_TIMING_TIME_DIFF(time_parsecpool, time_verify , RT_TIMING_LOAD_VERIFY); - RT_TIMING_TIME_DIFF(time_verify , time_attrs , RT_TIMING_LOAD_ATTRS); - RT_TIMING_TIME_DIFF(time_start , time_attrs , RT_TIMING_LOAD_TOTAL); - - return true; -} - - -/* load_class_from_classbuffer ************************************************* - - Convenience wrapper for load_class_from_classbuffer. - - SYNCHRONIZATION: - This function is NOT synchronized! - -*******************************************************************************/ - -classinfo *load_class_from_classbuffer(classbuffer *cb) -{ - classinfo *c; - bool result; - int32_t dumpmarker; - - /* Get the classbuffer's class. */ - - c = cb->clazz; - - /* Check if the class is already loaded. */ - - if (c->state & CLASS_LOADED) - return c; - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_class_loads++; -#endif - -#if !defined(NDEBUG) - if (loadverbose) - log_message_class("Loading class: ", c); -#endif - - /* Mark start of dump memory area. */ - - DMARKER; - - /* Class is currently loading. */ - - c->state |= CLASS_LOADING; - - /* Parse the classbuffer. */ - - result = load_class_from_classbuffer_intern(cb); - - /* Release dump area. */ - - DRELEASE; - - /* An error occurred. */ - - if (result == false) { - /* Revert loading state. */ - - c->state = (c->state & ~CLASS_LOADING); - - return NULL; - } - - /* Revert loading state and set loaded. */ - - c->state = (c->state & ~CLASS_LOADING) | CLASS_LOADED; - -#if defined(ENABLE_JVMTI) - /* fire Class Prepare JVMTI event */ - - if (jvmti) - jvmti_ClassLoadPrepare(true, c); -#endif - -#if !defined(NDEBUG) - if (loadverbose) - log_message_class("Loading done class: ", c); -#endif - - return c; -} - - -/* load_newly_created_array **************************************************** - - Load a newly created array class. - - RETURN VALUE: - c....................the array class C has been loaded - other classinfo......the array class was found in the class cache, - C has been freed - NULL.................an exception has been thrown - - Note: - This is an internal function. Do not use it unless you know exactly - what you are doing! - - Use one of the load_class_... functions for general array class loading. - -*******************************************************************************/ - -classinfo *load_newly_created_array(classinfo *c, classloader_t *loader) -{ - classinfo *comp = NULL; - methodinfo *clone; - methoddesc *clonedesc; - constant_classref *classrefs; - char *text; - s4 namelen; - utf *u; - - text = c->name->text; - namelen = c->name->blength; - - /* Check array class name */ - - if ((namelen < 2) || (text[0] != '[')) { - exceptions_throw_classnotfoundexception(c->name); - return NULL; - } - - /* Check the element type */ - - switch (text[1]) { - case '[': - /* c is an array of arrays. We have to create the component class. */ - - u = utf_new(text + 1, namelen - 1); - - comp = load_class_from_classloader(u, loader); - - if (comp == NULL) - return NULL; - - assert(comp->state & CLASS_LOADED); - - /* the array's flags are that of the component class */ - c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT; - c->classloader = comp->classloader; - break; - - case 'L': - /* c is an array of objects. */ - - /* check for cases like `[L;' or `[L[I;' or `[Ljava.lang.Object' */ - if ((namelen < 4) || (text[2] == '[') || (text[namelen - 1] != ';')) { - exceptions_throw_classnotfoundexception(c->name); - return NULL; - } - - u = utf_new(text + 2, namelen - 3); - - if (!(comp = load_class_from_classloader(u, loader))) - return NULL; - - assert(comp->state & CLASS_LOADED); - - /* the array's flags are that of the component class */ - c->flags = (comp->flags & ~ACC_INTERFACE) | ACC_FINAL | ACC_ABSTRACT; - c->classloader = comp->classloader; - break; - - default: - /* c is an array of a primitive type */ - - /* check for cases like `[II' and whether the character is a - valid primitive type */ - - if ((namelen > 2) || (primitive_class_get_by_char(text[1]) == NULL)) { - exceptions_throw_classnotfoundexception(c->name); - return NULL; - } - - /* the accessibility of the array class is public (VM Spec 5.3.3) */ - c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT; - c->classloader = NULL; - } - - assert(class_java_lang_Object); -#if defined(ENABLE_JAVASE) - assert(class_java_lang_Cloneable); - assert(class_java_io_Serializable); -#endif - - /* Setup the array class. */ - - c->super = class_java_lang_Object; - -#if defined(ENABLE_JAVASE) - - c->interfacescount = 2; - c->interfaces = MNEW(classinfo*, 2); - c->interfaces[0] = class_java_lang_Cloneable; - c->interfaces[1] = class_java_io_Serializable; - -#elif defined(ENABLE_JAVAME_CLDC1_1) - - c->interfacescount = 0; - c->interfaces = NULL; - -#else -# error unknow Java configuration -#endif - - c->methodscount = 1; - c->methods = MNEW(methodinfo, c->methodscount); - - MZERO(c->methods, methodinfo, c->methodscount); - - classrefs = MNEW(constant_classref, 2); - - CLASSREF_INIT(classrefs[0], c, c->name); - CLASSREF_INIT(classrefs[1], c, utf_java_lang_Object); - - /* create descriptor for clone method */ - /* we need one paramslot which is reserved for the 'this' parameter */ - clonedesc = NEW(methoddesc); - clonedesc->returntype.type = TYPE_ADR; - clonedesc->returntype.classref = classrefs + 1; - clonedesc->returntype.arraydim = 0; - /* initialize params to "empty", add real params below in - descriptor_params_from_paramtypes */ - clonedesc->paramcount = 0; - clonedesc->paramslots = 0; - clonedesc->paramtypes[0].classref = classrefs + 0; - clonedesc->params = NULL; - - /* create methodinfo */ - - clone = c->methods; - MSET(clone, 0, methodinfo, 1); - -#if defined(ENABLE_THREADS) - lock_init_object_lock(&clone->header); -#endif - - /* ATTENTION: if you delete the ACC_NATIVE below, set - clone->maxlocals=1 (interpreter related) */ - - clone->flags = ACC_PUBLIC | ACC_NATIVE; - clone->name = utf_clone; - clone->descriptor = utf_void__java_lang_Object; - clone->parseddesc = clonedesc; - clone->clazz = c; - - /* parse the descriptor to get the register allocation */ - - if (!descriptor_params_from_paramtypes(clonedesc, clone->flags)) - return false; - - clone->code = codegen_generate_stub_native(clone, BUILTIN_clone); - - /* XXX: field: length? */ - - /* array classes are not loaded from class files */ - - c->state |= CLASS_LOADED; - c->parseddescs = (u1 *) clonedesc; - c->parseddescsize = sizeof(methodinfo); - c->classrefs = classrefs; - c->classrefcount = 1; - - /* insert class into the loaded class cache */ - /* XXX free classinfo if NULL returned? */ - - return classcache_store(loader, c, true); -} - - -/* loader_close **************************************************************** - - Frees all resources. - -*******************************************************************************/ - -void loader_close(void) -{ - /* empty */ -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/loader.h b/src/vmcore/loader.h deleted file mode 100644 index faa9ba5cf..000000000 --- a/src/vmcore/loader.h +++ /dev/null @@ -1,183 +0,0 @@ -/* src/vmcore/loader.h - class loader header - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _LOADER_H -#define _LOADER_H - -/* forward typedefs ***********************************************************/ - -typedef struct classbuffer classbuffer; - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "vm/global.h" - -#include "vmcore/descriptor.h" -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/references.h" -#include "vmcore/utf8.h" - - -/* constant pool entries ******************************************************* - - All constant pool entries need a data structure which contain the entrys - value. In some cases this structure exist already, in the remaining cases - this structure must be generated: - - kind structure generated? - ---------------------------------------------------------------------- - CONSTANT_Class constant_classref yes - CONSTANT_Fieldref constant_FMIref yes - CONSTANT_Methodref constant_FMIref yes - CONSTANT_InterfaceMethodref constant_FMIref yes - CONSTANT_String unicode no - CONSTANT_Integer constant_integer yes - CONSTANT_Float constant_float yes - CONSTANT_Long constant_long yes - CONSTANT_Double constant_double yes - CONSTANT_NameAndType constant_nameandtype yes - CONSTANT_Utf8 unicode no - CONSTANT_UNUSED - - -*******************************************************************************/ - -typedef struct { /* Integer */ - s4 value; -} constant_integer; - - -typedef struct { /* Float */ - float value; -} constant_float; - - -typedef struct { /* Long */ - s8 value; -} constant_long; - - -typedef struct { /* Double */ - double value; -} constant_double; - - -typedef struct { /* NameAndType (Field or Method) */ - utf *name; /* field/method name */ - utf *descriptor; /* field/method type descriptor string */ -} constant_nameandtype; - - -/* classbuffer ****************************************************************/ - -struct classbuffer { - classinfo *clazz; /* pointer to classinfo structure */ - uint8_t *data; /* pointer to byte code */ - int32_t size; /* size of the byte code */ - uint8_t *pos; /* current read position */ - char *path; /* path to file (for debugging) */ -}; - - -/* hashtable_classloader_entry ************************************************* - - ATTENTION: The pointer to the classloader object needs to be the - first field of the entry, so that it can be used as an indirection - cell. This is checked by gc_init() during startup. - -*******************************************************************************/ - -typedef struct hashtable_classloader_entry hashtable_classloader_entry; - -struct hashtable_classloader_entry { - java_object_t *object; - hashtable_classloader_entry *hashlink; -}; - - -/* classloader ***************************************************************** - - [!ENABLE_HANDLES]: The classloader is a Java Object which cannot move. - [ENABLE_HANDLES] : The classloader entry itself is a static handle for a - given classloader (use loader_hashtable_classloader_foo). - -*******************************************************************************/ - -#if defined(ENABLE_HANDLES) -typedef hashtable_classloader_entry classloader_t; -#else -typedef java_object_t classloader_t; -#endif - - -/* function prototypes ********************************************************/ - -void loader_preinit(void); -void loader_init(void); - -/* classloader management functions */ -classloader_t *loader_hashtable_classloader_add(java_handle_t *cl); -classloader_t *loader_hashtable_classloader_find(java_handle_t *cl); - -void loader_load_all_classes(void); - -bool loader_skip_attribute_body(classbuffer *cb); - -#if defined(ENABLE_JAVASE) -bool loader_load_attribute_signature(classbuffer *cb, utf **signature); -#endif - -/* free resources */ -void loader_close(void); - -/* class loading functions */ -classinfo *load_class_from_sysloader(utf *name); -classinfo *load_class_from_classloader(utf *name, classloader_t *cl); -classinfo *load_class_bootstrap(utf *name); - -/* (don't use the following directly) */ -classinfo *load_class_from_classbuffer(classbuffer *cb); -classinfo *load_newly_created_array(classinfo *c, classloader_t *loader); - -#endif /* _LOADER_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/method.c b/src/vmcore/method.c deleted file mode 100644 index 393ad4472..000000000 --- a/src/vmcore/method.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* src/vmcore/method.c - method functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "native/llni.h" - -#include "threads/lock-common.h" - -#include "vm/array.h" -#include "vm/builtin.h" -#include "vm/exceptions.h" -#include "vm/global.h" -#include "vm/resolve.h" -#include "vm/vm.h" - -#include "vm/jit/code.h" -#include "vm/jit/methodheader.h" - -#include "vm/jit_interface.h" - -#include "vmcore/class.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/suck.h" -#include "vmcore/utf8.h" - - -#if !defined(NDEBUG) && defined(ENABLE_INLINING) -#define INLINELOG(code) do { if (opt_TraceInlining) { code } } while (0) -#else -#define INLINELOG(code) -#endif - - -/* global variables ***********************************************************/ - -methodinfo *method_java_lang_reflect_Method_invoke; - - -/* method_init ***************************************************************** - - Initialize method subsystem. - -*******************************************************************************/ - -void method_init(void) -{ -#if defined(ENABLE_JAVASE) - /* Sanity check. */ - - if (class_java_lang_reflect_Method == NULL) - vm_abort("method_init: class_java_lang_reflect_Method is NULL"); - - /* Cache java.lang.reflect.Method.invoke() */ - - method_java_lang_reflect_Method_invoke = - class_findmethod(class_java_lang_reflect_Method, utf_invoke, NULL); - - if (method_java_lang_reflect_Method_invoke == NULL) - vm_abort("method_init: Could not resolve method java.lang.reflect.Method.invoke()."); -#endif -} - - -/* method_load ***************************************************************** - - Loads a method from the class file and fills an existing methodinfo - structure. - - method_info { - u2 access_flags; - u2 name_index; - u2 descriptor_index; - u2 attributes_count; - attribute_info attributes[attribute_count]; - } - - attribute_info { - u2 attribute_name_index; - u4 attribute_length; - u1 info[attribute_length]; - } - - LineNumberTable_attribute { - u2 attribute_name_index; - u4 attribute_length; - u2 line_number_table_length; - { - u2 start_pc; - u2 line_number; - } line_number_table[line_number_table_length]; - } - -*******************************************************************************/ - -bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool) -{ - classinfo *c; - int argcount; - s4 i, j, k, l; - utf *u; - u2 name_index; - u2 descriptor_index; - u2 attributes_count; - u2 attribute_name_index; - utf *attribute_name; - u2 code_attributes_count; - u2 code_attribute_name_index; - utf *code_attribute_name; - - /* get classinfo */ - - c = cb->clazz; - - LOCK_INIT_OBJECT_LOCK(&(m->header)); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_all_methods++; -#endif - - /* all fields of m have been zeroed in load_class_from_classbuffer */ - - m->clazz = c; - - if (!suck_check_classbuffer_size(cb, 2 + 2 + 2)) - return false; - - /* access flags */ - - m->flags = suck_u2(cb); - - /* name */ - - name_index = suck_u2(cb); - - if (!(u = class_getconstant(c, name_index, CONSTANT_Utf8))) - return false; - - m->name = u; - - /* descriptor */ - - descriptor_index = suck_u2(cb); - - if (!(u = class_getconstant(c, descriptor_index, CONSTANT_Utf8))) - return false; - - m->descriptor = u; - - if (!descriptor_pool_add(descpool, u, &argcount)) - return false; - -#ifdef ENABLE_VERIFIER - if (opt_verify) { - if (!is_valid_name_utf(m->name)) { - exceptions_throw_classformaterror(c, "Method with invalid name"); - return false; - } - - if (m->name->text[0] == '<' && - m->name != utf_init && m->name != utf_clinit) { - exceptions_throw_classformaterror(c, "Method with invalid special name"); - return false; - } - } -#endif /* ENABLE_VERIFIER */ - - if (!(m->flags & ACC_STATIC)) - argcount++; /* count the 'this' argument */ - -#ifdef ENABLE_VERIFIER - if (opt_verify) { - if (argcount > 255) { - exceptions_throw_classformaterror(c, "Too many arguments in signature"); - return false; - } - - /* check flag consistency */ - if (m->name != utf_clinit) { - i = (m->flags & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED)); - - if (i != 0 && i != ACC_PUBLIC && i != ACC_PRIVATE && i != ACC_PROTECTED) { - exceptions_throw_classformaterror(c, - "Illegal method modifiers: 0x%X", - m->flags); - return false; - } - - if (m->flags & ACC_ABSTRACT) { - if ((m->flags & (ACC_FINAL | ACC_NATIVE | ACC_PRIVATE | - ACC_STATIC | ACC_STRICT | ACC_SYNCHRONIZED))) { - exceptions_throw_classformaterror(c, - "Illegal method modifiers: 0x%X", - m->flags); - return false; - } - } - - if (c->flags & ACC_INTERFACE) { - if ((m->flags & (ACC_ABSTRACT | ACC_PUBLIC)) != (ACC_ABSTRACT | ACC_PUBLIC)) { - exceptions_throw_classformaterror(c, - "Illegal method modifiers: 0x%X", - m->flags); - return false; - } - } - - if (m->name == utf_init) { - if (m->flags & (ACC_STATIC | ACC_FINAL | ACC_SYNCHRONIZED | - ACC_NATIVE | ACC_ABSTRACT)) { - exceptions_throw_classformaterror(c, "Instance initialization method has invalid flags set"); - return false; - } - } - } - } -#endif /* ENABLE_VERIFIER */ - - /* mark the method as monomorphic until further notice */ - - m->flags |= ACC_METHOD_MONOMORPHIC; - - /* non-abstract methods have an implementation in this class */ - - if (!(m->flags & ACC_ABSTRACT)) - m->flags |= ACC_METHOD_IMPLEMENTED; - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* attributes count */ - - attributes_count = suck_u2(cb); - - for (i = 0; i < attributes_count; i++) { - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* attribute name index */ - - attribute_name_index = suck_u2(cb); - - attribute_name = - class_getconstant(c, attribute_name_index, CONSTANT_Utf8); - - if (attribute_name == NULL) - return false; - - if (attribute_name == utf_Code) { - /* Code */ - - if (m->flags & (ACC_ABSTRACT | ACC_NATIVE)) { - exceptions_throw_classformaterror(c, "Code attribute in native or abstract methods"); - return false; - } - - if (m->jcode) { - exceptions_throw_classformaterror(c, "Multiple Code attributes"); - return false; - } - - if (!suck_check_classbuffer_size(cb, 4 + 2 + 2)) - return false; - - suck_u4(cb); - m->maxstack = suck_u2(cb); - m->maxlocals = suck_u2(cb); - - if (m->maxlocals < argcount) { - exceptions_throw_classformaterror(c, "Arguments can't fit into locals"); - return false; - } - - if (!suck_check_classbuffer_size(cb, 4)) - return false; - - m->jcodelength = suck_u4(cb); - - if (m->jcodelength == 0) { - exceptions_throw_classformaterror(c, "Code of a method has length 0"); - return false; - } - - if (m->jcodelength > 65535) { - exceptions_throw_classformaterror(c, "Code of a method longer than 65535 bytes"); - return false; - } - - if (!suck_check_classbuffer_size(cb, m->jcodelength)) - return false; - - m->jcode = MNEW(u1, m->jcodelength); - suck_nbytes(m->jcode, cb, m->jcodelength); - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - m->rawexceptiontablelength = suck_u2(cb); - if (!suck_check_classbuffer_size(cb, (2 + 2 + 2 + 2) * m->rawexceptiontablelength)) - return false; - - m->rawexceptiontable = MNEW(raw_exception_entry, m->rawexceptiontablelength); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) { - count_vmcode_len += m->jcodelength + 18; - count_extable_len += - m->rawexceptiontablelength * sizeof(raw_exception_entry); - } -#endif - - for (j = 0; j < m->rawexceptiontablelength; j++) { - u4 idx; - m->rawexceptiontable[j].startpc = suck_u2(cb); - m->rawexceptiontable[j].endpc = suck_u2(cb); - m->rawexceptiontable[j].handlerpc = suck_u2(cb); - - idx = suck_u2(cb); - - if (!idx) { - m->rawexceptiontable[j].catchtype.any = NULL; - } - else { - /* the classref is created later */ - if (!(m->rawexceptiontable[j].catchtype.any = - (utf *) class_getconstant(c, idx, CONSTANT_Class))) - return false; - } - } - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* code attributes count */ - - code_attributes_count = suck_u2(cb); - - for (k = 0; k < code_attributes_count; k++) { - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* code attribute name index */ - - code_attribute_name_index = suck_u2(cb); - - code_attribute_name = - class_getconstant(c, code_attribute_name_index, CONSTANT_Utf8); - - if (code_attribute_name == NULL) - return false; - - /* check which code attribute */ - - if (code_attribute_name == utf_LineNumberTable) { - /* LineNumberTable */ - - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* attribute length */ - - (void) suck_u4(cb); - - /* line number table length */ - - m->linenumbercount = suck_u2(cb); - - if (!suck_check_classbuffer_size(cb, - (2 + 2) * m->linenumbercount)) - return false; - - m->linenumbers = MNEW(lineinfo, m->linenumbercount); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - size_lineinfo += sizeof(lineinfo) * m->linenumbercount; -#endif - - for (l = 0; l < m->linenumbercount; l++) { - m->linenumbers[l].start_pc = suck_u2(cb); - m->linenumbers[l].line_number = suck_u2(cb); - } - } -#if defined(ENABLE_JAVASE) - else if (code_attribute_name == utf_StackMapTable) { - /* StackTableMap */ - - if (!stackmap_load_attribute_stackmaptable(cb, m)) - return false; - } -#endif - else { - /* unknown code attribute */ - - if (!loader_skip_attribute_body(cb)) - return false; - } - } - } - else if (attribute_name == utf_Exceptions) { - /* Exceptions */ - - if (m->thrownexceptions != NULL) { - exceptions_throw_classformaterror(c, "Multiple Exceptions attributes"); - return false; - } - - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* attribute length */ - - (void) suck_u4(cb); - - m->thrownexceptionscount = suck_u2(cb); - - if (!suck_check_classbuffer_size(cb, 2 * m->thrownexceptionscount)) - return false; - - m->thrownexceptions = MNEW(classref_or_classinfo, m->thrownexceptionscount); - - for (j = 0; j < m->thrownexceptionscount; j++) { - /* the classref is created later */ - if (!((m->thrownexceptions)[j].any = - (utf*) class_getconstant(c, suck_u2(cb), CONSTANT_Class))) - return false; - } - } -#if defined(ENABLE_JAVASE) - else if (attribute_name == utf_Signature) { - /* Signature */ - - if (!loader_load_attribute_signature(cb, &(m->signature))) - return false; - } - -#if defined(ENABLE_ANNOTATIONS) - else if (attribute_name == utf_RuntimeVisibleAnnotations) { - /* RuntimeVisibleAnnotations */ - if (!annotation_load_method_attribute_runtimevisibleannotations(cb, m)) - return false; - } - else if (attribute_name == utf_RuntimeInvisibleAnnotations) { - /* RuntimeInvisibleAnnotations */ - if (!annotation_load_method_attribute_runtimeinvisibleannotations(cb, m)) - return false; - } - else if (attribute_name == utf_RuntimeVisibleParameterAnnotations) { - /* RuntimeVisibleParameterAnnotations */ - if (!annotation_load_method_attribute_runtimevisibleparameterannotations(cb, m)) - return false; - } - else if (attribute_name == utf_RuntimeInvisibleParameterAnnotations) { - /* RuntimeInvisibleParameterAnnotations */ - if (!annotation_load_method_attribute_runtimeinvisibleparameterannotations(cb, m)) - return false; - } - else if (attribute_name == utf_AnnotationDefault) { - /* AnnotationDefault */ - if (!annotation_load_method_attribute_annotationdefault(cb, m)) - return false; - } -#endif -#endif - else { - /* unknown attribute */ - - if (!loader_skip_attribute_body(cb)) - return false; - } - } - - if ((m->jcode == NULL) && !(m->flags & (ACC_ABSTRACT | ACC_NATIVE))) { - exceptions_throw_classformaterror(c, "Missing Code attribute"); - return false; - } - -#if defined(ENABLE_REPLACEMENT) - /* initialize the hit countdown field */ - - m->hitcountdown = METHOD_INITIAL_HIT_COUNTDOWN; -#endif - - /* everything was ok */ - - return true; -} - - -/* method_free ***************************************************************** - - Frees all memory that was allocated for this method. - -*******************************************************************************/ - -void method_free(methodinfo *m) -{ - if (m->jcode) - MFREE(m->jcode, u1, m->jcodelength); - - if (m->rawexceptiontable) - MFREE(m->rawexceptiontable, raw_exception_entry, m->rawexceptiontablelength); - - code_free_code_of_method(m); - - if (m->stubroutine) { - if (m->flags & ACC_NATIVE) { - removenativestub(m->stubroutine); - - } else { - removecompilerstub(m->stubroutine); - } - } -} - - -/* method_canoverwrite ********************************************************* - - Check if m and old are identical with respect to type and - name. This means that old can be overwritten with m. - -*******************************************************************************/ - -bool method_canoverwrite(methodinfo *m, methodinfo *old) -{ - if (m->name != old->name) - return false; - - if (m->descriptor != old->descriptor) - return false; - - if (m->flags & ACC_STATIC) - return false; - - return true; -} - - -/* method_new_builtin ********************************************************** - - Creates a minimal methodinfo structure for builtins. This comes handy - when dealing with builtin stubs or stacktraces. - -*******************************************************************************/ - -methodinfo *method_new_builtin(builtintable_entry *bte) -{ - methodinfo *m; - - /* allocate the methodinfo structure */ - - m = NEW(methodinfo); - - /* initialize methodinfo structure */ - - MZERO(m, methodinfo, 1); - LOCK_INIT_OBJECT_LOCK(&(m->header)); - - m->flags = ACC_METHOD_BUILTIN; - m->parseddesc = bte->md; - m->name = bte->name; - m->descriptor = bte->descriptor; - - /* return the newly created methodinfo */ - - return m; -} - - -/* method_vftbl_lookup ********************************************************* - - Does a method lookup in the passed virtual function table. This - function does exactly the same thing as JIT, but additionally - relies on the fact, that the methodinfo pointer is at the first - data segment slot (even for compiler stubs). - -*******************************************************************************/ - -methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m) -{ - methodptr mptr; - methodptr *pmptr; - methodinfo *resm; /* pointer to new resolved method */ - - /* If the method is not an instance method, just return it. */ - - if (m->flags & ACC_STATIC) - return m; - - assert(vftbl); - - /* Get the method from the virtual function table. Is this an - interface method? */ - - if (m->clazz->flags & ACC_INTERFACE) { - pmptr = vftbl->interfacetable[-(m->clazz->index)]; - mptr = pmptr[(m - m->clazz->methods)]; - } - else { - mptr = vftbl->table[m->vftblindex]; - } - - /* and now get the codeinfo pointer from the first data segment slot */ - - resm = code_get_methodinfo_for_pv(mptr); - - return resm; -} - - -/* method_get_parametercount ************************************************** - - Use the descriptor of a method to determine the number of parameters - of the method. The this pointer of non-static methods is not counted. - - IN: - m........the method of which the parameters should be counted - - RETURN VALUE: - The parameter count or -1 on error. - -*******************************************************************************/ - -int32_t method_get_parametercount(methodinfo *m) -{ - methoddesc *md; /* method descriptor of m */ - int32_t paramcount = 0; /* the parameter count of m */ - - md = m->parseddesc; - - /* is the descriptor fully parsed? */ - - if (md->params == NULL) { - if (!descriptor_params_from_paramtypes(md, m->flags)) { - return -1; - } - } - - paramcount = md->paramcount; - - /* skip `this' pointer */ - - if (!(m->flags & ACC_STATIC)) { - --paramcount; - } - - return paramcount; -} - - -/* method_get_parametertypearray *********************************************** - - Use the descriptor of a method to generate a java.lang.Class array - which contains the classes of the parametertypes of the method. - - This function is called by java.lang.reflect.{Constructor,Method}. - -*******************************************************************************/ - -java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m) -{ - methoddesc *md; - typedesc *paramtypes; - int32_t paramcount; - java_handle_objectarray_t *oa; - int32_t i; - classinfo *c; - - md = m->parseddesc; - - /* is the descriptor fully parsed? */ - - if (m->parseddesc->params == NULL) - if (!descriptor_params_from_paramtypes(md, m->flags)) - return NULL; - - paramtypes = md->paramtypes; - paramcount = md->paramcount; - - /* skip `this' pointer */ - - if (!(m->flags & ACC_STATIC)) { - paramtypes++; - paramcount--; - } - - /* create class-array */ - - oa = builtin_anewarray(paramcount, class_java_lang_Class); - - if (oa == NULL) - return NULL; - - /* get classes */ - - for (i = 0; i < paramcount; i++) { - if (!resolve_class_from_typedesc(¶mtypes[i], true, false, &c)) - return NULL; - - LLNI_array_direct(oa, i) = (java_object_t *) c; - } - - return oa; -} - - -/* method_get_exceptionarray *************************************************** - - Get the exceptions which can be thrown by a method. - -*******************************************************************************/ - -java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m) -{ - java_handle_objectarray_t *oa; - classinfo *c; - s4 i; - - /* create class-array */ - - oa = builtin_anewarray(m->thrownexceptionscount, class_java_lang_Class); - - if (oa == NULL) - return NULL; - - /* iterate over all exceptions and store the class in the array */ - - for (i = 0; i < m->thrownexceptionscount; i++) { - c = resolve_classref_or_classinfo_eager(m->thrownexceptions[i], true); - - if (c == NULL) - return NULL; - - LLNI_array_direct(oa, i) = (java_object_t *) c; - } - - return oa; -} - - -/* method_returntype_get ******************************************************* - - Get the return type of the method. - -*******************************************************************************/ - -classinfo *method_returntype_get(methodinfo *m) -{ - typedesc *td; - classinfo *c; - - td = &(m->parseddesc->returntype); - - if (!resolve_class_from_typedesc(td, true, false, &c)) - return NULL; - - return c; -} - - -/* method_count_implementations ************************************************ - - Count the implementations of a method in a class cone (a class and all its - subclasses.) - - IN: - m................the method to count - c................class at which to start the counting (this class and - all its subclasses will be searched) - - OUT: - *found...........if found != NULL, *found receives the method - implementation that was found. This value is only - meaningful if the return value is 1. - - RETURN VALUE: - the number of implementations found - -*******************************************************************************/ - -s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found) -{ - s4 count; - methodinfo *mp; - methodinfo *mend; - classinfo *child; - - count = 0; - - mp = c->methods; - mend = mp + c->methodscount; - - for (; mp < mend; ++mp) { - if (method_canoverwrite(mp, m)) { - if (found) - *found = mp; - count++; - break; - } - } - - for (child = c->sub; child != NULL; child = child->nextsub) { - count += method_count_implementations(m, child, found); - } - - return count; -} - - -/* method_get_annotations ****************************************************** - - Get a methods' unparsed annotations in a byte array. - - IN: - m........the method of which the annotations should be returned - - RETURN VALUE: - The unparsed annotations in a byte array (or NULL if there aren't any). - -*******************************************************************************/ - -java_handle_bytearray_t *method_get_annotations(methodinfo *m) -{ -#if defined(ENABLE_ANNOTATIONS) - classinfo *c; /* methods' declaring class */ - int slot; /* methods' slot */ - java_handle_t *annotations; /* methods' unparsed annotations */ - java_handle_t *method_annotations; /* all methods' unparsed annotations */ - /* of the declaring class */ - - c = m->clazz; - slot = m - c->methods; - annotations = NULL; - - LLNI_classinfo_field_get(c, method_annotations, method_annotations); - - /* the method_annotations array might be shorter then the method - * count if the methods above a certain index have no annotations. - */ - if (method_annotations != NULL && - array_length_get(method_annotations) > slot) { - annotations = array_objectarray_element_get( - (java_handle_objectarray_t*)method_annotations, slot); - } - - return (java_handle_bytearray_t*)annotations; -#else - return NULL; -#endif -} - - -/* method_get_parameterannotations ******************************************** - - Get a methods' unparsed parameter annotations in an array of byte - arrays. - - IN: - m........the method of which the parameter annotations should be - returned - - RETURN VALUE: - The unparsed parameter annotations in a byte array (or NULL if - there aren't any). - -*******************************************************************************/ - -java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m) -{ -#if defined(ENABLE_ANNOTATIONS) - classinfo *c; /* methods' declaring class */ - int slot; /* methods' slot */ - java_handle_t *parameterAnnotations; /* methods' unparsed */ - /* parameter annotations */ - java_handle_t *method_parameterannotations; /* all methods' unparsed */ - /* parameter annotations of */ - /* the declaring class */ - - c = m->clazz; - slot = m - c->methods; - parameterAnnotations = NULL; - - LLNI_classinfo_field_get( - c, method_parameterannotations, method_parameterannotations); - - /* the method_annotations array might be shorter then the method - * count if the methods above a certain index have no annotations. - */ - if (method_parameterannotations != NULL && - array_length_get(method_parameterannotations) > slot) { - parameterAnnotations = array_objectarray_element_get( - (java_handle_objectarray_t*)method_parameterannotations, - slot); - } - - return (java_handle_bytearray_t*)parameterAnnotations; -#else - return NULL; -#endif -} - - -/* method_get_annotationdefault *********************************************** - - Get a methods' unparsed annotation default value in a byte array. - - IN: - m........the method of which the annotation default value should be - returned - - RETURN VALUE: - The unparsed annotation default value in a byte array (or NULL if - there isn't one). - -*******************************************************************************/ - -java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m) -{ -#if defined(ENABLE_ANNOTATIONS) - classinfo *c; /* methods' declaring class */ - int slot; /* methods' slot */ - java_handle_t *annotationDefault; /* methods' unparsed */ - /* annotation default value */ - java_handle_t *method_annotationdefaults; /* all methods' unparsed */ - /* annotation default values of */ - /* the declaring class */ - - c = m->clazz; - slot = m - c->methods; - annotationDefault = NULL; - - LLNI_classinfo_field_get( - c, method_annotationdefaults, method_annotationdefaults); - - /* the method_annotations array might be shorter then the method - * count if the methods above a certain index have no annotations. - */ - if (method_annotationdefaults != NULL && - array_length_get(method_annotationdefaults) > slot) { - annotationDefault = array_objectarray_element_get( - (java_handle_objectarray_t*)method_annotationdefaults, slot); - } - - return (java_handle_bytearray_t*)annotationDefault; -#else - return NULL; -#endif -} - - -/* method_add_to_worklist ****************************************************** - - Add the method to the given worklist. If the method already occurs in - the worklist, the worklist remains unchanged. - -*******************************************************************************/ - -static void method_add_to_worklist(methodinfo *m, method_worklist **wl) -{ - method_worklist *wi; - - for (wi = *wl; wi != NULL; wi = wi->next) - if (wi->m == m) - return; - - wi = NEW(method_worklist); - wi->next = *wl; - wi->m = m; - - *wl = wi; -} - - -/* method_add_assumption_monomorphic ******************************************* - - Record the assumption that the method is monomorphic. - - IN: - m.................the method - caller............the caller making the assumption - -*******************************************************************************/ - -void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller) -{ - method_assumption *as; - - /* XXX LOCKING FOR THIS FUNCTION? */ - - /* check if we already have registered this assumption */ - - for (as = m->assumptions; as != NULL; as = as->next) { - if (as->context == caller) - return; - } - - /* register the assumption */ - - as = NEW(method_assumption); - as->next = m->assumptions; - as->context = caller; - - m->assumptions = as; -} - - -/* method_break_assumption_monomorphic ***************************************** - - Break the assumption that this method is monomorphic. All callers that - have registered this assumption are added to the worklist. - - IN: - m.................the method - wl................worklist where to add invalidated callers - -*******************************************************************************/ - -void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl) -{ - method_assumption *as; - - /* XXX LOCKING FOR THIS FUNCTION? */ - - for (as = m->assumptions; as != NULL; as = as->next) { - INLINELOG( - printf("ASSUMPTION BROKEN (monomorphism): "); - method_print(m); - printf(" in "); - method_println(as->context); - ); - - method_add_to_worklist(as->context, wl); - } -} - - -/* method_printflags *********************************************************** - - Prints the flags of a method to stdout like. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void method_printflags(methodinfo *m) -{ - if (m == NULL) { - printf("NULL"); - return; - } - - if (m->flags & ACC_PUBLIC) printf(" PUBLIC"); - if (m->flags & ACC_PRIVATE) printf(" PRIVATE"); - if (m->flags & ACC_PROTECTED) printf(" PROTECTED"); - if (m->flags & ACC_STATIC) printf(" STATIC"); - if (m->flags & ACC_FINAL) printf(" FINAL"); - if (m->flags & ACC_SYNCHRONIZED) printf(" SYNCHRONIZED"); - if (m->flags & ACC_VOLATILE) printf(" VOLATILE"); - if (m->flags & ACC_TRANSIENT) printf(" TRANSIENT"); - if (m->flags & ACC_NATIVE) printf(" NATIVE"); - if (m->flags & ACC_INTERFACE) printf(" INTERFACE"); - if (m->flags & ACC_ABSTRACT) printf(" ABSTRACT"); - if (m->flags & ACC_METHOD_BUILTIN) printf(" (builtin)"); - if (m->flags & ACC_METHOD_MONOMORPHIC) printf(" (mono)"); - if (m->flags & ACC_METHOD_IMPLEMENTED) printf(" (impl)"); -} -#endif /* !defined(NDEBUG) */ - - -/* method_print **************************************************************** - - Prints a method to stdout like: - - java.lang.Object.()V - -*******************************************************************************/ - -#if !defined(NDEBUG) -void method_print(methodinfo *m) -{ - if (m == NULL) { - printf("NULL"); - return; - } - - if (m->clazz != NULL) - utf_display_printable_ascii_classname(m->clazz->name); - else - printf("NULL"); - printf("."); - utf_display_printable_ascii(m->name); - utf_display_printable_ascii(m->descriptor); - - method_printflags(m); -} -#endif /* !defined(NDEBUG) */ - - -/* method_println ************************************************************** - - Prints a method plus new line to stdout like: - - java.lang.Object.()V - -*******************************************************************************/ - -#if !defined(NDEBUG) -void method_println(methodinfo *m) -{ - if (opt_debugcolor) printf("\033[31m"); /* red */ - method_print(m); - if (opt_debugcolor) printf("\033[m"); - printf("\n"); -} -#endif /* !defined(NDEBUG) */ - - -/* method_methodref_print ****************************************************** - - Prints a method reference to stdout. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void method_methodref_print(constant_FMIref *mr) -{ - if (!mr) { - printf("(constant_FMIref *)NULL"); - return; - } - - if (IS_FMIREF_RESOLVED(mr)) { - printf(" "); - method_print(mr->p.method); - } - else { - printf(" "); - utf_display_printable_ascii_classname(mr->p.classref->name); - printf("."); - utf_display_printable_ascii(mr->name); - utf_display_printable_ascii(mr->descriptor); - } -} -#endif /* !defined(NDEBUG) */ - - -/* method_methodref_println **************************************************** - - Prints a method reference to stdout, followed by a newline. - -*******************************************************************************/ - -#if !defined(NDEBUG) -void method_methodref_println(constant_FMIref *mr) -{ - method_methodref_print(mr); - printf("\n"); -} -#endif /* !defined(NDEBUG) */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/method.h b/src/vmcore/method.h deleted file mode 100644 index ff28286f4..000000000 --- a/src/vmcore/method.h +++ /dev/null @@ -1,222 +0,0 @@ -/* src/vmcore/method.h - method functions header - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _METHOD_H -#define _METHOD_H - -/* forward typedefs ***********************************************************/ - -typedef struct methodinfo methodinfo; -typedef struct raw_exception_entry raw_exception_entry; -typedef struct lineinfo lineinfo; -typedef struct method_assumption method_assumption; -typedef struct method_worklist method_worklist; -typedef struct codeinfo codeinfo; - -#include "config.h" -#include "vm/types.h" - -#include "vm/builtin.h" -#include "vm/global.h" - -#include "vmcore/descriptor.h" -#include "vmcore/references.h" -#include "vmcore/linker.h" -#include "vmcore/loader.h" - -#if defined(ENABLE_JAVASE) -# include "vmcore/stackmap.h" -#endif - -#include "vmcore/utf8.h" - - -#if defined(ENABLE_REPLACEMENT) -/* Initial value for the hit countdown field of each method. */ -#define METHOD_INITIAL_HIT_COUNTDOWN 1000 -#endif - - -/* methodinfo *****************************************************************/ - -struct methodinfo { /* method structure */ - java_object_t header; /* we need this in jit's monitorenter */ - s4 flags; /* ACC flags */ - utf *name; /* name of method */ - utf *descriptor; /* JavaVM descriptor string of method */ -#if defined(ENABLE_JAVASE) - utf *signature; /* Signature attribute */ - stack_map_t *stack_map; /* StackMapTable attribute */ -#endif - - methoddesc *parseddesc; /* parsed descriptor */ - - classinfo *clazz; /* class, the method belongs to */ - s4 vftblindex; /* index of method in virtual function */ - /* table (if it is a virtual method) */ - s4 maxstack; /* maximum stack depth of method */ - s4 maxlocals; /* maximum number of local variables */ - s4 jcodelength; /* length of JavaVM code */ - u1 *jcode; /* pointer to JavaVM code */ - - s4 rawexceptiontablelength; /* exceptiontable length */ - raw_exception_entry *rawexceptiontable; /* the exceptiontable */ - - u2 thrownexceptionscount; /* number of exceptions attribute */ - classref_or_classinfo *thrownexceptions; /* except. a method may throw */ - - u2 linenumbercount; /* number of linenumber attributes */ - lineinfo *linenumbers; /* array of lineinfo items */ - - u1 *stubroutine; /* stub for compiling or calling natives */ - codeinfo *code; /* current code of this method */ - -#if defined(ENABLE_LSRA) - s4 maxlifetimes; /* helper for lsra */ -#endif - - methodinfo *overwrites; /* method that is directly overwritten */ - method_assumption *assumptions; /* list of assumptions about this method */ - -#if defined(ENABLE_REPLACEMENT) - s4 hitcountdown; /* decreased for each hit */ -#endif - -#if defined(ENABLE_DEBUG_FILTER) - u1 filtermatches; /* flags indicating which filters the method matches */ -#endif - -#if defined(ENABLE_ESCAPE) - u1 *paramescape; -#endif -}; - -/* method_assumption *********************************************************** - - This struct is used for registering assumptions about methods. - -*******************************************************************************/ - -struct method_assumption { - method_assumption *next; - methodinfo *context; -}; - - -/* method_worklist ************************************************************* - - List node used for method worklists. - -*******************************************************************************/ - -struct method_worklist { - method_worklist *next; - methodinfo *m; -}; - - -/* raw_exception_entry ********************************************************/ - -/* exception table entry read by the loader */ - -struct raw_exception_entry { /* exceptiontable entry in a method */ - classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall) */ - u2 startpc; /* start pc of guarded area (inclusive) */ - u2 endpc; /* end pc of guarded area (exklusive) */ - u2 handlerpc; /* pc of exception handler */ -}; - - -/* lineinfo *******************************************************************/ - -struct lineinfo { - u2 start_pc; - u2 line_number; -}; - - -/* global variables ***********************************************************/ - -extern methodinfo *method_java_lang_reflect_Method_invoke; - - -/* inline functions ***********************************************************/ - -inline static bool method_is_builtin(methodinfo* m) -{ - return m->flags & ACC_METHOD_BUILTIN; -} - - -/* function prototypes ********************************************************/ - -void method_init(void); - -bool method_load(classbuffer *cb, methodinfo *m, descriptor_pool *descpool); -void method_free(methodinfo *m); -bool method_canoverwrite(methodinfo *m, methodinfo *old); - -methodinfo *method_new_builtin(builtintable_entry *bte); - -methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m); - -int32_t method_get_parametercount(methodinfo *m); -java_handle_objectarray_t *method_get_parametertypearray(methodinfo *m); -java_handle_objectarray_t *method_get_exceptionarray(methodinfo *m); -classinfo *method_returntype_get(methodinfo *m); - -void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller); -void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl); - -s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found); - -java_handle_bytearray_t *method_get_annotations(methodinfo *m); -java_handle_bytearray_t *method_get_parameterannotations(methodinfo *m); -java_handle_bytearray_t *method_get_annotationdefault(methodinfo *m); - -#if !defined(NDEBUG) -void method_printflags(methodinfo *m); -void method_print(methodinfo *m); -void method_println(methodinfo *m); -void method_methodref_print(constant_FMIref *mr); -void method_methodref_println(constant_FMIref *mr); -#endif - -#endif /* _METHOD_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/options.c b/src/vmcore/options.c deleted file mode 100644 index e9ae46fbc..000000000 --- a/src/vmcore/options.c +++ /dev/null @@ -1,838 +0,0 @@ -/* src/vmcore/options.c - contains global options - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include - -#include "mm/memory.h" - -#include "native/jni.h" - -#include "vm/vm.h" - -#include "vmcore/options.h" -#include "vmcore/system.h" - - -/* command line option ********************************************************/ - -s4 opt_index = 0; /* index of processed arguments */ -char *opt_arg; /* this one exports the option argument */ - -bool opt_foo = false; /* option for development */ - -bool opt_jar = false; - -#if defined(ENABLE_JIT) -bool opt_jit = true; /* JIT mode execution (default) */ -bool opt_intrp = false; /* interpreter mode execution */ -#else -bool opt_jit = false; /* JIT mode execution */ -bool opt_intrp = true; /* interpreter mode execution (default) */ -#endif - -bool opt_run = true; - -s4 opt_heapmaxsize = 0; /* maximum heap size */ -s4 opt_heapstartsize = 0; /* initial heap size */ -s4 opt_stacksize = 0; /* thread stack size */ - -bool opt_verbose = false; -bool opt_debugcolor = false; /* use ANSI terminal sequences */ -bool compileall = false; - -bool loadverbose = false; -bool initverbose = false; - -bool opt_verboseclass = false; -bool opt_verbosegc = false; -bool opt_verbosejni = false; -bool opt_verbosecall = false; /* trace all method invocation */ - -bool showmethods = false; -bool showconstantpool = false; -bool showutf = false; - -char *opt_method = NULL; -char *opt_signature = NULL; - -bool compileverbose = false; /* trace compiler actions */ -bool showstack = false; - -bool opt_showdisassemble = false; /* generate disassembler listing */ -bool opt_shownops = false; -bool opt_showddatasegment = false; /* generate data segment listing */ -bool opt_showintermediate = false; /* generate intermediate code listing */ - -bool checkbounds = true; /* check array bounds */ -bool opt_noieee = false; /* don't implement ieee compliant floats */ -bool checksync = true; /* do synchronization */ -#if defined(ENABLE_LOOP) -bool opt_loops = false; /* optimize array accesses in loops */ -#endif - -bool makeinitializations = true; - -#if defined(ENABLE_STATISTICS) -bool opt_stat = false; -bool opt_getloadingtime = false; /* to measure the runtime */ -bool opt_getcompilingtime = false; /* compute compile time */ -#endif -#if defined(ENABLE_VERIFIER) -bool opt_verify = true; /* true if classfiles should be verified */ -#endif - -#if defined(ENABLE_PROFILING) -bool opt_prof = false; -bool opt_prof_bb = false; -#endif - - -/* optimization options *******************************************************/ - -#if defined(ENABLE_IFCONV) -bool opt_ifconv = false; -#endif - -#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) -bool opt_lsra = false; -#endif -#if defined(ENABLE_SSA) -bool opt_ssa_dce = false; /* enable dead code elemination */ -bool opt_ssa_cp = false; /* enable copy propagation */ -#endif - - -/* interpreter options ********************************************************/ - -#if defined(ENABLE_INTRP) -bool opt_no_dynamic = false; /* suppress dynamic superinstructions */ -bool opt_no_replication = false; /* don't use replication in intrp */ -bool opt_no_quicksuper = false; /* instructions for quickening cannot be - part of dynamic superinstructions */ - -s4 opt_static_supers = 0x7fffffff; -bool vm_debug = false; /* XXX this should be called `opt_trace' */ -#endif - -#if defined(ENABLE_DEBUG_FILTER) -const char *opt_filter_verbosecall_include = 0; -const char *opt_filter_verbosecall_exclude = 0; -const char *opt_filter_show_method = 0; -#endif - - -/* -XX options ****************************************************************/ - -/* NOTE: For better readability keep these alpha-sorted. */ - -/* Options which must always be available (production options in - HotSpot). */ - -int64_t opt_MaxDirectMemorySize = -1; -int opt_MaxPermSize = 0; -int opt_PermSize = 0; -int opt_ThreadStackSize = 0; - -/* Debugging options which can be turned off. */ - -int opt_DebugExceptions = 0; -int opt_DebugFinalizer = 0; -int opt_DebugLocalReferences = 0; -int opt_DebugLocks = 0; -int opt_DebugPackage = 0; -int opt_DebugPatcher = 0; -int opt_DebugProperties = 0; -int opt_DebugStackFrameInfo = 0; -int opt_DebugStackTrace = 0; -int opt_DebugThreads = 0; -#if defined(ENABLE_DISASSEMBLER) -int opt_DisassembleStubs = 0; -#endif -#if defined(ENABLE_GC_CACAO) -int opt_GCDebugRootSet = 0; -int opt_GCStress = 0; -#endif -#if defined(ENABLE_INLINING) -int opt_Inline = 0; -#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) -int opt_InlineAll = 0; -int opt_InlineCount = INT_MAX; -int opt_InlineMaxSize = INT_MAX; -int opt_InlineMinSize = 0; -#endif -#endif -int opt_PrintConfig = 0; -int opt_ProfileGCMemoryUsage = 0; -int opt_ProfileMemoryUsage = 0; -FILE *opt_ProfileMemoryUsageGNUPlot = NULL; -#if defined(ENABLE_REPLACEMENT) -int opt_TestReplacement = 0; -#endif -int opt_TraceCompilerCalls = 0; -int opt_TraceExceptions = 0; -int opt_TraceHPI = 0; -#if defined(ENABLE_INLINING) && !defined(NDEBUG) -int opt_TraceInlining = 0; -#endif -int opt_TraceJavaCalls = 0; -int opt_TraceJNICalls = 0; -int opt_TraceJVMCalls = 0; -int opt_TraceJVMCallsVerbose = 0; -int opt_TraceLinkClass = 0; -#if defined(ENABLE_REPLACEMENT) -int opt_TraceReplacement = 0; -#endif -int opt_TraceSubsystemInitialization = 0; -int opt_TraceTraps = 0; - - -enum { - OPT_TYPE_BOOLEAN, - OPT_TYPE_VALUE -}; - -enum { - /* Options which must always be available (production options in - HotSpot). */ - - OPT_MaxDirectMemorySize, - OPT_MaxPermSize, - OPT_PermSize, - OPT_ThreadStackSize, - - /* Debugging options which can be turned off. */ - - OPT_DebugExceptions, - OPT_DebugFinalizer, - OPT_DebugLocalReferences, - OPT_DebugLocks, - OPT_DebugPackage, - OPT_DebugPatcher, - OPT_DebugProperties, - OPT_DebugStackFrameInfo, - OPT_DebugStackTrace, - OPT_DebugThreads, - OPT_DisassembleStubs, - OPT_GCDebugRootSet, - OPT_GCStress, - OPT_Inline, - OPT_InlineAll, - OPT_InlineCount, - OPT_InlineMaxSize, - OPT_InlineMinSize, - OPT_PrintConfig, - OPT_ProfileGCMemoryUsage, - OPT_ProfileMemoryUsage, - OPT_ProfileMemoryUsageGNUPlot, - OPT_TestReplacement, - OPT_TraceCompilerCalls, - OPT_TraceExceptions, - OPT_TraceHPI, - OPT_TraceInlining, - OPT_TraceJavaCalls, - OPT_TraceJNICalls, - OPT_TraceJVMCalls, - OPT_TraceJVMCallsVerbose, - OPT_TraceLinkClass, - OPT_TraceReplacement, - OPT_TraceSubsystemInitialization, - OPT_TraceTraps, - OPT_Vmlog, - OPT_VmlogStrings, - OPT_VmlogIgnore -}; - - -option_t options_XX[] = { - /* Options which must always be available (production options in - HotSpot). */ - - { "MaxDirectMemorySize", OPT_MaxDirectMemorySize, OPT_TYPE_VALUE, "Maximum total size of NIO direct-buffer allocations" }, - { "MaxPermSize", OPT_MaxPermSize, OPT_TYPE_VALUE, "not implemented" }, - { "PermSize", OPT_PermSize, OPT_TYPE_VALUE, "not implemented" }, - { "ThreadStackSize", OPT_ThreadStackSize, OPT_TYPE_VALUE, "TODO" }, - - /* Debugging options which can be turned off. */ - - { "DebugExceptions", OPT_DebugExceptions, OPT_TYPE_BOOLEAN, "debug exceptions" }, - { "DebugFinalizer", OPT_DebugFinalizer, OPT_TYPE_BOOLEAN, "debug finalizer thread" }, - { "DebugLocalReferences", OPT_DebugLocalReferences, OPT_TYPE_BOOLEAN, "print debug information for local reference tables" }, - { "DebugLocks", OPT_DebugLocks, OPT_TYPE_BOOLEAN, "print debug information for locks" }, - { "DebugPackage", OPT_DebugPackage, OPT_TYPE_BOOLEAN, "debug Java boot-packages" }, - { "DebugPatcher", OPT_DebugPatcher, OPT_TYPE_BOOLEAN, "debug JIT code patching" }, - { "DebugProperties", OPT_DebugProperties, OPT_TYPE_BOOLEAN, "print debug information for properties" }, - { "DebugStackFrameInfo", OPT_DebugStackFrameInfo, OPT_TYPE_BOOLEAN, "TODO" }, - { "DebugStackTrace", OPT_DebugStackTrace, OPT_TYPE_BOOLEAN, "debug stacktrace creation" }, - { "DebugThreads", OPT_DebugThreads, OPT_TYPE_BOOLEAN, "print debug information for threads" }, -#if defined(ENABLE_DISASSEMBLER) - { "DisassembleStubs", OPT_DisassembleStubs, OPT_TYPE_BOOLEAN, "disassemble builtin and native stubs when generated" }, -#endif -#if defined(ENABLE_GC_CACAO) - { "GCDebugRootSet", OPT_GCDebugRootSet, OPT_TYPE_BOOLEAN, "GC: print root-set at collection" }, - { "GCStress", OPT_GCStress, OPT_TYPE_BOOLEAN, "GC: forced collection at every allocation" }, -#endif -#if defined(ENABLE_INLINING) - { "Inline", OPT_Inline, OPT_TYPE_BOOLEAN, "enable method inlining" }, -#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) - { "InlineAll", OPT_InlineAll, OPT_TYPE_BOOLEAN, "use inlining in all compilations" }, - { "InlineCount", OPT_InlineCount, OPT_TYPE_VALUE, "stop inlining after the given number of roots" }, - { "InlineMaxSize", OPT_InlineMaxSize, OPT_TYPE_VALUE, "maximum size for inlined result" }, - { "InlineMinSize", OPT_InlineMinSize, OPT_TYPE_VALUE, "minimum size for inlined result" }, -#endif -#endif - { "PrintConfig", OPT_PrintConfig, OPT_TYPE_BOOLEAN, "print VM configuration" }, - { "ProfileGCMemoryUsage", OPT_ProfileGCMemoryUsage, OPT_TYPE_VALUE, "profiles GC memory usage in the given interval, is in seconds (default: 5)" }, - { "ProfileMemoryUsage", OPT_ProfileMemoryUsage, OPT_TYPE_VALUE, "TODO" }, - { "ProfileMemoryUsageGNUPlot", OPT_ProfileMemoryUsageGNUPlot, OPT_TYPE_VALUE, "TODO" }, -#if defined(ENABLE_REPLACEMENT) - { "TestReplacement", OPT_TestReplacement, OPT_TYPE_BOOLEAN, "activate all replacement points during code generation" }, -#endif - { "TraceCompilerCalls", OPT_TraceCompilerCalls, OPT_TYPE_BOOLEAN, "trace JIT compiler calls" }, - { "TraceExceptions", OPT_TraceExceptions, OPT_TYPE_BOOLEAN, "trace Exception throwing" }, - { "TraceHPI", OPT_TraceHPI, OPT_TYPE_BOOLEAN, "Trace Host Porting Interface (HPI)" }, -#if defined(ENABLE_INLINING) && !defined(NDEBUG) - { "TraceInlining", OPT_TraceInlining, OPT_TYPE_VALUE, "trace method inlining with the given verbosity level (default: 1)" }, -#endif -#if !defined(ENABLE_VMLOG) - { "TraceJavaCalls", OPT_TraceJavaCalls, OPT_TYPE_BOOLEAN, "trace Java method calls" }, -#endif - { "TraceJNICalls", OPT_TraceJNICalls, OPT_TYPE_BOOLEAN, "trace JNI method calls" }, - { "TraceJVMCalls", OPT_TraceJVMCalls, OPT_TYPE_BOOLEAN, "trace JVM method calls but omit very frequent ones" }, - { "TraceJVMCallsVerbose", OPT_TraceJVMCallsVerbose, OPT_TYPE_BOOLEAN, "trace all JVM method calls" }, - { "TraceLinkClass", OPT_TraceLinkClass, OPT_TYPE_BOOLEAN, "trace class linking" }, -#if defined(ENABLE_REPLACEMENT) - { "TraceReplacement", OPT_TraceReplacement, OPT_TYPE_VALUE, "trace on-stack replacement with the given verbosity level (default: 1)" }, -#endif - { "TraceSubsystemInitialization", OPT_TraceSubsystemInitialization, OPT_TYPE_BOOLEAN, "trace initialization of subsystems" }, - { "TraceTraps", OPT_TraceTraps, OPT_TYPE_BOOLEAN, "trace traps generated by JIT code" }, -#if defined(ENABLE_VMLOG) - { "Vmlog", OPT_Vmlog, OPT_TYPE_VALUE, "prefix for vmlog trace files (enables vmlog)" }, - { "VmlogStrings", OPT_VmlogStrings, OPT_TYPE_VALUE, "prefix of vmlog string file to load" }, - { "VmlogIgnore", OPT_VmlogIgnore, OPT_TYPE_VALUE, "prefix of vmlog ignore file to load" }, -#endif - - /* end marker */ - - { NULL, -1, -1, NULL } -}; - - -/* options_get ***************************************************************** - - DOCUMENT ME!!! - -*******************************************************************************/ - -int options_get(opt_struct *opts, JavaVMInitArgs *vm_args) -{ - char *option; - int i; - - if (opt_index >= vm_args->nOptions) - return OPT_DONE; - - /* get the current option */ - - option = vm_args->options[opt_index].optionString; - - if ((option == NULL) || (option[0] != '-')) - return OPT_DONE; - - for (i = 0; opts[i].name; i++) { - if (!opts[i].arg) { - /* boolean option found */ - - if (strcmp(option + 1, opts[i].name) == 0) { - opt_index++; - return opts[i].value; - } - - } else { - /* parameter option found */ - - /* with a space between */ - - if (strcmp(option + 1, opts[i].name) == 0) { - opt_index++; - - if (opt_index < vm_args->nOptions) { - opt_arg = system_strdup(vm_args->options[opt_index].optionString); - opt_index++; - return opts[i].value; - } - - return OPT_ERROR; - - } else { - /* parameter and option have no space between */ - - /* FIXME: this assumption is plain wrong, hits you if there is a - * parameter with no argument starting with same letter as param with argument - * but named after that one, ouch! */ - - size_t l = system_strlen(opts[i].name); - - if (system_strlen(option + 1) > l) { - if (memcmp(option + 1, opts[i].name, l) == 0) { - opt_index++; - opt_arg = system_strdup(option + 1 + l); - return opts[i].value; - } - } - } - } - } - - return OPT_ERROR; -} - - -/* options_xxusage ************************************************************* - - Print usage message for debugging options. - -*******************************************************************************/ - -static void options_xxusage(void) -{ - option_t *opt; - int length; - int i; - char *c; - - /* Prevent compiler warning. */ - - length = 0; - - for (opt = options_XX; opt->name != NULL; opt++) { - printf(" -XX:"); - - switch (opt->type) { - case OPT_TYPE_BOOLEAN: - printf("+%s", opt->name); - length = system_strlen(" -XX:+") + system_strlen(opt->name); - break; - - case OPT_TYPE_VALUE: - printf("%s=", opt->name); - length = system_strlen(" -XX:") + system_strlen(opt->name) + - system_strlen("="); - break; - - default: - vm_abort("options_xxusage: unkown option type %d", opt->type); - } - - /* Check if the help fits into one 80-column line. - Documentation starts at column 29. */ - - if (length < (29 - 1)) { - /* Print missing spaces up to column 29. */ - - for (i = length; i < 29; i++) - printf(" "); - } - else { - printf("\n"); - printf(" "); /* 29 spaces */ - } - - /* Check documentation length. */ - - length = system_strlen(opt->doc); - - if (length < (80 - 29)) { - printf("%s", opt->doc); - } - else { - for (c = opt->doc, i = 29; *c != 0; c++, i++) { - /* If we are at the end of the line, break it. */ - - if (i == 80) { - printf("\n"); - printf(" "); /* 29 spaces */ - i = 29; - } - - printf("%c", *c); - } - } - - printf("\n"); - } - - /* exit with error code */ - - exit(1); -} - - -/* options_xx ****************************************************************** - - Handle -XX: options. - -*******************************************************************************/ - -void options_xx(JavaVMInitArgs *vm_args) -{ - const char *name; - const char *start; - char *end; - int length; - int enable; - char *value; - option_t *opt; - char *filename; - FILE *file; - int i; - - /* Iterate over all passed options. */ - - for (i = 0; i < vm_args->nOptions; i++) { - /* Get the current option. */ - - name = vm_args->options[i].optionString; - - /* Check for help (-XX). */ - - if (strcmp(name, "-XX") == 0) - options_xxusage(); - - /* Check if the option start with -XX. */ - - start = strstr(name, "-XX:"); - - if ((start == NULL) || (start != name)) - continue; - - /* Check if the option is a boolean option. */ - - if (name[4] == '+') { - start = name + 4 + 1; - enable = 1; - } - else if (name[4] == '-') { - start = name + 4 + 1; - enable = 0; - } - else { - start = name + 4; - enable = -1; - } - - /* Search for a '=' in the option name and get the option name - length and the value of the option. */ - - end = strchr(start, '='); - - if (end == NULL) { - length = system_strlen(start); - value = NULL; - } - else { - length = end - start; - value = end + 1; - } - - /* Search the option in the option array. */ - - for (opt = options_XX; opt->name != NULL; opt++) { - if (strncmp(opt->name, start, length) == 0) { - /* Check if the options passed fits to the type. */ - - switch (opt->type) { - case OPT_TYPE_BOOLEAN: - if ((enable == -1) || (value != NULL)) - options_xxusage(); - break; - case OPT_TYPE_VALUE: - if ((enable != -1) || (value == NULL)) - options_xxusage(); - break; - default: - vm_abort("options_xx: unknown option type %d for option %s", - opt->type, opt->name); - } - - break; - } - } - - /* Process the option. */ - - switch (opt->value) { - - /* Options which must always be available (production options - in HotSpot). */ - - case OPT_MaxDirectMemorySize: - opt_MaxDirectMemorySize = system_atoi(value); - break; - - case OPT_MaxPermSize: - /* Currently ignored. */ - break; - - case OPT_PermSize: - /* Currently ignored. */ - break; - - case OPT_ThreadStackSize: - /* currently ignored */ - break; - - /* Debugging options which can be turned off. */ - - case OPT_DebugExceptions: - opt_DebugExceptions = enable; - break; - - case OPT_DebugFinalizer: - opt_DebugFinalizer = enable; - break; - - case OPT_DebugLocalReferences: - opt_DebugLocalReferences = enable; - break; - - case OPT_DebugLocks: - opt_DebugLocks = enable; - break; - - case OPT_DebugPackage: - opt_DebugPackage = enable; - break; - - case OPT_DebugPatcher: - opt_DebugPatcher = enable; - break; - - case OPT_DebugProperties: - opt_DebugProperties = enable; - break; - - case OPT_DebugStackFrameInfo: - opt_DebugStackFrameInfo = enable; - break; - - case OPT_DebugStackTrace: - opt_DebugStackTrace = enable; - break; - - case OPT_DebugThreads: - opt_DebugThreads = enable; - break; - -#if defined(ENABLE_DISASSEMBLER) - case OPT_DisassembleStubs: - opt_DisassembleStubs = enable; - break; -#endif - -#if defined(ENABLE_GC_CACAO) - case OPT_GCDebugRootSet: - opt_GCDebugRootSet = enable; - break; - - case OPT_GCStress: - opt_GCStress = enable; - break; -#endif - -#if defined(ENABLE_INLINING) - case OPT_Inline: - opt_Inline = enable; - break; -#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) - case OPT_InlineAll: - opt_InlineAll = enable; - break; - - case OPT_InlineCount: - if (value != NULL) - opt_InlineCount = system_atoi(value); - break; - - case OPT_InlineMaxSize: - if (value != NULL) - opt_InlineMaxSize = system_atoi(value); - break; - - case OPT_InlineMinSize: - if (value != NULL) - opt_InlineMinSize = system_atoi(value); - break; -#endif -#endif - - case OPT_PrintConfig: - opt_PrintConfig = enable; - break; - - case OPT_ProfileGCMemoryUsage: - if (value == NULL) - opt_ProfileGCMemoryUsage = 5; - else - opt_ProfileGCMemoryUsage = system_atoi(value); - break; - - case OPT_ProfileMemoryUsage: - if (value == NULL) - opt_ProfileMemoryUsage = 5; - else - opt_ProfileMemoryUsage = system_atoi(value); - -# if defined(ENABLE_STATISTICS) - /* we also need statistics */ - - opt_stat = true; -# endif - break; - - case OPT_ProfileMemoryUsageGNUPlot: - if (value == NULL) - filename = "profile.dat"; - else - filename = value; - - file = fopen(filename, "w"); - - if (file == NULL) - vm_abort_errno("options_xx: fopen failed"); - - opt_ProfileMemoryUsageGNUPlot = file; - break; - -#if defined(ENABLE_REPLACEMENT) - case OPT_TestReplacement: - opt_TestReplacement = enable; - break; -#endif - - case OPT_TraceCompilerCalls: - opt_TraceCompilerCalls = enable; - break; - - case OPT_TraceExceptions: - opt_TraceExceptions = enable; - break; - - case OPT_TraceHPI: - opt_TraceHPI = enable; - break; - -#if defined(ENABLE_INLINING) && !defined(NDEBUG) - case OPT_TraceInlining: - if (value == NULL) - opt_TraceInlining = 1; - else - opt_TraceInlining = system_atoi(value); - break; -#endif - - case OPT_TraceJavaCalls: - opt_verbosecall = enable; - opt_TraceJavaCalls = enable; - break; - - case OPT_TraceJNICalls: - opt_TraceJNICalls = enable; - break; - - case OPT_TraceJVMCalls: - opt_TraceJVMCalls = enable; - break; - - case OPT_TraceJVMCallsVerbose: - opt_TraceJVMCallsVerbose = enable; - break; - - case OPT_TraceLinkClass: - opt_TraceLinkClass = enable; - break; - -#if defined(ENABLE_REPLACEMENT) - case OPT_TraceReplacement: - if (value == NULL) - opt_TraceReplacement = 1; - else - opt_TraceReplacement = system_atoi(value); - break; -#endif - - case OPT_TraceSubsystemInitialization: - opt_TraceSubsystemInitialization = enable; - break; - - case OPT_TraceTraps: - opt_TraceTraps = enable; - break; - -#if defined(ENABLE_VMLOG) - case OPT_Vmlog: - if (value == NULL) - vmlog_cacao_set_prefix("vmlog"); - else - vmlog_cacao_set_prefix(value); - opt_verbosecall = 1; - opt_TraceJavaCalls = 1; - break; - - case OPT_VmlogStrings: - if (value != NULL) - vmlog_cacao_set_stringprefix(value); - break; - - case OPT_VmlogIgnore: - if (value != NULL) - vmlog_cacao_set_ignoreprefix(value); - break; -#endif - - default: - printf("Unknown -XX option: %s\n", name); - break; - } - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/options.h b/src/vmcore/options.h deleted file mode 100644 index ca4e09666..000000000 --- a/src/vmcore/options.h +++ /dev/null @@ -1,268 +0,0 @@ -/* src/vmcore/options.h - define global options extern - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _OPTIONS_H -#define _OPTIONS_H - - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "native/jni.h" - -#include "vm/global.h" - - -/* reserved option numbers ****************************************************/ - -/* define these negative since the other options are an enum */ - -#define OPT_DONE -1 -#define OPT_ERROR -2 -#define OPT_IGNORE -3 - - -typedef struct opt_struct opt_struct; - -struct opt_struct { - char *name; - bool arg; - int value; -}; - - -typedef struct option_t option_t; - -struct option_t { - char *name; - int value; - int type; - char *doc; -}; - - -/* global variables ***********************************************************/ - -extern s4 opt_index; -extern char *opt_arg; - -extern bool opt_foo; - -extern bool opt_jit; -extern bool opt_intrp; - -extern bool opt_jar; -extern bool opt_run; - -extern s4 opt_heapmaxsize; -extern s4 opt_heapstartsize; -extern s4 opt_stacksize; - -extern bool opt_verbose; -extern bool opt_debugcolor; -extern bool compileall; - -extern bool loadverbose; /* Print debug messages during loading */ -extern bool initverbose; /* Log class initialization */ - -extern bool opt_verboseclass; -extern bool opt_verbosegc; -extern bool opt_verbosejni; -extern bool opt_verbosecall; - -extern bool showmethods; -extern bool showconstantpool; -extern bool showutf; - -extern char *opt_method; -extern char *opt_signature; - -extern bool compileverbose; -extern bool showstack; - -extern bool opt_showdisassemble; -extern bool opt_shownops; -extern bool opt_showddatasegment; -extern bool opt_showintermediate; - -extern bool checkbounds; -extern bool opt_noieee; -extern bool checksync; -#if defined(ENABLE_LOOP) -extern bool opt_loops; -#endif - -extern bool makeinitializations; - -#if defined(ENABLE_STATISTICS) -extern bool opt_stat; -extern bool opt_getloadingtime; -extern bool opt_getcompilingtime; -#endif -#if defined(ENABLE_VERIFIER) -extern bool opt_verify; -#endif - -#if defined(ENABLE_PROFILING) -extern bool opt_prof; -extern bool opt_prof_bb; -#endif - -/* optimization options *******************************************************/ - -#if defined(ENABLE_IFCONV) -extern bool opt_ifconv; -#endif - -#if defined(ENABLE_LSRA) || defined(ENABLE_SSA) -extern bool opt_lsra; -#endif -#if defined(ENABLE_SSA) -extern bool opt_ssa_dce; /* enable dead code elemination */ -extern bool opt_ssa_cp; /* enable copy propagation */ -#endif - -/* interpreter options ********************************************************/ - -#if defined(ENABLE_INTRP) -extern bool opt_no_dynamic; -extern bool opt_no_replication; -extern bool opt_no_quicksuper; - -extern s4 opt_static_supers; -extern bool vm_debug; -#endif - -/* debug output filtering options *********************************************/ - -#if defined(ENABLE_DEBUG_FILTER) -extern const char *opt_filter_verbosecall_include; -extern const char *opt_filter_verbosecall_exclude; -extern const char *opt_filter_show_method; -#endif - - -/* -XX options ****************************************************************/ - -/* NOTE: For better readability keep these alpha-sorted. */ - -/* Options which must always be available (production options in - HotSpot). */ - -extern int64_t opt_MaxDirectMemorySize; -extern int opt_MaxPermSize; -extern int opt_PermSize; -extern int opt_ThreadStackSize; - -/* Debugging options which can be turned off. */ - -extern int opt_DebugExceptions; -extern int opt_DebugFinalizer; -extern int opt_DebugLocalReferences; -extern int opt_DebugLocks; -extern int opt_DebugPatcher; -extern int opt_DebugPackage; -extern int opt_DebugProperties; -extern int opt_DebugStackFrameInfo; -extern int opt_DebugStackTrace; -extern int opt_DebugThreads; -#if defined(ENABLE_DISASSEMBLER) -extern int opt_DisassembleStubs; -#endif -#if defined(ENABLE_GC_CACAO) -extern int opt_GCDebugRootSet; -extern int opt_GCStress; -#endif -#if defined(ENABLE_INLINING) -extern int opt_Inline; -#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) -extern int opt_InlineAll; -extern int opt_InlineCount; -extern int opt_InlineMaxSize; -extern int opt_InlineMinSize; -#endif -#endif -extern int opt_PrintConfig; -extern int opt_ProfileGCMemoryUsage; -extern int opt_ProfileMemoryUsage; -extern FILE *opt_ProfileMemoryUsageGNUPlot; -#if defined(ENABLE_REPLACEMENT) -extern int opt_TestReplacement; -#endif -extern int opt_TraceCompilerCalls; -extern int opt_TraceExceptions; -extern int opt_TraceHPI; -#if defined(ENABLE_INLINING) && !defined(NDEBUG) -extern int opt_TraceInlining; -#endif -extern int opt_TraceJavaCalls; -extern int opt_TraceJNICalls; -extern int opt_TraceJVMCalls; -extern int opt_TraceJVMCallsVerbose; -extern int opt_TraceLinkClass; -#if defined(ENABLE_REPLACEMENT) -extern int opt_TraceReplacement; -#endif -extern int opt_TraceSubsystemInitialization; -extern int opt_TraceTraps; - - -/* function prototypes ********************************************************/ - -int options_get(opt_struct *opts, JavaVMInitArgs *vm_args); -void options_xx(JavaVMInitArgs *vm_args); - - -/* debug **********************************************************************/ - -#if !defined(NDEBUG) -# define TRACESUBSYSTEMINITIALIZATION(text) \ - do { \ - if (opt_TraceSubsystemInitialization) { \ - log_println("[Initializing subsystem: %s]", text); \ - } \ - } while (0) -#else -# define TRACESUBSYSTEMINITIALIZATION(text) -#endif - -#endif /* _OPTIONS_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/primitivecore.c b/src/vmcore/primitivecore.c deleted file mode 100644 index d55da764f..000000000 --- a/src/vmcore/primitivecore.c +++ /dev/null @@ -1,244 +0,0 @@ -/* src/vmcore/primitivecore.c - core functions for primitive types - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/global.h" -#include "vm/primitive.h" -#include "vm/vm.h" - -#include "vmcore/class.h" -#include "vmcore/options.h" -#include "vmcore/utf8.h" - - -/* primitivetype_table ********************************************************* - - Structure for primitive classes: contains the class for wrapping - the primitive type, the primitive class, the name of the class for - wrapping, the one character type signature and the name of the - primitive class. - - CAUTION: Don't change the order of the types. This table is indexed - by the ARRAYTYPE_ constants (except ARRAYTYPE_OBJECT). - -*******************************************************************************/ - -primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT] = { - { "int" , NULL, NULL, NULL, "java/lang/Integer", 'I', "[I", NULL }, - { "long" , NULL, NULL, NULL, "java/lang/Long", 'J', "[J", NULL }, - { "float" , NULL, NULL, NULL, "java/lang/Float", 'F', "[F", NULL }, - { "double" , NULL, NULL, NULL, "java/lang/Double", 'D', "[D", NULL }, - { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, - { "byte" , NULL, NULL, NULL, "java/lang/Byte", 'B', "[B", NULL }, - { "char" , NULL, NULL, NULL, "java/lang/Character", 'C', "[C", NULL }, - { "short" , NULL, NULL, NULL, "java/lang/Short", 'S', "[S", NULL }, - { "boolean" , NULL, NULL, NULL, "java/lang/Boolean", 'Z', "[Z", NULL }, - { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, -#if defined(ENABLE_JAVASE) - { "void" , NULL, NULL, NULL, "java/lang/Void", 'V', NULL, NULL } -#else - { NULL , NULL, NULL, NULL, NULL, 0 , NULL, NULL }, -#endif -}; - - -/* primitive_init ************************************************************** - - Fill the primitive type table with the primitive-type classes, - array-classes and wrapper classes. This is important in the VM - startup. - - We split this primitive-type table initialization because of - annotations in the bootstrap classes. - - But we may get a problem if we have annotations in: - - java/lang/Object - java/lang/Cloneable - java/io/Serializable - - Also see: loader_preinit and linker_preinit. - -*******************************************************************************/ - -void primitive_init(void) -{ - utf *name; - classinfo *c; - utf *u; - classinfo *ac; - int i; - - TRACESUBSYSTEMINITIALIZATION("primitive_init"); - - /* Load and link primitive-type classes and array-classes. */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) { - /* Skip dummy entries. */ - - if (primitivetype_table[i].cname == NULL) - continue; - - /* create UTF-8 name */ - - name = utf_new_char(primitivetype_table[i].cname); - - primitivetype_table[i].name = name; - - /* create primitive class */ - - c = class_create_classinfo(name); - - /* Primitive type classes don't have a super class. */ - - c->super = NULL; - - /* set flags and mark it as primitive class */ - - c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT | ACC_CLASS_PRIMITIVE; - - /* prevent loader from loading primitive class */ - - c->state |= CLASS_LOADED; - - /* INFO: don't put primitive classes into the classcache */ - - if (!link_class(c)) - vm_abort("linker_init: linking failed"); - - /* Just to be sure. */ - - assert(c->state & CLASS_LOADED); - assert(c->state & CLASS_LINKED); - - primitivetype_table[i].class_primitive = c; - - /* Create primitive array class. */ - - if (primitivetype_table[i].arrayname != NULL) { - u = utf_new_char(primitivetype_table[i].arrayname); - ac = class_create_classinfo(u); - ac = load_newly_created_array(ac, NULL); - - if (ac == NULL) - vm_abort("primitive_init: loading failed"); - - assert(ac->state & CLASS_LOADED); - - if (!link_class(ac)) - vm_abort("primitive_init: linking failed"); - - /* Just to be sure. */ - - assert(ac->state & CLASS_LOADED); - assert(ac->state & CLASS_LINKED); - - primitivetype_table[i].arrayclass = ac; - } - } - - /* We use two for-loops to have the array-classes already in the - primitive-type table (hint: annotations in wrapper-classes). */ - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) { - /* Skip dummy entries. */ - - if (primitivetype_table[i].cname == NULL) - continue; - - /* Create class for wrapping the primitive type. */ - - u = utf_new_char(primitivetype_table[i].wrapname); - c = load_class_bootstrap(u); - - if (c == NULL) - vm_abort("primitive_init: loading failed"); - - if (!link_class(c)) - vm_abort("primitive_init: linking failed"); - - /* Just to be sure. */ - - assert(c->state & CLASS_LOADED); - assert(c->state & CLASS_LINKED); - - primitivetype_table[i].class_wrap = c; - } -} - - -/* primitive_postinit ********************************************************** - - Finish the primitive-type table initialization. In this step we - set the vftbl of the primitive-type classes. - - This is necessary because java/lang/Class is loaded and linked - after the primitive types have been linked. - - We have to do that in an extra function, as the primitive types are - not stored in the classcache. - -*******************************************************************************/ - -void primitive_postinit(void) -{ - classinfo *c; - int i; - - TRACESUBSYSTEMINITIALIZATION("primitive_postinit"); - - assert(class_java_lang_Class); - assert(class_java_lang_Class->vftbl); - - for (i = 0; i < PRIMITIVETYPE_COUNT; i++) { - /* Skip dummy entries. */ - - if (primitivetype_table[i].cname == NULL) - continue; - - c = primitivetype_table[i].class_primitive; - - c->object.header.vftbl = class_java_lang_Class->vftbl; - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/references.h b/src/vmcore/references.h deleted file mode 100644 index 6ac233618..000000000 --- a/src/vmcore/references.h +++ /dev/null @@ -1,168 +0,0 @@ -/* src/vmcore/references.h - references to classes/fields/methods - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - -#ifndef _REFERENCES_H_ -#define _REFERENCES_H_ - -/* forward typedefs ***********************************************************/ - -typedef struct constant_classref constant_classref; -typedef struct constant_FMIref constant_FMIref; - - -/* constant_classref **********************************************************/ - -struct constant_classref { - void *pseudo_vftbl; /* for distinguishing it from classinfo */ - struct classinfo *referer; /* class containing the reference */ - struct utf *name; /* name of the class refered to */ -}; - - -/* classref_or_classinfo ******************************************************/ - -typedef union classref_or_classinfo { - constant_classref *ref; /* a symbolic class reference */ - struct classinfo *cls; /* an already loaded class */ - void *any; /* used for general access (x != NULL,...) */ -} classref_or_classinfo; - - -/* parseddesc_t ***************************************************************/ - -typedef union parseddesc { - struct typedesc *fd; /* parsed field descriptor */ - struct methoddesc *md; /* parsed method descriptor */ - void *any; /* used for simple test against NULL */ -} parseddesc_t; - - -#include "config.h" -#include "vm/types.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/descriptor.h" -#include "vmcore/field.h" -#include "vmcore/method.h" -#include "vmcore/utf8.h" - - -/*----------------------------------------------------------------------------*/ -/* References */ -/* */ -/* This header files defines the following types used for references to */ -/* classes/methods/fields and descriptors: */ -/* */ -/* classinfo * a loaded class */ -/* constant_classref a symbolic reference */ -/* classref_or_classinfo a loaded class or a symbolic reference */ -/* */ -/* constant_FMIref a symb. ref. to a field/method/intf.method */ -/* */ -/* typedesc * describes a field type */ -/* methoddesc * descrives a method type */ -/* parseddesc describes a field type or a method type */ -/*----------------------------------------------------------------------------*/ - -/* structs ********************************************************************/ - -/* constant_FMIref ************************************************************/ - -struct constant_FMIref{ /* Fieldref, Methodref and InterfaceMethodref */ - union { - s4 index; /* used only within the loader */ - constant_classref *classref; /* class having this field/meth./intfm. */ - fieldinfo *field; /* resolved field */ - methodinfo *method; /* resolved method */ - } p; - utf *name; /* field/method/interfacemethod name */ - utf *descriptor; /* field/method/intfmeth. type descriptor string */ - parseddesc_t parseddesc; /* parsed descriptor */ -}; - - -/* macros *********************************************************************/ - -/* a value that never occurrs in classinfo.header.vftbl */ -#define CLASSREF_PSEUDO_VFTBL ((void *) 1) - -/* macro for testing if a classref_or_classinfo is a classref */ -/* `reforinfo` is only evaluated once */ -#define IS_CLASSREF(reforinfo) \ - ((reforinfo).ref->pseudo_vftbl == CLASSREF_PSEUDO_VFTBL) - -/* macro for testing if a constant_FMIref has been resolved */ -/* `fmiref` is only evaluated once */ -#define IS_FMIREF_RESOLVED(fmiref) \ - ((fmiref)->p.classref->pseudo_vftbl != CLASSREF_PSEUDO_VFTBL) - -/* the same as IS_CLASSREF, but also check against NULL */ -#define IS_XCLASSREF(reforinfo) \ - ((reforinfo).any && IS_CLASSREF(reforinfo)) - -/* macro for casting a classref/classinfo * to a classref_or_classinfo */ -#define CLASSREF_OR_CLASSINFO(value) \ - (*((classref_or_classinfo *)(&(value)))) - -/* macro for accessing the name of a classref/classinfo */ -#define CLASSREF_OR_CLASSINFO_NAME(value) \ - (IS_CLASSREF(value) ? (value).ref->name : (value).cls->name) - -/* macro for accessing the class name of a method reference */ -#define METHODREF_CLASSNAME(fmiref) \ - (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.method->clazz->name \ - : (fmiref)->p.classref->name) - -/* macro for accessing the class name of a method reference */ -#define FIELDREF_CLASSNAME(fmiref) \ - (IS_FMIREF_RESOLVED(fmiref) ? (fmiref)->p.field->clazz->name \ - : (fmiref)->p.classref->name) - -/* initialize a constant_classref with referer `ref` and name `classname` */ - -#define CLASSREF_INIT(c,ref,classname) \ - do { \ - (c).pseudo_vftbl = CLASSREF_PSEUDO_VFTBL; \ - (c).referer = (ref); \ - (c).name = (classname); \ - } while (0) - -#endif /* _REFERENCES_H_ */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ - diff --git a/src/vmcore/rt-timing.c b/src/vmcore/rt-timing.c deleted file mode 100644 index 7e535bef0..000000000 --- a/src/vmcore/rt-timing.c +++ /dev/null @@ -1,195 +0,0 @@ -/* src/vmcore/rt-timing.c - POSIX real-time timing utilities - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "vm/global.h" - -#include "vmcore/rt-timing.h" - - -struct rt_timing_stat { - int index; - int totalindex; - const char *name; -}; - -static struct rt_timing_stat rt_timing_stat_defs[] = { - { RT_TIMING_JIT_CHECKS ,RT_TIMING_JIT_TOTAL , "checks at beginning" }, - { RT_TIMING_JIT_PARSE ,RT_TIMING_JIT_TOTAL , "parse" }, - { RT_TIMING_JIT_STACK ,RT_TIMING_JIT_TOTAL , "analyse_stack" }, - { RT_TIMING_JIT_TYPECHECK ,RT_TIMING_JIT_TOTAL , "typecheck" }, - { RT_TIMING_JIT_LOOP ,RT_TIMING_JIT_TOTAL , "loop" }, - { RT_TIMING_JIT_IFCONV ,RT_TIMING_JIT_TOTAL , "if conversion" }, - { RT_TIMING_JIT_ALLOC ,RT_TIMING_JIT_TOTAL , "register allocation" }, - { RT_TIMING_JIT_RPLPOINTS ,RT_TIMING_JIT_TOTAL , "replacement point generation" }, - { RT_TIMING_JIT_CODEGEN ,RT_TIMING_JIT_TOTAL , "codegen" }, - { RT_TIMING_JIT_TOTAL ,-1 , "total compile time" }, - { -1 ,-1 , "" }, - - { RT_TIMING_LINK_RESOLVE ,RT_TIMING_LINK_TOTAL, "link: resolve superclass/superinterfaces"}, - { RT_TIMING_LINK_C_VFTBL ,RT_TIMING_LINK_TOTAL, "link: compute vftbl length"}, - { RT_TIMING_LINK_ABSTRACT ,RT_TIMING_LINK_TOTAL, "link: handle abstract methods"}, - { RT_TIMING_LINK_C_IFTBL ,RT_TIMING_LINK_TOTAL, "link: compute interface table"}, - { RT_TIMING_LINK_F_VFTBL ,RT_TIMING_LINK_TOTAL, "link: fill vftbl"}, - { RT_TIMING_LINK_OFFSETS ,RT_TIMING_LINK_TOTAL, "link: set offsets"}, - { RT_TIMING_LINK_F_IFTBL ,RT_TIMING_LINK_TOTAL, "link: fill interface table"}, - { RT_TIMING_LINK_FINALIZER ,RT_TIMING_LINK_TOTAL, "link: set finalizer"}, - { RT_TIMING_LINK_EXCEPTS ,RT_TIMING_LINK_TOTAL, "link: resolve exception classes"}, - { RT_TIMING_LINK_SUBCLASS ,RT_TIMING_LINK_TOTAL, "link: re-calculate subclass indices"}, - { RT_TIMING_LINK_TOTAL ,-1 , "total link time" }, - { -1 ,-1 , "" }, - - { RT_TIMING_LOAD_CHECKS ,RT_TIMING_LOAD_TOTAL, "load: initial checks"}, - { RT_TIMING_LOAD_NDPOOL ,RT_TIMING_LOAD_TOTAL, "load: new descriptor pool"}, - { RT_TIMING_LOAD_CPOOL ,RT_TIMING_LOAD_TOTAL, "load: load constant pool"}, - { RT_TIMING_LOAD_SETUP ,RT_TIMING_LOAD_TOTAL, "load: class setup"}, - { RT_TIMING_LOAD_FIELDS ,RT_TIMING_LOAD_TOTAL, "load: load fields"}, - { RT_TIMING_LOAD_METHODS ,RT_TIMING_LOAD_TOTAL, "load: load methods"}, - { RT_TIMING_LOAD_CLASSREFS ,RT_TIMING_LOAD_TOTAL, "load: create classrefs"}, - { RT_TIMING_LOAD_DESCS ,RT_TIMING_LOAD_TOTAL, "load: allocate descriptors"}, - { RT_TIMING_LOAD_SETREFS ,RT_TIMING_LOAD_TOTAL, "load: set classrefs"}, - { RT_TIMING_LOAD_PARSEFDS ,RT_TIMING_LOAD_TOTAL, "load: parse field descriptors"}, - { RT_TIMING_LOAD_PARSEMDS ,RT_TIMING_LOAD_TOTAL, "load: parse method descriptors"}, - { RT_TIMING_LOAD_PARSECP ,RT_TIMING_LOAD_TOTAL, "load: parse descriptors in constant pool"}, - { RT_TIMING_LOAD_VERIFY ,RT_TIMING_LOAD_TOTAL, "load: verifier checks"}, - { RT_TIMING_LOAD_ATTRS ,RT_TIMING_LOAD_TOTAL, "load: load attributes"}, - { RT_TIMING_LOAD_TOTAL ,-1 , "total load time (from classbuffer)"}, - { -1 ,-1 , "" }, - - { RT_TIMING_LOAD_BOOT_LOOKUP,-1 , "boot: lookup in classcache"}, - { RT_TIMING_LOAD_BOOT_ARRAY ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load array classes"}, - { RT_TIMING_LOAD_BOOT_SUCK ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: suck class files"}, - { RT_TIMING_LOAD_BOOT_LOAD ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: load from class buffer"}, - { RT_TIMING_LOAD_BOOT_CACHE ,RT_TIMING_LOAD_BOOT_TOTAL, "boot: store in classcache"}, - { RT_TIMING_LOAD_BOOT_TOTAL ,-1 , "total bootstrap loader time"}, - { -1 ,-1 , "" }, - - { RT_TIMING_LOAD_CL_LOOKUP ,-1 , "classloader: lookup in classcache" }, - { RT_TIMING_LOAD_CL_PREPARE ,-1 , "classloader: prepare loader call" }, - { RT_TIMING_LOAD_CL_JAVA ,-1 , "classloader: loader Java code" }, - { RT_TIMING_LOAD_CL_CACHE ,-1 , "classloader: store in classcache" }, - { -1 ,-1 , "" }, - - { RT_TIMING_NEW_OBJECT ,-1 , "builtin_new time" }, - { RT_TIMING_NEW_ARRAY ,-1 , "builtin_newarray time" }, - { -1 ,-1 , "" }, - - { RT_TIMING_GC_ALLOC ,-1 , "heap allocation time" }, -#if defined(ENABLE_GC_CACAO) - { RT_TIMING_GC_SUSPEND ,RT_TIMING_GC_TOTAL , "gc: suspending threads" }, - { RT_TIMING_GC_ROOTSET1 ,RT_TIMING_GC_TOTAL , "gc: rootset finding" }, - { RT_TIMING_GC_MARK ,RT_TIMING_GC_TOTAL , "gc: marking phase" }, - { RT_TIMING_GC_COMPACT ,RT_TIMING_GC_TOTAL , "gc: compaction phase" }, - { RT_TIMING_GC_ROOTSET2 ,RT_TIMING_GC_TOTAL , "gc: rootset writeback" }, - { RT_TIMING_GC_TOTAL ,-1 , "total garbage collection time" }, - { -1 ,-1 , "" }, -#endif - - { 0 ,-1 , NULL } -}; - -static long long rt_timing_sum[RT_TIMING_N] = { 0 }; - -void rt_timing_gettime(struct timespec *ts) -{ - if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,ts) != 0) { - fprintf(stderr,"could not get time by clock_gettime: %s\n",strerror(errno)); - abort(); - } -} - -long rt_timing_diff_usec(struct timespec *a,struct timespec *b) -{ - long diff; - time_t atime; - - diff = (b->tv_nsec - a->tv_nsec) / 1000; - atime = a->tv_sec; - while (atime < b->tv_sec) { - atime++; - diff += 1000000; - } - return diff; -} - -void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index) -{ - long diff; - - diff = rt_timing_diff_usec(a,b); - rt_timing_sum[index] += diff; -} - -void rt_timing_print_time_stats(FILE *file) -{ - struct rt_timing_stat *stats; - double total; - - for (stats = rt_timing_stat_defs; stats->name; ++stats) { - if (stats->index < 0) { - fprintf(file,"%s\n",stats->name); - continue; - } - - if (stats->totalindex >= 0) { - total = rt_timing_sum[stats->totalindex]; - fprintf(file,"%12lld usec %3.0f%% %s\n", - rt_timing_sum[stats->index], - (total != 0.0) ? rt_timing_sum[stats->index] / total * 100.0 : 0.0, - stats->name); - } - else { - fprintf(file,"%12lld usec %s\n", - rt_timing_sum[stats->index], - stats->name); - } - } -} - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/rt-timing.h b/src/vmcore/rt-timing.h deleted file mode 100644 index d78e8c986..000000000 --- a/src/vmcore/rt-timing.h +++ /dev/null @@ -1,143 +0,0 @@ -/* src/vmcore/rt-timing.h - POSIX real-time timing utilities - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _RT_TIMING_H -#define _RT_TIMING_H - -#include "config.h" - -#if defined(ENABLE_RT_TIMING) - -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "vm/global.h" - - -#define RT_TIMING_GET_TIME(ts) \ - rt_timing_gettime(&(ts)); - -#define RT_TIMING_TIME_DIFF(a,b,index) \ - rt_timing_time_diff(&(a),&(b),(index)); - -#define RT_TIMING_JIT_CHECKS 0 -#define RT_TIMING_JIT_PARSE 1 -#define RT_TIMING_JIT_STACK 2 -#define RT_TIMING_JIT_TYPECHECK 3 -#define RT_TIMING_JIT_LOOP 4 -#define RT_TIMING_JIT_IFCONV 5 -#define RT_TIMING_JIT_ALLOC 6 -#define RT_TIMING_JIT_RPLPOINTS 7 -#define RT_TIMING_JIT_CODEGEN 8 -#define RT_TIMING_JIT_TOTAL 9 - -#define RT_TIMING_LINK_RESOLVE 10 -#define RT_TIMING_LINK_C_VFTBL 11 -#define RT_TIMING_LINK_ABSTRACT 12 -#define RT_TIMING_LINK_C_IFTBL 13 -#define RT_TIMING_LINK_F_VFTBL 14 -#define RT_TIMING_LINK_OFFSETS 15 -#define RT_TIMING_LINK_F_IFTBL 16 -#define RT_TIMING_LINK_FINALIZER 17 -#define RT_TIMING_LINK_EXCEPTS 18 -#define RT_TIMING_LINK_SUBCLASS 19 -#define RT_TIMING_LINK_TOTAL 20 - -#define RT_TIMING_LOAD_CHECKS 21 -#define RT_TIMING_LOAD_NDPOOL 22 -#define RT_TIMING_LOAD_CPOOL 23 -#define RT_TIMING_LOAD_SETUP 24 -#define RT_TIMING_LOAD_FIELDS 25 -#define RT_TIMING_LOAD_METHODS 26 -#define RT_TIMING_LOAD_CLASSREFS 27 -#define RT_TIMING_LOAD_DESCS 28 -#define RT_TIMING_LOAD_SETREFS 29 -#define RT_TIMING_LOAD_PARSEFDS 30 -#define RT_TIMING_LOAD_PARSEMDS 31 -#define RT_TIMING_LOAD_PARSECP 32 -#define RT_TIMING_LOAD_VERIFY 33 -#define RT_TIMING_LOAD_ATTRS 34 -#define RT_TIMING_LOAD_TOTAL 35 - -#define RT_TIMING_LOAD_BOOT_LOOKUP 36 -#define RT_TIMING_LOAD_BOOT_ARRAY 37 -#define RT_TIMING_LOAD_BOOT_SUCK 38 -#define RT_TIMING_LOAD_BOOT_LOAD 39 -#define RT_TIMING_LOAD_BOOT_CACHE 40 -#define RT_TIMING_LOAD_BOOT_TOTAL 41 - -#define RT_TIMING_LOAD_CL_LOOKUP 42 -#define RT_TIMING_LOAD_CL_PREPARE 43 -#define RT_TIMING_LOAD_CL_JAVA 44 -#define RT_TIMING_LOAD_CL_CACHE 45 - -#define RT_TIMING_NEW_OBJECT 46 -#define RT_TIMING_NEW_ARRAY 47 - -#define RT_TIMING_GC_ALLOC 48 -#define RT_TIMING_GC_SUSPEND 49 -#define RT_TIMING_GC_ROOTSET1 50 -#define RT_TIMING_GC_MARK 51 -#define RT_TIMING_GC_COMPACT 52 -#define RT_TIMING_GC_ROOTSET2 53 -#define RT_TIMING_GC_TOTAL 54 - -#define RT_TIMING_N 55 - -void rt_timing_gettime(struct timespec *ts); - -void rt_timing_time_diff(struct timespec *a,struct timespec *b,int index); - -long rt_timing_diff_usec(struct timespec *a,struct timespec *b); - -void rt_timing_print_time_stats(FILE *file); - -#else /* !defined(ENABLE_RT_TIMING) */ - -#define RT_TIMING_GET_TIME(ts) -#define RT_TIMING_TIME_DIFF(a,b,index) - -#endif /* defined(ENABLE_RT_TIMING) */ - -#endif /* _RT_TIMING_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/stackmap.c b/src/vmcore/stackmap.c deleted file mode 100644 index 40ee97e40..000000000 --- a/src/vmcore/stackmap.c +++ /dev/null @@ -1,520 +0,0 @@ -/* src/vmcore/stackmap.c - class attribute StackMapTable - - Copyright (C) 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" -#include "vm/types.h" - -#include "mm/memory.h" - -#include "vm/exceptions.h" - -#include "vmcore/class.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/stackmap.h" -#include "vmcore/statistics.h" -#include "vmcore/suck.h" - - -/* stackmap_get_verification_type_info ***************************************** - - union verification_type_info { - Top_variable_info; - Integer_variable_info; - Float_variable_info; - Long_variable_info; - Double_variable_info; - Null_variable_info; - UninitializedThis_variable_info; - Object_variable_info; - Uninitialized_variable_info; - } - - Top_variable_info { - u1 tag = ITEM_Top; // 0 - } - - Integer_variable_info { - u1 tag = ITEM_Integer; // 1 - } - - Float_variable_info { - u1 tag = ITEM_Float; // 2 - } - - Long_variable_info { - u1 tag = ITEM_Long; // 4 - } - - Double_variable_info { - u1 tag = ITEM_Double; // 3 - } - - Null_variable_info { - u1 tag = ITEM_Null; // 5 - } - - UninitializedThis_variable_info { - u1 tag = ITEM_UninitializedThis; // 6 - } - - Object_variable_info { - u1 tag = ITEM_Object; // 7 - u2 cpool_index; - } - - Uninitialized_variable_info { - u1 tag = ITEM_Uninitialized; // 8 - u2 offset; - } - -*******************************************************************************/ - -static bool stackmap_get_verification_type_info(classbuffer *cb, verification_type_info_t *verification_type_info) -{ - /* get verification type */ - - if (!suck_check_classbuffer_size(cb, 1)) - return false; - - verification_type_info->tag = suck_u1(cb); - - /* process the tag */ - - switch (verification_type_info->tag) { - case ITEM_Top: - case ITEM_Integer: - case ITEM_Float: - case ITEM_Long: - case ITEM_Double: - case ITEM_Null: - case ITEM_UninitializedThis: - break; - - case ITEM_Object: - /* get constant pool index */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - verification_type_info->Object_variable_info.cpool_index = suck_u2(cb); - break; - - case ITEM_Uninitialized: - /* get offset */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - verification_type_info->Uninitialized_variable_info.offset = suck_u2(cb); - break; - } - - return true; -} - - -/* stackmap_get_same_locals_1_stack_item_frame ********************************* - - same_locals_1_stack_item_frame { - u1 frame_type = SAME_LOCALS_1_STACK_ITEM; // 64-127 - verification_type_info stack[1]; - } - -*******************************************************************************/ - -static bool stackmap_get_same_locals_1_stack_item_frame(classbuffer *cb, stack_map_frame_t *stack_map_frame) -{ - same_locals_1_stack_item_frame_t *same_locals_1_stack_item_frame; - - /* for convenience */ - - same_locals_1_stack_item_frame = - &(stack_map_frame->same_locals_1_stack_item_frame); - - if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame->stack[0]))) - return false; - - return true; -} - - -/* stackmap_get_same_locals_1_stack_item_frame_extended ************************ - - same_locals_1_stack_item_frame_extended { - u1 frame_type = SAME_LOCALS_1_STACK_ITEM_EXTENDED; // 247 - u2 offset_delta; - verification_type_info stack[1]; - } - -*******************************************************************************/ - -static bool stackmap_get_same_locals_1_stack_item_frame_extended(classbuffer *cb, stack_map_frame_t *stack_map_frame) -{ - same_locals_1_stack_item_frame_extended_t *same_locals_1_stack_item_frame_extended; - - /* for convenience */ - - same_locals_1_stack_item_frame_extended = - &(stack_map_frame->same_locals_1_stack_item_frame_extended); - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* get offset delta */ - - same_locals_1_stack_item_frame_extended->offset_delta = suck_u2(cb); - - /* process stack */ - - if (!stackmap_get_verification_type_info(cb, &(same_locals_1_stack_item_frame_extended->stack[0]))) - return false; - - return true; -} - - -/* stackmap_get_chop_frame ***************************************************** - - chop_frame { - u1 frame_type = CHOP_FRAME; // 248-250 - u2 offset_delta; - } - -*******************************************************************************/ - -static bool stackmap_get_chop_frame(classbuffer *cb, - stack_map_frame_t *stack_map_frame) -{ - chop_frame_t *chop_frame; - - /* for convenience */ - - chop_frame = &(stack_map_frame->chop_frame); - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* get offset delta */ - - chop_frame->offset_delta = suck_u2(cb); - - return true; -} - - -/* stackmap_get_same_frame_extended ******************************************** - - same_frame_extended { - u1 frame_type = SAME_FRAME_EXTENDED; // 251 - u2 offset_delta; - } - -*******************************************************************************/ - -static bool stackmap_get_same_frame_extended(classbuffer *cb, - stack_map_frame_t *stack_map_frame) -{ - same_frame_extended_t *same_frame_extended; - - /* for convenience */ - - same_frame_extended = &(stack_map_frame->same_frame_extended); - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* get offset delta */ - - same_frame_extended->offset_delta = suck_u2(cb); - - return true; -} - - -/* stackmap_get_append_frame *************************************************** - - append_frame { - u1 frame_type = APPEND_FRAME; // 252-254 - u2 offset_delta; - verification_type_info locals[frame_Type - 251]; - } - -*******************************************************************************/ - -static bool stackmap_get_append_frame(classbuffer *cb, - stack_map_frame_t *stack_map_frame) -{ - append_frame_t *append_frame; - s4 number_of_locals; - s4 i; - - /* for convenience */ - - append_frame = &(stack_map_frame->append_frame); - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - /* get offset delta */ - - append_frame->offset_delta = suck_u2(cb); - - /* allocate locals array */ - - number_of_locals = append_frame->frame_type - 251; - - append_frame->locals = DMNEW(verification_type_info_t, number_of_locals); - - /* process all locals */ - - for (i = 0; i < number_of_locals; i++) - if (!stackmap_get_verification_type_info(cb, &(append_frame->locals[i]))) - return false; - - return true; -} - - -/* stackmap_get_full_frame ***************************************************** - - full_frame { - u1 frame_type = FULL_FRAME; - u2 offset_delta; - u2 number_of_locals; - verification_type_info locals[number_of_locals]; - u2 number_of_stack_items; - verification_type_info stack[number_of_stack_items]; - } - -*******************************************************************************/ - -static bool stackmap_get_full_frame(classbuffer *cb, - stack_map_frame_t *stack_map_frame) -{ - full_frame_t *full_frame; - s4 i; - - /* for convenience */ - - full_frame = &(stack_map_frame->full_frame); - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 2 + 2)) - return false; - - /* get offset delta */ - - stack_map_frame->full_frame.offset_delta = suck_u2(cb); - - /* get number of locals */ - - full_frame->number_of_locals = suck_u2(cb); - - /* allocate locals array */ - - full_frame->locals = - DMNEW(verification_type_info_t, full_frame->number_of_locals); - - /* process all locals */ - - for (i = 0; i < full_frame->number_of_locals; i++) - if (!stackmap_get_verification_type_info(cb, &(full_frame->locals[i]))) - return false; - - /* get number of stack items */ - - if (!suck_check_classbuffer_size(cb, 2)) - return false; - - full_frame->number_of_stack_items = suck_u2(cb); - - /* allocate stack array */ - - full_frame->stack = - DMNEW(verification_type_info_t, full_frame->number_of_stack_items); - - /* process all stack items */ - - for (i = 0; i < full_frame->number_of_stack_items; i++) - if (!stackmap_get_verification_type_info(cb, &(full_frame->stack[i]))) - return false; - - return true; -} - - -/* stackmap_load_attribute_stackmaptable *************************************** - - stack_map { - u2 attribute_name_index; - u4 attribute_length; - u2 number_of_entries; - stack_map_frame entries[number_of_entries]; - } - - union stack_map_frame { - same_frame; - same_locals_1_stack_item_frame; - same_locals_1_stack_item_frame_extended; - chop_frame; - same_frame_extended; - append_frame; - full_frame; - } - - same_frame { - u1 frame_type = SAME; // 0-63 - } - -*******************************************************************************/ - -bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m) -{ - classinfo *c; - stack_map_t *stack_map; - s4 i; - u1 frame_type; - - /* get classinfo */ - - c = cb->clazz; - - /* allocate stack map structure */ - - stack_map = DNEW(stack_map_t); - - STATISTICS(size_stack_map += sizeof(stack_map_t)); - - /* check buffer size */ - - if (!suck_check_classbuffer_size(cb, 4 + 2)) - return false; - - /* attribute_length */ - - stack_map->attribute_length = suck_u4(cb); - - if (!suck_check_classbuffer_size(cb, stack_map->attribute_length)) - return false; - - /* get number of entries */ - - stack_map->number_of_entries = suck_u2(cb); - - /* process all entries */ - - stack_map->entries = DMNEW(stack_map_frame_t, stack_map->number_of_entries); - - for (i = 0; i < stack_map->number_of_entries; i++) { - /* get the frame type */ - - frame_type = suck_u1(cb); - - stack_map->entries[i].frame_type = frame_type; - - /* process frame */ - - if (frame_type <= FRAME_TYPE_SAME) { - /* same_frame */ - } - else if (frame_type <= FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM) { - /* same_locals_1_stack_item_frame */ - - if (!stackmap_get_same_locals_1_stack_item_frame(cb, &(stack_map->entries[i]))) - return false; - } - else if (frame_type <= FRAME_TYPE_RESERVED) { - /* reserved */ - - exceptions_throw_classformaterror(c, "reserved frame type"); - return false; - } - else if (frame_type == FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED) { - /* same_locals_1_stack_item_frame_extended */ - - if (!stackmap_get_same_locals_1_stack_item_frame_extended(cb, &(stack_map->entries[i]))) - return false; - } - else if (frame_type <= FRAME_TYPE_CHOP) { - /* chop_frame */ - - if (!stackmap_get_chop_frame(cb, &(stack_map->entries[i]))) - return false; - } - else if (frame_type == FRAME_TYPE_SAME_FRAME_EXTENDED) { - /* same_frame_extended */ - - if (!stackmap_get_same_frame_extended(cb, &(stack_map->entries[i]))) - return false; - } - else if (frame_type <= FRAME_TYPE_APPEND) { - /* append_frame */ - - if (!stackmap_get_append_frame(cb, &(stack_map->entries[i]))) - return false; - } - else if (frame_type == FRAME_TYPE_FULL_FRAME) { - /* full_frame */ - - if (!stackmap_get_full_frame(cb, &(stack_map->entries[i]))) - return false; - } - } - - /* store stack map in method structure */ - -#if 0 - /* currently not used */ - - m->stack_map = stack_map; -#endif - - return true; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/stackmap.h b/src/vmcore/stackmap.h deleted file mode 100644 index 973941a76..000000000 --- a/src/vmcore/stackmap.h +++ /dev/null @@ -1,232 +0,0 @@ -/* src/vmcore/stackmap.h - class attribute StackMapTable - - Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates, - R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, - C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, - Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _STACKMAP_H -#define _STACKMAP_H - -/* forward typedefs ***********************************************************/ - -typedef struct stack_map_t stack_map_t; -typedef union stack_map_frame_t stack_map_frame_t; -typedef struct same_locals_1_stack_item_frame_t same_locals_1_stack_item_frame_t; -typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t; -typedef struct chop_frame_t chop_frame_t; -typedef struct same_frame_extended_t same_frame_extended_t; -typedef struct append_frame_t append_frame_t; -typedef struct full_frame_t full_frame_t; - -typedef union verification_type_info_t verification_type_info_t; -typedef struct Top_variable_info_t Top_variable_info_t; -typedef struct Integer_variable_info_t Integer_variable_info_t; -typedef struct Float_variable_info_t Float_variable_info_t; -typedef struct Long_variable_info_t Long_variable_info_t; -typedef struct Double_variable_info_t Double_variable_info_t; -typedef struct Null_variable_info_t Null_variable_info_t; -typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t; -typedef struct Object_variable_info_t Object_variable_info_t; -typedef struct Uninitialized_variable_info_t Uninitialized_variable_info_t; - - -#include "config.h" -#include "vm/types.h" - -#include "vm/global.h" - -#include "vmcore/loader.h" -#include "vmcore/method.h" - - -/* verification_type_info *****************************************************/ - -#define ITEM_Top 0 -#define ITEM_Integer 1 -#define ITEM_Float 2 -#define ITEM_Double 3 -#define ITEM_Long 4 -#define ITEM_Null 5 -#define ITEM_UninitializedThis 6 -#define ITEM_Object 7 -#define ITEM_Uninitialized 8 - -struct Top_variable_info_t { - u1 tag; -}; - -struct Integer_variable_info_t { - u1 tag; -}; - -struct Float_variable_info_t { - u1 tag; -}; - -struct Long_variable_info_t { - u1 tag; -}; - -struct Double_variable_info_t { - u1 tag; -}; - -struct Null_variable_info_t { - u1 tag; -}; - -struct UninitializedThis_variable_info_t { - u1 tag; -}; - -struct Object_variable_info_t { - u1 tag; - u2 cpool_index; -}; - -struct Uninitialized_variable_info_t { - u1 tag; - u2 offset; -}; - -union verification_type_info_t { - u1 tag; - Top_variable_info_t Top_variable_info; - Integer_variable_info_t Integer_variable_info; - Float_variable_info_t Float_variable_info; - Long_variable_info_t Long_variable_info; - Double_variable_info_t Double_variable_info; - Null_variable_info_t Null_variable_info; - UninitializedThis_variable_info_t UninitializedThis_variable_info; - Object_variable_info_t Object_variable_info; - Uninitialized_variable_info_t Uninitialized_variable_info; -}; - - -/* stack_map_t ****************************************************************/ - -struct stack_map_t { - u2 attribute_name_index; - u4 attribute_length; - u2 number_of_entries; - stack_map_frame_t *entries; -}; - - -/* same_locals_1_stack_item_frame_t *******************************************/ - -struct same_locals_1_stack_item_frame_t { - u1 frame_type; - verification_type_info_t stack[1]; -}; - - -/* same_locals_1_stack_item_frame_extended_t **********************************/ - -struct same_locals_1_stack_item_frame_extended_t { - u1 frame_type; - u2 offset_delta; - verification_type_info_t stack[1]; -}; - - -/* chop_frame_t ***************************************************************/ - -struct chop_frame_t { - u1 frame_type; - u2 offset_delta; -}; - - -/* same_frame_extended_t ******************************************************/ - -struct same_frame_extended_t { - u1 frame_type; - u2 offset_delta; -}; - - -/* append_frame_t *************************************************************/ - -struct append_frame_t { - u1 frame_type; - u2 offset_delta; - verification_type_info_t *locals; -}; - - -/* full_frame_t ***************************************************************/ - -struct full_frame_t { - u1 frame_type; - u2 offset_delta; - u2 number_of_locals; - verification_type_info_t *locals; - u2 number_of_stack_items; - verification_type_info_t *stack; -}; - - -/* stack_map_frame_t **********************************************************/ - -#define FRAME_TYPE_SAME 63 /* 0-63 */ -#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM 127 /* 0-127 */ -#define FRAME_TYPE_RESERVED 246 /* 128-246 */ -#define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED 247 /* 247 */ -#define FRAME_TYPE_CHOP 250 /* 248-250 */ -#define FRAME_TYPE_SAME_FRAME_EXTENDED 251 /* 251 */ -#define FRAME_TYPE_APPEND 254 /* 252-254 */ -#define FRAME_TYPE_FULL_FRAME 255 /* 255 */ - -union stack_map_frame_t { - u1 frame_type; - same_locals_1_stack_item_frame_t same_locals_1_stack_item_frame; - same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended; - chop_frame_t chop_frame; - same_frame_extended_t same_frame_extended; - append_frame_t append_frame; - full_frame_t full_frame; -}; - - -/* function prototypes ********************************************************/ - -bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m); - -#endif /* _STACKMAP_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/statistics.c b/src/vmcore/statistics.c deleted file mode 100644 index 99781e8c6..000000000 --- a/src/vmcore/statistics.c +++ /dev/null @@ -1,821 +0,0 @@ -/* src/vmcore/statistics.c - global varables for statistics - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#if defined(HAVE_TIME_H) -# include -#endif - -#if defined(HAVE_SYS_TIME_H) -# include -#endif - -#if defined(HAVE_SYS_RESOURCE_H) -# include -#endif - -#include "vm/types.h" - -#include "mm/gc-common.h" - -#include "toolbox/logging.h" - -#include "vm/global.h" - -#include "vm/jit/code.h" - -#include "vmcore/class.h" -#include "vmcore/field.h" -#include "vmcore/method.h" -#include "vmcore/options.h" -#include "vmcore/statistics.h" - - -/* global variables ***********************************************************/ - -static s8 loadingtime = 0; /* accumulated loading time */ -static s8 loadingstarttime = 0; -static s8 loadingstoptime = 0; -static s4 loadingtime_recursion = 0; - -static s8 compilingtime = 0; /* accumulated compile time */ -static s8 compilingstarttime = 0; -static s8 compilingstoptime = 0; -static s4 compilingtime_recursion = 0; - -s4 codememusage = 0; -s4 maxcodememusage = 0; - -s4 memoryusage = 0; -s4 maxmemusage = 0; - -s4 maxdumpsize = 0; - -s4 globalallocateddumpsize = 0; -s4 globaluseddumpsize = 0; - - -/* variables for measurements *************************************************/ - -s4 size_classinfo = 0; -s4 size_fieldinfo = 0; -s4 size_methodinfo = 0; -s4 size_lineinfo = 0; -s4 size_codeinfo = 0; - -s4 size_stub_native = 0; - -s4 size_stack_map = 0; -s4 size_string = 0; - -s4 size_threadobject = 0; -int32_t size_thread_index_t = 0; -int32_t size_stacksize = 0; - -s4 size_lock_record = 0; -s4 size_lock_hashtable = 0; -s4 size_lock_waiter = 0; - -int32_t count_linenumbertable = 0; -int32_t size_linenumbertable = 0; - -s4 size_patchref = 0; - -u8 count_calls_java_to_native = 0; -u8 count_calls_native_to_java = 0; - -int count_const_pool_len = 0; -int count_classref_len = 0; -int count_parsed_desc_len = 0; -int count_vftbl_len = 0; -int count_all_methods = 0; -int count_methods_marked_used = 0; /* RTA */ - -int count_vmcode_len = 0; -int count_extable_len = 0; -int count_class_loads = 0; -int count_class_inits = 0; - -int count_utf_len = 0; /* size of utf hash */ -int count_utf_new = 0; /* calls of utf_new */ -int count_utf_new_found = 0; /* calls of utf_new with fast return */ - -int count_locals_conflicts = 0; /* register allocator statistics */ -int count_locals_spilled = 0; -int count_locals_register = 0; -int count_ss_spilled = 0; -int count_ss_register = 0; -int count_methods_allocated_by_lsra = 0; -int count_mem_move_bb = 0; -int count_interface_size = 0; -int count_argument_mem_ss = 0; -int count_argument_reg_ss = 0; -int count_method_in_register = 0; -int count_mov_reg_reg = 0; -int count_mov_mem_reg = 0; -int count_mov_reg_mem = 0; -int count_mov_mem_mem = 0; - -int count_jit_calls = 0; -int count_methods = 0; -int count_spills_read_ila = 0; -int count_spills_read_flt = 0; -int count_spills_read_dbl = 0; -int count_spills_write_ila = 0; -int count_spills_write_flt = 0; -int count_spills_write_dbl = 0; -int count_pcmd_activ = 0; -int count_pcmd_drop = 0; -int count_pcmd_zero = 0; -int count_pcmd_const_store = 0; -int count_pcmd_const_alu = 0; -int count_pcmd_const_bra = 0; -int count_pcmd_load = 0; -int count_pcmd_move = 0; -int count_load_instruction = 0; -int count_pcmd_store = 0; -int count_pcmd_store_comb = 0; -int count_dup_instruction = 0; -int count_pcmd_op = 0; -int count_pcmd_mem = 0; -int count_pcmd_met = 0; -int count_pcmd_bra = 0; -int count_pcmd_table = 0; -int count_pcmd_return = 0; -int count_pcmd_returnx = 0; -int count_check_null = 0; -int count_check_bound = 0; -int count_max_basic_blocks = 0; -int count_basic_blocks = 0; -int count_javainstr = 0; -int count_max_javainstr = 0; -int count_javacodesize = 0; -int count_javaexcsize = 0; -int count_calls = 0; -int count_tryblocks = 0; -int count_code_len = 0; -int count_data_len = 0; -int count_cstub_len = 0; -int count_max_new_stack = 0; -int count_upper_bound_new_stack = 0; - -int count_emit_branch = 0; -int count_emit_branch_8bit = 0; -int count_emit_branch_16bit = 0; -int count_emit_branch_32bit = 0; -int count_emit_branch_64bit = 0; - -s4 count_branches_resolved = 0; -s4 count_branches_unresolved = 0; - -u8 count_jni_callXmethod_calls=0; -u8 count_jni_calls=0; - - -static int count_block_stack_init[11] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0 -}; -int *count_block_stack = count_block_stack_init; -static int count_analyse_iterations_init[5] = { - 0, 0, 0, 0, 0 -}; -int *count_analyse_iterations = count_analyse_iterations_init; -static int count_method_bb_distribution_init[9] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0 -}; -int *count_method_bb_distribution = count_method_bb_distribution_init; -static int count_block_size_distribution_init[18] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0 -}; -int *count_block_size_distribution = count_block_size_distribution_init; -static int count_store_length_init[21] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0 -}; -int *count_store_length = count_store_length_init; -static int count_store_depth_init[11] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0 -}; -int *count_store_depth = count_store_depth_init; - - -/* instruction scheduler statistics *******************************************/ - -s4 count_schedule_basic_blocks = 0; -s4 count_schedule_nodes = 0; -s4 count_schedule_leaders = 0; -s4 count_schedule_max_leaders = 0; -s4 count_schedule_critical_path = 0; - - -/* jnicallXmethodinvokation *************************************************** - - increments the jni CallXMethod invokation count by one - -*******************************************************************************/ - -void jnicallXmethodnvokation(void) -{ - /* XXX do locking here */ - count_jni_callXmethod_calls++; -} - - -/* jniinvokation ************************************************************* - - increments the jni overall invokation count by one - -*******************************************************************************/ - -void jniinvokation(void) -{ - /* XXX do locking here */ - count_jni_calls++; -} - - -/* getcputime *********************************** ****************************** - - Returns the used CPU time in microseconds - -*******************************************************************************/ - -s8 getcputime(void) -{ -#if defined(HAVE_GETRUSAGE) - struct rusage ru; - int sec, usec; - - getrusage(RUSAGE_SELF, &ru); - - sec = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec; - usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec; - - return sec * 1000000 + usec; -#else - /* If we don't have getrusage, simply return 0. */ - - return 0; -#endif -} - - -/* loadingtime_stop ************************************************************ - - XXX - -*******************************************************************************/ - -void loadingtime_start(void) -{ - loadingtime_recursion++; - - if (loadingtime_recursion == 1) - loadingstarttime = getcputime(); -} - - -/* loadingtime_stop ************************************************************ - - XXX - -*******************************************************************************/ - -void loadingtime_stop(void) -{ - if (loadingtime_recursion == 1) { - loadingstoptime = getcputime(); - loadingtime += (loadingstoptime - loadingstarttime); - } - - loadingtime_recursion--; -} - - -/* compilingtime_stop ********************************************************** - - XXX - -*******************************************************************************/ - -void compilingtime_start(void) -{ - compilingtime_recursion++; - - if (compilingtime_recursion == 1) - compilingstarttime = getcputime(); -} - - -/* compilingtime_stop ********************************************************** - - XXX - -*******************************************************************************/ - -void compilingtime_stop(void) -{ - if (compilingtime_recursion == 1) { - compilingstoptime = getcputime(); - compilingtime += (compilingstoptime - compilingstarttime); - } - - compilingtime_recursion--; -} - - -/* print_times ***************************************************************** - - Prints a summary of CPU time usage. - -*******************************************************************************/ - -void print_times(void) -{ - s8 totaltime; - s8 runtime; - - totaltime = getcputime(); - runtime = totaltime - loadingtime - compilingtime; - -#if SIZEOF_VOID_P == 8 - dolog("Time for loading classes: %6ld ms", loadingtime / 1000); - dolog("Time for compiling code: %6ld ms", compilingtime / 1000); - dolog("Time for running program: %6ld ms", runtime / 1000); - dolog("Total time: %6ld ms", totaltime / 1000); -#else - dolog("Time for loading classes: %6lld ms", loadingtime / 1000); - dolog("Time for compiling code: %6lld ms", compilingtime / 1000); - dolog("Time for running program: %6lld ms", runtime / 1000); - dolog("Total time: %6lld ms", totaltime / 1000); -#endif -} - - -/* print_stats ***************************************************************** - - outputs detailed compiler statistics - -*******************************************************************************/ - -void print_stats(void) -{ - s4 i; - float f; - s4 sum; - - - dolog("Number of JIT compiler calls: %6d", count_jit_calls); - dolog("Number of compiled methods: %6d", count_methods); - - dolog("Number of compiled basic blocks: %6d", - count_basic_blocks); - dolog("Number of max. basic blocks per method: %6d", - count_max_basic_blocks); - - dolog("Number of compiled JavaVM instructions: %6d", - count_javainstr); - dolog("Number of max. JavaVM instructions per method: %6d", - count_max_javainstr); - dolog("Size of compiled JavaVM instructions: %6d(%d)", - count_javacodesize, count_javacodesize - count_methods * 18); - - dolog("Size of compiled Exception Tables: %d", count_javaexcsize); - dolog("Number of Machine-Instructions: %d", count_code_len >> 2); - dolog("Number of Spills (write to memory) : %d [%d|%d|%d]", - count_spills_write_ila + count_spills_write_flt + count_spills_write_dbl, - count_spills_write_ila, count_spills_write_flt, count_spills_write_dbl); - dolog("Number of Spills (read from memory) : %d [%d|%d|%d]", - count_spills_read_ila + count_spills_read_flt + count_spills_read_dbl, - count_spills_read_ila, count_spills_read_flt, count_spills_read_dbl); - dolog("Number of Activ Pseudocommands: %6d", count_pcmd_activ); - dolog("Number of Drop Pseudocommands: %6d", count_pcmd_drop); - dolog("Number of Const Pseudocommands: %6d (zero:%5d)", - count_pcmd_load, count_pcmd_zero); - dolog("Number of ConstAlu Pseudocommands: %6d (cmp: %5d, store:%5d)", - count_pcmd_const_alu, count_pcmd_const_bra, count_pcmd_const_store); - dolog("Number of Move Pseudocommands: %6d", count_pcmd_move); - dolog("Number of Load Pseudocommands: %6d", count_load_instruction); - dolog("Number of Store Pseudocommands: %6d (combined: %5d)", - count_pcmd_store, count_pcmd_store - count_pcmd_store_comb); - dolog("Number of OP Pseudocommands: %6d", count_pcmd_op); - dolog("Number of DUP Pseudocommands: %6d", count_dup_instruction); - dolog("Number of Mem Pseudocommands: %6d", count_pcmd_mem); - dolog("Number of Method Pseudocommands: %6d", count_pcmd_met); - dolog("Number of Branch Pseudocommands: %6d (rets:%5d, Xrets: %5d)", - count_pcmd_bra, count_pcmd_return, count_pcmd_returnx); - log_println(" resolved branches: %6d", count_branches_resolved); - log_println(" unresolved branches: %6d", count_branches_unresolved); - dolog("Number of Table Pseudocommands: %6d", count_pcmd_table); - dolog("Number of Useful Pseudocommands: %6d", count_pcmd_table + - count_pcmd_bra + count_pcmd_load + count_pcmd_mem + count_pcmd_op); - dolog("Number of Null Pointer Checks: %6d", count_check_null); - dolog("Number of Array Bound Checks: %6d", count_check_bound); - dolog("Number of Try-Blocks: %d", count_tryblocks); - - dolog("Number of branch_emit (total, 8bit/16bit/32bit/64bit offset): %d, %d/%d/%d/%d", - count_emit_branch, count_emit_branch_8bit, count_emit_branch_16bit, - count_emit_branch_32bit, count_emit_branch_64bit); - - dolog("Maximal count of stack elements: %d", count_max_new_stack); - dolog("Upper bound of max stack elements: %d", count_upper_bound_new_stack); - dolog("Distribution of stack sizes at block boundary"); - dolog(" 0 1 2 3 4 5 6 7 8 9 >=10"); - dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", - count_block_stack[0], count_block_stack[1], count_block_stack[2], - count_block_stack[3], count_block_stack[4], count_block_stack[5], - count_block_stack[6], count_block_stack[7], count_block_stack[8], - count_block_stack[9], count_block_stack[10]); - dolog("Distribution of store stack depth"); - dolog(" 0 1 2 3 4 5 6 7 8 9 >=10"); - dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", - count_store_depth[0], count_store_depth[1], count_store_depth[2], - count_store_depth[3], count_store_depth[4], count_store_depth[5], - count_store_depth[6], count_store_depth[7], count_store_depth[8], - count_store_depth[9], count_store_depth[10]); - dolog("Distribution of store creator chains first part"); - dolog(" 0 1 2 3 4 5 6 7 8 9"); - dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", - count_store_length[0], count_store_length[1], count_store_length[2], - count_store_length[3], count_store_length[4], count_store_length[5], - count_store_length[6], count_store_length[7], count_store_length[8], - count_store_length[9]); - dolog("Distribution of store creator chains second part"); - dolog(" 10 11 12 13 14 15 16 17 18 19 >=20"); - dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d", - count_store_length[10], count_store_length[11], - count_store_length[12], count_store_length[13], - count_store_length[14], count_store_length[15], - count_store_length[16], count_store_length[17], - count_store_length[18], count_store_length[19], - count_store_length[20]); - dolog("Distribution of analysis iterations"); - dolog(" 1 2 3 4 >=5"); - dolog("%6d%6d%6d%6d%6d", - count_analyse_iterations[0], count_analyse_iterations[1], - count_analyse_iterations[2], count_analyse_iterations[3], - count_analyse_iterations[4]); - - - /* Distribution of basic blocks per method ********************************/ - - log_println("Distribution of basic blocks per method:"); - log_println(" <=5 <=10 <=15 <=20 <=30 <=40 <=50 <=75 >75"); - - log_start(); - for (i = 0; i <= 8; i++) - log_print("%6d", count_method_bb_distribution[i]); - log_finish(); - - /* print ratio */ - - f = (float) count_methods; - - log_start(); - for (i = 0; i <= 8; i++) - log_print("%6.2f", (float) count_method_bb_distribution[i] / f); - log_finish(); - - /* print cumulated ratio */ - - log_start(); - for (i = 0, sum = 0; i <= 8; i++) { - sum += count_method_bb_distribution[i]; - log_print("%6.2f", (float) sum / f); - } - log_finish(); - - - /* Distribution of basic block sizes **************************************/ - - log_println("Distribution of basic block sizes:"); - log_println(" 0 1 2 3 4 5 6 7 8 9 <13 <15 <17 <19 <21 <26 <31 >30"); - - /* print block sizes */ - - log_start(); - for (i = 0; i <= 17; i++) - log_print("%6d", count_block_size_distribution[i]); - log_finish(); - - /* print ratio */ - - f = (float) count_basic_blocks; - - log_start(); - for (i = 0; i <= 17; i++) - log_print("%6.2f", (float) count_block_size_distribution[i] / f); - log_finish(); - - /* print cumulated ratio */ - - log_start(); - for (i = 0, sum = 0; i <= 17; i++) { - sum += count_block_size_distribution[i]; - log_print("%6.2f", (float) sum / f); - } - log_finish(); - - statistics_print_memory_usage(); - - dolog("Number of class loads: %6d", count_class_loads); - dolog("Number of class inits: %6d", count_class_inits); - dolog("Number of loaded Methods: %6d\n", count_all_methods); - - dolog("Calls of utf_new: %6d", count_utf_new); - dolog("Calls of utf_new (element found): %6d\n", count_utf_new_found); - - - /* LSRA statistics ********************************************************/ - - dolog("Moves reg -> reg: %6d", count_mov_reg_reg); - dolog("Moves mem -> reg: %6d", count_mov_mem_reg); - dolog("Moves reg -> mem: %6d", count_mov_reg_mem); - dolog("Moves mem -> mem: %6d", count_mov_mem_mem); - - dolog("Methods allocated by LSRA: %6d", - count_methods_allocated_by_lsra); - dolog("Conflicts between local Variables: %6d", count_locals_conflicts); - dolog("Local Variables held in Memory: %6d", count_locals_spilled); - dolog("Local Variables held in Registers: %6d", count_locals_register); - dolog("Stackslots held in Memory: %6d", count_ss_spilled); - dolog("Stackslots held in Registers: %6d", count_ss_register); - dolog("Memory moves at BB Boundaries: %6d", count_mem_move_bb); - dolog("Number of interface slots: %6d\n", count_interface_size); - dolog("Number of Argument stack slots in register: %6d", - count_argument_reg_ss); - dolog("Number of Argument stack slots in memory: %6d\n", - count_argument_mem_ss); - dolog("Number of Methods kept in registers: %6d\n", - count_method_in_register); - - - /* instruction scheduler statistics ***************************************/ - -#if defined(USE_SCHEDULER) - dolog("Instruction scheduler statistics:"); - dolog("Number of basic blocks: %7d", count_schedule_basic_blocks); - dolog("Number of nodes: %7d", count_schedule_nodes); - dolog("Number of leaders nodes: %7d", count_schedule_leaders); - dolog("Number of max. leaders nodes: %7d", count_schedule_max_leaders); - dolog("Length of critical path: %7d\n", count_schedule_critical_path); -#endif - - - /* call statistics ********************************************************/ - - dolog("Function call statistics:"); - dolog("Number of jni->CallXMethod function invokations: %ld", - count_jni_callXmethod_calls); - dolog("Overall number of jni invokations: %ld", - count_jni_calls); - - log_println("java-to-native calls: %10ld", count_calls_java_to_native); - log_println("native-to-java calls: %10ld", count_calls_native_to_java); - - - /* now print other statistics ********************************************/ - -#if defined(ENABLE_INTRP) - print_dynamic_super_statistics(); -#endif -} - - -/* statistics_print_date ******************************************************* - - Print current date and time. - -*******************************************************************************/ - -void statistics_print_date(void) -{ - time_t t; - struct tm tm; - -#if defined(HAVE_TIME) - time(&t); -#else -# error !HAVE_TIME -#endif - -#if defined(HAVE_LOCALTIME_R) - localtime_r(&t, &tm); -#else -# error !HAVE_LOCALTIME_R -#endif - - log_println("%d-%02d-%02d %02d:%02d:%02d", - 1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); -} - - -/* statistics_print_memory_usage *********************************************** - - Print current memory usage. - -*******************************************************************************/ - -void statistics_print_memory_usage(void) -{ - s4 sum; - - log_println("memory usage ----------------------"); - log_println(""); - log_println("code: %10d", count_code_len); - log_println("data: %10d", count_data_len); - log_println(" ----------"); - - sum = - count_code_len + - count_data_len; - - log_println(" %10d", sum); - - log_println(""); - - log_println("classinfo (%3d B): %10d", (int) sizeof(classinfo), size_classinfo); - log_println("fieldinfo (%3d B): %10d", (int) sizeof(fieldinfo), size_fieldinfo); - log_println("methodinfo (%3d B): %10d", (int) sizeof(methodinfo), size_methodinfo); - log_println("lineinfo (%3d B): %10d", (int) sizeof(lineinfo), size_lineinfo); - log_println("codeinfo (%3d B): %10d", (int) sizeof(codeinfo), size_codeinfo); - log_println(" ----------"); - - sum = - size_classinfo + - size_fieldinfo + - size_methodinfo + - size_lineinfo + - size_codeinfo; - - log_println(" %10d", sum); - - log_println(""); - - log_println("linenumber tables (%5d): %10d", count_linenumbertable, size_linenumbertable); - log_println("exception tables: %10d", count_extable_len); - log_println("patcher references: %10d", size_patchref); - log_println(" ----------"); - - sum = - size_linenumbertable + - count_extable_len + - size_patchref; - - log_println(" %10d", sum); - - log_println(""); - - log_println("constant pool: %10d", count_const_pool_len); - log_println("classref: %10d", count_classref_len); - log_println("parsed descriptors: %10d", count_parsed_desc_len); - log_println("vftbl: %10d", count_vftbl_len); - log_println("compiler stubs: %10d", count_cstub_len); - log_println("native stubs: %10d", size_stub_native); - log_println("utf: %10d", count_utf_len); - log_println("vmcode: %10d", count_vmcode_len); - log_println("stack map: %10d", size_stack_map); - log_println("string: %10d", size_string); - log_println("threadobject: %10d", size_threadobject); - log_println("thread index: %10d", size_thread_index_t); - log_println("stack size: %10d", size_stacksize); - log_println("lock record: %10d", size_lock_record); - log_println("lock hashtable: %10d", size_lock_hashtable); - log_println("lock waiter: %10d", size_lock_waiter); - log_println(" ----------"); - - sum = - count_const_pool_len + - count_classref_len + - count_parsed_desc_len + - count_vftbl_len + - count_cstub_len + - size_stub_native + - count_utf_len + - count_vmcode_len + - size_stack_map + - size_string + - size_threadobject + - size_thread_index_t + - size_stacksize + - size_lock_record + - size_lock_hashtable + - size_lock_waiter; - - log_println(" %10d", sum); - - log_println(""); - - log_println("max. code memory: %10d", maxcodememusage); - log_println("max. heap memory: %10d", maxmemusage); - log_println("max. dump memory: %10d", maxdumpsize); - log_println(""); - log_println("heap memory not freed: %10d", (int32_t) memoryusage); - log_println("dump memory not freed: %10d", (int32_t) globalallocateddumpsize); - - log_println(""); -} - - -/* statistics_print_gc_memory_usage ******************************************** - - Print current GC memory usage. - -*******************************************************************************/ - -void statistics_print_gc_memory_usage(void) -{ - static int64_t count = 0; - int64_t max; - int64_t size; - int64_t free; - int64_t used; - int64_t total; - - count++; - - max = gc_get_max_heap_size(); - size = gc_get_heap_size(); - free = gc_get_free_bytes(); - used = size - free; - total = gc_get_total_bytes(); - - if (opt_ProfileMemoryUsageGNUPlot) { - if (count == 1) - fprintf(opt_ProfileMemoryUsageGNUPlot, "plot \"profile.dat\" using 1:2 with lines title \"max. Java heap size\", \"profile.dat\" using 1:3 with lines title \"Java heap size\", \"profile.dat\" using 1:4 with lines title \"used\", \"profile.dat\" using 1:5 with lines title \"free\"\n"); - -#if SIZEOF_VOID_P == 8 - fprintf(opt_ProfileMemoryUsageGNUPlot, "%ld %ld %ld %ld %ld\n", count, max, size, used, free); -#else - fprintf(opt_ProfileMemoryUsageGNUPlot, "%lld %lld %lld %lld %lld\n", count, max, size, used, free); -#endif - - fflush(opt_ProfileMemoryUsageGNUPlot); - } - else { - log_println("GC memory usage -------------------"); - log_println(""); - log_println("max. Java heap size: %10lld", max); - log_println(""); - log_println("Java heap size: %10lld", size); - log_println("used: %10lld", used); - log_println("free: %10lld", free); - log_println("totally used: %10lld", total); - log_println(""); - } -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/statistics.h b/src/vmcore/statistics.h deleted file mode 100644 index 62730ce93..000000000 --- a/src/vmcore/statistics.h +++ /dev/null @@ -1,268 +0,0 @@ -/* src/vmcore/statistics.h - exports global varables for statistics - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _STATISTICS_H -#define _STATISTICS_H - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "vm/global.h" - - -/* statistic macros ***********************************************************/ - -#if defined(ENABLE_STATISTICS) -#define STATISTICS(x) \ - do { \ - if (opt_stat) { \ - x; \ - } \ - } while (0) -#else -#define STATISTICS(x) /* nothing */ -#endif - -/* in_ inline statistics */ - -#define IN_MAX 9 -#define IN_UNIQUEVIRT 0x0000 -#define IN_UNIQUE_INTERFACE 0x0001 -#define IN_OUTSIDERS 0x0004 -#define IN_MAXDEPTH 0x0008 -#define IN_MAXCODE 0x0010 -#define IN_JCODELENGTH 0x0020 -#define IN_EXCEPTION 0x0040 -#define IN_NOT_UNIQUE_VIRT 0x0080 -#define IN_NOT_UNIQUE_INTERFACE 0x0100 - -#define N_UNIQUEVIRT 0 -#define N_UNIQUE_INTERFACE 1 -#define N_OUTSIDERS 2 -#define N_MAXDEPTH 3 -#define N_MAXCODE 4 -#define N_JCODELENGTH 5 -#define N_EXCEPTION 6 -#define N_NOT_UNIQUE_VIRT 7 -#define N_NOT_UNIQUE_INTERFACE 8 - - -/* global variables ***********************************************************/ - -extern s4 codememusage; -extern s4 maxcodememusage; - -extern s4 memoryusage; -extern s4 maxmemusage; - -extern s4 maxdumpsize; - -extern s4 globalallocateddumpsize; -extern s4 globaluseddumpsize; - - -/* variables for measurements *************************************************/ - -extern s4 size_classinfo; -extern s4 size_fieldinfo; -extern s4 size_methodinfo; -extern s4 size_lineinfo; -extern s4 size_codeinfo; - -extern s4 size_stub_native; - -extern s4 size_stack_map; -extern s4 size_string; - -extern s4 size_threadobject; -extern int32_t size_thread_index_t; -extern int32_t size_stacksize; - -extern s4 size_lock_record; -extern s4 size_lock_hashtable; -extern s4 size_lock_waiter; - -extern int32_t count_linenumbertable; -extern int32_t size_linenumbertable; - -extern s4 size_patchref; - -extern u8 count_calls_java_to_native; -extern u8 count_calls_native_to_java; - -extern int count_const_pool_len; -extern int count_classref_len; -extern int count_parsed_desc_len; -extern int count_vftbl_len; -extern int count_all_methods; -extern int count_methods_marked_used; /*RTA*/ -extern int count_vmcode_len; -extern int count_extable_len; -extern int count_class_loads; -extern int count_class_inits; - -extern int count_utf_len; /* size of utf hash */ -extern int count_utf_new; -extern int count_utf_new_found; - -extern int count_locals_conflicts; -extern int count_locals_spilled; -extern int count_locals_register; -extern int count_ss_spilled; -extern int count_ss_register; -extern int count_methods_allocated_by_lsra; -extern int count_mem_move_bb; -extern int count_interface_size; -extern int count_argument_mem_ss; -extern int count_argument_reg_ss; -extern int count_method_in_register; -extern int count_mov_reg_reg; -extern int count_mov_mem_reg; -extern int count_mov_reg_mem; -extern int count_mov_mem_mem; - -extern int count_jit_calls; -extern int count_methods; -extern int count_spills_read_ila; -extern int count_spills_read_flt; -extern int count_spills_read_dbl; -extern int count_spills_write_ila; -extern int count_spills_write_flt; -extern int count_spills_write_dbl; -extern int count_pcmd_activ; -extern int count_pcmd_drop; -extern int count_pcmd_zero; -extern int count_pcmd_const_store; -extern int count_pcmd_const_alu; -extern int count_pcmd_const_bra; -extern int count_pcmd_load; -extern int count_pcmd_move; -extern int count_load_instruction; -extern int count_pcmd_store; -extern int count_pcmd_store_comb; -extern int count_dup_instruction; -extern int count_pcmd_op; -extern int count_pcmd_mem; -extern int count_pcmd_met; -extern int count_pcmd_bra; -extern int count_pcmd_table; -extern int count_pcmd_return; -extern int count_pcmd_returnx; -extern int count_check_null; -extern int count_check_bound; -extern int count_max_basic_blocks; -extern int count_basic_blocks; -extern int count_max_javainstr; -extern int count_javainstr; -extern int count_javacodesize; -extern int count_javaexcsize; -extern int count_calls; -extern int count_tryblocks; -extern int count_code_len; -extern int count_data_len; -extern int count_cstub_len; -extern int count_max_new_stack; -extern int count_upper_bound_new_stack; - -extern int count_emit_branch; -extern int count_emit_branch_8bit; -extern int count_emit_branch_16bit; -extern int count_emit_branch_32bit; -extern int count_emit_branch_64bit; - -extern s4 count_branches_resolved; -extern s4 count_branches_unresolved; - -extern int *count_block_stack; -extern int *count_analyse_iterations; -extern int *count_method_bb_distribution; -extern int *count_block_size_distribution; -extern int *count_store_length; -extern int *count_store_depth; - /* in_ inline statistics */ -extern int count_in; -extern int count_in_uniqVirt; -extern int count_in_uniqIntf; -extern int count_in_rejected; -extern int count_in_rejected_mult; -extern int count_in_outsiders; -extern int count_in_uniqueVirt_not_inlined; -extern int count_in_uniqueInterface_not_inlined; -extern int count_in_maxDepth; -extern int count_in_maxMethods; - -extern u2 count_in_not [512]; - -/* instruction scheduler statistics *******************************************/ - -extern s4 count_schedule_basic_blocks; -extern s4 count_schedule_nodes; -extern s4 count_schedule_leaders; -extern s4 count_schedule_max_leaders; -extern s4 count_schedule_critical_path; - - -/* function prototypes ********************************************************/ - -s8 getcputime(void); - -void loadingtime_start(void); -void loadingtime_stop(void); -void compilingtime_start(void); -void compilingtime_stop(void); - -void print_times(void); -void print_stats(void); - -void statistics_print_date(void); -void statistics_print_memory_usage(void); -void statistics_print_gc_memory_usage(void); - -void mem_usagelog(bool givewarnings); - -void compiledinvokation(void); -void jnicallXmethodnvokation(void); -void jniinvokation(void); - -#endif /* _STATISTICS_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/suck.c b/src/vmcore/suck.c deleted file mode 100644 index 933ceab00..000000000 --- a/src/vmcore/suck.c +++ /dev/null @@ -1,631 +0,0 @@ -/* src/vmcore/suck.c - functions to read LE ordered types from a buffer - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "arch.h" - -#include "mm/memory.h" - -#include "threads/lock-common.h" - -#include "toolbox/list.h" -#include "toolbox/logging.h" -#include "toolbox/util.h" - -#include "vm/exceptions.h" -#include "vm/properties.h" -#include "vm/vm.h" - -#include "vmcore/loader.h" -#include "vmcore/options.h" -#include "vmcore/suck.h" -#include "vmcore/system.h" -#include "vmcore/zip.h" - - -/* global variables ***********************************************************/ - -list_t *list_classpath_entries; - - -/* suck_init ******************************************************************* - - Initializes the suck subsystem like initializing the classpath - entries list. - -*******************************************************************************/ - -bool suck_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("suck_init"); - - list_classpath_entries = list_create(OFFSET(list_classpath_entry, linkage)); - - /* everything's ok */ - - return true; -} - - -/* scandir_filter ************************************************************** - - Filters for zip/jar files. - -*******************************************************************************/ - -#if defined(__LINUX__) -static int scandir_filter(const struct dirent *a) -#else -static int scandir_filter(struct dirent *a) -#endif -{ - s4 namlen; - -#if defined(_DIRENT_HAVE_D_NAMLEN) - namlen = a->d_namlen; -#else - namlen = strlen(a->d_name); -#endif - - if ((strncasecmp(a->d_name + namlen - 4, ".zip", 4) == 0) || - (strncasecmp(a->d_name + namlen - 4, ".jar", 4) == 0)) - return 1; - - return 0; -} - - -/* suck_add ******************************************************************** - - Adds a classpath to the global classpath entries list. - -*******************************************************************************/ - -void suck_add(char *classpath) -{ - list_classpath_entry *lce; - char *start; - char *end; - char *filename; - s4 filenamelen; - bool is_zip; - char *cwd; - s4 cwdlen; -#if defined(ENABLE_ZLIB) - hashtable *ht; -#endif - - /* parse the classpath string */ - - for (start = classpath; (*start) != '\0'; ) { - - /* search for ':' delimiter to get the end of the current entry */ - for (end = start; ((*end) != '\0') && ((*end) != ':'); end++); - - if (start != end) { - is_zip = false; - filenamelen = end - start; - - if (filenamelen > 4) { - if ((strncasecmp(end - 4, ".zip", 4) == 0) || - (strncasecmp(end - 4, ".jar", 4) == 0)) { - is_zip = true; - } - } - - /* save classpath entries as absolute pathnames */ - - cwd = NULL; - cwdlen = 0; - - if (*start != '/') { /* XXX fix me for win32 */ - cwd = _Jv_getcwd(); - cwdlen = strlen(cwd) + strlen("/"); - } - - /* allocate memory for filename and fill it */ - - filename = MNEW(char, filenamelen + cwdlen + strlen("/") + - strlen("0")); - - if (cwd) { - strcpy(filename, cwd); - strcat(filename, "/"); - strncat(filename, start, filenamelen); - - /* add cwd length to file length */ - filenamelen += cwdlen; - - } else { - strncpy(filename, start, filenamelen); - filename[filenamelen] = '\0'; - } - - lce = NULL; - - if (is_zip) { -#if defined(ENABLE_ZLIB) - ht = zip_open(filename); - - if (ht != NULL) { - lce = NEW(list_classpath_entry); - - lce->type = CLASSPATH_ARCHIVE; - lce->htclasses = ht; - lce->path = filename; - lce->pathlen = filenamelen; - - /* SUN compatible -verbose:class output */ - - if (opt_verboseclass) - printf("[Opened %s]\n", filename); - } - -#else - vm_abort("suck_add: zip/jar files not supported"); -#endif - } - else { - if (filename[filenamelen - 1] != '/') {/* XXX fixme for win32 */ - filename[filenamelen] = '/'; - filename[filenamelen + 1] = '\0'; - filenamelen++; - } - - lce = NEW(list_classpath_entry); - - lce->type = CLASSPATH_PATH; - lce->path = filename; - lce->pathlen = filenamelen; - } - - /* add current classpath entry, if no error */ - - if (lce != NULL) - list_add_last(list_classpath_entries, lce); - } - - /* goto next classpath entry, skip ':' delimiter */ - - if ((*end) == ':') - start = end + 1; - else - start = end; - } -} - - -/* suck_add_from_property ****************************************************** - - Adds a classpath form a property entry to the global classpath - entries list. - -*******************************************************************************/ - -void suck_add_from_property(char *key) -{ - char *value; - char *start; - char *end; - char *path; - s4 pathlen; - struct dirent **namelist; - s4 n; - s4 i; - s4 namlen; - char *boot_class_path; - char *p; - - /* get the property value */ - - value = properties_get(key); - - if (value == NULL) - return; - - /* get the directory entries of the property */ - - for (start = value; (*start) != '\0'; ) { - - /* search for ':' delimiter to get the end of the current entry */ - - for (end = start; ((*end) != '\0') && ((*end) != ':'); end++); - - /* found an entry */ - - if (start != end) { - /* allocate memory for the path entry */ - - pathlen = end - start; - path = MNEW(char, pathlen + strlen("0")); - - /* copy and terminate the string */ - - strncpy(path, start, pathlen); - path[pathlen] = '\0'; - - /* Reset namelist to NULL for the freeing in an error case - (see below). */ - - namelist = NULL; - - /* scan the directory found for zip/jar files */ - - n = system_scandir(path, &namelist, scandir_filter, alphasort); - - /* On error, just continue, this should be ok. */ - - if (n > 0) { - for (i = 0; i < n; i++) { -#if defined(_DIRENT_HAVE_D_NAMLEN) - namlen = namelist[i]->d_namlen; -#else - namlen = strlen(namelist[i]->d_name); -#endif - - /* Allocate memory for bootclasspath. */ - - boot_class_path = properties_get("sun.boot.class.path"); - - p = MNEW(char, - pathlen + strlen("/") + namlen + - strlen(":") + - strlen(boot_class_path) + - strlen("0")); - - /* Prepend the file found to the bootclasspath. */ - - strcpy(p, path); - strcat(p, "/"); - strcat(p, namelist[i]->d_name); - strcat(p, ":"); - strcat(p, boot_class_path); - - properties_add("sun.boot.class.path", p); - properties_add("java.boot.class.path", p); - - MFREE(boot_class_path, char, strlen(boot_class_path)); - - /* free the memory allocated by scandir */ - /* (We use `free` as the memory came from the C library.) */ - - free(namelist[i]); - } - } - - /* On some systems (like Linux) when n == 0, then namelist - returned from scnadir is NULL, thus we don't have to - free it. - (Use `free` as the memory came from the C library.) */ - - if (namelist != NULL) - free(namelist); - - MFREE(path, char, pathlen + strlen("0")); - } - - /* goto next entry, skip ':' delimiter */ - - if ((*end) == ':') - start = end + 1; - else - start = end; - } -} - - -/* suck_check_classbuffer_size ************************************************* - - Assert that at least bytes are left to read is limited - to the range of non-negative s4 values. - -*******************************************************************************/ - -bool suck_check_classbuffer_size(classbuffer *cb, s4 len) -{ -#ifdef ENABLE_VERIFIER - if (len < 0 || ((cb->data + cb->size) - cb->pos) < len) { - exceptions_throw_classformaterror(cb->clazz, "Truncated class file"); - return false; - } -#endif /* ENABLE_VERIFIER */ - - return true; -} - - -u1 suck_u1(classbuffer *cb) -{ - u1 a; - - a = SUCK_BE_U1(cb->pos); - cb->pos++; - - return a; -} - - -u2 suck_u2(classbuffer *cb) -{ - u2 a; - - a = SUCK_BE_U2(cb->pos); - cb->pos += 2; - - return a; -} - - -u4 suck_u4(classbuffer *cb) -{ - u4 a; - - a = SUCK_BE_U4(cb->pos); - cb->pos += 4; - - return a; -} - - -u8 suck_u8(classbuffer *cb) -{ -#if U8_AVAILABLE == 1 - u8 a; - - a = SUCK_BE_U8(cb->pos); - cb->pos += 8; - - return a; -#else - u8 v; - - v.high = suck_u4(cb); - v.low = suck_u4(cb); - - return v; -#endif -} - - -float suck_float(classbuffer *cb) -{ - float f; - -#if WORDS_BIGENDIAN == 0 - u1 buffer[4]; - u2 i; - - for (i = 0; i < 4; i++) - buffer[3 - i] = suck_u1(cb); - - MCOPY((u1 *) (&f), buffer, u1, 4); -#else - suck_nbytes((u1*) (&f), cb, 4); -#endif - - assert(sizeof(float) == 4); - - return f; -} - - -double suck_double(classbuffer *cb) -{ - double d; - -#if WORDS_BIGENDIAN == 0 - u1 buffer[8]; - u2 i; - -# if defined(__ARM__) && defined(__ARMEL__) && !defined(__VFP_FP__) - /* - * On little endian ARM processors when using FPA, word order - * of doubles is still big endian. So take that into account - * here. When using VFP, word order of doubles follows byte - * order. (michi 2005/07/24) - */ - for (i = 0; i < 4; i++) - buffer[3 - i] = suck_u1(cb); - for (i = 0; i < 4; i++) - buffer[7 - i] = suck_u1(cb); -# else - for (i = 0; i < 8; i++) - buffer[7 - i] = suck_u1(cb); -# endif /* defined(__ARM__) && ... */ - - MCOPY((u1 *) (&d), buffer, u1, 8); -#else - suck_nbytes((u1*) (&d), cb, 8); -#endif - - assert(sizeof(double) == 8); - - return d; -} - - -/* suck_nbytes ***************************************************************** - - Transfer block of classfile data into a buffer. - -*******************************************************************************/ - -void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len) -{ - MCOPY(buffer, cb->pos, u1, len); - cb->pos += len; -} - - -/* suck_skip_nbytes ************************************************************ - - Skip block of classfile data. - -*******************************************************************************/ - -void suck_skip_nbytes(classbuffer *cb, s4 len) -{ - cb->pos += len; -} - - -/* suck_start ****************************************************************** - - Returns true if classbuffer is already loaded or a file for the - specified class has succussfully been read in. All directories of - the searchpath are used to find the classfile (.class). - Returns NULL if no classfile is found and writes an error message. - -*******************************************************************************/ - -classbuffer *suck_start(classinfo *c) -{ - list_classpath_entry *lce; - char *filename; - s4 filenamelen; - char *path; - FILE *classfile; - s4 len; - struct stat buffer; - classbuffer *cb; - - /* initialize return value */ - - cb = NULL; - - /* get the classname as char string (do it here for the warning at - the end of the function) */ - - filenamelen = utf_bytes(c->name) + strlen(".class") + strlen("0"); - filename = MNEW(char, filenamelen); - - utf_copy(filename, c->name); - strcat(filename, ".class"); - - /* walk through all classpath entries */ - - for (lce = list_first(list_classpath_entries); lce != NULL && cb == NULL; - lce = list_next(list_classpath_entries, lce)) { -#if defined(ENABLE_ZLIB) - if (lce->type == CLASSPATH_ARCHIVE) { - - /* enter a monitor on zip/jar archives */ - - LOCK_MONITOR_ENTER(lce); - - /* try to get the file in current archive */ - - cb = zip_get(lce, c); - - /* leave the monitor */ - - LOCK_MONITOR_EXIT(lce); - - } else { -#endif /* defined(ENABLE_ZLIB) */ - path = MNEW(char, lce->pathlen + filenamelen); - strcpy(path, lce->path); - strcat(path, filename); - - classfile = system_fopen(path, "r"); - - if (classfile) { /* file exists */ - if (!system_stat(path, &buffer)) { /* read classfile data */ - cb = NEW(classbuffer); - cb->clazz = c; - cb->size = buffer.st_size; - cb->data = MNEW(u1, cb->size); - cb->pos = cb->data; - cb->path = lce->path; - - /* read class data */ - - len = system_fread((void *) cb->data, 1, cb->size, - classfile); - - if (len != buffer.st_size) { - suck_stop(cb); -/* if (ferror(classfile)) { */ -/* } */ - } - - /* close the class file */ - - system_fclose(classfile); - } - } - - MFREE(path, char, lce->pathlen + filenamelen); -#if defined(ENABLE_ZLIB) - } -#endif - } - - if (opt_verbose) - if (cb == NULL) - dolog("Warning: Can not open class file '%s'", filename); - - MFREE(filename, char, filenamelen); - - return cb; -} - - -/* suck_stop ******************************************************************* - - Frees memory for buffer with classfile data. - - CAUTION: This function may only be called if buffer has been - allocated by suck_start with reading a file. - -*******************************************************************************/ - -void suck_stop(classbuffer *cb) -{ - /* free memory */ - - MFREE(cb->data, u1, cb->size); - FREE(cb, classbuffer); -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/suck.h b/src/vmcore/suck.h deleted file mode 100644 index cc29e061f..000000000 --- a/src/vmcore/suck.h +++ /dev/null @@ -1,201 +0,0 @@ -/* src/vmcore/suck.h - functions to read LE ordered types from a buffer - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _SUCK_H -#define _SUCK_H - -#include "config.h" -#include "vm/types.h" - -#include "toolbox/hashtable.h" -#include "toolbox/list.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" - - -/* list_classpath_entry *******************************************************/ - -enum { - CLASSPATH_PATH, - CLASSPATH_ARCHIVE -}; - -typedef struct list_classpath_entry list_classpath_entry; - -struct list_classpath_entry { -#if defined(ENABLE_THREADS) - java_object_t header; /* monitor locking on zip/jar files */ -#endif - s4 type; - char *path; - s4 pathlen; -#if defined(ENABLE_ZLIB) - hashtable *htclasses; -#endif - listnode_t linkage; -}; - - -/* macros to read LE and BE types from a buffer ******************************** - - BE macros are for Java class file loading. - LE macros are for ZIP file loading. - -*******************************************************************************/ - -/* LE macros (for ZIP files ) *************************************************/ - -#if defined(__I386__) || defined(__X86_64__) - -/* we can optimize the LE access on little endian machines without alignment */ - -#define SUCK_LE_U1(p) *((u1 *) (p)) -#define SUCK_LE_U2(p) *((u2 *) (p)) -#define SUCK_LE_U4(p) *((u4 *) (p)) - -#if U8_AVAILABLE == 1 -#define SUCK_LE_U8(p) *((u8 *) (p)) -#endif - -#else /* defined(__I386__) || defined(__X86_64__) */ - -#define SUCK_LE_U1(p) \ - ((u1) (p)[0]) - -#define SUCK_LE_U2(p) \ - ((((u2) (p)[1]) << 8) + \ - ((u2) (p)[0])) - -#define SUCK_LE_U4(p) \ - ((((u4) (p)[3]) << 24) + \ - (((u4) (p)[2]) << 16) + \ - (((u4) (p)[1]) << 8) + \ - ((u4) (p)[0])) - -#if U8_AVAILABLE == 1 -#define SUCK_LE_U8(p) \ - ((((u8) (p)[7]) << 56) + \ - (((u8) (p)[6]) << 48) + \ - (((u8) (p)[5]) << 40) + \ - (((u8) (p)[4]) << 32) + \ - (((u8) (p)[3]) << 24) + \ - (((u8) (p)[2]) << 16) + \ - (((u8) (p)[1]) << 8) + \ - ((u8) (p)[0])) -#endif - -#endif /* defined(__I386__) || defined(__X86_64__) */ - - -/* BE macros (for Java class files ) ******************************************/ - -#define SUCK_BE_U1(p) \ - ((u1) (p)[0]) - -#define SUCK_BE_U2(p) \ - ((((u2) (p)[0]) << 8) + \ - ((u2) (p)[1])) - -#define SUCK_BE_U4(p) \ - ((((u4) (p)[0]) << 24) + \ - (((u4) (p)[1]) << 16) + \ - (((u4) (p)[2]) << 8) + \ - ((u4) (p)[3])) - -#if U8_AVAILABLE == 1 -#define SUCK_BE_U8(p) \ - ((((u8) (p)[0]) << 56) + \ - (((u8) (p)[1]) << 48) + \ - (((u8) (p)[2]) << 40) + \ - (((u8) (p)[3]) << 32) + \ - (((u8) (p)[4]) << 24) + \ - (((u8) (p)[5]) << 16) + \ - (((u8) (p)[6]) << 8) + \ - ((u8) (p)[7])) -#endif - - -#define SUCK_BE_S1(p) (s1) SUCK_BE_U1(p) -#define SUCK_BE_S2(p) (s2) SUCK_BE_U2(p) -#define SUCK_BE_S4(p) (s4) SUCK_BE_U4(p) -#define SUCK_BE_S8(p) (s8) SUCK_BE_U8(p) - - -/* signed suck defines ********************************************************/ - -#define suck_s1(a) (s1) suck_u1((a)) -#define suck_s2(a) (s2) suck_u2((a)) -#define suck_s4(a) (s4) suck_u4((a)) -#define suck_s8(a) (s8) suck_u8((a)) - - -/* export variables ***********************************************************/ - -extern list_t *list_classpath_entries; - - -/* function prototypes ********************************************************/ - -bool suck_init(void); - -void suck_add(char *classpath); -void suck_add_from_property(char *key); - -bool suck_check_classbuffer_size(classbuffer *cb, s4 len); - -u1 suck_u1(classbuffer *cb); -u2 suck_u2(classbuffer *cb); -u4 suck_u4(classbuffer *cb); -u8 suck_u8(classbuffer *cb); - -float suck_float(classbuffer *cb); -double suck_double(classbuffer *cb); - -void suck_nbytes(u1 *buffer, classbuffer *cb, s4 len); -void suck_skip_nbytes(classbuffer *cb, s4 len); - -classbuffer *suck_start(classinfo *c); - -void suck_stop(classbuffer *cb); - -#endif /* _SUCK_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/src/vmcore/system.c b/src/vmcore/system.c deleted file mode 100644 index be474a9ef..000000000 --- a/src/vmcore/system.c +++ /dev/null @@ -1,176 +0,0 @@ -/* src/vmcore/system.c - system (OS) functions - - Copyright (C) 2007 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -/* NOTE: In this file we check for all system headers, because we wrap - all system calls into functions for better portability. */ - -#if defined(HAVE_ERRNO_H) -# include -#endif - -#if defined(HAVE_STDINT_H) -# include -#endif - -#if defined(HAVE_STRING_H) -# include -#endif - -#if defined(HAVE_UNISTD_H) -# include -#endif - -#if defined(HAVE_SYS_MMAN_H) -# include -#endif - -#if defined(__DARWIN__) -# include -# include -# include -#endif - -/* this should work on BSD */ -/* #include */ - -#include "vm/vm.h" - - -/* system_mmap_anonymous ******************************************************* - - Maps anonymous memory, even on systems not defining - MAP_ANON(YMOUS). - -*******************************************************************************/ - -void *system_mmap_anonymous(void *addr, size_t len, int prot, int flags) -{ - void *p; - -#if defined(MAP_ANON) || defined(MAP_ANONYMOUS) - p = mmap(addr, len, prot, -# if defined(MAP_ANON) - MAP_ANON | flags, -# else - MAP_ANONYMOUS | flags, -# endif - -1, 0); -#else - int fd; - - fd = open("/dev/zero", O_RDONLY, 0); - - if (fd == -1) - vm_abort("system_mmap_anonymous: open failed: %s", strerror(errno)); - - p = mmap(addr, len, prot, flags, fd, 0); -#endif - -#if defined(MAP_FAILED) - if (p == MAP_FAILED) -#else - if (p == (void *) -1) -#endif - vm_abort("system_mmap_anonymous: mmap failed: %s", strerror(errno)); - - return p; -} - - -/* system_processors_online **************************************************** - - Returns the number of online processors in the system. - - RETURN: - online processor count - -*******************************************************************************/ - -int system_processors_online(void) -{ -#if defined(_SC_NPROC_ONLN) - - return (int) sysconf(_SC_NPROC_ONLN); - -#elif defined(_SC_NPROCESSORS_ONLN) - - return (int) sysconf(_SC_NPROCESSORS_ONLN); - -#elif defined(__DARWIN__) - - host_basic_info_data_t hinfo; - mach_msg_type_number_t hinfo_count = HOST_BASIC_INFO_COUNT; - kern_return_t rc; - - rc = host_info(mach_host_self(), HOST_BASIC_INFO, - (host_info_t) &hinfo, &hinfo_count); - - if (rc != KERN_SUCCESS) { - return -1; - } - - /* XXX michi: according to my infos this should be - hinfo.max_cpus, can someone please confirm or deny that? */ - return (int) hinfo.avail_cpus; - -#elif defined(__FREEBSD__) -# error IMPLEMENT ME! - - /* this should work in BSD */ - /* - int ncpu, mib[2], rc; - size_t len; - - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - len = sizeof(ncpu); - rc = sysctl(mib, 2, &ncpu, &len, NULL, 0); - - return (int32_t) ncpu; - */ - -#else - - return 1; - -#endif -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/system.h b/src/vmcore/system.h deleted file mode 100644 index 6d6e6838d..000000000 --- a/src/vmcore/system.h +++ /dev/null @@ -1,458 +0,0 @@ -/* src/vmcore/system.h - system (OS) functions - - Copyright (C) 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _VMCORE_SYSTEM_H -#define _VMCORE_SYSTEM_H - -#include "config.h" - -/* NOTE: In this file we check for all system headers, because we wrap - all system calls into inline functions for better portability. */ - -#if defined(HAVE_DIRENT_H) -# include -#endif - -#if defined(HAVE_FCNTL_H) -# include -#endif - -#if defined(ENABLE_JRE_LAYOUT) -# if defined(HAVE_LIBGEN_H) -# include -# endif -#endif - -#if defined(HAVE_STDINT_H) -# include -#endif - -#if defined(HAVE_STDIO_H) -# include -#endif - -#if defined(HAVE_STDLIB_H) -# include -#endif - -#if defined(HAVE_STRING_H) -# include -#endif - -#if defined(HAVE_UNISTD_H) -# include -#endif - -#if defined(HAVE_SYS_MMAN_H) -# include -#endif - -#if defined(HAVE_SYS_SOCKET_H) -# include -#endif - -#if defined(HAVE_SYS_STAT_H) -# include -#endif - -#if defined(HAVE_SYS_TYPES_H) -# include -#endif - - -/* inline functions ***********************************************************/ - -inline static void system_abort(void) -{ -#if defined(HAVE_ABORT) - abort(); -#else -# error abort not available -#endif -} - -inline static int system_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) -{ -#if defined(HAVE_ACCEPT) - return accept(sockfd, addr, addrlen); -#else -# error accept not available -#endif -} - -inline static int system_access(const char *pathname, int mode) -{ -#if defined(HAVE_ACCESS) - return access(pathname, mode); -#else -# error access not available -#endif -} - -inline static int system_atoi(const char *nptr) -{ -#if defined(HAVE_ATOI) - return atoi(nptr); -#else -# error atoi not available -#endif -} - -inline static void *system_calloc(size_t nmemb, size_t size) -{ -#if defined(HAVE_CALLOC) - return calloc(nmemb, size); -#else -# error calloc not available -#endif -} - -inline static int system_close(int fd) -{ -#if defined(HAVE_CLOSE) - return close(fd); -#else -# error close not available -#endif -} - -inline static int system_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) -{ -#if defined(HAVE_CONNECT) - return connect(sockfd, serv_addr, addrlen); -#else -# error connect not available -#endif -} - -#if defined(ENABLE_JRE_LAYOUT) -inline static char *system_dirname(char *path) -{ -#if defined(HAVE_DIRNAME) - return dirname(path); -#else -# error dirname not available -#endif -} -#endif - -inline static FILE *system_fopen(const char *path, const char *mode) -{ -#if defined(HAVE_FOPEN) - return fopen(path, mode); -#else -# error fopen not available -#endif -} - -inline static int system_fclose(FILE *fp) -{ -#if defined(HAVE_FCLOSE) - return fclose(fp); -#else -# error fclose not available -#endif -} - -inline static size_t system_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) -{ -#if defined(HAVE_FREAD) - return fread(ptr, size, nmemb, stream); -#else -# error fread not available -#endif -} - -inline static void system_free(void *ptr) -{ -#if defined(HAVE_FREE) - free(ptr); -#else -# error free not available -#endif -} - -inline static int system_fsync(int fd) -{ -#if defined(HAVE_FSYNC) - return fsync(fd); -#else -# error fsync not available -#endif -} - -inline static int system_ftruncate(int fd, off_t length) -{ -#if defined(HAVE_FTRUNCATE) - return ftruncate(fd, length); -#else -# error ftruncate not available -#endif -} - -inline static int system_gethostname(char *name, size_t len) -{ -#if defined(HAVE_GETHOSTNAME) - return gethostname(name, len); -#else -# error gethostname not available -#endif -} - -inline static int system_getpagesize(void) -{ -#if defined(HAVE_GETPAGESIZE) - return getpagesize(); -#else -# error getpagesize not available -#endif -} - -inline static int system_getsockname(int s, struct sockaddr *name, socklen_t *namelen) -{ -#if defined(HAVE_GETSOCKNAME) - return getsockname(s, name, namelen); -#else -# error getsockname not available -#endif -} - -inline static int system_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) -{ -#if defined(HAVE_GETSOCKOPT) - return getsockopt(s, level, optname, optval, optlen); -#else -# error getsockopt not available -#endif -} - -inline static int system_listen(int sockfd, int backlog) -{ -#if defined(HAVE_LISTEN) - return listen(sockfd, backlog); -#else -# error listen not available -#endif -} - -inline static off_t system_lseek(int fildes, off_t offset, int whence) -{ -#if defined(HAVE_LSEEK) - return lseek(fildes, offset, whence); -#else -# error lseek not available -#endif -} - -inline static void *system_malloc(size_t size) -{ -#if defined(HAVE_MALLOC) - return malloc(size); -#else -# error malloc not available -#endif -} - -inline static void *system_memcpy(void *dest, const void *src, size_t n) -{ -#if defined(HAVE_MEMCPY) - return memcpy(dest, src, n); -#else -# error memcpy not available -#endif -} - -inline static void *system_memset(void *s, int c, size_t n) -{ -#if defined(HAVE_MEMSET) - return memset(s, c, n); -#else -# error memset not available -#endif -} - -inline static int system_mprotect(void *addr, size_t len, int prot) -{ -#if defined(HAVE_MPROTECT) - return mprotect(addr, len, prot); -#else -# error mprotect not available -#endif -} - -inline static int system_open(const char *pathname, int flags, mode_t mode) -{ -#if defined(HAVE_OPEN) - return open(pathname, flags, mode); -#else -# error open not available -#endif -} - -inline static ssize_t system_read(int fd, void *buf, size_t count) -{ -#if defined(HAVE_READ) - return read(fd, buf, count); -#else -# error read not available -#endif -} - -inline static void *system_realloc(void *ptr, size_t size) -{ -#if defined(HAVE_REALLOC) - return realloc(ptr, size); -#else -# error realloc not available -#endif -} - -#if defined(__LINUX__) -inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compar)(const void *, const void *)) -#elif defined(__IRIX__) -inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(dirent_t *), int(*compar)(dirent_t **, dirent_t **)) -#else -inline static int system_scandir(const char *dir, struct dirent ***namelist, int(*filter)(struct dirent *), int(*compar)(const void *, const void *)) -#endif -{ -#if defined(HAVE_SCANDIR) - return scandir(dir, namelist, filter, compar); -#else -# error scandir not available -#endif -} - -inline static int system_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen) -{ -#if defined(HAVE_SETSOCKOPT) - return setsockopt(s, level, optname, optval, optlen); -#else -# error setsockopt not available -#endif -} - -inline static int system_shutdown(int s, int how) -{ -#if defined(HAVE_SHUTDOWN) - return shutdown(s, how); -#else -# error shutdown not available -#endif -} - -inline static int system_socket(int domain, int type, int protocol) -{ -#if defined(HAVE_SOCKET) - return socket(domain, type, protocol); -#else -# error socket not available -#endif -} - -inline static int system_stat(const char *path, struct stat *buf) -{ -#if defined(HAVE_STAT) - return stat(path, buf); -#else -# error stat not available -#endif -} - -inline static char *system_strcat(char *dest, const char *src) -{ -#if defined(HAVE_STRCAT) - return strcat(dest, src); -#else -# error strcat not available -#endif -} - -inline static char *system_strcpy(char *dest, const char *src) -{ -#if defined(HAVE_STRCPY) - return strcpy(dest, src); -#else -# error strcpy not available -#endif -} - -inline static char *system_strdup(const char *s) -{ -#if defined(HAVE_STRDUP) - return strdup(s); -#else -# error strdup not available -#endif -} - -inline static char *system_strerror(int errnum) -{ -#if defined(HAVE_STRERROR) - return strerror(errnum); -#else -# error strerror not available -#endif -} - -inline static size_t system_strlen(const char *s) -{ -#if defined(HAVE_STRLEN) - return strlen(s); -#else -# error strlen not available -#endif -} - -inline static ssize_t system_write(int fd, const void *buf, size_t count) -{ -#if defined(HAVE_WRITE) - return write(fd, buf, count); -#else -# error write not available -#endif -} - - -/* function prototypes ********************************************************/ - -void *system_mmap_anonymous(void *addr, size_t len, int prot, int flags); -int system_processors_online(void); - -#endif /* _VMCORE_SYSTEM_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/utf8.c b/src/vmcore/utf8.c deleted file mode 100644 index b292d95b0..000000000 --- a/src/vmcore/utf8.c +++ /dev/null @@ -1,1933 +0,0 @@ -/* src/vmcore/utf8.c - utf8 string functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include - -#include "vm/types.h" - -#include "mm/memory.h" - -#include "threads/lock-common.h" - -#include "toolbox/hashtable.h" - -#include "vm/exceptions.h" - -#include "vmcore/options.h" - -#if defined(ENABLE_STATISTICS) -# include "vmcore/statistics.h" -#endif - -#include "vmcore/utf8.h" - - -/* global variables ***********************************************************/ - -/* hashsize must be power of 2 */ - -#define HASHTABLE_UTF_SIZE 16384 /* initial size of utf-hash */ - -hashtable *hashtable_utf; /* hashtable for utf8-symbols */ - - -/* utf-symbols for pointer comparison of frequently used strings **************/ - -utf *utf_java_lang_Object; - -utf *utf_java_lang_Class; -utf *utf_java_lang_ClassLoader; -utf *utf_java_lang_Cloneable; -utf *utf_java_lang_SecurityManager; -utf *utf_java_lang_String; -utf *utf_java_lang_ThreadGroup; -utf *utf_java_lang_ref_SoftReference; -utf *utf_java_lang_ref_WeakReference; -utf *utf_java_lang_ref_PhantomReference; -utf *utf_java_io_Serializable; - -utf *utf_java_lang_Throwable; -utf *utf_java_lang_Error; - -utf *utf_java_lang_AbstractMethodError; -utf *utf_java_lang_ClassCircularityError; -utf *utf_java_lang_ClassFormatError; -utf *utf_java_lang_ExceptionInInitializerError; -utf *utf_java_lang_IncompatibleClassChangeError; -utf *utf_java_lang_InstantiationError; -utf *utf_java_lang_InternalError; -utf *utf_java_lang_LinkageError; -utf *utf_java_lang_NoClassDefFoundError; -utf *utf_java_lang_NoSuchFieldError; -utf *utf_java_lang_NoSuchMethodError; -utf *utf_java_lang_OutOfMemoryError; -utf *utf_java_lang_UnsatisfiedLinkError; -utf *utf_java_lang_UnsupportedClassVersionError; -utf *utf_java_lang_VerifyError; -utf *utf_java_lang_VirtualMachineError; - -utf *utf_java_lang_Exception; - -utf *utf_java_lang_ArithmeticException; -utf *utf_java_lang_ArrayIndexOutOfBoundsException; -utf *utf_java_lang_ArrayStoreException; -utf *utf_java_lang_ClassCastException; -utf *utf_java_lang_ClassNotFoundException; -utf *utf_java_lang_CloneNotSupportedException; -utf *utf_java_lang_IllegalAccessException; -utf *utf_java_lang_IllegalArgumentException; -utf *utf_java_lang_IllegalMonitorStateException; -utf *utf_java_lang_InstantiationException; -utf *utf_java_lang_InterruptedException; -utf *utf_java_lang_NegativeArraySizeException; -utf *utf_java_lang_NullPointerException; -utf *utf_java_lang_RuntimeException; -utf *utf_java_lang_StringIndexOutOfBoundsException; - -utf *utf_java_lang_reflect_InvocationTargetException; - -utf *utf_java_security_PrivilegedActionException; - -#if defined(ENABLE_JAVASE) -utf* utf_java_lang_Void; -#endif - -utf* utf_java_lang_Boolean; -utf* utf_java_lang_Byte; -utf* utf_java_lang_Character; -utf* utf_java_lang_Short; -utf* utf_java_lang_Integer; -utf* utf_java_lang_Long; -utf* utf_java_lang_Float; -utf* utf_java_lang_Double; - -#if defined(ENABLE_JAVASE) -utf *utf_java_lang_StackTraceElement; -utf *utf_java_lang_reflect_Constructor; -utf *utf_java_lang_reflect_Field; -utf *utf_java_lang_reflect_Method; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -utf *utf_java_lang_reflect_VMConstructor; -utf *utf_java_lang_reflect_VMField; -utf *utf_java_lang_reflect_VMMethod; -# endif - -utf *utf_java_util_Vector; -#endif - -utf *utf_InnerClasses; /* InnerClasses */ -utf *utf_ConstantValue; /* ConstantValue */ -utf *utf_Code; /* Code */ -utf *utf_Exceptions; /* Exceptions */ -utf *utf_LineNumberTable; /* LineNumberTable */ -utf *utf_SourceFile; /* SourceFile */ - -#if defined(ENABLE_JAVASE) -utf *utf_EnclosingMethod; -utf *utf_Signature; -utf *utf_StackMapTable; - -#if defined(ENABLE_ANNOTATIONS) -utf *utf_RuntimeVisibleAnnotations; /* RuntimeVisibleAnnotations */ -utf *utf_RuntimeInvisibleAnnotations; /* RuntimeInvisibleAnnotations */ -utf *utf_RuntimeVisibleParameterAnnotations; /* RuntimeVisibleParameterAnnotations */ -utf *utf_RuntimeInvisibleParameterAnnotations; /* RuntimeInvisibleParameterAnnotations */ -utf *utf_AnnotationDefault; /* AnnotationDefault */ -#endif -#endif - -utf *utf_init; /* */ -utf *utf_clinit; /* */ -utf *utf_clone; /* clone */ -utf *utf_finalize; /* finalize */ -utf *utf_invoke; -utf *utf_main; -utf *utf_run; /* run */ - -utf *utf_add; -utf *utf_remove; -utf *utf_addThread; -utf *utf_removeThread; -utf *utf_put; -utf *utf_get; -utf *utf_uncaughtException; -utf *utf_value; - -utf *utf_fillInStackTrace; -utf *utf_findNative; -utf *utf_getSystemClassLoader; -utf *utf_initCause; -utf *utf_loadClass; -utf *utf_loadClassInternal; -utf *utf_printStackTrace; - -utf *utf_division_by_zero; - -utf *utf_Z; /* Z */ -utf *utf_B; /* B */ -utf *utf_C; /* C */ -utf *utf_S; /* S */ -utf *utf_I; /* I */ -utf *utf_J; /* J */ -utf *utf_F; /* F */ -utf *utf_D; /* D */ - -utf *utf_void__void; /* ()V */ -utf *utf_boolean__void; /* (Z)V */ -utf *utf_byte__void; /* (B)V */ -utf *utf_char__void; /* (C)V */ -utf *utf_short__void; /* (S)V */ -utf *utf_int__void; /* (I)V */ -utf *utf_long__void; /* (J)V */ -utf *utf_float__void; /* (F)V */ -utf *utf_double__void; /* (D)V */ - -utf *utf_void__java_lang_ClassLoader; /* ()Ljava/lang/ClassLoader; */ -utf *utf_void__java_lang_Object; /* ()Ljava/lang/Object; */ -utf *utf_void__java_lang_Throwable; /* ()Ljava/lang/Throwable; */ -utf *utf_java_lang_ClassLoader_java_lang_String__J; -utf *utf_java_lang_Exception__V; /* (Ljava/lang/Exception;)V */ -utf *utf_java_lang_Object__java_lang_Object; -utf *utf_java_lang_String__void; /* (Ljava/lang/String;)V */ -utf *utf_java_lang_String__java_lang_Class; -utf *utf_java_lang_Thread__V; /* (Ljava/lang/Thread;)V */ -utf *utf_java_lang_Thread_java_lang_Throwable__V; -utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V; -utf *utf_java_lang_Throwable__void; /* (Ljava/lang/Throwable;)V */ -utf *utf_java_lang_Throwable__java_lang_Throwable; - -utf *utf_not_named_yet; /* special name for unnamed classes */ -utf *utf_null; -utf *array_packagename; - - -/* utf_init ******************************************************************** - - Initializes the utf8 subsystem. - -*******************************************************************************/ - -void utf8_init(void) -{ - TRACESUBSYSTEMINITIALIZATION("utf8_init"); - - /* create utf8 hashtable */ - - hashtable_utf = NEW(hashtable); - - hashtable_create(hashtable_utf, HASHTABLE_UTF_SIZE); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_utf_len += sizeof(utf*) * hashtable_utf->size; -#endif - - /* create utf-symbols for pointer comparison of frequently used strings */ - - utf_java_lang_Object = utf_new_char("java/lang/Object"); - - utf_java_lang_Class = utf_new_char("java/lang/Class"); - utf_java_lang_ClassLoader = utf_new_char("java/lang/ClassLoader"); - utf_java_lang_Cloneable = utf_new_char("java/lang/Cloneable"); - utf_java_lang_SecurityManager = utf_new_char("java/lang/SecurityManager"); - utf_java_lang_String = utf_new_char("java/lang/String"); - utf_java_lang_ThreadGroup = utf_new_char("java/lang/ThreadGroup"); - - utf_java_lang_ref_SoftReference = - utf_new_char("java/lang/ref/SoftReference"); - - utf_java_lang_ref_WeakReference = - utf_new_char("java/lang/ref/WeakReference"); - - utf_java_lang_ref_PhantomReference = - utf_new_char("java/lang/ref/PhantomReference"); - - utf_java_io_Serializable = utf_new_char("java/io/Serializable"); - - utf_java_lang_Throwable = utf_new_char("java/lang/Throwable"); - utf_java_lang_Error = utf_new_char("java/lang/Error"); - - utf_java_lang_ClassCircularityError = - utf_new_char("java/lang/ClassCircularityError"); - - utf_java_lang_ClassFormatError = utf_new_char("java/lang/ClassFormatError"); - - utf_java_lang_ExceptionInInitializerError = - utf_new_char("java/lang/ExceptionInInitializerError"); - - utf_java_lang_IncompatibleClassChangeError = - utf_new_char("java/lang/IncompatibleClassChangeError"); - - utf_java_lang_InstantiationError = - utf_new_char("java/lang/InstantiationError"); - - utf_java_lang_InternalError = utf_new_char("java/lang/InternalError"); - utf_java_lang_LinkageError = utf_new_char("java/lang/LinkageError"); - - utf_java_lang_NoClassDefFoundError = - utf_new_char("java/lang/NoClassDefFoundError"); - - utf_java_lang_OutOfMemoryError = utf_new_char("java/lang/OutOfMemoryError"); - - utf_java_lang_UnsatisfiedLinkError = - utf_new_char("java/lang/UnsatisfiedLinkError"); - - utf_java_lang_UnsupportedClassVersionError = - utf_new_char("java/lang/UnsupportedClassVersionError"); - - utf_java_lang_VerifyError = utf_new_char("java/lang/VerifyError"); - - utf_java_lang_VirtualMachineError = - utf_new_char("java/lang/VirtualMachineError"); - -#if defined(ENABLE_JAVASE) - utf_java_lang_AbstractMethodError = - utf_new_char("java/lang/AbstractMethodError"); - - utf_java_lang_NoSuchFieldError = - utf_new_char("java/lang/NoSuchFieldError"); - - utf_java_lang_NoSuchMethodError = - utf_new_char("java/lang/NoSuchMethodError"); -#endif - - utf_java_lang_Exception = utf_new_char("java/lang/Exception"); - - utf_java_lang_ArithmeticException = - utf_new_char("java/lang/ArithmeticException"); - - utf_java_lang_ArrayIndexOutOfBoundsException = - utf_new_char("java/lang/ArrayIndexOutOfBoundsException"); - - utf_java_lang_ArrayStoreException = - utf_new_char("java/lang/ArrayStoreException"); - - utf_java_lang_ClassCastException = - utf_new_char("java/lang/ClassCastException"); - - utf_java_lang_ClassNotFoundException = - utf_new_char("java/lang/ClassNotFoundException"); - - utf_java_lang_CloneNotSupportedException = - utf_new_char("java/lang/CloneNotSupportedException"); - - utf_java_lang_IllegalAccessException = - utf_new_char("java/lang/IllegalAccessException"); - - utf_java_lang_IllegalArgumentException = - utf_new_char("java/lang/IllegalArgumentException"); - - utf_java_lang_IllegalMonitorStateException = - utf_new_char("java/lang/IllegalMonitorStateException"); - - utf_java_lang_InstantiationException = - utf_new_char("java/lang/InstantiationException"); - - utf_java_lang_InterruptedException = - utf_new_char("java/lang/InterruptedException"); - - utf_java_lang_NegativeArraySizeException = - utf_new_char("java/lang/NegativeArraySizeException"); - - utf_java_lang_NullPointerException = - utf_new_char("java/lang/NullPointerException"); - - utf_java_lang_RuntimeException = - utf_new_char("java/lang/RuntimeException"); - - utf_java_lang_StringIndexOutOfBoundsException = - utf_new_char("java/lang/StringIndexOutOfBoundsException"); - - utf_java_lang_reflect_InvocationTargetException = - utf_new_char("java/lang/reflect/InvocationTargetException"); - - utf_java_security_PrivilegedActionException = - utf_new_char("java/security/PrivilegedActionException"); - -#if defined(ENABLE_JAVASE) - utf_java_lang_Void = utf_new_char("java/lang/Void"); -#endif - - utf_java_lang_Boolean = utf_new_char("java/lang/Boolean"); - utf_java_lang_Byte = utf_new_char("java/lang/Byte"); - utf_java_lang_Character = utf_new_char("java/lang/Character"); - utf_java_lang_Short = utf_new_char("java/lang/Short"); - utf_java_lang_Integer = utf_new_char("java/lang/Integer"); - utf_java_lang_Long = utf_new_char("java/lang/Long"); - utf_java_lang_Float = utf_new_char("java/lang/Float"); - utf_java_lang_Double = utf_new_char("java/lang/Double"); - -#if defined(ENABLE_JAVASE) - utf_java_lang_StackTraceElement = - utf_new_char("java/lang/StackTraceElement"); - - utf_java_lang_reflect_Constructor = - utf_new_char("java/lang/reflect/Constructor"); - - utf_java_lang_reflect_Field = utf_new_char("java/lang/reflect/Field"); - utf_java_lang_reflect_Method = utf_new_char("java/lang/reflect/Method"); - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) - utf_java_lang_reflect_VMConstructor = utf_new_char("java/lang/reflect/VMConstructor"); - utf_java_lang_reflect_VMField = utf_new_char("java/lang/reflect/VMField"); - utf_java_lang_reflect_VMMethod = utf_new_char("java/lang/reflect/VMMethod"); -# endif - - utf_java_util_Vector = utf_new_char("java/util/Vector"); -#endif - - utf_InnerClasses = utf_new_char("InnerClasses"); - utf_ConstantValue = utf_new_char("ConstantValue"); - utf_Code = utf_new_char("Code"); - utf_Exceptions = utf_new_char("Exceptions"); - utf_LineNumberTable = utf_new_char("LineNumberTable"); - utf_SourceFile = utf_new_char("SourceFile"); - -#if defined(ENABLE_JAVASE) - utf_EnclosingMethod = utf_new_char("EnclosingMethod"); - utf_Signature = utf_new_char("Signature"); - utf_StackMapTable = utf_new_char("StackMapTable"); - -# if defined(ENABLE_ANNOTATIONS) - utf_RuntimeVisibleAnnotations = utf_new_char("RuntimeVisibleAnnotations"); - utf_RuntimeInvisibleAnnotations = utf_new_char("RuntimeInvisibleAnnotations"); - utf_RuntimeVisibleParameterAnnotations = utf_new_char("RuntimeVisibleParameterAnnotations"); - utf_RuntimeInvisibleParameterAnnotations = utf_new_char("RuntimeInvisibleParameterAnnotations"); - utf_AnnotationDefault = utf_new_char("AnnotationDefault"); -# endif -#endif - - utf_init = utf_new_char(""); - utf_clinit = utf_new_char(""); - utf_clone = utf_new_char("clone"); - utf_finalize = utf_new_char("finalize"); - utf_invoke = utf_new_char("invoke"); - utf_main = utf_new_char("main"); - utf_run = utf_new_char("run"); - - utf_add = utf_new_char("add"); - utf_remove = utf_new_char("remove"); - utf_addThread = utf_new_char("addThread"); - utf_removeThread = utf_new_char("removeThread"); - utf_put = utf_new_char("put"); - utf_get = utf_new_char("get"); - utf_uncaughtException = utf_new_char("uncaughtException"); - utf_value = utf_new_char("value"); - - utf_fillInStackTrace = utf_new_char("fillInStackTrace"); - utf_findNative = utf_new_char("findNative"); - utf_getSystemClassLoader = utf_new_char("getSystemClassLoader"); - utf_initCause = utf_new_char("initCause"); - utf_loadClass = utf_new_char("loadClass"); - utf_loadClassInternal = utf_new_char("loadClassInternal"); - utf_printStackTrace = utf_new_char("printStackTrace"); - - utf_division_by_zero = utf_new_char("/ by zero"); - - utf_Z = utf_new_char("Z"); - utf_B = utf_new_char("B"); - utf_C = utf_new_char("C"); - utf_S = utf_new_char("S"); - utf_I = utf_new_char("I"); - utf_J = utf_new_char("J"); - utf_F = utf_new_char("F"); - utf_D = utf_new_char("D"); - - utf_void__void = utf_new_char("()V"); - utf_boolean__void = utf_new_char("(Z)V"); - utf_byte__void = utf_new_char("(B)V"); - utf_char__void = utf_new_char("(C)V"); - utf_short__void = utf_new_char("(S)V"); - utf_int__void = utf_new_char("(I)V"); - utf_long__void = utf_new_char("(J)V"); - utf_float__void = utf_new_char("(F)V"); - utf_double__void = utf_new_char("(D)V"); - utf_void__java_lang_Object = utf_new_char("()Ljava/lang/Object;"); - utf_void__java_lang_Throwable = utf_new_char("()Ljava/lang/Throwable;"); - - utf_void__java_lang_ClassLoader = - utf_new_char("()Ljava/lang/ClassLoader;"); - - utf_java_lang_ClassLoader_java_lang_String__J = - utf_new_char("(Ljava/lang/ClassLoader;Ljava/lang/String;)J"); - - utf_java_lang_Exception__V = utf_new_char("(Ljava/lang/Exception;)V"); - - utf_java_lang_Object__java_lang_Object = - utf_new_char("(Ljava/lang/Object;)Ljava/lang/Object;"); - - utf_java_lang_String__void = utf_new_char("(Ljava/lang/String;)V"); - - utf_java_lang_String__java_lang_Class = - utf_new_char("(Ljava/lang/String;)Ljava/lang/Class;"); - - utf_java_lang_Thread__V = utf_new_char("(Ljava/lang/Thread;)V"); - - utf_java_lang_Thread_java_lang_Throwable__V = - utf_new_char("(Ljava/lang/Thread;Ljava/lang/Throwable;)V"); - - utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V = - utf_new_char("(Ljava/lang/ThreadGroup;Ljava/lang/String;)V"); - - utf_java_lang_Throwable__void = utf_new_char("(Ljava/lang/Throwable;)V"); - - utf_java_lang_Throwable__java_lang_Throwable = - utf_new_char("(Ljava/lang/Throwable;)Ljava/lang/Throwable;"); - - utf_null = utf_new_char("null"); - utf_not_named_yet = utf_new_char("\t"); - array_packagename = utf_new_char("\t"); -} - - -/* utf_hashkey ***************************************************************** - - The hashkey is computed from the utf-text by using up to 8 - characters. For utf-symbols longer than 15 characters 3 characters - are taken from the beginning and the end, 2 characters are taken - from the middle. - -*******************************************************************************/ - -#define nbs(val) ((u4) *(++text) << val) /* get next byte, left shift by val */ -#define fbs(val) ((u4) *( text) << val) /* get first byte, left shift by val */ - -u4 utf_hashkey(const char *text, u4 length) -{ - const char *start_pos = text; /* pointer to utf text */ - u4 a; - - switch (length) { - case 0: /* empty string */ - return 0; - - case 1: return fbs(0); - case 2: return fbs(0) ^ nbs(3); - case 3: return fbs(0) ^ nbs(3) ^ nbs(5); - case 4: return fbs(0) ^ nbs(2) ^ nbs(4) ^ nbs(6); - case 5: return fbs(0) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(6); - case 6: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(5) ^ nbs(6); - case 7: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6); - case 8: return fbs(0) ^ nbs(1) ^ nbs(2) ^ nbs(3) ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7); - - case 9: - a = fbs(0); - a ^= nbs(1); - a ^= nbs(2); - text++; - return a ^ nbs(4) ^ nbs(5) ^ nbs(6) ^ nbs(7) ^ nbs(8); - - case 10: - a = fbs(0); - text++; - a ^= nbs(2); - a ^= nbs(3); - a ^= nbs(4); - text++; - return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9); - - case 11: - a = fbs(0); - text++; - a ^= nbs(2); - a ^= nbs(3); - a ^= nbs(4); - text++; - return a ^ nbs(6) ^ nbs(7) ^ nbs(8) ^ nbs(9) ^ nbs(10); - - case 12: - a = fbs(0); - text += 2; - a ^= nbs(2); - a ^= nbs(3); - text++; - a ^= nbs(5); - a ^= nbs(6); - a ^= nbs(7); - text++; - return a ^ nbs(9) ^ nbs(10); - - case 13: - a = fbs(0); - a ^= nbs(1); - text++; - a ^= nbs(3); - a ^= nbs(4); - text += 2; - a ^= nbs(7); - a ^= nbs(8); - text += 2; - return a ^ nbs(9) ^ nbs(10); - - case 14: - a = fbs(0); - text += 2; - a ^= nbs(3); - a ^= nbs(4); - text += 2; - a ^= nbs(7); - a ^= nbs(8); - text += 2; - return a ^ nbs(9) ^ nbs(10) ^ nbs(11); - - case 15: - a = fbs(0); - text += 2; - a ^= nbs(3); - a ^= nbs(4); - text += 2; - a ^= nbs(7); - a ^= nbs(8); - text += 2; - return a ^ nbs(9) ^ nbs(10) ^ nbs(11); - - default: /* 3 characters from beginning */ - a = fbs(0); - text += 2; - a ^= nbs(3); - a ^= nbs(4); - - /* 2 characters from middle */ - text = start_pos + (length / 2); - a ^= fbs(5); - text += 2; - a ^= nbs(6); - - /* 3 characters from end */ - text = start_pos + length - 4; - - a ^= fbs(7); - text++; - - return a ^ nbs(10) ^ nbs(11); - } -} - -/* utf_full_hashkey ************************************************************ - - This function computes a hash value using all bytes in the string. - - The algorithm is the "One-at-a-time" algorithm as published - by Bob Jenkins on http://burtleburtle.net/bob/hash/doobs.html. - -*******************************************************************************/ - -u4 utf_full_hashkey(const char *text, u4 length) -{ - register const unsigned char *p = (const unsigned char *) text; - register u4 hash; - register u4 i; - - hash = 0; - for (i=length; i--;) - { - hash += *p++; - hash += (hash << 10); - hash ^= (hash >> 6); - } - hash += (hash << 3); - hash ^= (hash >> 11); - hash += (hash << 15); - - return hash; -} - -/* unicode_hashkey ************************************************************* - - Compute the hashkey of a unicode string. - -*******************************************************************************/ - -u4 unicode_hashkey(u2 *text, u2 len) -{ - return utf_hashkey((char *) text, len); -} - - -/* utf_new ********************************************************************* - - Creates a new utf-symbol, the text of the symbol is passed as a - u1-array. The function searches the utf-hashtable for a utf-symbol - with this text. On success the element returned, otherwise a new - hashtable element is created. - - If the number of entries in the hashtable exceeds twice the size of - the hashtable slots a reorganization of the hashtable is done and - the utf symbols are copied to a new hashtable with doubled size. - -*******************************************************************************/ - -utf *utf_new(const char *text, u2 length) -{ - u4 key; /* hashkey computed from utf-text */ - u4 slot; /* slot in hashtable */ - utf *u; /* hashtable element */ - u2 i; - - LOCK_MONITOR_ENTER(hashtable_utf->header); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_utf_new++; -#endif - - key = utf_hashkey(text, length); - slot = key & (hashtable_utf->size - 1); - u = hashtable_utf->ptr[slot]; - - /* search external hash chain for utf-symbol */ - - while (u) { - if (u->blength == length) { - /* compare text of hashtable elements */ - - for (i = 0; i < length; i++) - if (text[i] != u->text[i]) - goto nomatch; - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_utf_new_found++; -#endif - - /* symbol found in hashtable */ - - LOCK_MONITOR_EXIT(hashtable_utf->header); - - return u; - } - - nomatch: - u = u->hashlink; /* next element in external chain */ - } - - /* location in hashtable found, create new utf element */ - - u = NEW(utf); - - u->blength = length; /* length in bytes of utfstring */ - u->hashlink = hashtable_utf->ptr[slot]; /* link in external hashchain */ - u->text = mem_alloc(length + 1);/* allocate memory for utf-text */ - - memcpy(u->text, text, length); /* copy utf-text */ - u->text[length] = '\0'; - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_utf_len += sizeof(utf) + length + 1; -#endif - - hashtable_utf->ptr[slot] = u; /* insert symbol into table */ - hashtable_utf->entries++; /* update number of entries */ - - if (hashtable_utf->entries > (hashtable_utf->size * 2)) { - - /* reorganization of hashtable, average length of the external - chains is approx. 2 */ - - hashtable *newhash; /* the new hashtable */ - u4 i; - utf *u; - utf *nextu; - u4 slot; - - /* create new hashtable, double the size */ - - newhash = hashtable_resize(hashtable_utf, hashtable_utf->size * 2); - -#if defined(ENABLE_STATISTICS) - if (opt_stat) - count_utf_len += sizeof(utf*) * hashtable_utf->size; -#endif - - /* transfer elements to new hashtable */ - - for (i = 0; i < hashtable_utf->size; i++) { - u = hashtable_utf->ptr[i]; - - while (u) { - nextu = u->hashlink; - slot = utf_hashkey(u->text, u->blength) & (newhash->size - 1); - - u->hashlink = (utf *) newhash->ptr[slot]; - newhash->ptr[slot] = u; - - /* follow link in external hash chain */ - - u = nextu; - } - } - - /* dispose old table */ - - hashtable_free(hashtable_utf); - - hashtable_utf = newhash; - } - - LOCK_MONITOR_EXIT(hashtable_utf->header); - - return u; -} - - -/* utf_new_u2 ****************************************************************** - - Make utf symbol from u2 array, if isclassname is true '.' is - replaced by '/'. - -*******************************************************************************/ - -utf *utf_new_u2(u2 *unicode_pos, u4 unicode_length, bool isclassname) -{ - char *buffer; /* memory buffer for unicode characters */ - char *pos; /* pointer to current position in buffer */ - u4 left; /* unicode characters left */ - u4 buflength; /* utf length in bytes of the u2 array */ - utf *result; /* resulting utf-string */ - int i; - - /* determine utf length in bytes and allocate memory */ - - buflength = u2_utflength(unicode_pos, unicode_length); - buffer = MNEW(char, buflength); - - left = buflength; - pos = buffer; - - for (i = 0; i++ < unicode_length; unicode_pos++) { - /* next unicode character */ - u2 c = *unicode_pos; - - if ((c != 0) && (c < 0x80)) { - /* 1 character */ - left--; - if ((int) left < 0) break; - /* convert classname */ - if (isclassname && c == '.') - *pos++ = '/'; - else - *pos++ = (char) c; - - } else if (c < 0x800) { - /* 2 characters */ - unsigned char high = c >> 6; - unsigned char low = c & 0x3F; - left = left - 2; - if ((int) left < 0) break; - *pos++ = high | 0xC0; - *pos++ = low | 0x80; - - } else { - /* 3 characters */ - char low = c & 0x3f; - char mid = (c >> 6) & 0x3F; - char high = c >> 12; - left = left - 3; - if ((int) left < 0) break; - *pos++ = high | 0xE0; - *pos++ = mid | 0x80; - *pos++ = low | 0x80; - } - } - - /* insert utf-string into symbol-table */ - result = utf_new(buffer,buflength); - - MFREE(buffer, char, buflength); - - return result; -} - - -/* utf_new_char **************************************************************** - - Creates a new utf symbol, the text for this symbol is passed as a - c-string ( = char* ). - -*******************************************************************************/ - -utf *utf_new_char(const char *text) -{ - return utf_new(text, strlen(text)); -} - - -/* utf_new_char_classname ****************************************************** - - Creates a new utf symbol, the text for this symbol is passed as a - c-string ( = char* ) "." characters are going to be replaced by - "/". Since the above function is used often, this is a separte - function, instead of an if. - -*******************************************************************************/ - -utf *utf_new_char_classname(const char *text) -{ - if (strchr(text, '.')) { - char *txt = strdup(text); - char *end = txt + strlen(txt); - char *c; - utf *tmpRes; - - for (c = txt; c < end; c++) - if (*c == '.') *c = '/'; - - tmpRes = utf_new(txt, strlen(txt)); - FREE(txt, 0); - - return tmpRes; - - } else - return utf_new(text, strlen(text)); -} - - -/* utf_nextu2 ****************************************************************** - - Read the next unicode character from the utf string and increment - the utf-string pointer accordingly. - - CAUTION: This function is unsafe for input that was not checked - by is_valid_utf! - -*******************************************************************************/ - -u2 utf_nextu2(char **utf_ptr) -{ - /* uncompressed unicode character */ - u2 unicode_char = 0; - /* current position in utf text */ - unsigned char *utf = (unsigned char *) (*utf_ptr); - /* bytes representing the unicode character */ - unsigned char ch1, ch2, ch3; - /* number of bytes used to represent the unicode character */ - int len = 0; - - switch ((ch1 = utf[0]) >> 4) { - default: /* 1 byte */ - (*utf_ptr)++; - return (u2) ch1; - case 0xC: - case 0xD: /* 2 bytes */ - if (((ch2 = utf[1]) & 0xC0) == 0x80) { - unsigned char high = ch1 & 0x1F; - unsigned char low = ch2 & 0x3F; - unicode_char = (high << 6) + low; - len = 2; - } - break; - - case 0xE: /* 2 or 3 bytes */ - if (((ch2 = utf[1]) & 0xC0) == 0x80) { - if (((ch3 = utf[2]) & 0xC0) == 0x80) { - unsigned char low = ch3 & 0x3f; - unsigned char mid = ch2 & 0x3f; - unsigned char high = ch1 & 0x0f; - unicode_char = (((high << 6) + mid) << 6) + low; - len = 3; - } else - len = 2; - } - break; - } - - /* update position in utf-text */ - *utf_ptr = (char *) (utf + len); - - return unicode_char; -} - - -/* utf_bytes ******************************************************************* - - Determine number of bytes (aka. octets) in the utf string. - - IN: - u............utf string - - OUT: - The number of octets of this utf string. - There is _no_ terminating zero included in this count. - -*******************************************************************************/ - -u4 utf_bytes(utf *u) -{ - return u->blength; -} - - -/* utf_get_number_of_u2s_for_buffer ******************************************** - - Determine number of UTF-16 u2s in the given UTF-8 buffer - - CAUTION: This function is unsafe for input that was not checked - by is_valid_utf! - - CAUTION: Use this function *only* when you want to convert an UTF-8 buffer - to an array of u2s (UTF-16) and want to know how many of them you will get. - All other uses of this function are probably wrong. - - IN: - buffer........points to first char in buffer - blength.......number of _bytes_ in the buffer - - OUT: - the number of u2s needed to hold this string in UTF-16 encoding. - There is _no_ terminating zero included in this count. - - NOTE: Unlike utf_get_number_of_u2s, this function never throws an - exception. - -*******************************************************************************/ - -u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength) -{ - const char *endpos; /* points behind utf string */ - const char *utf_ptr; /* current position in utf text */ - u4 len = 0; /* number of unicode characters */ - - utf_ptr = buffer; - endpos = utf_ptr + blength; - - while (utf_ptr < endpos) { - len++; - /* next unicode character */ - utf_nextu2((char **)&utf_ptr); - } - - assert(utf_ptr == endpos); - - return len; -} - - -/* utf_get_number_of_u2s ******************************************************* - - Determine number of UTF-16 u2s in the utf string. - - CAUTION: This function is unsafe for input that was not checked - by is_valid_utf! - - CAUTION: Use this function *only* when you want to convert a utf string - to an array of u2s and want to know how many of them you will get. - All other uses of this function are probably wrong. - - IN: - u............utf string - - OUT: - the number of u2s needed to hold this string in UTF-16 encoding. - There is _no_ terminating zero included in this count. - XXX 0 if a NullPointerException has been thrown (see below) - -*******************************************************************************/ - -u4 utf_get_number_of_u2s(utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - u4 len = 0; /* number of unicode characters */ - - /* XXX this is probably not checked by most callers! Review this after */ - /* the invalid uses of this function have been eliminated */ - if (u == NULL) { - exceptions_throw_nullpointerexception(); - return 0; - } - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) { - len++; - /* next unicode character */ - utf_nextu2(&utf_ptr); - } - - if (utf_ptr != endpos) { - /* string ended abruptly */ - exceptions_throw_internalerror("Illegal utf8 string"); - return 0; - } - - return len; -} - - -/* utf8_safe_number_of_u2s ***************************************************** - - Determine number of UTF-16 u2s needed for decoding the given UTF-8 string. - (For invalid UTF-8 the U+fffd replacement character will be counted.) - - This function is safe even for invalid UTF-8 strings. - - IN: - text..........zero-terminated(!) UTF-8 string (may be invalid) - must NOT be NULL - nbytes........strlen(text). (This is needed to completely emulate - the RI). - - OUT: - the number of u2s needed to hold this string in UTF-16 encoding. - There is _no_ terminating zero included in this count. - -*******************************************************************************/ - -s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes) { - register const unsigned char *t; - register s4 byte; - register s4 len; - register const unsigned char *tlimit; - s4 byte1; - s4 byte2; - s4 byte3; - s4 value; - s4 skip; - - assert(text); - assert(nbytes >= 0); - - len = 0; - t = (const unsigned char *) text; - tlimit = t + nbytes; - - /* CAUTION: Keep this code in sync with utf8_safe_convert_to_u2s! */ - - while (1) { - byte = *t++; - - if (byte & 0x80) { - /* highest bit set, non-ASCII character */ - - if ((byte & 0xe0) == 0xc0) { - /* 2-byte: should be 110..... 10...... ? */ - - if ((*t++ & 0xc0) == 0x80) - ; /* valid 2-byte */ - else - t--; /* invalid */ - } - else if ((byte & 0xf0) == 0xe0) { - /* 3-byte: should be 1110.... 10...... 10...... */ - /* ^t */ - - if (t + 2 > tlimit) - return len + 1; /* invalid, stop here */ - - if ((*t++ & 0xc0) == 0x80) { - if ((*t++ & 0xc0) == 0x80) - ; /* valid 3-byte */ - else - t--; /* invalid */ - } - else - t--; /* invalid */ - } - else if ((byte & 0xf8) == 0xf0) { - /* 4-byte: should be 11110... 10...... 10...... 10...... */ - /* ^t */ - - if (t + 3 > tlimit) - return len + 1; /* invalid, stop here */ - - if (((byte1 = *t++) & 0xc0) == 0x80) { - if (((byte2 = *t++) & 0xc0) == 0x80) { - if (((byte3 = *t++) & 0xc0) == 0x80) { - /* valid 4-byte UTF-8? */ - value = ((byte & 0x07) << 18) - | ((byte1 & 0x3f) << 12) - | ((byte2 & 0x3f) << 6) - | ((byte3 & 0x3f) ); - - if (value > 0x10FFFF) - ; /* invalid */ - else if (value > 0xFFFF) - len += 1; /* we need surrogates */ - else - ; /* 16bit suffice */ - } - else - t--; /* invalid */ - } - else - t--; /* invalid */ - } - else - t--; /* invalid */ - } - else if ((byte & 0xfc) == 0xf8) { - /* invalid 5-byte */ - if (t + 4 > tlimit) - return len + 1; /* invalid, stop here */ - - skip = 4; - for (; skip && ((*t & 0xc0) == 0x80); --skip) - t++; - } - else if ((byte & 0xfe) == 0xfc) { - /* invalid 6-byte */ - if (t + 5 > tlimit) - return len + 1; /* invalid, stop here */ - - skip = 5; - for (; skip && ((*t & 0xc0) == 0x80); --skip) - t++; - } - else - ; /* invalid */ - } - else { - /* NUL */ - - if (byte == 0) - break; - - /* ASCII character, common case */ - } - - len++; - } - - return len; -} - - -/* utf8_safe_convert_to_u2s **************************************************** - - Convert the given UTF-8 string to UTF-16 into a pre-allocated buffer. - (Invalid UTF-8 will be replaced with the U+fffd replacement character.) - Use utf8_safe_number_of_u2s to determine the number of u2s to allocate. - - This function is safe even for invalid UTF-8 strings. - - IN: - text..........zero-terminated(!) UTF-8 string (may be invalid) - must NOT be NULL - nbytes........strlen(text). (This is needed to completely emulate - the RI). - buffer........a preallocated array of u2s to receive the decoded - string. Use utf8_safe_number_of_u2s to get the - required number of u2s for allocating this. - -*******************************************************************************/ - -#define UNICODE_REPLACEMENT 0xfffd - -void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer) { - register const unsigned char *t; - register s4 byte; - register const unsigned char *tlimit; - s4 byte1; - s4 byte2; - s4 byte3; - s4 value; - s4 skip; - - assert(text); - assert(nbytes >= 0); - - t = (const unsigned char *) text; - tlimit = t + nbytes; - - /* CAUTION: Keep this code in sync with utf8_safe_number_of_u2s! */ - - while (1) { - byte = *t++; - - if (byte & 0x80) { - /* highest bit set, non-ASCII character */ - - if ((byte & 0xe0) == 0xc0) { - /* 2-byte: should be 110..... 10...... */ - - if (((byte1 = *t++) & 0xc0) == 0x80) { - /* valid 2-byte UTF-8 */ - *buffer++ = ((byte & 0x1f) << 6) - | ((byte1 & 0x3f) ); - } - else { - *buffer++ = UNICODE_REPLACEMENT; - t--; - } - } - else if ((byte & 0xf0) == 0xe0) { - /* 3-byte: should be 1110.... 10...... 10...... */ - - if (t + 2 > tlimit) { - *buffer++ = UNICODE_REPLACEMENT; - return; - } - - if (((byte1 = *t++) & 0xc0) == 0x80) { - if (((byte2 = *t++) & 0xc0) == 0x80) { - /* valid 3-byte UTF-8 */ - *buffer++ = ((byte & 0x0f) << 12) - | ((byte1 & 0x3f) << 6) - | ((byte2 & 0x3f) ); - } - else { - *buffer++ = UNICODE_REPLACEMENT; - t--; - } - } - else { - *buffer++ = UNICODE_REPLACEMENT; - t--; - } - } - else if ((byte & 0xf8) == 0xf0) { - /* 4-byte: should be 11110... 10...... 10...... 10...... */ - - if (t + 3 > tlimit) { - *buffer++ = UNICODE_REPLACEMENT; - return; - } - - if (((byte1 = *t++) & 0xc0) == 0x80) { - if (((byte2 = *t++) & 0xc0) == 0x80) { - if (((byte3 = *t++) & 0xc0) == 0x80) { - /* valid 4-byte UTF-8? */ - value = ((byte & 0x07) << 18) - | ((byte1 & 0x3f) << 12) - | ((byte2 & 0x3f) << 6) - | ((byte3 & 0x3f) ); - - if (value > 0x10FFFF) { - *buffer++ = UNICODE_REPLACEMENT; - } - else if (value > 0xFFFF) { - /* we need surrogates */ - *buffer++ = 0xd800 | ((value >> 10) - 0x40); - *buffer++ = 0xdc00 | (value & 0x03ff); - } - else - *buffer++ = value; /* 16bit suffice */ - } - else { - *buffer++ = UNICODE_REPLACEMENT; - t--; - } - } - else { - *buffer++ = UNICODE_REPLACEMENT; - t--; - } - } - else { - *buffer++ = UNICODE_REPLACEMENT; - t--; - } - } - else if ((byte & 0xfc) == 0xf8) { - if (t + 4 > tlimit) { - *buffer++ = UNICODE_REPLACEMENT; - return; - } - - skip = 4; - for (; skip && ((*t & 0xc0) == 0x80); --skip) - t++; - *buffer++ = UNICODE_REPLACEMENT; - } - else if ((byte & 0xfe) == 0xfc) { - if (t + 5 > tlimit) { - *buffer++ = UNICODE_REPLACEMENT; - return; - } - - skip = 5; - for (; skip && ((*t & 0xc0) == 0x80); --skip) - t++; - *buffer++ = UNICODE_REPLACEMENT; - } - else - *buffer++ = UNICODE_REPLACEMENT; - } - else { - /* NUL */ - - if (byte == 0) - break; - - /* ASCII character, common case */ - - *buffer++ = byte; - } - } -} - - -/* u2_utflength **************************************************************** - - Returns the utf length in bytes of a u2 array. - -*******************************************************************************/ - -u4 u2_utflength(u2 *text, u4 u2_length) -{ - u4 result_len = 0; /* utf length in bytes */ - u2 ch; /* current unicode character */ - u4 len; - - for (len = 0; len < u2_length; len++) { - /* next unicode character */ - ch = *text++; - - /* determine bytes required to store unicode character as utf */ - if (ch && (ch < 0x80)) - result_len++; - else if (ch < 0x800) - result_len += 2; - else - result_len += 3; - } - - return result_len; -} - - -/* utf_copy ******************************************************************** - - Copy the given utf string byte-for-byte to a buffer. - - IN: - buffer.......the buffer - u............the utf string - -*******************************************************************************/ - -void utf_copy(char *buffer, utf *u) -{ - /* our utf strings are zero-terminated (done by utf_new) */ - MCOPY(buffer, u->text, char, u->blength + 1); -} - - -/* utf_cat ********************************************************************* - - Append the given utf string byte-for-byte to a buffer. - - IN: - buffer.......the buffer - u............the utf string - -*******************************************************************************/ - -void utf_cat(char *buffer, utf *u) -{ - /* our utf strings are zero-terminated (done by utf_new) */ - MCOPY(buffer + strlen(buffer), u->text, char, u->blength + 1); -} - - -/* utf_copy_classname ********************************************************** - - Copy the given utf classname byte-for-byte to a buffer. - '/' is replaced by '.' - - IN: - buffer.......the buffer - u............the utf string - -*******************************************************************************/ - -void utf_copy_classname(char *buffer, utf *u) -{ - char *bufptr; - char *srcptr; - char *endptr; - char ch; - - bufptr = buffer; - srcptr = u->text; - endptr = UTF_END(u) + 1; /* utfs are zero-terminared by utf_new */ - - while (srcptr != endptr) { - ch = *srcptr++; - if (ch == '/') - ch = '.'; - *bufptr++ = ch; - } -} - - -/* utf_cat ********************************************************************* - - Append the given utf classname byte-for-byte to a buffer. - '/' is replaced by '.' - - IN: - buffer.......the buffer - u............the utf string - -*******************************************************************************/ - -void utf_cat_classname(char *buffer, utf *u) -{ - utf_copy_classname(buffer + strlen(buffer), u); -} - -/* utf_display_printable_ascii ************************************************* - - Write utf symbol to stdout (for debugging purposes). - Non-printable and non-ASCII characters are printed as '?'. - -*******************************************************************************/ - -void utf_display_printable_ascii(utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - - if (u == NULL) { - printf("NULL"); - fflush(stdout); - return; - } - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) { - /* read next unicode character */ - - u2 c = utf_nextu2(&utf_ptr); - - if ((c >= 32) && (c <= 127)) - printf("%c", c); - else - printf("?"); - } - - fflush(stdout); -} - - -/* utf_display_printable_ascii_classname *************************************** - - Write utf symbol to stdout with `/' converted to `.' (for debugging - purposes). - Non-printable and non-ASCII characters are printed as '?'. - -*******************************************************************************/ - -void utf_display_printable_ascii_classname(utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - - if (u == NULL) { - printf("NULL"); - fflush(stdout); - return; - } - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) { - /* read next unicode character */ - - u2 c = utf_nextu2(&utf_ptr); - - if (c == '/') - c = '.'; - - if ((c >= 32) && (c <= 127)) - printf("%c", c); - else - printf("?"); - } - - fflush(stdout); -} - - -/* utf_sprint_convert_to_latin1 ************************************************ - - Write utf symbol into c-string (for debugging purposes). - Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield - invalid results. - -*******************************************************************************/ - -void utf_sprint_convert_to_latin1(char *buffer, utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - u2 pos = 0; /* position in c-string */ - - if (!u) { - strcpy(buffer, "NULL"); - return; - } - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) - /* copy next unicode character */ - buffer[pos++] = utf_nextu2(&utf_ptr); - - /* terminate string */ - buffer[pos] = '\0'; -} - - -/* utf_sprint_convert_to_latin1_classname ************************************** - - Write utf symbol into c-string with `/' converted to `.' (for debugging - purposes). - Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield - invalid results. - -*******************************************************************************/ - -void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - u2 pos = 0; /* position in c-string */ - - if (!u) { - strcpy(buffer, "NULL"); - return; - } - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) { - /* copy next unicode character */ - u2 c = utf_nextu2(&utf_ptr); - if (c == '/') c = '.'; - buffer[pos++] = c; - } - - /* terminate string */ - buffer[pos] = '\0'; -} - - -/* utf_strcat_convert_to_latin1 ************************************************ - - Like libc strcat, but uses an utf8 string. - Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield - invalid results. - -*******************************************************************************/ - -void utf_strcat_convert_to_latin1(char *buffer, utf *u) -{ - utf_sprint_convert_to_latin1(buffer + strlen(buffer), u); -} - - -/* utf_strcat_convert_to_latin1_classname ************************************** - - Like libc strcat, but uses an utf8 string. - Characters are converted to 8-bit Latin-1, non-Latin-1 characters yield - invalid results. - -*******************************************************************************/ - -void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u) -{ - utf_sprint_convert_to_latin1_classname(buffer + strlen(buffer), u); -} - - -/* utf_fprint_printable_ascii ************************************************** - - Write utf symbol into file. - Non-printable and non-ASCII characters are printed as '?'. - -*******************************************************************************/ - -void utf_fprint_printable_ascii(FILE *file, utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - - if (!u) - return; - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) { - /* read next unicode character */ - u2 c = utf_nextu2(&utf_ptr); - - if (c >= 32 && c <= 127) fprintf(file, "%c", c); - else fprintf(file, "?"); - } -} - - -/* utf_fprint_printable_ascii_classname **************************************** - - Write utf symbol into file with `/' converted to `.'. - Non-printable and non-ASCII characters are printed as '?'. - -*******************************************************************************/ - -void utf_fprint_printable_ascii_classname(FILE *file, utf *u) -{ - char *endpos; /* points behind utf string */ - char *utf_ptr; /* current position in utf text */ - - if (!u) - return; - - endpos = UTF_END(u); - utf_ptr = u->text; - - while (utf_ptr < endpos) { - /* read next unicode character */ - u2 c = utf_nextu2(&utf_ptr); - if (c == '/') c = '.'; - - if (c >= 32 && c <= 127) fprintf(file, "%c", c); - else fprintf(file, "?"); - } -} - - -/* is_valid_utf **************************************************************** - - Return true if the given string is a valid UTF-8 string. - - utf_ptr...points to first character - end_pos...points after last character - -*******************************************************************************/ - -/* static unsigned long min_codepoint[6] = {0,1L<<7,1L<<11,1L<<16,1L<<21,1L<<26}; */ - -bool is_valid_utf(char *utf_ptr, char *end_pos) -{ - int bytes; - int len,i; - char c; - unsigned long v; - - if (end_pos < utf_ptr) return false; - bytes = end_pos - utf_ptr; - while (bytes--) { - c = *utf_ptr++; - - if (!c) return false; /* 0x00 is not allowed */ - if ((c & 0x80) == 0) continue; /* ASCII */ - - if ((c & 0xe0) == 0xc0) len = 1; /* 110x xxxx */ - else if ((c & 0xf0) == 0xe0) len = 2; /* 1110 xxxx */ - else if ((c & 0xf8) == 0xf0) len = 3; /* 1111 0xxx */ - else if ((c & 0xfc) == 0xf8) len = 4; /* 1111 10xx */ - else if ((c & 0xfe) == 0xfc) len = 5; /* 1111 110x */ - else return false; /* invalid leading byte */ - - if (len > 2) return false; /* Java limitation */ - - v = (unsigned long)c & (0x3f >> len); - - if ((bytes -= len) < 0) return false; /* missing bytes */ - - for (i = len; i--; ) { - c = *utf_ptr++; - if ((c & 0xc0) != 0x80) /* 10xx xxxx */ - return false; - v = (v << 6) | (c & 0x3f); - } - - if (v == 0) { - if (len != 1) return false; /* Java special */ - - } else { - /* Sun Java seems to allow overlong UTF-8 encodings */ - - /* if (v < min_codepoint[len]) */ - /* XXX throw exception? */ - } - - /* surrogates in UTF-8 seem to be allowed in Java classfiles */ - /* if (v >= 0xd800 && v <= 0xdfff) return false; */ /* surrogates */ - - /* even these seem to be allowed */ - /* if (v == 0xfffe || v == 0xffff) return false; */ /* invalid codepoints */ - } - - return true; -} - - -/* is_valid_name *************************************************************** - - Return true if the given string may be used as a class/field/method - name. (Currently this only disallows empty strings and control - characters.) - - NOTE: The string is assumed to have passed is_valid_utf! - - utf_ptr...points to first character - end_pos...points after last character - -*******************************************************************************/ - -bool is_valid_name(char *utf_ptr, char *end_pos) -{ - if (end_pos <= utf_ptr) return false; /* disallow empty names */ - - while (utf_ptr < end_pos) { - unsigned char c = *utf_ptr++; - - if (c < 0x20) return false; /* disallow control characters */ - if (c == 0xc0 && (unsigned char) *utf_ptr == 0x80) /* disallow zero */ - return false; - } - - return true; -} - -bool is_valid_name_utf(utf *u) -{ - return is_valid_name(u->text, UTF_END(u)); -} - - -/* utf_show ******************************************************************** - - Writes the utf symbols in the utfhash to stdout and displays the - number of external hash chains grouped according to the chainlength - (for debugging purposes). - -*******************************************************************************/ - -#if !defined(NDEBUG) -void utf_show(void) -{ - -#define CHAIN_LIMIT 20 /* limit for seperated enumeration */ - - u4 chain_count[CHAIN_LIMIT]; /* numbers of chains */ - u4 max_chainlength = 0; /* maximum length of the chains */ - u4 sum_chainlength = 0; /* sum of the chainlengths */ - u4 beyond_limit = 0; /* number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */ - u4 i; - - printf("UTF-HASH:\n"); - - /* show element of utf-hashtable */ - - for (i = 0; i < hashtable_utf->size; i++) { - utf *u = hashtable_utf->ptr[i]; - - if (u) { - printf("SLOT %d: ", (int) i); - - while (u) { - printf("'"); - utf_display_printable_ascii(u); - printf("' "); - u = u->hashlink; - } - printf("\n"); - } - } - - printf("UTF-HASH: %d slots for %d entries\n", - (int) hashtable_utf->size, (int) hashtable_utf->entries ); - - if (hashtable_utf->entries == 0) - return; - - printf("chains:\n chainlength number of chains %% of utfstrings\n"); - - for (i=0;isize; i++) { - - utf *u = (utf*) hashtable_utf->ptr[i]; - u4 chain_length = 0; - - /* determine chainlength */ - while (u) { - u = u->hashlink; - chain_length++; - } - - /* update sum of all chainlengths */ - sum_chainlength+=chain_length; - - /* determine the maximum length of the chains */ - if (chain_length>max_chainlength) - max_chainlength = chain_length; - - /* update number of utf-symbols in chains with length>=CHAIN_LIMIT-1 */ - if (chain_length>=CHAIN_LIMIT) { - beyond_limit+=chain_length; - chain_length=CHAIN_LIMIT-1; - } - - /* update number of hashchains of current length */ - chain_count[chain_length]++; - } - - /* display results */ - for (i=1;ientries)); - - printf(" >=%2d %17d %18.2f%%\n",CHAIN_LIMIT-1,chain_count[CHAIN_LIMIT-1],((float) beyond_limit*100)/hashtable_utf->entries); - - - printf("max. chainlength:%5d\n",max_chainlength); - - /* avg. chainlength = sum of chainlengths / number of chains */ - printf("avg. chainlength:%5.2f\n",(float) sum_chainlength / (hashtable_utf->size-chain_count[0])); -} -#endif /* !defined(NDEBUG) */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/utf8.h b/src/vmcore/utf8.h deleted file mode 100644 index 6f7661062..000000000 --- a/src/vmcore/utf8.h +++ /dev/null @@ -1,306 +0,0 @@ -/* src/vmcore/utf8.h - utf8 string functions - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _UTF_H -#define _UTF_H - -/* forward typedefs ***********************************************************/ - -typedef struct utf utf; - -#include "config.h" - -#include - -#include "vm/types.h" - -#include "vm/global.h" - - -/* data structure for utf8 symbols ********************************************/ - -struct utf { - utf *hashlink; /* link for external hash chain */ - s4 blength; /* text length in bytes */ - char *text; /* pointer to text */ -}; - -/* to determine the end of utf strings */ - -#define UTF_END(u) ((char *) u->text + u->blength) - - -/* utf-symbols for pointer comparison of frequently used strings **************/ - -extern utf *utf_java_lang_Object; - -extern utf *utf_java_lang_Class; -extern utf *utf_java_lang_ClassLoader; -extern utf *utf_java_lang_Cloneable; -extern utf *utf_java_lang_SecurityManager; -extern utf *utf_java_lang_String; -extern utf *utf_java_lang_ThreadGroup; -extern utf *utf_java_lang_ref_SoftReference; -extern utf *utf_java_lang_ref_WeakReference; -extern utf *utf_java_lang_ref_PhantomReference; -extern utf *utf_java_io_Serializable; - -extern utf *utf_java_lang_Throwable; -extern utf *utf_java_lang_Error; - -extern utf *utf_java_lang_AbstractMethodError; -extern utf *utf_java_lang_ClassCircularityError; -extern utf *utf_java_lang_ClassFormatError; -extern utf *utf_java_lang_ExceptionInInitializerError; -extern utf *utf_java_lang_IncompatibleClassChangeError; -extern utf *utf_java_lang_InstantiationError; -extern utf *utf_java_lang_InternalError; -extern utf *utf_java_lang_LinkageError; -extern utf *utf_java_lang_NoClassDefFoundError; -extern utf *utf_java_lang_NoSuchFieldError; -extern utf *utf_java_lang_NoSuchMethodError; -extern utf *utf_java_lang_OutOfMemoryError; -extern utf *utf_java_lang_UnsatisfiedLinkError; -extern utf *utf_java_lang_UnsupportedClassVersionError; -extern utf *utf_java_lang_VerifyError; -extern utf *utf_java_lang_VirtualMachineError; - -extern utf *utf_java_lang_Exception; - -extern utf *utf_java_lang_ArithmeticException; -extern utf *utf_java_lang_ArrayIndexOutOfBoundsException; -extern utf *utf_java_lang_ArrayStoreException; -extern utf *utf_java_lang_ClassCastException; -extern utf *utf_java_lang_ClassNotFoundException; -extern utf *utf_java_lang_CloneNotSupportedException; -extern utf *utf_java_lang_IllegalAccessException; -extern utf *utf_java_lang_IllegalArgumentException; -extern utf *utf_java_lang_IllegalMonitorStateException; -extern utf *utf_java_lang_InstantiationException; -extern utf *utf_java_lang_InterruptedException; -extern utf *utf_java_lang_NegativeArraySizeException; -extern utf *utf_java_lang_NullPointerException; -extern utf *utf_java_lang_RuntimeException; -extern utf *utf_java_lang_StringIndexOutOfBoundsException; - -extern utf *utf_java_lang_reflect_InvocationTargetException; - -extern utf *utf_java_security_PrivilegedActionException; - -#if defined(ENABLE_JAVASE) -extern utf* utf_java_lang_Void; -#endif - -extern utf* utf_java_lang_Boolean; -extern utf* utf_java_lang_Byte; -extern utf* utf_java_lang_Character; -extern utf* utf_java_lang_Short; -extern utf* utf_java_lang_Integer; -extern utf* utf_java_lang_Long; -extern utf* utf_java_lang_Float; -extern utf* utf_java_lang_Double; - -#if defined(ENABLE_JAVASE) -extern utf *utf_java_lang_StackTraceElement; -extern utf *utf_java_lang_reflect_Constructor; -extern utf *utf_java_lang_reflect_Field; -extern utf *utf_java_lang_reflect_Method; - -# if defined(WITH_JAVA_RUNTIME_LIBRARY_GNU_CLASSPATH) -extern utf *utf_java_lang_reflect_VMConstructor; -extern utf *utf_java_lang_reflect_VMField; -extern utf *utf_java_lang_reflect_VMMethod; -# endif - -extern utf *utf_java_util_Vector; -#endif - -extern utf *utf_InnerClasses; -extern utf *utf_ConstantValue; -extern utf *utf_Code; -extern utf *utf_Exceptions; -extern utf *utf_LineNumberTable; -extern utf *utf_SourceFile; - -#if defined(ENABLE_JAVASE) -extern utf *utf_EnclosingMethod; -extern utf *utf_Signature; -extern utf *utf_StackMapTable; - -#if defined(ENABLE_ANNOTATIONS) -extern utf *utf_RuntimeVisibleAnnotations; -extern utf *utf_RuntimeInvisibleAnnotations; -extern utf *utf_RuntimeVisibleParameterAnnotations; -extern utf *utf_RuntimeInvisibleParameterAnnotations; -extern utf *utf_AnnotationDefault; -#endif -#endif - -extern utf *utf_init; -extern utf *utf_clinit; -extern utf *utf_clone; -extern utf *utf_finalize; -extern utf *utf_invoke; -extern utf *utf_main; -extern utf *utf_run; - -extern utf *utf_add; -extern utf *utf_remove; -extern utf *utf_addThread; -extern utf *utf_removeThread; -extern utf *utf_put; -extern utf *utf_get; -extern utf *utf_uncaughtException; -extern utf *utf_value; - -extern utf *utf_fillInStackTrace; -extern utf *utf_findNative; -extern utf *utf_getSystemClassLoader; -extern utf *utf_initCause; -extern utf *utf_loadClass; -extern utf *utf_loadClassInternal; -extern utf *utf_printStackTrace; - -extern utf *utf_division_by_zero; - -extern utf *utf_Z; -extern utf *utf_B; -extern utf *utf_C; -extern utf *utf_S; -extern utf *utf_I; -extern utf *utf_J; -extern utf *utf_F; -extern utf *utf_D; - -extern utf *utf_void__void; -extern utf *utf_boolean__void; -extern utf *utf_byte__void; -extern utf *utf_char__void; -extern utf *utf_short__void; -extern utf *utf_int__void; -extern utf *utf_long__void; -extern utf *utf_float__void; -extern utf *utf_double__void; - -extern utf *utf_void__java_lang_ClassLoader; -extern utf *utf_void__java_lang_Object; -extern utf *utf_void__java_lang_Throwable; -extern utf *utf_java_lang_ClassLoader_java_lang_String__J; -extern utf *utf_java_lang_Exception__V; -extern utf *utf_java_lang_Object__java_lang_Object; -extern utf *utf_java_lang_String__void; -extern utf *utf_java_lang_String__java_lang_Class; -extern utf *utf_java_lang_Thread__V; -extern utf *utf_java_lang_Thread_java_lang_Throwable__V; -extern utf *utf_Ljava_lang_ThreadGroup_Ljava_lang_String__V; -extern utf *utf_java_lang_Throwable__void; -extern utf *utf_java_lang_Throwable__java_lang_Throwable; - -extern utf *utf_not_named_yet; -extern utf *utf_null; -extern utf *array_packagename; - - -/* function prototypes ********************************************************/ - -/* initialize the utf8 subsystem */ -void utf8_init(void); - -u4 utf_hashkey(const char *text, u4 length); -u4 utf_full_hashkey(const char *text, u4 length); - -/* determine hashkey of a unicode-symbol */ -u4 unicode_hashkey(u2 *text, u2 length); - -/* create new utf-symbol */ -utf *utf_new(const char *text, u2 length); - -/* make utf symbol from u2 array */ -utf *utf_new_u2(u2 *unicodedata, u4 unicodelength, bool isclassname); - -utf *utf_new_char(const char *text); -utf *utf_new_char_classname(const char *text); - -/* get number of bytes */ -u4 utf_bytes(utf *u); - -/* get next unicode character of a utf-string */ -u2 utf_nextu2(char **utf); - -/* get (number of) unicode characters of a utf string (safe) */ -s4 utf8_safe_number_of_u2s(const char *text, s4 nbytes); -void utf8_safe_convert_to_u2s(const char *text, s4 nbytes, u2 *buffer); - -/* get (number of) unicode characters of a utf string (UNSAFE!) */ -u4 utf_get_number_of_u2s(utf *u); -u4 utf_get_number_of_u2s_for_buffer(const char *buffer, u4 blength); - -/* determine utf length in bytes of a u2 array */ -u4 u2_utflength(u2 *text, u4 u2_length); - -void utf_copy(char *buffer, utf *u); -void utf_cat(char *buffer, utf *u); -void utf_copy_classname(char *buffer, utf *u); -void utf_cat_classname(char *buffer, utf *u); - -/* write utf symbol to file/buffer */ -void utf_display_printable_ascii(utf *u); -void utf_display_printable_ascii_classname(utf *u); - -void utf_sprint_convert_to_latin1(char *buffer, utf *u); -void utf_sprint_convert_to_latin1_classname(char *buffer, utf *u); - -void utf_strcat_convert_to_latin1(char *buffer, utf *u); -void utf_strcat_convert_to_latin1_classname(char *buffer, utf *u); - -void utf_fprint_printable_ascii(FILE *file, utf *u); -void utf_fprint_printable_ascii_classname(FILE *file, utf *u); - -/* check if a UTF-8 string is valid */ -bool is_valid_utf(char *utf_ptr, char *end_pos); - -/* check if a UTF-8 string may be used as a class/field/method name */ -bool is_valid_name(char *utf_ptr, char *end_pos); -bool is_valid_name_utf(utf *u); - -/* show utf-table */ -void utf_show(void); - -#endif /* _UTF_H */ - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/zip.c b/src/vmcore/zip.c deleted file mode 100644 index c3644e22c..000000000 --- a/src/vmcore/zip.c +++ /dev/null @@ -1,460 +0,0 @@ -/* src/vmcore/zip.c - ZIP file handling for bootstrap classloader - - Copyright (C) 1996-2005, 2006, 2007, 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "vm/types.h" - -#include "toolbox/hashtable.h" - -#include "mm/memory.h" - -#include "vm/global.h" -#include "vm/vm.h" - -#include "vmcore/suck.h" -#include "vmcore/utf8.h" -#include "vmcore/zip.h" - - -/* start size for classes hashtable *******************************************/ - -#define HASHTABLE_CLASSES_SIZE (1 << 10) - - -/* info taken from: - http://www.pkware.com/business_and_developers/developer/popups/appnote.txt -*/ - -/* all signatures in the ZIP file have a length of 4 bytes ********************/ - -#define SIGNATURE_LENGTH 4 - -/* Central directory structure ************************************************* - - [file header 1] - . - . - . - [file header n] - [digital signature] - - File header: - - central file header signature 4 bytes (0x02014b50) - version made by 2 bytes - version needed to extract 2 bytes - general purpose bit flag 2 bytes - compression method 2 bytes - last mod file time 2 bytes - last mod file date 2 bytes - crc-32 4 bytes - compressed size 4 bytes - uncompressed size 4 bytes - file name length 2 bytes - extra field length 2 bytes - file comment length 2 bytes - disk number start 2 bytes - internal file attributes 2 bytes - external file attributes 4 bytes - relative offset of local header 4 bytes - - file name (variable size) - extra field (variable size) - file comment (variable size) - - Digital signature: - - header signature 4 bytes (0x05054b50) - size of data 2 bytes - signature data (variable size) - -*******************************************************************************/ - -#define CDSFH_HEADER_SIZE 46 - -#define CDSFH_SIGNATURE 0x02014b50 -#define CDSFH_COMPRESSION_METHOD 10 -#define CDSFH_COMPRESSED_SIZE 20 -#define CDSFH_UNCOMPRESSED_SIZE 24 -#define CDSFH_FILE_NAME_LENGTH 28 -#define CDSFH_EXTRA_FIELD_LENGTH 30 -#define CDSFH_FILE_COMMENT_LENGTH 32 -#define CDSFH_RELATIVE_OFFSET 42 -#define CDSFH_FILENAME 46 - -typedef struct cdsfh cdsfh; - -struct cdsfh { - u2 compressionmethod; - u4 compressedsize; - u4 uncompressedsize; - u2 filenamelength; - u2 extrafieldlength; - u2 filecommentlength; - u4 relativeoffset; -}; - - -/* End of central directory record ********************************************* - - end of central dir signature 4 bytes (0x06054b50) - number of this disk 2 bytes - number of the disk with the - start of the central directory 2 bytes - total number of entries in the - central directory on this disk 2 bytes - total number of entries in - the central directory 2 bytes - size of the central directory 4 bytes - offset of start of central - directory with respect to - the starting disk number 4 bytes - .ZIP file comment length 2 bytes - .ZIP file comment (variable size) - -*******************************************************************************/ - -#define EOCDR_SIGNATURE 0x06054b50 -#define EOCDR_ENTRIES 10 -#define EOCDR_OFFSET 16 - -typedef struct eocdr eocdr; - -struct eocdr { - u2 entries; - u4 offset; -}; - - -/* zip_open ******************************************************************** - - XXX - -*******************************************************************************/ - -hashtable *zip_open(char *path) -{ - hashtable *ht; - hashtable_zipfile_entry *htzfe; - int fd; - u1 lfh_signature[SIGNATURE_LENGTH]; - off_t len; - u1 *filep; - s4 i; - u1 *p; - eocdr eocdr; - cdsfh cdsfh; - const char *filename; - const char *classext; - utf *u; - u4 key; /* hashkey computed from utf-text */ - u4 slot; /* slot in hashtable */ - - /* first of all, open the file */ - - if ((fd = open(path, O_RDONLY)) == -1) - return NULL; - - /* check for signature in first local file header */ - - if (read(fd, lfh_signature, SIGNATURE_LENGTH) != SIGNATURE_LENGTH) - return NULL; - - if (SUCK_LE_U4(lfh_signature) != LFH_SIGNATURE) - return NULL; - - /* get the file length */ - - if ((len = lseek(fd, 0, SEEK_END)) == -1) - return NULL; - - /* we better mmap the file */ - - filep = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0); - - /* some older compilers, like DEC OSF cc, don't like comparisons - on void* types */ - - if ((ptrint) filep == (ptrint) MAP_FAILED) - return NULL; - - /* find end of central directory record */ - - for (p = filep + len; p >= filep; p--) - if (SUCK_LE_U4(p) == EOCDR_SIGNATURE) - break; - - /* get number of entries in central directory */ - - eocdr.entries = SUCK_LE_U2(p + EOCDR_ENTRIES); - eocdr.offset = SUCK_LE_U4(p + EOCDR_OFFSET); - - /* create hashtable for filenames */ - - ht = NEW(hashtable); - - hashtable_create(ht, HASHTABLE_CLASSES_SIZE); - - /* add all file entries into the hashtable */ - - for (i = 0, p = filep + eocdr.offset; i < eocdr.entries; i++) { - /* check file header signature */ - - if (SUCK_LE_U4(p) != CDSFH_SIGNATURE) - return NULL; - - /* we found an entry */ - - cdsfh.compressionmethod = SUCK_LE_U2(p + CDSFH_COMPRESSION_METHOD); - cdsfh.compressedsize = SUCK_LE_U4(p + CDSFH_COMPRESSED_SIZE); - cdsfh.uncompressedsize = SUCK_LE_U4(p + CDSFH_UNCOMPRESSED_SIZE); - cdsfh.filenamelength = SUCK_LE_U2(p + CDSFH_FILE_NAME_LENGTH); - cdsfh.extrafieldlength = SUCK_LE_U2(p + CDSFH_EXTRA_FIELD_LENGTH); - cdsfh.filecommentlength = SUCK_LE_U2(p + CDSFH_FILE_COMMENT_LENGTH); - cdsfh.relativeoffset = SUCK_LE_U4(p + CDSFH_RELATIVE_OFFSET); - - /* create utf8 string of filename, strip .class from classes */ - - filename = (const char *) (p + CDSFH_FILENAME); - classext = filename + cdsfh.filenamelength - strlen(".class"); - - /* skip directory entries */ - - if (filename[cdsfh.filenamelength - 1] != '/') { - if (strncmp(classext, ".class", strlen(".class")) == 0) - u = utf_new(filename, cdsfh.filenamelength - strlen(".class")); - else - u = utf_new(filename, cdsfh.filenamelength); - - /* insert class into hashtable */ - - htzfe = NEW(hashtable_zipfile_entry); - - htzfe->filename = u; - htzfe->compressionmethod = cdsfh.compressionmethod; - htzfe->compressedsize = cdsfh.compressedsize; - htzfe->uncompressedsize = cdsfh.uncompressedsize; - htzfe->data = filep + cdsfh.relativeoffset; - - /* get hashtable slot */ - - key = utf_hashkey(u->text, u->blength); - slot = key & (ht->size - 1); - - /* insert into external chain */ - - htzfe->hashlink = ht->ptr[slot]; - - /* insert hashtable zipfile entry */ - - ht->ptr[slot] = htzfe; - ht->entries++; - } - - /* move to next central directory structure file header */ - - p = p + - CDSFH_HEADER_SIZE + - cdsfh.filenamelength + - cdsfh.extrafieldlength + - cdsfh.filecommentlength; - } - - /* return pointer to hashtable */ - - return ht; -} - - -/* zip_find ******************************************************************** - - Search for the given filename in the classpath entries of a zip file. - - NOTE: The '.class' extension is stripped when reading a zip file, so if - you want to find a .class file, you must search for its name _without_ - the '.class' extension. - XXX I dont like that, it makes foo and foo.class ambiguous. -Edwin - - IN: - lce..........the classpath entries for the zip file - u............the filename to look for - - RETURN VALUE: - hashtable_zipfile_entry * of the entry if found, or - NULL if not found - -*******************************************************************************/ - -hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u) -{ - hashtable *ht; - u4 key; /* hashkey computed from utf-text */ - u4 slot; /* slot in hashtable */ - hashtable_zipfile_entry *htzfe; /* hashtable element */ - - /* get classes hashtable from the classpath entry */ - - ht = lce->htclasses; - - /* get the hashtable slot of the name searched */ - - key = utf_hashkey(u->text, u->blength); - slot = key & (ht->size - 1); - htzfe = ht->ptr[slot]; - - /* search external hash chain for utf-symbol */ - - while (htzfe) { - if (htzfe->filename == u) - return htzfe; - - /* next element in external chain */ - - htzfe = htzfe->hashlink; - } - - /* file not found in this archive */ - - return NULL; -} - - -/* zip_get ******************************************************************** - - XXX - -*******************************************************************************/ - -classbuffer *zip_get(list_classpath_entry *lce, classinfo *c) -{ - hashtable_zipfile_entry *htzfe; - lfh lfh; - u1 *indata; - u1 *outdata; - z_stream zs; - int err; - classbuffer *cb; - - /* try to find the class in the current archive */ - - htzfe = zip_find(lce, c->name); - - if (htzfe == NULL) - return NULL; - - /* read stuff from local file header */ - - lfh.filenamelength = SUCK_LE_U2(htzfe->data + LFH_FILE_NAME_LENGTH); - lfh.extrafieldlength = SUCK_LE_U2(htzfe->data + LFH_EXTRA_FIELD_LENGTH); - - indata = htzfe->data + - LFH_HEADER_SIZE + - lfh.filenamelength + - lfh.extrafieldlength; - - /* allocate buffer for uncompressed data */ - - outdata = MNEW(u1, htzfe->uncompressedsize); - - /* how is the file stored? */ - - switch (htzfe->compressionmethod) { - case Z_DEFLATED: - /* fill z_stream structure */ - - zs.next_in = indata; - zs.avail_in = htzfe->compressedsize; - zs.next_out = outdata; - zs.avail_out = htzfe->uncompressedsize; - - zs.zalloc = Z_NULL; - zs.zfree = Z_NULL; - zs.opaque = Z_NULL; - - /* initialize this inflate run */ - - if (inflateInit2(&zs, -MAX_WBITS) != Z_OK) - vm_abort("zip_get: inflateInit2 failed: %s", strerror(errno)); - - /* decompress the file into buffer */ - - err = inflate(&zs, Z_SYNC_FLUSH); - - if ((err != Z_STREAM_END) && (err != Z_OK)) - vm_abort("zip_get: inflate failed: %s", strerror(errno)); - - /* finish this inflate run */ - - if (inflateEnd(&zs) != Z_OK) - vm_abort("zip_get: inflateEnd failed: %s", strerror(errno)); - break; - - case 0: - /* uncompressed file, just copy the data */ - MCOPY(outdata, indata, u1, htzfe->compressedsize); - break; - - default: - vm_abort("zip_get: unknown compression method %d", - htzfe->compressionmethod); - } - - /* allocate classbuffer */ - - cb = NEW(classbuffer); - - cb->clazz = c; - cb->size = htzfe->uncompressedsize; - cb->data = outdata; - cb->pos = outdata; - cb->path = lce->path; - - /* return the filled classbuffer structure */ - - return cb; -} - - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim:noexpandtab:sw=4:ts=4: - */ diff --git a/src/vmcore/zip.h b/src/vmcore/zip.h deleted file mode 100644 index 0d09aa540..000000000 --- a/src/vmcore/zip.h +++ /dev/null @@ -1,112 +0,0 @@ -/* src/vmcore/zip.c - ZIP file handling for bootstrap classloader - - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - J. Wenninger, Institut f. Computersprachen - TU Wien - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -#ifndef _ZIP_H -#define _ZIP_H - -#include "config.h" -#include "vm/types.h" - -#include "toolbox/hashtable.h" - -#include "vm/global.h" - -#include "vmcore/class.h" -#include "vmcore/loader.h" -#include "vmcore/suck.h" -#include "vmcore/utf8.h" - - -/* Local file header *********************************************************** - - local file header signature 4 bytes (0x04034b50) - version needed to extract 2 bytes - general purpose bit flag 2 bytes - compression method 2 bytes - last mod file time 2 bytes - last mod file date 2 bytes - crc-32 4 bytes - compressed size 4 bytes - uncompressed size 4 bytes - file name length 2 bytes - extra field length 2 bytes - - file name (variable size) - extra field (variable size) - -*******************************************************************************/ - -#define LFH_HEADER_SIZE 30 - -#define LFH_SIGNATURE 0x04034b50 -#define LFH_FILE_NAME_LENGTH 26 -#define LFH_EXTRA_FIELD_LENGTH 28 - -typedef struct lfh lfh; - -struct lfh { - u2 compressionmethod; - u4 compressedsize; - u4 uncompressedsize; - u2 filenamelength; - u2 extrafieldlength; -}; - -/* hashtable_zipfile_entry ****************************************************/ - -typedef struct hashtable_zipfile_entry hashtable_zipfile_entry; - -struct hashtable_zipfile_entry { - utf *filename; - u2 compressionmethod; - u4 compressedsize; - u4 uncompressedsize; - u1 *data; - hashtable_zipfile_entry *hashlink; -}; - - -/* function prototypes ********************************************************/ - -hashtable *zip_open(char *path); -hashtable_zipfile_entry *zip_find(list_classpath_entry *lce, utf *u); -classbuffer *zip_get(list_classpath_entry *lce, classinfo *c); - -#endif /* _ZIP_H */ - -/* - * These are local overrides for various environment variables in Emacs. - * Please do not remove this and leave it at the end of the file, where - * Emacs will automagically detect them. - * --------------------------------------------------------------------- - * Local variables: - * mode: c - * indent-tabs-mode: t - * c-basic-offset: 4 - * tab-width: 4 - * End: - */ diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am index 1481cac0b..3f58045ee 100644 --- a/tests/regression/Makefile.am +++ b/tests/regression/Makefile.am @@ -22,10 +22,10 @@ SUBDIRS = \ + base \ assertion \ bugzilla \ jasmin \ - junit \ native \ resolving diff --git a/tests/regression/base/All.java b/tests/regression/base/All.java new file mode 100644 index 000000000..9d9c8e8b7 --- /dev/null +++ b/tests/regression/base/All.java @@ -0,0 +1,37 @@ +/* tests/regression/junit/All.java - runs all CACAO regression unit tests + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) + +@Suite.SuiteClasses({ +TestExceptionInStaticClassInitializer.class, +TestPatcher.class +}) + +public class All { +} diff --git a/tests/regression/base/Makefile.am b/tests/regression/base/Makefile.am new file mode 100644 index 000000000..a00fc60bd --- /dev/null +++ b/tests/regression/base/Makefile.am @@ -0,0 +1,49 @@ +## tests/regression/junit/Makefile.am +## +## Copyright (C) 2008 +## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO +## +## This file is part of CACAO. +## +## This program is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +## 02110-1301, USA. + + +JAVA = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao +JAVACMD = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH) +JAVACCMD = $(JAVAC) -source 1.5 -target 1.5 -nowarn -bootclasspath $(BOOTCLASSPATH) + +EXTRA_DIST = \ + $(srcdir)/*.java + +CLEANFILES = \ + *.class + +check: build run + +build: + $(JAVACCMD) -classpath $(JUNIT_JAR) -d . $(srcdir)/*.java + +run: + $(JAVACMD) -classpath $(JUNIT_JAR):. org.junit.runner.JUnitCore All + + +## Local variables: +## mode: Makefile +## indent-tabs-mode: t +## c-basic-offset: 4 +## tab-width: 8 +## compile-command: "automake --add-missing" +## End: diff --git a/tests/regression/base/TestExceptionInStaticClassInitializer.java b/tests/regression/base/TestExceptionInStaticClassInitializer.java new file mode 100644 index 000000000..61ab65cba --- /dev/null +++ b/tests/regression/base/TestExceptionInStaticClassInitializer.java @@ -0,0 +1,59 @@ +/* tests/regression/bugzilla/TestExceptionInStaticClassInitializer.java + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +import org.junit.Test; +import static org.junit.Assert.*; + +public class TestExceptionInStaticClassInitializer { + @Test + public void test() { + try { + TestExceptionInStaticClassInitializer_x.i = 1; + fail("Should throw ExceptionInInitializerError"); + } + catch (ExceptionInInitializerError success) { + Throwable cause = success.getCause(); + + assertTrue("Cause should be RuntimeException but is " + cause.getClass(), cause.getClass() == RuntimeException.class); + + StackTraceElement[] ste = cause.getStackTrace(); + + assertTrue("Linenumber should be " + LINE + " but is " + ste[0].getLineNumber(), ste[0].getLineNumber() == LINE); + } + } + + // This linenumber must be the one from... + final static int LINE = 57; +} + +class TestExceptionInStaticClassInitializer_x { + static int i; + + static { + if (true) + // ...the following line. + throw new RuntimeException(); + } +} diff --git a/tests/regression/base/TestPatcher.java b/tests/regression/base/TestPatcher.java new file mode 100644 index 000000000..cbf8a1339 --- /dev/null +++ b/tests/regression/base/TestPatcher.java @@ -0,0 +1,643 @@ +/* tests/regression/bugzilla/TestPatcher.java + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.io.*; + +public class TestPatcher { + static boolean doit = true; + + final static int i = 123; + final static long l = 1234567890123L; + final static float f = 123.456F; + final static double d = 789.012; + final static Object o = new Object(); + + @Test + public void testNormal() { + invokestatic(); + invokespecial(); + + getstatic(); + putstatic(); + putstaticconst(); + + getfield(); + putfield(); + putfieldconst(); + + newarray(); + multianewarray(); + + checkcast(); + _instanceof(); + + aastoreconst(); + } + + public void testWithoutClasses() { + // Delete all classes. + //new File("TestPatcher$invokestatic.class").delete(); + + invokestatic(); + invokespecial(); + + getstatic(); + putstatic(); + putstaticconst(); + + getfield(); + putfield(); + putfieldconst(); + + newarray(); + multianewarray(); + + checkcast(); + _instanceof(); + + aastoreconst(); + } + + private void invokestatic() { + try { + if (doit) + invokestatic.sub(); + } catch (NoClassDefFoundError e) { + fail(e.toString()); + } + } + + private void getstatic() { + try { + if (doit) + assertTrue(getstaticI.i + " != " + i, getstaticI.i == i); + } catch (NoClassDefFoundError e) { + fail(e.toString()); + } + + try { + if (doit) + assertTrue(getstaticJ.l + " != " + l, getstaticJ.l == l); + } catch (NoClassDefFoundError e) { + fail(e.toString()); + } + + try { + if (doit) + assertTrue(getstaticF.f + " != " + f, getstaticF.f == f); + } catch (NoClassDefFoundError e) { + fail(e.toString()); + } + + try { + if (doit) + assertTrue(getstaticD.d + " != " + d, getstaticD.d == d); + } catch (NoClassDefFoundError e) { + fail(e.toString()); + } + + try { + if (doit) + assertTrue(getstaticL.o + " != null", getstaticL.o == null); + } catch (NoClassDefFoundError e) { + fail(e.toString()); + } + } + + private void putstatic() { + try { + if (doit) { + putstaticI.i = i; + assertTrue(putstaticI.i + " != " + i, putstaticI.i == i); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticJ.l = l; + assertTrue(putstaticJ.l + " != " + l, putstaticJ.l == l); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticF.f = f; + assertTrue(putstaticF.f + " != " + f, putstaticF.f == f); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticD.d = d; + assertTrue(putstaticD.d + " != " + d, putstaticD.d == d); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + + try { + if (doit) { + putstaticL.o = o; + assertTrue(putstaticL.o + " != " + o, putstaticL.o == o); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void putstaticconst() { + try { + if (doit) { + putstaticconstI.i = i; + assertTrue(putstaticconstI.i + " != " + i, putstaticconstI.i == i); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstJ.l = l; + assertTrue(putstaticconstJ.l + " != " + l, putstaticconstJ.l == l); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstF.f = f; + assertTrue(putstaticconstF.f + " != " + f, putstaticconstF.f == f); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstD.d = d; + assertTrue(putstaticconstD.d + " != " + d, putstaticconstD.d == d); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstI.i = 0; + assertTrue(putstaticconstI.i + " != " + 0, putstaticconstI.i == 0); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstJ.l = 0L; + assertTrue(putstaticconstJ.l + " != " + 0L, putstaticconstJ.l == 0L); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstF.f = 0.0F; + assertTrue(putstaticconstF.f + " != " + 0.0F, putstaticconstF.f == 0.0F); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstD.d = 0.0; + assertTrue(putstaticconstD.d + " != " + 0.0, putstaticconstD.d == 0.0); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstL.o = null; + assertTrue(putstaticconstL.o + " != " + null, putstaticconstL.o == null); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putstaticconstC.c = putstaticconstC.class; + assertTrue(putstaticconstC.c + " != " + Class.forName("TestPatcher$putstaticconstC"), putstaticconstC.c == Class.forName("TestPatcher$putstaticconstC")); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } catch (ClassNotFoundException t) { + fail(t.toString()); + } + } + + private void getfield() { + try { + if (doit) + assertTrue(new getfieldI().i + " != " + i, new getfieldI().i == i); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) + assertTrue(new getfieldJ().l + " != " + l, new getfieldJ().l == l); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) + assertTrue(new getfieldF().f + " != " + f, new getfieldF().f == f); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) + assertTrue(new getfieldD().d + " != " + d, new getfieldD().d == d); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) + assertTrue(new getfieldL().o + " != " + null, new getfieldL().o == null); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void putfield() { + try { + if (doit) { + TestPatcher.putfieldI pfi = new TestPatcher.putfieldI(); + pfi.i = i; + assertTrue(pfi.i + " != " + i, pfi.i == i); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldJ pfj = new putfieldJ(); + pfj.l = l; + assertTrue(pfj.l + " != " + l, pfj.l == l); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldF pff = new putfieldF(); + pff.f = f; + assertTrue(pff.f + " != " + f, pff.f == f); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldD pfd = new putfieldD(); + pfd.d = d; + assertTrue(pfd.d + " != " + d, pfd.d == d); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldL pfl = new putfieldL(); + pfl.o = o; + assertTrue(pfl.o + " != " + o, pfl.o == o); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void putfieldconst() { + try { + if (doit) { + putfieldconstI pfci = new putfieldconstI(); + pfci.i = i; + assertTrue(pfci.i + " != " + i, pfci.i == i); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstJ pfcj = new putfieldconstJ(); + pfcj.l = l; + assertTrue(pfcj.l + " != " + l, pfcj.l == l); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstF pfcf = new putfieldconstF(); + pfcf.f = f; + assertTrue(pfcf.f + " != " + f, pfcf.f == f); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstD pfcd = new putfieldconstD(); + pfcd.d = d; + assertTrue(pfcd.d + " != " + d, pfcd.d == d); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstI pfci = new putfieldconstI(); + pfci.i = 0; + assertTrue(pfci.i + " != " + 0, pfci.i == 0); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstJ pfcj = new putfieldconstJ(); + pfcj.l = 0L; + assertTrue(pfcj.l + " != " + 0L, pfcj.l == 0L); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstF pfcf = new putfieldconstF(); + pfcf.f = 0.0F; + assertTrue(pfcf.f + " != " + 0.0F, pfcf.f == 0.0F); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstD pfcd = new putfieldconstD(); + pfcd.d = 0.0; + assertTrue(pfcd.d + " != " + 0.0, pfcd.d == 0.0); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstL pfcl = new putfieldconstL(); + pfcl.o = null; + assertTrue(pfcl.o + " != " + null, pfcl.o == null); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) { + putfieldconstC pfcc = new putfieldconstC(); + pfcc.c = putfieldconstC.class; + assertTrue(pfcc.c + " != " + Class.forName("TestPatcher$putfieldconstC"), pfcc.c == Class.forName("TestPatcher$putfieldconstC")); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } catch (ClassNotFoundException t) { + fail(t.toString()); + } + } + + private void newarray() { + try { + if (doit) { + newarray[] na = new newarray[1]; + na[0] = null; + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void multianewarray() { + try { + if (doit) { + multianewarray[][] ma = new multianewarray[1][1]; + ma[0][0] = null; + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void invokespecial() { + try { + if (doit) + new invokespecial(); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void checkcast() { + Object o = new Object(); + + // class + try { + if (doit) { + checkcastC cc = (checkcastC) o; + fail(); + } + } catch (ClassCastException success) { + // This is OK. + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + // interface + try { + if (doit) { + checkcastI ci = (checkcastI) o; + fail(); + } + } catch (ClassCastException success) { + // This is OK. + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + + // array + Object[] oa = new Object[1]; + + try { + if (doit) { + checkcastC[] cca = (checkcastC[]) oa; + fail(); + } + } catch (ClassCastException e) { + // This is OK. + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void _instanceof() { + Object o = new Object(); + + try { + if (doit) + if (o instanceof instanceofC) + fail(); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + try { + if (doit) + if (o instanceof instanceofI) + fail(); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + + + // array + Object[] oa = new Object[1]; + + try { + if (doit) + if (oa instanceof instanceofC[]) + fail(); + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } + } + + private void aastoreconst() { + Class[] ca = new Class[1]; + + try { + if (doit) { + ca[0] = aastoreconstClass.class; + + if (ca[0] == null) + fail(); + + assertTrue(ca[0] + " != " + Class.forName("TestPatcher$aastoreconstClass") , ca[0] == Class.forName("TestPatcher$aastoreconstClass")); + } + } catch (NoClassDefFoundError t) { + fail(t.toString()); + } catch (ClassNotFoundException t) { + fail(t.toString()); + } + } + + static class invokestatic { static void sub() {} } + static class invokespecial { void invokespecial() {} } + + static class getstaticI { static int i = TestPatcher.i; } + static class getstaticJ { static long l = TestPatcher.l; } + static class getstaticF { static float f = TestPatcher.f; } + static class getstaticD { static double d = TestPatcher.d; } + static class getstaticL { static Object o = null; } + + static class putstaticI { static int i; } + static class putstaticJ { static long l; } + static class putstaticF { static float f; } + static class putstaticD { static double d; } + static class putstaticL { static Object o; } + + static class putstaticconstI { static int i; } + static class putstaticconstJ { static long l; } + static class putstaticconstF { static float f; } + static class putstaticconstD { static double d; } + static class putstaticconstL { static Object o; } + static class putstaticconstC { static Class c; } + + static class getfieldI { int i = TestPatcher.i; } + static class getfieldJ { long l = TestPatcher.l; } + static class getfieldF { float f = TestPatcher.f; } + static class getfieldD { double d = TestPatcher.d; } + static class getfieldL { Object o = null; } + + static class putfieldI { int i; } + static class putfieldJ { long l; } + static class putfieldF { float f; } + static class putfieldD { double d; } + static class putfieldL { Object o; } + + static class putfieldconstI { int i; } + static class putfieldconstJ { long l; } + static class putfieldconstF { float f; } + static class putfieldconstD { double d; } + static class putfieldconstL { Object o; } + static class putfieldconstC { Class c; } + + static class newarray {} + static class multianewarray {} + + static class instanceofC {} + static interface instanceofI {} + + static class checkcastC {} + static interface checkcastI {} + + static class aastoreconstClass {} +} diff --git a/tests/regression/bugzilla/All.java b/tests/regression/bugzilla/All.java index e5fcac12f..94e7d3d33 100644 --- a/tests/regression/bugzilla/All.java +++ b/tests/regression/bugzilla/All.java @@ -23,32 +23,19 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class All extends TestCase { - /** - * Runs all CACAO regression unit tests using - * junit.textui.TestRunner - */ - public static void main(String[] args) { - Test s = suite(); - TestRunner.run(s); - } - - /** - * Collects all CACAO regression unit tests as one suite - */ - public static Test suite() { - TestSuite suite = new TestSuite("CACAO Regression Unit Tests"); - - // Add your test here. - - suite.addTest(new TestSuite(PR52.class)); - suite.addTest(new TestSuite(PR57.class)); - suite.addTest(new TestSuite(PR58.class)); - suite.addTest(new TestSuite(PR65.class)); - - return suite; - } +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) + +@Suite.SuiteClasses({ +PR52.class, +PR57.class, +PR58.class, +PR65.class, +PR80.class, +PR89.class +}) + +public class All { } diff --git a/tests/regression/bugzilla/Makefile.am b/tests/regression/bugzilla/Makefile.am index b22e5a2d9..f56d5df03 100644 --- a/tests/regression/bugzilla/Makefile.am +++ b/tests/regression/bugzilla/Makefile.am @@ -23,7 +23,7 @@ JAVA = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao JAVACMD = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH) -JAVACCMD = $(JAVAC) -bootclasspath $(BOOTCLASSPATH) +JAVACCMD = $(JAVAC) -source 1.5 -target 1.5 -nowarn -bootclasspath $(BOOTCLASSPATH) EXTRA_DIST = \ $(srcdir)/*.java @@ -34,10 +34,10 @@ CLEANFILES = \ check: build run build: - $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java + $(JAVACCMD) -classpath $(JUNIT_JAR) -d . $(srcdir)/*.java run: - $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All + $(JAVACMD) -classpath $(JUNIT_JAR):. org.junit.runner.JUnitCore All ## Local variables: diff --git a/tests/regression/bugzilla/PR52.java b/tests/regression/bugzilla/PR52.java index fae85f1ca..c189a2eb8 100644 --- a/tests/regression/bugzilla/PR52.java +++ b/tests/regression/bugzilla/PR52.java @@ -23,20 +23,12 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; import java.security.*; -public class PR52 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR52.class); - } - +public class PR52 { + @Test public void test() { // This one only triggers with GNU Classpath. AccessController.getContext(); diff --git a/tests/regression/bugzilla/PR57.java b/tests/regression/bugzilla/PR57.java index b8a960fe6..2bd11f5d0 100644 --- a/tests/regression/bugzilla/PR57.java +++ b/tests/regression/bugzilla/PR57.java @@ -23,24 +23,11 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; -public class PR57 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR57.class); - } - - public void test() { - try { - Class.forName("x"); - fail("Should throw ClassNotFoundException"); - } - catch (ClassNotFoundException success) { - } +public class PR57 { + @Test ( expected = ClassNotFoundException.class ) + public void test() throws ClassNotFoundException { + Class.forName("x"); } } diff --git a/tests/regression/bugzilla/PR58.java b/tests/regression/bugzilla/PR58.java index d70281c29..e8c9db083 100644 --- a/tests/regression/bugzilla/PR58.java +++ b/tests/regression/bugzilla/PR58.java @@ -23,23 +23,16 @@ */ -import junit.framework.*; -import junit.textui.*; +import org.junit.Test; +import static org.junit.Assert.*; import java.io.*; -public class PR58 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR58.class); - } - +public class PR58 { class x extends y {} class y {} + @Test public void testSuperClass() { // Delete the class file which is extended. new File("PR58$y.class").delete(); @@ -60,6 +53,7 @@ public class PR58 extends TestCase { interface i {} class j implements i {} + @Test public void testSuperInterface() { // Delete the interface file which is implemented. new File("PR58$i.class").delete(); diff --git a/tests/regression/bugzilla/PR65.java b/tests/regression/bugzilla/PR65.java index 400a3e61a..8fd141806 100644 --- a/tests/regression/bugzilla/PR65.java +++ b/tests/regression/bugzilla/PR65.java @@ -23,25 +23,13 @@ */ -import junit.framework.*; -import junit.textui.*; - -public class PR65 extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(PR65.class); - } - - public void test() { - try { - Object o = new int[2][1]; - Number[][] na = (Number[][]) o; - na[0][0] = null; - fail("Should throw ClassCastException"); - } catch (ClassCastException success) { - } +import org.junit.Test; + +public class PR65 { + @Test ( expected = ClassCastException.class ) + public void test() throws ClassCastException { + Object o = new int[2][1]; + Number[][] na = (Number[][]) o; + na[0][0] = null; } } diff --git a/tests/regression/bugzilla/PR80.java b/tests/regression/bugzilla/PR80.java new file mode 100644 index 000000000..85f23d820 --- /dev/null +++ b/tests/regression/bugzilla/PR80.java @@ -0,0 +1,36 @@ +/* tests/regression/bugzilla/PR80.java + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +import org.junit.Test; + +public class PR80 { + @Test ( expected = ArrayIndexOutOfBoundsException.class ) + public void test() throws ArrayIndexOutOfBoundsException { + // Taken from Mauve gnu.testlet.java.lang.System.arraycopy + int[] a = new int[5]; + int[] b = new int[5]; + System.arraycopy(a, 4, b, 4, Integer.MAX_VALUE); + } +} diff --git a/tests/regression/bugzilla/PR89.java b/tests/regression/bugzilla/PR89.java new file mode 100644 index 000000000..506ac21d8 --- /dev/null +++ b/tests/regression/bugzilla/PR89.java @@ -0,0 +1,62 @@ +/* tests/regression/bugzilla/PR89.java + + Copyright (C) 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + +*/ + + +import org.junit.Test; +import static org.junit.Assert.*; + +import java.lang.reflect.*; + +public class PR89 { + final static float f = 123.456f; + final static double d = 789.012; + + @Test + public void testFloat() throws Exception { + FloatReflect floatReflect = new FloatReflect(); + Method m = FloatReflect.class.getMethod("returnFloat", null); + Float ret = (Float) m.invoke(floatReflect, null); + assertEquals(f, ret, 0.0); + } + + @Test + public void testDouble() throws Exception { + DoubleReflect doubleReflect = new DoubleReflect(); + Method m = DoubleReflect.class.getMethod("returnDouble", null); + Double ret = (Double) m.invoke(doubleReflect, null); + assertEquals(d, ret, 0.0); + } + + class FloatReflect { + public float returnFloat() { + return f; + } + } + + class DoubleReflect { + public double returnDouble() { + return d; + } + } +} diff --git a/tests/regression/jasmin/Makefile.am b/tests/regression/jasmin/Makefile.am index 7584b3be3..25d689f6b 100644 --- a/tests/regression/jasmin/Makefile.am +++ b/tests/regression/jasmin/Makefile.am @@ -37,7 +37,7 @@ CLEANFILES = \ check: build run build: - $(JAVACMD) -cp /usr/share/java/cup.jar:/usr/share/java/jasmin-sable.jar jasmin.Main $(srcdir)/*.j + $(JAVACMD) -cp $(JASMIN_JAR) jasmin.Main $(srcdir)/*.j run: @LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs JAVA="$(top_builddir)/src/cacao/cacao -Xbootclasspath:$(BOOTCLASSPATH)" $(srcdir)/runtest $(srcdir)/*.j diff --git a/tests/regression/junit/All.java b/tests/regression/junit/All.java deleted file mode 100644 index 15a552301..000000000 --- a/tests/regression/junit/All.java +++ /dev/null @@ -1,52 +0,0 @@ -/* tests/regression/junit/All.java - runs all CACAO regression unit tests - - Copyright (C) 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -import junit.framework.*; -import junit.textui.*; - -public class All extends TestCase { - /** - * Runs all CACAO regression unit tests using - * junit.textui.TestRunner - */ - public static void main(String[] args) { - Test s = suite(); - TestRunner.run(s); - } - - /** - * Collects all CACAO regression unit tests as one suite. - */ - public static Test suite() { - TestSuite suite = new TestSuite("CACAO Regression Unit Tests"); - - // Add your test here. - - suite.addTest(new TestSuite(TestPatcher.class)); - suite.addTest(new TestSuite(TestExceptionInStaticClassInitializer.class)); - - return suite; - } -} diff --git a/tests/regression/junit/Makefile.am b/tests/regression/junit/Makefile.am deleted file mode 100644 index d43942e68..000000000 --- a/tests/regression/junit/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -## tests/regression/junit/Makefile.am -## -## Copyright (C) 2008 -## CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO -## -## This file is part of CACAO. -## -## This program is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 2, or (at -## your option) any later version. -## -## This program is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -## 02110-1301, USA. - - -JAVA = LD_LIBRARY_PATH=$(top_builddir)/src/cacao/.libs $(top_builddir)/src/cacao/cacao -JAVACMD = $(JAVA) -Xbootclasspath:$(BOOTCLASSPATH) -JAVACCMD = $(JAVAC) -source 1.5 -target 1.5 -nowarn -bootclasspath $(BOOTCLASSPATH) - -EXTRA_DIST = \ - $(srcdir)/*.java - -CLEANFILES = \ - *.class - -check: build run - -build: - $(JAVACCMD) -classpath /usr/share/java/junit4.jar -d . $(srcdir)/*.java - -run: - $(JAVACMD) -classpath /usr/share/java/junit4.jar:. org.junit.runner.JUnitCore All - - -## Local variables: -## mode: Makefile -## indent-tabs-mode: t -## c-basic-offset: 4 -## tab-width: 8 -## compile-command: "automake --add-missing" -## End: diff --git a/tests/regression/junit/TestExceptionInStaticClassInitializer.java b/tests/regression/junit/TestExceptionInStaticClassInitializer.java deleted file mode 100644 index e6cc93e07..000000000 --- a/tests/regression/junit/TestExceptionInStaticClassInitializer.java +++ /dev/null @@ -1,66 +0,0 @@ -/* tests/regression/bugzilla/TestExceptionInStaticClassInitializer.java - - Copyright (C) 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -import junit.framework.*; -import junit.textui.*; - -public class TestExceptionInStaticClassInitializer extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(TestExceptionInStaticClassInitializer.class); - } - - public void test() { - try { - TestExceptionInStaticClassInitializer_x.i = 1; - fail("Should throw ExceptionInInitializerError"); - } - catch (ExceptionInInitializerError success) { - Throwable cause = success.getCause(); - - assertTrue("Cause should be RuntimeException but is " + cause.getClass(), cause.getClass() == RuntimeException.class); - - StackTraceElement[] ste = cause.getStackTrace(); - - assertTrue("Linenumber should be " + LINE + " but is " + ste[0].getLineNumber(), ste[0].getLineNumber() == LINE); - } - } - - // This linenumber must be the one from... - final static int LINE = 64; -} - -class TestExceptionInStaticClassInitializer_x { - static int i; - - static { - if (true) - // ...the following line. - throw new RuntimeException(); - } -} diff --git a/tests/regression/junit/TestPatcher.java b/tests/regression/junit/TestPatcher.java deleted file mode 100644 index 841760826..000000000 --- a/tests/regression/junit/TestPatcher.java +++ /dev/null @@ -1,650 +0,0 @@ -/* tests/regression/bugzilla/TestPatcher.java - - Copyright (C) 2008 - CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO - - This file is part of CACAO. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2, or (at - your option) any later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - -*/ - - -import junit.framework.*; -import junit.textui.*; - -import java.io.*; - -public class TestPatcher extends TestCase { - public static void main(String[] args) { - TestRunner.run(suite()); - } - - public static Test suite() { - return new TestSuite(TestPatcher.class); - } - - static boolean doit = true; - - final static int i = 123; - final static long l = 1234567890123L; - final static float f = 123.456F; - final static double d = 789.012; - final static Object o = new Object(); - - public void testNormal() { - invokestatic(); - invokespecial(); - - getstatic(); - putstatic(); - putstaticconst(); - - getfield(); - putfield(); - putfieldconst(); - - newarray(); - multianewarray(); - - checkcast(); - _instanceof(); - - aastoreconst(); - } - - public void testWithoutClasses() { - // Delete all classes. - //new File("TestPatcher$invokestatic.class").delete(); - - invokestatic(); - invokespecial(); - - getstatic(); - putstatic(); - putstaticconst(); - - getfield(); - putfield(); - putfieldconst(); - - newarray(); - multianewarray(); - - checkcast(); - _instanceof(); - - aastoreconst(); - } - - private void invokestatic() { - try { - if (doit) - invokestatic.sub(); - } catch (NoClassDefFoundError e) { - fail(e.toString()); - } - } - - private void getstatic() { - try { - if (doit) - assertTrue(getstaticI.i + " != " + i, getstaticI.i == i); - } catch (NoClassDefFoundError e) { - fail(e.toString()); - } - - try { - if (doit) - assertTrue(getstaticJ.l + " != " + l, getstaticJ.l == l); - } catch (NoClassDefFoundError e) { - fail(e.toString()); - } - - try { - if (doit) - assertTrue(getstaticF.f + " != " + f, getstaticF.f == f); - } catch (NoClassDefFoundError e) { - fail(e.toString()); - } - - try { - if (doit) - assertTrue(getstaticD.d + " != " + d, getstaticD.d == d); - } catch (NoClassDefFoundError e) { - fail(e.toString()); - } - - try { - if (doit) - assertTrue(getstaticL.o + " != null", getstaticL.o == null); - } catch (NoClassDefFoundError e) { - fail(e.toString()); - } - } - - private void putstatic() { - try { - if (doit) { - putstaticI.i = i; - assertTrue(putstaticI.i + " != " + i, putstaticI.i == i); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticJ.l = l; - assertTrue(putstaticJ.l + " != " + l, putstaticJ.l == l); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticF.f = f; - assertTrue(putstaticF.f + " != " + f, putstaticF.f == f); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticD.d = d; - assertTrue(putstaticD.d + " != " + d, putstaticD.d == d); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - - try { - if (doit) { - putstaticL.o = o; - assertTrue(putstaticL.o + " != " + o, putstaticL.o == o); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void putstaticconst() { - try { - if (doit) { - putstaticconstI.i = i; - assertTrue(putstaticconstI.i + " != " + i, putstaticconstI.i == i); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstJ.l = l; - assertTrue(putstaticconstJ.l + " != " + l, putstaticconstJ.l == l); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstF.f = f; - assertTrue(putstaticconstF.f + " != " + f, putstaticconstF.f == f); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstD.d = d; - assertTrue(putstaticconstD.d + " != " + d, putstaticconstD.d == d); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstI.i = 0; - assertTrue(putstaticconstI.i + " != " + 0, putstaticconstI.i == 0); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstJ.l = 0L; - assertTrue(putstaticconstJ.l + " != " + 0L, putstaticconstJ.l == 0L); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstF.f = 0.0F; - assertTrue(putstaticconstF.f + " != " + 0.0F, putstaticconstF.f == 0.0F); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstD.d = 0.0; - assertTrue(putstaticconstD.d + " != " + 0.0, putstaticconstD.d == 0.0); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstL.o = null; - assertTrue(putstaticconstL.o + " != " + null, putstaticconstL.o == null); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putstaticconstC.c = putstaticconstC.class; - assertTrue(putstaticconstC.c + " != " + Class.forName("TestPatcher$putstaticconstC"), putstaticconstC.c == Class.forName("TestPatcher$putstaticconstC")); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } catch (ClassNotFoundException t) { - fail(t.toString()); - } - } - - private void getfield() { - try { - if (doit) - assertTrue(new getfieldI().i + " != " + i, new getfieldI().i == i); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) - assertTrue(new getfieldJ().l + " != " + l, new getfieldJ().l == l); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) - assertTrue(new getfieldF().f + " != " + f, new getfieldF().f == f); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) - assertTrue(new getfieldD().d + " != " + d, new getfieldD().d == d); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) - assertTrue(new getfieldL().o + " != " + null, new getfieldL().o == null); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void putfield() { - try { - if (doit) { - TestPatcher.putfieldI pfi = new TestPatcher.putfieldI(); - pfi.i = i; - assertTrue(pfi.i + " != " + i, pfi.i == i); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldJ pfj = new putfieldJ(); - pfj.l = l; - assertTrue(pfj.l + " != " + l, pfj.l == l); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldF pff = new putfieldF(); - pff.f = f; - assertTrue(pff.f + " != " + f, pff.f == f); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldD pfd = new putfieldD(); - pfd.d = d; - assertTrue(pfd.d + " != " + d, pfd.d == d); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldL pfl = new putfieldL(); - pfl.o = o; - assertTrue(pfl.o + " != " + o, pfl.o == o); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void putfieldconst() { - try { - if (doit) { - putfieldconstI pfci = new putfieldconstI(); - pfci.i = i; - assertTrue(pfci.i + " != " + i, pfci.i == i); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstJ pfcj = new putfieldconstJ(); - pfcj.l = l; - assertTrue(pfcj.l + " != " + l, pfcj.l == l); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstF pfcf = new putfieldconstF(); - pfcf.f = f; - assertTrue(pfcf.f + " != " + f, pfcf.f == f); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstD pfcd = new putfieldconstD(); - pfcd.d = d; - assertTrue(pfcd.d + " != " + d, pfcd.d == d); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstI pfci = new putfieldconstI(); - pfci.i = 0; - assertTrue(pfci.i + " != " + 0, pfci.i == 0); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstJ pfcj = new putfieldconstJ(); - pfcj.l = 0L; - assertTrue(pfcj.l + " != " + 0L, pfcj.l == 0L); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstF pfcf = new putfieldconstF(); - pfcf.f = 0.0F; - assertTrue(pfcf.f + " != " + 0.0F, pfcf.f == 0.0F); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstD pfcd = new putfieldconstD(); - pfcd.d = 0.0; - assertTrue(pfcd.d + " != " + 0.0, pfcd.d == 0.0); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstL pfcl = new putfieldconstL(); - pfcl.o = null; - assertTrue(pfcl.o + " != " + null, pfcl.o == null); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) { - putfieldconstC pfcc = new putfieldconstC(); - pfcc.c = putfieldconstC.class; - assertTrue(pfcc.c + " != " + Class.forName("TestPatcher$putfieldconstC"), pfcc.c == Class.forName("TestPatcher$putfieldconstC")); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } catch (ClassNotFoundException t) { - fail(t.toString()); - } - } - - private void newarray() { - try { - if (doit) { - newarray[] na = new newarray[1]; - na[0] = null; - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void multianewarray() { - try { - if (doit) { - multianewarray[][] ma = new multianewarray[1][1]; - ma[0][0] = null; - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void invokespecial() { - try { - if (doit) - new invokespecial(); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void checkcast() { - Object o = new Object(); - - // class - try { - if (doit) { - checkcastC cc = (checkcastC) o; - fail(); - } - } catch (ClassCastException success) { - // This is OK. - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - // interface - try { - if (doit) { - checkcastI ci = (checkcastI) o; - fail(); - } - } catch (ClassCastException success) { - // This is OK. - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - - // array - Object[] oa = new Object[1]; - - try { - if (doit) { - checkcastC[] cca = (checkcastC[]) oa; - fail(); - } - } catch (ClassCastException e) { - // This is OK. - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void _instanceof() { - Object o = new Object(); - - try { - if (doit) - if (o instanceof instanceofC) - fail(); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - try { - if (doit) - if (o instanceof instanceofI) - fail(); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - - - // array - Object[] oa = new Object[1]; - - try { - if (doit) - if (oa instanceof instanceofC[]) - fail(); - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } - } - - private void aastoreconst() { - Class[] ca = new Class[1]; - - try { - if (doit) { - ca[0] = aastoreconstClass.class; - - if (ca[0] == null) - fail(); - - assertTrue(ca[0] + " != " + Class.forName("TestPatcher$aastoreconstClass") , ca[0] == Class.forName("TestPatcher$aastoreconstClass")); - } - } catch (NoClassDefFoundError t) { - fail(t.toString()); - } catch (ClassNotFoundException t) { - fail(t.toString()); - } - } - - static class invokestatic { static void sub() {} } - static class invokespecial { void invokespecial() {} } - - static class getstaticI { static int i = TestPatcher.i; } - static class getstaticJ { static long l = TestPatcher.l; } - static class getstaticF { static float f = TestPatcher.f; } - static class getstaticD { static double d = TestPatcher.d; } - static class getstaticL { static Object o = null; } - - static class putstaticI { static int i; } - static class putstaticJ { static long l; } - static class putstaticF { static float f; } - static class putstaticD { static double d; } - static class putstaticL { static Object o; } - - static class putstaticconstI { static int i; } - static class putstaticconstJ { static long l; } - static class putstaticconstF { static float f; } - static class putstaticconstD { static double d; } - static class putstaticconstL { static Object o; } - static class putstaticconstC { static Class c; } - - static class getfieldI { int i = TestPatcher.i; } - static class getfieldJ { long l = TestPatcher.l; } - static class getfieldF { float f = TestPatcher.f; } - static class getfieldD { double d = TestPatcher.d; } - static class getfieldL { Object o = null; } - - static class putfieldI { int i; } - static class putfieldJ { long l; } - static class putfieldF { float f; } - static class putfieldD { double d; } - static class putfieldL { Object o; } - - static class putfieldconstI { int i; } - static class putfieldconstJ { long l; } - static class putfieldconstF { float f; } - static class putfieldconstD { double d; } - static class putfieldconstL { Object o; } - static class putfieldconstC { Class c; } - - static class newarray {} - static class multianewarray {} - - static class instanceofC {} - static interface instanceofI {} - - static class checkcastC {} - static interface checkcastI {} - - static class aastoreconstClass {} -} diff --git a/tests/regression/native/checkjni.c b/tests/regression/native/checkjni.c index 62a57afe7..68337d49e 100644 --- a/tests/regression/native/checkjni.c +++ b/tests/regression/native/checkjni.c @@ -1,9 +1,7 @@ /* src/tests/native/checkjni.c - for testing JNI stuff - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,20 +20,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - Changes: - */ +#include "config.h" + #include #include -#include "config.h" -#include "native/jni.h" +#include "native/jni.hpp" JNIEXPORT jboolean JNICALL Java_checkjni_IsAssignableFrom(JNIEnv *env, jclass clazz, jclass sub, jclass sup) diff --git a/tests/regression/native/test.c b/tests/regression/native/test.c index 3d568f66d..f6a077749 100644 --- a/tests/regression/native/test.c +++ b/tests/regression/native/test.c @@ -1,9 +1,7 @@ /* tests/native/test.c - for testing native stuff - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,18 +20,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Christian Thalinger - - */ +#include "config.h" + #include -#include "config.h" -#include "native/jni.h" +#include "native/jni.hpp" JNIEXPORT void JNICALL Java_test_nsub(JNIEnv *env, jclass clazz) diff --git a/tests/regression/native/testarguments.c b/tests/regression/native/testarguments.c index bc7be27c5..8c95c8a69 100644 --- a/tests/regression/native/testarguments.c +++ b/tests/regression/native/testarguments.c @@ -1,9 +1,7 @@ /* tests/regression/native/testarguments.c - tests argument passing - Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - TU Wien + Copyright (C) 1996-2005, 2006, 2007, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -30,7 +28,7 @@ #include #include -#include "native/jni.h" +#include "native/jni.hpp" JNIEXPORT jobject JNICALL Java_testarguments_adr(JNIEnv *env, jclass clazz, jint i) diff --git a/tests/regression/native/testgetobjectclass0.c b/tests/regression/native/testgetobjectclass0.c index 2bce8e1f1..961025bf4 100644 --- a/tests/regression/native/testgetobjectclass0.c +++ b/tests/regression/native/testgetobjectclass0.c @@ -1,9 +1,7 @@ /* tests/native/testgetobjectclass0.c - tests argument passing - Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel, - C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring, - E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, - TU Wien + Copyright (C) 1996-2005, 2006, 2008 + CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO This file is part of CACAO. @@ -22,16 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Contact: cacao@cacaojvm.org - - Authors: Joseph Wenninger - - */ #include "config.h" -#include "native/jni.h" +#include "native/jni.hpp" JNIEXPORT void JNICALL Java_testgetobjectclass0_getobjectclass0(JNIEnv *env, jclass clazz)