Merged revisions 7797-7917 via svnmerge from
authormichi <none@none>
Sun, 20 May 2007 20:42:18 +0000 (20:42 +0000)
committermichi <none@none>
Sun, 20 May 2007 20:42:18 +0000 (20:42 +0000)
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/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.
........
  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.
........

--HG--
branch : exact-gc

247 files changed:
.cvsignore [deleted file]
configure.ac
contrib/.cvsignore [deleted file]
contrib/check_dangerous_printf.pl [deleted file]
doc/.cvsignore [deleted file]
doc/handbook/.cvsignore [deleted file]
man/.cvsignore [deleted file]
src/.cvsignore [deleted file]
src/cacao/.cvsignore [deleted file]
src/cacaoh/.cvsignore [deleted file]
src/cacaoh/dummy.c
src/fdlibm/.cvsignore [deleted file]
src/lib/.cvsignore [deleted file]
src/lib/Makefile.am
src/lib/vm/reference/gnu/classpath/VMStackWalker.java [deleted file]
src/lib/vm/reference/gnu/classpath/VMSystemProperties.java [deleted file]
src/lib/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java [deleted file]
src/lib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java [deleted file]
src/lib/vm/reference/java/lang/VMClassLoader.java [deleted file]
src/lib/vm/reference/java/lang/VMString.java [deleted file]
src/lib/vm/reference/java/lang/VMThread.java [deleted file]
src/lib/vm/reference/java/lang/VMThrowable.java [deleted file]
src/lib/vm/reference/java/security/VMAccessController.java [deleted file]
src/mm/.cvsignore [deleted file]
src/mm/boehm-gc/.cvsignore [deleted file]
src/mm/boehm-gc/doc/.cvsignore [deleted file]
src/mm/boehm-gc/include/.cvsignore [deleted file]
src/mm/boehm-gc/include/gc.h
src/mm/cacao-gc/.cvsignore [deleted file]
src/mm/memory.c
src/mm/memory.h
src/native/.cvsignore [deleted file]
src/native/include/.cvsignore [deleted file]
src/native/jni.c
src/native/jvmti/.cvsignore [deleted file]
src/native/native.c
src/native/native.h
src/native/tools/.cvsignore [deleted file]
src/native/vm/.cvsignore [deleted file]
src/native/vm/Makefile.am
src/native/vm/cldc1.1/.cvsignore [deleted file]
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 [deleted file]
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 [deleted file]
src/threads/.cvsignore [deleted file]
src/threads/Makefile.am
src/threads/critical.c
src/threads/critical.h
src/threads/native/.cvsignore [deleted file]
src/threads/native/lock.c
src/threads/native/lock.h
src/threads/native/threads.c
src/threads/native/threads.h
src/threads/none/.cvsignore [deleted file]
src/threads/none/lock.h
src/threads/threads-common.c
src/threads/threads-common.h
src/toolbox/.cvsignore [deleted file]
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 [deleted file]
src/vm/Makefile.am
src/vm/builtin.c
src/vm/finalizer.c
src/vm/initialize.c
src/vm/jit/.cvsignore [deleted file]
src/vm/jit/allocator/.cvsignore [deleted file]
src/vm/jit/alpha/.cvsignore [deleted file]
src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/emit.c
src/vm/jit/alpha/freebsd/.cvsignore [deleted file]
src/vm/jit/alpha/linux/.cvsignore [deleted file]
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/arm/.cvsignore [deleted file]
src/vm/jit/arm/codegen.c
src/vm/jit/arm/emit.c
src/vm/jit/arm/linux/.cvsignore [deleted file]
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 [deleted file]
src/vm/jit/i386/codegen.c
src/vm/jit/i386/darwin/.cvsignore [deleted file]
src/vm/jit/i386/darwin/md-os.c
src/vm/jit/i386/emit.c
src/vm/jit/i386/freebsd/.cvsignore [deleted file]
src/vm/jit/i386/linux/.cvsignore [deleted file]
src/vm/jit/i386/linux/md-os.c
src/vm/jit/inline/.cvsignore [deleted file]
src/vm/jit/inline/Makefile.am
src/vm/jit/inline/inline.c
src/vm/jit/inline/inline.h
src/vm/jit/intrp/.cvsignore [deleted file]
src/vm/jit/jit.c
src/vm/jit/loop/.cvsignore [deleted file]
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 [deleted file]
src/vm/jit/mips/codegen.c
src/vm/jit/mips/emit.c
src/vm/jit/mips/irix/.cvsignore [deleted file]
src/vm/jit/mips/linux/.cvsignore [deleted file]
src/vm/jit/mips/linux/md-os.c
src/vm/jit/optimizing/.cvsignore [deleted file]
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 [deleted file]
src/vm/jit/parisc/linux/.cvsignore [deleted file]
src/vm/jit/parse.c
src/vm/jit/patcher.h
src/vm/jit/powerpc/.cvsignore [deleted file]
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/darwin/.cvsignore [deleted file]
src/vm/jit/powerpc/emit.c
src/vm/jit/powerpc/linux/.cvsignore [deleted file]
src/vm/jit/powerpc/linux/md-abi.c
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc/netbsd/.cvsignore [deleted file]
src/vm/jit/powerpc64/.cvsignore [deleted file]
src/vm/jit/powerpc64/asmpart.S
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/emit.c
src/vm/jit/powerpc64/linux/.cvsignore [deleted file]
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/powerpc64/patcher.c
src/vm/jit/s390/.cvsignore [deleted file]
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 [deleted file]
src/vm/jit/show.c
src/vm/jit/sparc64/.cvsignore [deleted file]
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 [deleted file]
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 [deleted file]
src/vm/jit/sparc64/solaris/md-os.c
src/vm/jit/stack.c
src/vm/jit/stacktrace.c
src/vm/jit/tools/.cvsignore [deleted file]
src/vm/jit/verify/.cvsignore [deleted file]
src/vm/jit/x86_64/.cvsignore [deleted file]
src/vm/jit/x86_64/codegen.c
src/vm/jit/x86_64/emit.c
src/vm/jit/x86_64/freebsd/.cvsignore [deleted file]
src/vm/jit/x86_64/linux/.cvsignore [deleted file]
src/vm/jit/x86_64/linux/md-os.c
src/vm/signal.c
src/vm/string.c
src/vm/vm.c
src/vmcore/.cvsignore [deleted file]
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 [deleted file]
tests/Makefile.am
tests/regression/.cvsignore [deleted file]
tests/regression/codepatching/.cvsignore [deleted file]
tests/regression/native/.cvsignore [deleted file]
tests/stack/.cvsignore [deleted file]

diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644 (file)
index f9fd942..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-Makefile
-Makefile.in
-TAGS
-aclocal.m4
-autom4te.cache
-config.h
-config.h.in
-config.log
-config.status
-configure
-libtool
-stamp-h1
-compile
-config.guess
-config.sub
-depcomp
-install-sh
-ltmain.sh
-missing
index 327d6171e944322c9be3bcf6c7589d4c657b11ca..62b76eb92258b3241ffa17c9e805271b2cfbeb15 100644 (file)
@@ -22,7 +22,7 @@ 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 
-dnl $Id: configure.ac 7796 2007-04-23 20:04:44Z twisti $
+dnl $Id: configure.ac 7902 2007-05-11 22:33:15Z twisti $
 
 dnl Process this file with autoconf to produce a configure script.
 
@@ -212,10 +212,16 @@ AM_PROG_MKDIR_P
 dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
+
+dnl keep them alpha-sorted!
 AC_CHECK_HEADERS([fcntl.h])
-AC_CHECK_HEADERS([sys/time.h])
+AC_CHECK_HEADERS([string.h])
+AC_CHECK_HEADERS([time.h])
 AC_CHECK_HEADERS([unistd.h])
 AC_CHECK_HEADERS([sys/ioctl.h])
+AC_CHECK_HEADERS([sys/mman.h])
+AC_CHECK_HEADERS([sys/resource.h])
+AC_CHECK_HEADERS([sys/time.h])
 
 dnl this is for fdlibm
 AC_CHECK_HEADERS([stdint.h])
@@ -241,10 +247,23 @@ AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
 AC_FUNC_MEMCMP
 AC_FUNC_MMAP
-AC_CHECK_FUNCS([calloc mmap getpagesize free])
-AC_CHECK_FUNCS([getcwd gettimeofday])
-AC_CHECK_FUNCS([scandir])
+
+dnl keep them alpha-sorted!
+AC_CHECK_FUNCS([calloc])
+AC_CHECK_FUNCS([getpagesize])
+AC_CHECK_FUNCS([free])
+AC_CHECK_FUNCS([getcwd])
+AC_CHECK_FUNCS([gettimeofday])
+AC_CHECK_FUNCS([getrusage])
 AC_CHECK_FUNCS([isnan])
+AC_CHECK_FUNCS([localtime])
+AC_CHECK_FUNCS([localtime_r])
+AC_CHECK_FUNCS([mmap])
+AC_CHECK_FUNCS([mprotect])
+AC_CHECK_FUNCS([scandir])
+AC_CHECK_FUNCS([strdup])
+AC_CHECK_FUNCS([time])
+
 
 dnl Checks for libraries.
 
@@ -569,61 +588,7 @@ if test x"${ENABLE_JVMTI}" = "xyes"; then
 fi
 
 
-dnl threads
-AC_ARG_ENABLE([threads], [AS_HELP_STRING(--enable-threads,enable threads support (none,native) [[default=native]])])
-AC_ARG_ENABLE([__thread], [AS_HELP_STRING(--enable-__thread,use TLS features)], [use__thread=$enableval], [use__thread=no])
-
-AC_MSG_CHECKING(whether to include threads support)
-enable_threads=${enable_threads:-native}
-case "$enable_threads" in
-no | none | single)
-    AC_MSG_RESULT(no)
-    dnl no threads for boehm
-    ac_configure_args="$ac_configure_args --disable-boehm-threads"
-    AM_CONDITIONAL([ENABLE_THREADS], [false])
-    ;;
-
-native | posix | pthreads)
-    AC_DEFINE([ENABLE_THREADS], 1, [enable threads])
-    
-    AM_CONDITIONAL([ENABLE_THREADS], [true])
-    
-    AC_MSG_RESULT(yes, native)
-    AC_CHECK_LIB(pthread, main)
-
-    ARCH_CFLAGS="$ARCH_CFLAGS -D_REENTRANT"
-
-    dnl we changed ARCH_CFLAGS, set CFLAGS again
-    CFLAGS="$ARCH_CFLAGS $OPT_CFLAGS"
-
-    dnl tell boehm to support threads as well
-    ac_configure_args="$ac_configure_args --enable-boehm-threads=posix"
-    ;;
-
-*)
-    AC_MSG_ERROR($enable_threads is an unknown thread package)
-    ;;
-esac
-
-
-dnl Check whether the compiler supports the __thread keyword.
-if test "x$use__thread" != xno; then
-  AC_CACHE_CHECK([for __thread], ac_cv_gcc___thread,
-  [cat > conftest.c <<\EOF
-__thread int a = 42;
-EOF
-  if AC_TRY_COMMAND([${CC-cc} $ARCH_CFLAGS $OPT_CFLAGS -c conftest.c >&AS_MESSAGE_LOG_FD]); then
-    ac_cv_gcc___thread=yes 
-  else
-    ac_cv_gcc___thread=no
-  fi
-  rm -f conftest*])
-  if test "$ac_cv_gcc___thread" = yes; then
-    AC_DEFINE([HAVE___THREAD], 1, [have __thread])
-  fi
-else
-  ac_cv_gcc___thread=no
-fi
+AC_CHECK_ENABLE_THREADS
 
 
 dnl check if if-conversion should be supported
@@ -982,6 +947,7 @@ AC_CONFIG_FILES([Makefile]
                [src/vm/jit/mips/Makefile]
                [src/vm/jit/mips/irix/Makefile]
                [src/vm/jit/mips/linux/Makefile]
+               [src/vm/jit/mips/uclinux/Makefile]
                [src/vm/jit/optimizing/Makefile]
                [src/vm/jit/parisc/Makefile]
                [src/vm/jit/parisc/linux/Makefile]
diff --git a/contrib/.cvsignore b/contrib/.cvsignore
deleted file mode 100644 (file)
index d573a97..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Makefile
-Makefile.in
-setenvinstalled
-setenvsource
diff --git a/contrib/check_dangerous_printf.pl b/contrib/check_dangerous_printf.pl
deleted file mode 100644 (file)
index 2a4d742..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-#! perl -w
-
-# This scripts finds calls of printf and printf-like functions which
-# do not use a literal string as format. Such calls are potentially
-# dangerous as they could use formats which do not match their
-# argument lists.
-
-use strict;
-use File::Find;
-no warnings 'File::Find';
-
-my @FUNCTIONS =
-    (
-     # NAME ........ name of function
-     # FORMATPOS ... index of format string argument, first is 1
-     {NAME => 'printf'     ,FORMATPOS => 1},
-     {NAME => 'sprintf'    ,FORMATPOS => 2},
-     {NAME => 'fprintf'    ,FORMATPOS => 2},
-     {NAME => 'error'      ,FORMATPOS => 1},
-     {NAME => 'dolog'      ,FORMATPOS => 1},
-     {NAME => 'dolog_plain',FORMATPOS => 1},
-    );
-
-my $rxall;
-my %tests;
-my @tests;
-my @files;
-
-prepare();
-find(\&wanted,'.');
-process();
-
-sub prepare
-{
-    for my $f (@FUNCTIONS) {
-       my $name = $f->{NAME};
-       $rxall .= "|" if $rxall;
-       $rxall .= "\\b$name\\b";
-#      push @{$tests{$f->{FORMATPOS}}},$f;
-       $tests{$f->{NAME}} = $f;
-    }
-    $rxall = qr/($rxall)/;
-    study $rxall;
-}
-
-sub wanted
-{
-    push @files, $File::Find::name if /\.[ch]$/i;
-    push @files, $File::Find::name if /\.inc$/i;
-}
-
-sub get_args
-{
-    my ($coderef,$file,$line) = @_;
-    my $arg;
-    my $level = 0;
-    my @args;
-
- ARG:
-    while (1) {
-       unless ($$coderef =~ /\G(.*?)([,()"])/g) {
-           return undef;
-       }
-       $arg .= $1;
-       my $d = $2;
-       if ($d eq ')') {
-           if ($level-- == 0) {
-               push @args,$arg;
-               return \@args;
-           }
-       }
-       elsif ($d eq ',') {
-           if ($level == 0) {
-               push @args,$arg;
-               $arg = '';
-               next ARG;
-           }
-       }
-       elsif ($d eq '(') {
-           $level++;
-       }
-       elsif ($d eq '"') {
-           unless($$coderef =~ /\G  (  ([^\\"]|\\.)*   "  )  /gx) {
-               return undef;
-           }
-           $d .= $1;
-       }
-       $arg .= $d;
-    }
-}
-
-sub process
-{
-    for my $file (@files) {
-#      print "$file\n";
-       open(FILE,"<$file") or die "Could not open $file: $!";
-       my $code;
-       my $pos = 0;
-       my @pos;
-       while (<FILE>) {
-           s/\n/ /;
-           s/[ \t]+/ /;
-           $code .= $_;
-           push @pos,$pos;
-           $pos += length;
-       }
-       close(FILE);
-
-       my $line = 1;
-    OCC:
-       while ($code =~ /$rxall/g) {
-           my $pos = pos($code);
-           my $fname = $1;
-           my $test = $tests{$fname};
-           while (pos($code) > $pos[$line]) {$line++}
-#          print "$1\n";
-           unless ($code =~ /\G\s*\(/g) {
-               print STDERR "$file:$line: warning: could not find parenthesis\n";
-               pos($code) = $pos;
-               next OCC;
-           }
-       
-           my $index = 1;
-
-           my $args = get_args(\$code,$file,$line);
-           unless ($args) {
-               print STDERR "$file:$line:warning: could not parse arguments\n";
-               pos($code) = $pos;
-               next OCC;
-           }
-
-           if (@$args < $test->{FORMATPOS}) {
-               print STDERR "$file:$line: warning: could not find format of $fname\n";
-               next OCC;
-           }
-
-           my $fmt = $args->[$test->{FORMATPOS} - 1];
-
-           if ($fmt =~ /^\s*$/) {
-               print "$file:$line: missing format: $fname(".join(',',@$args).")\n";
-               next OCC;
-           }
-
-           unless ($fmt =~ /^\s*"/) {
-               print "$file:$line: nonliteral format: $fname(".join(',',@$args).")\n";
-               next OCC;
-           }
-
-           if ($fmt =~ /^\s*"(.*)"\s*$/) {
-               my $f = $1;
-               $f =~ s/"\s+"//g;
-               my $pct = 0;
-               while ($f =~ /(%%?)/g) {$pct++ if length($1)==1};
-
-               if ($pct != @$args - $test->{FORMATPOS}) {
-               print "$file:$line: arguments?: $fname(".join(',',@$args).")\n";
-               }
-           }
-       }
-    }
-}
-
diff --git a/doc/.cvsignore b/doc/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/doc/handbook/.cvsignore b/doc/handbook/.cvsignore
deleted file mode 100644 (file)
index 1acaf34..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-*.aux
-*.bbl
-*.blg
-*.dvi
-*.log
-*.toc
-Makefile
-Makefile.in
diff --git a/man/.cvsignore b/man/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/src/.cvsignore b/src/.cvsignore
deleted file mode 100644 (file)
index e5cd21f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-TAGS
diff --git a/src/cacao/.cvsignore b/src/cacao/.cvsignore
deleted file mode 100644 (file)
index c3b42d4..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-cacao
-cacao.exe
diff --git a/src/cacaoh/.cvsignore b/src/cacaoh/.cvsignore
deleted file mode 100644 (file)
index 0c6e784..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-cacaoh
-cacaoh.exe
index 8b682765eb31e8b11a4077ef45176987ff573019..b16991631db649b0ae14d0dcd44b2db23f5710d5 100644 (file)
@@ -584,6 +584,14 @@ ptrint threads_get_current_tid(void)
        return 0;
 }
 
+void threads_cast_stopworld(void)
+{
+}
+
+void threads_cast_startworld(void)
+{
+}
+
 
 /* vm *************************************************************************/
 
diff --git a/src/fdlibm/.cvsignore b/src/fdlibm/.cvsignore
deleted file mode 100644 (file)
index 8f5e11a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.o
-*.a
-*.lo
-*.la
-.libs
-.deps
-Makefile
-Makefile.in
-TAGS
diff --git a/src/lib/.cvsignore b/src/lib/.cvsignore
deleted file mode 100644 (file)
index 1694749..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Makefile
-Makefile.in
-classes
-vm.zip
index 015d36fda3a2dbb49f3bc1ecf6b895791a6c89c2..d1217d2a29f260d0d1f1004decc0a2c475cc5b01 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 7235 2007-01-22 17:22:28Z twisti $
+## $Id: Makefile.am 7890 2007-05-09 16:05:58Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -32,15 +32,15 @@ EXTRA_DIST = \
 CLEANFILES = vm.zip
 
 VM_JAVA_FILES = \
-       $(top_srcdir)/src/lib/vm/reference/gnu/classpath/VMStackWalker.java \
-       $(top_srcdir)/src/lib/vm/reference/gnu/classpath/VMSystemProperties.java \
-       $(top_srcdir)/src/lib/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java \
-       $(top_srcdir)/src/lib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
-       $(top_srcdir)/src/lib/vm/reference/java/lang/VMClassLoader.java \
-       $(top_srcdir)/src/lib/vm/reference/java/lang/VMString.java \
-       $(top_srcdir)/src/lib/vm/reference/java/lang/VMThread.java \
-       $(top_srcdir)/src/lib/vm/reference/java/lang/VMThrowable.java \
-       $(top_srcdir)/src/lib/vm/reference/java/security/VMAccessController.java
+       $(top_srcdir)/src/lib/gnu/gnu/classpath/VMStackWalker.java \
+       $(top_srcdir)/src/lib/gnu/gnu/classpath/VMSystemProperties.java \
+       $(top_srcdir)/src/lib/gnu/gnu/java/lang/management/VMMemoryMXBeanImpl.java \
+       $(top_srcdir)/src/lib/gnu/gnu/java/lang/management/VMRuntimeMXBeanImpl.java \
+       $(top_srcdir)/src/lib/gnu/java/lang/VMClassLoader.java \
+       $(top_srcdir)/src/lib/gnu/java/lang/VMString.java \
+       $(top_srcdir)/src/lib/gnu/java/lang/VMThread.java \
+       $(top_srcdir)/src/lib/gnu/java/lang/VMThrowable.java \
+       $(top_srcdir)/src/lib/gnu/java/security/VMAccessController.java
 
 VM_CLASS_FILES = \
        classes/gnu/classpath/VMStackWalker.class \
diff --git a/src/lib/vm/reference/gnu/classpath/VMStackWalker.java b/src/lib/vm/reference/gnu/classpath/VMStackWalker.java
deleted file mode 100644 (file)
index 434edd2..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* VMStackWalker.java -- Reference implementation of VM hooks for stack access
-   Copyright (C) 2005 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath;
-
-/**
- * This class provides access to the classes on the Java stack
- * for reflection and security purposes.
- *
- * <p>
- * This class is only available to privileged code (i.e., code loaded
- * by the bootstrap loader).
- *
- * @author John Keiser
- * @author Eric Blake <ebb9@email.byu.edu>
- * @author Archie Cobbs
- */
-public final class VMStackWalker
-{
-  /**
-   * Get a list of all the classes currently executing methods on the
-   * Java stack. <code>getClassContext()[0]</code> is the class associated
-   * with the currently executing method, i.e., the method that called
-   * <code>VMStackWalker.getClassContext()</code> (possibly through
-   * reflection). So you may need to pop off these stack frames from
-   * the top of the stack:
-   * <ul>
-   * <li><code>VMStackWalker.getClassContext()</code>
-   * <li><code>Method.invoke()</code>
-   * </ul>
-   *
-   * @return an array of the declaring classes of each stack frame
-   */
-  public static native Class[] getClassContext();
-
-  /**
-   * Get the class associated with the method invoking the method
-   * invoking this method, or <code>null</code> if the stack is not
-   * that deep (e.g., invoked via JNI invocation API). This method
-   * is an optimization for the expression <code>getClassContext()[1]</code>
-   * and should return the same result.
-   *
-   * <p>
-   * VM implementers are encouraged to provide a more efficient
-   * version of this method.
-   */
-//    public static Class getCallingClass()
-//    {
-//      Class[] ctx = getClassContext();
-//      if (ctx.length < 3)
-//        return null;
-//      return ctx[2];
-//    }
-  public static native Class getCallingClass();
-
-  /**
-   * Get the class loader associated with the Class returned by
-   * <code>getCallingClass()</code>, or <code>null</code> if no such class
-   * exists or it is the boot loader. This method is an optimization for the
-   * expression <code>VMStackWalker.getClassLoader(getClassContext()[1])</code>
-   * and should return the same result.
-   *
-   * <p>
-   * VM implementers are encouraged to provide a more efficient
-   * version of this method.
-   */
-//    public static ClassLoader getCallingClassLoader()
-//    {
-//      Class[] ctx = getClassContext();
-//      if (ctx.length < 3)
-//        return null;
-//      return getClassLoader(ctx[2]);
-//    }
-  public static native ClassLoader getCallingClassLoader();
-
-
-  /**
-   * Retrieve the class's ClassLoader, or <code>null</code> if loaded
-   * by the bootstrap loader. I.e., this should return the same thing
-   * as {@link java.lang.VMClass#getClassLoader}. This duplicate version
-   * is here to work around access permissions.
-   */
-//    public static native ClassLoader getClassLoader(Class cl);
-
-  /**
-   * Walk up the stack and return the first non-null class loader.
-   * If there aren't any non-null class loaders on the stack, return null.
-   */
-//   public static ClassLoader firstNonNullClassLoader()
-//   {
-//     Class[] stack = getClassContext();
-//     for (int i = 0; i < stack.length; i++)
-//       {
-//         ClassLoader loader = getClassLoader(stack[i]);
-//         if (loader != null)
-//           return loader;
-//       }
-//     return null;
-//   }
-    public static native ClassLoader firstNonNullClassLoader();
-}
diff --git a/src/lib/vm/reference/gnu/classpath/VMSystemProperties.java b/src/lib/vm/reference/gnu/classpath/VMSystemProperties.java
deleted file mode 100644 (file)
index 287a933..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* VMSystemProperties.java -- Allow the VM to set System properties.
-   Copyright (C) 2004 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath;
-
-import java.util.Properties;
-
-class VMSystemProperties
-{
-    /**
-     * Get the system properties. This is done here, instead of in System,
-     * because of the bootstrap sequence. Note that the native code should
-     * not try to use the Java I/O classes yet, as they rely on the properties
-     * already existing. The only safe method to use to insert these default
-     * system properties is {@link Properties#setProperty(String, String)}.
-     *
-     * <p>These properties MUST include:
-     * <dl>
-     * <dt>java.version         <dd>Java version number
-     * <dt>java.vendor          <dd>Java vendor specific string
-     * <dt>java.vendor.url      <dd>Java vendor URL
-     * <dt>java.home            <dd>Java installation directory
-     * <dt>java.vm.specification.version <dd>VM Spec version
-     * <dt>java.vm.specification.vendor  <dd>VM Spec vendor
-     * <dt>java.vm.specification.name    <dd>VM Spec name
-     * <dt>java.vm.version      <dd>VM implementation version
-     * <dt>java.vm.vendor       <dd>VM implementation vendor
-     * <dt>java.vm.name         <dd>VM implementation name
-     * <dt>java.specification.version    <dd>Java Runtime Environment version
-     * <dt>java.specification.vendor     <dd>Java Runtime Environment vendor
-     * <dt>java.specification.name       <dd>Java Runtime Environment name
-     * <dt>java.class.version   <dd>Java class version number
-     * <dt>java.class.path      <dd>Java classpath
-     * <dt>java.library.path    <dd>Path for finding Java libraries
-     * <dt>java.io.tmpdir       <dd>Default temp file path
-     * <dt>java.compiler        <dd>Name of JIT to use
-     * <dt>java.ext.dirs        <dd>Java extension path
-     * <dt>os.name              <dd>Operating System Name
-     * <dt>os.arch              <dd>Operating System Architecture
-     * <dt>os.version           <dd>Operating System Version
-     * <dt>file.separator       <dd>File separator ("/" on Unix)
-     * <dt>path.separator       <dd>Path separator (":" on Unix)
-     * <dt>line.separator       <dd>Line separator ("\n" on Unix)
-     * <dt>user.name            <dd>User account name
-     * <dt>user.home            <dd>User home directory
-     * <dt>user.dir             <dd>User's current working directory
-     * <dt>gnu.cpu.endian       <dd>"big" or "little"
-     * </dl>
-     *
-     * @param properties the Properties object to insert the system properties into
-     */
-    static native void preInit(Properties properties);
-
-    /**
-     * Here you get a chance to overwrite some of the properties set by
-     * the common SystemProperties code. For example, it might be
-     * a good idea to process the properties specified on the command
-     * line here.
-     */
-//     static void postInit(Properties properties)
-//     {
-//     }
-    static native void postInit(Properties properties);
-}
diff --git a/src/lib/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java b/src/lib/vm/reference/gnu/java/lang/management/VMMemoryMXBeanImpl.java
deleted file mode 100644 (file)
index d71a06d..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/* VMMemoryMXBeanImpl.java - VM impl. of a memory bean
-   Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.lang.management;
-
-import java.lang.management.MemoryUsage;
-
-/**
- * Provides access to information about the memory
- * management of the current invocation of the virtual
- * machine.  Instances of this bean are obtained by calling
- * {@link ManagementFactory#getMemoryMXBean()}.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- * @since 1.5
- */
-final class VMMemoryMXBeanImpl
-{
-
-  /**
-   * Returns an instance of {@link java.lang.management.MemoryUsage}
-   * with appropriate initial, used, committed and maximum values
-   * for the heap.  By default, this uses the methods of
-   * {@link java.lang.Runtime} to provide some of the values.
-   *
-   * @return an {@link java.lang.management.MemoryUsage} instance
-   *         for the heap.
-   */
-//   static MemoryUsage getHeapMemoryUsage()
-//   {
-//     Runtime runtime = Runtime.getRuntime();
-//     long totalMem = runtime.totalMemory();
-//     return new MemoryUsage(-1, totalMem - runtime.freeMemory(),
-//                        totalMem, runtime.maxMemory());
-//   }
-  static native MemoryUsage getHeapMemoryUsage();
-
-  /**
-   * Returns an instance of {@link java.lang.management.MemoryUsage}
-   * with appropriate initial, used, committed and maximum values
-   * for non-heap memory.
-   *
-   * @return an {@link java.lang.management.MemoryUsage} instance
-   *         for non-heap memory.
-   */
-  static native MemoryUsage getNonHeapMemoryUsage();
-
-  /**
-   * Returns the number of objects ready to be garbage collected.
-   *
-   * @return the number of finalizable objects.
-   */
-  static native int getObjectPendingFinalizationCount();
-
-  /**
-   * Returns true if the virtual machine will emit additional
-   * information when memory is allocated and deallocated.  The
-   * format of the output is left up to the virtual machine.
-   *
-   * @return true if verbose class loading output is on.
-   */
-  static native boolean isVerbose();
-
-  /**
-   * Turns on or off the emission of additional information
-   * when memory is allocated and deallocated.  The format of the
-   * output is left up to the virtual machine.  This method
-   * may be called by multiple threads concurrently, but there
-   * is only one global setting of verbosity that is affected.
-   *
-   * @param verbose the new setting for verbose class loading
-   *                output.
-   */
-  static native void setVerbose(boolean verbose);
-
-}
diff --git a/src/lib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java b/src/lib/vm/reference/gnu/java/lang/management/VMRuntimeMXBeanImpl.java
deleted file mode 100644 (file)
index 32a8660..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* VMRuntimeMXBeanImpl.java - VM implementation of an runtime bean
-   Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.java.lang.management;
-
-import gnu.classpath.SystemProperties;
-
-/**
- * Provides access to information about the virtual machine.
- *
- * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
- * @since 1.5
- */
-final class VMRuntimeMXBeanImpl
-{
-
-  /**
-   * Returns the command-line arguments supplied
-   * to the virtual machine, excluding those supplied
-   * to <code>main()</code>.
-   *
-   * @return the command-line arguments.
-   */
-  static native String[] getInputArguments();
-
-  /**
-   * Returns a developer-chosen name for the virtual
-   * machine, which may differ over different running
-   * instances of the same virtual machine binary.
-   * For example, this may include the particular
-   * process identifier used by this instance or
-   * the host name of the machine on which it is
-   * running.  The intention is that this name refers
-   * to the precise entity that the other data supplied
-   * by the bean refers to, rather than the VM in general.
-   *
-   * @return the custom name of the VM.
-   */
-  static String getName()
-  {
-    return SystemProperties.getProperty("java.vm.name") + " " +
-      SystemProperties.getProperty("java.vm.version");
-  }
-
-  /**
-   * The time in milliseconds at which the virtual
-   * machine was started.  This method is only executed
-   * once (for efficency), as the value is not expected
-   * to change.
-   *
-   * @return the VM start time.
-   */
-  static native long getStartTime();
-
-}
diff --git a/src/lib/vm/reference/java/lang/VMClassLoader.java b/src/lib/vm/reference/java/lang/VMClassLoader.java
deleted file mode 100755 (executable)
index 46e741e..0000000
+++ /dev/null
@@ -1,454 +0,0 @@
-/* VMClassLoader.java -- Reference implementation of native interface
-   required by ClassLoader
-   Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.lang;
-
-import gnu.classpath.Configuration;
-import gnu.classpath.SystemProperties;
-import gnu.java.lang.InstrumentationImpl;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.instrument.Instrumentation;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.ProtectionDomain;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.zip.ZipFile;
-
-/**
- * java.lang.VMClassLoader is a package-private helper for VMs to implement
- * on behalf of java.lang.ClassLoader.
- *
- * @author John Keiser
- * @author Mark Wielaard (mark@klomp.org)
- * @author Eric Blake (ebb9@email.byu.edu)
- */
-final class VMClassLoader
-{
-
-
-  /** packages loaded by the bootstrap class loader */
-  static final HashMap definedPackages = new HashMap();
-
-  /** jars from property java.boot.class.path */
-  static final HashMap bootjars = new HashMap();
-  
-
-  /**
-   * Converts the array string of native package names to
-   * Packages. The packages are then put into the
-   * definedPackages hashMap
-   */
-  static
-  {
-    String[] packages = getBootPackages();
-    
-    if( packages != null)
-      {
-        String specName = 
-              SystemProperties.getProperty("java.specification.name");
-        String vendor =
-              SystemProperties.getProperty("java.specification.vendor");
-        String version =
-              SystemProperties.getProperty("java.specification.version");
-        
-        Package p;
-              
-        for(int i = 0; i < packages.length; i++)
-          {
-            p = new Package(packages[i],
-                  specName,
-                  vendor,
-                  version,
-                  "GNU Classpath",
-                  "GNU",
-                  Configuration.CLASSPATH_VERSION,
-                  null,
-                  null);
-
-            definedPackages.put(packages[i], p);
-          }
-      }
-  }
-
-  
-  /**
-   * Helper to define a class using a string of bytes. This assumes that
-   * the security checks have already been performed, if necessary.
-   *
-   * Implementations of this method are advised to consider the
-   * situation where user code modifies the byte array after it has
-   * been passed to defineClass.  This can be handled by making a
-   * private copy of the array, or arranging to only read any given
-   * byte a single time.
-   *
-   * @param name the name to give the class, or null if unknown
-   * @param data the data representing the classfile, in classfile format
-   * @param offset the offset into the data where the classfile starts
-   * @param len the length of the classfile data in the array
-   * @param pd the protection domain
-   * @return the class that was defined
-   * @throws ClassFormatError if data is not in proper classfile format
-   */
-  static final native Class defineClass(ClassLoader cl, String name,
-                                 byte[] data, int offset, int len,
-                                 ProtectionDomain pd)
-    throws ClassFormatError;
-
-  /**
-   * Helper to resolve all references to other classes from this class.
-   *
-   * @param c the class to resolve
-   */
-  static final native void resolveClass(Class c);
-
-  /**
-   * Helper to load a class from the bootstrap class loader.
-   *
-   * @param name the class name to load
-   * @param resolve whether to resolve it
-   * @return the class, loaded by the bootstrap classloader or null
-   * if the class wasn't found. Returning null is equivalent to throwing
-   * a ClassNotFoundException (but a possible performance optimization).
-   */
-  static final native Class loadClass(String name, boolean resolve)
-    throws ClassNotFoundException;
-
-  /**
-   * Helper to load a resource from the bootstrap class loader.
-   *
-   * @param name the resource to find
-   * @return the URL to the resource
-   */
-  static URL getResource(String name)
-  {
-    Enumeration e = getResources(name);
-    if (e.hasMoreElements())
-      return (URL)e.nextElement();
-    return null;
-  }
-  /**
-   * Helper to get a list of resources from the bootstrap class loader.
-   *
-   * @param name the resource to find
-   * @return an enumeration of resources
-   */
-  static Enumeration getResources(String name)
-  {
-//     StringTokenizer st = new StringTokenizer(
-//       SystemProperties.getProperty("java.boot.class.path", "."),
-//       File.pathSeparator);
-//     Vector v = new Vector();
-//     while (st.hasMoreTokens())
-//       {
-//     File file = new File(st.nextToken());
-//     if (file.isDirectory())
-//       {
-//         try
-//           {
-//                 File f = new File(file, name);
-//                 if (!f.exists()) continue;
-//                 v.add(new URL("file://" + f.getAbsolutePath()));
-//           }
-//         catch (MalformedURLException e)
-//           {
-//             throw new Error(e);
-//           }
-//       }
-//     else if (file.isFile())
-//       {
-//         ZipFile zip;
-//             synchronized(bootjars)
-//               {
-//                 zip = (ZipFile) bootjars.get(file.getName());
-//               }
-//             if(zip == null)
-//               {
-//                 try
-//               {
-//                     zip = new ZipFile(file);
-//                     synchronized(bootjars)
-//                       {
-//                         bootjars.put(file.getName(), zip);
-//                       }
-//               }
-//             catch (IOException e)
-//               {
-//                 continue;
-//               }
-//               }
-//         String zname = name.startsWith("/") ? name.substring(1) : name;
-//         if (zip.getEntry(zname) == null)
-//           continue;
-//         try
-//           {
-//             v.add(new URL("jar:file://"
-//               + file.getAbsolutePath() + "!/" + zname));
-//           }
-//         catch (MalformedURLException e)
-//           {
-//             throw new Error(e);
-//           }
-//       }
-//       }
-//     return v.elements();
-//   }
-    Vector urls = nativeGetResources(name);
-    Vector v = new Vector();
-    for (Enumeration en = urls.elements(); en.hasMoreElements();)
-      {
-       try
-         {
-           v.add(new URL((String) en.nextElement()));
-         }
-       catch (MalformedURLException e)
-         {
-           throw new Error(e);
-         }
-      }
-    return v.elements();
-  }
-
-  private native static final Vector nativeGetResources(String name);
-
-
-  /**
-   * Returns a String[] of native package names. The default
-   * implementation tries to load a list of package from
-   * the META-INF/INDEX.LIST file in the boot jar file.
-   * If not found or if any exception is raised, it returns
-   * an empty array. You may decide this needs native help.
-   */
-  private static String[] getBootPackages()
-  {
-    try
-      {
-        Enumeration indexListEnumeration = getResources("META-INF/INDEX.LIST");
-        Set packageSet = new HashSet();
-
-        while (indexListEnumeration.hasMoreElements())
-          {
-            try
-              {
-                String line;
-                int lineToSkip = 3;
-                BufferedReader reader = new BufferedReader(
-                                                           new InputStreamReader(
-                                                                                 ((URL) indexListEnumeration.nextElement()).openStream()));
-                while ((line = reader.readLine()) != null)
-                  {
-                    if (lineToSkip == 0)
-                      {
-                        if (line.length() == 0)
-                          lineToSkip = 1;
-                        else
-                          packageSet.add(line.replace('/', '.'));
-                      }
-                    else
-                      lineToSkip--;
-                  }
-                reader.close();
-              }
-            catch (IOException e)
-              {
-                // Empty catch block on purpose
-              }
-          }
-        return (String[]) packageSet.toArray(new String[packageSet.size()]);
-      }
-    catch (Exception e)
-      {
-        return new String[0];
-      }
-  }
-
-
-  /**
-   * Helper to get a package from the bootstrap class loader.
-   *
-   * @param name the name to find
-   * @return the named package, if it exists
-   */
-  static Package getPackage(String name)
-  {
-    return (Package)definedPackages.get(name);
-  }
-
-
-  
-  /**
-   * Helper to get all packages from the bootstrap class loader.  
-   *
-   * @return all named packages, if any exist
-   */
-  static Package[] getPackages()
-  {
-    Package[] packages = new Package[definedPackages.size()];
-    definedPackages.values().toArray(packages);
-    return packages;
-  }
-
-  /**
-   * Helper for java.lang.Integer, Byte, etc to get the TYPE class
-   * at initialization time. The type code is one of the chars that
-   * represents the primitive type as in JNI.
-   *
-   * <ul>
-   * <li>'Z' - boolean</li>
-   * <li>'B' - byte</li>
-   * <li>'C' - char</li>
-   * <li>'D' - double</li>
-   * <li>'F' - float</li>
-   * <li>'I' - int</li>
-   * <li>'J' - long</li>
-   * <li>'S' - short</li>
-   * <li>'V' - void</li>
-   * </ul>
-   *
-   * @param type the primitive type
-   * @return a "bogus" class representing the primitive type
-   */
-  static final native Class getPrimitiveClass(char type);
-
-  /**
-   * The system default for assertion status. This is used for all system
-   * classes (those with a null ClassLoader), as well as the initial value for
-   * every ClassLoader's default assertion status.
-   *
-   * XXX - Not implemented yet; this requires native help.
-   *
-   * @return the system-wide default assertion status
-   */
-//   static final boolean defaultAssertionStatus()
-//   {
-//     return true;
-//   }
-  static native final boolean defaultAssertionStatus();
-
-  /**
-   * The system default for package assertion status. This is used for all
-   * ClassLoader's packageAssertionStatus defaults. It must be a map of
-   * package names to Boolean.TRUE or Boolean.FALSE, with the unnamed package
-   * represented as a null key.
-   *
-   * XXX - Not implemented yet; this requires native help.
-   *
-   * @return a (read-only) map for the default packageAssertionStatus
-   */
-  static final Map packageAssertionStatus()
-  {
-    return new HashMap();
-  }
-
-  /**
-   * The system default for class assertion status. This is used for all
-   * ClassLoader's classAssertionStatus defaults. It must be a map of
-   * class names to Boolean.TRUE or Boolean.FALSE
-   *
-   * XXX - Not implemented yet; this requires native help.
-   *
-   * @return a (read-only) map for the default classAssertionStatus
-   */
-  static final Map classAssertionStatus()
-  {
-    return new HashMap();
-  }
-
-  static ClassLoader getSystemClassLoader()
-  {
-    return ClassLoader.defaultGetSystemClassLoader();
-  }
-
-  /**
-   * Find the class if this class loader previously defined this class
-   * or if this class loader has been recorded as the initiating class loader
-   * for this class.
-   */
-  static native Class findLoadedClass(ClassLoader cl, String name);
-
-  /**
-   * The Instrumentation object created by the vm when agents are defined.
-   */
-  static final Instrumentation instrumenter = null;
-
-  /**
-   * Call the transformers of the possible Instrumentation object. This
-   * implementation assumes the instrumenter is a
-   * <code>InstrumentationImpl</code> object. VM implementors would
-   * have to redefine this method if they provide their own implementation
-   * of the <code>Instrumentation</code> interface.
-   *
-   * @param loader the initiating loader
-   * @param name the name of the class
-   * @param data the data representing the classfile, in classfile format
-   * @param offset the offset into the data where the classfile starts
-   * @param len the length of the classfile data in the array
-   * @param pd the protection domain
-   * @return the new data representing the classfile
-   */
-  static final Class defineClassWithTransformers(ClassLoader loader,
-      String name, byte[] data, int offset, int len, ProtectionDomain pd)
-  {
-    
-    if (instrumenter != null)
-      {
-        byte[] modifiedData = new byte[len];
-        System.arraycopy(data, offset, modifiedData, 0, len);
-        modifiedData =
-          ((InstrumentationImpl)instrumenter).callTransformers(loader, name,
-            null, pd, modifiedData);
-        
-        return defineClass(loader, name, modifiedData, 0, modifiedData.length,
-            pd);
-      }
-    else
-      {
-        return defineClass(loader, name, data, offset, len, pd);
-      }
-  }
-}
diff --git a/src/lib/vm/reference/java/lang/VMString.java b/src/lib/vm/reference/java/lang/VMString.java
deleted file mode 100644 (file)
index 57e4423..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* VMString.java -- VM Specific String methods
-   Copyright (C) 2003 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-/*
- * This class is a reference version, mainly for compiling a class library
- * jar.  It is likely that VM implementers replace this with their own
- * version that can communicate effectively with the VM.
- */
-
-/**
- * Code relocated from java.lang.String by 
- * @author Dave Grove <groved@us.ibm.com>
- */
-final class VMString
-{
-
-  /**
-   * Holds the references for each intern()'d String. If all references to
-   * the string disappear, and the VM properly supports weak references,
-   * the String will be GC'd.
-   */
-//    private static final WeakHashMap internTable = new WeakHashMap();
-
-  /**
-   * Fetches this String from the intern hashtable. If two Strings are
-   * considered equal, by the equals() method, then intern() will return the
-   * same String instance. ie. if (s1.equals(s2)) then
-   * (s1.intern() == s2.intern()). All string literals and string-valued
-   * constant expressions are already interned.
-   *
-   * @param str the String to intern
-   * @return the interned String
-   */
-//    static String intern(String str)
-//    {
-//      synchronized (internTable)
-//        {
-//          WeakReference ref = (WeakReference) internTable.get(str);
-//          if (ref != null)
-//            {
-//              String s = (String) ref.get();
-//              // If s is null, then no strong references exist to the String;
-//              // the weak hash map will soon delete the key.
-//              if (s != null)
-//                return s;
-//            }
-//          internTable.put(str, new WeakReference(str));
-//        }
-//      return str;
-//    }
-
-  /**
-   * this one is native in CACAO
-   */
-  static native String intern(String str);
-
-} // class VMString
diff --git a/src/lib/vm/reference/java/lang/VMThread.java b/src/lib/vm/reference/java/lang/VMThread.java
deleted file mode 100644 (file)
index a511f3c..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/* VMThread -- VM interface for Thread of executable code
-   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-/**
- * VM interface for Thread of executable code. Holds VM dependent state.
- * It is deliberately package local and final and should only be accessed
- * by the Thread class.
- * <p>
- * This is the GNU Classpath reference implementation, it should be adapted
- * for a specific VM.
- * <p>
- * The following methods must be implemented:
- * <ul>
- * <li>native void start(long stacksize);
- * <li>native void interrupt();
- * <li>native boolean isInterrupted();
- * <li>native void suspend();
- * <li>native void resume();
- * <li>native void nativeSetPriority(int priority);
- * <li>native void nativeStop(Throwable t);
- * <li>native static Thread currentThread();
- * <li>static native void yield();
- * <li>static native boolean interrupted();
- * </ul>
- * All other methods may be implemented to make Thread handling more efficient
- * or to implement some optional (and sometimes deprecated) behaviour. Default
- * implementations are provided but it is highly recommended to optimize them
- * for a specific VM.
- * 
- * @author Jeroen Frijters (jeroen@frijters.net)
- * @author Dalibor Topic (robilad@kaffe.org)
- */
-final class VMThread
-{
-    /**
-     * The Thread object that this VM state belongs to.
-     * Used in currentThread() and start().
-     * Note: when this thread dies, this reference is *not* cleared
-     */
-    volatile Thread thread;
-
-    /**
-     * Flag that is set when the thread runs, used by stop() to protect against
-     * stop's getting lost.
-     */
-    private volatile boolean running;
-
-    /**
-     * VM private data.
-     */
-    private transient Object vmdata;
-
-    /**
-     * Private constructor, create VMThreads with the static create method.
-     *
-     * @param thread The Thread object that was just created.
-     */
-    private VMThread(Thread thread)
-    {
-       this.thread = thread;
-    }
-
-    /**
-     * This method is the initial Java code that gets executed when a native
-     * thread starts. It's job is to coordinate with the rest of the VMThread
-     * logic and to start executing user code and afterwards handle clean up.
-     */
-    private void run()
-    {
-       try
-       {
-           try
-           {
-               running = true;
-               synchronized(thread)
-               {
-                   Throwable t = thread.stillborn;
-                   if(t != null)
-                   {
-                       thread.stillborn = null;
-                       throw t;
-                   }
-               }
-               thread.run();
-           }
-           catch(Throwable t)
-           {
-               try
-               {
-                 Thread.UncaughtExceptionHandler handler;
-                 handler = thread.getUncaughtExceptionHandler();
-                 handler.uncaughtException(thread, t);
-               }
-               catch(Throwable ignore)
-               {
-               }
-           }
-       }
-       finally
-       {
-           // Setting runnable to false is partial protection against stop
-           // being called while we're cleaning up. To be safe all code in
-           // VMThread be unstoppable.
-           running = false;
-           thread.die();
-           synchronized(this)
-           {
-               // release the threads waiting to join us
-               notifyAll();
-           }
-       }
-    }
-
-    /**
-     * Creates a native Thread. This is called from the start method of Thread.
-     * The Thread is started.
-     *
-     * @param thread The newly created Thread object
-     * @param stacksize Indicates the requested stacksize. Normally zero,
-     * non-zero values indicate requested stack size in bytes but it is up
-     * to the specific VM implementation to interpret them and may be ignored.
-     */
-    static void create(Thread thread, long stacksize)
-    {
-       VMThread vmThread = new VMThread(thread);
-       thread.vmThread = vmThread;
-       vmThread.start(stacksize);
-    }
-
-    /**
-     * Gets the name of the thread. Usually this is the name field of the
-     * associated Thread object, but some implementation might choose to
-     * return the name of the underlying platform thread.
-     */
-    String getName()
-    {
-       return thread.name;
-    }
-
-    /**
-     * Set the name of the thread. Usually this sets the name field of the
-     * associated Thread object, but some implementations might choose to
-     * set the name of the underlying platform thread.
-     * @param name The new name
-     */
-    void setName(String name)
-    {
-       thread.name = name;
-    }
-
-    /**
-     * Set the thread priority field in the associated Thread object and
-     * calls the native method to set the priority of the underlying
-     * platform thread.
-     * @param priority The new priority
-     */
-    void setPriority(int priority)
-    {
-       thread.priority = priority;
-       nativeSetPriority(priority);
-    }
-
-    /**
-     * Returns the priority. Usually this is the priority field from the
-     * associated Thread object, but some implementation might choose to
-     * return the priority of the underlying platform thread.
-     * @return this Thread's priority
-     */
-    int getPriority()
-    {
-        return thread.priority;
-    }
-
-    /**
-     * Returns true if the thread is a daemon thread. Usually this is the
-     * daemon field from the associated Thread object, but some
-     * implementation might choose to return the daemon state of the underlying
-     * platform thread.
-     * @return whether this is a daemon Thread or not
-     */
-    boolean isDaemon()
-    {
-        return thread.daemon;
-    }
-
-    /**
-     * Returns the number of stack frames in this Thread.
-     * Will only be called when when a previous call to suspend() returned true.
-     *
-     * @deprecated unsafe operation
-     */
-    native int countStackFrames();
-
-    /**
-     * Wait the specified amount of time for the Thread in question to die.
-     *
-     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-     * not offer that fine a grain of timing resolution. Besides, there is
-     * no guarantee that this thread can start up immediately when time expires,
-     * because some other thread may be active.  So don't expect real-time
-     * performance.
-     *
-     * @param ms the number of milliseconds to wait, or 0 for forever
-     * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is interrupted; it's
-     *         <i>interrupted status</i> will be cleared
-     */
-    synchronized void join(long ms, int ns) throws InterruptedException
-    {
-       // Round up
-       ms += (ns != 0) ? 1 : 0;
-
-       // 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.
-       while(thread.vmThread != null)
-       {
-           // We use the VMThread object to wait on, because this is a private
-           // object, so client code cannot call notify on us.
-           wait(ms);
-           if(ms != 0)
-           {
-               now = System.currentTimeMillis();
-               ms = end - now;
-               if(ms <= 0)
-               {
-                   break;
-               }
-           }
-       }
-    }
-
-    /**
-     * Cause this Thread to stop abnormally and throw the specified exception.
-     * If you stop a Thread that has not yet started, the stop is ignored
-     * (contrary to what the JDK documentation says).
-     * <b>WARNING</b>This bypasses Java security, and can throw a checked
-     * exception which the call stack is unprepared to handle. Do not abuse 
-     * this power.
-     *
-     * <p>This is inherently unsafe, as it can interrupt synchronized blocks and
-     * leave data in bad states.
-     *
-     * <p><b>NOTE</b> stop() should take care not to stop a thread if it is
-     * executing code in this class.
-     *
-     * @param t the Throwable to throw when the Thread dies
-     * @deprecated unsafe operation, try not to use
-     */
-    void stop(Throwable t)
-    {
-       // Note: we assume that we own the lock on thread
-       // (i.e. that Thread.stop() is synchronized)
-       if(running)
-           nativeStop(t);
-       else
-           thread.stillborn = t;
-    }
-
-    /**
-     * Create a native thread on the underlying platform and start it executing
-     * on the run method of this object.
-     * @param stacksize the requested size of the native thread stack
-     */
-    native void start(long stacksize);
-
-    /**
-     * Interrupt this thread.
-     */
-    native void interrupt();
-
-    /**
-     * Determine whether this Thread has been interrupted, but leave
-     * the <i>interrupted status</i> alone in the process.
-     *
-     * @return whether the Thread has been interrupted
-     */
-    native boolean isInterrupted();
-
-    /**
-     * Suspend this Thread.  It will not come back, ever, unless it is resumed.
-     */
-    native void suspend();
-
-    /**
-     * Resume this Thread.  If the thread is not suspended, this method does
-     * nothing.
-     */
-    native void resume();
-
-    /**
-     * Set the priority of the underlying platform thread.
-     *
-     * @param priority the new priority
-     */
-    native void nativeSetPriority(int priority);
-
-    /**
-     * Asynchronously throw the specified throwable in this Thread.
-     *
-     * @param t the exception to throw
-     */
-    native void nativeStop(Throwable t);
-
-    /**
-     * Return the Thread object associated with the currently executing
-     * thread.
-     *
-     * @return the currently executing Thread
-     */
-    static native Thread currentThread();
-
-    /**
-     * Yield to another thread. The Thread will not lose any locks it holds
-     * during this time. There are no guarantees which thread will be
-     * next to run, and it could even be this one, but most VMs will choose
-     * the highest priority thread that has been waiting longest.
-     */
-    static native void yield();
-
-    /**
-     * Suspend the current Thread's execution for the specified amount of
-     * time. The Thread will not lose any locks it has during this time. There
-     * are no guarantees which thread will be next to run, but most VMs will
-     * choose the highest priority thread that has been waiting longest.
-     *
-     * <p>Note that 1,000,000 nanoseconds == 1 millisecond, but most VMs do
-     * not offer that fine a grain of timing resolution. Besides, there is
-     * no guarantee that this thread can start up immediately when time expires,
-     * because some other thread may be active.  So don't expect real-time
-     * performance.
-     *
-     * @param ms the number of milliseconds to sleep.
-     * @param ns the number of extra nanoseconds to sleep (0-999999)
-     * @throws InterruptedException if the Thread is (or was) interrupted;
-     *         it's <i>interrupted status</i> 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;
-       }
-
-      // 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;
-           }
-       }
-    }
-
-    /**
-     * Determine whether the current Thread has been interrupted, and clear
-     * the <i>interrupted status</i> in the process.
-     *
-     * @return whether the current Thread has been interrupted
-     */
-    static native boolean interrupted();
-
-    /**
-     * Checks whether the current thread holds the monitor on a given object.
-     * This allows you to do <code>assert Thread.holdsLock(obj)</code>.
-     *
-     * @param obj the object to check
-     * @return true if the current thread is currently synchronized on obj
-     * @throws NullPointerException if obj is null
-     */
-//     static boolean holdsLock(Object obj) 
-//     {
-//       /* Use obj.notify to check if the current thread holds
-//        * the monitor of the object.
-//        * If it doesn't, notify will throw an exception.
-//        */
-//       try 
-//     {
-//       obj.notify();
-//       // okay, current thread holds lock
-//       return true;
-//     }
-//       catch (IllegalMonitorStateException e)
-//     {
-//       // it doesn't hold the lock
-//       return false;
-//     }
-//     }
-    static native boolean holdsLock(Object obj);
-
-  /**
-   * Returns the current state of the thread.
-   * The value must be one of "BLOCKED", "NEW",
-   * "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
-   * "WAITING".
-   *
-   * @return a string corresponding to one of the 
-   *         thread enumeration states specified above.
-   */
-  native String getState();
-
-}
diff --git a/src/lib/vm/reference/java/lang/VMThrowable.java b/src/lib/vm/reference/java/lang/VMThrowable.java
deleted file mode 100644 (file)
index d44c192..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* java.lang.VMThrowable -- VM support methods for Throwable.
-   Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-package java.lang;
-
-import gnu.classpath.Pointer;
-
-/**
- * VM dependant state and support methods for Throwable.
- * It is deliberately package local and final and should only be accessed
- * by the Throwable class.
- * <p>
- * This is the GNU Classpath reference implementation, it should be adapted
- * for a specific VM. The reference implementation does nothing.
- *
- * @author Mark Wielaard (mark@klomp.org)
- */
-final class VMThrowable
-{
-  /* IMPORTANT: the rawdata field is not a java object */
-  private final Pointer vmData;
-
-  /**
-   * VM private data.
-   */
-  private transient Object vmdata;
-
-  /**
-   * Private contructor, create VMThrowables with fillInStackTrace();
-   */
-//    private VMThrowable() { }
-  private VMThrowable()
-  {
-    vmData = null;
-  }
-
-  /**
-   * Fill in the stack trace with the current execution stack.
-   * Called by <code>Throwable.fillInStackTrace()</code> to get the state of
-   * the VM. Can return null when the VM does not support caputing the VM
-   * execution state.
-   *
-   * @return a new VMThrowable containing the current execution stack trace.
-   * @see Throwable#fillInStackTrace()
-   */
-  static native VMThrowable fillInStackTrace(Throwable t);
-
-  /**
-   * Returns an <code>StackTraceElement</code> array based on the execution
-   * state of the VM as captured by <code>fillInStackTrace</code>.
-   * Called by <code>Throwable.getStackTrace()</code>.
-   *
-   * @return a non-null but possible zero length array of StackTraceElement.
-   * @see Throwable#getStackTrace()
-   */
-  native StackTraceElement[] getStackTrace(Throwable t);
-}
diff --git a/src/lib/vm/reference/java/security/VMAccessController.java b/src/lib/vm/reference/java/security/VMAccessController.java
deleted file mode 100644 (file)
index 160df10..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/* VMAccessController.java -- VM-specific access controller methods.
-   Copyright (C) 2004, 2005  Free Software Foundation, Inc.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package java.security;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-
-final class VMAccessController
-{
-
-  // Fields.
-  // -------------------------------------------------------------------------
-
-  /**
-   * This is a per-thread stack of AccessControlContext objects (which can
-   * be null) for each call to AccessController.doPrivileged in each thread's
-   * call stack. We use this to remember which context object corresponds to
-   * which call.
-   */
-  private static final ThreadLocal contexts = new ThreadLocal();
-
-  /**
-   * This is a Boolean that, if set, tells getContext that it has already
-   * been called once, allowing us to handle recursive permission checks
-   * caused by methods getContext calls.
-   */
-  private static final ThreadLocal inGetContext = new ThreadLocal();
-
-  /**
-   * And we return this all-permissive context to ensure that privileged
-   * methods called from getContext succeed.
-   */
-  private static final AccessControlContext DEFAULT_CONTEXT;
-  static
-  {
-    CodeSource source = new CodeSource(null, null);
-    Permissions permissions = new Permissions();
-    permissions.add(new AllPermission());
-    ProtectionDomain[] domain = new ProtectionDomain[] {
-      new ProtectionDomain(source, permissions)
-    };
-    DEFAULT_CONTEXT = new AccessControlContext(domain);
-  }
-
-  private static final boolean DEBUG = gnu.classpath.Configuration.DEBUG;
-  private static void debug(String msg)
-  {
-    System.err.print(">>> VMAccessController: ");
-    System.err.println(msg);
-  }
-
-  // Constructors.
-  // -------------------------------------------------------------------------
-
-  private VMAccessController() { }
-
-  // Class methods.
-  // -------------------------------------------------------------------------
-
-  /**
-   * Relate a class (which should be an instance of {@link PrivilegedAction}
-   * with an access control context. This method is used by {@link
-   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}
-   * to set up the context that will be returned by {@link #getContext()}.
-   * This method relates the class to the current thread, so contexts
-   * pushed from one thread will not be available to another.
-   *
-   * @param acc The access control context.
-   */
-  static void pushContext (AccessControlContext acc)
-  {
-    if (DEBUG)
-      debug("pushing " + acc);
-    LinkedList stack = (LinkedList) contexts.get();
-    if (stack == null)
-      {
-         if (DEBUG)
-           debug("no stack... creating ");
-        stack = new LinkedList();
-        contexts.set(stack);
-      }
-    stack.addFirst(acc);
-  }
-
-  /**
-   * Removes the relation of a class to an {@link AccessControlContext}.
-   * This method is used by {@link AccessController} when exiting from a
-   * call to {@link
-   * AccessController#doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)}.
-   */
-  static void popContext()
-  {
-    if (DEBUG)
-      debug("popping context");
-
-    // Stack should never be null, nor should it be empty, if this method
-    // and its counterpart has been called properly.
-    LinkedList stack = (LinkedList) contexts.get();
-    if (stack != null)
-      {
-        stack.removeFirst();
-        if (stack.isEmpty())
-          contexts.set(null);
-      }
-    else if (DEBUG)
-      {
-        debug("no stack during pop?????");
-      }
-  }
-
-  /**
-   * Examine the method stack of the currently running thread, and create
-   * an {@link AccessControlContext} filled in with the appropriate {@link
-   * ProtectionDomain} objects given this stack.
-   *
-   * @return The context.
-   */
-  static AccessControlContext getContext()
-  {
-    // If we are already in getContext, but called a method that needs
-    // a permission check, return the all-permissive context so methods
-    // called from here succeed.
-    //
-    // XXX is this necessary? We should verify if there are any calls in
-    // the stack below this method that require permission checks.
-    Boolean inCall = (Boolean) inGetContext.get();
-    if (inCall != null && inCall.booleanValue())
-      {
-        if (DEBUG)
-          debug("already in getContext");
-        return DEFAULT_CONTEXT;
-      }
-
-    inGetContext.set(Boolean.TRUE);
-
-    Object[][] stack = getStack();
-    Class[] classes = (Class[]) stack[0];
-    String[] methods = (String[]) stack[1];
-
-    if (DEBUG)
-      debug("got trace of length " + classes.length);
-
-    HashSet domains = new HashSet();
-    HashSet seenDomains = new HashSet();
-    AccessControlContext context = null;
-    int privileged = 0;
-
-    // We walk down the stack, adding each ProtectionDomain for each
-    // class in the call stack. If we reach a call to doPrivileged,
-    // we don't add any more stack frames. We skip the first three stack
-    // frames, since they comprise the calls to getStack, getContext,
-    // and AccessController.getContext.
-    for (int i = 3; i < classes.length && privileged < 2; i++)
-      {
-        Class clazz = classes[i];
-        String method = methods[i];
-
-        if (DEBUG)
-          {
-            debug("checking " + clazz + "." + method);
-            // subject to getClassLoader RuntimePermission
-            debug("loader = " + clazz.getClassLoader());
-          }
-
-        // If the previous frame was a call to doPrivileged, then this is
-        // the last frame we look at.
-        if (privileged == 1)
-          privileged = 2;
-
-        if (clazz.equals (AccessController.class)
-            && method.equals ("doPrivileged"))
-          {
-            // If there was a call to doPrivileged with a supplied context,
-            // return that context. If using JAAS doAs*, it should be 
-           // a context with a SubjectDomainCombiner
-            LinkedList l = (LinkedList) contexts.get();
-            if (l != null)
-              context = (AccessControlContext) l.getFirst();
-            privileged = 1;
-          }
-
-        // subject to getProtectionDomain RuntimePermission
-       ProtectionDomain domain = clazz.getProtectionDomain();
-
-        if (domain == null)
-          continue;
-        if (seenDomains.contains(domain))
-          continue;
-        seenDomains.add(domain);
-
-        // Create a static snapshot of this domain, which may change over time
-        // if the current policy changes.
-        domains.add(new ProtectionDomain(domain.getCodeSource(),
-                                         domain.getPermissions()));
-      }
-
-    if (DEBUG)
-      debug("created domains: " + domains);
-
-    ProtectionDomain[] result = (ProtectionDomain[])
-      domains.toArray(new ProtectionDomain[domains.size()]);
-
-    if (context != null)
-      {
-        DomainCombiner dc = context.getDomainCombiner ();
-        // If the supplied context had no explicit DomainCombiner, use
-        // our private version, which computes the intersection of the
-        // context's domains with the derived set.
-        if (dc == null)
-          context = new AccessControlContext
-            (IntersectingDomainCombiner.SINGLETON.combine
-             (result, context.getProtectionDomains ()));
-        // Use the supplied DomainCombiner. This should be secure,
-        // because only trusted code may create an
-        // AccessControlContext with a custom DomainCombiner.
-        else
-          context = new AccessControlContext (result, context, dc);
-      }
-    // No context was supplied. Return the derived one.
-    else
-      context = new AccessControlContext (result);
-
-    inGetContext.set(Boolean.FALSE);
-    return context;
-  }
-
-  /**
-   * Returns a snapshot of the current call stack as a pair of arrays:
-   * the first an array of classes in the call stack, the second an array
-   * of strings containing the method names in the call stack. The two
-   * arrays match up, meaning that method <i>i</i> is declared in class
-   * <i>i</i>. The arrays are clean; it will only contain Java methods,
-   * and no element of the list should be null.
-   *
-   * <p>The default implementation returns an empty stack, which will be
-   * interpreted as having no permissions whatsoever.
-   *
-   * @return A pair of arrays describing the current call stack. The first
-   *    element is an array of Class objects, and the second is an array
-   *    of Strings comprising the method names.
-   */
-//    private static Object[][] getStack()
-//    {
-//      return new Object[][] { new Class[0], new String[0] };
-//    }
-  private native static Object[][] getStack();
-}
diff --git a/src/mm/.cvsignore b/src/mm/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/mm/boehm-gc/.cvsignore b/src/mm/boehm-gc/.cvsignore
deleted file mode 100644 (file)
index fd351f5..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-aclocal.m4
-autom4te.cache
-config.guess
-config.log
-config.status
-config.sub
-configure
-depcomp
-install-sh
-libtool
-ltmain.sh
-missing
diff --git a/src/mm/boehm-gc/doc/.cvsignore b/src/mm/boehm-gc/doc/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/src/mm/boehm-gc/include/.cvsignore b/src/mm/boehm-gc/include/.cvsignore
deleted file mode 100644 (file)
index 2c36f43..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-Makefile
-Makefile.in
-TAGS
-config.h
-config.h.in
-stamp-h1
index d31e041f60199d20e975217a66fc1c67b038e038..b80b568ba4f6953f738e3770ba83e98184d7e82a 100644 (file)
@@ -481,7 +481,7 @@ GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
 # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
      && !defined(__ia64__)
 #   ifndef GC_HAVE_BUILTIN_BACKTRACE
-#     define GC_HAVE_BUILTIN_BACKTRACE
+/* #     define GC_HAVE_BUILTIN_BACKTRACE */
 #   endif
 # endif
 # if defined(__i386__) || defined(__x86_64__)
diff --git a/src/mm/cacao-gc/.cvsignore b/src/mm/cacao-gc/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 7d68fef5a90a9d0154f0b501dd6ea903d2612e0a..481afd66868d5fa41b7f892a92c06d5060d71096 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: memory.c 7394 2007-02-23 22:47:06Z michi $
+   $Id: memory.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #include "arch.h"
 
 #include "mm/memory.h"
-#include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/threads-common.h"
+#include "native/native.h"
 
-# include "threads/native/lock.h"
-# include "threads/native/threads.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "toolbox/logging.h"
+
 #include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
+
 #include "vmcore/options.h"
 
 #if defined(ENABLE_STATISTICS)
@@ -101,13 +98,6 @@ static int                code_memory_size = 0;
 static int                pagesize         = 0;
 
 
-/* global variables ***********************************************************/
-
-#if defined(ENABLE_THREADS)
-static threadobject *thread_memory;
-#endif
-
-
 /* memory_init *****************************************************************
 
    Initialize the memory subsystem.
@@ -379,6 +369,10 @@ static void memory_thread(void)
                threads_sleep(2 * 1000, 0);
 
 # if defined(ENABLE_STATISTICS)
+               /* print current date and time */
+
+               statistics_print_date();
+
                /* print memory usage */
 
                statistics_print_memory_usage();
@@ -405,15 +399,11 @@ bool memory_start_thread(void)
 
        name = utf_new_char("Memory Profiler");
 
-       thread_memory = threads_create_thread(name);
+       /* start the memory profiling thread */
 
-       if (thread_memory == NULL)
+       if (!threads_thread_start_internal(name, memory_thread))
                return false;
 
-       /* actually start the memory profiling thread */
-
-       threads_start_thread(thread_memory, memory_thread);
-
        /* everything's ok */
 
        return true;
index 26f6d8479cfbecb713909757dbacd96982ef7d83..102b288453f553e07f4bc5242ee54a919ea5c4c8 100644 (file)
@@ -1,6 +1,6 @@
 /* src/mm/memory.h - macros for memory management
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-
-   Changes: Christian Thalinger
-
-   $Id: memory.h 7615 2007-03-29 23:10:59Z michi $
+   $Id: memory.h 7918 2007-05-20 20:42:18Z michi $
 
 */
 
diff --git a/src/native/.cvsignore b/src/native/.cvsignore
deleted file mode 100644 (file)
index dc74521..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-nativetable.inc
diff --git a/src/native/include/.cvsignore b/src/native/include/.cvsignore
deleted file mode 100644 (file)
index f30a44f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-*.h
-Makefile
-Makefile.in
-TAGS
index a011a0f0fe38b729ba56b189f2ebd184a4a47fab..3e2bae07ba3fc26bd8aa12ebda2a36dfed31a904 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jni.c 7723 2007-04-16 18:03:08Z michi $
+   $Id: jni.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 # include "native/vm/java_lang_ClassLoader.h"
 #endif
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-# include "threads/native/threads.h"
-#else
-# include "threads/none/lock.h"
-# include "threads/none/threads.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "toolbox/logging.h"
 
diff --git a/src/native/jvmti/.cvsignore b/src/native/jvmti/.cvsignore
deleted file mode 100644 (file)
index 9e7def3..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-cacaodbgserver
index 7c28b22b6c7efb8b9fd2085402274e10b9f358d1..f3ff12994111b0eae970b1c31eba996113485b5b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: native.c 7674 2007-04-05 13:27:11Z michi $
+   $Id: native.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
 #include "native/jni.h"
 #include "native/native.h"
-#include "native/include/java_lang_String.h"
-#include "native/include/java_lang_Throwable.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "native/vm/nativevm.h"
+
+#include "threads/lock-common.h"
 
+#include "toolbox/avl.h"
 #include "toolbox/hashtable.h"
 #include "toolbox/logging.h"
 
 
 /* include table of native functions ******************************************/
 
-#if defined(ENABLE_JAVASE)
-
-#include "native/include/java_io_InputStream.h"
-#include "native/include/java_io_PrintStream.h"
-
-#include "native/include/java_lang_Cloneable.h"
-#include "native/include/java_util_Properties.h"
-
-#include "native/include/java_lang_Object.h"
-
-#include "native/include/gnu_classpath_VMStackWalker.h"
-#include "native/include/gnu_classpath_VMSystemProperties.h"
-#include "native/include/gnu_java_lang_management_VMClassLoadingMXBeanImpl.h"
-#include "native/include/gnu_java_lang_management_VMMemoryMXBeanImpl.h"
-#include "native/include/gnu_java_lang_management_VMRuntimeMXBeanImpl.h"
-#include "native/include/java_lang_VMClass.h"
-#include "native/include/java_security_ProtectionDomain.h"  /* required by... */
-#include "native/include/java_lang_VMClassLoader.h"
-#include "native/include/java_lang_VMObject.h"
-#include "native/include/java_lang_VMRuntime.h"
-#include "native/include/java_lang_VMString.h"
-#include "native/include/java_lang_VMSystem.h"
-#include "native/include/java_lang_VMThread.h"
-#include "native/include/java_lang_VMThrowable.h"
-#include "native/include/java_lang_management_VMManagementFactory.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_lang_reflect_VMProxy.h"
-#include "native/include/java_security_VMAccessController.h"
-#include "native/include/sun_misc_Unsafe.h"
+#if defined(WITH_STATIC_CLASSPATH)
+# include "native/nativetable.inc"
+#endif
+
 
-#if defined(ENABLE_JVMTI)
-#include "native/include/gnu_classpath_jdwp_event_EventRequest.h"
-#include "native/include/java_nio_ByteBuffer.h"
-#include "native/include/gnu_classpath_jdwp_VMVirtualMachine.h"
-#include "native/include/gnu_classpath_jdwp_VMFrame.h"
-#include "native/include/gnu_classpath_jdwp_VMMethod.h"
+/* tables for methods *********************************************************/
+
+#if defined(WITH_STATIC_CLASSPATH)
+#define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
+
+/* table for fast string comparison */
+static nativecompref nativecomptable[NATIVETABLESIZE];
+
+/* string comparsion table initialized */
+static bool nativecompdone = false;
 #endif
 
-#elif defined(ENABLE_JAVAME_CLDC1_1)
 
-#include "native/include/com_sun_cldchi_io_ConsoleOutputStream.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Double.h"
-#include "native/include/java_lang_Float.h"
-#include "native/include/java_lang_Math.h"
-#include "native/include/java_lang_Runtime.h"
-#include "native/include/java_lang_System.h"
-#include "native/include/java_lang_Thread.h"
+/* global variables ***********************************************************/
+
+static avl_tree_t *tree_native_methods;
+static hashtable *hashtable_library;
+
+
+/* prototypes *****************************************************************/
+
+static s4 native_tree_native_methods_comparator(const void *treenode, const void *node);
+
+
+/* native_init *****************************************************************
+
+   Initializes the native subsystem.
+
+*******************************************************************************/
+
+bool native_init(void)
+{
+#if !defined(WITH_STATIC_CLASSPATH)
+       /* initialize libltdl */
+
+       if (lt_dlinit())
+               vm_abort("native_init: lt_dlinit failed: %s\n", lt_dlerror());
+
+       /* initialize library hashtable, 10 entries should be enough */
+
+       hashtable_library = NEW(hashtable);
 
+       hashtable_create(hashtable_library, 10);
 #endif
 
-#if defined(WITH_STATIC_CLASSPATH)
+       /* initialize the native methods table */
+
+       tree_native_methods = avl_create(&native_tree_native_methods_comparator);
 
-/* these are required to prevent compiler warnings */
+       /* register the intern native functions */
 
-#include "native/include/java_net_DatagramPacket.h"
-#include "native/include/java_net_InetAddress.h"
-#include "native/include/java_net_SocketImpl.h"
+       nativevm_init();
 
-#include "native/include/gnu_java_net_PlainDatagramSocketImpl.h"
-#include "native/include/gnu_java_net_PlainSocketImpl.h"
-#include "native/include/gnu_java_nio_PipeImpl.h"
-#include "native/include/gnu_java_nio_channels_FileChannelImpl.h"
-#include "native/include/gnu_java_nio_charset_iconv_IconvEncoder.h"
-#include "native/include/gnu_java_nio_charset_iconv_IconvDecoder.h"
-#include "native/include/java_lang_VMProcess.h"
-#include "native/include/java_nio_MappedByteBufferImpl.h"
-#include "native/include/java_nio_channels_spi_SelectorProvider.h"
+       /* everything's ok */
 
-/* now include the native table */
+       return true;
+}
 
-#include "native/nativetable.inc"
 
-#elif !defined(ENABLE_LIBJVM)
+/* native_tree_native_methods_comparator ***************************************
 
-/* dummynativetable ************************************************************
+   Comparison function for AVL tree of native methods.
 
-   Ensure that symbols for functions implemented within CACAO are used
-   and exported to dlopen.
+   IN:
+       treenode....node in the tree
+          node........node to compare with tree-node
 
-   ATTENTION: Don't make this table static!!!  Otherwise the compiler
-   may optimize it away!
+   RETURN VALUE:
+       -1, 0, +1
 
 *******************************************************************************/
 
-functionptr dummynativetable[] = {
-#if defined(ENABLE_JAVASE)
-       (functionptr) Java_gnu_classpath_VMStackWalker_getClassContext,
-       (functionptr) Java_gnu_classpath_VMStackWalker_getCallingClass,
-       (functionptr) Java_gnu_classpath_VMStackWalker_getCallingClassLoader,
-       (functionptr) Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader,
-
-       (functionptr) Java_gnu_classpath_VMSystemProperties_preInit,
-
-       (functionptr) Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount,
-       (functionptr) Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount,
-       (functionptr) Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose,
-       (functionptr) Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_setVerbose,
-
-       (functionptr) Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage,
-       (functionptr) Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage,
-       (functionptr) Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount,
-       (functionptr) Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose,
-       (functionptr) Java_gnu_java_lang_management_VMMemoryMXBeanImpl_setVerbose,
-
-       (functionptr) Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments,
-       (functionptr) Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getStartTime,
-
-       (functionptr) Java_java_lang_VMClass_isInstance,
-       (functionptr) Java_java_lang_VMClass_isAssignableFrom,
-       (functionptr) Java_java_lang_VMClass_isInterface,
-       (functionptr) Java_java_lang_VMClass_isPrimitive,
-       (functionptr) Java_java_lang_VMClass_getName,
-       (functionptr) Java_java_lang_VMClass_getSuperclass,
-       (functionptr) Java_java_lang_VMClass_getInterfaces,
-       (functionptr) Java_java_lang_VMClass_getComponentType,
-       (functionptr) Java_java_lang_VMClass_getModifiers,
-       (functionptr) Java_java_lang_VMClass_getDeclaringClass,
-       (functionptr) Java_java_lang_VMClass_getDeclaredClasses,
-       (functionptr) Java_java_lang_VMClass_getDeclaredFields,
-       (functionptr) Java_java_lang_VMClass_getDeclaredMethods,
-       (functionptr) Java_java_lang_VMClass_getDeclaredConstructors,
-       (functionptr) Java_java_lang_VMClass_getClassLoader,
-       (functionptr) Java_java_lang_VMClass_forName,
-       (functionptr) Java_java_lang_VMClass_isArray,
-       (functionptr) Java_java_lang_VMClass_throwException,
-
-       (functionptr) Java_java_lang_VMClassLoader_defineClass,
-       (functionptr) Java_java_lang_VMClassLoader_resolveClass,
-       (functionptr) Java_java_lang_VMClassLoader_loadClass,
-       (functionptr) Java_java_lang_VMClassLoader_getPrimitiveClass,
-       (functionptr) Java_java_lang_VMClassLoader_nativeGetResources,
-       (functionptr) Java_java_lang_VMClassLoader_findLoadedClass,
-
-       (functionptr) Java_java_lang_VMObject_getClass,
-       (functionptr) Java_java_lang_VMObject_clone,
-       (functionptr) Java_java_lang_VMObject_notify,
-       (functionptr) Java_java_lang_VMObject_notifyAll,
-       (functionptr) Java_java_lang_VMObject_wait,
-
-       (functionptr) Java_java_lang_VMRuntime_availableProcessors,
-       (functionptr) Java_java_lang_VMRuntime_freeMemory,
-       (functionptr) Java_java_lang_VMRuntime_totalMemory,
-       (functionptr) Java_java_lang_VMRuntime_maxMemory,
-       (functionptr) Java_java_lang_VMRuntime_gc,
-       (functionptr) Java_java_lang_VMRuntime_runFinalization,
-       (functionptr) Java_java_lang_VMRuntime_runFinalizationForExit,
-       (functionptr) Java_java_lang_VMRuntime_traceInstructions,
-       (functionptr) Java_java_lang_VMRuntime_traceMethodCalls,
-       (functionptr) Java_java_lang_VMRuntime_runFinalizersOnExit,
-       (functionptr) Java_java_lang_VMRuntime_exit,
-       (functionptr) Java_java_lang_VMRuntime_nativeLoad,
-       (functionptr) Java_java_lang_VMRuntime_mapLibraryName,
-
-       (functionptr) Java_java_lang_VMString_intern,
-
-       (functionptr) Java_java_lang_VMSystem_arraycopy,
-       (functionptr) Java_java_lang_VMSystem_identityHashCode,
-
-       (functionptr) Java_java_lang_VMThread_start,
-       (functionptr) Java_java_lang_VMThread_interrupt,
-       (functionptr) Java_java_lang_VMThread_isInterrupted,
-       (functionptr) Java_java_lang_VMThread_suspend,
-       (functionptr) Java_java_lang_VMThread_resume,
-       (functionptr) Java_java_lang_VMThread_nativeSetPriority,
-       (functionptr) Java_java_lang_VMThread_nativeStop,
-       (functionptr) Java_java_lang_VMThread_currentThread,
-       (functionptr) Java_java_lang_VMThread_yield,
-       (functionptr) Java_java_lang_VMThread_interrupted,
-       (functionptr) Java_java_lang_VMThread_holdsLock,
-       (functionptr) Java_java_lang_VMThread_getState,
-
-       (functionptr) Java_java_lang_VMThrowable_fillInStackTrace,
-       (functionptr) Java_java_lang_VMThrowable_getStackTrace,
-
-       (functionptr) Java_java_lang_management_VMManagementFactory_getMemoryPoolNames,
-       (functionptr) Java_java_lang_management_VMManagementFactory_getMemoryManagerNames,
-       (functionptr) Java_java_lang_management_VMManagementFactory_getGarbageCollectorNames,
-
-       (functionptr) Java_java_lang_reflect_Constructor_getModifiersInternal,
-       (functionptr) Java_java_lang_reflect_Constructor_constructNative,
-
-       (functionptr) Java_java_lang_reflect_Field_getModifiersInternal,
-       (functionptr) Java_java_lang_reflect_Field_getType,
-       (functionptr) Java_java_lang_reflect_Field_get,
-       (functionptr) Java_java_lang_reflect_Field_getBoolean,
-       (functionptr) Java_java_lang_reflect_Field_getByte,
-       (functionptr) Java_java_lang_reflect_Field_getChar,
-       (functionptr) Java_java_lang_reflect_Field_getShort,
-       (functionptr) Java_java_lang_reflect_Field_getInt,
-       (functionptr) Java_java_lang_reflect_Field_getLong,
-       (functionptr) Java_java_lang_reflect_Field_getFloat,
-       (functionptr) Java_java_lang_reflect_Field_getDouble,
-       (functionptr) Java_java_lang_reflect_Field_set,
-       (functionptr) Java_java_lang_reflect_Field_setBoolean,
-       (functionptr) Java_java_lang_reflect_Field_setByte,
-       (functionptr) Java_java_lang_reflect_Field_setChar,
-       (functionptr) Java_java_lang_reflect_Field_setShort,
-       (functionptr) Java_java_lang_reflect_Field_setInt,
-       (functionptr) Java_java_lang_reflect_Field_setLong,
-       (functionptr) Java_java_lang_reflect_Field_setFloat,
-       (functionptr) Java_java_lang_reflect_Field_setDouble,
-
-       (functionptr) Java_java_lang_reflect_Method_getModifiersInternal,
-       (functionptr) Java_java_lang_reflect_Method_getReturnType,
-       (functionptr) Java_java_lang_reflect_Method_getParameterTypes,
-       (functionptr) Java_java_lang_reflect_Method_getExceptionTypes,
-       (functionptr) Java_java_lang_reflect_Method_invokeNative,
-
-       (functionptr) Java_java_lang_reflect_VMProxy_getProxyClass,
-       (functionptr) Java_java_lang_reflect_VMProxy_getProxyData,
-       (functionptr) Java_java_lang_reflect_VMProxy_generateProxyClass,
-
-       (functionptr) Java_java_security_VMAccessController_getStack,
-
-       (functionptr) Java_sun_misc_Unsafe_objectFieldOffset,
-       (functionptr) Java_sun_misc_Unsafe_compareAndSwapInt,
+static s4 native_tree_native_methods_comparator(const void *treenode, const void *node)
+{
+       const native_methods_node_t *treenmn;
+       const native_methods_node_t *nmn;
 
-#if defined(ENABLE_JVMTI)
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_suspendThread,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_resumeThread,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSuspendCount,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClassesCount,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassStatus,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllClassMethods,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getClassMethod,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrames,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrame,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getFrameCount,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getThreadStatus,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getLoadRequests,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_executeMethod,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getSourceFile,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_registerEvent,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_unregisterEvent,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_clearEvents,
-       (functionptr) Java_gnu_classpath_jdwp_VMVirtualMachine_getAllLoadedClasses,
-       (functionptr) Java_gnu_classpath_jdwp_VMFrame_setValue,
-       (functionptr) Java_gnu_classpath_jdwp_VMFrame_getValue,
-       (functionptr) Java_gnu_classpath_jdwp_VMMethod_getName,
-       (functionptr) Java_gnu_classpath_jdwp_VMMethod_getSignature,
-       (functionptr) Java_gnu_classpath_jdwp_VMMethod_getModifiers,
-       (functionptr) Java_gnu_classpath_jdwp_VMMethod_getLineTable,
-       (functionptr) Java_gnu_classpath_jdwp_VMMethod_getVariableTable
-#endif
+       treenmn = treenode;
+       nmn     = node;
 
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-       (functionptr) Java_com_sun_cldc_io_ResourceInputStream_open,
+       /* these are for walking the tree */
 
-       (functionptr) Java_com_sun_cldc_io_j2me_socket_Protocol_open0,
-       (functionptr) Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf,
-       (functionptr) Java_com_sun_cldc_io_j2me_socket_Protocol_writeByte,
+       if (treenmn->classname < nmn->classname)
+               return -1;
+       else if (treenmn->classname > nmn->classname)
+               return 1;
 
-       (functionptr) Java_com_sun_cldchi_io_ConsoleOutputStream_write,
+       if (treenmn->name < nmn->name)
+               return -1;
+       else if (treenmn->name > nmn->name)
+               return 1;
 
-       (functionptr) Java_java_lang_Class_forName,
-       (functionptr) Java_java_lang_Class_newInstance,
-       (functionptr) Java_java_lang_Class_isInstance,
-       (functionptr) Java_java_lang_Class_isAssignableFrom,
-       (functionptr) Java_java_lang_Class_isInterface,
-       (functionptr) Java_java_lang_Class_isArray,
-       (functionptr) Java_java_lang_Class_getName,
+       if (treenmn->descriptor < nmn->descriptor)
+               return -1;
+       else if (treenmn->descriptor > nmn->descriptor)
+               return 1;
 
-       (functionptr) Java_java_lang_Double_doubleToLongBits,
+       /* all pointers are equal, we have found the entry */
 
-       (functionptr) Java_java_lang_Float_floatToIntBits,
+       return 0;
+}
 
-       (functionptr) Java_java_lang_Math_ceil,
-       (functionptr) Java_java_lang_Math_cos,
-       (functionptr) Java_java_lang_Math_floor,
-       (functionptr) Java_java_lang_Math_sin,
-       (functionptr) Java_java_lang_Math_sqrt,
-       (functionptr) Java_java_lang_Math_tan,
 
-       (functionptr) Java_java_lang_Object_hashCode,
-       (functionptr) Java_java_lang_Object_notify,
-       (functionptr) Java_java_lang_Object_wait,
+/* native_make_overloaded_function *********************************************
 
-       (functionptr) Java_java_lang_Runtime_exitInternal,
-       (functionptr) Java_java_lang_Runtime_freeMemory,
-       (functionptr) Java_java_lang_Runtime_totalMemory,
-       (functionptr) Java_java_lang_Runtime_gc,
+   XXX
 
-       (functionptr) Java_java_lang_String_hashCode,
-       (functionptr) Java_java_lang_String_indexOf__I,
-       (functionptr) Java_java_lang_String_indexOf__II,
-       (functionptr) Java_java_lang_String_lastIndexOf__II,
-       (functionptr) Java_java_lang_String_intern,
+*******************************************************************************/
 
-       (functionptr) Java_java_lang_System_getProperty0,
+#if !defined(WITH_STATIC_CLASSPATH)
+static utf *native_make_overloaded_function(utf *name, utf *descriptor)
+{
+       char *newname;
+       s4    namelen;
+       char *utf_ptr;
+       u2    c;
+       s4    i;
+       s4    dumpsize;
+       utf  *u;
 
-       (functionptr) Java_java_lang_Thread_currentThread,
-       (functionptr) Java_java_lang_Thread_setPriority0,
-       (functionptr) Java_java_lang_Thread_start0,
-       (functionptr) Java_java_lang_Thread_yield,
+       /* mark memory */
 
-       (functionptr) Java_java_lang_Throwable_printStackTrace,
-       (functionptr) Java_java_lang_Throwable_fillInStackTrace
-#endif
-};
+       dumpsize = dump_size();
 
-#endif /* defined(ENABLE_LIBJVM) */
+       utf_ptr = descriptor->text;
+       namelen = strlen(name->text) + strlen("__") + strlen("0");
 
+       /* calculate additional length */
 
-/* tables for methods *********************************************************/
+       while ((c = utf_nextu2(&utf_ptr)) != ')') {
+               switch (c) {
+               case 'Z':
+               case 'B':
+               case 'C':
+               case 'S':
+               case 'I':
+               case 'J':
+               case 'F':
+               case 'D':
+                       namelen++;
+                       break;
+               case '[':
+                       namelen += 2;
+                       break;
+               case 'L':
+                       namelen++;
+                       while (utf_nextu2(&utf_ptr) != ';')
+                               namelen++;
+                       namelen += 2;
+                       break;
+               case '(':
+                       break;
+               default:
+                       assert(0);
+               }
+       }
 
-#if defined(WITH_STATIC_CLASSPATH)
-#define NATIVETABLESIZE  (sizeof(nativetable)/sizeof(struct nativeref))
+       /* reallocate memory */
 
-/* table for fast string comparison */
-static nativecompref nativecomptable[NATIVETABLESIZE];
+       i = strlen(name->text);
 
-/* string comparsion table initialized */
-static bool nativecompdone = false;
-#endif
+       newname = DMNEW(char, namelen);
+       MCOPY(newname, name->text, char, i);
+
+       utf_ptr = descriptor->text;
+
+       newname[i++] = '_';
+       newname[i++] = '_';
+
+       while ((c = utf_nextu2(&utf_ptr)) != ')') {
+               switch (c) {
+               case 'Z':
+               case 'B':
+               case 'C':
+               case 'S':
+               case 'J':
+               case 'I':
+               case 'F':
+               case 'D':
+                       newname[i++] = c;
+                       break;
+               case '[':
+                       newname[i++] = '_';
+                       newname[i++] = '3';
+                       break;
+               case 'L':
+                       newname[i++] = 'L';
+                       while ((c = utf_nextu2(&utf_ptr)) != ';')
+                               if (((c >= 'a') && (c <= 'z')) ||
+                                       ((c >= 'A') && (c <= 'Z')) ||
+                                       ((c >= '0') && (c <= '9')))
+                                       newname[i++] = c;
+                               else
+                                       newname[i++] = '_';
+                       newname[i++] = '_';
+                       newname[i++] = '2';
+                       break;
+               case '(':
+                       break;
+               default:
+                       assert(0);
+               }
+       }
+
+       /* close string */
+
+       newname[i] = '\0';
+
+       /* make a utf-string */
+
+       u = utf_new_char(newname);
+
+       /* release memory */
+
+       dump_release(dumpsize);
+
+       return u;
+}
+
+
+/* native_insert_char **********************************************************
+
+   Inserts the passed UTF character into the native method name.  If
+   necessary it is escaped properly.
+
+*******************************************************************************/
+
+static s4 native_insert_char(char *name, u4 pos, u2 c)
+{
+       s4 val;
+       s4 i;
+
+       switch (c) {
+       case '/':
+       case '.':
+               /* replace '/' or '.' with '_' */
+               name[pos] = '_';
+               break;
+
+       case '_':
+               /* escape sequence for '_' is '_1' */
+               name[pos]   = '_';
+               name[++pos] = '1';
+               break;
+
+       case ';':
+               /* escape sequence for ';' is '_2' */
+               name[pos]   = '_';
+               name[++pos] = '2';
+               break;
+
+       case '[':
+               /* escape sequence for '[' is '_1' */
+               name[pos]   = '_';
+               name[++pos] = '3';
+               break;
+
+       default:
+               if (isalnum(c))
+                       name[pos] = c;
+               else {
+                       /* unicode character */
+                       name[pos]   = '_';
+                       name[++pos] = '0';
+
+                       for (i = 0; i < 4; ++i) {
+                               val = c & 0x0f;
+                               name[pos + 4 - i] = (val > 10) ? ('a' + val - 10) : ('0' + val);
+                               c >>= 4;
+                       }
+
+                       pos += 4;
+               }
+               break;
+       }
+
+       /* return the new buffer index */
+
+       return pos;
+}
+
+
+/* native_method_symbol ********************************************************
+
+   Generate a method-symbol string out of the class name and the
+   method name.
+
+*******************************************************************************/
+
+static utf *native_method_symbol(utf *classname, utf *methodname)
+{
+       char *name;
+       s4    namelen;
+       char *utf_ptr;
+       char *utf_endptr;
+       u2    c;
+       u4    pos;
+       s4    dumpsize;
+       utf  *u;
+
+       /* mark memory */
+
+       dumpsize = dump_size();
+
+       /* Calculate length of native function name.  We multiply the
+          class and method name length by 6 as this is the maxium
+          escape-sequence that can be generated (unicode). */
+
+       namelen =
+               strlen("Java_") +
+               utf_get_number_of_u2s(classname) * 6 +
+               strlen("_") +
+               utf_get_number_of_u2s(methodname) * 6 +
+               strlen("0");
+
+       /* allocate memory */
+
+       name = DMNEW(char, namelen);
+
+       /* generate name of native functions */
+
+       strcpy(name, "Java_");
+       pos = strlen("Java_");
+
+       utf_ptr    = classname->text;
+       utf_endptr = UTF_END(classname);
+
+       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
+               c   = *utf_ptr;
+               pos = native_insert_char(name, pos, c);
+       }
+
+       /* seperator between class and method */
+
+       name[pos++] = '_';
+
+       utf_ptr    = methodname->text;
+       utf_endptr = UTF_END(methodname);
+
+       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
+               c   = *utf_ptr;
+               pos = native_insert_char(name, pos, c);
+       }
+
+       /* close string */
+
+       name[pos] = '\0';
+
+       /* check for an buffer overflow */
+
+       assert(pos <= namelen);
+
+       /* make a utf-string */
+
+       u = utf_new_char(name);
+
+       /* release memory */
+
+       dump_release(dumpsize);
+
+       return u;
+}
+
+
+/* native_method_register ******************************************************
+
+   Register a native method in the native method table.
+
+*******************************************************************************/
+
+void native_method_register(utf *classname, JNINativeMethod *methods, s4 count)
+{
+       native_methods_node_t *nmn;
+       utf                   *name;
+       utf                   *descriptor;
+       s4                     i;
+
+       /* insert all methods passed */
+
+       for (i = 0; i < count; i++) {
+               if (opt_verbosejni) {
+                       printf("[Registering JNI native method ");
+                       utf_display_printable_ascii_classname(classname);
+                       printf(".%s]\n", methods[i].name);
+               }
+
+               /* generate the utf8 names */
+
+               name       = utf_new_char(methods[i].name);
+               descriptor = utf_new_char(methods[i].signature);
+
+               /* allocate a new tree node */
+
+               nmn = NEW(native_methods_node_t);
+
+               nmn->classname  = classname;
+               nmn->name       = name;
+               nmn->descriptor = descriptor;
+               nmn->function   = (functionptr) (ptrint) methods[i].fnPtr;
+
+               /* insert the method into the tree */
+
+               avl_insert(tree_native_methods, nmn);
+       }
+}
+
+
+/* native_method_find **********************************************************
+
+   Find a native method in the native method table.
+
+*******************************************************************************/
 
+static functionptr native_method_find(methodinfo *m)
+{
+       native_methods_node_t  tmpnmn;
+       native_methods_node_t *nmn;
 
-/* global variables ***********************************************************/
+       /* fill the temporary structure used for searching the tree */
 
-#if !defined(WITH_STATIC_CLASSPATH)
-static hashtable *hashtable_library;
-static lt_dlhandle mainhandle;
-#endif
+       tmpnmn.classname  = m->class->name;
+       tmpnmn.name       = m->name;
+       tmpnmn.descriptor = m->descriptor;
 
+       /* find the entry in the AVL-tree */
 
-/* native_init *****************************************************************
+       nmn = avl_find(tree_native_methods, &tmpnmn);
 
-   Initializes the native subsystem.
+       if (nmn == NULL)
+               return NULL;
 
-*******************************************************************************/
+       return nmn->function;
+}
 
-bool native_init(void)
-{
-#if !defined(WITH_STATIC_CLASSPATH)
-       /* initialize libltdl */
 
-       if (lt_dlinit())
-               vm_abort("native_init: lt_dlinit failed: %s\n", lt_dlerror());
+/* native_library_open *********************************************************
 
-       /* Get the handle for the main program or for the libjvm.so,
-          depends on the configuration. */
+   Open a native library with the given utf8 name.
 
-# if defined(ENABLE_LIBJVM)
-       /* First try to open where dlopen searches, e.g. LD_LIBRARY_PATH.
-          If not found, try the absolute path. */
+*******************************************************************************/
 
-       if (!(mainhandle = lt_dlopenext("libjvm")))
-               if (!(mainhandle = lt_dlopenext(cacao_libjvm)))
-                       vm_abort("native_init: lt_dlopenext failed: %s\n", lt_dlerror());
-# else
-       if (!(mainhandle = lt_dlopen(NULL)))
-               vm_abort("native_init: lt_dlopen failed: %s\n", lt_dlerror());
-# endif
+#if !defined(WITH_STATIC_CLASSPATH)
+lt_dlhandle native_library_open(utf *filename)
+{
+       lt_dlhandle handle;
 
-       /* initialize library hashtable, 10 entries should be enough */
+       /* try to open the library */
 
-       hashtable_library = NEW(hashtable);
+       handle = lt_dlopen(filename->text);
 
-       hashtable_create(hashtable_library, 10);
-#endif
+       if (handle == NULL) {
+               if (opt_verbose) {
+                       log_start();
+                       log_print("native_library_load: lt_dlopen failed: ");
+                       log_print(lt_dlerror());
+                       log_finish();
+               }
 
-       /* everything's ok */
+               return NULL;
+       }
 
-       return true;
+       return handle;
 }
+#endif
 
 
-/* native_hashtable_library_add ************************************************
+/* native_library_add **********************************************************
 
    Adds an entry to the native library hashtable.
 
 *******************************************************************************/
 
 #if !defined(WITH_STATIC_CLASSPATH)
-void native_hashtable_library_add(utf *filename, java_objectheader *loader,
-                                                                 lt_dlhandle handle)
+void native_library_add(utf *filename, java_objectheader *loader,
+                                               lt_dlhandle handle)
 {
        hashtable_classloader_entry    *cle;
        hashtable_library_loader_entry *le;
@@ -530,15 +630,15 @@ void native_hashtable_library_add(utf *filename, java_objectheader *loader,
 #endif /* !defined(WITH_STATIC_CLASSPATH) */
 
 
-/* native_hashtable_library_find ***********************************************
+/* native_library_find *********************************************************
 
    Find an entry in the native library hashtable.
 
 *******************************************************************************/
 
 #if !defined(WITH_STATIC_CLASSPATH)
-hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
-                                                                                                                       java_objectheader *loader)
+hashtable_library_name_entry *native_library_find(utf *filename,
+                                                                                                 java_objectheader *loader)
 {
        hashtable_classloader_entry    *cle;
        hashtable_library_loader_entry *le;
@@ -570,7 +670,7 @@ hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
 
        /* no loader found? return NULL */
 
-       if (!le)
+       if (le == NULL)
                return NULL;
 
        /* search for library name */
@@ -649,172 +749,6 @@ functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
 #endif /* defined(WITH_STATIC_CLASSPATH) */
 
 
-/* native_make_overloaded_function *********************************************
-
-   XXX
-
-*******************************************************************************/
-
-#if !defined(WITH_STATIC_CLASSPATH)
-static char *native_make_overloaded_function(char *name, utf *desc)
-{
-       char *newname;
-       s4    namelen;
-       char *utf_ptr;
-       u2    c;
-       s4    i;
-
-       utf_ptr = desc->text;
-       namelen = strlen(name) + strlen("__") + strlen("0");
-
-       /* calculate additional length */
-
-       while ((c = utf_nextu2(&utf_ptr)) != ')') {
-               switch (c) {
-               case 'Z':
-               case 'B':
-               case 'C':
-               case 'S':
-               case 'I':
-               case 'J':
-               case 'F':
-               case 'D':
-                       namelen++;
-                       break;
-               case '[':
-                       namelen += 2;
-                       break;
-               case 'L':
-                       namelen++;
-                       while (utf_nextu2(&utf_ptr) != ';')
-                               namelen++;
-                       namelen += 2;
-                       break;
-               case '(':
-                       break;
-               default:
-                       assert(0);
-               }
-       }
-
-
-       /* reallocate memory */
-
-       i = strlen(name);
-
-       newname = DMNEW(char, namelen);
-       MCOPY(newname, name, char, i);
-
-       utf_ptr = desc->text;
-
-       newname[i++] = '_';
-       newname[i++] = '_';
-
-       while ((c = utf_nextu2(&utf_ptr)) != ')') {
-               switch (c) {
-               case 'Z':
-               case 'B':
-               case 'C':
-               case 'S':
-               case 'J':
-               case 'I':
-               case 'F':
-               case 'D':
-                       newname[i++] = c;
-                       break;
-               case '[':
-                       newname[i++] = '_';
-                       newname[i++] = '3';
-                       break;
-               case 'L':
-                       newname[i++] = 'L';
-                       while ((c = utf_nextu2(&utf_ptr)) != ';')
-                               if (((c >= 'a') && (c <= 'z')) ||
-                                       ((c >= 'A') && (c <= 'Z')) ||
-                                       ((c >= '0') && (c <= '9')))
-                                       newname[i++] = c;
-                               else
-                                       newname[i++] = '_';
-                       newname[i++] = '_';
-                       newname[i++] = '2';
-                       break;
-               case '(':
-                       break;
-               default:
-                       assert(0);
-               }
-       }
-
-       /* close string */
-
-       newname[i] = '\0';
-
-       return newname;
-}
-
-
-/* native_insert_char **********************************************************
-
-   Inserts the passed UTF character into the native method name.  If
-   necessary it is escaped properly.
-
-*******************************************************************************/
-
-static s4 native_insert_char(char *name, u4 pos, u2 c)
-{
-       s4 val;
-       s4 i;
-
-       switch (c) {
-       case '/':
-       case '.':
-               /* replace '/' or '.' with '_' */
-               name[pos] = '_';
-               break;
-
-       case '_':
-               /* escape sequence for '_' is '_1' */
-               name[pos]   = '_';
-               name[++pos] = '1';
-               break;
-
-       case ';':
-               /* escape sequence for ';' is '_2' */
-               name[pos]   = '_';
-               name[++pos] = '2';
-               break;
-
-       case '[':
-               /* escape sequence for '[' is '_1' */
-               name[pos]   = '_';
-               name[++pos] = '3';
-               break;
-
-       default:
-               if (isalnum(c))
-                       name[pos] = c;
-               else {
-                       /* unicode character */
-                       name[pos]   = '_';
-                       name[++pos] = '0';
-
-                       for (i = 0; i < 4; ++i) {
-                               val = c & 0x0f;
-                               name[pos + 4 - i] = (val > 10) ? ('a' + val - 10) : ('0' + val);
-                               c >>= 4;
-                       }
-
-                       pos += 4;
-               }
-               break;
-       }
-
-       /* return the new buffer index */
-
-       return pos;
-}
-
-
 /* native_resolve_function *****************************************************
 
    Resolves a native function, maybe from a dynamic library.
@@ -823,15 +757,9 @@ static s4 native_insert_char(char *name, u4 pos, u2 c)
 
 functionptr native_resolve_function(methodinfo *m)
 {
-       lt_ptr                          sym;
-       char                           *name;
-       char                           *newname;
-       s4                              namelen;
-       char                           *utf_ptr;
-       char                           *utf_endptr;
-       u2                              c;
-       u4                              pos;
-       s4                              dumpsize;
+       utf                            *name;
+       utf                            *newname;
+       functionptr                     f;
        hashtable_library_loader_entry *le;
        hashtable_library_name_entry   *ne;
        u4                              key;    /* hashkey                        */
@@ -846,55 +774,10 @@ functionptr native_resolve_function(methodinfo *m)
                utf_display_printable_ascii(m->name);
                printf(" ... ");
        }
-               
-       /* Calculate length of native function name.  We multiply the
-          class and method name length by 6 as this is the maxium
-          escape-sequence that can be generated (unicode). */
-
-       namelen = strlen("Java_") +
-               utf_get_number_of_u2s(m->class->name) * 6 +
-               strlen("_") +
-               utf_get_number_of_u2s(m->name) * 6 +
-               strlen("0");
-
-       /* allocate memory */
-
-       dumpsize = dump_size();
-
-       name = DMNEW(char, namelen);
-
-       /* generate name of native functions */
-
-       strcpy(name, "Java_");
-       pos = strlen("Java_");
-
-       utf_ptr    = m->class->name->text;
-       utf_endptr = UTF_END(m->class->name);
-
-       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
-               c   = *utf_ptr;
-               pos = native_insert_char(name, pos, c);
-       }
-
-       /* seperator between class and method */
-
-       name[pos++] = '_';
-
-       utf_ptr    = m->name->text;
-       utf_endptr = UTF_END(m->name);
-
-       for (; utf_ptr < utf_endptr; utf_ptr++, pos++) {
-               c   = *utf_ptr;
-               pos = native_insert_char(name, pos, c);
-       }
-
-       /* close string */
-
-       name[pos] = '\0';
 
-       /* check for an buffer overflow */
+       /* generate method symbol string */
 
-       assert(pos <= namelen);
+       name = native_method_symbol(m->class->name, m->name);
 
        /* generate overloaded function (having the types in it's name)           */
 
@@ -903,7 +786,7 @@ functionptr native_resolve_function(methodinfo *m)
        /* check the library hash entries of the classloader of the
           methods's class  */
 
-       sym = NULL;
+       f = NULL;
 
        /* normally addresses are aligned to 4, 8 or 16 bytes */
 
@@ -913,16 +796,16 @@ functionptr native_resolve_function(methodinfo *m)
 
        /* iterate through loaders in this hash slot */
 
-       while ((le != NULL) && (sym == NULL)) {
+       while ((le != NULL) && (f == NULL)) {
                /* iterate through names in this loader */
 
                ne = le->namelink;
                        
-               while ((ne != NULL) && (sym == NULL)) {
-                       sym = lt_dlsym(ne->handle, name);
+               while ((ne != NULL) && (f == NULL)) {
+                       f = (functionptr) (ptrint) lt_dlsym(ne->handle, name->text);
 
-                       if (sym == NULL)
-                               sym = lt_dlsym(ne->handle, newname);
+                       if (f == NULL)
+                               f = (functionptr) (ptrint) lt_dlsym(ne->handle, newname->text);
 
                        ne = ne->hashlink;
                }
@@ -930,45 +813,36 @@ functionptr native_resolve_function(methodinfo *m)
                le = le->hashlink;
        }
 
-       if (sym != NULL)
+       if (f != NULL)
                if (opt_verbosejni)
                        printf("JNI ]\n");
 
-
        /* If not found, try to find the native function symbol in the
           main program. */
 
-       if (sym == NULL) {
-               sym = lt_dlsym(mainhandle, name);
+       if (f == NULL) {
+               f = native_method_find(m);
 
-               if (sym == NULL)
-                       sym = lt_dlsym(mainhandle, newname);
-
-               if (sym != NULL)
+               if (f != NULL)
                        if (opt_verbosejni)
                                printf("internal ]\n");
        }
 
-
 #if defined(ENABLE_JVMTI)
        /* fire Native Method Bind event */
-       if (jvmti) jvmti_NativeMethodBind(m, sym, &sym);
+       if (jvmti) jvmti_NativeMethodBind(m, f, &f);
 #endif
 
        /* no symbol found? throw exception */
 
-       if (sym == NULL) {
+       if (f == NULL) {
                if (opt_verbosejni)
                        printf("failed ]\n");
 
                exceptions_throw_unsatisfiedlinkerror(m->name);
        }
 
-       /* release memory */
-
-       dump_release(dumpsize);
-
-       return (functionptr) (ptrint) sym;
+       return f;
 }
 #endif /* !defined(WITH_STATIC_CLASSPATH) */
 
@@ -1113,46 +987,6 @@ java_objectheader *native_new_and_init_throwable(classinfo *c, java_objectheader
 }
 
 
-/* native_class_getdeclaredannotations *****************************************
-
-   Implementation for
-   java.lang.Class.getDeclaredAnnotations(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;
-
-*******************************************************************************/
-
-#if defined(ENABLE_JAVASE)
-java_objectarray *native_class_getdeclaredannotations(classinfo *c)
-{
-       java_objectarray *oa;
-       s4                count;
-       s4                i;
-
-       classinfo *class_java_lang_annotation_Annotation;
-
-       /* create Annotation-array */
-
-       /* XXX should we cache that class? */
-       if (!(class_java_lang_annotation_Annotation =
-                 load_class_bootstrap(utf_new_char("java/lang/annotation/Annotation"))))
-               return NULL;
-
-       count = c->runtimevisibleannotationscount;
-
-       oa = builtin_anewarray(count, class_java_lang_annotation_Annotation);
-
-       if (oa == NULL)
-               return NULL;
-
-       /* fill the annotations */
-
-       for (i = 0; i < count; i++) {
-       }
-
-       return oa;
-}
-#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
index b12d417e44997e706366df30d5486da61633620f..89399a3872e2b2915ab5628350eeac7532b7dc26 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: native.h 7601 2007-03-28 23:02:50Z michi $
+   $Id: native.h 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -36,6 +36,8 @@
 # include <ltdl.h>
 #endif
 
+#include "native/jni.h"
+
 #include "vm/global.h"
 
 #include "vmcore/class.h"
 #include "vmcore/utf8.h"
 
 
+/* defines ********************************************************************/
+
+#define NATIVE_METHODS_COUNT    sizeof(methods) / sizeof(JNINativeMethod)
+
+
 /* table for locating native methods */
 
 typedef struct nativeref nativeref;
@@ -55,6 +62,18 @@ typedef struct hashtable_library_loader_entry hashtable_library_loader_entry;
 typedef struct hashtable_library_name_entry hashtable_library_name_entry;
 
 
+/* native_methods_node_t ******************************************************/
+
+typedef struct native_methods_node_t native_methods_node_t;
+
+struct native_methods_node_t {
+       utf         *classname;             /* class name                         */
+       utf         *name;                  /* method name                        */
+       utf         *descriptor;            /* descriptor name                    */
+       functionptr  function;              /* pointer to the implementation      */
+};
+
+
 /* hashtable_library_loader_entry *********************************************/
 
 struct hashtable_library_loader_entry {
@@ -93,44 +112,37 @@ struct nativecompref {
 };
 
 
-/* initialize native subsystem */
+/* function prototypes ********************************************************/
+
 bool native_init(void);
 
+void native_method_register(utf *classname, JNINativeMethod *methods, s4 count);
+
 #if defined(WITH_STATIC_CLASSPATH)
 
-/* find native function */
 functionptr native_findfunction(utf *cname, utf *mname, utf *desc,
                                                                bool isstatic);
 
 #else /* defined(WITH_STATIC_CLASSPATH) */
 
-/* add a library to the library hash */
-void native_hashtable_library_add(utf *filename, java_objectheader *loader,
-                                                                 lt_dlhandle handle);
+lt_dlhandle native_library_open(utf *filename);
+void        native_library_add(utf *filename, java_objectheader *loader,
+                                                          lt_dlhandle handle);
 
-/* find a library entry in the library hash */
-hashtable_library_name_entry *native_hashtable_library_find(utf *filename,
-                                                                                                                       java_objectheader *loader);
+hashtable_library_name_entry *native_library_find(utf *filename,
+                                                                                                 java_objectheader *loader);
 
-/* resolve native function */
 functionptr native_resolve_function(methodinfo *m);
 
 #endif /* defined(WITH_STATIC_CLASSPATH) */
 
-/* create new object on the heap and call the initializer */
 java_objectheader *native_new_and_init(classinfo *c);
 
-/* create new object on the heap and call the initializer 
-   mainly used for exceptions with a message */
 java_objectheader *native_new_and_init_string(classinfo *c,
                                                                                          java_objectheader *s);
 
-/* create new object on the heap and call the initializer 
-   mainly used for exceptions with an index */
 java_objectheader *native_new_and_init_int(classinfo *c, s4 i);
 
-/* create new object on the heap and call the initializer 
-   mainly used for exceptions with cause */
 java_objectheader *native_new_and_init_throwable(classinfo *c,
                                                                                                 java_objectheader *t);
 
diff --git a/src/native/tools/.cvsignore b/src/native/tools/.cvsignore
deleted file mode 100644 (file)
index ab8e673..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-gennativetable
diff --git a/src/native/vm/.cvsignore b/src/native/vm/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 71f95d8f59b05ecf48772bc97d65d8ac378d4e53..f8ff81bbcf265def027603b3f7cb145bd0237452 100644 (file)
@@ -60,6 +60,9 @@ noinst_LTLIBRARIES = \
        libnativevm.la
 
 libnativevm_la_SOURCES = \
+       nativevm.c \
+       nativevm.h \
+       \
        java_lang_Class.c \
        java_lang_Class.h \
        $(CLASSLOADER_SOURCES) \
diff --git a/src/native/vm/cldc1.1/.cvsignore b/src/native/vm/cldc1.1/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index e0d7a8f1066d1403929da8d4d052ed4907de6bf5..1bd4ae55d3f90473095ac3ec253104fb9efba08b 100644 (file)
 #include "vm/types.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/com_sun_cldc_io_ResourceInputStream.h"
+
 #include "vm/vm.h" /* REMOVE ME: temporarily */
 
 
+/* 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 },
+};
+/* _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);
+}
+
+
 /*
  * Class:     com/sun/cldc/io/ResourceInputStream
  * Method:    open
index 1274b074fe459be05a11d61633b7ac5e3153c42e..14fe27f2dd068b81d5634bfdb5e06f9ab0829117 100644 (file)
 #include "mm/memory.h"
 
 #include "native/jni.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
index fa9610379a8e260aff259d6ec561c6a8f8afe60b..875ed46ddf62e96291ea6d0651aa4d61b2c70773 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/cldc1.1/com_sun_cldchi_io_ConsoleOutputStream.c
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Phil Tomsich
-            Christian Thalinger
-
    $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
 
 */
 #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);
+}
 
 
 /*
@@ -46,7 +67,7 @@
  * Method:    write
  * Signature: (I)V
  */
-JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, jclass clazz, s4 c)
+JNIEXPORT void JNICALL Java_com_sun_cldchi_io_ConsoleOutputStream_write(JNIEnv *env, com_sun_cldchi_io_ConsoleOutputStream *this, s4 c)
 {
        (void) fputc(c, stdout);
 }
index 4a42b030a9cdf9bb43e06c5e928153fe255da39e..c9e82a7b70e445cbb48ca9d33d09fe9085b16f17 100644 (file)
 #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 "native/vm/java_lang_Runtime.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
index dfb484e5a38d1bb21674d9c367e07f464291bd66..07b0ab6f764c765e70fef6a35a4ecbc61cd3fe43 100644 (file)
 #include "native/jni.h"
 #include "native/native.h"
 
-#include "native/include/java_lang_String.h" /* required by java_lang_Class.h */
-#include "native/include/java_lang_Class.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 "native/vm/java_lang_Class.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
index a617d92a5d92e9e0cf0df9b39d379676e7585968..d860d86ef50a4a7058b764d6019b3f2f41f86ae8 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/cldc1.1/java_lang_Double.c
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Phil Tomsich
-            Christian Thalinger
-
    $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
 
 */
 #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(jclass clazz, double doubleValue)
+JNIEXPORT s8 JNICALL Java_java_lang_Double_doubleToLongBits(JNIEnv *env, jclass clazz, double doubleValue)
 {
        jvalue val;
        s8  e, f;
@@ -75,7 +98,7 @@ JNIEXPORT s8 JNICALL Java_java_lang_Double_doubleToLongBits(jclass clazz, double
  * Method:    longBitsToDouble
  * Signature: (J)D
  */
-JNIEXPORT s8 JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, s8 longValue)
+JNIEXPORT double JNICALL Java_java_lang_Double_longBitsToDouble(JNIEnv *env, jclass clazz, s8 longValue)
 {
        jvalue val;
        val.j = longValue;
index 799500a935203a42cd2d30eccdce2d9e6296d7bb..5e89bf3f2b63ed33f36a1b0d999a930b075c687f 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/cldc1.1/java_lang_Float.c
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Phil Tomsich
-            Christian Thalinger
-
    $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
 
 */
 
 #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
index 6ef7108a978cb33ead55a1973a196f24e7b449e9..772a3eefa5dc76608304897db00b28e7eb2a5d4a 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/cldc1.1/java_lang_Math.c
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Phil Tomsich
-            Christian Thalinger
-
    $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
 
 */
 #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);
+}
 
 
 /*
index ef5b83399b22580389be37c16c07da8e6ff72a1d..b6eb7513e4de1a4e477a790d50c5a589b8f8ac60 100644 (file)
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/native.h"
 
-#include "native/include/java_lang_String.h" /* required by java_lang_Class.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 "native/vm/java_lang_Object.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/VMObject
+ * Class:     java/lang/Object
  * Method:    getClass
- * Signature: (Ljava/lang/Object;)Ljava/lang/Class;
+ * Signature: ()Ljava/lang/Class;
  */
 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj)
 {
index 11fe32e404c449cfdabb3444ac8b4bc613599c81..b576359f9da79ecfb3f90328f074c6cad2c15c22 100644 (file)
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/native.h"
 
 #include "native/include/java_lang_Runtime.h"
 
 #include "native/vm/java_lang_Runtime.h"
 
 
+/* native methods implemented by this file ************************************/
+static JNINativeMethod methods[] = {
+       { "exitInternal", "(I)V", (void *) (ptrint) &Java_java_lang_Runtime_exitInternal },
+       { "freeMemory",   "()J",  (void *) (ptrint) &Java_java_lang_Runtime_freeMemory   },
+       { "totalMemory",  "()J",  (void *) (ptrint) &Java_java_lang_Runtime_totalMemory  },
+       { "gc",           "()V",  (void *) (ptrint) &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
index 76acde4454693fb23c43a5cb9ea7d2a8f2e268a7..ad60b48bd9e751bd058b10f03ec854c402a297bc 100644 (file)
 
 #include "native/jni.h"
 #include "native/native.h"
-#include "native/include/java_lang_String.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
index ff415f17fb2bf54e25576ae57cc83c67051b3176..3547a504b0e508c5ba51e4eb87ea2d57789de42a 100644 (file)
 #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
index c415853b831af066203995908535ade7015b8941..433d6e6b0870c25b7ee4f8006ef0000d3a9773dc 100644 (file)
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/native.h"
 
 #include "native/include/java_lang_Thread.h"
 
 #include "native/vm/java_lang_Thread.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
+#include "threads/threads-common.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
index bd9c259d2225df9185ebc5cf2d03424646e495d1..68f86c5377d4be89f7aa56ecddf73e35d338cfd9 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/cldc1.1/java_lang_Throwable.c - java/lang/Throwable
 
-   Copyright (C) 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Joseph Wenninger
-            Christian Thalinger
-
    $Id: java_lang_VMThrowable.c 6213 2006-12-18 17:36:06Z twisti $
 
 */
 #include "vm/types.h"
 
 #include "native/jni.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 *) (ptrint) &Java_java_lang_Throwable_printStackTrace  },
+       { "fillInStackTrace", "()V", (void *) (ptrint) &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
@@ -64,7 +86,7 @@ JNIEXPORT void JNICALL Java_java_lang_Throwable_printStackTrace(JNIEnv *env, jav
 /*
  * Class:     java/lang/Throwable
  * Method:    fillInStackTrace
- * Signature: (Ljava/lang/Throwable;)V
+ * Signature: ()V
  */
 JNIEXPORT void JNICALL Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, java_lang_Throwable *this)
 {
diff --git a/src/native/vm/gnu/.cvsignore b/src/native/vm/gnu/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index dbe476bae74870a9ffb36b4b9ea12ab5046009a4..8104fbee89040701e21c38a982bcb5a4a9e88016 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: gnu_classpath_VMStackWalker.c 7399 2007-02-23 23:29:13Z michi $
+   $Id: gnu_classpath_VMStackWalker.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 
 #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/builtin.h"
 #include "vm/global.h"
 
 #include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
-#include "vmcore/loader.h"
-#include "vmcore/options.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);
+}
 
 
 /*
index 52c9f1d45c0de7fdadd43419a72dc51f53364b68..f4ad3f8b04d83a14ee536bff02ccb182b3d4d8a2 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: gnu_classpath_VMSystemProperties.c 7264 2007-01-31 14:05:57Z twisti $
+   $Id: gnu_classpath_VMSystemProperties.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 #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
index 8be4825a1a486e7dc60b318c627f3439a4c128d6..2ec54697410ac263bfde74a119c5436ac0a5b679 100644 (file)
@@ -33,6 +33,9 @@
 #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 "vmcore/classcache.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getLoadedClassCount",   "()I",  (void *) (ptrint) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getLoadedClassCount   },
+       { "getUnloadedClassCount", "()J",  (void *) (ptrint) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_getUnloadedClassCount },
+       { "isVerbose",             "()Z",  (void *) (ptrint) &Java_gnu_java_lang_management_VMClassLoadingMXBeanImpl_isVerbose             },
+       { "setVerbose",            "(Z)V", (void *) (ptrint) &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
index 37741ec71cf76ef92b7972183662a7a17a4a4e40..780a6e8f1eeaca95315bff56a1b9cfe270f34c90 100644 (file)
 #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/options.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getHeapMemoryUsage",                "()Ljava/lang/management/MemoryUsage;", (void *) (ptrint) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getHeapMemoryUsage                },
+       { "getNonHeapMemoryUsage",             "()Ljava/lang/management/MemoryUsage;", (void *) (ptrint) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getNonHeapMemoryUsage             },
+       { "getObjectPendingFinalizationCount", "()I",                                  (void *) (ptrint) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_getObjectPendingFinalizationCount },
+       { "isVerbose",                         "()Z",                                  (void *) (ptrint) &Java_gnu_java_lang_management_VMMemoryMXBeanImpl_isVerbose                         },
+       { "setVerbose",                        "(Z)V",                                 (void *) (ptrint) &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
index adeef5faa8a425025de90adefd38f6f2b6fcdc5f..d66e5d7d000433825cf07f6bc044f637f8fc0146 100644 (file)
@@ -31,6 +31,9 @@
 #include "vm/types.h"
 
 #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 "vmcore/class.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getInputArguments", "()[Ljava/lang/String;", (void *) (ptrint) &Java_gnu_java_lang_management_VMRuntimeMXBeanImpl_getInputArguments },
+       { "getStartTime",      "()J",                   (void *) (ptrint) &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
index 483e5e1d97f8ecb80d0cf5751543053d2eb144e1..62b92a92b52a83c0d21cf377a415342a74786280 100644 (file)
 #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"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "findMonitorDeadlockedThreads", "()[J",                                  (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_findMonitorDeadlockedThreads },
+       { "getCurrentThreadCpuTime",      "()J",                                   (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadCpuTime      },
+       { "getCurrentThreadUserTime",     "()J",                                   (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getCurrentThreadUserTime     },
+       { "getPeakThreadCount",           "()I",                                   (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getPeakThreadCount           },
+       { "getThreadCpuTime",             "(J)J",                                  (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadCpuTime             },
+       { "getThreadInfoForId",           "(JI)Ljava/lang/management/ThreadInfo;", (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadInfoForId           },
+       { "getThreadUserTime",            "(J)J",                                  (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getThreadUserTime            },
+       { "getTotalStartedThreadCount",   "()J",                                   (void *) (ptrint) &Java_gnu_java_lang_management_VMThreadMXBeanImpl_getTotalStartedThreadCount   },
+       { "resetPeakThreadCount",         "()V",                                   (void *) (ptrint) &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
index dfd4c155f722189c77166f0e23bc6bbb6d6905e2..98253103dc635d228edb36fd3beb83d674fbb610 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMClass.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: java_lang_VMClass.c 7912 2007-05-18 13:12:09Z twisti $
 
 */
 
 #include "vm/types.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/java_lang_Object.h"
 #include "native/include/java_lang_Throwable.h"
-#include "native/include/java_lang_VMClass.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 "native/vm/java_lang_Class.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "isInstance",              "(Ljava/lang/Class;Ljava/lang/Object;)Z",                        (void *) (ptrint) &Java_java_lang_VMClass_isInstance              },
+       { "isAssignableFrom",        "(Ljava/lang/Class;Ljava/lang/Class;)Z",                         (void *) (ptrint) &Java_java_lang_VMClass_isAssignableFrom        },
+       { "isInterface",             "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isInterface             },
+       { "isPrimitive",             "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isPrimitive             },
+       { "getName",                 "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (ptrint) &Java_java_lang_VMClass_getName                 },
+       { "getSuperclass",           "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (ptrint) &Java_java_lang_VMClass_getSuperclass           },
+       { "getInterfaces",           "(Ljava/lang/Class;)[Ljava/lang/Class;",                         (void *) (ptrint) &Java_java_lang_VMClass_getInterfaces           },
+       { "getComponentType",        "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (ptrint) &Java_java_lang_VMClass_getComponentType        },
+       { "getModifiers",            "(Ljava/lang/Class;Z)I",                                         (void *) (ptrint) &Java_java_lang_VMClass_getModifiers            },
+       { "getDeclaringClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (ptrint) &Java_java_lang_VMClass_getDeclaringClass       },
+       { "getDeclaredClasses",      "(Ljava/lang/Class;Z)[Ljava/lang/Class;",                        (void *) (ptrint) &Java_java_lang_VMClass_getDeclaredClasses      },
+       { "getDeclaredFields",       "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;",                (void *) (ptrint) &Java_java_lang_VMClass_getDeclaredFields       },
+       { "getDeclaredMethods",      "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;",               (void *) (ptrint) &Java_java_lang_VMClass_getDeclaredMethods      },
+       { "getDeclaredConstructors", "(Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;",          (void *) (ptrint) &Java_java_lang_VMClass_getDeclaredConstructors },
+       { "getClassLoader",          "(Ljava/lang/Class;)Ljava/lang/ClassLoader;",                    (void *) (ptrint) &Java_java_lang_VMClass_getClassLoader          },
+       { "forName",                 "(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;", (void *) (ptrint) &Java_java_lang_VMClass_forName                 },
+       { "isArray",                 "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isArray                 },
+       { "throwException",          "(Ljava/lang/Throwable;)V",                                      (void *) (ptrint) &Java_java_lang_VMClass_throwException          },
+#if 0
+       { "getDeclaredAnnotations",  "(Ljava/lang/Class;)[Ljava/lang/annotation/Annotation;",         (void *) (ptrint) &Java_java_lang_VMClass_getDeclaredAnnotations  },
+#endif
+       { "getEnclosingClass",       "(Ljava/lang/Class;)Ljava/lang/Class;",                          (void *) (ptrint) &Java_java_lang_VMClass_getEnclosingClass       },
+       { "getEnclosingConstructor", "(Ljava/lang/Class;)Ljava/lang/reflect/Constructor;",            (void *) (ptrint) &Java_java_lang_VMClass_getEnclosingConstructor },
+       { "getEnclosingMethod",      "(Ljava/lang/Class;)Ljava/lang/reflect/Method;",                 (void *) (ptrint) &Java_java_lang_VMClass_getEnclosingMethod      },
+       { "getClassSignature",       "(Ljava/lang/Class;)Ljava/lang/String;",                         (void *) (ptrint) &Java_java_lang_VMClass_getClassSignature       },
+#if 0
+       { "isAnonymousClass",        "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isAnonymousClass        },
+       { "isLocalClass",            "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isLocalClass            },
+       { "isMemberClass",           "(Ljava/lang/Class;)Z",                                          (void *) (ptrint) &Java_java_lang_VMClass_isMemberClass           },
+#endif
+};
+
+
+/* _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/Object;)Z
+ * Signature: (Ljava/lang/Class;Ljava/lang/Object;)Z
  */
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Object *o)
 {
@@ -56,7 +111,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInstance(JNIEnv *env, jclass clazz
 /*
  * Class:     java/lang/VMClass
  * Method:    isAssignableFrom
- * Signature: (Ljava/lang/Class;)Z
+ * Signature: (Ljava/lang/Class;Ljava/lang/Class;)Z
  */
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
 {
@@ -67,7 +122,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass
 /*
  * Class:     java/lang/VMClass
  * Method:    isInterface
- * Signature: ()Z
+ * Signature: (Ljava/lang/Class;)Z
  */
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass clazz, java_lang_Class *klass)
 {
@@ -78,7 +133,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isInterface(JNIEnv *env, jclass claz
 /*
  * Class:     java/lang/VMClass
  * Method:    isPrimitive
- * Signature: ()Z
+ * Signature: (Ljava/lang/Class;)Z
  */
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass clazz, java_lang_Class *klass)
 {
@@ -89,7 +144,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isPrimitive(JNIEnv *env, jclass claz
 /*
  * Class:     java/lang/VMClass
  * Method:    getName
- * Signature: ()Ljava/lang/String;
+ * 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)
 {
@@ -100,7 +155,7 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMClass_getName(JNIEnv *env,
 /*
  * Class:     java/lang/VMClass
  * Method:    getSuperclass
- * Signature: ()Ljava/lang/Class;
+ * 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)
 {
@@ -111,7 +166,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getSuperclass(JNIEnv *
 /*
  * Class:     java/lang/VMClass
  * Method:    getInterfaces
- * Signature: ()[Ljava/lang/Class;
+ * Signature: (Ljava/lang/Class;)[Ljava/lang/Class;
  */
 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
 {
@@ -122,7 +177,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv
 /*
  * Class:     java/lang/VMClass
  * Method:    getComponentType
- * Signature: ()Ljava/lang/Class;
+ * 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)
 {
@@ -133,7 +188,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getComponentType(JNIEn
 /*
  * Class:     java/lang/VMClass
  * Method:    getModifiers
- * Signature: (Z)I
+ * Signature: (Ljava/lang/Class;Z)I
  */
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 ignoreInnerClassesAttrib)
 {
@@ -144,7 +199,7 @@ JNIEXPORT s4 JNICALL Java_java_lang_VMClass_getModifiers(JNIEnv *env, jclass cla
 /*
  * Class:     java/lang/VMClass
  * Method:    getDeclaringClass
- * Signature: ()Ljava/lang/Class;
+ * 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)
 {
@@ -155,7 +210,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_getDeclaringClass(JNIE
 /*
  * Class:     java/lang/VMClass
  * Method:    getDeclaredClasses
- * Signature: (Z)[Ljava/lang/Class;
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/Class;
  */
 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
 {
@@ -166,7 +221,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredClasses(JN
 /*
  * Class:     java/lang/VMClass
  * Method:    getDeclaredFields
- * Signature: (Z)[Ljava/lang/reflect/Field;
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Field;
  */
 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
 {
@@ -177,7 +232,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredFields(JNI
 /*
  * Class:     java/lang/VMClass
  * Method:    getDeclaredMethods
- * Signature: (Z)[Ljava/lang/reflect/Method;
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Method;
  */
 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
 {
@@ -188,7 +243,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredMethods(JN
 /*
  * Class:     java/lang/VMClass
  * Method:    getDeclaredConstructors
- * Signature: (Z)[Ljava/lang/reflect/Constructor;
+ * Signature: (Ljava/lang/Class;Z)[Ljava/lang/reflect/Constructor;
  */
 JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredConstructors(JNIEnv *env, jclass clazz, java_lang_Class *klass, s4 publicOnly)
 {
@@ -199,7 +254,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getDeclaredConstructo
 /*
  * Class:     java/lang/VMClass
  * Method:    getClassLoader
- * Signature: ()Ljava/lang/ClassLoader;
+ * 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)
 {
@@ -221,7 +276,7 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClass_forName(JNIEnv *env, j
 /*
  * Class:     java/lang/VMClass
  * Method:    isArray
- * Signature: ()Z
+ * Signature: (Ljava/lang/Class;)Z
  */
 JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isArray(JNIEnv *env, jclass clazz, java_lang_Class *klass)
 {
index eac72274226b94d55353d1c4badaa225cdcbba89..f30764e02089e916cc72b065ef8a718d60755f9f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMClassLoader.c 7723 2007-04-16 18:03:08Z michi $
+   $Id: java_lang_VMClassLoader.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -44,6 +44,8 @@
 #include "native/include/java_lang_ClassLoader.h"
 #include "native/include/java_util_Vector.h"
 
+#include "native/include/java_lang_VMClassLoader.h"
+
 #include "native/vm/java_lang_ClassLoader.h"
 
 #include "toolbox/logging.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 *) (ptrint) &Java_java_lang_VMClassLoader_defineClass            },
+       { "getPrimitiveClass",      "(C)Ljava/lang/Class;",                                                                             (void *) (ptrint) &Java_java_lang_VMClassLoader_getPrimitiveClass      },
+       { "resolveClass",           "(Ljava/lang/Class;)V",                                                                             (void *) (ptrint) &Java_java_lang_VMClassLoader_resolveClass           },
+       { "loadClass",              "(Ljava/lang/String;Z)Ljava/lang/Class;",                                                           (void *) (ptrint) &Java_java_lang_VMClassLoader_loadClass              },
+       { "nativeGetResources",     "(Ljava/lang/String;)Ljava/util/Vector;",                                                           (void *) (ptrint) &Java_java_lang_VMClassLoader_nativeGetResources     },
+       { "defaultAssertionStatus", "()Z",                                                                                              (void *) (ptrint) &Java_java_lang_VMClassLoader_defaultAssertionStatus },
+       { "findLoadedClass",        "(Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/Class;",                                     (void *) (ptrint) &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
@@ -162,7 +193,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMClassLoader_resolveClass(JNIEnv *env, jc
  * 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, jboolean resolve)
+JNIEXPORT java_lang_Class* JNICALL Java_java_lang_VMClassLoader_loadClass(JNIEnv *env, jclass clazz, java_lang_String *name, s4 resolve)
 {
        classinfo         *c;
        utf               *u;
index 010c18a52c99fca353e7fde8480b00ec24a036cc..c0f089cf57e57f55739a537ff2d71ea34a195477 100644 (file)
@@ -1,6 +1,6 @@
 /* src/native/vm/gnu/java_lang_VMObject.c - java/lang/VMObject
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-            Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMObject.c 6221 2006-12-21 15:56:38Z twisti $
+   $Id: java_lang_VMObject.c 7912 2007-05-18 13:12:09Z twisti $
 
 */
 
 #include "vm/types.h"
 
 #include "native/jni.h"
-#include "native/include/java_lang_Class.h"
-#include "native/include/java_lang_Cloneable.h"
-#include "native/include/java_lang_Object.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 "native/vm/java_lang_Object.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getClass",  "(Ljava/lang/Object;)Ljava/lang/Class;",     (void *) (ptrint) &Java_java_lang_VMObject_getClass  },
+       { "clone",     "(Ljava/lang/Cloneable;)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_VMObject_clone     },
+       { "notify",    "(Ljava/lang/Object;)V",                     (void *) (ptrint) &Java_java_lang_VMObject_notify    },
+       { "notifyAll", "(Ljava/lang/Object;)V",                     (void *) (ptrint) &Java_java_lang_VMObject_notifyAll },
+       { "wait",      "(Ljava/lang/Object;JI)V",                   (void *) (ptrint) &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
@@ -68,7 +94,7 @@ JNIEXPORT java_lang_Object* JNICALL Java_java_lang_VMObject_clone(JNIEnv *env, j
 /*
  * Class:     java/lang/VMObject
  * Method:    notify
- * Signature: ()V
+ * Signature: (Ljava/lang/Object;)V
  */
 JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz, java_lang_Object *this)
 {
@@ -79,7 +105,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMObject_notify(JNIEnv *env, jclass clazz,
 /*
  * Class:     java/lang/VMObject
  * Method:    notifyAll
- * Signature: ()V
+ * Signature: (Ljava/lang/Object;)V
  */
 JNIEXPORT void JNICALL Java_java_lang_VMObject_notifyAll(JNIEnv *env, jclass clazz, java_lang_Object *this)
 {
index 98d52dbdf3ae5d2d2cae101c6e7082430a76880e..bb1a2038977f6fc599d6bcacb6d0177ee35675a6 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMRuntime.c 7718 2007-04-16 15:26:01Z twisti $
+   $Id: java_lang_VMRuntime.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 #include "mm/memory.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 "native/vm/java_lang_Runtime.h"
 
 #include "vm/builtin.h"
 */
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "exit",                   "(I)V",                                         (void *) (ptrint) &Java_java_lang_VMRuntime_exit                   },
+       { "freeMemory",             "()J",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_freeMemory             },
+       { "totalMemory",            "()J",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_totalMemory            },
+       { "maxMemory",              "()J",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_maxMemory              },
+       { "gc",                     "()V",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_gc                     },
+       { "runFinalization",        "()V",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_runFinalization        },
+       { "runFinalizersOnExit",    "(Z)V",                                         (void *) (ptrint) &Java_java_lang_VMRuntime_runFinalizersOnExit    },
+       { "runFinalizationForExit", "()V",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_runFinalizationForExit },
+       { "traceInstructions",      "(Z)V",                                         (void *) (ptrint) &Java_java_lang_VMRuntime_traceInstructions      },
+       { "traceMethodCalls",       "(Z)V",                                         (void *) (ptrint) &Java_java_lang_VMRuntime_traceMethodCalls       },
+       { "availableProcessors",    "()I",                                          (void *) (ptrint) &Java_java_lang_VMRuntime_availableProcessors    },
+       { "nativeLoad",             "(Ljava/lang/String;Ljava/lang/ClassLoader;)I", (void *) (ptrint) &Java_java_lang_VMRuntime_nativeLoad             },
+       { "mapLibraryName",         "(Ljava/lang/String;)Ljava/lang/String;",       (void *) (ptrint) &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);
+}
+
+
 /*
  * Class:     java/lang/VMRuntime
  * Method:    exit
index 93804a9bfcd8c6cbf688ed222707c7350f1730b7..d860c2175e1680429fb006c6e48009c60446b150 100644 (file)
@@ -1,6 +1,6 @@
-/* native/vm/VMString.c - java/lang/VMString
+/* src/native/vm/gnu/java_lang_VMString.c - java/lang/VMString
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Christian Thalinger
-
-   $Id: java_lang_VMString.c 6213 2006-12-18 17:36:06Z twisti $
+   $Id: java_lang_VMString.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 
+#include "config.h"
+
 #include <stdlib.h>
 
 #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
@@ -50,7 +73,7 @@ JNIEXPORT java_lang_String* JNICALL Java_java_lang_VMString_intern(JNIEnv *env,
 {
        java_objectheader *o;
 
-       if (!str)
+       if (str == NULL)
                return NULL;
 
        /* search table so identical strings will get identical pointers */
index 677fe1b551e9a55a8ffc863cecf99e7657d521f0..1b13f7ffe9283c8814a623c1d8001d2564e71909 100644 (file)
@@ -1,6 +1,6 @@
-/* src/native/vm/VMSystem.c - java/lang/VMSystem
+/* src/native/vm/gnu/java_lang_VMSystem.c - java/lang/VMSystem
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_VMSystem.c 7399 2007-02-23 23:29:13Z michi $
+   $Id: java_lang_VMSystem.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #include "mm/gc-common.h"
 
 #include "native/jni.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 *) (ptrint) &Java_java_lang_VMSystem_arraycopy },
+       { "identityHashCode", "(Ljava/lang/Object;)I",                      (void *) (ptrint) &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
index 765960d92c233ae5be0d9dacbf1c96d46005a7e9..2925e5a8ae0bc254a952f2093de838e6ac10363e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMThread.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: java_lang_VMThread.c 7912 2007-05-18 13:12:09Z twisti $
 
 */
 
 
 #include "native/jni.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_Thread.h"
+
+#include "native/include/java_lang_VMThread.h"
+
 #include "native/vm/java_lang_Thread.h"
 
 #if defined(ENABLE_THREADS)
 #endif
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "countStackFrames",  "()I",                      (void *) (ptrint) &Java_java_lang_VMThread_countStackFrames  },
+       { "start",             "(J)V",                     (void *) (ptrint) &Java_java_lang_VMThread_start             },
+       { "interrupt",         "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_interrupt         },
+       { "isInterrupted",     "()Z",                      (void *) (ptrint) &Java_java_lang_VMThread_isInterrupted     },
+       { "suspend",           "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_suspend           },
+       { "resume",            "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_resume            },
+       { "nativeSetPriority", "(I)V",                     (void *) (ptrint) &Java_java_lang_VMThread_nativeSetPriority },
+       { "nativeStop",        "(Ljava/lang/Throwable;)V", (void *) (ptrint) &Java_java_lang_VMThread_nativeStop        },
+       { "currentThread",     "()Ljava/lang/Thread;",     (void *) (ptrint) &Java_java_lang_VMThread_currentThread     },
+       { "yield",             "()V",                      (void *) (ptrint) &Java_java_lang_VMThread_yield             },
+       { "interrupted",       "()Z",                      (void *) (ptrint) &Java_java_lang_VMThread_interrupted       },
+       { "holdsLock",         "(Ljava/lang/Object;)Z",    (void *) (ptrint) &Java_java_lang_VMThread_holdsLock         },
+       { "getState",          "()Ljava/lang/String;",     (void *) (ptrint) &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
@@ -124,7 +163,7 @@ JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeSetPriority(JNIEnv *env, ja
 /*
  * Class:     java/lang/VMThread
  * Method:    nativeStop
- * Signature: (Ljava/lang/Object;)V
+ * Signature: (Ljava/lang/Throwable;)V
  */
 JNIEXPORT void JNICALL Java_java_lang_VMThread_nativeStop(JNIEnv *env, java_lang_VMThread *this, java_lang_Throwable *t)
 {
index d70d4b78474f5ddc3a13b26ee70bdc2f88bcdd4d..feb5fa25a36b870b168257d4a98f4492499a3f8b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMThrowable.c 7720 2007-04-16 15:49:09Z twisti $
+   $Id: java_lang_VMThrowable.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 
 #include "native/jni.h"
 #include "native/native.h"
+
 #include "native/include/gnu_classpath_Pointer.h"
 #include "native/include/java_lang_Class.h"
 #include "native/include/java_lang_StackTraceElement.h"
 #include "native/include/java_lang_Throwable.h"
+
 #include "native/include/java_lang_VMThrowable.h"
 
 #include "native/vm/java_lang_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
index 54b902447d0239bb43bb9908f3d48e1edebe17b7..e4e78fa0b96d117555b28cae7c2f8fdc9582f152 100644 (file)
@@ -34,6 +34,9 @@
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_lang_management_VMManagementFactory.h"
 
 #include "toolbox/logging.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);
+}
+
+
 /*
  * Class:     java/lang/management/VMManagementFactory
  * Method:    getMemoryPoolNames
index f13cde7e5d6da5eb8384dace83899e99988ce233..15ebe09418653870f5e53fdbb45395d06f6ede3b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Constructor.c 7720 2007-04-16 15:49:09Z twisti $
+   $Id: java_lang_reflect_Constructor.c 7912 2007-05-18 13:12:09Z twisti $
 
 */
 
 
 #include "native/jni.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"
+
 #include "native/include/java_lang_reflect_Constructor.h"
 
 #include "toolbox/logging.h"
 #include "vmcore/method.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getModifiersInternal", "()I",                                                       (void *) (ptrint) &Java_java_lang_reflect_Constructor_getModifiersInternal },
+       { "getParameterTypes",    "()[Ljava/lang/Class;",                                      (void *) (ptrint) &Java_java_lang_reflect_Constructor_getParameterTypes    },
+       { "getExceptionTypes",    "()[Ljava/lang/Class;",                                      (void *) (ptrint) &Java_java_lang_reflect_Constructor_getExceptionTypes    },
+       { "constructNative",      "([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Constructor_constructNative      },
+       { "getSignature",         "()Ljava/lang/String;",                                      (void *) (ptrint) &Java_java_lang_reflect_Constructor_getSignature         },
+};
+
+
+/* _Jv_java_lang_reflect_Constructor_init **************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_Constructor_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/Constructor");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
 /*
  * Class:     java/lang/reflect/Constructor
  * Method:    getModifiersInternal
@@ -106,7 +135,7 @@ JNIEXPORT java_objectarray* JNICALL Java_java_lang_reflect_Constructor_getExcept
 /*
  * Class:     java/lang/reflect/Constructor
  * Method:    constructNative
- * Signature: ([Ljava/lang/Object;)Ljava/lang/Object;
+ * Signature: ([Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;
  */
 JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Constructor_constructNative(JNIEnv *env, java_lang_reflect_Constructor *this, java_objectarray *args, java_lang_Class *declaringClass, s4 slot)
 {
index fb340072669f8785ce03e2fd1872fbd612894c11..b150381b4b9ff1d10ecf2a5fa1bd71d40fbacbef 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Field.c 7720 2007-04-16 15:49:09Z twisti $
+   $Id: java_lang_reflect_Field.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
@@ -35,6 +35,7 @@
 
 #include "native/jni.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"
@@ -46,6 +47,7 @@
 #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 "vm/access.h"
 #include "vmcore/utf8.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getModifiersInternal", "()I",                                     (void *) (ptrint) &Java_java_lang_reflect_Field_getModifiersInternal },
+       { "getType",              "()Ljava/lang/Class;",                     (void *) (ptrint) &Java_java_lang_reflect_Field_getType              },
+       { "get",                  "(Ljava/lang/Object;)Ljava/lang/Object;",  (void *) (ptrint) &Java_java_lang_reflect_Field_get                  },
+       { "getBoolean",           "(Ljava/lang/Object;)Z",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getBoolean           },
+       { "getByte",              "(Ljava/lang/Object;)B",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getByte              },
+       { "getChar",              "(Ljava/lang/Object;)C",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getChar              },
+       { "getShort",             "(Ljava/lang/Object;)S",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getShort             },
+       { "getInt",               "(Ljava/lang/Object;)I",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getInt               },
+       { "getLong",              "(Ljava/lang/Object;)J",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getLong              },
+       { "getFloat",             "(Ljava/lang/Object;)F",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getFloat             },
+       { "getDouble",            "(Ljava/lang/Object;)D",                   (void *) (ptrint) &Java_java_lang_reflect_Field_getDouble            },
+       { "set",                  "(Ljava/lang/Object;Ljava/lang/Object;)V", (void *) (ptrint) &Java_java_lang_reflect_Field_set                  },
+       { "setBoolean",           "(Ljava/lang/Object;Z)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setBoolean           },
+       { "setByte",              "(Ljava/lang/Object;B)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setByte              },
+       { "setChar",              "(Ljava/lang/Object;C)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setChar              },
+       { "setShort",             "(Ljava/lang/Object;S)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setShort             },
+       { "setInt",               "(Ljava/lang/Object;I)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setInt               },
+       { "setLong",              "(Ljava/lang/Object;J)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setLong              },
+       { "setFloat",             "(Ljava/lang/Object;F)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setFloat             },
+       { "setDouble",            "(Ljava/lang/Object;D)V",                  (void *) (ptrint) &Java_java_lang_reflect_Field_setDouble            },
+       { "getSignature",         "()Ljava/lang/String;",                    (void *) (ptrint) &Java_java_lang_reflect_Field_getSignature         },
+};
+
+
+/* _Jv_java_lang_reflect_Field_init ********************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_Field_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/Field");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
 /* cacao_get_field_address *****************************************************
 
    Return the address of a field of an object.
index 026d570933eeadb9e0e6b24c1369627982576845..f67512682ca7b92e492db87a7d7d9a1dcb668134 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_reflect_Method.c 7719 2007-04-16 15:29:29Z twisti $
+   $Id: java_lang_reflect_Method.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 
 #include "native/jni.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_reflect_Method.h"
 
 #include "vm/access.h"
 #include "vm/stringlocal.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "getModifiersInternal", "()I",                                                                         (void *) (ptrint) &Java_java_lang_reflect_Method_getModifiersInternal },
+       { "getReturnType",        "()Ljava/lang/Class;",                                                         (void *) (ptrint) &Java_java_lang_reflect_Method_getReturnType        },
+       { "getParameterTypes",    "()[Ljava/lang/Class;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getParameterTypes    },
+       { "getExceptionTypes",    "()[Ljava/lang/Class;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getExceptionTypes    },
+       { "invokeNative",         "(Ljava/lang/Object;[Ljava/lang/Object;Ljava/lang/Class;I)Ljava/lang/Object;", (void *) (ptrint) &Java_java_lang_reflect_Method_invokeNative         },
+       { "getSignature",         "()Ljava/lang/String;",                                                        (void *) (ptrint) &Java_java_lang_reflect_Method_getSignature         },
+};
+
+
+/* _Jv_java_lang_reflect_Method_init *******************************************
+
+   Register native functions.
+
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_Method_init(void)
+{
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/Method");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
+
+
 /*
  * Class:     java/lang/reflect/Method
  * Method:    getModifiersInternal
index 2f96606419512fa38f8e2b2931edeb30c42d8267..2fb8eaf7f061b6c4a945517544a75e7b3c7c3008 100644 (file)
@@ -1,6 +1,6 @@
-/* src/native/vm/VMProxy.c - java/lang/reflect/VMProxy
+/* src/native/vm/gnu/java_lang_reflect_VMProxy.c - java/lang/reflect/VMProxy
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Roman Obermaiser
-
-   Changes: Joseph Wenninger
-            Christian Thalinger
-
-   $Id: java_lang_reflect_VMProxy.c 6213 2006-12-18 17:36:06Z twisti $
+   $Id: java_lang_reflect_VMProxy.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
 
+#include "config.h"
+
 #include <stdlib.h>
 
 #include "native/jni.h"
+#include "native/native.h"
+
 #include "native/include/java_lang_Class.h"
 #include "native/include/java_lang_ClassLoader.h"
-#include "toolbox/logging.h"
 
+#include "native/include/java_lang_reflect_VMProxy.h"
+
+
+/* native methods implemented by this file ************************************/
+
+#if 0
+static JNINativeMethod methods[] = {
+       { "getProxyClass",      "(Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/Class;",                   (void *) (ptrint) &Java_java_lang_reflect_VMProxy_getProxyClass      },
+       { "getProxyData",       "(Ljava/lang/ClassLoader;[Ljava/lang/Class;)Ljava/lang/reflect/Proxy$ProxyData;", (void *) (ptrint) &Java_java_lang_reflect_VMProxy_getProxyData       },
+       { "generateProxyClass", "(Ljava/lang/ClassLoader;Ljava/lang/reflect/Proxy$ProxyData;)Ljava/lang/Class;",  (void *) (ptrint) &Java_java_lang_reflect_VMProxy_generateProxyClass },
+};
+#endif
+
+
+/* _Jv_java_lang_reflect_VMProxy_init ******************************************
+
+   Register native functions.
 
+*******************************************************************************/
+
+void _Jv_java_lang_reflect_VMProxy_init(void)
+{
+#if 0
+       utf *u;
+
+       u = utf_new_char("java/lang/reflect/VMProxy");
+
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+#endif
+}
+
+
+#if 0
 /*
  * Class:     java/lang/reflect/VMProxy
  * Method:    getProxyClass
@@ -49,8 +77,6 @@
  */
 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_getProxyClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, java_objectarray *par2)
 {
-       log_text("Java_java_lang_reflect_Proxy_getProxyClass: IMPLEMENT ME!");
-
        return NULL;
 }
 
@@ -62,8 +88,6 @@ JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_getProxyClass(
  */
 JNIEXPORT struct java_lang_reflect_Proxy_ProxyData* JNICALL Java_java_lang_reflect_VMProxy_getProxyData(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, java_objectarray *par2)
 {
-       log_text("Java_java_lang_reflect_Proxy_getProxyData: IMPLEMENT ME!");
-
        return NULL;
 }
 
@@ -75,10 +99,9 @@ JNIEXPORT struct java_lang_reflect_Proxy_ProxyData* JNICALL Java_java_lang_refle
  */
 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_reflect_VMProxy_generateProxyClass(JNIEnv *env, jclass clazz, java_lang_ClassLoader *par1, struct java_lang_reflect_Proxy_ProxyData *par2)
 {
-       log_text("Java_java_lang_reflect_Proxy_generateProxyClass: IMPLEMENT ME!");
-
        return NULL;
 }
+#endif
 
 
 /*
index 43f6bd55bb48363f31708a276be33f50f0550eff..47dfe6cdfbccfa11a4ba6ac52d90cbbb18cce2e9 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_security_VMAccessController.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: java_security_VMAccessController.c 7910 2007-05-16 08:02:52Z twisti $
 
 */
 
@@ -31,6 +31,9 @@
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/native.h"
+
+#include "native/include/java_security_VMAccessController.h"
 
 #include "vm/builtin.h"
 
 #include "vmcore/options.h"
 
 
-/*
- * Class:     java/security/VMAccessController
- * Method:    getStack
- * Signature: ()[[Ljava/lang/Object;
- */
-JNIEXPORT java_objectarray* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz) {
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__I386__) || defined(__MIPS__) || defined(__POWERPC__) || defined (__X86_64__)
-       /* these JITs support stacktraces */
+/* native methods implemented by this file ************************************/
 
-       return stacktrace_getStack();
+static JNINativeMethod methods[] = {
+       { "getStack", "()[[Ljava/lang/Object;", (void *) (ptrint) &Java_java_security_VMAccessController_getStack },
+};
 
-#else
-# if defined(ENABLE_INTRP)
-       /* the interpreter supports stacktraces, even if the JIT does not */
 
-       if (opt_intrp) {
-               return stacktrace_getStack();
+/* _Jv_java_security_VMAccessController_init ***********************************
 
-       } else
-# endif
-               {
-                       java_objectarray *result;
-                       java_objectarray *classes;
-                       java_objectarray *methodnames;
+   Register native functions.
 
-                       if (!(result = builtin_anewarray(2, arrayclass_java_lang_Object)))
-                               return NULL;
+*******************************************************************************/
 
-                       if (!(classes = builtin_anewarray(0, class_java_lang_Class)))
-                               return NULL;
+void _Jv_java_security_VMAccessController_init(void)
+{
+       utf *u;
 
-                       if (!(methodnames = builtin_anewarray(0, class_java_lang_String)))
-                               return NULL;
+       u = utf_new_char("java/security/VMAccessController");
 
-                       result->data[0] = (java_objectheader *) classes;
-                       result->data[1] = (java_objectheader *) methodnames;
+       native_method_register(u, methods, NATIVE_METHODS_COUNT);
+}
 
-                       return result;
-               }
-#endif
+
+/*
+ * Class:     java/security/VMAccessController
+ * Method:    getStack
+ * Signature: ()[[Ljava/lang/Object;
+ */
+JNIEXPORT java_objectarray* JNICALL Java_java_security_VMAccessController_getStack(JNIEnv *env, jclass clazz)
+{
+       return stacktrace_getStack();
 }
 
 
index 73a74a16629ca12c2c4e0d7d4d50077bacd60e05..c11b112bb9c6be4f23978b6cee5c2988689bb13d 100644 (file)
 #include "vm/types.h"
 
 #include "native/jni.h"
+#include "native/native.h"
+
 #include "native/include/java_lang_Object.h"
 #include "native/include/java_lang_reflect_Field.h"
-#include "native/include/java_lang_Thread.h" /* required by sun_misc_Unsafe.h */
+#include "native/include/java_lang_Thread.h"             /* required by s.m.U */
+
 #include "native/include/sun_misc_Unsafe.h"
 
 
+/* native methods implemented by this file ************************************/
+
+static JNINativeMethod methods[] = {
+       { "objectFieldOffset",    "(Ljava/lang/reflect/Field;)J",                               (void *) (ptrint) &Java_sun_misc_Unsafe_objectFieldOffset    },
+       { "compareAndSwapInt",    "(Ljava/lang/Object;JII)Z",                                   (void *) (ptrint) &Java_sun_misc_Unsafe_compareAndSwapInt    },
+#if 0
+       { "compareAndSwapLong",   "(Ljava/lang/Object;JJJ)Z",                                   (void *) (ptrint) &Java_sun_misc_Unsafe_compareAndSwapLong   },
+       { "compareAndSwapObject", "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z", (void *) (ptrint) &Java_sun_misc_Unsafe_compareAndSwapObject },
+       { "putOrderedInt",        "(Ljava/lang/Object;JI)V",                                    (void *) (ptrint) &Java_sun_misc_Unsafe_putOrderedInt        },
+       { "putOrderedLong",       "(Ljava/lang/Object;JJ)V",                                    (void *) (ptrint) &Java_sun_misc_Unsafe_putOrderedLong       },
+       { "putOrderedObject",     "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (ptrint) &Java_sun_misc_Unsafe_putOrderedObject     },
+       { "putIntVolatile",       "(Ljava/lang/Object;JI)V",                                    (void *) (ptrint) &Java_sun_misc_Unsafe_putIntVolatile       },
+       { "getIntVolatile",       "(Ljava/lang/Object;J)I",                                     (void *) (ptrint) &Java_sun_misc_Unsafe_getIntVolatile       },
+       { "putLongVolatile",      "(Ljava/lang/Object;JJ)V",                                    (void *) (ptrint) &Java_sun_misc_Unsafe_putLongVolatile      },
+       { "putLong",              "(Ljava/lang/Object;JJ)V",                                    (void *) (ptrint) &Java_sun_misc_Unsafe_putLong              },
+       { "getLongVolatile",      "(Ljava/lang/Object;J)J",                                     (void *) (ptrint) &Java_sun_misc_Unsafe_getLongVolatile      },
+       { "getLong",              "(Ljava/lang/Object;J)J",                                     (void *) (ptrint) &Java_sun_misc_Unsafe_getLong              },
+       { "putObjectVolatile",    "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (ptrint) &Java_sun_misc_Unsafe_putObjectVolatile    },
+       { "putObject",            "(Ljava/lang/Object;JLjava/lang/Object;)V",                   (void *) (ptrint) &Java_sun_misc_Unsafe_putObject            },
+       { "getObjectVolatile",    "(Ljava/lang/Object;J)Ljava/lang/Object;",                    (void *) (ptrint) &Java_sun_misc_Unsafe_getObjectVolatile    },
+       { "arrayBaseOffset",      "(Ljava/lang/Class;)I",                                       (void *) (ptrint) &Java_sun_misc_Unsafe_arrayBaseOffset      },
+       { "arrayIndexScale",      "(Ljava/lang/Class;)I",                                       (void *) (ptrint) &Java_sun_misc_Unsafe_arrayIndexScale      },
+       { "unpark",               "(Ljava/lang/Thread;)V",                                      (void *) (ptrint) &Java_sun_misc_Unsafe_unpark               },
+       { "park",                 "(ZJ)V",                                                      (void *) (ptrint) &Java_sun_misc_Unsafe_park                 },
+#endif
+};
+
+
+/* _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:    objectFieldOffset
index 83f5f7570552969bb057467804e64f31284d9fe6..adadd0d0be95e9de84fa6abe5b779cc40170a863 100644 (file)
@@ -47,9 +47,7 @@
 
 #include "native/include/java_lang_Object.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 
index bb52a4d1a5b6febe51b90303ec1dc81236a0a704..0447d448a5817c2620e747ff20e3a28686c793a6 100644 (file)
@@ -134,26 +134,22 @@ s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, java_objectheade
 
        /* is the library already loaded? */
 
-       if (native_hashtable_library_find(name, cl))
+       if (native_library_find(name, cl) != NULL)
                return 1;
 
-       /* try to open the library */
+       /* open the library */
 
-       if (!(handle = lt_dlopen(name->text))) {
-               if (opt_verbose) {
-                       log_start();
-                       log_print("_Jv_java_lang_Runtime_loadLibrary: ");
-                       log_print(lt_dlerror());
-                       log_finish();
-               }
+       handle = native_library_open(name);
 
+       if (handle == NULL)
                return 0;
-       }
 
 # if defined(ENABLE_JNI)
        /* resolve JNI_OnLoad function */
 
-       if ((onload = lt_dlsym(handle, "JNI_OnLoad"))) {
+       onload = lt_dlsym(handle, "JNI_OnLoad");
+
+       if (onload != NULL) {
                JNIEXPORT s4 (JNICALL *JNI_OnLoad) (JavaVM *, void *);
                JavaVM *vm;
 
@@ -175,7 +171,7 @@ s4 _Jv_java_lang_Runtime_loadLibrary(java_lang_String *libname, java_objectheade
 
        /* insert the library name into the library hash */
 
-       native_hashtable_library_add(name, cl, handle);
+       native_library_add(name, cl, handle);
 
        return 1;
 #endif /* defined(WITH_STATIC_CLASSPATH) */
index aeba0e8ec163f9b1fe3957c69d4d33a941b28c62..b13766677071e14210c201dd3f5b2217531ac86b 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: java_lang_VMThread.c 6213 2006-12-18 17:36:06Z twisti $
+   $Id: java_lang_Thread.c 7833 2007-04-26 13:07:05Z twisti $
 
 */
 
@@ -43,6 +43,7 @@
 # include "native/include/java_lang_VMThread.h"
 #endif
 
+#include "threads/lock-common.h"
 #include "threads/threads-common.h"
 
 #include "toolbox/logging.h"
@@ -88,7 +89,7 @@ void _Jv_java_lang_Thread_sleep(s8 millis)
 void _Jv_java_lang_Thread_start(java_lang_Thread *this, s8 stacksize)
 {
 #if defined(ENABLE_THREADS)
-       threads_start_javathread(this);
+       threads_thread_start(this);
 #endif
 }
 
index cccbca696f87a04136a3106baca6ca302493108b..8cc76c33daeef5b2e7b52d29f05484bd52e4a082 100644 (file)
@@ -47,8 +47,6 @@
 # include "native/include/java_lang_VMThread.h"
 #endif
 
-#include "threads/native/threads.h"
-
 
 /* function prototypes ********************************************************/
 
diff --git a/src/scripts/.cvsignore b/src/scripts/.cvsignore
deleted file mode 100644 (file)
index dfd259f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-java
diff --git a/src/threads/.cvsignore b/src/threads/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 412c3f5bf20ffe7fb4816b9c8beba527c70b79a9..f8e34c8d0671ff001c8380ebe1b561dfe9dabbf4 100644 (file)
@@ -22,7 +22,7 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 7365 2007-02-15 19:42:13Z twisti $
+## $Id: Makefile.am 7813 2007-04-25 19:20:13Z twisti $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -46,6 +46,7 @@ noinst_LTLIBRARIES = \
 libthreads_la_SOURCES = \
        critical.c \
        critical.h \
+       lock-common.h \
        threads-common.c \
        threads-common.h
 
index ab69fce052721a22186563dfab23d383d8f069f3..a0d459561cd3dfb34687ac45b48e2fa63bc33567 100644 (file)
 
 /* the AVL tree containing the critical sections */
 
-static avl_tree *criticaltree;
+static avl_tree_t *criticaltree;
 
 
 /* prototypes *****************************************************************/
 
-static s4 critical_compare(const void *pa, const void *pb);
+static s4 critical_comparator(const void *treenode, const void *node);
 static void critical_register_asm_critical_sections(void);
 
 
@@ -59,110 +59,69 @@ static void critical_register_asm_critical_sections(void);
 
 void critical_init(void)
 {
-    criticaltree = avl_create(&critical_compare);
+    criticaltree = avl_create(&critical_comparator);
 
        critical_register_asm_critical_sections();
 }
 
 
-/* critical_compare ************************************************************
+/* critical_comparator *********************************************************
 
    Comparison function for AVL tree of critical section.
 
    IN:
-       pa...............first node
-          pb...............second node
+       treenode....node in the tree
+          node........node to compare with tree-node
 
    RETURN VALUE:
        -1, 0, +1 for (pa <, ==, > pb)
 
 *******************************************************************************/
 
-static s4 critical_compare(const void *pa, const void *pb)
+static s4 critical_comparator(const void *treenode, const void *node)
 {
-       const critical_section_node_t *na = pa;
-       const critical_section_node_t *nb = pb;
-
-       if (na->mcodebegin < nb->mcodebegin)
-               return -1;
-       if (na->mcodebegin > nb->mcodebegin)
-               return 1;
-       return 0;
-}
+       const critical_section_node_t *treecsn;
+       const critical_section_node_t *csn;
 
+       treecsn = treenode;
+       csn     = node;
 
-/* critical_find ***************************************************************
-   Find the critical region the given pc is in.
+       /* compare for avl_find if we have found an entry */
 
-   IN:
-       mcodeptr.........PC
+       if ((treecsn->start <= csn->start) && (csn->start < treecsn->end))
+               return 0;
 
-   OUT:
-       pointer to critical region node, or
-          NULL if critical region was not found.
-   
-*******************************************************************************/
+       /* these are for walking the tree */
 
-static const critical_section_node_t *critical_find(u1 *mcodeptr)
-{
-    avl_node *n;
-    const critical_section_node_t *m;
-
-    n = criticaltree->root;
-       m = NULL;
-
-    if (!n)
-        return NULL;
-
-    for (;;) {
-        const critical_section_node_t *d = n->data;
-
-        if (mcodeptr == d->mcodebegin)
-            return d;
-
-        if (mcodeptr < d->mcodebegin) {
-            if (n->childs[0]) {
-                n = n->childs[0];
-                       }
-            else {
-                return m;
-                       }
-        }
-               else {
-            if (n->childs[1]) {
-                m = n->data;
-                n = n->childs[1];
-            }
-                       else {
-                return n->data;
-                       }
-        }
-    }
+       if (treecsn->start < csn->start)
+               return -1;
+       else
+               return 1;
 }
 
 
-/* critical_register_critical_section ******************************************
+/* critical_section_register ***************************************************
  
    Register a critical section.
 
    IN:
-       n................node for the critical section
+       csn....node for the critical section
 
 *******************************************************************************/
 
-void critical_register_critical_section(critical_section_node_t *n)
+void critical_section_register(critical_section_node_t *csn)
 {
-       (void) avl_insert(criticaltree, n);
+       (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.
+   Find a restart point for the given PC, in case it is in a critical
+   section.
 
    IN:
-       mcodeptr.........PC
+       pc.........PC
 
    OUT:
        PC of the restart point, or
@@ -170,12 +129,23 @@ void critical_register_critical_section(critical_section_node_t *n)
 
 *******************************************************************************/
 
-u1 *critical_find_restart_point(u1 *mcodeptr)
+u1 *critical_find_restart_point(u1 *pc)
 {
-       const critical_section_node_t *n = critical_find(mcodeptr);
+       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;
 
-       /* XXX should we check >= n->mcodebegin */
-       return (n && mcodeptr < n->mcodeend && mcodeptr > n->mcodebegin) ? n->mcoderestart : NULL;
+       return csn->restart;
 }
 
 
@@ -191,8 +161,8 @@ static void critical_register_asm_critical_sections(void)
 #if defined(ENABLE_JIT) && defined(ENABLE_THREADS)
        critical_section_node_t *n = &asm_criticalsections;
 
-       while (n->mcodebegin)
-               critical_register_critical_section(n++);
+       while (n->start)
+               critical_section_register(n++);
 #endif
 }
 
index 378e78356fdfb32727ad5b9b0e9be39f3e9dd729..7bfcb1197e5fa50307c3b45aa708e1154546af59 100644 (file)
@@ -52,27 +52,26 @@ typedef struct critical_section_node_t critical_section_node_t;
 
    A node representing a restartable critical section.
 
+   CAUTION: This order must not be changed, it is used in
+            asm_criticalsections!
+
 *******************************************************************************/
 
-/* CAUTION: This must not be changed, it is used in asm_criticalsections!     */
 struct critical_section_node_t {
-       u1 *mcodebegin;
-       u1 *mcodeend;
-       u1 *mcoderestart;
+       u1 *start;
+       u1 *end;
+       u1 *restart;
 };
 
 
 /* functions ******************************************************************/
 
-void critical_init(void);
-
-void critical_register_critical_section(critical_section_node_t *);
-
-u1 *critical_find_restart_point(u1*);
+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) */
-/* XXX should be renamed to md_restart_critical_section                   */
-void thread_restartcriticalsection(ucontext_t *);
+void  md_critical_section_restart(ucontext_t *_uc);
 
 #endif /* _CRITICAL_H */
 
diff --git a/src/threads/native/.cvsignore b/src/threads/native/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index a6078339f7da4834877cb3b7ffd3688ea54d4375..9e9636581e0e8b4830e3ffd36d6643665aaaca91 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "vm/global.h"
 #include "vm/exceptions.h"
+#include "vm/finalizer.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
 
 #include "native/jvmti/cacaodbg.h"
 #endif
 
+#if defined(ENABLE_GC_BOEHM)
+# include "mm/boehm-gc/include/gc.h"
+#endif
+
 
 /******************************************************************************/
 /* DEBUGGING MACROS                                                           */
 #define LOCK_WORD_WITHOUT_COUNT(lockword) ((lockword) & ~THIN_LOCK_COUNT_MASK)
 
 
-/******************************************************************************/
-/* GLOBAL VARIABLES                                                           */
-/******************************************************************************/
-
-/* global lock record pool list header */
-lock_record_pool_t *lock_global_pool;
-
-/* mutex for synchronizing access to the global pool */
-pthread_mutex_t lock_global_pool_lock;
+/* global variables ***********************************************************/
 
 /* hashtable mapping objects to lock records */
 static lock_hashtable_t lock_hashtable;
@@ -200,9 +197,6 @@ static lock_hashtable_t lock_hashtable;
 /******************************************************************************/
 
 static void lock_hashtable_init(void);
-static lock_record_t * lock_hashtable_get_lock_record(threadobject *t, java_objectheader *o);
-
-static lock_record_t * lock_record_alloc(threadobject *t);
 
 static void lock_record_enter(threadobject *t, lock_record_t *lr);
 static void lock_record_exit(threadobject *t, lock_record_t *lr);
@@ -223,7 +217,7 @@ static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one);
 
 void lock_init(void)
 {
-       pthread_mutex_init(&lock_global_pool_lock, NULL);
+       /* initialize lock hashtable */
 
        lock_hashtable_init();
 
@@ -233,48 +227,6 @@ void lock_init(void)
 }
 
 
-/* lock_record_init ************************************************************
-
-   Initialize a lock record.
-
-   IN:
-      r............the lock record to initialize
-         t............will become the owner
-
-*******************************************************************************/
-
-static void lock_record_init(lock_record_t *r, threadobject *t)
-{
-       r->owner = NULL;
-       r->count = 0;
-       r->waiters = NULL;
-
-#if !defined(NDEBUG)
-       r->nextfree = NULL;
-#endif
-
-       pthread_mutex_init(&(r->mutex), NULL);
-}
-
-
-/* lock_init_execution_env *****************************************************
-
-   Initialize the execution environment for a thread.
-
-   IN:
-      thread.......the thread
-
-*******************************************************************************/
-
-void lock_init_execution_env(threadobject *thread)
-{
-       thread->ee.firstfree = NULL;
-       thread->ee.lockrecordpools = NULL;
-       thread->ee.lockrecordcount = 0;
-}
-
-
-
 /* lock_pre_compute_thinlock ***************************************************
 
    Pre-compute the thin lock value for a thread index.
@@ -293,227 +245,79 @@ ptrint lock_pre_compute_thinlock(s4 index)
 }
 
 
+/* lock_record_new *************************************************************
 
-/*============================================================================*/
-/* LOCK RECORD MANAGEMENT                                                     */
-/*============================================================================*/
-
-
-/* lock_record_alloc_new_pool **************************************************
-
-   Get a new lock record pool from the memory allocator.
-
-   IN:
-      thread.......the thread that will own the lock records
-         size.........number of lock records in the pool to allocate
-
-   RETURN VALUE:
-      the new lock record pool, with initialized lock records
+   Allocate a lock record.
 
 *******************************************************************************/
 
-static lock_record_pool_t *lock_record_alloc_new_pool(threadobject *thread, int size)
+static lock_record_t *lock_record_new(void)
 {
-       lock_record_pool_t *pool;
-       s4                  i;
+       lock_record_t *lr;
 
-       /* get the pool from the memory allocator */
+       /* allocate the data structure on the C heap */
 
-       pool = mem_alloc(sizeof(lock_record_pool_header_t)
-                                  + sizeof(lock_record_t) * size);
+       lr = NEW(lock_record_t);
 
 #if defined(ENABLE_STATISTICS)
        if (opt_stat)
-               size_lock_record_pool += sizeof(lock_record_pool_header_t) +
-                       sizeof(lock_record_t) * size;
+               size_lock_record += sizeof(lock_record_t);
 #endif
 
-       /* initialize the pool header */
-
-       pool->header.size = size;
+       /* initialize the members */
 
-       /* initialize the individual lock records */
-
-       for (i = 0; i < size; i++) {
-               lock_record_init(&pool->lr[i], thread);
-
-               pool->lr[i].nextfree = &pool->lr[i + 1];
-       }
+       lr->object  = NULL;
+       lr->owner   = NULL;
+       lr->count   = 0;
+       lr->waiters = NULL;
 
-       /* terminate free list */
-
-       pool->lr[i - 1].nextfree = NULL;
-
-       return pool;
-}
-
-
-/* lock_record_alloc_pool ******************************************************
-
-   Allocate a lock record pool. The pool is either taken from the global free
-   list or requested from the memory allocator.
-
-   IN:
-      thread.......the thread that will own the lock records
-         size.........number of lock records in the pool to allocate
-
-   RETURN VALUE:
-      the new lock record pool, with initialized lock records
-
-*******************************************************************************/
-
-static lock_record_pool_t *lock_record_alloc_pool(threadobject *t, int size)
-{
-       pthread_mutex_lock(&lock_global_pool_lock);
+       /* initialize the mutex */
 
-       if (lock_global_pool != NULL) {
-               int i;
-               lock_record_pool_t *pool;
+       pthread_mutex_init(&(lr->mutex), NULL);
 
-               /* pop a pool from the global freelist */
-
-               pool             = lock_global_pool;
-               lock_global_pool = pool->header.next;
-
-               pthread_mutex_unlock(&lock_global_pool_lock);
-
-               /* re-initialize owner and freelist chaining */
-
-               for (i = 0; i < pool->header.size; i++) {
-                       pool->lr[i].owner    = NULL;
-                       pool->lr[i].nextfree = &pool->lr[i + 1];
-               }
-               pool->lr[i - 1].nextfree = NULL;
-
-               return pool;
-       }
-
-       pthread_mutex_unlock(&lock_global_pool_lock);
-
-       /* we have to get a new pool from the allocator */
-
-       return lock_record_alloc_new_pool(t, size);
-}
-
-
-/* lock_record_free_pools ******************************************************
-
-   Free the lock record pools in the given linked list. The pools are inserted
-   into the global freelist.
-
-   IN:
-      pool.........list header
-
-*******************************************************************************/
-
-void lock_record_free_pools(lock_record_pool_t *pool)
-{
-       lock_record_pool_header_t *last;
-
-       assert(false); /* XXX this function does not match the new locking */
-                      /*     algorithm. We must find another way to free  */
-                      /*     unused lock records.                         */
-
-       if (pool == NULL)
-               return;
-
-       pthread_mutex_lock(&lock_global_pool_lock);
-
-       /* find the last pool in the list */
-
-       last = &pool->header;
-
-       while (last->next)
-               last = &last->next->header;
-
-       /* chain it to the lock_global_pool freelist */
-
-       last->next = lock_global_pool;
-
-       /* insert the freed pools into the freelist */
-
-       lock_global_pool = pool;
-
-       pthread_mutex_unlock(&lock_global_pool_lock);
+       return lr;
 }
 
 
-/* lock_record_alloc ***********************************************************
+/* lock_record_free ************************************************************
 
-   Allocate a lock record which is owned by the current thread.
+   Free a lock record.
 
    IN:
-      t............the current thread 
+       lr....lock record to free
 
 *******************************************************************************/
 
-static lock_record_t *lock_record_alloc(threadobject *t)
+static void lock_record_free(lock_record_t *lr)
 {
-       lock_record_t *r;
-
-       assert(t);
-       r = t->ee.firstfree;
-
-       if (!r) {
-               int poolsize;
-               lock_record_pool_t *pool;
-
-               /* get a new pool */
-
-               poolsize = t->ee.lockrecordcount ? t->ee.lockrecordcount * 2
-                                                                                : LOCK_INITIAL_LOCK_RECORDS;
-               pool = lock_record_alloc_pool(t, poolsize);
-
-               /* add it to our per-thread pool list */
+#if 0
+       /* check the members */
 
-               pool->header.next = t->ee.lockrecordpools;
-               t->ee.lockrecordpools = pool;
-               t->ee.lockrecordcount += pool->header.size;
-
-               /* take the first record from the pool */
-               r = &pool->lr[0];
-       }
-
-       /* pop the record from the freelist */
-
-       t->ee.firstfree = r->nextfree;
-#ifndef NDEBUG
-       r->nextfree = NULL; /* in order to find invalid uses of nextfree */
+       lr->object  = o;
+       lr->owner   = NULL;
+       lr->count   = 0;
+       lr->waiters = NULL;
 #endif
 
-       return r;
-}
-
+       /* destroy the mutex */
 
-/* lock_record_recycle *********************************************************
+       pthread_mutex_destroy(&(lr->mutex));
 
-   Recycle the given lock record. It will be inserted in the appropriate
-   free list.
+       /* free the data structure */
 
-   IN:
-      t............the owner
-         r............lock record to recycle
+       FREE(lr, lock_record_t);
 
-*******************************************************************************/
-
-static inline void lock_record_recycle(threadobject *t, lock_record_t *r)
-{
-       assert(t);
-       assert(r);
-       assert(r->owner == NULL);
-       assert(r->nextfree == NULL);
-
-       r->nextfree = t->ee.firstfree;
-       t->ee.firstfree = r;
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_lock_record -= sizeof(lock_record_t);
+#endif
 }
 
 
-
 /*============================================================================*/
 /* HASHTABLE MAPPING OBJECTS TO LOCK RECORDS                                  */
 /*============================================================================*/
 
-
 /* lock_hashtable_init *********************************************************
 
    Initialize the global hashtable mapping objects to lock records.
@@ -581,7 +385,7 @@ static void lock_hashtable_grow(void)
                while (lr) {
                        next = lr->hashlink;
 
-                       h = LOCK_HASH(lr->obj);
+                       h = LOCK_HASH(lr->object);
                        newslot = h % newsize;
 
                        lr->hashlink = newtable[newslot];
@@ -605,31 +409,33 @@ static void lock_hashtable_grow(void)
 }
 
 
-/* lock_hashtable_get_lock_record **********************************************
+/* lock_hashtable_get **********************************************************
 
-   Find the lock record for the given object. If it does not exists, yet,
-   create it and enter it in the hashtable.
+   Find the lock record for the given object.  If it does not exists,
+   yet, create it and enter it in the hashtable.
 
    IN:
-      t.................the current thread
-         o.................the object to look up
+         o....the object to look up
 
    RETURN VALUE:
       the lock record to use for this object
 
 *******************************************************************************/
 
-static lock_record_t *lock_hashtable_get_lock_record(threadobject *t, java_objectheader *o)
+#if defined(ENABLE_GC_BOEHM)
+static void lock_record_finalizer(void *object, void *p);
+#endif
+
+static lock_record_t *lock_hashtable_get(java_objectheader *o)
 {
-       ptrint lockword;
-       u4 slot;
+       ptrint         lockword;
+       u4             slot;
        lock_record_t *lr;
 
        lockword = (ptrint) o->monitorPtr;
 
-       if (IS_FAT_LOCK(lockword)) {
+       if (IS_FAT_LOCK(lockword))
                return GET_FAT_LOCK(lockword);
-       }
 
        /* lock the hashtable */
 
@@ -638,26 +444,33 @@ static lock_record_t *lock_hashtable_get_lock_record(threadobject *t, java_objec
        /* lookup the lock record in the hashtable */
 
        slot = LOCK_HASH(o) % lock_hashtable.size;
-       lr = lock_hashtable.ptr[slot];
-       while (lr) {
-               if (lr->obj == o) {
+       lr   = lock_hashtable.ptr[slot];
+
+       for (; lr != NULL; lr = lr->hashlink) {
+               if (lr->object == o) {
                        pthread_mutex_unlock(&(lock_hashtable.mutex));
                        return lr;
                }
-
-               lr = lr->hashlink;
        }
 
        /* not found, we must create a new one */
 
-       lr = lock_record_alloc(t);
-       lr->obj = o;
+       lr = lock_record_new();
+
+       lr->object = o;
+
+#if defined(ENABLE_GC_BOEHM)
+       /* register new finalizer to clean up the lock record */
+
+       GC_REGISTER_FINALIZER(o, lock_record_finalizer, 0, 0, 0);
+#endif
+
        LOCK_LOG(("thread %d allocated for %p new lr %p\n",
-                       t->index, (void*) o, (void*) lr));
+                         t->index, (void*) o, (void*) lr));
 
        /* enter it in the hashtable */
 
-       lr->hashlink = lock_hashtable.ptr[slot];
+       lr->hashlink             = lock_hashtable.ptr[slot];
        lock_hashtable.ptr[slot] = lr;
        lock_hashtable.entries++;
 
@@ -677,6 +490,102 @@ static lock_record_t *lock_hashtable_get_lock_record(threadobject *t, java_objec
 }
 
 
+/* lock_hashtable_remove *******************************************************
+
+   Remove the lock record for the given object from the hashtable.
+
+   IN:
+       o....the object to look up
+
+*******************************************************************************/
+
+static void lock_hashtable_remove(java_objectheader *o)
+{
+       ptrint         lockword;
+       lock_record_t *lr;
+       u4             slot;
+       lock_record_t *tmplr;
+
+       /* lock the hashtable */
+
+       pthread_mutex_lock(&(lock_hashtable.mutex));
+
+       /* get lock record */
+
+       lockword = (ptrint) o->monitorPtr;
+
+       assert(IS_FAT_LOCK(lockword));
+
+       lr = GET_FAT_LOCK(lockword);
+
+       /* remove the lock-record from the hashtable */
+
+       slot  = LOCK_HASH(o) % lock_hashtable.size;
+       tmplr = lock_hashtable.ptr[slot];
+
+       if (tmplr == lr) {
+               /* special handling if it's the first in the chain */
+
+               lock_hashtable.ptr[slot] = lr->hashlink;
+       }
+       else {
+               for (; tmplr != NULL; tmplr = tmplr->hashlink) {
+                       if (tmplr->hashlink == lr) {
+                               tmplr->hashlink = lr->hashlink;
+                               break;
+                       }
+               }
+
+               assert(tmplr != NULL);
+       }
+
+       /* decrease entry count */
+
+       lock_hashtable.entries--;
+
+       /* unlock the hashtable */
+
+       pthread_mutex_unlock(&(lock_hashtable.mutex));
+}
+
+
+/* lock_record_finalizer *******************************************************
+
+   XXX Remove me for exact GC.
+
+*******************************************************************************/
+
+static void lock_record_finalizer(void *object, void *p)
+{
+       java_objectheader *o;
+       ptrint             lockword;
+       lock_record_t     *lr;
+
+       o = (java_objectheader *) object;
+
+       /* check for a finalizer function */
+
+       if (o->vftbl->class->finalizer != NULL)
+               finalizer_run(object, p);
+
+       /* remove the lock-record entry from the hashtable */
+
+       lock_hashtable_remove(o);
+
+       /* get lock record */
+
+       lockword = (ptrint) o->monitorPtr;
+
+       assert(IS_FAT_LOCK(lockword));
+
+       lr = GET_FAT_LOCK(lockword);
+
+       /* now release the lock record */
+
+       lock_record_free(lr);
+}
+
+
 /*============================================================================*/
 /* OBJECT LOCK INITIALIZATION                                                 */
 /*============================================================================*/
@@ -731,6 +640,7 @@ lock_record_t *lock_get_initial_lock_word(void)
 static inline void lock_record_enter(threadobject *t, lock_record_t *lr)
 {
        pthread_mutex_lock(&(lr->mutex));
+
        lr->owner = t;
 }
 
@@ -828,10 +738,11 @@ static void lock_inflate(threadobject *t, java_objectheader *o, lock_record_t *l
 
 bool lock_monitor_enter(java_objectheader *o)
 {
-       threadobject *t;
+       threadobject  *t;
        /* CAUTION: This code assumes that ptrint is unsigned! */
-       ptrint        lockword;
-       ptrint        thinlock;
+       ptrint         lockword;
+       ptrint         thinlock;
+       lock_record_t *lr;
 
        if (o == NULL) {
                exceptions_throw_nullpointerexception();
@@ -869,11 +780,9 @@ bool lock_monitor_enter(java_objectheader *o)
                        return true;
                }
                else {
-                       lock_record_t *lr;
-
                        /* recursion count overflow */
 
-                       lr = lock_hashtable_get_lock_record(t, o);
+                       lr = lock_hashtable_get(o);
                        lock_record_enter(t, lr);
                        lock_inflate(t, o, lr);
                        lr->count++;
@@ -884,79 +793,80 @@ bool lock_monitor_enter(java_objectheader *o)
 
        /* the lock is either contented or fat */
 
-       {
-               lock_record_t *lr;
-
-               if (IS_FAT_LOCK(lockword)) {
+       if (IS_FAT_LOCK(lockword)) {
 
-                       lr = GET_FAT_LOCK(lockword);
+               lr = GET_FAT_LOCK(lockword);
 
-                       /* check for recursive entering */
-                       if (lr->owner == t) {
-                               lr->count++;
-                               return true;
-                       }
+               /* check for recursive entering */
+               if (lr->owner == t) {
+                       lr->count++;
+                       return true;
+               }
 
-                       /* acquire the mutex of the lock record */
+               /* acquire the mutex of the lock record */
 
-                       lock_record_enter(t, lr);
+               lock_record_enter(t, lr);
 
-                       assert(lr->count == 0);
+               assert(lr->count == 0);
 
-                       return true;
-               }
+               return true;
+       }
 
-               /****** inflation path ******/
+       /****** inflation path ******/
 
-               /* first obtain the lock record for this object */
+       /* first obtain the lock record for this object */
 
-               lr = lock_hashtable_get_lock_record(t, o);
+       lr = lock_hashtable_get(o);
 
 #if defined(ENABLE_JVMTI)
-        /* Monitor Contended Enter */
-               jvmti_MonitorContendedEntering(false, o);
+       /* Monitor Contended Enter */
+       jvmti_MonitorContendedEntering(false, o);
 #endif
-               /* enter the monitor */
 
-               lock_record_enter(t, lr);
+       /* enter the monitor */
 
+       lock_record_enter(t, lr);
 
 #if defined(ENABLE_JVMTI)
-               /* Monitor Contended Entered */
-               jvmti_MonitorContendedEntering(true, o);
+       /* Monitor Contended Entered */
+       jvmti_MonitorContendedEntering(true, o);
 #endif
 
-               /* inflation loop */
+       /* inflation loop */
 
-               while (IS_THIN_LOCK(lockword = (ptrint) o->monitorPtr)) {
-                       /* Set the flat lock contention bit to let the owning thread */
-                       /* know that we want to be notified of unlocking.            */
+       while (IS_THIN_LOCK(lockword = (ptrint) o->monitorPtr)) {
+               /* Set the flat lock contention bit to let the owning thread
+                  know that we want to be notified of unlocking. */
 
-                       LOCK_SET_FLC_BIT(o);
+               LOCK_SET_FLC_BIT(o);
 
-                       LOCK_LOG(("thread %d set flc bit on %p lr %p\n",
-                                       t->index, (void*) o, (void*) lr));
+               LOCK_LOG(("thread %d set flc bit on %p lr %p\n",
+                                 t->index, (void*) o, (void*) lr));
 
-                       /* try to lock the object */
+               /* try to lock the object */
 
-                       if (COMPARE_AND_SWAP_SUCCEEDS(&(o->monitorPtr), THIN_UNLOCKED, thinlock)) {
-                               /* we can inflate the lock ourselves */
-                               LOCK_LOG(("thread %d inflating lock of %p to lr %p\n",
-                                               t->index, (void*) o, (void*) lr));
-                               lock_inflate(t, o, lr);
-                       }
-                       else {
-                               /* wait until another thread sees the flc bit and notifies us of unlocking */
-                               LOCK_LOG(("thread %d waiting for notification on %p lr %p\n",
-                                               t->index, (void*) o, (void*) lr));
-                               lock_record_wait(t, lr, 0, 0);
-                       }
+               if (COMPARE_AND_SWAP_SUCCEEDS(&(o->monitorPtr), THIN_UNLOCKED, thinlock)) {
+                       /* we can inflate the lock ourselves */
+
+                       LOCK_LOG(("thread %d inflating lock of %p to lr %p\n",
+                                         t->index, (void*) o, (void*) lr));
+
+                       lock_inflate(t, o, lr);
                }
+               else {
+                       /* wait until another thread sees the flc bit and notifies
+                          us of unlocking */
 
-               /* we own the inflated lock now */
+                       LOCK_LOG(("thread %d waiting for notification on %p lr %p\n",
+                                         t->index, (void*) o, (void*) lr));
 
-               return true;
+                       lock_record_wait(t, lr, 0, 0);
+               }
        }
+
+       /* we own the inflated lock now */
+
+       return true;
 }
 
 
@@ -1016,7 +926,7 @@ bool lock_monitor_exit(java_objectheader *o)
 
                        /* there has been a contention on this thin lock */
 
-                       lr = lock_hashtable_get_lock_record(t, o);
+                       lr = lock_hashtable_get(o);
 
                        LOCK_LOG(("thread %d for %p got lr %p\n",
                                        t->index, (void*) o, (void*) lr));
@@ -1262,7 +1172,9 @@ static void lock_monitor_wait(threadobject *t, java_objectheader *o, s8 millis,
                }
 
                /* inflate this lock */
-               lr = lock_hashtable_get_lock_record(t, o);
+
+               lr = lock_hashtable_get(o);
+
                lock_record_enter(t, lr);
                lock_inflate(t, o, lr);
        }
@@ -1297,16 +1209,19 @@ static void lock_record_notify(threadobject *t, lock_record_t *lr, bool one)
 
        /* for each waiter: */
 
-       for (waiter = lr->waiters; waiter; waiter = waiter->next) {
+       for (waiter = lr->waiters; waiter != NULL; waiter = waiter->next) {
 
                /* signal the waiting thread */
 
                waitingthread = waiter->waiter;
 
                pthread_mutex_lock(&waitingthread->waitmutex);
+
                if (waitingthread->sleeping)
                        pthread_cond_signal(&waitingthread->waitcond);
+
                waitingthread->signaled = true;
+
                pthread_mutex_unlock(&waitingthread->waitmutex);
 
                /* if we should only wake one, we are done */
@@ -1360,7 +1275,9 @@ static void lock_monitor_notify(threadobject *t, java_objectheader *o, bool one)
                }
 
                /* inflate this lock */
-               lr = lock_hashtable_get_lock_record(t, o);
+
+               lr = lock_hashtable_get(o);
+
                lock_record_enter(t, lr);
                lock_inflate(t, o, lr);
        }
@@ -1391,20 +1308,21 @@ static void lock_monitor_notify(threadobject *t, java_objectheader *o, bool one)
 
 bool lock_is_held_by_current_thread(java_objectheader *o)
 {
-       ptrint        lockword;
-       threadobject *t;
+       threadobject  *t;
+       ptrint         lockword;
+       lock_record_t *lr;
+
+       t = THREADOBJECT;
 
        /* check if we own this monitor */
        /* We don't have to worry about stale values here, as any stale value */
        /* will fail this check.                                              */
 
        lockword = (ptrint) o->monitorPtr;
-       t = THREADOBJECT;
 
        if (IS_FAT_LOCK(lockword)) {
-               lock_record_t *lr;
-
                /* it's a fat lock */
+
                lr = GET_FAT_LOCK(lockword);
 
                return (lr->owner == t);
index abc5a5810147b3fb9ccd4f72e775a95f6f3261a6..54d385dc530307541c6effed96143c272d159418 100644 (file)
 
 /* typedefs *******************************************************************/
 
-typedef struct lock_execution_env_t      lock_execution_env_t;
 typedef struct lock_record_t             lock_record_t;
-typedef struct lock_record_pool_header_t lock_record_pool_header_t;
-typedef struct lock_record_pool_t        lock_record_pool_t;
 typedef struct lock_waiter_t             lock_waiter_t;
 typedef struct lock_hashtable_t          lock_hashtable_t;
 
 
-/* lock_execution_env_t ********************************************************
-
-   Execution environment. Contains the lock record freelist and pools.
-
-*******************************************************************************/
-
-struct lock_execution_env_t {
-       lock_record_t         *firstfree;        /* lock record freelist          */
-       lock_record_pool_t    *lockrecordpools;  /* list of per-thread pools      */
-       int                    lockrecordcount;  /* # of records for this thread  */
-};
-
-
 /* lock_waiter_t ***************************************************************
 
    List node for storing a waiting thread.
@@ -82,12 +66,11 @@ struct lock_waiter_t {
 *******************************************************************************/
 
 struct lock_record_t {
-       java_objectheader   *obj;                /* object for which this lock is */
+       java_objectheader   *object;             /* object for which this lock is */
        struct threadobject *owner;              /* current owner of this monitor */
        s4                   count;              /* recursive lock count          */
        pthread_mutex_t      mutex;              /* mutex for synchronizing       */
        lock_waiter_t       *waiters;            /* list of threads waiting       */
-       lock_record_t       *nextfree;           /* next in free list             */
        lock_record_t       *hashlink;           /* next record in hash chain     */
 };
 
@@ -106,62 +89,13 @@ struct lock_hashtable_t {
 };
 
 
-/* lock_record_pool_header_t ***************************************************
-   Lock records are allocated in pools. Each pool has on of these headers.
-
-*******************************************************************************/
-
-struct lock_record_pool_header_t {
-       lock_record_pool_t *next;                /* next pool                     */
-       int                 size;                /* records in this pool          */
-}; 
-
-
-/* lock_record_pool_t **********************************************************
-   Lock records are allocated in such pools.
-
-*******************************************************************************/
-
-struct lock_record_pool_t {
-       lock_record_pool_header_t header;        /* pool header (see above)       */
-       lock_record_t             lr[1];         /* variable array of records     */
-};
-
-#if defined(ENABLE_JVMTI)
-extern pthread_mutex_t lock_global_pool_lock;
-extern lock_record_pool_t *lock_global_pool;
-#endif
-
-
-/* functions ******************************************************************/
+/* defines ********************************************************************/
 
-void lock_init(void);
-
-void lock_init_execution_env(struct threadobject *thread);
-void lock_record_free_pools(lock_record_pool_t *pool);
-
-void lock_init_object_lock(java_objectheader *);
-lock_record_t *lock_get_initial_lock_word(void);
-
-ptrint lock_pre_compute_thinlock(s4 index);
-
-bool lock_monitor_enter(java_objectheader *);
-bool lock_monitor_exit(java_objectheader *);
-
-#define LOCK_monitor_enter    (functionptr) lock_monitor_enter
-#define LOCK_monitor_exit     (functionptr) lock_monitor_exit
+#define LOCK_INIT_OBJECT_LOCK(o) lock_init_object_lock((java_objectheader *) (o))
 
 #define LOCK_MONITOR_ENTER(o)    lock_monitor_enter((java_objectheader *) (o))
 #define LOCK_MONITOR_EXIT(o)     lock_monitor_exit((java_objectheader *) (o))
 
-bool lock_is_held_by_current_thread(java_objectheader *o);
-
-void lock_wait_for_object(java_objectheader *o, s8 millis, s4 nanos);
-void lock_notify_object(java_objectheader *o);
-void lock_notify_all_object(java_objectheader *o);
-
 #endif /* _LOCK_H */
 
 
index 6a6244a18efcfdbba399761fd988b208ce95f7e9..651ebd720aabdf958e146a4ead6630cd3953503c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: threads.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 # include "native/include/java_lang_VMThread.h"
 #endif
 
+#include "threads/lock-common.h"
 #include "threads/threads-common.h"
 
 #include "threads/native/threads.h"
 
-#include "toolbox/avl.h"
 #include "toolbox/logging.h"
 
 #include "vm/builtin.h"
@@ -189,8 +189,6 @@ static int sem_destroy(sem_t *sem)
 #define STOPWORLD_FROM_GC               1
 #define STOPWORLD_FROM_CLASS_NUMBERING  2
 
-#define THREADS_INITIAL_TABLE_SIZE      8
-
 
 /* startupinfo *****************************************************************
 
@@ -210,22 +208,13 @@ typedef struct {
 
 /* prototypes *****************************************************************/
 
-static void threads_table_init(void);
-static s4 threads_table_add(threadobject *thread);
-static void threads_table_remove(threadobject *thread);
 static void threads_calc_absolute_time(struct timespec *tm, s8 millis, s4 nanos);
 
-#if !defined(NDEBUG) && 0
-static void threads_table_dump(FILE *file);
-#endif
 
 /******************************************************************************/
 /* GLOBAL VARIABLES                                                           */
 /******************************************************************************/
 
-/* the main thread                                                            */
-threadobject *mainthreadobj;
-
 static methodinfo *method_thread_init;
 
 /* the thread object of the current thread                                    */
@@ -237,11 +226,8 @@ __thread threadobject *threads_current_threadobject;
 pthread_key_t threads_current_threadobject_key;
 #endif
 
-/* global threads table                                                       */
-static threads_table_t threads_table;
-
-/* global mutex for changing the thread list                                  */
-static pthread_mutex_t threadlistlock;
+/* global mutex for the threads table */
+static pthread_mutex_t mutex_threads_table;
 
 /* global mutex for stop-the-world                                            */
 static pthread_mutex_t stopworldlock;
@@ -261,8 +247,6 @@ static pthread_mutex_t suspend_ack_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER;
 #endif
 
-static pthread_attr_t threadattr;
-
 /* mutexes used by the fake atomic instructions                               */
 #if defined(USE_FAKE_ATOMIC_INSTRUCTIONS)
 pthread_mutex_t _atomic_add_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -411,7 +395,7 @@ static void threads_cast_darwinstop(void)
                        if (r != KERN_SUCCESS)
                                vm_abort("thread_get_state failed");
 
-                       thread_restartcriticalsection((ucontext_t *) &thread_state);
+                       md_critical_section_restart((ucontext_t *) &thread_state);
 
                        r = thread_set_state(thread, flavor, (natural_t *) &thread_state,
                                                                 thread_state_count);
@@ -456,16 +440,77 @@ static void threads_cast_irixresume(void)
 }
 #endif
 
-#if 0
+#if !defined(DISABLE_GC)
+
+void threads_cast_stopworld(void)
+{
+#if !defined(__DARWIN__) && !defined(__CYGWIN__)
+       int count, i;
+#endif
+
+       lock_stopworld(STOPWORLD_FROM_CLASS_NUMBERING);
+
+       /* lock the threads table */
+
+       threads_table_lock();
+
+#if defined(__DARWIN__)
+       threads_cast_darwinstop();
+#elif defined(__CYGWIN__)
+       /* TODO */
+       assert(0);
+#else
+       /* send all threads the suspend signal */
+
+       threads_cast_sendsignals(GC_signum1());
+
+       /* wait for all threads to suspend (except the current one) */
+
+       count = threads_table_get_threads() - 1;
+
+       for (i = 0; i < count; i++)
+               threads_sem_wait(&suspend_ack);
+#endif
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
+}
+
+void threads_cast_startworld(void)
+{
+       /* lock the threads table */
+
+       threads_table_lock();
+
+#if defined(__DARWIN__)
+       threads_cast_darwinresume();
+#elif defined(__MIPS__)
+       threads_cast_irixresume();
+#elif defined(__CYGWIN__)
+       /* TODO */
+       assert(0);
+#else
+       threads_cast_sendsignals(GC_signum2());
+#endif
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
+
+       unlock_stopworld();
+}
+
+
 #if !defined(__DARWIN__)
-static void threads_sigsuspend_handler(ucontext_t *ctx)
+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)
-       thread_restartcriticalsection(ctx);
+       md_critical_section_restart(_uc);
 #endif
 
        /* Do as Boehm does. On IRIX a condition variable is used for wake-up
@@ -591,46 +636,59 @@ void threads_startworld(void)
 
 *******************************************************************************/
 
-static void threads_set_current_threadobject(threadobject *thread)
+void threads_set_current_threadobject(threadobject *thread)
 {
 #if !defined(HAVE___THREAD)
-       pthread_setspecific(threads_current_threadobject_key, thread);
+       if (pthread_setspecific(threads_current_threadobject_key, thread) != 0)
+               vm_abort("threads_set_current_threadobject: pthread_setspecific failed: %s", strerror(errno));
 #else
        threads_current_threadobject = thread;
 #endif
 }
 
 
-/* threads_init_threadobject **************************************************
+/* threads_impl_thread_new *****************************************************
 
    Initialize implementation fields of a threadobject.
 
    IN:
-      thread............the threadobject
+      t....the threadobject
 
-******************************************************************************/
+*******************************************************************************/
 
-static void threads_init_threadobject(threadobject *thread)
+void threads_impl_thread_new(threadobject *t)
 {
        /* get the pthread id */
 
-       thread->tid = pthread_self();
+       t->tid = pthread_self();
 
-       thread->index = 0;
+       /* initialize the mutex and the condition */
 
-#if defined(ENABLE_GC_CACAO)
-       thread->flags       |= THREAD_FLAG_IN_NATIVE;
-       thread->gc_critical  = false;
-#endif
+       pthread_mutex_init(&(t->waitmutex), NULL);
+       pthread_cond_init(&(t->waitcond), NULL);
+}
 
-       /* TODO destroy all those things */
 
-       pthread_mutex_init(&(thread->waitmutex), NULL);
-       pthread_cond_init(&(thread->waitcond), NULL);
+/* threads_impl_thread_free ****************************************************
 
-       thread->interrupted = false;
-       thread->signaled    = false;
-       thread->sleeping    = false;
+   Cleanup thread stuff.
+
+   IN:
+      t....the threadobject
+
+*******************************************************************************/
+
+void threads_impl_thread_free(threadobject *t)
+{
+       /* destroy the mutex and the condition */
+
+       if (pthread_mutex_destroy(&(t->waitmutex)) != 0)
+               vm_abort("threads_impl_thread_free: pthread_mutex_destroy failed: %s",
+                                strerror(errno));
+
+       if (pthread_cond_destroy(&(t->waitcond)) != 0)
+               vm_abort("threads_impl_thread_free: pthread_cond_destroy failed: %s",
+                                strerror(errno));
 }
 
 
@@ -649,7 +707,7 @@ threadobject *threads_get_current_threadobject(void)
 }
 
 
-/* threads_preinit *************************************************************
+/* threads_impl_preinit ********************************************************
 
    Do some early initialization of stuff required.
 
@@ -658,9 +716,8 @@ threadobject *threads_get_current_threadobject(void)
 
 *******************************************************************************/
 
-void threads_preinit(void)
+void threads_impl_preinit(void)
 {
-       pthread_mutex_init(&threadlistlock, NULL);
        pthread_mutex_init(&stopworldlock, NULL);
 
        /* initialize exit mutex and condition (on exit we join all
@@ -669,34 +726,56 @@ void threads_preinit(void)
        pthread_mutex_init(&mutex_join, NULL);
        pthread_cond_init(&cond_join, NULL);
 
-       mainthreadobj = NEW(threadobject);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_threadobject += sizeof(threadobject);
-#endif
-
-       mainthreadobj->object   = NULL;
-       mainthreadobj->tid      = pthread_self();
-       mainthreadobj->index    = 1;
-       mainthreadobj->thinlock = lock_pre_compute_thinlock(mainthreadobj->index);
-       
 #if !defined(HAVE___THREAD)
        pthread_key_create(&threads_current_threadobject_key, NULL);
 #endif
-       threads_set_current_threadobject(mainthreadobj);
 
        threads_sem_init(&suspend_ack, 0, 0);
+}
+
+
+/* threads_table_lock **********************************************************
+
+   Initialize threads table mutex.
+
+*******************************************************************************/
+
+void threads_impl_table_init(void)
+{
+       pthread_mutex_init(&mutex_threads_table, NULL);
+}
+
+
+/* threads_table_lock **********************************************************
+
+   Enter the threads table mutex.
+
+   NOTE: We need this function as we can't use an internal lock for
+         the threads table because the thread's lock is initialized in
+         threads_table_add (when we have the thread index), but we
+         already need the lock at the entry of the function.
+
+*******************************************************************************/
 
-       /* initialize the threads table */
+void threads_table_lock(void)
+{
+       if (pthread_mutex_lock(&mutex_threads_table) != 0)
+               vm_abort("threads_table_lock: pthread_mutex_lock failed: %s",
+                                strerror(errno));
+}
 
-       threads_table_init();
 
-       /* initialize subsystems */
+/* threads_table_unlock ********************************************************
 
-       lock_init();
+   Leave the threads table mutex.
+
+*******************************************************************************/
 
-       critical_init();
+void threads_table_unlock(void)
+{
+       if (pthread_mutex_unlock(&mutex_threads_table) != 0)
+               vm_abort("threads_table_unlock: pthread_mutex_unlock failed: %s",
+                                strerror(errno));
 }
 
 
@@ -708,33 +787,21 @@ void threads_preinit(void)
 
 bool threads_init(void)
 {
+       threadobject          *mainthread;
        java_objectheader     *threadname;
-       threadobject          *tempthread;
+       java_lang_Thread      *t;
        java_objectheader     *o;
 
 #if defined(ENABLE_JAVASE)
        java_lang_ThreadGroup *threadgroup;
        methodinfo            *m;
-       java_lang_Thread      *t;
 #endif
 
 #if defined(WITH_CLASSPATH_GNU)
        java_lang_VMThread    *vmt;
 #endif
 
-       tempthread = mainthreadobj;
-
-       /* XXX We have to find a new way to free lock records */
-       /*     with the new locking algorithm.                */
-       /* lock_record_free_pools(mainthreadobj->ee.lockrecordpools); */
-
-#if 0
-       /* This is kinda tricky, we grow the java.lang.Thread object so we
-          can keep the execution environment there. No Thread object must
-          have been created at an earlier time. */
-
-       class_java_lang_Thread->instancesize = sizeof(threadobject);
-#endif
+       pthread_attr_t attr;
 
        /* get methods we need in this file */
 
@@ -757,56 +824,28 @@ bool threads_init(void)
        if (method_thread_init == NULL)
                return false;
 
-       /* create a vm internal thread object for the main thread */
-       /* XXX Michi: we do not need to do this here, we could use the one
-              created by threads_preinit() */
-
-#if defined(ENABLE_GC_CACAO)
-       mainthreadobj = NEW(threadobject);
-
-# if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_threadobject += sizeof(threadobject);
-# endif
-#else
-       mainthreadobj = GCNEW(threadobject);
-#endif
+       /* Get the main-thread (NOTE: The main threads is always the first
+          thread in the table). */
 
-       if (mainthreadobj == NULL)
-               return false;
+       mainthread = threads_table_first();
 
        /* create a java.lang.Thread for the main thread */
 
-       mainthreadobj->object = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
+       t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
 
-       if (mainthreadobj->object == NULL)
+       if (t == NULL)
                return false;
 
-       FREE(tempthread, threadobject);
-
-       threads_init_threadobject(mainthreadobj);
-       threads_set_current_threadobject(mainthreadobj);
-       lock_init_execution_env(mainthreadobj);
-
-       /* thread is running */
-
-       mainthreadobj->state = THREAD_STATE_RUNNABLE;
+       /* set the object in the internal data structure */
 
-       mainthreadobj->next = mainthreadobj;
-       mainthreadobj->prev = mainthreadobj;
-
-       threads_table_add(mainthreadobj);
-
-       /* mark main thread as Java thread */
-
-       mainthreadobj->flags = THREAD_FLAG_JAVA;
+       mainthread->object = t;
 
 #if defined(ENABLE_INTRP)
        /* create interpreter stack */
 
        if (opt_intrp) {
                MSET(intrp_main_stack, 0, u1, opt_stacksize);
-               mainthreadobj->_global_sp = (Cell*) (intrp_main_stack + opt_stacksize);
+               mainthread->_global_sp = (Cell*) (intrp_main_stack + opt_stacksize);
        }
 #endif
 
@@ -832,22 +871,22 @@ bool threads_init(void)
 
        /* set the thread */
 
-       vmt->thread = mainthreadobj->object;
-       vmt->vmdata = (java_lang_Object *) mainthreadobj;
+       vmt->thread = t;
+       vmt->vmdata = (java_lang_Object *) mainthread;
 
        /* call java.lang.Thread.<init>(Ljava/lang/VMThread;Ljava/lang/String;IZ)V */
-       o = (java_objectheader *) mainthreadobj->object;
+       o = (java_objectheader *) t;
 
        (void) vm_call_method(method_thread_init, o, vmt, threadname, NORM_PRIORITY,
                                                  false);
 #elif defined(WITH_CLASSPATH_CLDC1_1)
        /* set the thread */
 
-       mainthreadobj->object->vm_thread = (java_lang_Object *) mainthreadobj;
+       t->vm_thread = (java_lang_Object *) mainthread;
 
        /* call public Thread(String name) */
 
-       o = (java_objectheader *) mainthreadobj->object;
+       o = (java_objectheader *) t;
 
        (void) vm_call_method(method_thread_init, o, threadname);
 #endif
@@ -856,7 +895,7 @@ bool threads_init(void)
                return false;
 
 #if defined(ENABLE_JAVASE)
-       mainthreadobj->object->group = threadgroup;
+       t->group = threadgroup;
 
        /* add main thread to java.lang.ThreadGroup */
 
@@ -867,152 +906,35 @@ bool threads_init(void)
                                                                 true);
 
        o = (java_objectheader *) threadgroup;
-       t = mainthreadobj->object;
 
        (void) vm_call_method(m, o, t);
 
        if (*exceptionptr)
                return false;
-
 #endif
 
        threads_set_thread_priority(pthread_self(), NORM_PRIORITY);
 
        /* initialize the thread attribute object */
 
-       if (pthread_attr_init(&threadattr)) {
-               log_println("pthread_attr_init failed: %s", strerror(errno));
-               return false;
-       }
-
-       pthread_attr_setdetachstate(&threadattr, PTHREAD_CREATE_DETACHED);
-
-       /* everything's ok */
-
-       return true;
-}
-
-
-/* threads_table_init *********************************************************
-
-   Initialize the global threads table.
-
-******************************************************************************/
-
-static void threads_table_init(void)
-{
-       s4 size;
-       s4 i;
-
-       size = THREADS_INITIAL_TABLE_SIZE;
-
-       threads_table.size = size;
-       threads_table.table = MNEW(threads_table_entry_t, size);
-
-       /* link the entries in a freelist */
-
-       for (i=0; i<size; ++i) {
-               threads_table.table[i].nextfree = i+1;
-       }
+       if (pthread_attr_init(&attr) != 0)
+               vm_abort("threads_init: pthread_attr_init failed: %s", strerror(errno));
 
-       /* terminate the freelist */
+       if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
+               vm_abort("threads_init: pthread_attr_setdetachstate failed: %s",
+                                strerror(errno));
 
-       threads_table.table[size-1].nextfree = 0; /* index 0 is never free */
-}
-
-
-/* threads_table_add **********************************************************
-
-   Add a thread to the global threads table. The index is entered in the
-   threadobject. The thinlock value for the thread is pre-computed.
-
-   IN:
-      thread............the thread to add
-
-   RETURN VALUE:
-      The table index for the newly added thread. This value has also been
-         entered in the threadobject.
-
-   PRE-CONDITION:
-      The caller must hold the threadlistlock!
-
-******************************************************************************/
-
-static s4 threads_table_add(threadobject *thread)
-{
-       s4 index;
-       s4 oldsize;
-       s4 newsize;
-       s4 i;
-
-       /* table[0] serves as the head of the freelist */
-
-       index = threads_table.table[0].nextfree;
-
-       /* if we got a free index, use it */
-
-       if (index) {
-got_an_index:
-               threads_table.table[0].nextfree = threads_table.table[index].nextfree;
-               threads_table.table[index].thread = thread;
-               thread->index = index;
-               thread->thinlock = lock_pre_compute_thinlock(index);
-               return index;
-       }
-
-       /* we must grow the table */
-
-       oldsize = threads_table.size;
-       newsize = oldsize * 2;
-
-       threads_table.table = MREALLOC(threads_table.table, threads_table_entry_t,
-                                                                  oldsize, newsize);
-       threads_table.size = newsize;
-
-       /* link the new entries to a free list */
-
-       for (i=oldsize; i<newsize; ++i) {
-               threads_table.table[i].nextfree = i+1;
+#if !defined(NDEBUG)
+       if (opt_verbosethreads) {
+               printf("[Starting thread ");
+               threads_thread_print_info(mainthread);
+               printf("]\n");
        }
+#endif
 
-       /* terminate the freelist */
-
-       threads_table.table[newsize-1].nextfree = 0; /* index 0 is never free */
-
-       /* use the first of the new entries */
-
-       index = oldsize;
-       goto got_an_index;
-}
-
-
-/* threads_table_remove *******************************************************
-
-   Remove a thread from the global threads table.
-
-   IN:
-      thread............the thread to remove
-
-   PRE-CONDITION:
-      The caller must hold the threadlistlock!
-
-******************************************************************************/
-
-static void threads_table_remove(threadobject *thread)
-{
-       s4 index;
-
-       index = thread->index;
-
-       /* put the index into the freelist */
-
-       threads_table.table[index] = threads_table.table[0];
-       threads_table.table[0].nextfree = index;
+       /* everything's ok */
 
-       /* delete the index in the threadobject to discover bugs */
-#if !defined(NDEBUG)
-       thread->index = 0;
-#endif
+       return true;
 }
 
 
@@ -1043,7 +965,6 @@ static void *threads_startup_thread(void *t)
        java_lang_VMThread *vmt;
 #endif
        sem_t              *psem;
-       threadobject       *tnext;
        classinfo          *c;
        methodinfo         *m;
        java_objectheader  *o;
@@ -1071,41 +992,28 @@ static void *threads_startup_thread(void *t)
        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);
+       /* 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. */
 
-       /* set the thread object */
+       threads_sem_wait(startup->psem_first);
 
 #if defined(__DARWIN__)
        thread->mach_thread = mach_thread_self();
 #endif
 
-       threads_init_threadobject(thread);
+       /* store the internal thread data-structure in the TSD */
+
        threads_set_current_threadobject(thread);
 
        /* thread is running */
 
        thread->state = THREAD_STATE_RUNNABLE;
 
-       /* insert the thread into the threadlist and the threads table */
-
-       pthread_mutex_lock(&threadlistlock);
-
-       thread->prev = mainthreadobj;
-       thread->next = tnext = mainthreadobj->next;
-       mainthreadobj->next = thread;
-       tnext->prev = thread;
+       /* insert the thread into the threads table */
 
        threads_table_add(thread);
 
-       pthread_mutex_unlock(&threadlistlock);
-
-       /* init data structures of this thread */
-
-       lock_init_execution_env(thread);
-
        /* tell threads_startup_thread that we registered ourselves */
        /* CAUTION: *startup becomes invalid with this!             */
 
@@ -1130,13 +1038,17 @@ static void *threads_startup_thread(void *t)
                jvmti_ThreadStartEnd(JVMTI_EVENT_THREAD_START);
 #endif
 
+#if !defined(NDEBUG)
+       if (opt_verbosethreads) {
+               printf("[Starting thread ");
+               threads_thread_print_info(thread);
+               printf("]\n");
+       }
+#endif
+
        /* find and run the Thread.run()V method if no other function was passed */
 
        if (function == NULL) {
-               /* this is a normal Java thread */
-
-               thread->flags |= THREAD_FLAG_JAVA;
-
 #if defined(WITH_CLASSPATH_GNU)
                /* We need to start the run method of
                   java.lang.VMThread. Since this is a final class, we can use
@@ -1177,10 +1089,6 @@ static void *threads_startup_thread(void *t)
                (void) vm_call_method(m, o);
        }
        else {
-               /* this is an internal thread */
-
-               thread->flags |= THREAD_FLAG_INTERNAL;
-
                /* set ThreadMXBean variables */
 
                _Jv_jvm->java_lang_management_ThreadMXBean_ThreadCount++;
@@ -1196,6 +1104,14 @@ static void *threads_startup_thread(void *t)
                (function)();
        }
 
+#if !defined(NDEBUG)
+       if (opt_verbosethreads) {
+               printf("[Stopping thread ");
+               threads_thread_print_info(thread);
+               printf("]\n");
+       }
+#endif
+
 #if defined(ENABLE_JVMTI)
        /* fire thread end event */
 
@@ -1214,49 +1130,68 @@ static void *threads_startup_thread(void *t)
 }
 
 
-/* threads_start_thread ********************************************************
+/* threads_impl_thread_start ***************************************************
 
-   Start a thread in the JVM. Both (vm internal and java) thread objects exist.
+   Start a thread in the JVM.  Both (vm internal and java) thread
+   objects exist.
 
    IN:
-      thread.......the thread object
-         function.....function to run in the new thread. NULL means that the
-                      "run" method of the object `t` should be called
+      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_start_thread(threadobject *thread, functionptr function)
+void threads_impl_thread_start(threadobject *thread, functionptr f)
 {
        sem_t          sem;
        sem_t          sem_first;
        pthread_attr_t attr;
        startupinfo    startup;
+       int            ret;
 
        /* fill startupinfo structure passed by pthread_create to
         * threads_startup_thread */
 
        startup.thread     = thread;
-       startup.function   = function;       /* maybe we don't call Thread.run()V */
+       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 attribute object */
+       /* initialize thread attributes */
 
-       if (pthread_attr_init(&attr))
-               vm_abort("pthread_attr_init failed: %s", strerror(errno));
+       if (pthread_attr_init(&attr) != 0)
+               vm_abort("threads_impl_thread_start: pthread_attr_init failed: %s",
+                                strerror(errno));
+
+    if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
+               vm_abort("threads_impl_thread_start: pthread_attr_setdetachstate failed: %s",
+                                strerror(errno));
 
        /* initialize thread stacksize */
 
        if (pthread_attr_setstacksize(&attr, opt_stacksize))
-               vm_abort("pthread_attr_setstacksize failed: %s", strerror(errno));
+               vm_abort("threads_impl_thread_start: pthread_attr_setstacksize failed: %s",
+                                strerror(errno));
 
        /* create the thread */
 
-       if (pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup))
-               vm_abort("pthread_create failed: %s", strerror(errno));
+       ret = pthread_create(&(thread->tid), &attr, threads_startup_thread, &startup);
+
+       /* destroy the thread attributes */
+
+       if (pthread_attr_destroy(&attr) != 0)
+               vm_abort("threads_impl_thread_start: pthread_attr_destroy failed: %s",
+                                strerror(errno));
+
+       /* check for pthread_create error */
+
+       if (ret != 0)
+               vm_abort("threads_impl_thread_start: pthread_create failed: %s",
+                                strerror(errno));
 
        /* signal that pthread_create has returned, so thread->tid is valid */
 
@@ -1310,6 +1245,7 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
 
 #if defined(ENABLE_JAVASE)
        java_lang_ThreadGroup *group;
+       threadobject          *mainthread;
        methodinfo            *m;
 #endif
 
@@ -1317,17 +1253,9 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
        java_lang_VMThread    *vmt;
 #endif
 
-       /* create a vm internal thread object */
+       /* create internal thread data-structure */
 
-       thread = NEW(threadobject);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_threadobject += sizeof(threadobject);
-#endif
-
-       if (thread == NULL)
-               return false;
+       thread = threads_thread_new();
 
        /* create a java.lang.Thread object */
 
@@ -1338,33 +1266,26 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
 
        thread->object = t;
 
-       threads_init_threadobject(thread);
-       threads_set_current_threadobject(thread);
-       lock_init_execution_env(thread);
-
-       /* thread is running */
+       /* thread is a Java thread and running */
 
-       thread->state = THREAD_STATE_RUNNABLE;
+       thread->flags = THREAD_FLAG_JAVA;
 
-       /* insert the thread into the threadlist and the threads table */
+       if (isdaemon)
+               thread->flags |= THREAD_FLAG_DAEMON;
 
-       pthread_mutex_lock(&threadlistlock);
+       thread->state = THREAD_STATE_RUNNABLE;
 
-       thread->prev        = mainthreadobj;
-       thread->next        = mainthreadobj->next;
-       mainthreadobj->next = thread;
-       thread->next->prev  = thread;
+       /* insert the thread into the threads table */
 
        threads_table_add(thread);
 
-       pthread_mutex_unlock(&threadlistlock);
-
-       /* mark thread as Java thread */
-
-       thread->flags = THREAD_FLAG_JAVA;
-
-       if (isdaemon)
-               thread->flags |= THREAD_FLAG_DAEMON;
+#if !defined(NDEBUG)
+       if (opt_verbosethreads) {
+               printf("[Attaching thread ");
+               threads_thread_print_info(thread);
+               printf("]\n");
+       }
+#endif
 
 #if defined(ENABLE_INTRP)
        /* create interpreter stack */
@@ -1400,7 +1321,10 @@ bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon)
        else {
                u     = utf_null;
 #if defined(ENABLE_JAVASE)
-               group = mainthreadobj->object->group;
+               /* get the main thread */
+
+               mainthread = threads_table_first();
+               group = mainthread->object->group;
 #endif
        }
 
@@ -1462,13 +1386,6 @@ bool threads_detach_thread(threadobject *thread)
        java_lang_Thread      *t;
 #endif
 
-       /* Allow lock record pools to be used by other threads. They
-          cannot be deleted so we'd better not waste them. */
-
-       /* XXX We have to find a new way to free lock records */
-       /*     with the new locking algorithm.                */
-       /* lock_record_free_pools(thread->ee.lockrecordpools); */
-
        /* XXX implement uncaught exception stuff (like JamVM does) */
 
 #if defined(ENABLE_JAVASE)
@@ -1502,20 +1419,17 @@ bool threads_detach_thread(threadobject *thread)
 
        thread->state = THREAD_STATE_TERMINATED;
 
-       /* lock thread list */
-
-       pthread_mutex_lock(&threadlistlock);
-
-       /* remove thread from thread list and threads table */
-
-       thread->next->prev = thread->prev;
-       thread->prev->next = thread->next;
+       /* remove thread from the threads table */
 
        threads_table_remove(thread);
 
-       /* unlock thread list */
-
-       pthread_mutex_unlock(&threadlistlock);
+#if !defined(NDEBUG)
+       if (opt_verbosethreads) {
+               printf("[Detaching thread ");
+               threads_thread_print_info(thread);
+               printf("]\n");
+       }
+#endif
 
        /* signal that this thread has finished */
 
@@ -1525,17 +1439,13 @@ bool threads_detach_thread(threadobject *thread)
 
        /* free the vm internal thread object */
 
-       FREE(thread, threadobject);
-
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_threadobject -= sizeof(threadobject);
-#endif
+       threads_thread_free(thread);
 
        return true;
 }
 
 
+<<<<<<< .working
 /* threads_suspend_thread ******************************************************
 
    Suspend the passed thread. Execution stops until the thread
@@ -1713,9 +1623,11 @@ void threads_join_all_threads(void)
 
        pthread_mutex_lock(&mutex_join);
 
-       /* wait for condition as long as we have non-daemon threads */
+       /* 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 (threads_find_non_daemon_thread() != NULL)
+       while (threads_table_get_non_daemons() > 1)
                pthread_cond_wait(&cond_join, &mutex_join);
 
        /* leave join mutex */
@@ -2030,47 +1942,6 @@ void threads_yield(void)
 }
 
 
-/* threads_table_dump *********************************************************
-
-   Dump the threads table for debugging purposes.
-
-   IN:
-      file..............stream to write to
-
-******************************************************************************/
-
-#if !defined(NDEBUG) && 0
-static void threads_table_dump(FILE *file)
-{
-       s4 i;
-       s4 size;
-       ptrint index;
-
-       pthread_mutex_lock(&threadlistlock);
-
-       size = threads_table.size;
-
-       fprintf(file, "======== THREADS TABLE (size %d) ========\n", size);
-
-       for (i=0; i<size; ++i) {
-               index = threads_table.table[i].nextfree;
-
-               fprintf(file, "%4d: ", i);
-
-               if (index < size) {
-                       fprintf(file, "free, nextfree = %d\n", (int) index);
-               }
-               else {
-                       fprintf(file, "thread %p\n", (void*) threads_table.table[i].thread);
-               }
-       }
-
-       fprintf(file, "======== END OF THREADS TABLE ========\n");
-
-       pthread_mutex_unlock(&threadlistlock);
-}
-#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
index 45302a3d5848111d3a18a9de8d9d962738bde03c..d565c7b53238301208e0c90794af65b8d77b326f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.h 7766 2007-04-19 13:24:48Z michi $
+   $Id: threads.h 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -32,9 +32,7 @@
 
 /* forward typedefs ***********************************************************/
 
-typedef struct threadobject          threadobject;
-typedef union  threads_table_entry_t threads_table_entry_t;
-typedef struct threads_table_t       threads_table_t;
+typedef struct threadobject threadobject;
 
 
 #include "config.h"
@@ -96,32 +94,6 @@ extern pthread_key_t threads_current_threadobject_key;
 #endif /* defined(HAVE___THREAD) */
 
 
-/* threads_table_entry_t *******************************************************
-
-   An entry in the global threads table.
-
-*******************************************************************************/
-
-union threads_table_entry_t {
-       threadobject       *thread;        /* an existing thread                  */
-       ptrint              nextfree;      /* next free index                     */
-};
-
-
-/* threads_table_t *************************************************************
-
-   Struct for the global threads table.
-
-*******************************************************************************/
-
-struct threads_table_t {
-       threads_table_entry_t *table;      /* the table, threads[0] is the head   */
-                                          /* of the free list. Real entries      */
-                                                                          /* start at threads[1].                */
-       s4                     size;       /* current size of the table           */
-};
-
-
 /* threadobject ****************************************************************
 
    Struct holding thread local variables.
@@ -140,11 +112,6 @@ struct threads_table_t {
 struct threadobject {
        java_lang_Thread     *object;       /* link to java.lang.Thread object    */
 
-       lock_execution_env_t  ee;           /* data for the lock implementation   */
-
-       threadobject         *next;         /* next thread in list, or self       */
-       threadobject         *prev;         /* prev thread in list, or self       */
-
        ptrint                thinlock;     /* pre-computed thin lock value       */
 
        s4                    index;        /* thread index, starting with 1      */
@@ -202,11 +169,6 @@ struct threadobject {
 #define STACKFRAMEINFO    (THREADOBJECT->_stackframeinfo)
 
 
-/* variables ******************************************************************/
-
-extern threadobject *mainthreadobj;
-
-
 /* functions ******************************************************************/
 
 void threads_sem_init(sem_t *sem, bool shared, int value);
@@ -215,7 +177,6 @@ void threads_sem_post(sem_t *sem);
 
 threadobject *threads_get_current_threadobject(void);
 
-void threads_preinit(void);
 bool threads_init(void);
 
 void threads_start_thread(threadobject *thread, functionptr function);
diff --git a/src/threads/none/.cvsignore b/src/threads/none/.cvsignore
deleted file mode 100644 (file)
index e5cd21f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-TAGS
index b671bd7e6d4ae8a5444e9a7bb27ff320f315371a..c8f8424d27cc4e61088c01ba6ccd8210526f3181 100644 (file)
@@ -30,7 +30,9 @@
 #ifndef _LOCK_H
 #define _LOCK_H
 
-/* define some stuff we need to no-ops ****************************************/
+/* define some stuff to no-ops *************************************************/
+
+#define LOCK_INIT_OBJECT_LOCK(o)
 
 #define LOCK_MONITOR_ENTER(o)
 #define LOCK_MONITOR_EXIT(o)
index 9bb4293ea3074d264989c8e8cb5aadb02ebf4f84..a30e3ad5c188ee2a3523f28c63a898f9cd3130c8 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: signal.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: threads-common.c 7914 2007-05-18 14:17:34Z twisti $
 
 */
 
 # include "native/include/java_lang_VMThread.h"
 #endif
 
+#include "threads/critical.h"
+#include "threads/lock-common.h"
 #include "threads/threads-common.h"
 
-#include "threads/native/threads.h"
-
 #include "vm/builtin.h"
 #include "vm/stringlocal.h"
 #include "vm/vm.h"
 #include "vmcore/utf8.h"
 
 
-/* threads_create_thread *******************************************************
+/* global variables ***********************************************************/
+
+/* global threads table */
+static threads_table_t threads_table;
+
+
+/* prototypes *****************************************************************/
+
+static void threads_table_init(threadobject *mainthread);
+
+
+/* threads_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_preinit(void)
+{
+       threadobject *mainthread;
+
+       /* Initialize the threads implementation (sets the thinlock on the
+          main thread). */
+
+       threads_impl_preinit();
+
+       /* create internal thread data-structure for the main thread */
+
+       mainthread = threads_thread_new();
+
+       mainthread->object   = NULL;
+       mainthread->index    = 1;
+       mainthread->thinlock = lock_pre_compute_thinlock(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 */
+
+       threads_set_current_threadobject(mainthread);
+       
+       /* initialize the threads table with the main-thread */
+
+       threads_table_init(mainthread);
+
+       /* initialize locking subsystems */
+
+       lock_init();
+
+       /* initialize the critical section */
+
+       critical_init();
+}
+
+
+/* threads_table_init **********************************************************
+
+   Initialize the global threads table.  We initialize the table with
+   the main-thread, which has always the index 1.
+
+   IN:
+      mainthread....the main-thread
+
+*******************************************************************************/
+
+#define THREADS_INITIAL_TABLE_SIZE    8
+
+static void threads_table_init(threadobject *mainthread)
+{
+       threads_table_entry_t *ttemain;
+       s4                     size;
+       s4                     i;
+
+       /* initialize the threads table lock */
+
+       threads_impl_table_init();
+
+       /* initialize the table */
+
+       size = THREADS_INITIAL_TABLE_SIZE;
+
+       threads_table.table   = MNEW(threads_table_entry_t, size);
+       threads_table.size    = size;
+       threads_table.used    = 0;
+       threads_table.daemons = 0;
+
+       /* Link the entries in a freelist.  Skip 2 entries: 0 is the
+          free-list header and 1 is the main thread. */
+
+       for (i = 2; i < size; i++) {
+               threads_table.table[i].thread = NULL;
+               threads_table.table[i].next   = i + 1;
+       }
+
+       threads_table.table[0].next = 2;
+
+       /* terminate the freelist */
+
+       threads_table.table[size - 1].next = 0;          /* index 0 is never free */
+
+       /* insert the main-thread */
+
+       ttemain = &(threads_table.table[1]);
+
+       ttemain->thread = mainthread;
+       ttemain->next   = 0;
+
+       /* now 1 entry is used */
+
+       threads_table.used = 1;
+}
+
+
+/* threads_table_add ***********************************************************
+
+   Add a thread to the global threads table. The index is entered in the
+   threadobject. The thinlock value for the thread is pre-computed.
+
+   IN:
+      thread............the thread to add
+
+   RETURN VALUE:
+      The table index for the newly added thread. This value has also been
+         entered in the threadobject.
+
+*******************************************************************************/
+
+s4 threads_table_add(threadobject *thread)
+{
+       threads_table_entry_t *ttefree;
+       threads_table_entry_t *ttemain;
+       threads_table_entry_t *tte;
+       s4 index;
+       s4 oldsize;
+       s4 newsize;
+       s4 i;
+
+       /* lock the threads table */
+
+       threads_table_lock();
+
+       /* get free and main entry */
+
+       ttefree = &(threads_table.table[0]);
+       ttemain = &(threads_table.table[1]);
+
+       /* get the next free index */
+
+       index = ttefree->next;
+
+       /* no entry free anymore? resize the table */
+
+       if (index == 0) {
+               /* we must grow the table */
+
+               oldsize = threads_table.size;
+               newsize = oldsize * 2;
+
+               threads_table.table = MREALLOC(threads_table.table,
+                                                                          threads_table_entry_t, oldsize, newsize);
+               threads_table.size = newsize;
+
+               /* the addresses have changed, get them again */
+
+               ttefree = &(threads_table.table[0]);
+               ttemain = &(threads_table.table[1]);
+
+               /* link the new entries to a free list */
+
+               for (i = oldsize; i < newsize; i++) {
+                       threads_table.table[i].thread = NULL;
+                       threads_table.table[i].next   = i + 1;
+               }
+
+               ttefree->next = oldsize;
+
+               /* terminate the freelist */
+
+               threads_table.table[newsize - 1].next = 0;   /* index 0 is never free */
+
+               /* use the first of the new entries */
+
+               index = ttefree->next;
+       }
+
+       /* get the entry with the assigned index */
+
+       tte = &(threads_table.table[index]);
+
+       /* store the next free index into the free-list header */
+
+       ttefree->next = tte->next;
+
+       /* store the thread in the table */
+
+       tte->thread = thread;
+
+       /* link the new entry into the used-list */
+
+       tte->next     = ttemain->next;
+       ttemain->next = index;
+
+       /* update the counters */
+
+       threads_table.used++;
+
+       if (thread->flags & THREAD_FLAG_DAEMON)
+               threads_table.daemons++;
+
+       assert(threads_table.used < threads_table.size);
+
+       /* set the thread variables */
+
+       thread->index    = index;
+       thread->thinlock = lock_pre_compute_thinlock(index);
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
+
+       return index;
+}
+
+
+/* threads_table_remove *******************************************************
+
+   Remove a thread from the global threads table.
+
+   IN:
+      thread............the thread to remove
+
+******************************************************************************/
+
+void threads_table_remove(threadobject *thread)
+{
+       threads_table_entry_t *ttefree;
+       threads_table_entry_t *tte;
+       s4                     index;
+       s4                     i;
+
+       /* lock the threads table */
+
+       threads_table_lock();
+
+       /* get the free entry */
+
+       ttefree = &(threads_table.table[0]);
+
+       /* get the current entry */
+
+       index = thread->index;
+       tte   = &(threads_table.table[index]);
+
+       assert(tte->thread == thread);
+
+       /* Find the entry which has the one to be removed as next entry (I
+          think it's better to do it at the removal in linear time than
+          to have a list or to do it every time we iterate over all
+          threads). */
+
+       for (i = 0; i < threads_table.size; i++) {
+               if (threads_table.table[i].next == index) {
+                       threads_table.table[i].next = tte->next;
+                       break;
+               }
+       }
+
+       /* clear the thread pointer in the entry */
+
+       tte->thread = NULL;
+
+       /* this entry is free now, add it to the free-list */
+
+       tte->next     = ttefree->next;
+       ttefree->next = index;
+
+       /* update the counters */
+
+       threads_table.used--;
+
+       if (thread->flags & THREAD_FLAG_DAEMON)
+               threads_table.daemons--;
+
+       assert(threads_table.used >= 0);
+
+       /* delete the index in the threadobject to discover bugs */
+#if !defined(NDEBUG)
+       thread->index = 0;
+#endif
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
+}
+
+
+/* threads_table_get ***********************************************************
+
+   Return the thread of the given table-entry index.
+
+   NOTE: It is valid to pass and index of 0, as this entry is the
+         free-list header where the thread pointer is always NULL and
+         this is thre expected behavior.
+
+   NOTE: This function does not lock the table.
+
+*******************************************************************************/
+
+static threadobject *threads_table_get(s4 index)
+{
+       threadobject *thread;
+
+       /* get the requested entry */
+
+       assert((index >= 0) && (index < threads_table.size));
+
+       thread = threads_table.table[index].thread;
+
+       return thread;
+}
+
+
+/* threads_table_get_threads ***************************************************
+
+   Return the number of running threads.
+
+   NOTE: This function does not lock the table.
+
+*******************************************************************************/
+
+s4 threads_table_get_threads(void)
+{
+       return threads_table.used;
+}
+
+
+/* threads_table_get_non_daemons ***********************************************
+
+   Return the number of non-daemon threads.
+
+*******************************************************************************/
+
+s4 threads_table_get_non_daemons(void)
+{
+       s4 nondaemons;
+
+       /* lock the threads table */
+
+       threads_table_lock();
+
+       nondaemons = threads_table.used - threads_table.daemons;
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
+
+       return nondaemons;
+}
+
+
+/* threads_table_first *********************************************************
+
+   Return the first thread of the threads table.
+
+   NOTE: This is always the entry with index 1 and must be the main
+         thread.
+
+   NOTE: This function does not lock the table.
+
+*******************************************************************************/
+
+threadobject *threads_table_first(void)
+{
+       threadobject *thread;
+
+       /* get the requested entry */
+
+       thread = threads_table_get(1);
+
+       return thread;
+}
+
+
+/* threads_table_next **********************************************************
+
+   Return the next thread of the threads table relative to the passed
+   one.
+
+   NOTE: This function does not lock the table.
+
+*******************************************************************************/
+
+threadobject *threads_table_next(threadobject *thread)
+{
+       threads_table_entry_t *tte;
+       threadobject          *next;
+       s4                     index;
+
+       index = thread->index;
+
+       /* get the passed entry */
+
+       assert((index > 0) && (index < threads_table.size));
+
+       tte = &(threads_table.table[index]);
+
+       /* get the requested entry */
+
+       next = threads_table_get(tte->next);
+
+       return next;
+}
+
+
+/* threads_table_dump *********************************************************
+
+   Dump the threads table for debugging purposes.
+
+******************************************************************************/
+
+#if !defined(NDEBUG)
+void threads_table_dump(void)
+{
+       s4 i;
+       s4 size;
+       ptrint index;
+
+       size = threads_table.size;
+
+       log_println("threads table ==========");
+
+       log_println("size:    %d", size);
+       log_println("used:    %d", threads_table.used);
+       log_println("daemons: %d", threads_table.daemons);
+
+       for (i = 0; i < size; i++) {
+               index = threads_table.table[i].next;
+
+               if (threads_table.table[i].thread != NULL)
+                       log_println("%4d: thread=0x%08x, next=%d", i,
+                                               threads_table.table[i].thread->tid, (int) index);
+               else
+                       log_println("%4d: free, next=%d", i, (int) index);
+       }
+
+       log_println("end of threads table ==========");
+}
+#endif
+
+
+/* threads_thread_new **********************************************************
+
+   Allocates and initializes an internal thread data-structure.
+
+*******************************************************************************/
+
+threadobject *threads_thread_new(void)
+{
+       threadobject *t;
+
+       /* allocate internal thread data-structure */
+
+#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
+
+       /* initialize thread data structure */
+
+       t->index       = 0;
+       t->interrupted = false;
+       t->signaled    = false;
+       t->sleeping    = false;
+
+       threads_impl_thread_new(t);
+
+       return t;
+}
+
+
+/* threads_thread_free *********************************************************
 
-   Creates a thread object with the given name.
+   Frees an internal thread data-structure.
 
 *******************************************************************************/
 
-threadobject *threads_create_thread(utf *name)
+void threads_thread_free(threadobject *t)
+{
+       /* cleanup the implementation-specific bits */
+
+       threads_impl_thread_free(t);
+
+#if defined(ENABLE_GC_BOEHM)
+       GCFREE(t);
+#else
+       FREE(t, threadobject);
+#endif
+
+#if defined(ENABLE_STATISTICS)
+       if (opt_stat)
+               size_threadobject -= sizeof(threadobject);
+#endif
+}
+
+
+/* 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       *thread;
        java_lang_Thread   *t;
@@ -77,25 +598,22 @@ threadobject *threads_create_thread(utf *name)
        java_lang_VMThread *vmt;
 #endif
 
-       /* create the vm internal thread object */
+       /* create internal thread data-structure */
 
-       thread = NEW(threadobject);
-
-       if (thread == NULL)
-               return NULL;
+       thread = threads_thread_new();
 
        /* create the java thread object */
 
        t = (java_lang_Thread *) builtin_new(class_java_lang_Thread);
 
        if (t == NULL)
-               return NULL;
+               return false;
 
 #if defined(WITH_CLASSPATH_GNU)
        vmt = (java_lang_VMThread *) builtin_new(class_java_lang_VMThread);
 
        if (vmt == NULL)
-               return NULL;
+               return false;
 
        vmt->thread = t;
        vmt->vmdata = (java_lang_Object *) thread;
@@ -105,8 +623,9 @@ threadobject *threads_create_thread(utf *name)
        t->vm_thread = (java_lang_Object *) thread;
 #endif
 
-       thread->object     = t;
-       thread->flags      = THREAD_FLAG_DAEMON;
+       thread->object = t;
+
+       thread->flags = THREAD_FLAG_INTERNAL | THREAD_FLAG_DAEMON;
 
        /* set java.lang.Thread fields */
 
@@ -116,38 +635,42 @@ threadobject *threads_create_thread(utf *name)
 #endif
        t->priority = NORM_PRIORITY;
 
-       /* return the thread object */
+       /* start the thread */
 
-       return thread;
+       threads_impl_thread_start(thread, f);
+
+       /* everything's ok */
+
+       return true;
 }
 
 
-/* threads_start_javathread ***************************************************
+/* threads_thread_start ********************************************************
 
-   Start a thread in the JVM. Only the java thread object exists so far.
+   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_start_javathread(java_lang_Thread *object)
+void threads_thread_start(java_lang_Thread *object)
 {
        threadobject *thread;
 
-       /* create the vm internal threadobject */
-
-       thread = NEW(threadobject);
+       /* create internal thread data-structure */
 
-#if defined(ENABLE_STATISTICS)
-       if (opt_stat)
-               size_threadobject += sizeof(threadobject);
-#endif
+       thread = threads_thread_new();
 
        /* link the two objects together */
 
        thread->object = object;
 
+       /* this is a normal Java thread */
+
+       thread->flags = THREAD_FLAG_JAVA;
+
 #if defined(ENABLE_JAVASE)
        /* is this a daemon thread? */
 
@@ -164,10 +687,80 @@ void threads_start_javathread(java_lang_Thread *object)
        object->vm_thread = (java_lang_Object *) thread;
 #endif
 
-       /* Actually start the thread.  Don't pass a function pointer
-          (NULL) since we want Thread.run()V here. */
+       /* Start the thread.  Don't pass a function pointer (NULL) since
+          we want Thread.run()V here. */
+
+       threads_impl_thread_start(thread, NULL);
+}
+
+
+/* threads_thread_print_info ***************************************************
+
+   Print information of the passed thread.
+   
+*******************************************************************************/
+
+void threads_thread_print_info(threadobject *t)
+{
+       java_lang_Thread *object;
+       utf              *name;
+
+       /* the thread may be currently in initalization, don't print it */
+
+       object = t->object;
+
+       if (object != NULL) {
+               /* get thread name */
+
+#if defined(ENABLE_JAVASE)
+               name = javastring_toutf((java_objectheader *) object->name, false);
+#elif defined(ENABLE_JAVAME_CLDC1_1)
+               name = object->name;
+#endif
+
+               printf("\"");
+               utf_display_printable_ascii(name);
+               printf("\"");
 
-       threads_start_thread(thread, NULL);
+               if (t->flags & THREAD_FLAG_DAEMON)
+                       printf(" daemon");
+
+               printf(" prio=%d", object->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
+
+               /* print thread state */
+
+               switch (t->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("threads_thread_print_info: unknown thread state %d",
+                                        t->state);
+               }
+       }
 }
 
 
@@ -226,6 +819,10 @@ utf *threads_thread_get_state(threadobject *thread)
                break;
        default:
                vm_abort("threads_get_state: unknown thread state %d", thread->state);
+
+               /* keep compiler happy */
+
+               u = NULL;
        }
 
        return u;
@@ -257,6 +854,10 @@ bool threads_thread_is_alive(threadobject *thread)
 
        default:
                vm_abort("threads_is_alive: unknown thread state %d", thread->state);
+
+               /* keep compiler happy */
+
+               result = false;
        }
 
        return result;
@@ -272,84 +873,33 @@ bool threads_thread_is_alive(threadobject *thread)
 
 void threads_dump(void)
 {
-       threadobject     *thread;
-       java_lang_Thread *t;
-       utf              *name;
+       threadobject *t;
 
        /* XXX we should stop the world here */
 
-       printf("Full thread dump CACAO "VERSION":\n");
-
-       /* iterate over all started threads */
-
-       thread = mainthreadobj;
-
-       do {
-               /* get thread object */
-
-               t = thread->object;
+       /* lock the threads table */
 
-               /* the thread may be currently in initalization, don't print it */
+       threads_table_lock();
 
-               if (t != NULL) {
-                       /* get thread name */
+       printf("Full thread dump CACAO "VERSION":\n");
 
-#if defined(ENABLE_JAVASE)
-                       name = javastring_toutf((java_objectheader *) t->name, false);
-#elif defined(ENABLE_JAVAME_CLDC1_1)
-                       name = t->name;
-#endif
+       /* iterate over all started threads */
 
-                       printf("\n\"");
-                       utf_display_printable_ascii(name);
-                       printf("\"");
+       for (t = threads_table_first(); t != NULL; t = threads_table_next(t)) {
+               /* print thread info */
 
-                       if (thread->flags & THREAD_FLAG_DAEMON)
-                               printf(" daemon");
+               printf("\n");
+               threads_thread_print_info(t);
+               printf("\n");
 
-                       printf(" prio=%d", t->priority);
+               /* print trace of thread */
 
-#if SIZEOF_VOID_P == 8
-                       printf(" tid=0x%016lx", (ptrint) thread->tid);
-#else
-                       printf(" tid=0x%08lx", (ptrint) thread->tid);
-#endif
+               threads_thread_print_stacktrace(t);
+       }
 
-                       /* print thread state */
-
-                       switch (thread->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("threads_dump: unknown thread state %d",
-                                                thread->state);
-                       }
-
-                       printf("\n");
-
-                       /* print trace of thread */
-
-                       threads_thread_print_stacktrace(thread);
-               }
+       /* unlock the threads table */
 
-               thread = thread->next;
-       } while ((thread != NULL) && (thread != mainthreadobj));
+       threads_table_unlock();
 }
 
 
index a605f28042ddafdda56dd67e9f8128580fea8f61..2695d52859332a27781e40bd09a185dfc7a5978d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: signal.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: threads-common.h 7904 2007-05-14 13:29:32Z twisti $
 
 */
 
@@ -37,8 +37,6 @@
 
 #include "native/jni.h"
 
-#include "native/include/java_lang_Thread.h"
-
 #if defined(ENABLE_THREADS)
 # include "threads/native/threads.h"
 #else
 #include "vmcore/utf8.h"
 
 
+/* only define the following stuff with thread enabled ************************/
+
+#if defined(ENABLE_THREADS)
+
+/* typedefs *******************************************************************/
+
+typedef struct threads_table_entry_t threads_table_entry_t;
+typedef struct threads_table_t       threads_table_t;
+
+
 /* thread states **************************************************************/
 
 #define THREAD_STATE_NEW              0
 #define MAX_PRIORITY     10
 
 
+/* threads_table_entry_t *******************************************************
+
+   An entry in the global threads table.
+
+*******************************************************************************/
+
+struct threads_table_entry_t {
+       threadobject *thread;              /* an existing thread                  */
+       s4            next;                /* next free or used index             */
+};
+
+
+/* threads_table_t *************************************************************
+
+   Struct for the global threads table.
+
+*******************************************************************************/
+
+struct threads_table_t {
+       threads_table_entry_t *table;      /* the table, threads[0] is the head   */
+                                          /* of the free list. Real entries      */
+                                                                          /* start at threads[1].                */
+       s4                     size;       /* current size of the table           */
+       s4                     used;       /* number of thread entries            */
+       s4                     daemons;    /* number of daemon thread entries     */
+};
+
+
 /* function prototypes ********************************************************/
 
-threadobject *threads_create_thread(utf *name);
-void          threads_start_javathread(java_lang_Thread *object);
+void          threads_preinit(void);
+
+s4            threads_table_add(threadobject *thread);
+void          threads_table_remove(threadobject *thread);
+s4            threads_table_get_threads(void);
+s4            threads_table_get_non_daemons(void);
+threadobject *threads_table_first(void);
+threadobject *threads_table_next(threadobject *thread);
+
+#if !defined(NDEBUG)
+void          threads_table_dump(void);
+#endif
+
+threadobject *threads_thread_new(void);
+void          threads_thread_free(threadobject *t);
+bool          threads_thread_start_internal(utf *name, functionptr f);
+void          threads_thread_start(java_lang_Thread *object);
+
+void          threads_thread_print_info(threadobject *t);
+
 ptrint        threads_get_current_tid(void);
 utf          *threads_thread_get_state(threadobject *thread);
 bool          threads_thread_is_alive(threadobject *thread);
+
 void          threads_dump(void);
 void          threads_thread_print_stacktrace(threadobject *thread);
 void          threads_print_stacktrace(void);
 
+
+/* implementation specific functions */
+
+void          threads_impl_preinit(void);
+
+void          threads_impl_table_init(void);
+void          threads_table_lock(void);
+void          threads_table_unlock(void);
+
+void          threads_set_current_threadobject(threadobject *thread);
+void          threads_impl_thread_new(threadobject *t);
+void          threads_impl_thread_free(threadobject *t);
+void          threads_impl_thread_start(threadobject *thread, functionptr f);
+
+#endif /* ENABLE_THREADS */
+
 #endif /* _THREADS_COMMON_H */
 
 
diff --git a/src/toolbox/.cvsignore b/src/toolbox/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 15337fa4398528d9485680043c039dfd4610e306..54195c0aa6f5b90b525db5c2d67ad0c389863d27 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: avl.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: avl.c 7862 2007-05-03 14:53:39Z twisti $
 
 */
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
+#include "threads/lock-common.h"
+
 #include "toolbox/avl.h"
+#include "toolbox/logging.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "vm/global.h"
+#include "vm/vm.h"
 
 
 /* avl_create ******************************************************************
 
 *******************************************************************************/
 
-avl_tree *avl_create(avl_comparator *compar)
+avl_tree_t *avl_create(avl_comparator *comparator)
 {
-       avl_tree *t;
+       avl_tree_t *t;
 
-       t = NEW(avl_tree);
+       t = NEW(avl_tree_t);
 
        t->root       = NULL;
-       t->comparator = compar;
+       t->comparator = comparator;
        t->entries    = 0;
 
 #if defined(ENABLE_THREADS)
@@ -64,7 +65,7 @@ avl_tree *avl_create(avl_comparator *compar)
 
        t->lock       = NEW(java_objectheader);
 
-       lock_init_object_lock(t->lock);
+       LOCK_INIT_OBJECT_LOCK(t->lock);
 #endif
 
        return t;
@@ -77,11 +78,11 @@ avl_tree *avl_create(avl_comparator *compar)
 
 *******************************************************************************/
 
-static avl_node *avl_newnode(void *data)
+static avl_node_t *avl_newnode(void *data)
 {
-       avl_node *n;
+       avl_node_t *n;
 
-       n = NEW(avl_node);
+       n = NEW(avl_node_t);
 
        n->data      = data;
 
@@ -107,10 +108,10 @@ static avl_node *avl_newnode(void *data)
 
 *******************************************************************************/
 
-static void avl_rotate_left(avl_node **node)
+static void avl_rotate_left(avl_node_t **node)
 {
-       avl_node *tmp;
-       avl_node *tmpnode;
+       avl_node_t *tmp;
+       avl_node_t *tmpnode;
 
        /* rotate the node */
 
@@ -137,10 +138,10 @@ static void avl_rotate_left(avl_node **node)
 
 *******************************************************************************/
 
-static void avl_rotate_right(avl_node **node)
+static void avl_rotate_right(avl_node_t **node)
 {
-       avl_node *tmp;
-       avl_node *tmpnode;
+       avl_node_t *tmp;
+       avl_node_t *tmpnode;
 
        /* rotate the node */
 
@@ -161,10 +162,10 @@ static void avl_rotate_right(avl_node **node)
 
 *******************************************************************************/
 
-static void avl_adjust_balance(avl_node *node)
+static void avl_adjust_balance(avl_node_t *node)
 {
-       avl_node *left;
-       avl_node *right;
+       avl_node_t *left;
+       avl_node_t *right;
 
        left  = node->childs[AVL_LEFT];
        right = node->childs[AVL_RIGHT];
@@ -196,13 +197,13 @@ static void avl_adjust_balance(avl_node *node)
 
 *******************************************************************************/
 
-static s4 avl_insert_intern(avl_tree *tree, avl_node **node, void *data)
+static s4 avl_insert_intern(avl_tree_t *tree, avl_node_t **node, void *data)
 {
-       avl_node *tmpnode;
-       s4        res;
-       s4        direction;
-       s4        insert;
-       s4        balance;
+       avl_node_t *tmpnode;
+       s4          res;
+       s4          direction;
+       s4          insert;
+       s4          balance;
 
        /* set temporary variable */
 
@@ -214,12 +215,12 @@ static s4 avl_insert_intern(avl_tree *tree, avl_node **node, void *data)
 
        /* compare the current node */
 
-       res = tree->comparator(data, tmpnode->data);
+       res = tree->comparator(tmpnode->data, data);
 
        /* is this node already in the tree? */
 
        if (res == 0)
-               assert(0);
+               vm_abort("avl_insert_intern: node already in the tree");
 
        /* goto left or right child */
 
@@ -229,9 +230,9 @@ static s4 avl_insert_intern(avl_tree *tree, avl_node **node, void *data)
 
        if (tmpnode->childs[direction]) {
                balance = avl_insert_intern(tree, &tmpnode->childs[direction], data);
-
-       else {
-               avl_node *newnode;
+       }
+       else {
+               avl_node_t *newnode;
 
                /* no child, create this node */
 
@@ -263,14 +264,14 @@ static s4 avl_insert_intern(avl_tree *tree, avl_node **node, void *data)
 
                                tmpnode->balance = 0;
                                tmpnode->childs[AVL_RIGHT]->balance = 0;
-
-                       else {
+                       }
+                       else {
                                avl_rotate_left(&tmpnode->childs[AVL_LEFT]);
                                avl_rotate_right(&tmpnode);
                                avl_adjust_balance(tmpnode);
                        }
-
-               else if (tmpnode->balance > 1) {
+               }
+               else if (tmpnode->balance > 1) {
                        /* right subtree too tall: left rotation needed */
 
                        if (tmpnode->childs[AVL_RIGHT]->balance > 0) {
@@ -280,14 +281,14 @@ static s4 avl_insert_intern(avl_tree *tree, avl_node **node, void *data)
 
                                tmpnode->balance = 0;
                                tmpnode->childs[AVL_LEFT]->balance = 0;
-
-                       else {
+                       }
+                       else {
                                avl_rotate_right(&tmpnode->childs[AVL_RIGHT]);
                                avl_rotate_left(&tmpnode);
                                avl_adjust_balance(tmpnode);
                        }
-
-               else {
+               }
+               else {
                        insert = 1;
                }
        }
@@ -308,7 +309,7 @@ static s4 avl_insert_intern(avl_tree *tree, avl_node **node, void *data)
 
 *******************************************************************************/
 
-bool avl_insert(avl_tree *tree, void *data)
+bool avl_insert(avl_tree_t *tree, void *data)
 {
        assert(tree);
        assert(data);
@@ -317,25 +318,15 @@ bool avl_insert(avl_tree *tree, void *data)
 
        /* if we don't have a root node, create one */
 
-       if (tree->root == NULL) {
+       if (tree->root == NULL)
                tree->root = avl_newnode(data);
-
-       } else {
+       else
                avl_insert_intern(tree, &tree->root, data);
-       }
 
        /* increase entries count */
 
        tree->entries++;
 
-#if 0
-       printf("tree=%p entries=%d\n", tree, tree->entries);
-
-       printf("-------------------\n");
-       avl_dump(tree->root, 0);
-       printf("-------------------\n");
-#endif
-
        LOCK_MONITOR_EXIT(tree->lock);
 
        /* insertion was ok */
@@ -351,10 +342,10 @@ bool avl_insert(avl_tree *tree, void *data)
 
 *******************************************************************************/
 
-void *avl_find(avl_tree *tree, void *data)
+void *avl_find(avl_tree_t *tree, void *data)
 {
-       avl_node *node;
-       s4        res;
+       avl_node_t *node;
+       s4          res;
 
        assert(tree);
        assert(data);
@@ -366,7 +357,7 @@ void *avl_find(avl_tree *tree, void *data)
        for (node = tree->root; node != NULL; ) {
                /* compare the current node */
 
-               res = tree->comparator(data, node->data);
+               res = tree->comparator(node->data, data);
 
                /* was the entry found? return it */
 
@@ -396,7 +387,7 @@ void *avl_find(avl_tree *tree, void *data)
 *******************************************************************************/
 
 #if !defined(NDEBUG)
-void avl_dump(avl_node* node, s4 indent)
+void avl_dump(avl_node_t* node, s4 indent)
 {
        s4 tmp;
 
@@ -408,10 +399,13 @@ void avl_dump(avl_node* node, s4 indent)
        if (node->childs[AVL_RIGHT])
                avl_dump(node->childs[AVL_RIGHT], tmp + 1);
 
+       log_start();
+
        while(indent--)
-               printf("   ");
+               log_print("   ");
 
-       printf("%p (%d)\n", node->data, node->balance);
+       log_print("%p (%d)", node->data, node->balance);
+       log_finish();
 
        if (node->childs[AVL_LEFT])
                avl_dump(node->childs[AVL_LEFT], tmp + 1);
index b73b9b873ce8085a29dad507c4737cb7bf6a6b7a..9e9b05229e573208d0d54253019f7948187d7da1 100644 (file)
@@ -1,6 +1,6 @@
 /* src/toolbox/avl.h - AVL tree implementation
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: avl.h 4921 2006-05-15 14:24:36Z twisti $
+   $Id: avl.h 7860 2007-05-03 12:30:05Z twisti $
 
 */
 
 
 /* tree comparator prototype **************************************************/
 
-typedef s4 avl_comparator(const void *a, const void *b);
+typedef s4 avl_comparator(const void *treenode, const void *node);
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct avl_tree avl_tree;
-typedef struct avl_node avl_node;
+typedef struct avl_tree_t avl_tree_t;
+typedef struct avl_node_t avl_node_t;
 
 
-/* avl_tree *******************************************************************/
+/* avl_tree_t *****************************************************************/
 
-struct avl_tree {
+struct avl_tree_t {
 #if defined(ENABLE_THREADS)
        java_objectheader *lock;            /* threads lock object                */
 #endif
-       avl_node          *root;            /* pointer to root node               */
+       avl_node_t        *root;            /* pointer to root node               */
        avl_comparator    *comparator;      /* pointer to comparison function     */
        s4                 entries;         /* contains number of entries         */
 };
 
 
-/* avl_node *******************************************************************/
+/* avl_node_t *****************************************************************/
 
-struct avl_node {
-       void     *data;                     /* pointer to data structure          */
-       s4        balance;                  /* the range of the field is -2...2   */
-       avl_node *childs[2];                /* pointers to the child nodes        */
+struct avl_node_t {
+       void       *data;                   /* pointer to data structure          */
+       s4          balance;                /* the range of the field is -2...2   */
+       avl_node_t *childs[2];              /* pointers to the child nodes        */
 };
 
 
 /* function prototypes ********************************************************/
 
-avl_tree *avl_create(avl_comparator *compar);
-bool avl_insert(avl_tree *tree, void *data);
-void *avl_find(avl_tree *tree, void *data);
+avl_tree_t *avl_create(avl_comparator *comparator);
+bool        avl_insert(avl_tree_t *tree, void *data);
+void       *avl_find(avl_tree_t *tree, void *data);
 
 #if !defined(NDEBUG)
-void avl_dump(avl_node* node, s4 indent);
+void        avl_dump(avl_node_t* node, s4 indent);
 #endif
 
 #endif /* _AVL_H */
index d6d7bf1851826ec7611f9802a0381840e790b179..4c394c79ca342b6d04cf1d873d3a0ed78e61fadd 100644 (file)
@@ -1,4 +1,4 @@
-/* src/vm/hashtable.c - functions for internal hashtables
+/* 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,
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-            Mark Probst
-            Andreas Krall
-            Christian Thalinger
-
-   $Id: hashtable.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: hashtable.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/hashtable.h"
+
 #include "vm/global.h"
 
 
@@ -65,7 +57,7 @@ void hashtable_create(hashtable *hash, u4 size)
 
        hash->header = NEW(java_objectheader);
 
-       lock_init_object_lock(hash->header);
+       LOCK_INIT_OBJECT_LOCK(hash->header);
 #endif
 
        /* set initial hash values */
index e5a46d5c3dc5fac5cfabe3b5851b8e5393847ee5..6b391bab4537464d44623a99cacba3a9aab8f2da 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: list.c 7784 2007-04-20 13:51:41Z twisti $
+   $Id: list.c 7915 2007-05-18 14:22:19Z twisti $
 
 */
 
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/list.h"
 
@@ -56,9 +52,7 @@ list_t *list_create(s4 nodeoffset)
 
        l = NEW(list_t);
 
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock((java_objectheader *) l);
-#endif
+       LOCK_INIT_OBJECT_LOCK(l);
 
        l->first      = NULL;
        l->last       = NULL;
@@ -99,13 +93,29 @@ list_t *list_create_dump(s4 nodeoffset)
 *******************************************************************************/
 
 void list_add_first(list_t *l, void *element)
+{
+       LOCK_MONITOR_ENTER(l);
+
+       list_add_first_unsynced(l, element);
+
+       LOCK_MONITOR_EXIT(l);
+}
+
+
+/* list_add_first_unsynced *****************************************************
+
+   Adds the element as first element, but WITHOUT LOCKING!
+
+   ATTENTION: Use this function with care!!!
+
+*******************************************************************************/
+
+void list_add_first_unsynced(list_t *l, void *element)
 {
        listnode_t *ln;
 
        ln = (listnode_t *) (((u1 *) element) + l->nodeoffset);
 
-       LOCK_MONITOR_ENTER(l);
-
        if (l->first) {
                ln->prev       = NULL;
                ln->next       = l->first;
@@ -122,8 +132,6 @@ void list_add_first(list_t *l, void *element)
        /* increase number of elements */
 
        l->size++;
-
-       LOCK_MONITOR_EXIT(l);
 }
 
 
index c3d3accc3c0cd46ab473a382ca434b654dddc701..230a80fa25841c6ede5ec03c5f9ce1a8c8e46a25 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: list.h 7784 2007-04-20 13:51:41Z twisti $
+   $Id: list.h 7905 2007-05-14 14:11:33Z twisti $
 
 */
 
@@ -123,15 +123,16 @@ struct list_t {
 list_t *list_create(s4 nodeoffset);
 list_t *list_create_dump(s4 nodeoffset);
 
-void   list_add_first(list_t *l, void *element);
+void    list_add_first(list_t *l, void *element);
+void    list_add_first_unsynced(list_t *l, void *element);
 
-void   list_add_last(list_t *l, void *element);
-void   list_add_last_unsynced(list_t *l, void *element);
+void    list_add_last(list_t *l, void *element);
+void    list_add_last_unsynced(list_t *l, void *element);
 
-void   list_add_before(list_t *l, void *element, void *newelement);
+void    list_add_before(list_t *l, void *element, void *newelement);
 
-void   list_remove(list_t *l, void *element);
-void   list_remove_unsynced(list_t *l, void *element);
+void    list_remove(list_t *l, void *element);
+void    list_remove_unsynced(list_t *l, void *element);
 
 void   *list_first(list_t *l);
 void   *list_first_unsynced(list_t *l);
index 5c5d8de0890ad15eb58e98b25d3946ec3d214889..1e3ae2c7548fd45216eef6bb46b15c2fff3c3f6c 100644 (file)
@@ -112,6 +112,17 @@ bool wl_is_empty(worklist *w) {
        return (w->W_top == 0);
 }
 
+/*******************************************************************************
+wl_reset
+
+Empties the worklist.
+
+IN:     worklist *w    pointer to worklist created with wl_new
+*******************************************************************************/
+void wl_reset(worklist *w, int size) {
+       w->W_top = 0;
+       bv_reset(w->W_bv, size);
+}
 
 /*
  * These are local overrides for various environment variables in Emacs.
index 9ec5a3c47aedf9868413870f7223f8214dd261ad..d8d5be07b097950f2df7862a85d8b09f902ed60b 100644 (file)
@@ -73,6 +73,7 @@ worklist *wl_new(int size);
 void wl_add(worklist *w, int element);
 int wl_get(worklist *w);
 bool wl_is_empty(worklist *w);
+void wl_reset(worklist *w, int size);
 
 
 #endif /* _BITVECTOR_H */
diff --git a/src/vm/.cvsignore b/src/vm/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index aa734bda8b688b4a45e7f343071dec695ce7bc0e..96c6400358fc3c44ec16046aa14e4f662d312197 100644 (file)
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## $Id: Makefile.am 7786 2007-04-21 12:37:47Z edwin $
+## $Id: Makefile.am 7869 2007-05-05 08:08:49Z pm $
 
 ## 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
+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
 
 LIBS =
 
index 839a47d4ecccc2058b10d5a6bdf3125ca5e13c4c..21453355e075def1193955bdd1d0119a4feacfa0 100644 (file)
@@ -28,7 +28,7 @@
    calls instead of machine instructions, using the C calling
    convention.
 
-   $Id: builtin.c 7797 2007-04-23 20:12:39Z michi $
+   $Id: builtin.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -59,9 +59,7 @@
 #include "native/include/java_lang_String.h"
 #include "native/include/java_lang_Throwable.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/logging.h"
 #include "toolbox/util.h"
@@ -1866,7 +1864,7 @@ s8 builtin_lmul(s8 a, s8 b)
 #endif /* !(SUPPORT_LONG && SUPPORT_LONG_MUL) */
 
 
-#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
+#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) || defined (DISABLE_GC)
 s8 builtin_ldiv(s8 a, s8 b)
 {
        s8 c;
index 67689c47a6623a497577d97296fc4ec4a7569a22..4c77e4af29107bb8bcb201ea3fc19c95ff9ab2fd 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: finalizer.c 7343 2007-02-13 02:36:29Z ajordan $
+   $Id: finalizer.c 7831 2007-04-26 12:48:16Z twisti $
 
 */
 
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/threads-common.h"
-
-# include "threads/native/threads.h"
-# include "threads/native/lock.h"
-#else
-# include "threads/none/threads.h"
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -59,7 +52,6 @@
 /* global variables ***********************************************************/
 
 #if defined(ENABLE_THREADS)
-static threadobject      *thread_finalizer;
 static java_objectheader *lock_thread_finalizer;
 #endif
 
@@ -75,7 +67,7 @@ bool finalizer_init(void)
 #if defined(ENABLE_THREADS)
        lock_thread_finalizer = NEW(java_objectheader);
 
-       lock_init_object_lock(lock_thread_finalizer);
+       LOCK_INIT_OBJECT_LOCK(lock_thread_finalizer);
 #endif
 
        /* everything's ok */
@@ -129,15 +121,9 @@ bool finalizer_start_thread(void)
 
        name = utf_new_char("Finalizer");
 
-       thread_finalizer = threads_create_thread(name);
-
-       if (thread_finalizer == NULL)
+       if (!threads_thread_start_internal(name, finalizer_thread))
                return false;
 
-       /* actually start the finalizer thread */
-
-       threads_start_thread(thread_finalizer, finalizer_thread);
-
        /* everything's ok */
 
        return true;
index 366f85f9df446c2c39f0458929f932f7821ca1cf..9619b9656701d99276405cf37b745e1b9e7b759e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: initialize.c 7246 2007-01-29 18:49:05Z twisti $
+   $Id: initialize.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
 
 #include "vm/types.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/global.h"
 #include "vm/initialize.h"
diff --git a/src/vm/jit/.cvsignore b/src/vm/jit/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/allocator/.cvsignore b/src/vm/jit/allocator/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/alpha/.cvsignore b/src/vm/jit/alpha/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index a0c49618d522312250570367daf3ae93a9aaeea9..419ba3728a845c604ba62cecf291a54020dbb1e0 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -45,9 +45,7 @@
 #include "native/jni.h"
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -2710,42 +2708,24 @@ gen_method:
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
 
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *      
-                        *  OK if ((sub == NULL) ||
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL));
-                        *      
-                        *  superclass is a class:
-                        *      
-                        *  OK if ((sub == NULL) || (0
-                        *         <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *         super->vftbl->diffval));
-                        */
-
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
 
                                classinfo *super;
-                               vftbl_t   *supervftbl;
                                s4         superindex;
 
                                if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
-                                       super = NULL;
+                                       super      = NULL;
                                        superindex = 0;
-                                       supervftbl = NULL;
                                }
                                else {
-                                       super = iptr->sx.s23.s3.c.cls;
+                                       super      = iptr->sx.s23.s3.c.cls;
                                        superindex = super->index;
-                                       supervftbl = super->vftbl;
                                }
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               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 */
@@ -2809,16 +2789,16 @@ gen_method:
                                                                                          disp);
                                        }
                                        else {
-                                               disp = dseg_add_address(cd, supervftbl);
+                                               disp = dseg_add_address(cd, super->vftbl);
 
                                                emit_label_beqz(cd, BRANCH_LABEL_5, s1);
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       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)); */
@@ -2833,9 +2813,9 @@ gen_method:
                                        M_ISUB(REG_ITMP2, REG_ITMP3, REG_ITMP2);
                                        M_ALD(REG_ITMP3, REG_PV, disp);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        /*                              } */
                                        M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3);
                                        emit_classcast_check(cd, iptr, BRANCH_EQ, REG_ITMP3, s1);
@@ -2887,21 +2867,6 @@ gen_method:
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
 
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *      
-                        *  return (sub != NULL) &&
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL);
-                        *      
-                        *  superclass is a class:
-                        *      
-                        *  return ((sub != NULL) && (0
-                        *          <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *          super->vftbl->diffvall));
-                        */
-
                        {
                        classinfo *super;
                        vftbl_t   *supervftbl;
@@ -2918,9 +2883,9 @@ gen_method:
                                supervftbl = super->vftbl;
                        }
 
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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);
 
@@ -3002,15 +2967,15 @@ gen_method:
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_CMPULE(REG_ITMP1, REG_ITMP2, d);
 
@@ -3170,7 +3135,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                sizeof(stackframeinfo) / SIZEOF_VOID_P +
                sizeof(localref_table) / SIZEOF_VOID_P +
                1 +                             /* methodinfo for call trace          */
-               (md->paramcount > INT_ARG_CNT ? INT_ARG_CNT : md->paramcount) +
+               md->paramcount +
                nmd->memuse;
 
        /* create method header */
@@ -3218,17 +3183,21 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* save integer and float argument registers */
 
-       for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) {
-               if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
-                       M_LST(abi_registers_integer_argument[i], REG_SP, j * 8);
-                       j++;
-               }
-       }
+       for (i = 0; i < md->paramcount; i++) {
+               if (!md->params[i].inmemory) {
+                       s1 = md->params[i].regoff;
 
-       for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
-               if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
-                       M_DST(abi_registers_float_argument[i], REG_SP, j * 8);
-                       j++;
+                       switch (md->paramtypes[i].type) {
+                       case TYPE_INT:
+                       case TYPE_LNG:
+                       case TYPE_ADR:
+                               M_LST(s1, REG_SP, i * 8);
+                               break;
+                       case TYPE_FLT:
+                       case TYPE_DBL:
+                               M_DST(s1, REG_SP, i * 8);
+                               break;
+                       }
                }
        }
 
@@ -3246,17 +3215,21 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
        /* restore integer and float argument registers */
 
-       for (i = 0, j = 0; i < md->paramcount && i < INT_ARG_CNT; i++) {
-               if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
-                       M_LLD(abi_registers_integer_argument[i], REG_SP, j * 8);
-                       j++;
-               }
-       }
+       for (i = 0; i < md->paramcount; i++) {
+               if (!md->params[i].inmemory) {
+                       s1 = md->params[i].regoff;
 
-       for (i = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
-               if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
-                       M_DLD(abi_registers_float_argument[i], REG_SP, j * 8);
-                       j++;
+                       switch (md->paramtypes[i].type) {
+                       case TYPE_INT:
+                       case TYPE_LNG:
+                       case TYPE_ADR:
+                               M_LLD(s1, REG_SP, i * 8);
+                               break;
+                       case TYPE_FLT:
+                       case TYPE_DBL:
+                               M_DLD(s1, REG_SP, i * 8);
+                               break;
+                       }
                }
        }
 
index 38865c1232a9c8453b6753f30a5a16d41b875a1e..ee50adde72b66bca4fe55ff200bb3f3b74a27ca5 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 4398 2006-01-31 23:43:08Z twisti $
+   $Id: emit.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -38,9 +38,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
diff --git a/src/vm/jit/alpha/freebsd/.cvsignore b/src/vm/jit/alpha/freebsd/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/alpha/linux/.cvsignore b/src/vm/jit/alpha/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 4a559964e33d2fc312f1646c7cf1397450c90d98..c1fa249dd8fd88df18fa9e1737c172935db4d3bf 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7638 2007-04-02 21:24:59Z twisti $
+   $Id: md-os.c 7886 2007-05-07 21:34:01Z twisti $
 
 */
 
@@ -143,8 +143,15 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
+/* 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)
+void md_critical_section_restart(ucontext_t *_uc)
 {
        mcontext_t *_mc;
        u1         *pc;
@@ -156,8 +163,10 @@ void thread_restartcriticalsection(ucontext_t *_uc)
 
        npc = critical_find_restart_point(pc);
 
-       if (npc != NULL)
+       if (npc != NULL) {
+               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
                _mc->sc_pc = (ptrint) npc;
+       }
 }
 #endif
 
diff --git a/src/vm/jit/arm/.cvsignore b/src/vm/jit/arm/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index d888916551851d7c74623d239022e09b76375e8d..acb817d7d6a8d69103491897cc8bb4f1bbbeefe2 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7900 2007-05-11 20:35:16Z twisti $
 
 */
 
@@ -43,9 +43,7 @@
 
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -2431,7 +2429,6 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
-                                     /* val.a: (classinfo*) superclass               */
 
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
@@ -2448,9 +2445,9 @@ bool codegen_emit(jitdata *jd)
                                superindex = super->index;
                        }
 
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               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 */
@@ -2532,17 +2529,17 @@ bool codegen_emit(jitdata *jd)
 
                                M_LDR_INTERN(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
                                M_DSEG_LOAD(REG_ITMP3, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_CMP(REG_ITMP2, REG_ITMP3);
                                emit_classcast_check(cd, iptr, BRANCH_UGT, 0, s1);
 
@@ -2596,7 +2593,7 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
-                                     /* val.a: (classinfo*) superclass               */
+
                        {
                        classinfo *super;
                        s4         superindex;
@@ -2610,11 +2607,12 @@ bool codegen_emit(jitdata *jd)
                                superindex = super->index;
                        }
 
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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) {
                                M_MOV(REG_ITMP1, s1);
                                s1 = REG_ITMP1;
@@ -2709,15 +2707,15 @@ bool codegen_emit(jitdata *jd)
 
                                M_LDR_INTERN(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_DSEG_LOAD(REG_ITMP2, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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 */
index a60e471f0317d44ce27225270b5cf61f31acd64c..e16bc2ccc2781b09cc2faa33b9f4e2c54501eb37 100644 (file)
@@ -39,9 +39,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -77,25 +75,39 @@ s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
 
                disp = src->vv.regoff * 4;
 
-               if (IS_FLT_DBL_TYPE(src->type)) {
 #if defined(ENABLE_SOFTFLOAT)
-                       if (IS_2_WORD_TYPE(src->type))
-                               M_LLD(tempreg, REG_SP, disp);
-                       else
-                               M_ILD(tempreg, REG_SP, disp);
-#else
-                       if (IS_2_WORD_TYPE(src->type))
-                               M_DLD(tempreg, REG_SP, disp);
-                       else
-                               M_FLD(tempreg, REG_SP, disp);
-#endif
+               switch (src->type) {
+               case TYPE_INT:
+               case TYPE_FLT:
+               case TYPE_ADR:
+                       M_ILD(tempreg, REG_SP, disp);
+                       break;
+               case TYPE_LNG:
+               case TYPE_DBL:
+                       M_LLD(tempreg, REG_SP, disp);
+                       break;
+               default:
+                       vm_abort("emit_load: unknown type %d", src->type);
                }
-               else {
-                       if (IS_2_WORD_TYPE(src->type))
-                               M_LLD(tempreg, REG_SP, disp);
-                       else
-                               M_ILD(tempreg, REG_SP, disp);
+#else
+               switch (src->type) {
+               case TYPE_INT:
+               case TYPE_ADR:
+                       M_ILD(tempreg, REG_SP, disp);
+                       break;
+               case TYPE_LNG:
+                       M_LLD(tempreg, REG_SP, disp);
+                       break;
+               case TYPE_FLT:
+                       M_FLD(tempreg, REG_SP, disp);
+                       break;
+               case TYPE_DBL:
+                       M_DLD(tempreg, REG_SP, disp);
+                       break;
+               default:
+                       vm_abort("emit_load: unknown type %d", src->type);
                }
+#endif
 
                reg = tempreg;
        }
@@ -202,33 +214,45 @@ void emit_store(jitdata *jd, instruction *iptr, varinfo *dst, s4 d)
 
                disp = dst->vv.regoff * 4;
 
-               if (IS_FLT_DBL_TYPE(dst->type)) {
 #if defined(ENABLE_SOFTFLOAT)
-                       if (IS_2_WORD_TYPE(dst->type))
-                               M_LST(d, REG_SP, disp);
-                       else
-                               M_IST(d, REG_SP, disp);
-#else
-                       if (IS_2_WORD_TYPE(dst->type))
-                               M_DST(d, REG_SP, disp);
-                       else
-                               M_FST(d, REG_SP, disp);
-#endif
+               switch (dst->type) {
+               case TYPE_INT:
+               case TYPE_FLT:
+               case TYPE_ADR:
+                       M_IST(d, REG_SP, disp);
+                       break;
+               case TYPE_LNG:
+               case TYPE_DBL:
+                       M_LST(d, REG_SP, disp);
+                       break;
+               default:
+                       vm_abort("emit_store: unknown type %d", dst->type);
                }
-               else {
-                       if (IS_2_WORD_TYPE(dst->type))
-                               M_LST(d, REG_SP, disp);
-                       else
-                               M_IST(d, REG_SP, disp);
+#else
+               switch (dst->type) {
+               case TYPE_INT:
+               case TYPE_ADR:
+                       M_IST(d, REG_SP, disp);
+                       break;
+               case TYPE_LNG:
+                       M_LST(d, REG_SP, disp);
+                       break;
+               case TYPE_FLT:
+                       M_FST(d, REG_SP, disp);
+                       break;
+               case TYPE_DBL:
+                       M_DST(d, REG_SP, disp);
+                       break;
+               default:
+                       vm_abort("emit_store: unknown type %d", dst->type);
                }
+#endif
        }
        else if (IS_LNG_TYPE(dst->type)) {
 #if defined(__ARMEL__)
-               if (GET_HIGH_REG(dst->vv.regoff) == REG_SPLIT)
-                       M_IST_INTERN(GET_HIGH_REG(d), REG_SP, 0 * 4);
+               assert(GET_HIGH_REG(dst->vv.regoff) != REG_SPLIT);
 #else
-               if (GET_LOW_REG(dst->vv.regoff) == REG_SPLIT)
-                       M_IST_INTERN(GET_LOW_REG(d), REG_SP, 0 * 4);
+               assert(GET_LOW_REG(dst->vv.regoff) != REG_SPLIT);
 #endif
        }
 }
@@ -303,27 +327,45 @@ void emit_copy(jitdata *jd, instruction *iptr)
                }
 
                if (s1 != d) {
-                       if (IS_FLT_DBL_TYPE(src->type)) {
 #if defined(ENABLE_SOFTFLOAT)
-                               if (IS_2_WORD_TYPE(src->type))
-                                       M_LNGMOVE(s1, d);
-                               else
-                                       /* XXX grrrr, wrong direction! */
-                                       M_MOV(d, s1);
-#else
-                               if (IS_2_WORD_TYPE(src->type))
-                                       M_DMOV(s1, d);
-                               else
-                                       M_FMOV(s1, d);
-#endif
+                       switch (src->type) {
+                       case TYPE_INT:
+                       case TYPE_FLT:
+                       case TYPE_ADR:
+                               /* XXX grrrr, wrong direction! */
+                               M_MOV(d, s1);
+                               break;
+                       case TYPE_LNG:
+                       case TYPE_DBL:
+                               /* XXX grrrr, wrong direction! */
+                               M_MOV(GET_LOW_REG(d), GET_LOW_REG(s1));
+                               M_MOV(GET_HIGH_REG(d), GET_HIGH_REG(s1));
+                               break;
+                       default:
+                               vm_abort("emit_copy: unknown type %d", src->type);
                        }
-                       else {
-                               if (IS_2_WORD_TYPE(src->type))
-                                       M_LNGMOVE(s1, d);
-                               else
-                                       /* XXX grrrr, wrong direction! */
-                                       M_MOV(d, s1);
+#else
+                       switch (src->type) {
+                       case TYPE_INT:
+                       case TYPE_ADR:
+                               /* XXX grrrr, wrong direction! */
+                               M_MOV(d, s1);
+                               break;
+                       case TYPE_LNG:
+                               /* XXX grrrr, wrong direction! */
+                               M_MOV(GET_LOW_REG(d), GET_LOW_REG(s1));
+                               M_MOV(GET_HIGH_REG(d), GET_HIGH_REG(s1));
+                               break;
+                       case TYPE_FLT:
+                               M_FMOV(s1, d);
+                               break;
+                       case TYPE_DBL:
+                               M_DMOV(s1, d);
+                               break;
+                       default:
+                               vm_abort("emit_copy: unknown type %d", src->type);
                        }
+#endif
                }
 
                emit_store(jd, iptr, dst, d);
diff --git a/src/vm/jit/arm/linux/.cvsignore b/src/vm/jit/arm/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index d37c191c477d0bbc8dff8cf40da857bbf73a7099..4ed764b31f2e3ba2478642c73235faba29df7fda 100644 (file)
@@ -200,24 +200,30 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
-/* thread_restartcriticalsection ***********************************************
+/* md_critical_section_restart *************************************************
 
-   TODO: document me
+   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)
+void md_critical_section_restart(ucontext_t *_uc)
 {
        scontext_t *_sc;
-       void       *critical;
+       u1         *pc;
+       u1         *npc;
 
        _sc = &_uc->uc_mcontext;
 
-       critical = critical_find_restart_point((void *) _sc->arm_pc);
+       pc = (u1 *) _sc->arm_pc;
+
+       npc = critical_find_restart_point(pc);
 
-       if (critical)
-               _sc->arm_pc = (ptrint) critical;
+       if (npc != NULL) {
+               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
+               _sc->arm_pc = (ptrint) npc;
+       }
 }
 #endif
 
index bc63d9550039f1f0ab6d44868716813a00264928..cccf3acb10b7939a6b0fa47df146df5c0166a7a0 100644 (file)
@@ -39,7 +39,7 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen-common.c 7797 2007-04-23 20:12:39Z michi $
+   $Id: codegen-common.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #include "vm/jit/jit.h"
 #include "vm/jit/md.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"
 
 #if defined(ENABLE_INTRP)
 
 /* in this tree we store all method addresses *********************************/
 
-static avl_tree *methodtree = NULL;
-static s4 methodtree_comparator(const void *pc, const void *element);
+static avl_tree_t *methodtree = NULL;
+static s4 methodtree_comparator(const void *treenode, const void *node);
 
 
 /* codegen_init ****************************************************************
@@ -199,16 +203,12 @@ void codegen_setup(jitdata *jd)
 /*     cd->patchrefs      = list_create_dump(OFFSET(patchref, linkage)); */
        cd->patchrefs      = NULL;
        cd->brancheslabel  = list_create_dump(OFFSET(branch_label_ref_t, linkage));
+       cd->listcritical   = list_create_dump(OFFSET(critical_section_ref_t, linkage));
 
        cd->linenumberreferences = NULL;
        cd->linenumbertablesizepos = 0;
        cd->linenumbertablestartpos = 0;
        cd->linenumbertab = 0;
-       
-#if defined(ENABLE_THREADS)
-       cd->threadcritcurrent.next = NULL;
-       cd->threadcritcount = 0;
-#endif
 }
 
 
@@ -251,17 +251,13 @@ static void codegen_reset(jitdata *jd)
 /*     cd->patchrefs       = list_create_dump(OFFSET(patchref, linkage)); */
        cd->patchrefs       = NULL;
        cd->brancheslabel   = list_create_dump(OFFSET(branch_label_ref_t, linkage));
+       cd->listcritical    = list_create_dump(OFFSET(critical_section_ref_t, linkage));
 
        cd->linenumberreferences    = NULL;
        cd->linenumbertablesizepos  = 0;
        cd->linenumbertablestartpos = 0;
        cd->linenumbertab           = 0;
        
-#if defined(ENABLE_THREADS)
-       cd->threadcritcurrent.next = NULL;
-       cd->threadcritcount        = 0;
-#endif
-
        /* We need to clear the mpc and the branch references from all
           basic blocks as they will definitely change. */
 
@@ -563,19 +559,182 @@ void codegen_add_patch_ref(codegendata *cd, functionptr patcher, voidptr ref,
 }
 
 
+/* 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                 *list;
+       critical_section_ref_t *csr;
+       s4                      mpc;
+
+       /* get the critical section list */
+
+       list = 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_unsynced(list, 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                 *list;
+       critical_section_ref_t *csr;
+       s4                      mpc;
+
+       /* get the critical section list */
+
+       list = cd->listcritical;
+       
+       /* calculate the current mpc */
+
+       mpc = cd->mcodeptr - cd->mcodebase;
+
+       /* get the current critical section */
+
+       csr = list_last_unsynced(list);
+
+       /* 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                 *list;
+       critical_section_ref_t *csr;
+       s4                      mpc;
+
+       /* get the critical section list */
+
+       list = cd->listcritical;
+       
+       /* calculate the current mpc */
+
+       mpc = cd->mcodeptr - cd->mcodebase;
+
+       /* get the current critical section */
+
+       csr = list_last_unsynced(list);
+
+       /* 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                  *list;
+       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 */
+
+       list = cd->listcritical;
+
+       /* iterate over all critical sections */
+
+       for (csr = list_first_unsynced(list); csr != NULL;
+                csr = list_next_unsynced(list, 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
+
+
 /* methodtree_comparator *******************************************************
 
    Comparator function used for the AVL tree of methods.
 
+   ARGUMENTS:
+      treenode....the node from the tree
+      node........the node to compare to the tree-node
+
 *******************************************************************************/
 
-static s4 methodtree_comparator(const void *pc, const void *element)
+static s4 methodtree_comparator(const void *treenode, const void *node)
 {
        methodtree_element *mte;
        methodtree_element *mtepc;
 
-       mte = (methodtree_element *) element;
-       mtepc = (methodtree_element *) pc;
+       mte   = (methodtree_element *) treenode;
+       mtepc = (methodtree_element *) node;
 
        /* compare both startpc and endpc of pc, even if they have the same value,
           otherwise the avl_probe sometimes thinks the element is already in the
@@ -777,7 +936,6 @@ void codegen_finish(jitdata *jd)
        s4           alignedmcodelen;
        jumpref     *jr;
        u1          *epoint;
-       s4           extralen;
        s4           alignedlen;
 
        /* get required compiler data */
@@ -795,12 +953,6 @@ void codegen_finish(jitdata *jd)
 
        mcodelen = (s4) (cd->mcodeptr - cd->mcodebase);
 
-#if defined(ENABLE_THREADS)
-       extralen = sizeof(critical_section_node_t) * cd->threadcritcount;
-#else
-       extralen = 0;
-#endif
-
 #if defined(ENABLE_STATISTICS)
        if (opt_stat) {
                count_code_len += mcodelen;
@@ -830,7 +982,7 @@ void codegen_finish(jitdata *jd)
        /* allocate new memory */
 
        code->mcodelength = mcodelen + cd->dseglen;
-       code->mcode       = CNEW(u1, alignedlen + extralen);
+       code->mcode       = CNEW(u1, alignedlen);
 
        /* set the entrypoint of the method */
        
@@ -928,20 +1080,9 @@ void codegen_finish(jitdata *jd)
 #endif
 
 #if defined(ENABLE_THREADS)
-       {
-               critical_section_node_t *n = (critical_section_node_t *) ((ptrint) code->mcode + alignedlen);
-               s4 i;
-               codegen_critical_section_t *nt = cd->threadcrit;
-
-               for (i = 0; i < cd->threadcritcount; i++) {
-                       n->mcodebegin = (u1 *) (ptrint) code->mcode + nt->mcodebegin;
-                       n->mcodeend = (u1 *) (ptrint) code->mcode + nt->mcodeend;
-                       n->mcoderestart = (u1 *) (ptrint) code->mcode + nt->mcoderestart;
-                       critical_register_critical_section(n);
-                       n++;
-                       nt = nt->next;
-               }
-       }
+       /* create cirtical sections */
+
+       codegen_critical_section_finish(jd);
 #endif
 
        /* flush the instruction and data caches */
@@ -1083,7 +1224,7 @@ void codegen_generate_stub_builtin(builtintable_entry *bte)
 
 #if defined(ENABLE_STATISTICS)
        if (opt_stat)
-               count_nstub_len += code->mcodelength;
+               size_stub_native += code->mcodelength;
 #endif
 
        /* release memory */
@@ -1198,8 +1339,10 @@ codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
        codegen_finish(jd);
 
 #if defined(ENABLE_STATISTICS)
+       /* must be done after codegen_finish() */
+
        if (opt_stat)
-               count_nstub_len += code->mcodelength;
+               size_stub_native += code->mcodelength;
 #endif
 
 #if !defined(NDEBUG)
@@ -1363,7 +1506,7 @@ void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra)
 
        stacktrace_create_native_stackframeinfo(sfi, pv, sp, ra);
 
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
        /* add current JNI local references table to this thread */
 
        lrt->capacity    = LOCALREFTABLE_CAPACITY;
@@ -1398,7 +1541,7 @@ java_objectheader *codegen_finish_native_call(u1 *datasp)
 {
        stackframeinfo     *sfi;
        stackframeinfo    **psfi;
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
        localref_table     *lrt;
        localref_table     *plrt;
        s4                  localframes;
@@ -1421,7 +1564,7 @@ java_objectheader *codegen_finish_native_call(u1 *datasp)
 
        *psfi = sfi->prev;
 
-#if defined(ENABLE_JAVASE)
+#if defined(ENABLE_JNI)
        /* release JNI local references tables for this thread */
 
        lrt = LOCALREFTABLE;
@@ -1559,28 +1702,95 @@ s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum)
 }
 
 
-#if defined(ENABLE_THREADS)
-void codegen_threadcritrestart(codegendata *cd, int offset)
-{
-       cd->threadcritcurrent.mcoderestart = offset;
-}
+/* codegen_emit_phi_moves ****************************************************
 
+   Emits phi moves at the end of the basicblock.
+
+*******************************************************************************/
 
-void codegen_threadcritstart(codegendata *cd, int offset)
+#if defined(ENABLE_SSA)
+void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr)
 {
-       cd->threadcritcurrent.mcodebegin = offset;
-}
+       int lt_d,lt_s,i;
+       lsradata *ls;
+       codegendata *cd;
+       varinfo *s, *d;
+       instruction tmp_i;
 
+       cd = jd->cd;
+       ls = jd->ls;
 
-void codegen_threadcritstop(codegendata *cd, int offset)
-{
-       cd->threadcritcurrent.next = cd->threadcrit;
-       cd->threadcritcurrent.mcodeend = offset;
-       cd->threadcrit = DNEW(codegen_critical_section_t);
-       *(cd->threadcrit) = cd->threadcritcurrent;
-       cd->threadcritcount++;
-}
+       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
+                       return;
+               }
+
+               if (s->type == -1) {
+#if defined(SSA_DEBUG_VERBOSE)
+                       if (compileverbose)
+                               printf("...returning - phi lifetimes where joined\n");
+#endif
+                       return;
+               }
+
+               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) */
+
 
 
 /*
index b70f56fdfff95949a81addec74430bb9e2a6edbf..327bb5111caad9f4b51e26c4e7529e176e94afe0 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen-common.h 7797 2007-04-23 20:12:39Z michi $
+   $Id: codegen-common.h 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct codegen_critical_section_t codegen_critical_section_t;
-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 patchref                   patchref;
-typedef struct linenumberref              linenumberref;
+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 patchref               patchref;
+typedef struct linenumberref          linenumberref;
 
 
 #include "config.h"
@@ -102,17 +102,6 @@ typedef struct linenumberref              linenumberref;
 #define BRANCH_OPT_NONE         0
 
 
-
-/************************* critical sections  *********************************/
-
-struct codegen_critical_section_t {
-       codegen_critical_section_t *next;
-       s4                  mcodebegin;
-       s4                  mcodeend;
-       s4                  mcoderestart;
-};
-
-
 /* codegendata ****************************************************************/
 
 struct codegendata {
@@ -149,6 +138,7 @@ struct codegendata {
 /*     list_t         *patchrefs; */
        patchref       *patchrefs;
        list_t         *brancheslabel;
+       list_t         *listcritical;   /* list of critical sections              */
 
        linenumberref  *linenumberreferences; /* list of line numbers and the     */
                                        /* program counters of their first        */
@@ -159,10 +149,6 @@ struct codegendata {
 
        methodinfo     *method;
 
-       codegen_critical_section_t *threadcrit; /* List of critical code regions          */
-       codegen_critical_section_t threadcritcurrent;
-       s4                 threadcritcount; /* Number of critical regions         */
-
        s4              stackframesize;    /* stackframe size of this method      */
 
 #if defined(ENABLE_REPLACEMENT)
@@ -205,6 +191,16 @@ struct branch_label_ref_t {
 };
 
 
+/* 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 {
@@ -341,14 +337,27 @@ 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_threadcritrestart(codegendata *cd, int offset);
-void codegen_threadcritstart(codegendata *cd, int offset);
-void codegen_threadcritstop(codegendata *cd, int offset);
+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
 
 /* machine dependent functions */
 u1 *md_codegen_get_pv_from_pc(u1 *ra);
 
+
+#if defined(ENABLE_SSA)
+void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
+#endif
+
 #endif /* _CODEGEN_COMMON_H */
 
 
index c313e873d77728e3c6a42c500a0c5c82244ceb9e..5863710b0017a1fd7c00ab8ab8ccabea0bb0db25 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: dseg.h 7596 2007-03-28 21:05:53Z twisti $
+   $Id: dseg.h 7903 2007-05-14 11:15:33Z tbfg $
 
 */
 
@@ -122,7 +122,7 @@ void dseg_createlinenumbertable(codegendata *cd);
 
 s4 dseg_get_linenumber_from_pc(methodinfo **pm, u1 *pv, u1 *pc);
 
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K___) || defined(ENABLE_INTRP)
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
 void dseg_adddata(codegendata *cd);
 void dseg_resolve_datareferences(jitdata *jd);
 #endif
index 030ee7466ca61b14c792d95cf95c6a02bfcf174e..b37c063eb9dbabba04411df6592c23b19a7668a0 100644 (file)
@@ -46,6 +46,7 @@
 #define BRANCH_LABEL_3    3
 #define BRANCH_LABEL_4    4
 #define BRANCH_LABEL_5    5
+#define BRANCH_LABEL_6    6
 
 
 /* constant range macros ******************************************************/
diff --git a/src/vm/jit/i386/.cvsignore b/src/vm/jit/i386/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index beeb23075eb81067f1384c0ca32adee4bd89588b..812f5bd0961c13557073bfcb66c220a0cd0c4cc4 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7794 2007-04-23 19:57:45Z michi $
+   $Id: codegen.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -43,9 +43,7 @@
 #include "native/jni.h"
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 
 *******************************************************************************/
 
-#if defined(ENABLE_SSA)
-void cg_move(codegendata *cd, s4 type, s4 src_regoff, s4 src_flags,
-                        s4 dst_regoff, s4 dst_flags);
-void codegen_insert_phi_moves(jitdata *jd, basicblock *bptr);
-#endif
-
 bool codegen_emit(jitdata *jd)
 {
        methodinfo         *m;
@@ -239,12 +231,15 @@ bool codegen_emit(jitdata *jd)
        for (p = 0, l = 0; p < md->paramcount; p++) {
                t = md->paramtypes[p].type;
 
+               varindex = jd->local_map[l * 5 + t];
 #if defined(ENABLE_SSA)
                if ( ls != NULL ) {
-                       l = ls->local_0[p];
+                       if (varindex != UNUSED)
+                               varindex = ls->var_0[varindex];
+                       if ((varindex != UNUSED) && (ls->lifetime[varindex].type == UNUSED))
+                               varindex = UNUSED;
                }
 #endif
-               varindex = jd->local_map[l * 5 + t];
                l++;
                if (IS_2_WORD_TYPE(t))    /* increment local counter for 2 word types */
                        l++;
@@ -398,9 +393,9 @@ bool codegen_emit(jitdata *jd)
        } 
 
 #if defined(ENABLE_SSA)
-       /* with SSA Header is Basic Block 0 - insert phi Moves if necessary */
+       /* with SSA the Header is Basic Block 0 - insert phi Moves if necessary */
        if ( ls != NULL)
-               codegen_insert_phi_moves(jd, ls->basicblocks[0]);
+               codegen_emit_phi_moves(jd, ls->basicblocks[0]);
 #endif
 
        /* end of header generation */
@@ -2489,9 +2484,11 @@ bool codegen_emit(jitdata *jd)
 #if defined(ENABLE_SSA)
                        if ( ls != NULL ) {
                                last_cmd_was_goto = true;
+
                                /* In case of a Goto phimoves have to be inserted before the */
                                /* jump */
-                               codegen_insert_phi_moves(jd, bptr);
+
+                               codegen_emit_phi_moves(jd, bptr);
                        }
 #endif
                        emit_br(cd, iptr->dst.block);
@@ -3077,8 +3074,8 @@ gen_method:
 
                        if (d != TYPE_VOID) {
 #if defined(ENABLE_SSA)
-                               if ((ls == NULL) || (!IS_TEMPVAR_INDEX(iptr->dst.varindex)) ||
-                                       (ls->lifetime[-iptr->dst.varindex-1].type != -1)) 
+                               if ((ls == NULL) /* || (!IS_TEMPVAR_INDEX(iptr->dst.varindex)) */ ||
+                                       (ls->lifetime[iptr->dst.varindex].type != UNUSED)) 
                                        /* a "living" stackslot */
 #endif
                                {
@@ -3102,20 +3099,6 @@ gen_method:
 
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *
-                        *  OK if ((sub == NULL) ||
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL));
-                        *
-                        *  superclass is a class:
-                        *
-                        *  OK if ((sub == NULL) || (0
-                        *         <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *         super->vftbl->diffval));
-                        */
 
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
@@ -3135,9 +3118,9 @@ gen_method:
                                        supervftbl = super->vftbl;
                                }
                        
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               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 */
@@ -3209,9 +3192,9 @@ gen_method:
                                        }
 
                                        M_MOV_IMM(supervftbl, REG_ITMP3);
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_START;
+
                                        M_ILD32(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
 
                                        /*                              if (s1 != REG_ITMP1) { */
@@ -3227,9 +3210,9 @@ gen_method:
                                        M_ISUB(REG_ITMP3, REG_ITMP2);
                                        M_MOV_IMM(supervftbl, REG_ITMP3);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        /*                              } */
 
                                        M_CMP(REG_ITMP3, REG_ITMP2);
@@ -3273,20 +3256,6 @@ gen_method:
                        break;
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *
-                        *  return (sub != NULL) &&
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL);
-                        *
-                        *  superclass is a class:
-                        *
-                        *  return ((sub != NULL) && (0
-                        *          <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *          super->vftbl->diffvall));
-                        */
 
                        {
                        classinfo *super;
@@ -3304,9 +3273,8 @@ gen_method:
                                supervftbl = super->vftbl;
                        }
                        
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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);
@@ -3390,15 +3358,15 @@ gen_method:
                                }
 
                                M_MOV_IMM(supervftbl, REG_ITMP2);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_START;
+
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, diffval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_ISUB(REG_ITMP2, REG_ITMP1);
                                M_CLR(d);                                 /* may be REG_ITMP2 */
                                M_CMP(REG_ITMP3, REG_ITMP1);
@@ -3492,10 +3460,12 @@ gen_method:
 #endif
 #if defined(ENABLE_SSA)
        if ( ls != NULL ) {
+
                /* by edge splitting, in Blocks with phi moves there can only */
                /* be a goto as last command, no other Jump/Branch Command    */
+
                if (!last_cmd_was_goto)
-                       codegen_insert_phi_moves(jd, bptr);
+                       codegen_emit_phi_moves(jd, bptr);
        }
 
 #endif
@@ -3526,176 +3496,6 @@ gen_method:
        return true;
 }
 
-#if defined(ENABLE_SSA)
-void codegen_insert_phi_moves(jitdata *jd, basicblock *bptr) {
-       /* look for phi moves */
-       int t_a,s_a,i, type;
-       int t_lt, s_lt; /* lifetime indices of phi_moves */
-       s4 t_regoff, s_regoff, s_flags, t_flags;
-       codegendata *cd;
-       lsradata *ls;
-
-       MCODECHECK(512);
-
-       ls = jd->ls;
-       cd = jd->cd;
-       
-       /* 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--) {
-               t_a = ls->phi_moves[bptr->nr][i][0];
-               s_a = ls->phi_moves[bptr->nr][i][1];
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose)
-                       printf("BB %3i Move %3i <- %3i ", bptr->nr, t_a, s_a);
-#endif
-               if (t_a >= 0) {
-                       /* local var lifetimes */
-                       t_lt = ls->maxlifetimes + t_a;
-                       type = ls->lifetime[t_lt].type;
-               }
-               else {
-                       t_lt = -t_a-1;
-                       type = ls->lifetime[t_lt].local_ss->s->type;
-                       /* stackslot lifetime */
-               }
-
-               if (type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       return;
-               }
-
-               if (s_a >= 0) {
-                       /* local var lifetimes */
-                       s_lt = ls->maxlifetimes + s_a;
-                       type = ls->lifetime[s_lt].type;
-               }
-               else {
-                       s_lt = -s_a-1;
-                       type = ls->lifetime[s_lt].type;
-                       /* stackslot lifetime */
-               }
-
-               if (type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       return;
-               }
-
-               if (t_a >= 0) {
-                       t_flags = VAR(t_a)->flags;
-                       t_regoff = VAR(t_a)->vv.regoff;
-                       
-               }
-               else {
-                       t_flags = ls->lifetime[t_lt].local_ss->s->flags;
-                       t_regoff = ls->lifetime[t_lt].local_ss->s->regoff;
-               }
-
-               if (s_a >= 0) {
-                       /* local var move */
-                       s_flags = VAR(s_a)->flags;
-                       s_regoff = VAR(s_a)->vv.regoff;
-               } else {
-                       /* stackslot lifetime */
-                       s_flags = ls->lifetime[s_lt].local_ss->s->flags;
-                       s_regoff = ls->lifetime[s_lt].local_ss->s->regoff;
-               }
-
-               if (type == -1) {
-#if defined(SSA_DEBUG_VERBOSE)
-                       if (compileverbose)
-                               printf("...returning - phi lifetimes where joined\n");
-#endif
-                       return;
-               }
-
-               cg_move(cd, type, s_regoff, s_flags, t_regoff, t_flags);
-
-#if defined(SSA_DEBUG_VERBOSE)
-               if (compileverbose) {
-                       if (IS_INMEMORY(t_flags) && IS_INMEMORY(s_flags)) {
-                               /* mem -> mem */
-                               printf("M%3i <- M%3i",t_regoff,s_regoff);
-                       }
-                       else    if (IS_INMEMORY(s_flags)) {
-                               /* mem -> reg */
-                               printf("R%3i <- M%3i",t_regoff,s_regoff);
-                       }
-                       else if (IS_INMEMORY(t_flags)) {
-                               /* reg -> mem */
-                               printf("M%3i <- R%3i",t_regoff,s_regoff);
-                       }
-                       else {
-                               /* reg -> reg */
-                               printf("R%3i <- R%3i",t_regoff,s_regoff);
-                       }
-                       printf("\n");
-               }
-#endif /* defined(SSA_DEBUG_VERBOSE) */
-       }
-}
-
-void cg_move(codegendata *cd, s4 type, s4 src_regoff, s4 src_flags,
-                        s4 dst_regoff, s4 dst_flags) {
-       if ((IS_INMEMORY(dst_flags)) && (IS_INMEMORY(src_flags))) {
-               /* mem -> mem */
-               if (dst_regoff != src_regoff) {
-                       if (!IS_2_WORD_TYPE(type)) {
-                               if (IS_FLT_DBL_TYPE(type)) {
-                                       emit_flds_membase(cd, REG_SP, src_regoff * 4);
-                                       emit_fstps_membase(cd, REG_SP, dst_regoff * 4);
-                               } else{
-                                       emit_mov_membase_reg(cd, REG_SP, src_regoff * 4,
-                                                       REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, dst_regoff * 4);
-                               }
-                       } else { /* LONG OR DOUBLE */
-                               if (IS_FLT_DBL_TYPE(type)) {
-                                       emit_fldl_membase( cd, REG_SP, src_regoff * 4);
-                                       emit_fstpl_membase(cd, REG_SP, dst_regoff * 4);
-                               } else {
-                                       emit_mov_membase_reg(cd, REG_SP, src_regoff * 4,
-                                                       REG_ITMP1);
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, dst_regoff * 4);
-                                       emit_mov_membase_reg(cd, REG_SP, src_regoff * 4 + 4,
-                            REG_ITMP1);             
-                                       emit_mov_reg_membase(cd, REG_ITMP1, REG_SP, 
-                                                       dst_regoff * 4 + 4);
-                               }
-                       }
-               }
-       } else {
-               if (IS_FLT_DBL_TYPE(type)) {
-                       log_text("cg_move: flt/dbl type have to be in memory\n");
-/*                     assert(0); */
-               }
-               if (IS_2_WORD_TYPE(type)) {
-                       log_text("cg_move: longs have to be in memory\n");
-/*                     assert(0); */
-               }
-               if (IS_INMEMORY(src_flags)) {
-                       /* mem -> reg */
-                       emit_mov_membase_reg(cd, REG_SP, src_regoff * 4, dst_regoff);
-               } else if (IS_INMEMORY(dst_flags)) {
-                       /* reg -> mem */
-                       emit_mov_reg_membase(cd, src_regoff, REG_SP, dst_regoff * 4);
-               } else {
-                       /* reg -> reg */
-                       /* only ints can be in regs on i386 */
-                       M_INTMOVE(src_regoff,dst_regoff);
-               }
-       }
-}
-#endif /* defined(ENABLE_SSA) */
-
-
 /* codegen_emit_stub_compiler **************************************************
 
    Emit a stub routine which calls the compiler.
diff --git a/src/vm/jit/i386/darwin/.cvsignore b/src/vm/jit/i386/darwin/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 488e5987c4a62c253968a1e6aa874dc47427f5af..07cd00491c2ef069efefe56c7e32290c39652a6c 100644 (file)
@@ -41,7 +41,9 @@
 
 #include "vm/types.h"
 
-#include "vm/jit/i386/md-abi.h"
+#include "vm/jit/i386/codegen.h"
+
+#include "threads/threads-common.h"
 
 #include "vm/exceptions.h"
 #include "vm/global.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.h"
 
+#include "vm/jit/i386/codegen.h"
+
 
 /* md_signal_handler_sigsegv ***************************************************
 
-   NullPointerException signal handler for hardware null pointer
-   check.
+   Signal handler for hardware exceptions.
 
 *******************************************************************************/
 
@@ -62,22 +65,68 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
        ucontext_t          *_uc;
        mcontext_t           _mc;
+       u1                  *pv;
        i386_thread_state_t *_ss;
        u1                  *sp;
        u1                  *ra;
        u1                  *xpc;
+    u1                   opc;
+    u1                   mod;
+    u1                   rm;
+    s4                   d;
+    s4                   disp;
+    ptrint               val;
+    s4                   type;
+    java_objectheader   *o;
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
        _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     */
+    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 */
 
-       _ss->eax =
-               (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
+        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))))));
+    }
+    else {
+        /* this was a normal NPE */
+
+        type = EXCEPTION_HARDWARE_NULLPOINTER;
+    }
+
+    /* generate appropriate exception */
+
+    o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
+
+    /* set registers */
+
+    _ss->eax = (ptrint) o;
        _ss->ecx = (ptrint) xpc;
        _ss->eip = (ptrint) asm_handle_exception;
 }
@@ -94,22 +143,35 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 {
        ucontext_t          *_uc;
        mcontext_t           _mc;
+    u1                  *pv;
        i386_thread_state_t *_ss;
        u1                  *sp;
        u1                  *ra;
        u1                  *xpc;
+    s4                   type;
+    ptrint               val;
+    java_objectheader   *o;
+
 
        _uc = (ucontext_t *) _p;
        _mc = _uc->uc_mcontext;
        _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     */
 
-       _ss->eax =
-               (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
+    /* this is an ArithmeticException */
+
+    type = EXCEPTION_HARDWARE_ARITHMETIC;
+    val  = 0;
+
+    /* generate appropriate exception */
+
+    o = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
 
+    _ss->eax = (ptrint) o;
        _ss->ecx = (ptrint) xpc;
        _ss->eip = (ptrint) asm_handle_exception;
 }
index 68fbed54a78c8c6d1e235f569b2347037fdb46e0..3570a26be67c724f88cf860b72d5fa9568dd144c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: emit.c 7818 2007-04-25 19:47:50Z twisti $
 
 */
 
@@ -39,9 +39,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -589,7 +587,6 @@ void emit_replacement_stubs(jitdata *jd)
        codegendata *cd;
        codeinfo    *code;
        rplpoint    *rplp;
-       s4           disp;
        s4           i;
        s4           branchmpc;
        s4           outcode;
diff --git a/src/vm/jit/i386/freebsd/.cvsignore b/src/vm/jit/i386/freebsd/.cvsignore
deleted file mode 100644 (file)
index cfca562..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
diff --git a/src/vm/jit/i386/linux/.cvsignore b/src/vm/jit/i386/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index bf5d64804d820b0756a62cbffe0b6b09d2284c0a..07dad897e36e3903d6233476c872da75bf612b09 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7667 2007-04-05 00:16:05Z michi $
+   $Id: md-os.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -223,15 +223,30 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
+/* 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)
+void md_critical_section_restart(ucontext_t *_uc)
 {
-       void *critical;
+       mcontext_t    *_mc;
+       u1            *pc;
+       void          *npc;
 
-       critical = critical_find_restart_point((void *) uc->uc_mcontext.gregs[REG_EIP]);
+       _mc = &_uc->uc_mcontext;
 
-       if (critical)
-               uc->uc_mcontext.gregs[REG_EIP] = (ptrint) critical;
+       pc = (u1 *) _mc->gregs[REG_EIP];
+
+       npc = critical_find_restart_point(pc);
+
+       if (npc != NULL) {
+               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
+               _mc->gregs[REG_EIP] = (ptrint) npc;
+       }
 }
 #endif
 
diff --git a/src/vm/jit/inline/.cvsignore b/src/vm/jit/inline/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 7e7bca87ad0049462483a972205819f5b7fdae1f..a43d248e1a84e92e83deb542d9152e1d33efc6c8 100644 (file)
@@ -1,6 +1,6 @@
 ## src/vm/jit/inline/Makefile.am
 ##
-## Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+## 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
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 ##
-## Contact: cacao@cacaojvm.org
-##
-## Authors: Christian Thalinger
-##
-## Changes:
-##
-## $Id: Makefile.am 4929 2006-05-15 23:31:56Z twisti $
+## $Id: Makefile.am 7841 2007-04-30 11:58:57Z twisti $
 
 ## 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)
+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
 
 LIBS =
 
index cbda14347a5ce1afd4a0fc6056b3d90358ac7128..b790fe4dbb27ab0fd2a53b9237fc3396463e9b32 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: inline.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: inline.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
@@ -38,9 +38,8 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "toolbox/logging.h"
 
@@ -340,10 +339,9 @@ static bool inline_jit_compile(inline_node *iln)
        m = iln->m;
        assert(m);
 
-#if defined(ENABLE_THREADS)
        /* enter a monitor on the method */
-       lock_monitor_enter((java_objectheader *) m);
-#endif
+
+       LOCK_MONITOR_ENTER(m);
 
        /* allocate jitdata structure and fill it */
 
@@ -384,10 +382,9 @@ static bool inline_jit_compile(inline_node *iln)
 
 #endif
 
-#if defined(ENABLE_THREADS)
        /* leave the monitor */
-       lock_monitor_exit((java_objectheader *) m );
-#endif
+
+       LOCK_MONITOR_EXIT(m);
 
        return r;
 }
index 0753235b10f2bb7f64438e4e6092aea158ae07a9..9a8bf8b4253f5cdb9f5897a1418bf68d18b42439 100644 (file)
@@ -1,6 +1,6 @@
-/* jit/inline.h - code inliner
+/* src/vm/jit/inline/inline.h - code inliner
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Edwin Steiner
-
-   Changes:
-
-   $Id: inline.h 4478 2006-02-07 17:22:13Z edwin $
+   $Id: inline.h 7835 2007-04-26 13:43:08Z twisti $
 
 */
 
 #ifndef _INLINE_H
 #define _INLINE_H
 
+#include "config.h"
+
 #include "vm/global.h"
 
+#include "vm/jit/jit.h"
+
+
+/* function prototypes ********************************************************/
+
+bool inline_inline(jitdata *jd);
+
 #endif /* _INLINE_H */
 
 /*
diff --git a/src/vm/jit/intrp/.cvsignore b/src/vm/jit/intrp/.cvsignore
deleted file mode 100644 (file)
index e04a7bc..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.i
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 9e50926400cde9fed38449b837b8eca461fba48b..b6e4c69dd4884462164ef6fe72e07c438d448343 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: jit.c 7692 2007-04-12 14:47:24Z twisti $
+   $Id: jit.c 7835 2007-04-26 13:43:08Z twisti $
 
 */
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
 #include "native/native.h"
+
 #include "toolbox/logging.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "vm/global.h"
 #include "vm/initialize.h"
 # include "vm/jit/optimizing/ssa.h"
 #endif
 
+#if defined(ENABLE_INLINING)
+# include "vm/jit/inline/inline.h"
+#endif
+
 #include "vm/jit/loop/analyze.h"
 #include "vm/jit/loop/graph.h"
 #include "vm/jit/loop/loop.h"
 
 #include "vm/jit/verify/typecheck.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
-
 #include "vmcore/class.h"
 #include "vmcore/loader.h"
 #include "vmcore/method.h"
diff --git a/src/vm/jit/loop/.cvsignore b/src/vm/jit/loop/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 9173d190615774fcf1e3db8511967cd7479c4173..e8be31f188fdc81e6a80187f1396c9f7703da33a 100644 (file)
 
 #define U8_AVAILABLE                     1
 
-#define SUPPORT_DIVISION                 0
-#define SUPPORT_LONG                     0
+#define SUPPORT_DIVISION                 1
+#define SUPPORT_LONG                     1
 
 #define SUPPORT_FMOD                     0
 #define SUPPORT_FICVT                    0
 #define SUPPORT_IFCVT                    0
 
-#define SUPPORT_LONG_ADD                 0
+#define SUPPORT_LONG_ADD                 1
 #define SUPPORT_LONG_CMP                 0
 #define SUPPORT_LONG_CMP_CONST           0
 #define SUPPORT_LONG_LOGICAL             0
@@ -54,7 +54,7 @@
 #define SUPPORT_LONG_ICVT                0
 #define SUPPORT_LONG_FCVT                0
 
-#define SUPPORT_CONST_LOGICAL            0  /* AND, OR, XOR with immediates   */
+#define SUPPORT_CONST_LOGICAL            1  /* AND, OR, XOR with immediates   */
 #define SUPPORT_CONST_MUL                1  /* mutiply with immediate         */
 
 #define SUPPORT_CONST_STORE              0  /* do we support const stores     */
                                             /* only store REG_ZERO            */
 
 
-/* float **********************************************************************/
-
-#define SUPPORT_FLOAT                    0
 
-#if defined(ENABLE_SOFT_FLOAT_CMP)
-# define SUPPORT_FLOAT_CMP               0
+#if defined(ENABLE_SOFTFLOAT)
+       #define SUPPORT_FLOAT                   0
+       #define SUPPORT_DOUBLE                  0
+       #define SUPPORT_FLOAT_CMP               0
+       #define SUPPORT_DOUBLE_CMP              0
 #else
-# define SUPPORT_FLOAT_CMP               0
-#endif
+       #define SUPPORT_FLOAT                    1
+       #define SUPPORT_DOUBLE                   1
 
+/* float **********************************************************************/
+       #if defined(ENABLE_SOFT_FLOAT_CMP)
+               #define SUPPORT_FLOAT_CMP               0
+       #else
+               #define SUPPORT_FLOAT_CMP               1
+       #endif
 
 /* double *********************************************************************/
+       #if defined(ENABLE_SOFT_DOUBLE_CMP)
+               #define SUPPORT_DOUBLE_CMP              0
+       #else
+               #define SUPPORT_DOUBLE_CMP              1
+       #endif
 
-#define SUPPORT_DOUBLE                   0
-
-#if defined(ENABLE_SOFT_FLOAT_CMP)
-# define SUPPORT_DOUBLE_CMP              0
-#else
-# define SUPPORT_DOUBLE_CMP              0
 #endif
 
 
+
+
+
 #define HAS_ADDRESS_REGISTER_FILE        1
 
 #define HAS_4BYTE_STACKSLOT            1
 
 #define TRACE_ARGS_NUM                 8
 
-#warning There is no REG_ZERO
-#define REG_ZERO 666
+#define REG_ZERO -1
 
 #define SPECIALMEMUSE
 /* #define HAS_4BYTE_STACKSLOT */
index f2e0e5e658dd477d2e71a15128778ac375642c92..c963ae599b70e43444d44a41edf4e6a5c83ff471 100644 (file)
@@ -64,6 +64,8 @@ asm_vm_call_method_int:
 asm_vm_call_method_long:
 asm_vm_call_method_float:
 asm_vm_call_method_double:
+
+#if defined(ENABLE_SOFTFLOAT)
        addal   #(-11*4),%sp                                            /* create stackframe to save registers */
        moveml  %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp,%sp@        /* save registers */
 
@@ -71,9 +73,20 @@ asm_vm_call_method_double:
        movel   %sp@(11*4+1*4),%a2                              /* methodinfo argument in atmp1 */
        movel   %sp@(11*4+3*4),%a3                              /* args block */
        movel   %sp@(11*4+2*4),%d2                              /* arg count */
+#else
+       addal #(-11*4-6*8), %sp
+       moveml  %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp,%sp@        /* save registers */
+       fmovemd %fp2/%fp3/%fp4/%fp5/%fp6/%fp7,%sp@(11*4)                        /* save registers */
+
+       /* fetch arguments from vmargs data structure */
+       movel   %sp@(11*4+6*8+1*4),%a2                          /* methodinfo argument in atmp1 */
+       movel   %sp@(11*4+6*8+3*4),%a3                          /* args block */
+       movel   %sp@(11*4+6*8+2*4),%d2                          /* arg count */
+#endif
+
 
        moveal  %sp, %a5                                        /* memorize stack */
-       tst     %d2                                             /* do we have arguments ? */
+       tstl    %d2                                                     /* do we have arguments ? */
        beq     L_asm_vm_call_method_copy_done
        subql   #1,%d2                                          /* simplifies offset calulation */
 
@@ -84,87 +97,112 @@ asm_vm_call_method_double:
 
        addql   #1, %d2
 L_asm_vm_call_copy_arg:
-       subql   #1, %d2                                         /* why wasn't that here */
+       subql   #1, %d2                                         /* decrement argument counter */
+       movel   %a0@(offvmargtype+4), %d1       /* %d1 contains type of arg, vmargtype is u8 */ 
+
+       cmpil   #2, %d1                                         /* float type ? */
+       bne             L_asm_vm_call_copy_int
+
+       movel   %a0@(offvmargdata), %d0         /* float has different endianess as int */
+       movel   %d0, %sp@-
+       bra             L_asm_vm_call_copy_1_word_type
 
+L_asm_vm_call_copy_int:
        movel   %a0@(offvmargdata+4), %d0
        movel   %d0,%sp@-                                       /* push argument onto stack */
 
-       movel   %a0@(offvmargtype), %d0                         /* %d0 contains type of arg */  
-       btstl   #0, %d0                                         /* test if 2 word type */
+       btstl   #0, %d1                                         /* test if 2 word type */
        beq     L_asm_vm_call_copy_1_word_type
-       movel   %a0@(offvmargdata), %d0                         /* push second word onto stack */
+       movel   %a0@(offvmargdata), %d0         /* push second word onto stack */
        movel   %d0,%sp@-
 L_asm_vm_call_copy_1_word_type:
 
        subl    #(sizevmarg),%a0
-       tst     %d2                                             /* arguments left ? */
+       tstl    %d2                                                     /* arguments left ? */
        bne     L_asm_vm_call_copy_arg
 
 L_asm_vm_call_method_copy_done:
 
        leal    asm_call_jit_compiler,%a4                       /* we need to fake a invocation as it would happen from jit code */
-       movel   %a4, call_jit_dummy                             /* we need a writeable memory location */
-       moveal  call_jit_dummy, %a4                             /* XXX do we have a race condition here ? */
+       movel   %a4, call_jit_dummy                                     /* we need a writeable memory location */
+       moveal  call_jit_dummy, %a4                                     /* XXX do we have a race condition here ? */
        jsr     %a4@
 
 L_asm_vm_call_method_return:
        movel   %a5, %sp                                                /* pop arguments off stack */
+
+#if defined(ENABLE_SOFTFLOAT)
        moveml  %sp@, %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp       /* restore registers */
        addal   #(11*4),%sp                                             /* restore stack */
-       rts                                                             /* return to c code */
-       jsr 0   /* never come back ? */
+#else
+       fmovemd %sp@(11*4), %fp2/%fp3/%fp4/%fp5/%fp6/%fp7                       /* restore registers */
+       moveml  %sp@, %d2/%d3/%d4/%d5/%d6/%d7/%a2/%a3/%a4/%a5/%fp       /* restore registers */
+       addal   #(11*4+6*8),%sp                                         /* restore stack */
+#endif
+       moveal  %d0, %a0                                                /* XXX return value in %a0, too, gcc sometimes expects addresses in %a0, wired */
+asm_vm_call_method_end:                                                /* symbol needed to insert method into avl tree */
+       rts                                                                             /* return to c code */
 
-/* asm_vm_call_method_exception_handler        
+/* asm_vm_call_method_exception_handler        ********************************************************************
  *
  * calls void *builtin_throw_exception(java_objectheader *xptr) when no other handler is appropiate
- * this functions gets called indirectly from asm_handle_exception, which back then moved xptr to %a3
+ * this functions gets called indirectly from asm_handle_exception, which back then moved xptr to %a2
  * clear software design is in the eye of the beholder.
- */
+ ************************************************************************************************************/
 asm_vm_call_method_exception_handler:
-       movel   %a3, %sp@-                      /* push xptr argument */
+       movel   %a2, %sp@-                      /* push xptr argument */
        jsr     builtin_throw_exception
        lea     %sp@(4), %sp                    /* pop arg off stack */
-       bra     L_asm_vm_call_method_return
+       jmp     L_asm_vm_call_method_return
 
 
-asm_vm_call_method_end:                                                /* symbol needed to insert method into avl tree */
-       rts
-/*
+/* asm_call_jit_compiler ************************************************************************************
  *     Invokes compiler for untranslated java methods.
  *     C prototype: void asm_call_jit_compiler(void);
  *     BUT: this does not match reality, arguments _ARE_ passed via createcompilerstub and asm_vm_call_method...
  *     arguments passed via %a2(methodinfo) == REG_ATMP1
- *                           %a3(mptr)       == REG_ATMP2
- */
+ *                       %a3(mptr)       == REG_ATMP2
+ ************************************************************************************************************/
 asm_call_jit_compiler:
        addal   #(-4*4),%sp                                             /* create stackframe to save registers */
-       moveml  %a0/%a1/%d0/%d1,%sp@                                    /* save volatile registers */
-
-       movel   %sp@(4*4),%sp@-                                         /* push arguments onto stack (ra)*/
-       pea     %sp@(4*4+4)                                             /* the old stack pointer */
+       moveml  %a0/%a1/%d0/%d1,%sp@                    /* save volatile registers */
+#if !defined(ENABLE_SOFTFLOAT)
+       addal   #-8*2, %sp
+       fmovemd %fp0/%fp1, %sp@
+       movel   %sp@(8*4), %sp@-
+       pea             %sp@(8*4+8)
+#else
+       movel   %sp@(4*4), %sp@-                                /* push arguments onto stack (ra)*/
+       pea     %sp@(4*4+8)                                             /* the old stack pointer*/
+#endif
        movel   %a3,%sp@-                                               /* mptr */
        movel   %a2,%sp@-                                               /* methodinfo */
 
        /* C prototype: u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra); */
        jsr     jit_asm_compile                                         /* invoke compiler */
-       lea     %sp@(4*4),%sp                                           /* pop arguments off stack */
+       addal   #(4*4),%sp                                              /* pop arguments off stack */
        moveal  %d0, %a2                                                /* to tmp register */
 
-       moveml %sp@,%a0/%a1/%d0/%d1                                     /* restore volatile registers */
+#if !defined(ENABLE_SOFTFLOAT)
+       fmovemd %sp@, %fp0/%fp1
+       addal   #8*2, %sp
+#endif
+
+       moveml %sp@,%a0/%a1/%d0/%d1                             /* restore volatile registers */
        addal   #(4*4),%sp                                              /* remove stackframe */
 
-       tstl    %a2                                                     /* check for exception */
+       tstl    %a2                                                             /* check for exception */
        beq     L_asm_call_jit_compiler_exception
 
-       jmp     %a2@                                                    /* invoke java method */
-       jsr     0                                                       /* we should not ever return here */
+       jmp     %a2@                                                            /* invoke java method */
+       jsr     0                                                               /* we should not ever return here */
 
 L_asm_call_jit_compiler_exception:
-       jsr     0                                                       /* TODO */
+       jsr             exceptions_get_and_clear_exception              /* exception object in %d0 now */
+       moveal  %d0, %a2                                                                /* move exception object into sptr register */
+       moveal  %sp@+, %a3                                                              /* pop return address into exception address reg */
+       jmp asm_handle_exception                                                /* handle exception */
 
-       moveml  %fp@(-4*4), %a0/%a1/%d0/%d1                             /* restore registers */
-       unlk    %fp                                                     /* FIXME: this is wrong */
-       rts
 
 /* asm_patcher_wrapper ********************************************************
        
@@ -182,30 +220,36 @@ L_asm_call_jit_compiler_exception:
 *******************************************************************************/
 asm_patcher_wrapper:
 
-  movel %sp, %d0
   /* save scratch registers */
   movel %a0, %sp@-
   movel %a1, %sp@-
   movel %d0, %sp@-
   movel %d1, %sp@-
-#if !defined(ENABLE_SOFTFLOAT)
-  movel %f0, %sp@-
-  movel %f1, %sp@-
+
+#if defined(ENABLE_SOFTFLOAT)
+  /* calculate original value of sp */
+  movel %sp, %d0
+  addil #4*4, %d0
+#else
+  addal #-8*2, %sp
+  fmovemd %fp0/%fp1, %sp@
+
+  movel %sp, %d0
+  addil #8*4, %d0
 #endif
 
   clrl %sp@-                           /* pass ra */
   clrl %sp@-                           /* pass pv, if null use findmethod */
   movel %d0, %sp@-                     /* pass sp of patcher stub */
-  jsr  patcher_wrapper                 /* return value in %d0 */
-
-  lea  %sp@(3*4), %sp                  /* pop arguments off stack */
+  jsr  patcher_wrapper         /* return value in %d0 */
 
-  tst  %d0                             /* test if exception occured */
+  lea  %sp@(3*4), %sp          /* pop arguments off stack */
+  tst  %d0                                     /* test if exception occured */
   bne  L_asm_patcher_wrapper_exception
 
 #if !defined(ENABLE_SOFTFLOAT)
-  movel %sp@+, %f0
-  movel %sp@+, %f1
+  fmovemd %sp@, %fp0/%fp1
+  addal #8*2, %sp
 #endif
   movel %sp@+, %d1
   movel %sp@+, %d0
@@ -213,11 +257,23 @@ asm_patcher_wrapper:
   movel %sp@+, %a0
 
   lea   %sp@(6*4), %sp                 /* restore stack and remove patcher stub*/
-  rts                                  /* back to jit code */
+  rts                                                  /* back to jit code */
 
 L_asm_patcher_wrapper_exception:
   /* WARNING: the stack is still disturbed, look at asm_patcher_wrapper for details */
-  jsr 0                                        /* TODO */
+  /* we do not need to restore the content of the registers, I hope */
+#if !defined(ENABLE_SOFTFLOAT)
+       lea             %sp@(8*4), %sp
+#else
+       lea             %sp@(4*4), %sp
+#endif
+
+  lea          %sp@(5*4), %sp                          /* restore stack and remove patcher stub*/
+  movel                %sp@+, %d4                                      /* restore REG_ITMP3, stored in emit_patcher_stubs */
+  moveal       %d0, %a2                                        /* xptr, pointer to exception object */
+  moveal       %sp@+, %a3                                      /* pop return address into exception address register */
+  jmp          asm_handle_exception            /* handle exception */
+  illegal                                                              /* XXX: we never come back */
 
 /********************************************************************************
        Reads a few values atomically. 
@@ -272,16 +328,30 @@ asm_handle_nat_exception:
        lea     %sp@(4), %sp
 asm_handle_exception:
 L_asm_handle_exception_stack_loop:
-       
+       /* save temporary registers */
+       movel   %d0, %sp@-
+       movel   %d1, %sp@-
+       movel   %a0, %sp@-
+       movel   %a1, %sp@-
+#if !defined(ENABLE_SOFTFLOAT)
+       addal   #-8*2, %sp
+       fmovemd %fp0, %sp@(0)
+       fmovemd %fp1, %sp@(8)
+#endif
+
        /* we need the dseg, figure it out */
        movel   %a3, %sp@-                              /* push ra argument */
-       jsr     md_codegen_get_pv_from_pc               /* pv in %d0 now */
+       jsr     md_codegen_get_pv_from_pc       /* pv in %d0 now */
        movel   %d0, %d2                                /* move to safe register */
        lea     %sp@(4), %sp                            /* pop args off stack */
 
        /* now call the following c function */
        /* u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp) */
-       movel   %sp,%sp@-
+#if !defined(ENABLE_SOFTFLOAT)
+       pea             %sp@(4*4 + 8*2)
+#else
+       pea             %sp@(4*4)
+#endif
        movel   %d2,%sp@-
        movel   %a3,%sp@-
        movel   %a2,%sp@-
@@ -291,13 +361,33 @@ L_asm_handle_exception_stack_loop:
        beq     L_asm_handle_exception_not_catched
 
        /* %d0 contains address of exception handler */
-       moveal  %d0, %a0
-       jmp     %a0@
+       moveal  %d0, %a3
+
+       /* restore temporary registers */
+       moveal  %sp@+, %a1
+       moveal  %sp@+, %a0
+       movel   %sp@+, %d1
+       movel   %sp@+, %d0
+#if !defined(ENABLE_SOFTFLOAT)
+       fmovemd %fp0, %sp@(0)
+       fmovemd %fp1, %sp@(8)
+       addal   #8*2, %sp
+#endif
+
+       jmp     %a3@
 
 L_asm_handle_exception_not_catched:
        /* we did not find an exception handler in this stackframe */
        /* remove this frame and search in the one above */
        /* %a2 containts exception object ptr, %d2 the actual pv */
+
+       /* remove temporary registers stored */
+#if !defined(ENABLE_SOFTFLOAT)
+       addal   #4*4 + 8*2, %sp
+#else
+       addal   #4*4, %sp
+#endif
+
        moveal  %d2, %a3
        movel   %a3@(FrameSize), %d2
 
@@ -310,36 +400,71 @@ L_asm_handle_exception_not_catched:
        andil   #0x0000ffff, %d0        /* this is IntSave */
        cmpb    #0,%d0
        beq     L_asm_handle_ex_int_done
-       movel   (%a0)+, %d7
+       movel   -(%a0), %d7
 
        cmpb    #1,%d0
        beq     L_asm_handle_ex_int_done
-       movel   (%a0)+, %d6
+       movel   -(%a0), %d6
 
        cmpb    #2,%d0 
        beq     L_asm_handle_ex_int_done
-       movel   (%a0)+, %d5
+       movel   -(%a0), %d5
 
 L_asm_handle_ex_int_done:
 
        movel   %a3@(IntSave), %d0
        andil   #0xffff0000, %d0        /* this is AdrSave */
-       tstl    %d0
-       beq     L_handle_exception_nat_catched_no_adr
-       moveal  (%a0)+, %a5
-L_handle_exception_nat_catched_no_adr:
+       lsrl    #8, %d0
+       lsrl    #8, %d0
+
+       cmpb    #0, %d0
+       beq     L_asm_handle_ex_adr_done
+       moveal  -(%a0), %fp
+
+       cmpb    #1,%d0
+       beq     L_asm_handle_ex_adr_done
+       moveal  -(%a0), %a5
+
+L_asm_handle_ex_adr_done:
 
 #if !defined(ENABLE_SOFTFLOAT)
-       FIXME
+       movel   %a3@(FltSave), %d0
+       cmpb    #0,%d0
+       beq     L_asm_handle_ex_flt_done
+       fmovemd %a0@(-8), %fp7
+
+       cmpb    #1,%d0
+       beq     L_asm_handle_ex_flt_done
+       fdmoved %a0@(-16), %fp6
+       
+       cmpb    #2,%d0
+       beq     L_asm_handle_ex_flt_done
+       fdmoved %a0@(-24), %fp5
+
+L_asm_handle_ex_flt_done:
 #else
        /* nothing to do */
 #endif
        addal   %d2, %sp                /* remove old stackframe */
-       moveal  %sp@(0), %a3            /* make return address, new exception rasing address */
-       addal   #4,%sp                  /* remove return address fromstack */
+       moveal  %sp@+, %a3              /* make return address, new exception rasing address */
        subal   #2, %a3                 /* it was a jsr %aX, which is 4 bytes long */
        jmp     L_asm_handle_exception_stack_loop
 
 
 illegal
 .long 0x23234242
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of 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:
+ */
index 1c3f1114d8ad3e18ae20c376b36a0db5baffe241..687901b970d8dd4c067c825c7672cc962ec02c12 100644 (file)
@@ -32,6 +32,7 @@
 #include <assert.h>
 
 #include "md-abi.h"
+#include "md-os.h"
 
 #include "vm/types.h"
 #include "vm/jit/m68k/codegen.h"
@@ -41,9 +42,7 @@
 #include "native/jni.h"
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -113,9 +112,27 @@ bool codegen_emit(jitdata *jd)
                savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2;
 
                cd->stackframesize = rd->memuse + savedregs_num;
+       
+               /* we always add 3 words, 
+                * 1 word the lock word, which may be unused and resides @ rd->memuse * 4
+                * + 2 words to either save the return value for LOCK_monitor_exit @ rd->memuse * 4 + 4
+                * on the other hand we could use 2 words when a builtin returns a doulbe which are
+                * returned in %d0, %d1 and need to be stored onto the stack and read in used a fmovemd
+                * so we always _need_ at least 2 words, and this keeps the code simple */
+               cd->stackframesize += 3;        
+
+#if 0
 #if defined(ENABLE_THREADS)
-               assert(0);
+               /* we need additional space to save argument of monitor_enter */
+               if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+                       if (IS_2_WORD_TYPE(m->parseddesc->returntype.type))     {
+                               cd->stackframesize += 2;
+                       } else  {
+                               cd->stackframesize += 1;
+                       }
+               }
 #endif
+#endif 
        
                /* create method header */
                (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
@@ -128,7 +145,7 @@ bool codegen_emit(jitdata *jd)
                (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
                (void) dseg_add_unique_s4(cd, jd->isleafmethod);       /* IsLeaf          */
 
-               /* XXX we use the IntSAce a split field for the adr now */
+               /* XXX we use the IntSave a split field for the adr now */
                (void) dseg_add_unique_s4(cd, (ADR_SAV_CNT - rd->savadrreguse) << 16 | (INT_SAV_CNT - rd->savintreguse)); /* IntSave */
                (void) dseg_add_unique_s4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave */
 
@@ -164,7 +181,7 @@ bool codegen_emit(jitdata *jd)
                }
 #if !defined(ENABLE_SOFTFLOAT)
                for (i=FLT_SAV_CNT-1; i>=rd->savfltreguse; --i) {
-                       p-=2; M_FST(rd->savfltregs[i], REG_SP, p*4);    /* FIXME */
+                       p-=2; M_FSTORE(rd->savfltregs[i], REG_SP, p*4);
                }       
 #else
                assert(FLT_SAV_CNT == 0);
@@ -256,9 +273,27 @@ bool codegen_emit(jitdata *jd)
                        default: assert(0);
                        }
                } /* end for argument out of stack*/
-       }
 
+#if defined(ENABLE_THREADS)
+       /* call lock_monitor_enter function */
+       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+               if (m->flags & ACC_STATIC)      {
+                       M_AMOV_IMM((&m->class->object.header), REG_ATMP1);
+               } else  {
+                       /* for non-static case the first arg is the object */
+                       M_ALD(REG_ATMP1, REG_SP, cd->stackframesize*4 + 4);
+                       M_ATST(REG_ATMP1);
+                       M_BNE(2);
+                       M_TRAP(M68K_EXCEPTION_HARDWARE_NULLPOINTER);
+               }
+
+               M_AST(REG_ATMP1, REG_SP, rd->memuse * 4);
+               M_AST(REG_ATMP1, REG_SP, 0 * 4);
+               M_JSR_IMM(LOCK_monitor_enter);
+       }
+#endif
 
+       }
 
        /* create replacement points */
        REPLACEMENT_POINTS_INIT(cd, jd);
@@ -273,8 +308,35 @@ bool codegen_emit(jitdata *jd)
        /* branch resolving */
        codegen_resolve_branchrefs(cd, bptr);
 
+       /* handle replacement points */
+       REPLACEMENT_POINT_BLOCK_START(cd, bptr);
+
+#if defined(ENABLE_PROFILING)
+       assert(0);
+#endif
        /* FIXME there are still some constrcuts to copy in here */
 
+#if defined(ENABLE_LSRA)
+       assert(0);
+#endif
+
+       /* copy interface registers to their destination */
+       len = bptr->indepth;
+       MCODECHECK(64+len);
+
+       while (len > 0) {
+               len--;
+               var = VAR(bptr->invars[len]);
+               if ((len == bptr->indepth-1) && (bptr->type == BBTYPE_EXH)) {
+                       d = codegen_reg_of_var(0, var, REG_ATMP1_XPTR);
+                       M_ADRMOVE(REG_ATMP1_XPTR, d);
+                       emit_store(jd, NULL, var, d);
+               }
+               else {
+                       assert((var->flags & INOUT));
+               }
+       }
+
        /* walk through all instructions */
        len = bptr->icount;
        currentline = 0;
@@ -341,7 +403,7 @@ bool codegen_emit(jitdata *jd)
                        emit_store_dst(jd, iptr, d);
 #else
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
-                       FCONST(iptr->sx.val.f, d);
+                       FCONST(iptr->sx.val.i, d);
                        emit_store_dst(jd, iptr, d);
 #endif
                        break;
@@ -354,12 +416,85 @@ bool codegen_emit(jitdata *jd)
                        emit_store_dst(jd, iptr, d);
 #else
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
-                       DCONST(iptr->sx.val.d, d);
+                       disp = dseg_add_double(cd, iptr->sx.val.d);
+                       M_AMOV_IMM(0, REG_ATMP1);
+                       dseg_adddata(cd);
+                       M_DLD(d, REG_ATMP1, disp);
                        emit_store_dst(jd, iptr, d);
 #endif
                        break;
 
 
+               /* some long operations *********************************************/
+               case ICMD_LADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP3);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       M_INTMOVE(s2, REG_ITMP1);
+                       M_IADD(s1, REG_ITMP1);                  /* low word */
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP3);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP2);
+                       M_INTMOVE(s2, REG_ITMP2);
+                       M_IADDX(s1, REG_ITMP2);                 /* high word */
+                       emit_store_dst(jd, iptr, d);
+                       break;
+                       
+               case ICMD_LADDCONST:  /* ..., value  ==> ..., value + constant        */
+                                     /* sx.val.l = constant                          */
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       
+                       M_IMOV_IMM(iptr->sx.val.l >> 32, REG_ITMP3);
+
+                       s3 = iptr->sx.val.l & 0xffffffff;
+                       M_INTMOVE(s1, REG_ITMP1);
+                       M_IADD_IMM(s3, REG_ITMP1);              /* lower word in REG_ITMP1 now */
+
+                       M_IADDX(REG_ITMP3, REG_ITMP2);  /* high word in REG_ITMP2 now */
+                       M_LNGMOVE(REG_ITMP12_PACKED, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_LSUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2_low(jd, iptr, REG_ITMP3);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       M_INTMOVE(s1, REG_ITMP1);
+                       M_ISUB(s2, REG_ITMP1);                  /* low word */
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
+                       M_INTMOVE(s1, REG_ITMP2);
+                       M_ISUBX(s2, REG_ITMP2);                 /* high word */
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_LSUBCONST:  /* ..., value  ==> ..., value - constant        */
+                                     /* sx.val.l = constant                          */
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s1_high(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       
+                       M_IMOV_IMM( (-iptr->sx.val.l) >> 32, REG_ITMP3);
+
+                       s3 = (-iptr->sx.val.l) & 0xffffffff;
+                       M_INTMOVE(s1, REG_ITMP1);
+                       M_IADD_IMM(s3, REG_ITMP1);              /* lower word in REG_ITMP1 now */
+
+                       M_IADDX(REG_ITMP3, REG_ITMP2);  /* high word in REG_ITMP2 now */
+                       M_LNGMOVE(REG_ITMP12_PACKED, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_LNEG:       /* ..., value  ==> ..., - value                 */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       M_LNGMOVE(s1, REG_ITMP12_PACKED);
+                       M_INEG(GET_LOW_REG(REG_ITMP12_PACKED));
+                       M_INEGX(GET_HIGH_REG(REG_ITMP12_PACKED));
+                       M_LNGMOVE(REG_ITMP12_PACKED, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
 
                /* integer operations ************************************************/
                case ICMD_INEG:       /* ..., value  ==> ..., - value                 */
@@ -372,21 +507,11 @@ bool codegen_emit(jitdata *jd)
                        emit_store_dst(jd, iptr, d);
                        break;
 
-#if 0
-               case ICMD_LNEG:       /* ..., value  ==> ..., - value                 */
-
-                       s1 = emit_load_s1(jd, iptr, REG_ITMP12_PACKED);
-                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
-                       M_SUBFIC(GET_LOW_REG(s1), 0, GET_LOW_REG(d));
-                       M_SUBFZE(GET_HIGH_REG(s1), GET_HIGH_REG(d));
-                       emit_store_dst(jd, iptr, d);
-                       break;
-#endif
                case ICMD_I2L:        /* ..., value  ==> ..., value                   */
 
-                       s1 = emit_load_s1(jd, iptr, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP3);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
-                       M_INTMOVE(s1, GET_LOW_REG(d));                          /* sets negativ bit */
+                       M_IMOV(s1, GET_LOW_REG(d));                             /* sets negativ bit */
                        M_BPL(4);
                        M_ISET(GET_HIGH_REG(d));
                        M_TPFW;
@@ -475,32 +600,70 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_IDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        emit_arithmetic_check(cd, iptr, s2);
-
                        M_INTMOVE(s1, REG_ITMP1);
                        M_IDIV(s2, REG_ITMP1);
                        M_INTMOVE(REG_ITMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
 
+               case ICMD_IDIVPOW2:             /* ..., value  ==> ..., value << constant       */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       M_INTMOVE(s1, REG_ITMP1);
+
+                       M_ITST(REG_ITMP1);
+                       M_BPL(6);
+                       M_IADD_IMM((1 << iptr->sx.val.i) - 1, REG_ITMP1);
+
+                       M_IMOV_IMM(iptr->sx.val.i, REG_ITMP2);
+                       M_ISSR(REG_ITMP2, REG_ITMP1);
+                       M_INTMOVE(REG_ITMP1, d);
                        emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_IREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
                        emit_arithmetic_check(cd, iptr, s2);
 
+                       M_ICMP_IMM(0x80000000, s1);
+                       M_BNE(4+8);
+                       M_ICMP_IMM(-1, s2);
+                       M_BNE(4);
+                       M_ICLR(REG_ITMP3);
+                       M_TPFL;                                 /* hides the next instruction */
                        M_IREM(s2, s1, REG_ITMP3);
+
                        M_INTMOVE(REG_ITMP3, d);
 
                        emit_store_dst(jd, iptr, d);
                        break;
 
+               case ICMD_IREMPOW2:             /* ..., value  ==> ..., value << constant       */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
+                       if (s1 == d) {
+                               M_IMOV(s1, REG_ITMP1);
+                               s1 = REG_ITMP1;
+                       } 
+                       M_INTMOVE(s1, d);
+                       M_IAND_IMM(iptr->sx.val.i, d);
+                       M_ITST(s1);
+                       M_BGE(2 + 2 + 6 + 2);
+                       M_IMOV(s1, d);  /* don't use M_INTMOVE, so we know the jump offset */
+                       M_INEG(d);
+                       M_IAND_IMM(iptr->sx.val.i, d);     /* use 32-bit for jump offset */
+                       M_INEG(d);
+
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+
                case ICMD_LDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
                case ICMD_LREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
@@ -563,9 +726,18 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
-                       M_INTMOVE(s1, REG_ITMP1)
-                       M_ISSL_IMM(iptr->sx.val.i & 0x1f, REG_ITMP1);
-                       M_INTMOVE(REG_ITMP1, d);
+                       if (iptr->sx.val.i & 0x1f)      {
+                               M_INTMOVE(s1, REG_ITMP1)
+                               if ((iptr->sx.val.i & 0x1f) <= 7)       {
+                                       M_ISSL_IMM(iptr->sx.val.i & 0x1f, REG_ITMP1);
+                               } else  {
+                                       M_IMOV_IMM(iptr->sx.val.i & 0x1f, REG_ITMP2);
+                                       M_ISSL(REG_ITMP2, REG_ITMP1);
+                               }
+                               M_INTMOVE(REG_ITMP1, d);
+                       } else  {
+                               M_INTMOVE(s1, d);
+                       }
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -587,9 +759,18 @@ bool codegen_emit(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
-                       M_INTMOVE(s1, REG_ITMP1)
-                       M_ISSR_IMM(iptr->sx.val.i & 0x1f, REG_ITMP1);
-                       M_INTMOVE(REG_ITMP1, d);
+                       if (iptr->sx.val.i & 0x1f)      {
+                               M_INTMOVE(s1, REG_ITMP1)
+                               if ((iptr->sx.val.i & 0x1f) <= 7)       {
+                                       M_ISSR_IMM(iptr->sx.val.i & 0x1f, REG_ITMP1);
+                               } else  {
+                                       M_IMOV_IMM(iptr->sx.val.i & 0x1f, REG_ITMP2);
+                                       M_ISSR(REG_ITMP2, REG_ITMP1);
+                               }
+                               M_INTMOVE(REG_ITMP1, d);
+                       } else  {
+                               M_INTMOVE(s1, d);
+                       }
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -610,9 +791,18 @@ bool codegen_emit(jitdata *jd)
                                      /* sx.val.i = constant                          */
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
-                       M_INTMOVE(s1, REG_ITMP1)
-                       M_IUSR_IMM(iptr->sx.val.i & 0x1f, REG_ITMP1);
-                       M_INTMOVE(REG_ITMP1, d);
+                       if (iptr->sx.val.i & 0x1f)      {
+                               M_INTMOVE(s1, REG_ITMP1)
+                               if ((iptr->sx.val.i & 0x1f) <= 7)       {
+                                       M_IUSR_IMM(iptr->sx.val.i & 0x1f, REG_ITMP1);
+                               } else  {
+                                       M_IMOV_IMM(iptr->sx.val.i & 0x1f, REG_ITMP2);
+                                       M_IUSR(REG_ITMP2, REG_ITMP1);
+                               }
+                               M_INTMOVE(REG_ITMP1, d);
+                       } else  {
+                               M_INTMOVE(s1, d);
+                       }
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -638,8 +828,187 @@ bool codegen_emit(jitdata *jd)
                        emit_store_dst(jd, iptr, d);
                        break;
 
+               case ICMD_IOR:        /* ..., val1, val2  ==> ..., val1 | val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
+                       M_INTMOVE(s2, REG_ITMP2);
+                       M_IOR(s1, REG_ITMP2);
+                       M_INTMOVE(REG_ITMP2, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
 
+               case ICMD_IORCONST:   /* ..., value  ==> ..., value | constant        */
+                                     /* sx.val.i = constant                          */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       M_INTMOVE(s1, REG_ITMP1);
+                       M_IOR_IMM(iptr->sx.val.i, REG_ITMP1);
+                       M_INTMOVE(REG_ITMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
 
+               case ICMD_IXOR:        /* ..., val1, val2  ==> ..., val1 | val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
+                       M_INTMOVE(s2, REG_ITMP2);
+                       M_IXOR(s1, REG_ITMP2);
+                       M_INTMOVE(REG_ITMP2, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_IXORCONST:   /* ..., value  ==> ..., value | constant        */
+                                     /* sx.val.i = constant                          */
+                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       M_INTMOVE(s1, REG_ITMP1);
+                       M_IXOR_IMM(iptr->sx.val.i, REG_ITMP1);
+                       M_INTMOVE(REG_ITMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               /* floating point operations ******************************************/
+               #if !defined(ENABLE_SOFTFLOAT)
+               case ICMD_FCMPL:                /* ..., val1, val2  ==> ..., val1 fcmpl val2  */
+               case ICMD_DCMPL:
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       M_IMOV_IMM(-1, d);
+                       M_FCMP(s1, s2);
+                       M_BFUN(14);     /* result is -1, branch to end */
+                       M_BFLT(10);     /* result is -1, branch to end */
+                       M_IMOV_IMM(0, d);
+                       M_BFEQ(4)       /* result is 0, branch to end */
+                       M_IMOV_IMM(1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_FCMPG:                /* ..., val1, val2  ==> ..., val1 fcmpg val2  */
+               case ICMD_DCMPG:
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
+                       M_IMOV_IMM(1, d);
+                       M_FCMP(s1, s2);
+                       M_BFUN(16);     /* result is +1, branch to end */
+                       M_BFGT(14);     /* result is +1, branch to end */
+                       M_IMOV_IMM(0, d);
+                       M_BFEQ(8)       /* result is 0, branch to end */
+                       M_IMOV_IMM(-1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_FMUL:       /* ..., val1, val2  ==> ..., val1 * val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_FLTMOVE(s2, REG_FTMP2);
+                       M_FMUL(s1, REG_FTMP2);
+                       M_FLTMOVE(REG_FTMP2, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_DMUL:       /* ..., val1, val2  ==> ..., val1 * val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_DBLMOVE(s2, REG_FTMP2);
+                       M_DMUL(s1, REG_FTMP2);
+                       M_DBLMOVE(REG_FTMP2, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_FDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       M_FLTMOVE(s1, REG_FTMP1);
+                       M_FDIV(s2, REG_FTMP1);
+                       M_FLTMOVE(REG_FTMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_DDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       M_DBLMOVE(s1, REG_FTMP1);
+                       M_DDIV(s2, REG_FTMP1);
+                       M_DBLMOVE(REG_FTMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_FADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_FLTMOVE(s2, REG_FTMP2);
+                       M_FADD(s1, REG_FTMP2);
+                       M_FLTMOVE(REG_FTMP2, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_DADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_DBLMOVE(s2, REG_FTMP2);
+                       M_DADD(s1, REG_FTMP2);
+                       M_DBLMOVE(REG_FTMP2, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_FSUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_FLTMOVE(s1, REG_FTMP1);
+                       M_FSUB(s2, REG_FTMP1);
+                       M_FLTMOVE(REG_FTMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_DSUB:       /* ..., val1, val2  ==> ..., val1 - val2        */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_FTMP2);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_DBLMOVE(s1, REG_FTMP1);
+                       M_DSUB(s2, REG_FTMP1);
+                       M_DBLMOVE(REG_FTMP1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_F2D:       /* ..., value  ==> ..., (double) value           */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_F2D(s1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_D2F:       /* ..., value  ==> ..., (float) value           */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_D2F(s1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_FNEG:       /* ..., value  ==> ..., - value                 */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_FNEG(s1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               case ICMD_DNEG:       /* ..., value  ==> ..., - value                 */
+                       s1 = emit_load_s1(jd, iptr, REG_FTMP1);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
+                       M_DNEG(s1, d);
+                       emit_store_dst(jd, iptr, d);
+                       break;
+
+               #endif
 
                /* load/store/copy/move operations ************************************/
 
@@ -761,13 +1130,15 @@ bool codegen_emit(jitdata *jd)
                /* MEMORY *************************************************************/
                case ICMD_GETSTATIC:
                        if (INSTRUCTION_IS_UNRESOLVED(iptr))    {
-                               assert(0);
+                               uf        = iptr->sx.s23.s3.uf;
+                               fieldtype = uf->fieldref->parseddesc.fd->type;
+                               codegen_addpatchref(cd, PATCHER_get_putstatic, uf, 0);
                        } else  {
                                fieldinfo *fi = iptr->sx.s23.s3.fmiref->p.field;
 
                                fieldtype = fi->type;
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class, disp);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class, 0);
                                }
 
                                disp = (ptrint) &(fi->value);
@@ -858,7 +1229,7 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_GETFIELD:   /* ...  ==> ..., value                          */
 
-                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1(jd, iptr, REG_ATMP1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                uf        = iptr->sx.s23.s3.uf;
@@ -887,13 +1258,7 @@ bool codegen_emit(jitdata *jd)
 #endif
                        case TYPE_LNG:
                                d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
-                               if (GET_HIGH_REG(d) == s1) {
-                                       M_ILD(GET_LOW_REG(d), s1, disp + 4);
-                                       M_ILD(GET_HIGH_REG(d), s1, disp);
-                               } else {
-                                       M_ILD(GET_HIGH_REG(d), s1, disp);
-                                       M_ILD(GET_LOW_REG(d), s1, disp + 4);
-                               }
+                               M_LLD(d, s1, disp);
                                break;
                        case TYPE_ADR:
                                d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
@@ -954,8 +1319,7 @@ bool codegen_emit(jitdata *jd)
                        case TYPE_DBL:
 #endif
                        case TYPE_LNG:
-                               M_IST(GET_LOW_REG(s2), s1, disp + 4);      /* keep this order */
-                               M_IST(GET_HIGH_REG(s2), s1, disp);         /* keep this order */
+                               M_LST(s2, s1, disp);  
                                break;
                        case TYPE_ADR:
                                M_AST(s2, s1, disp);
@@ -1009,7 +1373,7 @@ bool codegen_emit(jitdata *jd)
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
                        /* implicit null-pointer check */
                        M_LHZX(REG_ATMP1, d);
-                       /*M_CZEXT(d, d);*/
+                       M_CZEXT(d, d);
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1027,7 +1391,7 @@ bool codegen_emit(jitdata *jd)
                
                        /* implicit null-pointer check */
                        M_LHZX(REG_ATMP1, d);
-                       M_HSEXT(d, d);
+                       M_SSEXT(d, d);
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1042,7 +1406,6 @@ bool codegen_emit(jitdata *jd)
                        M_IADD_IMM(OFFSET(java_intarray, data[0]), REG_ITMP2);
                        M_ADRMOVE(s1, REG_ATMP1);
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
-       
                        /* implicit null-pointer check */
                        M_LWZX(REG_ATMP1, d);
                        emit_store_dst(jd, iptr, d);
@@ -1050,21 +1413,23 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_LALOAD:     /* ..., arrayref, index  ==> ..., value         */
                        s1 = emit_load_s1(jd, iptr, REG_ATMP1);
-                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
                        /* implicit null-pointer check */
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
-                       M_INTMOVE(s2, REG_ITMP2);
-                       M_ISSL_IMM(3, REG_ITMP2);
-                       M_IADD(s1, REG_ITMP2);
-                       M_LLD(d, REG_ITMP2, OFFSET(java_longarray, data[0]));
+                       M_INTMOVE(s2, REG_ITMP1);
+                       M_ISSL_IMM(3, REG_ITMP1);
+                       M_IADD_IMM(OFFSET(java_longarray, data[0]), REG_ITMP1);
+                       M_ADRMOVE(s1, REG_ATMP1);
+                       M_AADDINT(REG_ITMP1, REG_ATMP1);
+                       /* implicit null-pointer check */
+                       M_LLD(d, REG_ATMP1, 0);
                        emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_FALOAD:     /* ..., arrayref, index  ==> ..., value         */
                        s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        M_INTMOVE(s2, REG_ITMP2);
                        M_ISSL_IMM(2, REG_ITMP2);
@@ -1073,8 +1438,10 @@ bool codegen_emit(jitdata *jd)
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
                        /* implicit null-pointer check */
 #if !defined(ENABLE_SOFTFLOAT)
-                       M_LFSX(REG_ATMP1, d);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       M_FLD(d, REG_ATMP1, 0);
 #else
+                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_LWZX(REG_ATMP1, d);
 #endif
                        emit_store_dst(jd, iptr, d);
@@ -1091,21 +1458,16 @@ bool codegen_emit(jitdata *jd)
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
                        /* implicit null-pointer check */
 #if !defined(ENABLE_SOFTFLOAT)
-                       d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);    /* FIXME */
-                       M_LFDX(REG_ATMP1, s3);
+                       d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                       M_DLD(d, REG_ATMP1, 0);
 #else
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
-                       /* implicit null-pointer check */
-                       M_LWZX(REG_ATMP1, GET_LOW_REG(d));
-                       M_AADD_IMM(REG_ATMP1, 4);
-                       /* implicit null-pointer check */
-                       M_LWZX(REG_ATMP1, GET_HIGH_REG(d));
+                       M_LLD(d, REG_ATMP1, 0);
 #endif
                        emit_store_dst(jd, iptr, d);
                        break;
 
                case ICMD_AALOAD:     /* ..., arrayref, index  ==> ..., value         */
-
                        s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
@@ -1123,7 +1485,6 @@ bool codegen_emit(jitdata *jd)
 
 
                case ICMD_BASTORE:    /* ..., arrayref, index, value  ==> ...         */
-
                        s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1132,13 +1493,11 @@ bool codegen_emit(jitdata *jd)
                        M_IADD_IMM(OFFSET(java_bytearray, data[0]), REG_ITMP2);
                        M_ADRMOVE(s1, REG_ATMP1);
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
-       
                        /* implicit null-pointer check */
                        M_STBX(REG_ATMP1, s3);
                        break;
 
                case ICMD_CASTORE:    /* ..., arrayref, index, value  ==> ...         */
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1153,7 +1512,6 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_SASTORE:    /* ..., arrayref, index, value  ==> ...         */
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
@@ -1168,13 +1526,12 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_IASTORE:    /* ..., arrayref, index, value  ==> ...         */
-
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
                        M_INTMOVE(s2, REG_ITMP2);
-                       M_ISSL_IMM(1, REG_ITMP2);
+                       M_ISSL_IMM(2, REG_ITMP2);
                        M_IADD_IMM(OFFSET(java_intarray, data[0]), REG_ITMP2);
                        M_ADRMOVE(s1, REG_ATMP1);
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
@@ -1183,29 +1540,24 @@ bool codegen_emit(jitdata *jd)
                        break;
 
                case ICMD_LASTORE:    /* ..., arrayref, index, value  ==> ...         */
-                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
+                       s1 = emit_load_s1(jd, iptr, REG_ATMP1);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP1);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
-                       s3 = emit_load_s3_high(jd, iptr, REG_ITMP3);
 
-                       M_INTMOVE(s2, REG_ITMP2);
-                       M_ISSL_IMM(3, REG_ITMP2);
-                       M_IADD_IMM(OFFSET(java_longarray, data[0]), REG_ITMP2);
+                       M_INTMOVE(s2, REG_ITMP1);
+                       M_ISSL_IMM(3, REG_ITMP1);
+                       M_IADD_IMM(OFFSET(java_longarray, data[0]), REG_ITMP1);
                        M_ADRMOVE(s1, REG_ATMP1);
-                       M_AADDINT(REG_ITMP2, REG_ATMP1);
-                       /* implicit null-pointer check */
-                       M_STWX(REG_ATMP1, s3);
-                       M_AADD_IMM(REG_ATMP1, 4);
-                       s3 = emit_load_s3_low(jd, iptr, REG_ITMP3);
+                       M_AADDINT(REG_ITMP1, REG_ATMP1);
                        /* implicit null-pointer check */
-                       M_STWX(REG_ATMP1, s3);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP12_PACKED);
+                       M_LST(s3, REG_ATMP1, 0);
                        break;
 
                case ICMD_FASTORE:    /* ..., arrayref, index, value  ==> ...         */
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
-                       s3 = emit_load_s3(jd, iptr, REG_FTMP3);
                        M_INTMOVE(s2, REG_ITMP2);
                        M_ISSL_IMM(2, REG_ITMP2);
                        M_IADD_IMM(OFFSET(java_floatarray, data[0]), REG_ITMP2);
@@ -1213,8 +1565,10 @@ bool codegen_emit(jitdata *jd)
                        M_AADDINT(REG_ITMP2, REG_ATMP1);
                        /* implicit null-pointer check */
 #if !defined(ENABLE_SOFTFLOAT)
-                       M_STFSX(REG_ATMP1, s3);
+                       s3 = emit_load_s3(jd, iptr, REG_FTMP3);
+                       M_FST(s3, REG_ATMP1, 0);
 #else
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP3);
                        M_STWX(REG_ATMP1, s3);
 #endif
                        break;
@@ -1231,15 +1585,11 @@ bool codegen_emit(jitdata *jd)
                        /* implicit null-pointer check */
 #if !defined(ENABLE_SOFTFLOAT)
                        s3 = emit_load_s3(jd, iptr, REG_FTMP3);
-                       M_STFDX(REG_ATMP1, s3);
+                       M_DST(s3, REG_ATMP1, 0);
 #else
-                       s3 = emit_load_s3_high(jd, iptr, REG_ITMP3);
-                       /* implicit null-pointer check */
-                       M_STWX(REG_ATMP1, s3);
-                       M_AADD_IMM(REG_ATMP1, 4);
-                       s3 = emit_load_s3_low(jd, iptr, REG_ITMP3);
+                       s3 = emit_load_s3(jd, iptr, REG_ITMP12_PACKED);
                        /* implicit null-pointer check */
-                       M_STWX(REG_ATMP1, s3);
+                       M_LST(s3, REG_ATMP1, 0);
 #endif
                        break;
 
@@ -1264,7 +1614,7 @@ bool codegen_emit(jitdata *jd)
                        M_INTMOVE(s2, REG_ITMP1);
                        M_ISSL_IMM(2, REG_ITMP1);
                        M_IADD_IMM(OFFSET(java_objectarray, data[0]), REG_ITMP1);
-                       M_INTMOVE(s1, REG_ATMP1);
+                       M_ADRMOVE(s1, REG_ATMP1);
                        M_AADDINT(REG_ITMP1, REG_ATMP1);
                        /* implicit null-pointer check */
                        M_STAX(REG_ATMP1, s3);
@@ -1328,7 +1678,13 @@ bool codegen_emit(jitdata *jd)
                                                break;
 #if !defined(ENABLE_SOFTFLOAT)
                                        case TYPE_FLT:
+                                               d = emit_load(jd, iptr, var, REG_FTMP1);
+                                               M_FST(d, REG_SP, md->params[s3].regoff*4);
+                                               break;
                                        case TYPE_DBL:
+                                               d = emit_load(jd, iptr, var, REG_FTMP1);
+                                               M_DST(d, REG_SP, md->params[s3].regoff*4);
+                                               break;
 #endif
                                        default:
                                                assert(0);
@@ -1378,9 +1734,9 @@ bool codegen_emit(jitdata *jd)
                                        M_ALD(REG_ATMP1, REG_SP, 0);
                                        /* implicit null-pointer check */
                                        M_ALD(REG_METHODPTR, REG_ATMP1, OFFSET(java_objectheader, vftbl));
-                                       M_ALD(REG_ATMP1, REG_METHODPTR, s1);
+                                       M_ALD(REG_ATMP3, REG_METHODPTR, s1);
                                        /* generate the actual call */
-                                       M_JSR(REG_ATMP1);
+                                       M_JSR(REG_ATMP3);
                                        break;
                                case ICMD_INVOKEINTERFACE: 
                                        if (lm == NULL) {
@@ -1398,10 +1754,10 @@ bool codegen_emit(jitdata *jd)
                                        /* implicit null-pointer check */
                                        M_ALD(REG_METHODPTR, REG_ATMP1, OFFSET(java_objectheader, vftbl));
                                        M_ALD(REG_METHODPTR, REG_METHODPTR, s1);
-                                       M_ALD(REG_ATMP1, REG_METHODPTR, s2);
+                                       M_ALD(REG_ATMP3, REG_METHODPTR, s2);
 
                                        /* generate the actual call */
-                                       M_JSR(REG_ATMP1);
+                                       M_JSR(REG_ATMP3);
                                        REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
                                        break;
 
@@ -1435,8 +1791,27 @@ bool codegen_emit(jitdata *jd)
                                                M_INT2ADRMOVE(REG_RESULT, s1);
                                                break;
 #if !defined(ENABLE_SOFTFLOAT)
+                                       /*
+                                        *      for BUILTINS float values are returned in %d0,%d1
+                                        *      within cacao we use %fp0 for that.
+                                        */
                                        case TYPE_FLT:
+                                               s1 = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                                               if (iptr->opc == ICMD_BUILTIN)  {
+                                                       M_INT2FLTMOVE(REG_FRESULT, s1);
+                                               } else  {
+                                                       M_FLTMOVE(REG_FRESULT, s1);
+                                               }
+                                               break;
                                        case TYPE_DBL:
+                                               s1 = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
+                                               if (iptr->opc == ICMD_BUILTIN)  {
+                                                       M_LST(REG_RESULT_PACKED, REG_SP, rd->memuse * 4 + 4);
+                                                       M_DLD(s1, REG_SP, rd->memuse * 4 + 4);
+                                               } else  {
+                                                       M_DBLMOVE(REG_FRESULT, s1);
+                                               }
+                                               break;
 #endif
                                        default:
                                                assert(0);
@@ -1474,7 +1849,6 @@ bool codegen_emit(jitdata *jd)
                case ICMD_DRETURN:
 #endif
                case ICMD_LRETURN:      /* ..., retvalue ==> ...                      */
-
                        REPLACEMENT_POINT_RETURN(cd, iptr);
                        s1 = emit_load_s1(jd, iptr, REG_RESULT_PACKED);
                        M_LNGMOVE(s1, REG_RESULT_PACKED);
@@ -1482,12 +1856,17 @@ bool codegen_emit(jitdata *jd)
 
 #if !defined(ENABLE_SOFTFLOAT)
                case ICMD_FRETURN:      /* ..., retvalue ==> ...                      */
-               case ICMD_DRETURN:
-
                        REPLACEMENT_POINT_RETURN(cd, iptr);
                        s1 = emit_load_s1(jd, iptr, REG_FRESULT);
                        M_FLTMOVE(s1, REG_FRESULT);
                        goto nowperformreturn;
+
+               case ICMD_DRETURN:
+                       REPLACEMENT_POINT_RETURN(cd, iptr);
+                       s1 = emit_load_s1(jd, iptr, REG_FRESULT);
+                       M_DBLMOVE(s1, REG_FRESULT);
+                       goto nowperformreturn;
+
 #endif
 
                case ICMD_RETURN:      /* ...  ==> ...                                */
@@ -1506,48 +1885,63 @@ nowperformreturn:
 #endif
 
 #if defined(ENABLE_THREADS)
+                       /* call lock_monitor_exit */
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
-                               disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
-                               M_ALD(REG_ITMP3, REG_PV, disp);
-                               M_MTCTR(REG_ITMP3);
+                               M_ILD(REG_ITMP3, REG_SP, rd->memuse * 4);
 
                                /* we need to save the proper return value */
-
+                               /* we do not care for the long -> doubel convert space here */
                                switch (iptr->opc) {
+#if defined(ENABLE_SOFTFLOAT)
+                               case ICMD_DRETURN:
+#endif
                                case ICMD_LRETURN:
-                                       M_IST(REG_RESULT2, REG_SP, rd->memuse * 4 + 8);
-                                       /* fall through */
+                                       M_LST(REG_RESULT_PACKED, REG_SP, rd->memuse * 4 + 4);
+                                       break;
+#if defined(ENABLE_SOFTFLOAT)
+                               case ICMD_FRETURN:
+#endif
                                case ICMD_IRETURN:
                                case ICMD_ARETURN:
                                        M_IST(REG_RESULT , REG_SP, rd->memuse * 4 + 4);
                                        break;
+#if !defined(ENABLE_SOFTFLOAT)
                                case ICMD_FRETURN:
                                        M_FST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
                                        break;
                                case ICMD_DRETURN:
                                        M_DST(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
                                        break;
+#endif
                                }
 
-                               M_ALD(REG_A0, REG_SP, rd->memuse * 4);
-                               M_JSR;
+                               M_IST(REG_ITMP3, REG_SP, 0 * 4);
+                               M_JSR_IMM(LOCK_monitor_exit);
 
                                /* and now restore the proper return value */
-
                                switch (iptr->opc) {
+
+#if defined(ENABLE_SOFTFLOAT)
+                               case ICMD_DRETURN:
+#endif
                                case ICMD_LRETURN:
-                                       M_ILD(REG_RESULT2, REG_SP, rd->memuse * 4 + 8);
-                                       /* fall through */
+                                       M_LLD(REG_RESULT_PACKED, REG_SP, rd->memuse * 4 + 4);
+                                       break;
+#if defined(ENABLE_SOFTFLOAT)
+                               case ICMD_FRETURN:
+#endif
                                case ICMD_IRETURN:
                                case ICMD_ARETURN:
                                        M_ILD(REG_RESULT , REG_SP, rd->memuse * 4 + 4);
                                        break;
+#if !defined(ENABLE_SOFTFLOAT)
                                case ICMD_FRETURN:
                                        M_FLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
                                        break;
                                case ICMD_DRETURN:
                                        M_DLD(REG_FRESULT, REG_SP, rd->memuse * 4 + 4);
                                        break;
+#endif
                                }
                        }
 #endif
@@ -1573,7 +1967,7 @@ nowperformreturn:
                        }
 #if !defined(ENABLE_SOFTFLOAT)
                        for (i = FLT_SAV_CNT - 1; i >= rd->savfltreguse; i--) {
-                               p -= 2; M_DLD(rd->savfltregs[i], REG_SP, p * 4);
+                               p -= 2; M_FLOAD(rd->savfltregs[i], REG_SP, p * 4);
                        }
 #endif
                        /* deallocate stack                                               */
@@ -1612,9 +2006,9 @@ nowperformreturn:
                                superindex = super->index;
                        }
                        
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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);
 
@@ -1677,15 +2071,15 @@ nowperformreturn:
                                }
 
                                M_ALD(REG_ATMP1, s1, OFFSET(java_objectheader, vftbl));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_ISUB(REG_ITMP3, REG_ITMP1);
                                M_ICMP(REG_ITMP2, REG_ITMP1);
                                M_BHI(4);
@@ -1737,9 +2131,8 @@ nowperformreturn:
                                        superindex = super->index;
                                }
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               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);
@@ -1799,15 +2192,15 @@ nowperformreturn:
                                        }
 
                                        M_ALD(REG_ATMP2, s1, OFFSET(java_objectheader, vftbl));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       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));
-#if defined(ENABLE_THREADS)
-                                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        M_ISUB(REG_ITMP1, REG_ITMP3);
                                        M_ICMP(REG_ITMP2, REG_ITMP3);   /* XXX was CMPU */
 
@@ -1945,7 +2338,7 @@ nowperformreturn:
 
                        /* a2 = pointer to dimensions = stack pointer */
                        M_AMOV(REG_SP, REG_ATMP1);
-                       M_AADD_IMM(REG_ATMP1, 3*4);
+                       M_AADD_IMM(3*4, REG_ATMP1);
                        M_AST(REG_ATMP1, REG_SP, 2*4);
 
                        M_JSR_IMM(BUILTIN_multianewarray);
@@ -2002,7 +2395,6 @@ void codegen_emit_stub_compiler(jitdata *jd)
        M_AMOV_IMM(m, REG_ATMP1);
        M_AMOV_IMM(asm_call_jit_compiler, REG_ATMP3);
        M_JMP(REG_ATMP3);
-       M_JMP_IMM(0);   /* FIXME: remove me */
 }
 
 
@@ -2035,8 +2427,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        cd->stackframesize =    sizeof(stackframeinfo) / SIZEOF_VOID_P +
                                sizeof(localref_table) / SIZEOF_VOID_P +
                                nmd->memuse +
-                               4 +                                             /* %d0,%d1,%a0,%a1*/
-                               2 * 2 +                                         /* %f0,%f1 */
                                1 +                                             /* functionptr */
                                4;                                              /* args for codegen_start_native_call */
 
@@ -2064,24 +2454,12 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 #if !defined(WITH_STATIC_CLASSPATH)
        if (f == NULL)  {
                codegen_addpatchref(cd, PATCHER_resolve_native_function, m, 0);
-               /*M_AMOV_IMM(0, REG_ATMP2);*/
        }
 #endif
        M_AMOV_IMM(f, REG_ATMP2); /* do not move this line, the patcher is needed */
 
        M_AST(REG_ATMP2, REG_SP, 4 * 4);
 
-       /* save integer and float temp registers */
-       /*
-       M_IST(REG_D0, REG_SP, 4*4 + 2*8 + 3*4);
-       M_IST(REG_D1, REG_SP, 4*4 + 2*8 + 2*4);
-       M_AST(REG_A0, REG_SP, 4*4 + 2*8 + 1*4);
-       M_AST(REG_A1, REG_SP, 4*4 + 2*8 + 0*4);
-       */
-
-       /* TODO */
-       /* store %f0, %f1 */
-
        /* put arguments for codegen_start_native_call onto stack */
        /* void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra) */
        
@@ -2097,7 +2475,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        M_AST(REG_ATMP1, REG_SP, 2 * 4);                /* sp */
 
        M_AMOV_IMM(0, REG_ATMP2);                       /* 0 needs to patched */
-       dseg_adddata(cd);                               /* this patches it */
+       dseg_adddata(cd);                                   /* this patches it */
 
        M_AST(REG_ATMP2, REG_SP, 1 * 4);                /* pv */
 
@@ -2140,25 +2518,18 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        switch (md->returntype.type)    {
                case TYPE_VOID: break;
 
-#if defined(ENABLE_SOFTFLOAT)
+               /* natives return float arguments in %d0, %d1, cacao expects them in %fp0 */
                case TYPE_DBL:
-#endif
                case TYPE_LNG:
                        M_IST(REG_D1, REG_SP, 2 * 4);
                        /* fall through */
 
-#if defined(ENABLE_SOFTFLOAT)
                case TYPE_FLT:
-#endif
                case TYPE_INT:
                case TYPE_ADR:
                        M_IST(REG_D0, REG_SP, 1 * 4);
                        break;
 
-#if !defined(ENABLE_SOFTFLOAT)
-               case TYPE_FLT:
-               case TYPE_DBL:  /* FIXME */
-#endif
                default: assert(0);
        }
        
@@ -2181,26 +2552,30 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        switch (md->returntype.type)    {
                case TYPE_VOID: break;
 
-#if defined(ENABLE_SOFTFLOAT)
                case TYPE_DBL:
-#endif
                case TYPE_LNG:
                        M_ILD(REG_D1, REG_SP, 2 * 4);
                        /* fall through */
-#if defined(ENABLE_SOFTFLOAT)
                case TYPE_FLT:
-#endif
                case TYPE_INT:
                case TYPE_ADR:
                        M_ILD(REG_D0, REG_SP, 1 * 4);
                        break;
 
+               default: assert(0);
+       }
 #if !defined(ENABLE_SOFTFLOAT)
+               /* additionally load values into floating points registers
+                * as cacao jit code expects them there */
+       switch (md->returntype.type)    {
                case TYPE_FLT:
-               case TYPE_DBL:  /* FIXME */
-#endif
-               default: assert(0);
+                       M_FLD(REG_D0, REG_SP, 1 * 4);
+                       break;
+               case TYPE_DBL:  
+                       M_DLD(REG_D0, REG_SP, 1 * 4);
+                       break;
        }
+#endif
        /* restore saved registers */
 
        M_AADD_IMM(cd->stackframesize*4, REG_SP);
index 7103b75fb0d296945fbaefcf842f04bc31189b80..f06e8059f6f38561aa4d373ef02415ca1faba7f6 100644 (file)
 
 #define M_IPUSH_IMM(a)         OPWORD_IMM32(0x121,7,1, (a))                            /* pea.l */
 
+#if 0
 #define        M_PUSHALL               OPWORD_IMM16(0x123,2,REG_SP,0xFFFF)                     /* A0-A7, D0-D7 pushed onto stack */
 #define M_POPALL               OPWORD_IMM16(0x133,2,REG_SP,0xFFFF)                     /* A0-A7, D0-D7 poped off stack */
+#endif
 
 /* M_XLD(a,b,c)....M_XLD(destinationreg, addressbase, offset)  */
 #define M_ILD(a,b,c)           OPWORD_IMM16( ( (2<<6) | ((a) << 3) | 0), 5, (b), (c))
                                } while(0);
 
 #if !defined(ENABLE_SOFTFLOAT)
-       #define M_FLD(a,b,c)            M_ILLEGAL
-       #define M_DLD(a,b,c)            M_ILLEGAL
+       #define M_FLD(a,b,c)            OPWORD_IMM32( 0x3c8, 5, (b), ( (( (0x11 << 10) | ((a)<<7) | 0x40 )<<16) | (((int16_t)(c)) & 0x0000ffff)) )
+       #define M_DLD(a,b,c)            OPWORD_IMM32( 0x3c8, 5, (b), ( (( (0x15 << 10) | ((a)<<7) | 0x44 )<<16) | (((int16_t)(c)) & 0x0000ffff)) )
 #endif
 
 /* M_XST(a,b,c)....M_XST(sourceregister, addressbase, offset)   */
                                } while(0);
 
 #if !defined(ENABLE_SOFTFLOAT)
-       #define M_FST(a,b,c)            M_ILLEGAL
-       #define M_DST(a,b,c)            M_ILLEGAL
+       #define M_FST(a,b,c)            OPWORD_IMM32( 0x3c8, 5, (b), ( ((  (0x19 <<10) | ((a)<<7) | 0  )<<16) | (((int16_t)(c)) & 0x0000ffff)) )
+       #define M_DST(a,b,c)            OPWORD_IMM32( 0x3c8, 5, (b), ( ((  (0x1d <<10) | ((a)<<7) | 0  )<<16) | (((int16_t)(c)) & 0x0000ffff)) )
+       #define M_FSTORE(a,b,c)         OPWORD_IMM32( 0x3c8, 5, (b), ( ( (0xf << 12) | (1 << (7-(a))) ) <<16) | (((int16_t)(c)) & 0x0000ffff))
+       #define M_FLOAD(a,b,c)          OPWORD_IMM32( 0x3c8, 5, (b), ( ( (0xd << 12) | (1 << (7-(a))) ) <<16) | (((int16_t)(c)) & 0x0000ffff))
 #endif
 
 /*M_XADD_IMM(a,b)...M_XADD_IMM(offset, reg) */
 
 /* M_OP(source, dest) ...  dest (OP) source -> dest*/
 #define M_ISUB(a,b)            OPWORD ( ( (9<<6)   | ((b)<<3) | 2), 0, (a))                    /* sub.l */
+#define M_ISUBX(a,b)   OPWORD ( ( (9<<6)   | ((b)<<3) | 6), 0, (a))                    /* subx.l */
 #define M_IADD(a,b)            OPWORD ( ( (0xd<<6) | ((b)<<3) | 2), 0, (a))                    /* add.l */
+#define M_IADDX(a,b)   OPWORD ( ( (0xd<<6) | ((b)<<3) | 6), 0, (a))                    /* addx.l */
 
 #define M_IMUL(a,b)            OPWORD_IMM16 ( 0x130, 0, (a), ( ((b) << 12) | (1 << 11)))       /* muls.l */
 #define M_IDIV(a,b)            OPWORD_IMM16 ( 0x131, 0, (a), ( ((b) << 12) | (1 << 11) | (b))) /* divs.l */
 #define M_IUSR(a,b)            OPWORD ( ( (0xe<<6) | ((a) << 3) | 2), 5, (b))                  /* lsr.l */
 
 #define M_IAND(a,b)            OPWORD ( ( (0xc<<6) | ((b) << 3) | 2), 0, (a))                  /* and.l */
-
 #define M_IOR(a,b)             OPWORD ( ( (0x8<<6) | ((b) << 3) | 2), 0, (a))                  /* or.l */
+#define M_IXOR(a,b)            OPWORD ( ( (0xb<<6) | ((a) << 3) | 6), 0, (b))                  /* eor.l */
+
+
+/* M_IX_IMM(imm, register)     */
+#define M_IAND_IMM(a,b)                OPWORD_IMM32( 0xa, 0, (b), (a))                                 /* andi.l # */
+#define M_IOR_IMM(a,b)         OPWORD_IMM32( 0x2, 0, (b), (a))                                 /* ori.l # */
+#define M_IXOR_IMM(a,b)                OPWORD_IMM32( 0x2a,0, (b), (a))                                 /* eori.l # */
 
 
 /* ultra sepcial 3 register form, b%a = c, (a!=c) */
 
 /* M_OP(dest) */
 #define M_INEG(a)              OPWORD(0x112, 0, (a))                                           /* neg.l */
+#define M_INEGX(a)             OPWORD(0x102, 0, (a))                                           /* neg.l */
 
 /* only generate opcode when condition true */
 #define OPWORD_COND(c, u,v,w)  \
        do { \
                if ( (c) ) { OPWORD( (u),(v),(w) ) }  \
        } while(0);
+#define OPWORD_IMM16_COND(c, u,v,w,x)  \
+       do { \
+               if ( (c) ) { OPWORD_IMM16( (u),(v),(w),(x) ) }  \
+       } while(0);
 /* assert on the opcode */
 #define OPWORD_ASSERT(a, u,v,w)        \
        do { \
                                } while(0);
 
 #if !defined(ENABLE_SOFTLFOAT)
-       #define M_FLTMOVE(a,b)          M_ILLEGAL
-       #define M_DBLMOVE(a,b)          M_ILLEGAL
+       #define M_FLTMOVE(a,b)          OPWORD_IMM16_COND( ((a)!=(b)), 0x3c8, 0, 0, ((a)<<10) | ((b)<<7) | 0x40)
+       #define M_INT2FLTMOVE(a,b)      OPWORD_IMM16( 0x3c8, 0, (a), ((0x11 << 10) | ((b) << 7) | 0x40 )) 
+       #define M_DBLMOVE(a,b)          OPWORD_IMM16_COND( ((a)!=(b)), 0x3c8, 0, 0, ((a)<<10) | ((b)<<7) | 0x44)
 #endif
 /* M_XTST....M_XTST(register) */
 #define M_ITST(a)              OPWORD(0x12a, 0, (a))                   /* tst.l */
 #define M_ICMP(b,a)            OPWORD( ( (0xb << 6) | ((a) << 3) | 2), 0, (b))                 /* cmp.l */
 #define M_ACMP(b,a)            OPWORD( ( (0xb << 6) | ((a) << 3) | 7), 1, (b))                 /* cmpa.l */
 
-/* M_AND_IMM(imm, register)    */
-#define M_IAND_IMM(a,b)                OPWORD_IMM32( 0xa, 0, (b), (a))                                 /* andi.l # */
 
 /* All kind of branches one could ever possibly need, each with 16 and 32 bit displacement */
 /* BRANCH16 and BRANCH32 are helpers */
 #define M_BR_16(a)                     BRANCH16(0x0, (a))      /* branch always */
 #define M_BR_32(a)                     BRANCH32(0x0, (a))
 
+#define M_BCS(a)                       BRANCH8 (0x5, (a))      /* carry set */
+
 #define M_BEQ(a)                       BRANCH8 (0x7, (a))
 #define M_BEQ_16(a)                    BRANCH16(0x7, (a))
 #define M_BEQ_32(a)                    BRANCH32(0x7, (a))
 #define M_BNAN_16(a)                   M_ILLEGAL               /* TODO */
 #define M_BNAN_32(a)                   M_ILLEGAL
 
+
+
 /* array store/load stuff */
 /* M_LXXX(baseaddressregister, targetregister) */
 /* M_SXXX(baseaddressregsiter, sourceregister)  */
 #define M_STWX(a,c)                    OPWORD( ( (2<<6) | ((a) << 3) | 2), 0, (c))
 #define M_STAX(a,c)                    OPWORD( ( (2<<6) | ((a) << 3) | 2), 1, (c))     /* movea.l */
 
-#if !defined(ENABLE_SOFTFLOAT)
-       #define M_LFSX(a,c)             M_ILLEGAL
-       #define M_LFDX(a,c)             M_ILLEGAL
-       #define M_STFSX(a,c)            M_ILLEGAL
-       #define M_STFDX(a,c)            M_ILLEGAL
-#endif
 
 #define M_BSEXT(a,b)                   OPWORD( ( (7<<6) | ((b) << 3) | 4), 0, (a))     /* mvs.b */
 #define M_CZEXT(a,b)                   OPWORD( ( (7<<6) | ((b) << 3) | 7), 0, (a))     /* mvz.w */
                                        } while(0);
 
 #if !defined(ENABLE_SOFTFLOAT)
-       #define FCONST(a,b)             M_ILLEGAL
-       #define DCONST(a,b)             M_ILLEGAL
+       #define FCONST(a,b)             do      {\
+                                                       M_IMOV_IMM((a), REG_ITMP1);\
+                                                       OPWORD_IMM16( 0x3c8, 0, REG_ITMP1, ( (0x11 << 10) | ((b)<<7) | 0x40) );\
+                                               } while(0);
 #endif
 
 #define M_TRAP_SETREGISTER(a)          OPWORD( 0x128, 0, (a))          /* tst.b */
                cd->mcodeptr += 2; \
        } while(0);
 
+
+#if !defined(ENABLE_SOFTFLOAT)
+       
+       #define M_FCMP(b,a)             OPWORD_IMM16(0x3c8, 0, 0, ((a)<<10) | ((b)<<7) | 0x38 )                 /* fcmp.d */
+
+       #define M_BFEQ(a)               OPWORD_IMM16(0x3ca, 0, 0x01, (a))
+       #define M_BFLT(a)               OPWORD_IMM16(0x3ca, 0, 0x14, (a))
+       #define M_BFGT(a)               OPWORD_IMM16(0x3ca, 0, 0x12, (a))
+       #define M_BFUN(a)               OPWORD_IMM16(0x3ca, 0, 0x10, (a))
+
+       #define M_FADD(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x62 )             /* fsadd */
+       #define M_DADD(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x66 )             /* fdadd */
+
+       #define M_FSUB(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x68 )             /* fssub */
+       #define M_DSUB(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x6c )             /* fdsub */
+
+       #define M_FMUL(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x63 )             /* fsmul */
+       #define M_DMUL(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x67 )             /* fdmul */
+
+       #define M_FDIV(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x60 )             /* fsdiv */
+       #define M_DDIV(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x64 )             /* fddiv */
+
+       #define M_D2F(a,b)              OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x44 )             /* fsmoved */
+       #define M_F2D(a,b)              OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x40 )             /* fdmoved */
+
+       #define M_FNEG(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x5a )             /* fneg.s */
+       #define M_DNEG(a,b)             OPWORD_IMM16(0x3c8, 0, 0, ((a) << 10) | ((b) << 7) | 0x5e )             /* fneg.d */
+#endif
+
 #endif /* _CODEGEN_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:
+ */
index 822526bdbbe11f68cf42d79e649aa66c39771190..94d1926b3f4ce1f2be1b5a2e11af3b34d524c0e8 100644 (file)
 #include "vm/jit/emit-common.h"
 #include "vm/exceptions.h"
 #include "vm/jit/asmpart.h"
-
 #include "vm/builtin.h"
+
 #include "mm/memory.h"
 
+#include "threads/lock-common.h"
+
 #include "codegen.h"
 #include "md-os.h"
 
-/*
- *     Loads an immededat operand into data register
- */
+/* emit_mov_imm_reg **************************************************************************
+ *
+ *     Loads an immededat operand into an integer data register
+ *
+ ********************************************************************************************/
 void emit_mov_imm_reg (codegendata *cd, s4 imm, s4 dreg)
 {
-       if ((imm & 0x000000FF) == imm)  {
+       /* FIXME: -1 can be used as byte form 0xff, but this ifs cascade is plain wrong it seems */
+
+       if ( (imm & 0x0000007F) == imm) {
                /* use byte form */
                *((s2*)cd->mcodeptr) = 0x7000 | (dreg << 9) | imm;      /* MOVEQ.L */
                cd->mcodeptr += 2;
-       } else if ((imm  & 0xFFFF0000) != 0)    {
+       } else if ((imm  & 0x00007FFF) == imm)  {
+               /* use word form */
+               OPWORD( ((7<<6) | (dreg << 3) | 5), 7, 4);                      /* MVS.W */
+               *((s2*)cd->mcodeptr) = (s2)imm;
+               cd->mcodeptr += 2;
+       } else {
                /* use long form */
                OPWORD( ((2<<6) | (dreg << 3) | 0), 7, 4);
                *((s4*)cd->mcodeptr) = (s4)imm;
                cd->mcodeptr += 4;
-       } else {
-               /* use word form */
-               OPWORD( ((3<<6) | (dreg << 3) | 0), 7, 4);
-               *((s2*)cd->mcodeptr) = (s2)imm;
-               cd->mcodeptr += 2;
+
        }
 }
 
-
 /* emit_copy *******************************************************************
 
    Generates a register/memory to register/memory copy.
@@ -302,8 +308,8 @@ void emit_patcher_stubs(jitdata *jd)
 
                cd->mcodeptr = tmpmcodeptr;     /* restore the current mcodeptr       */
 
-               /* save REG_ITMP3 */
-               M_IPUSH(REG_ITMP3);     /* FIXME why, and restore where ? */
+               /* save REG_ITMP3, restored in asm_patcher_wrapper  */
+               M_IPUSH(REG_ITMP3);             
 
                /* move pointer to java_objectheader onto stack */
 
@@ -312,10 +318,9 @@ void emit_patcher_stubs(jitdata *jd)
                (void) dseg_add_unique_address(cd, lock_get_initial_lock_word());
                disp = dseg_add_unique_address(cd, NULL);                  /* vftbl   */
 
-               assert(0); /* The next lines are wrong */
-               M_MOV_IMM(0, REG_ITMP3);
+               M_IMOV_IMM32(0, REG_ITMP3);
                dseg_adddata(cd);
-               M_AADD_IMM(REG_ITMP3, disp);
+               M_IADD_IMM(disp, REG_ITMP3);
                M_IPUSH(REG_ITMP3);
 #else
                M_IPUSH_IMM(0);
@@ -503,14 +508,24 @@ void emit_verbosecall_enter(jitdata* jd)
        /* mark trace code */
        M_NOP;
 
-       M_LINK(REG_FP, -16*4);  
-       M_PUSHALL;
+       M_IPUSH(REG_D0);
+       M_IPUSH(REG_D1);
+       M_APUSH(REG_A0);
+       M_APUSH(REG_A1);
+
+#if !defined(ENABLE_SOFTFLOAT)
+       M_AADD_IMM(-8*2, REG_SP);
+       M_FSTORE(REG_F0, REG_SP, 8);
+       M_FSTORE(REG_F1, REG_SP, 0);
 
+       disp = 4*4 + 8*2 + 4;   /* points to old argument stack initially */
+#else
+       disp = 4*4 + 4;
+#endif
        /* builtin_verbosecall_enter takes all args as s8 type */
        /* TRACE_ARGS_NUM is the number of args the builtin_verbosecall_enter expects */
        M_IPUSH_IMM(m);
        
-       disp = 16*4 + 4 + 4;    /* points to old argument stack initially */
 
        /* travel up stack to the first argument of the function which needs to be copied */
        for (i=0; (i < md->paramcount) && (i < TRACE_ARGS_NUM); i++)    {
@@ -550,8 +565,17 @@ void emit_verbosecall_enter(jitdata* jd)
        /* pop arguments off stack */
        M_AADD_IMM(TRACE_ARGS_NUM*8+4, REG_SP);
 
-       M_POPALL;
-       M_UNLK(REG_FP);
+#if !defined(ENABLE_SOFTFLOAT)
+       M_FSTORE(REG_F1, REG_SP, 0);
+       M_FSTORE(REG_F0, REG_SP, 8);
+       M_AADD_IMM(8*2, REG_SP);
+#endif
+
+       M_APOP(REG_A1);
+       M_APOP(REG_A0);
+       M_IPOP(REG_D1);
+       M_IPOP(REG_D0);
+
        M_NOP;
 }
 void emit_verbosecall_exit(jitdata* jd) 
@@ -575,36 +599,45 @@ void emit_verbosecall_exit(jitdata* jd)
 
        /* mark trace code */
        M_NOP;
-       M_LINK(REG_FP, 0);
+
+#if !defined(ENABLE_SOFTFLOAT)
+       M_AADD_IMM(-8, REG_SP);
+       M_FSTORE(REG_F1, REG_SP, 0);
+#endif
 
        M_IPUSH_IMM(m);                                 /* push methodinfo */
 
-       M_IPUSH_IMM(0);                                 /* TODO push float result */
+#if !defined(ENABLE_SOFTFLOAT)
+       M_AADD_IMM(-3*4, REG_SP);
+       M_FST(REG_D0, REG_SP, 8);
+       M_DST(REG_D0, REG_SP, 0);
+#else
+       M_IPUSH_IMM(0);
 
-       M_IPUSH_IMM(0);                                 /* TODO push double result */
-       M_IPUSH_IMM(0);                                 /* TODO push double result */
+       M_IPUSH_IMM(0);
+       M_IPUSH_IMM(0);
+#endif
 
        M_IPUSH(GET_HIGH_REG(REG_RESULT_PACKED))
        M_IPUSH(GET_LOW_REG(REG_RESULT_PACKED))         /* push long result */
 
-
        M_JSR_IMM(builtin_verbosecall_exit);
 
        /* poping result registers from stack */
        M_IPOP(GET_LOW_REG(REG_RESULT_PACKED))
        M_IPOP(GET_HIGH_REG(REG_RESULT_PACKED))
 
-#if 0
-       /* that is wrong of course, overwrites registers and stuff */
-       M_IPOP(0);      /* TODO: pop double result */
-       M_IPOP(0);      /* TODO: pop double result */
+#if !defined(ENABLE_SOFTFLOAT)
+       M_DLD(REG_D0, REG_SP, 0)
+       M_FLD(REG_D0, REG_SP, 8)
+#endif
+       M_AADD_IMM(3*4 + 4, REG_SP);
 
-       M_IPOP(0);      /* TODO: pop float result */
-#else
-       M_AADD_IMM(3*4, REG_SP);
+#if !defined(ENABLE_SOFTFLOAT)
+       M_FLOAD(REG_F1, REG_SP, 0)
+       M_AADD_IMM(8, REG_SP);
 #endif
-       M_AADD_IMM(4, REG_SP);                          /* remove rest of stack */
-       M_UNLK(REG_FP);
+
        M_NOP;
 }
 #endif
@@ -649,8 +682,8 @@ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1,
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
                M_ICMP(s2, REG_ITMP3);
-               M_BHI(2);
-               /*M_ALD_INTERN(s2, REG_ZERO, EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS);*/
+               M_BHI(4);
+               M_TRAP_SETREGISTER(s2);
                M_TRAP(EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
        }
 }
@@ -663,7 +696,8 @@ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1,
 void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
 {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
-               /* did like to assert on TYPE_ADR, but not possible in here */
+               /* XXX: this check is copied to call monitor_enter 
+                * invocation at the beginning of codegen.c */
                M_ATST(reg);
                M_BNE(2);
                M_TRAP(M68K_EXCEPTION_HARDWARE_NULLPOINTER);
@@ -681,27 +715,9 @@ void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_ITST(reg);
                M_BNE(2);
-               /*M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_ARITHMETIC);*/
-               M_ILLEGAL; /* FIXME */
-       }
-}
-
-#if 0
-/* emit_exception_check_areg **************************************************
- *
-   Emit an Exception check, tested register is address REG_RESULT
-
-*******************************************************************************/
-void emit_exception_check_areg(codegendata *cd, instruction *iptr)
-{
-       if (INSTRUCTION_MUST_CHECK(iptr)) {
-               M_ATST(REG_RESULT);
-               M_BNE(2);
-               /*M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_EXCEPTION);*/
-               M_ILLEGAL; /*FIXME*/
+               M_TRAP(EXCEPTION_HARDWARE_ARITHMETIC);
        }
 }
-#endif
 
 /* emit_exception_check_ireg **************************************************
 
index 37735f57dfb574688920acdbb02094d5fff16df9..8ac8ade0ac20756aa7b4b490f4998bb072448e89 100644 (file)
@@ -51,7 +51,7 @@ const s4 abi_registers_integer_temporary[]    = {0,1};
 /* Address register description */
 /* A6 is used as framepointer by native code, so be sure it is REG_RES */
 /*                        A0,      A1,   ATMP1,   ATMP2,   ATMP3,      A5,  REG_FP, REG_SP */
-s4 nregdescadr[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_RES, REG_RES, REG_END };
+s4 nregdescadr[] = { REG_TMP, REG_TMP, REG_RES, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_RES, REG_END };
 
 
 /* Floatingpoint register description */
@@ -173,3 +173,16 @@ void md_return_alloc(jitdata *jd, stackptr stackslot)
 
 }
 
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of 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:
+ */
index 2f5267ee23ed5c863b569e77d4f7949a767de2b7..8787105cda1c985d4b65bba0ac8b09fd8047e9af 100644 (file)
@@ -115,7 +115,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_
                val = (opc >> 9) & 0x0007;
                off = *(uint16_t*)(xpc+1);
        } else {
-               fprintf(stderr, "SEGV: short instructions %x\n", opc);
+               
+               /*fprintf(stderr, "SEGV: short instructions %x\n", opc);
+               */
                /* now check the 32 bit sized instructions */
                if ((opc & (2<<3)) == (2<<3))   {
                        if (opc & (1<<6)) adrreg = true;                /* M_L*X */
@@ -136,7 +138,8 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, actual_ucontext_t *_
        }*/
 
 
-       fprintf(stderr, "SEGV: sp=%x, xpc=%x, regval=%x\n", sp, xpc, regval);
+       /*fprintf(stderr, "SEGV: sp=%x, xpc=%x, regval=%x\n", sp, xpc, regval);
+       */
        e = exceptions_new_hardware_exception(0, sp, xpc, xpc, EXCEPTION_HARDWARE_NULLPOINTER, regval);
 
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1]     = (ptrint) e;
@@ -181,6 +184,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_u
        /* Figure out in which register the object causing the exception resides for appropiate exceptions
         */
        switch (type)   {
+               case EXCEPTION_HARDWARE_ARITHMETIC:
                case EXCEPTION_HARDWARE_EXCEPTION:
                        /* nothing */
                        break;
@@ -191,7 +195,10 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_u
                        regval = _mc->gregs[ GREGS_ADRREG_OFF + (regval & 0x7) ];
                        break;
                case EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS:
-                       regval = 0; /* FIXME */
+                       regval = *(uint16_t*)(xpc-4);
+                       assert( (regval&0xfff0) == 0x4a00 );
+                       /* was a data register */
+                       regval = _mc->gregs[regval & 0x7];
                        break;
                case M68K_EXCEPTION_HARDWARE_NULLPOINTER:
                        type = EXCEPTION_HARDWARE_NULLPOINTER;
@@ -200,10 +207,26 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, actual_ucontext_t *_u
                default: assert(0);
        }
 
-       /*fprintf(stderr, "NEW HWE: sp=%x, xpc=%x, tpye=%x, regval=%x\n", sp, xpc, type, regval);*/
+       /*fprintf(stderr, "NEW HWE: sp=%x, xpc=%x, tpye=%x, regval=%x\n", sp, xpc, type, regval);
+       */
        e = exceptions_new_hardware_exception(0, sp, xpc, xpc, type, regval);
 
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP1]     = (ptrint) e;
        _mc->gregs[GREGS_ADRREG_OFF + REG_ATMP2_XPC] = (ptrint) xpc;
        _mc->gregs[R_PC]          = (ptrint) asm_handle_exception;
 }
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of 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:
+ */
index 847d09ef5dee50c271deb4f2cc64580d8375140d..2f730f3b0bde2c495329a51f4cc438c29e2fb7c1 100644 (file)
 
 void md_signal_handler_sigill();
 void md_init_linux();
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of 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:
+ */
index 7d939407eeab88afeb08fd7f8858af4bf38e7c74..16eaec2ff30285f5aeb0bbd169b5b18bbd9b671b 100644 (file)
@@ -48,3 +48,18 @@ static inline long compare_and_swap(long *p, long oldval, long newval)
 #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:
+ */
index 4214fad1b1668b5f78a1350a0ad268ec49c6dab0..c2c668adbe41578f921667ff63271319dbddbe85 100644 (file)
@@ -119,20 +119,22 @@ u1* md_get_method_patch_address(u1 *ra, stackframeinfo *sfi, u1 *mptr)
        s2   offset;
 
        if (*((u2*)(ra - 2)) == 0x4e94) {               /* jsr %a4@ */
-               /* we had a moveal XXX, %a3 which is a 3 word opcode */
-               /* 2679 0000 0000 */
-               assert(*(u2*)(ra - 8) == 0x2879);               /* moveal */
-               pa = *((u4*)(ra - 6));                          /* another indirection ! */
-       } else if (*((u2*)(ra - 2)) == 0x4e92)  {               /* jsr %a2@ */
-               if (*(u2*)(ra - 8) == 0x247c)   {
-                       /* found a invokestatic/invokespecial */
-                       pa = ((u4*)(ra - 6));                   /* no indirection ! */
-               } else if (*((u2*)(ra - 6)) == 0x246b)  {
+               if (*((u2*)(ra - 6)) == 0x286b) {
                        /* found an invokevirtual */
                        /* get offset of load instruction 246b XXXX */
                        offset = *((s2*)(ra - 4));
                        pa = mptr + offset;                     /* mptr contains the magic we want */
                } else  {
+                       /* we had a moveal XXX, %a3 which is a 3 word opcode */
+                       /* 2679 0000 0000 */
+                       assert(*(u2*)(ra - 8) == 0x2879);               /* moveal */
+                       pa = *((u4*)(ra - 6));                          /* another indirection ! */
+               }
+       } else if (*((u2*)(ra - 2)) == 0x4e92)  {               /* jsr %a2@ */
+               if (*(u2*)(ra - 8) == 0x247c)   {
+                       /* found a invokestatic/invokespecial */
+                       pa = ((u4*)(ra - 6));                   /* no indirection ! */
+               } else {
                        assert(0);
                }
        } else {
@@ -211,8 +213,39 @@ u1* md_stacktrace_get_returnaddress(u1* sp, u4 framesize)
 { 
        /* return address is above stackpointer */
        u1 *ra = *((u1**)(sp + framesize));
+       
+       /* XXX: This helps for now, but it's a ugly hack
+        * the problem _may_ be: the link instruction is used
+        * by some gcc generated code, and we get an additional word
+        * on the stack, the old framepointer. Its address is somewhere
+        * near sp, but that all depends the code generated by the compiler.
+        * I'm unsure about a clean solution.
+        */
+       #if 0
+       if (!(ra > 0x40000000 && ra < 0x80000000))      {
+               ra = *((u1**)(sp + framesize + 4));
+       }
+       #endif
+       /* assert(ra > 0x40000000 && ra < 0x80000000);
+       printf("XXXXXX=%x\n", ra);
+        */
        return ra;
 }
 
 
 void md_codegen_patch_branch(void) { assert(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:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 8e00d734fc9a1441d973aa162711769cc3f26238..1e92250cde4b45c84d8323be23994e4e6ea447ce 100644 (file)
@@ -72,7 +72,6 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
        functionptr        f;
        bool               result;
        java_objectheader *e;
-       u4                 mcode, xmcode;
 
        /* define the patcher function */
 
@@ -83,29 +82,21 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
        xpc = (u1 *)                *((ptrint *) (sp + 6 * 4));
        /* REG_ITMP3                              sp + 5 * 4 */
        o   = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
-       mcode =                     *((u4*)      (sp + 3 * 4));
-       xmcode =                    *((u4*)      (sp + 2 * 4));
+       /*mcode =                                   *((u4*)      (sp + 3 * 4));*/
+       /*xmcode =                                      *((u4*)      (sp + 2 * 4));*/
        /* unresolved file                        sp + 1 * 4 */
        f   = (functionptr)         *((ptrint *) (sp + 0 * 4));
 
 
        /* calculate and set the new return address */
-
        xpc = xpc - PATCHER_CALL_SIZE;
        *((ptrint *) (sp + 6 * 4)) = (ptrint) xpc;
 
-       /* patch back original code */
-
-       *((u4*)(xpc))   = mcode;
-       *((u4*)(xpc+4)) = xmcode;
-       md_icacheflush(xpc, 8);
 
        /* cast the passed function to a patcher function */
-
        patcher_function = (bool (*)(u1 *)) (ptrint) f;
 
        /* enter a monitor on the patching position */
-
        PATCHER_MONITORENTER;
 
        /* create the stackframeinfo */
@@ -114,18 +105,19 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
           stacktrace_create_extern_stackframeinfo for
           md_codegen_get_pv_from_pc. */
 
+       /*
+       fprintf(stderr, "EXT STACKFRAME: sfi=%x pv=%x, sp=%x, xpc=%x\n", &sfi, pv, sp+7*4, xpc);
+       */
        stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 7 * 4, xpc, xpc);
 
        /* call the proper patcher function */
-
        result = (patcher_function)(sp);
 
-       /* remove the stackframeinfo */
 
+       /* remove the stackframeinfo */
        stacktrace_remove_stackframeinfo(&sfi);
 
        /* check for return value and exit accordingly */
-
        if (result == false) {
                e = exceptions_get_and_clear_exception();
 
@@ -138,6 +130,19 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
        return NULL;
 }
 
+/*     Helper
+ */
+static void patcher_patch_back(u1 *sp) 
+{
+       u1* xpc    = (u1 *)      *((ptrint *) (sp + 6 * 4));
+       u4 mcode  = *((u4*)      (sp + 3 * 4));
+       u4 xmcode = *((u4*)      (sp + 2 * 4));
+
+       *((u4*)(xpc))   = mcode;
+       *((u4*)(xpc+4)) = xmcode;
+       md_icacheflush(xpc, 8);
+}
+
 /* patcher_initialize_class ****************************************************
 
    Initalizes a given classinfo pointer.  This function does not patch
@@ -148,17 +153,19 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
 bool patcher_initialize_class(u1 *sp)
 {
        classinfo *c;
+       u4                 xpc, mcode, xmcode;
 
        /* get stuff from the stack */
-
        c = (classinfo *) *((ptrint *) (sp + 1 * 4));
 
        /* check if the class is initialized */
-
        if (!(c->state & CLASS_INITIALIZED))
                if (!initialize_class(c))
                        return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        return true;
 }
 
@@ -188,10 +195,13 @@ bool patcher_invokevirtual(u1 *sp)
        if (!(m = resolve_method_eager(um)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
 
-       assert( *((u2*)(ra+8)) == 0x246b);
+       assert( *((u2*)(ra+8)) == 0x286b);
 
        /* patch vftbl index */
        disp = (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
@@ -221,17 +231,17 @@ bool patcher_invokestatic_special(u1 *sp)
        methodinfo        *m;
 
        /* get stuff from the stack */
-
        disp =                       *((s4 *)     (sp + 6 * 4));
        um   = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
 
        /* get the fieldinfo */
-
        if (!(m = resolve_method_eager(um)))
                return false;
 
-       /* patch stubroutine */
+       /* patch back original code */
+       patcher_patch_back(sp);
 
+       /* patch stubroutine */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
 
        *((ptrint *) (disp+2)) = (ptrint) m->stubroutine;
@@ -256,17 +266,19 @@ bool patcher_resolve_class(u1 *sp)
 {
        unresolved_class *uc;
        classinfo        *c;
+       s4                              disp;
 
        /* get stuff from the stack */
-
-       uc = (unresolved_class *) *((ptrint *) (sp + 2 * 4));
+       uc = (unresolved_class *) *((ptrint *) (sp + 1 * 4));
+       disp =                    *((s4 *)     (sp + 6 * 4));
 
        /* resolve the class */
-       assert(0);
-
        if (!resolve_class(uc, resolveEager, false, &c))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        return true;
 }
 #endif /* ENABLE_VERIFIER */
@@ -283,23 +295,21 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
        classinfo         *c;
 
        /* get stuff from the stack */
-
        cr   = (constant_classref *) *((ptrint *) (sp + 1 * 4));
        disp =                       *((s4 *)     (sp + 6 * 4));
 
        /* get the classinfo */
-
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       /* patch the classinfo pointer */
+       /* patch back original code */
+       patcher_patch_back(sp);
 
+       /* patch the classinfo pointer */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
-
        *((ptrint *) (disp+2)) = (ptrint) c;
 
        /* synchronize inst cache */
-
        md_icacheflush(disp+2, SIZEOF_VOID_P);
 
        return true;
@@ -314,40 +324,34 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 bool patcher_get_putstatic(u1 *sp)
 {
        u1               *ra;
-       u4                mcode;
        unresolved_field *uf;
        s4                disp;
        u1               *pv;
        fieldinfo        *fi;
 
        /* get stuff from the stack */
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 4));
-       mcode =                       *((u4 *)     (sp + 3 * 4));
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 2 * 4));
-       disp  =                       *((s4 *)     (sp + 1 * 4));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 4));
+       uf    = (unresolved_field *)  *((ptrint *) (sp + 1 * 4));
+       disp  =                       *((s4 *)     (sp + 6 * 4));
 
        /* get the fieldinfo */
-
-       assert(0);
-
        if (!(fi = resolve_field_eager(uf)))
                return false;
 
        /* check if the field's class is initialized */
-
        if (!(fi->class->state & CLASS_INITIALIZED))
                if (!initialize_class(fi->class))
                        return false;
 
-       /* patch the field value's address */
-
-       *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+       /* patch back original code */
+       patcher_patch_back(sp);
 
-       /* synchronize data cache */
+       /* patch the field value's address */
+       if (opt_shownops) disp += PATCHER_CALL_SIZE;
+       assert(*((uint16_t*)(disp)) == 0x247c);
+       *((ptrint *) (disp+2)) = (ptrint) &(fi->value);
 
-       md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+       /* synchronize inst cache */
+       md_icacheflush(disp+2, SIZEOF_VOID_P);
 
        return true;
 }
@@ -371,64 +375,46 @@ bool patcher_get_putfield(u1 *sp)
        uf = (unresolved_field *) *((ptrint *) (sp + 1 * 4));
 
        /* get the fieldinfo */
-
-       assert(0);
-
        if (!(fi = resolve_field_eager(uf)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* if we show NOPs, we have to skip them */
+       if (opt_shownops) ra += PATCHER_CALL_SIZE;
 
-       if (opt_shownops) {
-               /* patch the field's offset */
-
-               if (IS_LNG_TYPE(fi->type)) {
-                       /* If the field has type long, we have to patch two
-                          instructions.  But we have to check which instruction
-                          is first.  We do that with the offset of the first
-                          instruction. */
-
-                       disp = *((u4 *) (ra + 1 * 4));
-
-                       if (disp == 4) {
-                               *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
-                               *((u4 *) (ra + 2 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
-                       }
-                       else {
-                               *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
-                               *((u4 *) (ra + 2 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
-                       }
+       /* patch the field's offset */
+       if (IS_LNG_TYPE(fi->type)) {
+               /* If the field has type long, we have to patch two
+                  instructions.  But we have to check which instruction
+                  is first.  We do that with the offset of the first
+                  instruction. */
+               assert(0);
+               disp = *((u4 *) (ra + 1 * 4));
+
+               if (disp == 4) {
+                       *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
+                       *((u4 *) (ra + 2 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
                }
-               else
-                       *((u4 *) (ra + 1 * 4)) |= (s2) (fi->offset & 0x0000ffff);
-       }
-       else {
-               if (IS_LNG_TYPE(fi->type)) {
-
-                       disp = *((u4 *) (sp + 3 * 4));
-
-                       /* We patch the first instruction in the patcher stub
-                          stack and the second in the code.  The first
-                          instruction is patched back later in
-                          patcher_wrapper. */
-
-                       if (disp == 4) {
-                               *((u4 *) (sp + 3 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
-                               *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
-                       }
-                       else {
-                               *((u4 *) (sp + 3 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
-                               *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
-                       }
+               else {
+                       *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
+                       *((u4 *) (ra + 2 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
                }
-               else
-                       *((u4 *) (sp + 3 * 4)) |= (s2) (fi->offset & 0x0000ffff);
+       } else  {
+               /*
+                *      0x40adb3f6:     0x254d0000      movel %a5,%a2@(0)
+                *                            ^^^^                     ^
+                *                            to be patched
+                */
+               assert( (*((uint32_t*)ra) & 0xffff0000) == *((uint32_t*)ra) );
+               assert( (fi->offset & 0x0000ffff) == fi->offset );
+               *((uint32_t*)ra) |= fi->offset;
+
+               /* synchronize instruction cache */
+               md_icacheflush(ra, 1 * 4);
        }
 
-       /* synchronize instruction cache */
-
-       md_icacheflush(ra + 1 * 4, 2 * 4);
-
        return true;
 }
 /* patcher_resolve_classref_to_flags *******************************************
@@ -463,6 +449,9 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* patch class flags */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
        assert( (*((u2*)(disp)) == 0x263c) || (*((u2*)(disp)) == 0x283c) );
@@ -503,6 +492,9 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* patch super class' vftbl */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
        assert( (*((u2*)disp) == 0x287c) || (*((u2*)disp)== 0x267c) );
@@ -545,6 +537,9 @@ bool patcher_instanceof_interface(u1 *sp)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
                
@@ -595,6 +590,9 @@ bool patcher_checkcast_interface(u1 *sp)
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* if we show NOPs, we have to skip them */
        if (opt_shownops) ra += PATCHER_CALL_SIZE;
 
@@ -635,6 +633,9 @@ bool patcher_resolve_native_function(u1 *sp)
        if (!(f = native_resolve_function(m)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* patch native function pointer */
        if (opt_shownops) disp += PATCHER_CALL_SIZE;
        *((ptrint *) (disp + 2)) = (ptrint) f;
@@ -650,6 +651,10 @@ bool patcher_resolve_native_function(u1 *sp)
 /* patcher_invokeinterface *****************************************************
 
    Machine code:
+0x40adb03e:     moveal %a2@(0),%a3             0x266a0000              <-- no patching
+0x40adb042:     moveal %a3@(0),%a3             0x266b0000              <-- patch this 0000
+0x40adb046:     moveal %a3@(0),%a4             0xxxxx0000              <-- patch this 0000
+0x40adb04a:     jsr %a4@                               0xxxxx                  
 
 
 *******************************************************************************/
@@ -665,30 +670,44 @@ bool patcher_invokeinterface(u1 *sp)
        ra = (u1 *)                *((ptrint *) (sp + 6 * 4));
        um = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
 
-       assert(0);
 
        /* get the fieldinfo */
        if (!(m = resolve_method_eager(um)))
                return false;
 
+       /* patch back original code */
+       patcher_patch_back(sp);
+
        /* if we show NOPs, we have to skip them */
-       if (opt_shownops) ra = ra + PATCHER_CALL_SIZE;
+       if (opt_shownops) ra += PATCHER_CALL_SIZE;
+       assert( *((uint32_t*)ra) == 0x246f0000 );
 
        /* patch interfacetable index (first #0) */
        disp = OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr*) * m->class->index;
-
-       /* XXX TWISTI: check displacement */
-       *((s4 *) (ra + 1 * 4)) |= (disp & 0x0000ffff);
+       /* XXX this disp is negative, check! 
+        * assert( (disp & 0x0000ffff) == disp);*/
+       *((uint16_t *) (ra + 5 * 2)) = disp;
 
        /* patch method offset (second #0) */
        disp = sizeof(methodptr) * (m - m->class->methods);
-
-       /* XXX TWISTI: check displacement */
-       *((s4 *) (ra + 2 * 4)) |= (disp & 0x0000ffff);
+       assert( (disp & 0x0000ffff) == disp);
+       *((uint16_t *) (ra + 7 * 2)) = disp;
 
        /* synchronize instruction cache */
-       md_icacheflush(ra + 1 * 4, 2 * 4);
+       md_icacheflush(ra + 5 * 2, 2 * 2);
 
        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/mips/.cvsignore b/src/vm/jit/mips/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index 9b1faa088ecd61764e510a17868a34283c118729..3af2ae78e7341175b9b2c882b4674bed3cb4ba1f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7880 2007-05-07 14:13:45Z twisti $
 
 */
 
@@ -43,9 +43,7 @@
 
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -3294,20 +3292,6 @@ gen_method:
 
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *
-                        *  OK if ((sub == NULL) ||
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL));
-                        *
-                        *  superclass is a class:
-                        *
-                        *  OK if ((sub == NULL) || (0
-                        *         <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *         super->vftbl->diffvall));
-                        */
 
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                classinfo *super;
@@ -3318,13 +3302,12 @@ gen_method:
                                        superindex = 0;
                                }
                                else {
-                                       super = iptr->sx.s23.s3.c.cls;
+                                       super      = iptr->sx.s23.s3.c.cls;
                                        superindex = super->index;
                                }
                        
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+                                       CODEGEN_CRITICAL_SECTION_NEW;
 
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
@@ -3395,9 +3378,9 @@ gen_method:
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       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)); */
@@ -3411,9 +3394,9 @@ gen_method:
                                        M_ISUB(REG_ITMP2, REG_ITMP3, REG_ITMP2); 
                                        M_ALD(REG_ITMP3, REG_PV, disp);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        /*                              } */
                                        M_CMPULT(REG_ITMP3, REG_ITMP2, REG_ITMP3);
                                        emit_classcast_check(cd, iptr, ICMD_IFNE, REG_ITMP3, s1);
@@ -3460,20 +3443,6 @@ gen_method:
                        break;
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *
-                        *  return (sub != NULL) &&
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL);
-                        *
-                        *  superclass is a class:
-                        *
-                        *  return ((sub != NULL) && (0
-                        *          <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *          super->vftbl->diffvall));
-                        */
 
                        {
                        classinfo *super;
@@ -3490,9 +3459,8 @@ gen_method:
                                superindex = super->index;
                        }
                        
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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);
@@ -3570,15 +3538,15 @@ gen_method:
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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);
index 5e4649a7b65e2878c6c51a57c05550a8e548e592..1a5b3cbd4aa9669593b60958d0f26f592b7e1804 100644 (file)
@@ -38,9 +38,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
diff --git a/src/vm/jit/mips/irix/.cvsignore b/src/vm/jit/mips/irix/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/mips/linux/.cvsignore b/src/vm/jit/mips/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 8beb3adf7954352d5d1578919ee1515543e58b73..8461616a35fe7c323668ed969f4a6ef5ab832b4e 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7688 2007-04-12 09:05:12Z michi $
+   $Id: md-os.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -199,8 +199,15 @@ 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 thread_restartcriticalsection(ucontext_t *_uc)
+void md_critical_section_restart(ucontext_t *_uc)
 {
        mcontext_t *_mc;
        u1         *pc;
diff --git a/src/vm/jit/optimizing/.cvsignore b/src/vm/jit/optimizing/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 236d355e11395bd8ed2d00f83fe966b28efda509..f9138d7cb2537339841b7da07dd7551d7cd8d902 100644 (file)
@@ -33,6 +33,8 @@
 
 #include "toolbox/bitvector.h"
 
+#include "vm/jit/jit.h"
+
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/dominators.h"
 
index 88a8963eb4026c5949a9e2d21170dae69228700d..461cca8e60b64d29423f001f35c9d324193daeaa 100644 (file)
 
 */
 
+#include <stdlib.h>
+
+#include "config.h"
+
 #include "mm/memory.h"
 
 #include "toolbox/bitvector.h"
 
+#include "vm/jit/jit.h"
+
 #include "vm/jit/optimizing/lsra.h"
 #include "vm/jit/optimizing/ssa.h"
 #include "vm/jit/optimizing/graph.h"
 
 #ifdef GRAPH_DEBUG_VERBOSE
-#include "vm/options.h"
+#include "vmcore/options.h"
 #endif
 
-
 /* Helpers for graph_make_cfg */
-void graph_add_jsr( methodinfo *m, graphdata *gd, struct _sbr *sbr,int from,
-                                       int to);
-void graph_add_cfg( methodinfo *m, graphdata *gd, int from, int to);
-void graph_add_exceptions(methodinfo *m, codegendata *cd, graphdata *gd); 
-void graph_add_subs(methodinfo *m, graphdata *gd, struct _sbr *sbr);
+void graph_add_cfg( jitdata *jd, graphdata *gd, basicblock *, basicblock *);
+void graph_add_exceptions(jitdata *jd, graphdata *gd); 
 void graph_add_edge( graphdata *gd, int from, int to );
-/* Helper for graph_make_subs */
-void graph_add_sub( methodinfo *m, graphdata *gd, int b_index,
-                                       graph_element *ret, bool *visited );
+
 /* Helper for graph_get_first_* */
 int graph_get_first_(graph_element *ge, graphiterator *i);
 void transform_CFG(jitdata *, graphdata *);
@@ -161,35 +161,43 @@ void graph_add_edge( graphdata *gd, int from, int to ) {
        gd->num_pred[to]++;
 }
 
-/* split the edge from BB from shown by iterator i wiht new_block */
+/* split the edge from BB from shown by iterator i with new_block */
 void graph_split_edge(graphdata *gd, int from, graphiterator *i, int new_block) {
        graphiterator i_pred;
        graph_element *n;
        int l, succ;
 
        /* i->value is the BB index of the "old" successor */
+
        succ = (*i)->value;
+
        /* search for iterator showing predecessor edge from BB succ back to */
        /* from */
+
        l = graph_get_first_predecessor(gd, succ, &i_pred);
        for(; (l != -1) && (l != from); l = graph_get_next(&i_pred));
        _GRAPH_ASSERT(l == from);
 
        /* change CFG entries */
+
        (*i)->value = new_block;
        i_pred->value = new_block;
 
        /* and insert the CFG successor and predecesser entries for new_block */
        /* 2 entries needed */
+
        n = DMNEW(graph_element, 2);
+
        /* make the successor entry for new_block */
+
        n->value = succ;
        n->next = gd->successor[new_block];
        gd->successor[new_block] = n;
        gd->num_succ[new_block]++;
 
-       n++;
        /* make the predecessor entry for new_block */
+
+       n++;
        n->value = from;
        n->next = gd->predecessor[new_block];
        gd->predecessor[new_block] = n;
@@ -201,42 +209,35 @@ Generate the Control Flow Graph
 ( pred,succ,num_pred of lsradata structure) 
 ************************************************/
 void graph_make_cfg(jitdata *jd,graphdata *gd) {
-       instruction *ip;
-       s4 *s4ptr;
-       int high, low, count;
-       int b_index, len;
-       bool fall_through;
-       struct _sbr sbr; /* list of subroutines, sorted by header */
+       instruction *iptr;
+       lookup_target_t *lookup;
+       branch_target_t *table;
+       int len, i, l;
        methodinfo *m;
        codegendata *cd;
        registerdata *rd;
        lsradata *ls;
+       basicblock *bptr;
 
        m = jd->m;
        cd = jd->cd;
        rd = jd->rd;
        ls = jd->ls;
 
-       sbr.next = NULL;
-
        /* Add edge from new Basic Block 0 (parameter initialization) */
        graph_add_edge(gd, 0, 1);
 
-       b_index=0;
-       while (b_index < m->basicblockcount ) {
-               if (m->basicblocks[b_index].flags >= BBREACHED) {
-                       fall_through = false;
-                                                                       
-                       if ((len = m->basicblocks[b_index].icount)) {
-                               /* set ip to last non NOP instruction   */
-                               ip = m->basicblocks[b_index].iinstr +
-                                       m->basicblocks[b_index].icount -1;
-                               while ((len>0) && (ip->opc == ICMD_NOP)) {
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+               if (bptr->flags >= BBREACHED) {
+                       if ((len = bptr->icount)) {
+                               /* set iptr to last non NOP instruction */
+                               iptr = bptr->iinstr + bptr->icount -1;
+                               while ((len>0) && (iptr->opc == ICMD_NOP)) {
                                        len--;
-                                       ip--;
+                                       iptr--;
                                }
                                /* block contains instructions  */
-                               switch (ip->opc) {                      /* check type of last instruction */
+                               switch (iptr->opc) {            /* check type of last instruction */
                                case ICMD_RETURN:
                                case ICMD_IRETURN:
                                case ICMD_LRETURN:
@@ -244,7 +245,6 @@ void graph_make_cfg(jitdata *jd,graphdata *gd) {
                                case ICMD_DRETURN:
                                case ICMD_ARETURN:
                                case ICMD_ATHROW:
-/*                                     graph_add_cfg(m, gd, b_index, m->basicblockcount); */
                                        break;                            /* function returns -> end of graph */
 
                                case ICMD_IFNULL:
@@ -275,70 +275,65 @@ void graph_make_cfg(jitdata *jd,graphdata *gd) {
                                case ICMD_IF_LCMPLE:
                                case ICMD_IF_ACMPEQ:
                                case ICMD_IF_ACMPNE:                /* branch -> add next block */
-                                       fall_through = true;
-/*                                     graph_add_cfg(m, gd, b_index, b_index+1); */
-                                       /* fall throu -> add branch target */
+                                       /* Add branch target */
+                                       graph_add_cfg(jd, gd, bptr, iptr->dst.block);
+                                       /* Add fall through path */
+                                       graph_add_cfg(jd, gd, bptr, bptr->next);
+                                       break;
+
                           
                                case ICMD_GOTO:
-                                       graph_add_cfg(m, gd, b_index,  m->basicblockindex[ip->op1]);
-                                       if (fall_through)
-                                               graph_add_cfg(m, gd, b_index, b_index+1);
+                                       graph_add_cfg(jd, gd, bptr,  iptr->dst.block);
                                        break;                                  /* visit branch (goto) target   */
                                
                                case ICMD_TABLESWITCH:          /* switch statement                             */
-                                       s4ptr = ip->val.a;
-                               
-                                       graph_add_cfg(m, gd, b_index,  m->basicblockindex[*s4ptr]);
-                               
-                                       s4ptr++;
-                                       low = *s4ptr;
-                                       s4ptr++;
-                                       high = *s4ptr;
-                               
-                                       count = (high-low+1);
-                               
-                                       while (--count >= 0) {
-                                               s4ptr++;
-                                               graph_add_cfg(m, gd, b_index, 
-                                                                        m->basicblockindex[*s4ptr]);
-                                   }
+                                       table = iptr->dst.table;
+                                       l = iptr->sx.s23.s2.tablelow;
+                                       i = iptr->sx.s23.s3.tablehigh;
+                                       i = i - l + 1;
+
+                                       /* Add default target */
+
+                                       graph_add_cfg(jd, gd, bptr,  table[0].block);
+                                       table += i;
+
+                                       while (--i >= 0) {
+                                               graph_add_cfg(jd, gd, bptr,  table->block);
+                                               --table;
+                                       }
                                        break;
                                
                                case ICMD_LOOKUPSWITCH:         /* switch statement                             */
-                                       s4ptr = ip->val.a;
-                          
-                                       graph_add_cfg(m, gd, b_index,  m->basicblockindex[*s4ptr]);
-                               
-                                       ++s4ptr;
-                                       count = *s4ptr++;
-                               
-                                       while (--count >= 0) {
-                                               graph_add_cfg(m, gd, b_index,
-                                                                         m->basicblockindex[s4ptr[1]]);
-                                               s4ptr += 2;
-                                   }
-                                       break;
+                                       lookup = iptr->dst.lookup;
+                                       i = iptr->sx.s23.s2.lookupcount;
+                       
+                                       while (--i >= 0) {
+                                               graph_add_cfg(jd, gd, bptr, lookup->target.block);
+                                               lookup++;
+                                       }
 
-                               case ICMD_JSR:
-                                       graph_add_jsr(m, gd, &sbr, b_index, m->basicblockindex[ip->op1]);
+                                       graph_add_cfg(jd, gd, bptr, iptr->sx.s23.s3.lookupdefault.block);
                                        break;
-                               
+
                                case ICMD_RET:
+                               case ICMD_JSR:
+                                       assert(0);
                                        break;
+
+                               case ICMD_NOP:
+                                       assert(0);
                                
                                default:
-                                       graph_add_cfg(m, gd, b_index, b_index + 1 );
+                                       graph_add_cfg(jd, gd, bptr, bptr + 1 );
                                        break;  
-                           } /* switch (ip->opc)*/                        
-                   }     /* if (m->basicblocks[blockIndex].icount) */
-           }         /* if (m->basicblocks[b_index].flags >= BBREACHED) */
-               b_index++;
-       }             /* while (b_index < m->basicblockcount ) */
-
-       /* add subroutines before exceptions! They "destroy" the CFG */
-       graph_add_subs(m, gd, &sbr); 
-       graph_add_exceptions(m, cd, gd);
+                           } /* switch (iptr->opc)*/                        
+                   }     /* if (bptr->icount) */
+           }         /* if (bptr->flags >= BBREACHED) */
+       }             /* for (bptr = ...; bptr != NULL; bptr = bptr->next) */
+
+       graph_add_exceptions(jd, gd);
        transform_CFG(jd, gd);
+
 #ifdef GRAPH_DEBUG_VERBOSE
        if (compileverbose)
                graph_print(ls, gd);
@@ -348,13 +343,19 @@ void graph_make_cfg(jitdata *jd,graphdata *gd) {
 /*****************************************************************
 add Edges from guarded Areas to Exception handlers in the CFG
 *****************************************************************/
-void graph_add_exceptions(methodinfo *m, codegendata *cd, graphdata *gd) { 
-       int i;
+void graph_add_exceptions(jitdata *jd, graphdata *gd) { 
+#if 0
+       basicblock *bptr;
+       raw_exception_entry *ex;
+       codegendata *cd;
+
+       cd = jd->cd;
 
        /* add cfg edges from all bb of a try block to the start of the according */
        /* exception handler to ensure the right order after depthfirst search    */
-       exceptiontable *ex;
+
        ex=jd->exceptiontable;
+
 #ifdef GRAPH_DEBUG_VERBOSE
        if (compileverbose)
                printf("ExTable(%i): ", jd->exceptiontablelength);
@@ -367,166 +368,49 @@ void graph_add_exceptions(methodinfo *m, codegendata *cd, graphdata *gd) {
                        printf("[%i-%i]->%i ",ex->start->nr, ex->end->nr,
                                   ex->handler->nr);
 #endif
-               _GRAPH_ASSERT(ex->handler->nr < m->basicblockcount);
-               _GRAPH_ASSERT(m->basicblocks[ex->handler->nr].flags >= BBREACHED);
+
+               _GRAPH_ASSERT(ex->handler->nr < jd->new_basicblockcount);
+               _GRAPH_ASSERT(ex->handler->flags >= BBREACHED);
                _GRAPH_ASSERT(ex->start->nr <= ex->end->nr);
 
                /* loop all valid Basic Blocks of the guarded area and add CFG edges  */
                /* to the appropriate handler */
-               for (i=ex->start->nr; (i <= ex->end->nr) &&
-                                (i < m->basicblockcount); i++)
-                       if (m->basicblocks[i].flags >= BBREACHED)
-                               graph_add_cfg(m, gd, i, ex->handler->nr);
+               for (bptr = ex->start; (bptr != NULL) && (bptr != ex->end); bptr = bptr->next) 
+                       if (bptr->flags >= BBREACHED)
+                               graph_add_cfg(jd, gd, bptr, ex->handler);
+
+               _GRAPH_ASSERT((bptr != NULL) 
+                                         && ((bptr->flags >=BBREACHED) || (bptr == ex->end)));
        }
 #ifdef GRAPH_DEBUG_VERBOSE
        if (compileverbose)
                printf("\n");
 #endif
-}
-
-/**************************************************
-Add subroutines from ls->sbr list to CFG
-**************************************************/
-void graph_add_subs(methodinfo *m, graphdata *gd, struct _sbr *sbr) {
-       struct _sbr *_sbr;
-       bool *visited;
-       int i;
-#ifdef GRAPH_DEBUG_VERBOSE
-       graph_element *ret;
-#endif
-
-       visited = (bool *)DMNEW(int, m->basicblockcount + 1);
-       for (i=0; i <= m->basicblockcount; i++) visited[i] = false;
-       for (_sbr = sbr->next; _sbr != NULL; _sbr=_sbr->next) {
-#ifdef GRAPH_DEBUG_VERBOSE
-               if (compileverbose) {
-                       printf("Subroutine Header: %3i Return Adresses:",_sbr->header);
-                       for (ret = _sbr->ret; ret != NULL; ret = ret->next)
-                               printf(" %3i", ret->value);
-                       printf("\n");
-               }
 #endif
-               graph_add_sub( m, gd, _sbr->header, _sbr->ret, visited );
-
-       }
 }
 
+
 /******************************************************************
 Add the CFG Edge into next und succ
 ******************************************************************/
-void graph_add_cfg( methodinfo *m, graphdata *gd, int from, int to) {
+void graph_add_cfg( jitdata *jd, graphdata *gd, basicblock *from,
+                                       basicblock *to) {
 
        /* ignore Empty, Deleted,... Basic Blocks as target */
        /* TODO: Setup BasicBlock array before to avoid this */
        /*       best together with using the basicblock list, so lsra works */
        /*       with opt_loops, too */
-       for (;(to < m->basicblockcount) && (m->basicblocks[to].flags < BBREACHED);
-                to++);
 
-       /* add one to from and to, so the to be inserted Basic Block 0 is */
-       /* already regarded */
-       graph_add_edge( gd, from + 1, to + 1);
-}
+       for (; (to != NULL) && (to->flags < BBREACHED); to = to->next);
 
-/*******************************************************************
-Remember Subroutine "jumps" in ls->sbr and add the CFG Edge of the 
-"jump" into succ and pred 
-*******************************************************************/
-void graph_add_jsr( methodinfo *m, graphdata *gd, struct _sbr *sbr, int from,
-                                       int to) {
-       struct _sbr *_sbr, *n;
-       graph_element *ret;
+       _GRAPH_ASSERT(to != NULL);
 
-       /* ignore Empty, Deleted,... Basic Blocks as target */
-       /* TODO: Setup BasicBlock array before to avoid this */
-       /*       best together with using the basicblock list, so lsra works */
-       /*       with opt_loops, too */
-       for (; (to < m->basicblockcount) && (m->basicblocks[to].flags < BBREACHED);
-                to++);
-       _GRAPH_ASSERT( to != m->basicblockcount );
-
-       graph_add_cfg(m, gd, from, to);
-
-       /* from + 1 ist the return Basic Block Index */
-       for (from++; (from < m->basicblockcount) &&
-                        (m->basicblocks[from].flags < BBREACHED); from++);
-       _GRAPH_ASSERT(from != m->basicblockcount);
-
-       /* add subroutine info in ls->sbr.next */
-
-       /* search for right place to insert */
-       for (_sbr = sbr; (_sbr->next != NULL) && (_sbr->next->header < to);
-                _sbr=_sbr->next);
-       
-       if ((_sbr->next!= NULL) && (_sbr->next->header == to)) {
-               /* Entry for this sub already exist */
-               _sbr = _sbr->next;
-       } else {
-               /* make new Entry and insert it in ls->sbr.next */
-               n = DNEW( struct _sbr );
-               n->header = to;
-               n->ret = NULL;
-
-               n->next = _sbr->next;
-               _sbr->next = n;
-
-               _sbr = n;
-       }
 
-       /* now insert return adress in sbr->ret */
-       ret = DNEW(graph_element);
-       ret->value = from;
-       ret->next = _sbr->ret;
-       _sbr->ret = ret;
+       /* add one to from and to, so the to be inserted Basic Block 0 is */
+       /* already regarded */
+       graph_add_edge( gd, from->nr + 1, to->nr + 1);
 }
 
-/**************************************************
-Add a subroutine to CFG
-**************************************************/
-void graph_add_sub(methodinfo *m, graphdata *gd, int b_index,
-                                  graph_element *ret, bool *visited ) {
-       graph_element *l;
-       instruction *ip;
-       bool next_block;
-       graphiterator i;
-       int s;
-
-       /* break at virtual End Block */
-       if (b_index != m->basicblockcount) {
-               visited[b_index] = true;
-               next_block = false;
-
-               if (m->basicblocks[b_index].flags < BBREACHED)
-                       next_block = true;
-               if (!next_block && !(m->basicblocks[b_index].icount))
-                       next_block = true;
-
-               if (!next_block) {
-                       ip = m->basicblocks[b_index].iinstr +
-                               m->basicblocks[b_index].icount - 1;
-               
-                       if (ip->opc == ICMD_JSR) /* nested Subroutines */
-                               next_block = true;
-               }
-
-               if (!next_block) {
-                       if (ip->opc == ICMD_RET) {
-                               /* subroutine return found -> add return adresses to CFG */
-                               for (l = ret; l != NULL; l = l->next)
-                                       graph_add_cfg( m, gd, b_index, l->value);
-                       } else { /* follow CFG */
-                               s = graph_get_first_successor(gd, b_index, &i); 
-                               for(; s != -1; s = graph_get_next(&i))
-                                       if (!visited[s])
-                                               graph_add_sub( m, gd, l->value, ret, visited);
-                       }
-               } else { /* fall through to next block */
-                       if (b_index + 1 < m->basicblockcount)
-                               if (!visited[b_index + 1])
-                                       graph_add_sub(m, gd, b_index + 1, ret, visited);
-               }
-       }
-}
 
 /*****************************************************************
 Sort Basic Blocks using Depth First search in reverse post order
@@ -597,19 +481,20 @@ void graph_DFS(lsradata *ls, graphdata *gd) {
 }
 
 
-void graph_init_basicblock( basicblock *bptr, int b_index) {
+void graph_init_basicblock(jitdata *jd, basicblock *bptr, int b_index) {
                bptr->nr = b_index;
                bptr->icount = 0;
                bptr->iinstr = NULL;
                bptr->type = BBTYPE_STD;
                bptr->flags = BBFINISHED;
-               bptr->instack = NULL;
-               bptr->outstack = NULL;
+               bptr->invars = NULL;
+               bptr->outvars = NULL;
                bptr->indepth = 0;
                bptr->outdepth = 0;
                bptr->branchrefs = NULL;
                bptr->mpc = -1;
                bptr->next = NULL;
+               bptr->method = jd->m;
 }
 
 /*********************************************************************+
@@ -622,8 +507,8 @@ TODO: Do not insert blocks right now - just adopt the call graph!
 void transform_CFG(jitdata *jd, graphdata *gd) {
        int i, j, k, n, num_new_blocks;
        int **var_def;
-       basicblock *tmp;
-       stackptr in, out, new_stack;
+       basicblock *tmp, *bptr;
+       s4 *in, *out, *new_in_stack, *new_out_stack;
        graphiterator iter;
        int *num_succ;
        struct graph_element **successor;
@@ -644,8 +529,8 @@ void transform_CFG(jitdata *jd, graphdata *gd) {
        /* multiple predecessor -> if found insert a new block between to split   */
        /* this edge. As first step count how many blocks have to be inserted.    */
 
-       num_new_blocks = 0;
-       for(i = 0; i< m->basicblockcount + 1; i++) {
+       num_new_blocks = 1;
+       for(i = 0; i< jd->basicblockcount + 1; i++) {
                if (graph_has_multiple_successors(gd, i)) {
                        k = graph_get_first_successor(gd, i, &iter);
                        for(; k != -1; k = graph_get_next(&iter)) {
@@ -658,24 +543,33 @@ void transform_CFG(jitdata *jd, graphdata *gd) {
        }
        
        /* increase now basicblockcount accordingly. */
-       ls->basicblockcount = m->basicblockcount + num_new_blocks + 1;
+       ls->basicblockcount = jd->basicblockcount + num_new_blocks;
 
        ls->basicblocks = DMNEW(basicblock *, ls->basicblockcount);
+       for(i = 0; i< ls->basicblockcount; i++)
+               ls->basicblocks[i] = NULL;
+
        /* copy Basic Block References to ls->basicblocks */
-       for(i = 0; i< m->basicblockcount; i++) {
-               ls->basicblocks[i+1] = &(m->basicblocks[i]);
-               ls->basicblocks[i+1]->nr = i+1;
+
+       for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
+/*             if (bptr->flags >= BBREACHED) { */
+                       _GRAPH_ASSERT(bptr->nr < jd->basicblockcount);
+                       ls->basicblocks[bptr->nr + 1] = bptr;
+                       bptr->nr = bptr->nr+1;
+/*             } */
        }
        
-       /* Create new Basic Blocks: 0, [m->basicblockcount..ls->basicblockcount[ */
-       /* num_new_blocks + 1 have to be inserted*/
-       tmp = DMNEW( basicblock, num_new_blocks + 1);
+       /* Create new Basic Blocks:
+          0, [jd->new_basicblockcount..ls->basicblockcount[ */
+       /* num_new_blocks have to be inserted*/
+
+       tmp = DMNEW( basicblock, num_new_blocks);
        ls->basicblocks[0] = tmp;
-       graph_init_basicblock( tmp, 0);
+       graph_init_basicblock( jd, tmp, 0);
        tmp++;
        ls->basicblocks[0]->next = ls->basicblocks[1];
 
-       if (ls->basicblockcount > m->basicblockcount + 1) {
+       if (ls->basicblockcount > jd->basicblockcount + 1) {
                /* new Blocks have to be inserted                   */
                num_succ = DMNEW(int, ls->basicblockcount);
                successor = DMNEW(graph_element *, ls->basicblockcount);
@@ -683,19 +577,19 @@ void transform_CFG(jitdata *jd, graphdata *gd) {
                num_pred = DMNEW(int, ls->basicblockcount);
                predecessor = DMNEW(graph_element *, ls->basicblockcount);
 
-               /* regard the + 1 for the already regarded new BB 0 */
+               /* regard the + 1 for the already inserted new BB 0 */
                /* So recreate ls->var_def                          */
                var_def = DMNEW(int *, ls->basicblockcount);
-               for(i = 0; i < m->basicblockcount + 1; i++) {
+               for(i = 0; i < jd->basicblockcount + 1; i++) {
                        var_def[i] = ls->var_def[i];
                        num_succ[i] = gd->num_succ[i];
                        num_pred[i] = gd->num_pred[i];
                        successor[i] = gd->successor[i];
                        predecessor[i] = gd->predecessor[i];
                }
-               for(i = m->basicblockcount + 1; i < ls->basicblockcount; i++) {
-                       var_def[i] = bv_new(ls->max_vars);
-                       graph_init_basicblock( tmp, i);
+               for(i = jd->basicblockcount + 1; i < ls->basicblockcount; i++) {
+                       var_def[i] = bv_new(jd->varcount);
+                       graph_init_basicblock( jd, tmp, i);
                        ls->basicblocks[i] = tmp;
                        tmp++;
 
@@ -716,8 +610,8 @@ void transform_CFG(jitdata *jd, graphdata *gd) {
        }
 
        /* Now Split the edges */
-       num_new_blocks = m->basicblockcount + 1; /* first free new block index */
-       for(i = 0; i < m->basicblockcount + 1; i++) {
+       num_new_blocks = jd->basicblockcount + 1; /* first free new block index */
+       for(i = 0; i < jd->basicblockcount + 1; i++) {
                if (graph_has_multiple_successors(gd, i)) {/* more than one successor */
                        j = graph_get_first_successor( gd, i, &iter);
                        for(; j != -1; j = graph_get_next(&iter)) {
@@ -734,48 +628,43 @@ void transform_CFG(jitdata *jd, graphdata *gd) {
 
                                        ls->basicblocks[num_new_blocks]->indepth =
                                                ls->basicblocks[i]->outdepth;
-                                       out = ls->basicblocks[i]->outstack;
-                                       ls->basicblocks[num_new_blocks]->instack = in = NULL;
+                                       out = ls->basicblocks[i]->outvars;
+                                       ls->basicblocks[num_new_blocks]->invars = in = NULL;
 
                                        if (ls->basicblocks[num_new_blocks]->indepth > 0) 
-                                               new_stack = DMNEW( stackelement,
+                                               new_in_stack = DMNEW( s4,
+                                                                         ls->basicblocks[num_new_blocks]->indepth);
+                                               new_out_stack = DMNEW( s4,
                                                                          ls->basicblocks[num_new_blocks]->indepth);
+
                                        for(n=0; n<ls->basicblocks[num_new_blocks]->indepth; n++) {
-                                               if (in == NULL) {
-                                                       in = new_stack++;
-                                               } else {
-                                                       in->prev = new_stack++;
-                                                       in = in->prev;
-                                               }
-                                               in->type = out->type;
-                                               in->varkind = STACKVAR;
-                                               in->varnum = 0;
-                                               in->regoff = 0;
-                                               in->flags = 0;
-                                               in->prev = NULL;
-                                               /* Add Definition */
-                                               if (n == 0)
-                                                       ls->basicblocks[num_new_blocks]->instack = in;
-
-                                               out = out->prev;
+                                               new_in_stack[n] = out[n];
+                                               new_out_stack[n] = out[n];
                                        }
+                                       ls->basicblocks[num_new_blocks]->invars = new_in_stack;
 
                                        /* Create Outstack */
-                                       ls->basicblocks[num_new_blocks]->outstack =
-                                               ls->basicblocks[num_new_blocks]->instack;
+                                       ls->basicblocks[num_new_blocks]->outvars =
+                                               new_out_stack;
                                        ls->basicblocks[num_new_blocks]->outdepth = 
                                                ls->basicblocks[num_new_blocks]->indepth;
 
                                        _GRAPH_ASSERT(ls->basicblocks[num_new_blocks]->outdepth == 
-                                                       ls->basicblocks[j]->indepth );
+                                                                 ls->basicblocks[j]->indepth );
+
+#if 0
+                                       /* !!!! There can't be inoutvar definitions in one of these */
+                                       /* newly inserted basicblocks !!!! */
 
                                        /* Add Definition */
                                        /* decrease nr temporarly, because ssa_set_interface*/
                                        /* adds 1 since it is called from stack.c, where there is */
                                        /* no new BB 0 inserted like now */
+
                                        ls->basicblocks[num_new_blocks]->nr--;
-                                       ssa_set_interface(cd, ls, ls->basicblocks[num_new_blocks]);
+                                       ssa_set_interface(jd, ls->basicblocks[num_new_blocks]);
                                        ls->basicblocks[num_new_blocks]->nr++;
+#endif
                                        num_new_blocks++;
                                }
                        }
@@ -784,10 +673,10 @@ void transform_CFG(jitdata *jd, graphdata *gd) {
 }
 
 void transform_BB(jitdata *jd, graphdata *gd) {
-       int i, len;
+       int n, len;
        int pred, succ;
        basicblock *last_block;
-       instruction *ip;
+       instruction *iptr;
        graphiterator iter;
        methodinfo *m;
        lsradata *ls;
@@ -797,130 +686,120 @@ void transform_BB(jitdata *jd, graphdata *gd) {
 
        /* the "real" last Block is always an empty block        */
        /* so take the one before, to insert new blocks after it */
-       last_block = &(m->basicblocks[m->basicblockcount - 1]);
+       last_block = &(jd->basicblocks[jd->basicblockcount - 1]);
        _GRAPH_ASSERT(last_block->next->next == NULL);
        _GRAPH_ASSERT(last_block->next->flags <= BBREACHED);
        last_block->next->nr = ls->basicblockcount;
 
        /* look through new blocks */
-       for(i = m->basicblockcount + 1; i < ls->basicblockcount ; i++) {
+       for(n = jd->basicblockcount + 1; n < ls->basicblockcount ; n++) {
                /* if a phi move happens at this block, we need this block */
                /* if not, remove him from the CFG */
-               if (ls->num_phi_moves[i] > 0) {
+               if (ls->num_phi_moves[n] > 0) {
                        /* i can only have one predecessor and one successor! */
-                       _GRAPH_ASSERT( graph_has_multiple_predecessors(gd,i) == false);
-                       _GRAPH_ASSERT( graph_has_multiple_successors(gd,i) == false);
+                       _GRAPH_ASSERT( graph_has_multiple_predecessors(gd, n) == false);
+                       _GRAPH_ASSERT( graph_has_multiple_successors(gd, n) == false);
                        
-                       succ = graph_get_first_successor(gd, i, &iter);
-                       pred = graph_get_first_predecessor(gd, i, &iter);
+                       succ = graph_get_first_successor(gd, n, &iter);
+                       pred = graph_get_first_predecessor(gd, n, &iter);
 
-                       /* set ip to last instruction                         */
+                       /* set iptr to last instruction                       */
                        len = ls->basicblocks[pred]->icount;
-                       ip = ls->basicblocks[pred]->iinstr + len - 1;
-                       while ((len>0) && (ip->opc == ICMD_NOP)) {
+                       iptr = ls->basicblocks[pred]->iinstr + len - 1;
+                       while ((len>0) && (iptr->opc == ICMD_NOP)) {
                                len--;
-                               ip--;
+                               iptr--;
                        }
 
                                
                        /* with JSR there can not be multiple successors  */
-                       _GRAPH_ASSERT(ip->opc != ICMD_JSR);
+                       _GRAPH_ASSERT(iptr->opc != ICMD_JSR);
                        /* If the return Statment has more successors and  */
                        /* one of these has more predecessor, we are in    */
                        /* troubles - one would have to insert a new Block */
                        /* after the one which executes the ICMD_JSR       */
                        /* !!TODO!! if subroutines will not be inlined     */
-                       _GRAPH_ASSERT(ip->opc != ICMD_RET);
+                       _GRAPH_ASSERT(iptr->opc != ICMD_RET);
 
                        /* link new block into basicblocks list */
                        /* if edge to split is the "fallthrough" path of the */
                        /* conditional, then link the new block inbetween    */
                        /* and generate no ICMD */
                        /* else if edge to split is the branch, generate a   */
-                       /* ICMD_GOTO and add new BB at and of BB List        */
+                       /* ICMD_GOTO and add new BB at the end of the BB List*/
                        if ((ls->basicblocks[pred]->next == ls->basicblocks[succ]) 
-                               && (ip->opc != ICMD_LOOKUPSWITCH)
-                               && (ip->opc != ICMD_TABLESWITCH)
-                               && (ip->opc != ICMD_GOTO)) {
+                               && (iptr->opc != ICMD_LOOKUPSWITCH)
+                               && (iptr->opc != ICMD_TABLESWITCH)
+                               && (iptr->opc != ICMD_GOTO)) {
                                /* GOTO, *SWITCH have no fallthrough path */
 
                                /* link into fallthrough path */
                                
                                                
-                               ls->basicblocks[i]->next =
+                               ls->basicblocks[n]->next =
                                        ls->basicblocks[pred]->next;
                                ls->basicblocks[pred]->next =
-                                       ls->basicblocks[i];
+                                       ls->basicblocks[n];
                                /* generate no instructions */
-                               ls->basicblocks[i]->icount = 1; 
-                               ls->basicblocks[i]->iinstr = NEW(instruction);
-                               ls->basicblocks[i]->iinstr[0].opc =     ICMD_NOP;
+                               ls->basicblocks[n]->icount = 1; 
+                               ls->basicblocks[n]->iinstr = NEW(instruction);
+                               ls->basicblocks[n]->iinstr[0].opc =     ICMD_NOP;
                        } else {
-                               /* Block i is in the Branch path */
+                               /* Block n is in the Branch path */
                                /* link Block at the end */
-                               ls->basicblocks[i]->next =last_block->next;
-                               last_block->next = ls->basicblocks[i];
-                               last_block = ls->basicblocks[i];
+                               ls->basicblocks[n]->next =last_block->next;
+                               last_block->next = ls->basicblocks[n];
+                               last_block = ls->basicblocks[n];
 
                                /* change the Branch Target to BB i */
 
 
        
-                               switch(ip->opc) {
+                               switch(iptr->opc) {
                                case ICMD_LOOKUPSWITCH:
                                        {
-                                               s4 k, l, *s4ptr;
-                                               void **tptr;
-                                                       
-                                               tptr = (void **) ip->target;
-                                               if ((basicblock*)tptr[0] == ls->basicblocks[succ]) {
-                                                       /* target found -> change*/
-                                                       tptr[0] = ls->basicblocks[i];
-                                               }
+                                               s4 i;
+                                               lookup_target_t *lookup;
 
-                                               s4ptr = ip->val.a;
-                                               l = s4ptr[0];                  /* default  */
-                                               k = s4ptr[1];                  /* count    */
-                               
-                                               while (--k >= 0) {
-                                                       s4ptr += 2;
-                                                       ++tptr;
+                                               lookup = iptr->dst.lookup;
 
-                                                       if ((basicblock*)tptr[0] == ls->basicblocks[succ])
-                                                       {
+                                               i = iptr->sx.s23.s2.lookupcount;
+                       
+                                               while (--i >= 0) {
+                                                       if (lookup->target.block == ls->basicblocks[succ])
                                                                /* target found -> change */
-                                                               tptr[0] = ls->basicblocks[i];
-                                                       }
+                                                               lookup->target.block = ls->basicblocks[n];
+                                                       lookup++;
                                                }
+
+                                               if (iptr->sx.s23.s3.lookupdefault.block == ls->basicblocks[succ])
+                                                       /* target found -> change */
+                                                       iptr->sx.s23.s3.lookupdefault.block = ls->basicblocks[n];
                                        }
                                        break;
                                case ICMD_TABLESWITCH:
                                        {
-                                               s4 k, l, *s4ptr;
-                                               void **tptr;
+                                               s4 i, l;
+                                               branch_target_t *table;
 
-                                               tptr = (void **) ip->target;
-                                               
-                                               s4ptr = ip->val.a;
-                                               l = s4ptr[1];              /* low     */
-                                               k = s4ptr[2];              /* high    */
+                                               table = iptr->dst.table;
+
+                                               l = iptr->sx.s23.s2.tablelow;
+                                               i = iptr->sx.s23.s3.tablehigh;
 
-                                               k = k - l + 1;
+                                               i = i - l + 1;
 
-                                               if ((basicblock*)tptr[0] == ls->basicblocks[succ])
-                                               {
+                                               if (table[0].block ==  ls->basicblocks[succ]) /* default target */
                                                        /* target found -> change*/
-                                                       tptr[0] = ls->basicblocks[i];
-                                               }
-                                               tptr += k;
-                                                       
-                                               while (--k >= 0) {
-                                                       if ((basicblock*)tptr[0] == ls->basicblocks[succ])
-                                                       {
-                                                               /* target found -> change*/
-                                                               tptr[0] = ls->basicblocks[i];
-                                                       }
-                                                       --tptr;
+                                                       table[0].block = ls->basicblocks[n];
+
+                                               table += i;
+
+                                               while (--i >= 0) {
+                                                       if (table->block == ls->basicblocks[succ])
+                                                               /* target found -> change */
+                                                               table->block = ls->basicblocks[n];
+                                                       --table;
                                                }
                                        }
                                        break;
@@ -953,8 +832,8 @@ void transform_BB(jitdata *jd, graphdata *gd) {
                                case ICMD_IF_ACMPEQ:
                                case ICMD_IF_ACMPNE:                
                                case ICMD_GOTO:
-                                       _GRAPH_ASSERT(ip->target == ls->basicblocks[succ]);
-                                       ip->target = ls->basicblocks[i];
+                                       _GRAPH_ASSERT(iptr->dst.block == ls->basicblocks[succ]);
+                                       iptr->dst.block = ls->basicblocks[n];
                                        break;
                                default:
                                        /* Exception Edge to split */
@@ -963,17 +842,14 @@ void transform_BB(jitdata *jd, graphdata *gd) {
                                }
 
                                /* Generate the ICMD_GOTO */
-                               ls->basicblocks[i]->icount = 1; 
-                               ls->basicblocks[i]->iinstr =
+                               ls->basicblocks[n]->icount = 1; 
+                               ls->basicblocks[n]->iinstr =
                                        DNEW(instruction);
-                               ls->basicblocks[i]->iinstr->opc =
+                               ls->basicblocks[n]->iinstr->opc =
                                        ICMD_GOTO;
-                               ls->basicblocks[i]->iinstr->target =
+                               ls->basicblocks[n]->iinstr->dst.block =
                                        ls->basicblocks[succ];
-                               ls->basicblocks[i]->iinstr->op1 = succ;
                        }
-                       ls->basicblocks[i]->iinstr[0].dst = 
-                               ls->basicblocks[i]->outstack;
                }
        }
 }
index ca62a998a18fb6bbf8c0eaf7b0950811e0e21295..a887b472336d6d5f5f2d545192861c4647e5b233 100644 (file)
 # define _GRAPH_ASSERT(a)
 #endif
 
+#if 0
 struct _sbr {
        int header;          /* BB Index of subroutine start (SBR_HEADER) */
        struct graph_element *ret;   /* List of possible return BB indizes */
        struct _sbr *next;
 };
+#endif
 
 struct graph_element {
   int value;
index 3e15dd23185e2c3484939e96217d4310a599451c..f2ac6d7038fc5c0e2c60fe1a25f31a72686c4a7c 100644 (file)
 #include "vm/jit/optimizing/lifetimes.h"
 
 #ifdef LT_DEBUG_VERBOSE
-#include "vm/options.h"
+#include "vmcore/options.h"
 #endif
 
 #include <time.h>
 #include <errno.h>
 
 /* function prototypes */
-void _scan_lifetimes(registerdata *rd, lsradata *ls, graphdata *gd,
-                                       basicblock *bptr);
-void _lsra_new_stack( lsradata *, stackptr , int , int, int);
-void _lsra_from_stack(lsradata *, stackptr , int , int, int);
-void lsra_usage_local(lsradata *, s4 , int , int , int , int );
+void _lt_scanlifetimes(jitdata *jd, graphdata *gd, basicblock *bptr, int);
+void lt_usage(jitdata *, s4 , int , int , int );
 
 
-void LifeOutAtBlock(lsradata *ls, graphdata *gd, int *M, int n,
-                                       struct lifetime *lt);
-void LifeInAtStatement(lsradata *ls, graphdata *gd, int *M, int b_index, 
+void lt_lifeoutatblock(lsradata *ls, graphdata *gd, int *M, int b_index,
+                                          struct lifetime *lt, worklist *W);
+void lt_lifeatstatement(lsradata *ls, graphdata *gd, int b_index, 
+                                               int iindex, struct lifetime *lt, bool life_in,
+                                               worklist *W);
+#if 0
+void lt_lifeinatstatement(lsradata *ls, graphdata *gd, int *M, int b_index, 
                                           int iindex, struct lifetime *lt);
-void LifeOutAtStatement(lsradata *ls, graphdata *gd, int *M, int b_index, 
+void lt_lifeoutatstatement(lsradata *ls, graphdata *gd, int *M, int b_index, 
                                                int iindex, struct lifetime *lt);
+#endif
 #ifdef USAGE_COUNT
 void lt_get_nesting(lsradata *ls, graphdata *gd, dominatordata *dd);
 #endif
 
-void set_use_site(struct lifetime *lt, struct site *use_site) {
+void lt_set_use_site(struct lifetime *lt, struct site *use_site) {
 }
 
-struct site *get_first_use_site(struct lifetime *lt, lt_iterator *iter) {
+struct site *lt_get_first_use_site(struct lifetime *lt, lt_iterator *iter) {
        return ((*iter) = lt->use);
 }
 
-struct site *get_next_site(lt_iterator *iter) {
+struct site *lt_get_next_site(lt_iterator *iter) {
        if ((*iter) == NULL)
                return NULL;
        else
                return ((*iter) = (*iter)->next);
 }
 
-struct site *get_first_def_site(struct lifetime *lt, lt_iterator *iter) {
+struct site *lt_get_first_def_site(struct lifetime *lt, lt_iterator *iter) {
        return ((*iter) = lt->def);
 }
 
-bool v_is_defined_at_s(lsradata *ls, int b_index, int iindex, 
+bool lt_v_is_defined_at_s(lsradata *ls, int b_index, int iindex, 
                                           struct lifetime * lt) {
        struct site *def_site;
        bool is_defined_at_s;
@@ -107,11 +109,16 @@ bool v_is_defined_at_s(lsradata *ls, int b_index, int iindex,
 /****************************************************************************
 Get Def & Use Sites
 ****************************************************************************/
-void scan_lifetimes(methodinfo *m, codegendata *cd, registerdata *rd,
-                                       lsradata *ls, graphdata *gd, dominatordata *dd) {
-       int i, p;
+void lt_scanlifetimes(jitdata *jd, graphdata *gd, dominatordata *dd) {
+       int i, l, p;
        s4 t;
-       methoddesc *md = m->parseddesc;
+       methodinfo *m;
+       lsradata *ls;
+       methoddesc *md;
+
+       ls = jd->ls;
+       m  = jd->m;
+       md = m->parseddesc;
 
        graph_DFS(ls, gd);
 
@@ -122,7 +129,12 @@ void scan_lifetimes(methodinfo *m, codegendata *cd, registerdata *rd,
 #if defined(LT_DEBUG_VERBOSE)
        if (compileverbose) {
                printf("Sorted: ");
-               for (i=0; i < ls->basicblockcount; i++) printf("%3i ", ls->sorted[i]);
+               for (i=0; i < ls->basicblockcount; i++) {
+                       l = ls->sorted[i];
+                       if (l != -1)
+                               l = ls->basicblocks[l]->nr;
+                       printf("%3i(%3i) ", ls->sorted[i], l);
+               }
                printf("\n");
                printf("Sorted_rev: ");
                for (i=0; i < ls->basicblockcount; i++) 
@@ -130,64 +142,53 @@ void scan_lifetimes(methodinfo *m, codegendata *cd, registerdata *rd,
                printf("\n");
        }
 #endif
-       if (ls->max_interfaces != -1) {
-               /* init Interface Stackslot lifetimes -1.. */
-               for (i = -1; i > -ls->interface_0[-ls->max_interfaces-1]-1; i--) {
-                       ls->lifetime[-i-1].v_index = i;
-                       ls->lifetime[-i-1].usagecount = 0;
-                       ls->lifetime[-i-1].bb_last_use = -1;
-                       ls->lifetime[-i-1].bb_first_def = -1;
-                       ls->lifetime[-i-1].local_ss = NULL;
-                       ls->lifetime[-i-1].savedvar = 0;
-                       ls->lifetime[-i-1].flags = 0;
-                       /* .type already set while ssa_Rename_, so we could save a */
-                       /* lookup table for the type information */
-               }
-               ls->v_index = -ls->interface_0[-ls->max_interfaces-1]-1;
-       }
 
        for(i = ls->basicblockcount - 1; i>= 0; i--)
                if (ls->sorted[i] != -1)
-                       _scan_lifetimes(rd, ls, gd, ls->basicblocks[ls->sorted[i]]);
+                       _lt_scanlifetimes(jd, gd, ls->basicblocks[ls->sorted[i]],
+                                                         ls->sorted[i]);
 
        /* Parameter initialisiation for locals [0 .. paramcount[            */
        /* -> add local var write access at (bb=0,iindex=0)                 */
 
-       for (p = 0; p < md->paramcount; p++) {
+       for (p = 0, l = 0; p < md->paramcount; p++) {
                t = md->paramtypes[p].type;
-               i = ls->local_0[p];
-               _LT_ASSERT( i < jd->maxlocals);
+               i = jd->local_map[l * 5 + t];
+               l++;
+               if (IS_2_WORD_TYPE(t))    /* increment local counter for 2 word types */
+                       l++;
+               if (i == UNUSED)
+                       continue;
+               i = ls->var_0[i];
+/*             _LT_ASSERT( i < jd->cd->maxlocals); */
 #ifdef LT_DEBUG_VERBOSE
                if (compileverbose)
                        printf("param %3i -> L %3i/%3i",p,i,t);
 #endif
-               if (rd->locals[i][t].type >= 0) {
-                       /* Param to Local init happens before normal Code */
-#ifdef LT_DEBUG_VERBOSE
-                       if (compileverbose)
-                               printf(" ok\n");
-#endif
-                       lsra_usage_local(ls, i, t, 0, 0, LSRA_STORE); 
-               }
+               _LT_ASSERT(t == VAR(i)->type);
+               
+               /* Param to Local init happens before normal Code */
+
 #ifdef LT_DEBUG_VERBOSE
-               else
-                       if (compileverbose)
-                               printf(" .....\n");
+               if (compileverbose)
+                       printf(" ok\n");
 #endif
+               lt_usage(jd, i, 0, 0, LT_DEF); 
        }  /* end for */
 }
 
 
-bool is_simple_lt(struct lifetime *lt) {
+bool lt_is_simple_lt(struct lifetime *lt) {
        lt_iterator i_def, i_use;
        struct site *def, *use;
        bool all_in_same_block;
 
        
-       def = get_first_def_site(lt, &i_def);
-       use = get_first_use_site(lt, &i_use);
+       def = lt_get_first_def_site(lt, &i_def);
+       use = lt_get_first_use_site(lt, &i_use);
        all_in_same_block = true;
-       for (; (all_in_same_block && (use != NULL)); use = get_next_site(&i_use)) {
+       for (; (all_in_same_block && (use != NULL));
+                use = lt_get_next_site(&i_use)) {
                all_in_same_block = 
                        (use->iindex >= 0) && (use->b_index == def->b_index);
        }
@@ -224,262 +225,38 @@ void lt_set_simple_use(lsradata *ls, struct lifetime *lt) {
        lt_is_live(ls, lt, lt->def->b_index, lt->def->iindex);
 
        /* get last use */
-       use = get_first_use_site(lt, &i_use);
+       use = lt_get_first_use_site(lt, &i_use);
 /*     lt->bb_last_use = ls->sorted_rev[use->b_index]; */
 /*     lt->i_last_use = use->iindex; */
-       for (;  (use != NULL); use = get_next_site(&i_use))
+       for (;  (use != NULL); use = lt_get_next_site(&i_use))
                lt_is_live(ls, lt, use->b_index, use->iindex);
 /*             if (use->iindex > lt->i_last_use) */
 /*                     lt->i_last_use = use->iindex; */
 }
 
-#if defined(JOIN_PHI_LT)
-/******************************************************************************
-Set up data structures for a interference graphs of variables used in each phi
-function
-******************************************************************************/
-void lt_setup_phi_interference(lsradata *ls, graphdata *gd) {
-       int a, b, i, j, t;
-       int *stack, stack_top;
-       struct igraph_lookup **lookup;
-       struct igraph_lookup *tmp;
-       int lookup_top, igraph_top;
-       struct igraph_vars *new_var;
-
-       lookup_top = igraph_top = 0;
-       lookup = DMNEW(struct igraph_lookup *, ls->max_vars_with_indices*2);
-       stack  = DMNEW(int, ls->max_vars_with_indices);
-       for(b = 0; b < ls->basicblockcount; b++) {
-               for(a = 0; a < ls->max_vars; a++) {
-                       if (ls->phi[b][a] != NULL) {
-                               
-#if defined(LT_DEBUG_VERBOSE)
-                               if (compileverbose) {
-                                       printf("Phi(%3i, %3i): ", a, gd->num_pred[b]);
-                               }
-#endif
-                               stack_top = 0;
-                               /* loop for all vars in this phi function -> setup a interf graph */
-                               /* structure for it */
-                               for(j = 0; j < gd->num_pred[b] + 1; j++) {
-                                       if (ls->phi[b][a][j] != ls->max_vars_with_indices) {
-                                               /* used entry */
-                                               stack[stack_top++] = ls->phi[b][a][j];
-#if defined(LT_DEBUG_VERBOSE)
-                                               if (compileverbose) {
-                                                       printf("%3i ",ls->phi[b][a][j]);
-                                               }
-#endif
-                                       }
-                               }
-                               _LT_ASSERT(stack_top <= ls->max_vars_with_indices);
-#if defined(LT_DEBUG_VERBOSE)
-                               if (compileverbose) {
-                                       printf("\n ");
-                               }
-#endif
-                               /* sort (insertion)*/
-                               /* TODO: make unique sort proc (see lsra_insertion...) */
-                               for (i = 1; i <= stack_top - 1; i++) {
-                                       j = i;
-                                       t = stack[j];
-                                       while ((j > 0) && (stack[j-1] > t)) {
-                                               stack[j] = stack[j-1];
-                                               j--;
-                                       }
-                                       stack[j] = t;
-                               }
-#if defined(LT_DEBUG_VERBOSE)
-                               if (compileverbose) {
-                                       printf("Sorted: ");
-                                       for(i=0; i < stack_top; i++)
-                                               printf("%3i ",stack[i]);
-                                       printf("\n");
-                               }
-#endif
-                               /* now remove duplicates */
-                               /* t ... new stack_top */
-                               /* i ... first of duplicate sequence */
-                               /* j ... next duplicate sequence */
-                               i = t = 0;
-                               while (i < stack_top) {
-                                       stack[t] = stack[i];
-                                       t++;
-                                       for(j = i + 1; (j < stack_top)&&(stack[i]==stack[j]); j++);
-                                       if (j == stack_top) {
-                                               /* last duplicate entries */
-                                               stack_top = t;
-                                               break;
-                                       }
-                                       i = j;
-                               }
-                               _LT_ASSERT(stack_top <= ls->max_vars_with_indices);
-#if defined(LSRA_DEBUG_VERBOSE)
-                               if (compileverbose) {
-                                       printf("wo duplicates: ");
-                                       for(i=0; i < stack_top; i++)
-                                               printf("%3i ",stack[i]);
-                                       printf("\n");
-                               }
-#endif
-                               /* setup lookuptable for vars stack[0..stack_top[ to        */
-                               /* interference graph number & interference graph structure */
-                               for(i = 0; i < stack_top; i++) {
-                                       _LT_ASSERT(lookup_top < ls->max_vars_with_indices*2);
-                                       lookup[lookup_top] = DNEW(struct igraph_lookup);
-                                       lookup[lookup_top]->var = stack[i]; /* var index */
-                                       lookup[lookup_top]->igraph = igraph_top; /* igraph index */
-                                       lookup_top++;
-                               }
-                               igraph_top++;
-                       }
-               }
-       }
-       ls->igraph = DMNEW(struct igraph , igraph_top);
-       ls->igraph_top = igraph_top;
-       for(i = 0; i < igraph_top; i++) {
-               ls->igraph[i].inter = NULL;
-               ls->igraph[i].vars = NULL;
-       }
-       
-       /* sort lookup */
-
-       for (i = 1; i < lookup_top; i++) {
-               j = i;
-               t = lookup[j]->var;
-               tmp = lookup[j];
-               while ((j > 0) && (lookup[j-1]->var > t)) {
-                       lookup[j]=lookup[j-1];
-                       j--;
-               }
-               lookup[j] = tmp;
-       }
-
-       /* join igraphs for multiple vars  */
-       /* TODO: make this more efficient! */
-       for (i = 1; i < lookup_top; i++) {
-               if (lookup[i-1]->var == lookup[i]->var) {
-                       for(j = 0; j < lookup_top; j++)
-                               if (j != i)
-                                       if (lookup[j]->igraph == lookup[i]->igraph)
-                                               lookup[j]->igraph = lookup[i-1]->igraph;
-                       lookup[i]->igraph = lookup[i-1]->igraph;
-               }
-       }
-
-       ls->igraph_lookup_top = lookup_top;
-       ls->igraph_lookup = DMNEW(struct igraph_lookup *, lookup_top);
-       for(i = 0; i < lookup_top; i++) {
-               ls->igraph_lookup[i] = lookup[i];
-               new_var = DNEW(struct igraph_vars);
-               new_var->v = lookup[i]->var;
-               new_var->next = ls->igraph[lookup[i]->igraph].vars;
-               ls->igraph[lookup[i]->igraph].vars = new_var;
-       }
-#if defined(LT_DEBUG_VERBOSE)
-                               if (compileverbose) {
-                                       printf("IGraph(%3i): ",igraph_top);
-                                       for(i = 0; i < igraph_top; i++) {
-                                               printf("%3i(",i);
-                                               for(new_var = ls->igraph[i].vars; new_var != NULL; new_var = new_var->next)
-                                                       printf("%3i,",new_var->v);
-                                               printf(") ");
-                                       }
-                                       printf("\n");
-                                       for(i=0; i < lookup_top; i++)
-                                               printf("(%3i->%3i) ",ls->igraph_lookup[i]->var, ls->igraph_lookup[i]->igraph);
-                                       printf("\n");
-                               }
-#endif
-}
-
-int get_igraph_index(lsradata *ls, int var) {
-       int i, i_max, i_min;
-
-       if (ls->igraph_lookup == NULL)
-               return -1;
-
-       i_min = 0;
-       i_max = ls->igraph_lookup_top;
-
-       while (true) {
-               i = (i_min + i_max)/2;
-               if (ls->igraph_lookup[i]->var == var)
-                       return ls->igraph_lookup[i]->igraph;
-               if ((i_max - i_min <= 1))
-                       return -1;
-               if (var < ls->igraph_lookup[i]->var) {
-                       i_max = i;
-               } else {
-                       i_min = i;
-               }
-       }
-       /* prevent compiler warning */
-       return -1;
-}
-
-void build_interference(lsradata *ls, int b_index, int iindex,
-                                        struct lifetime *lt) {
-       int igraph_index;
-       struct igraph_vars *v;
-       struct igraph_interference *i;
-       struct lifetime *lt_i;
-       
-       if ((igraph_index = get_igraph_index(ls, lt->v_index)) == -1)
-               return;
-
-       _LT_ASSERT(ls->igraph[igraph_index].vars != NULL);
-
-       for(v = ls->igraph[igraph_index].vars; v != NULL; v = v->next) {
-               /* ignore interference with var itself */
-               if (v->v != lt->v_index) {
-                       /* get lifetime of v->v */
-                       if (v->v >= 0) {
-                               lt_i = &(ls->lifetime[ls->maxlifetimes + v->v]);
-                       } else {
-                               lt_i = &(ls->lifetime[-v->v - 1]);
-                       }
-                       _LT_ASSERT(lt_i->v_index == v->v);
-
-                       if (v_is_defined_at_s(ls, b_index, iindex, lt_i)) {
-                               /* search if entry already exists */
-                               for(i = ls->igraph[igraph_index].inter; i != NULL; i = i->next)
-                               {
-                                       if ((i->v1 == min(v->v, lt->v_index)) &&
-                                               (i->v2 == max(v->v, lt->v_index)))
-                                               break;
-                               }
-                               if (i == NULL) {
-                                       i = DNEW(struct igraph_interference);
-                                       i->v1 = min(v->v, lt->v_index);
-                                       i->v2 = max(v->v, lt->v_index);
-                                       i->next = ls->igraph[igraph_index].inter;
-                                       ls->igraph[igraph_index].inter = i;
-                               }
-                       }
-               }
-       }
-       
-}
-#endif
-
-void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd) {
-       int *M; /* bit_vecor of visited blocks */
-       int *use; /* bit_vecor of blocks with use sites visited */
+void lt_lifeness_analysis(jitdata *jd, graphdata *gd) {
+       int *M;      /* bit_vecor of visited blocks */
+       int *use;    /* bit_vecor of blocks with use sites visited */
+       worklist *W; /* Worklist of Basic Blocks, where lt is life-out */
        
        struct site *use_site, *u_site;
        lt_iterator iter, iter1;
        graphiterator pred_iter;
 
-       int lt_index, i, pred, iindex, iindex1;
+       int lt_index, i, pred, iindex, iindex1, b_index;
        struct lifetime *lt;
        int *phi;
+/* #define MEASURE_RT */
+#ifdef MEASURE_RT
        struct timespec time_start,time_end;
-#if 0
-       bool measure = false;
 #endif
 
-/* #define MEASURE_RT */
+       lsradata *ls;
+       methodinfo *m;
+
+       ls = jd->ls;
+       m  = jd->m;
+
 
 #ifdef MEASURE_RT
        if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,&(time_start)) != 0) {
@@ -487,19 +264,10 @@ void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd) {
                abort();
        }
 #endif
-#if 0
-       if ((strcmp(m->class->name->text, "java/lang/Object")==0) &&
-               (strcmp(m->name->text,"equals")==0)) {
-               printf("----------------\n");
-/*             measure = false; */
-       }
-#endif
-#if defined(JOIN_PHI_LT)
-       lt_setup_phi_interference(ls, gd);
-#endif
 
-       M = bv_new(ls->basicblockcount);
+       M   = bv_new(ls->basicblockcount);
        use = bv_new(ls->basicblockcount);
+       W   = wl_new(ls->basicblockcount);
 
 #ifdef LT_DEBUG_VERBOSE
        if (compileverbose)
@@ -514,45 +282,57 @@ void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd) {
                printf("LT: %3i:", lt_index);
 #endif
 
-#if 0
-               if (measure)
-                       if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,&(time_start)) != 0) {
-                               fprintf(stderr,"could not get time: %s\n",strerror(errno));
-                               abort();
-                       }
-#endif
-                       
                lt->savedvar = 0;
 
                _LT_ASSERT(lt->def != NULL);
                _LT_ASSERT(lt->def->next == NULL); /* SSA! */
-               _LT_ASSERT(lt->use != NULL);
+/*             _LT_ASSERT(lt->use != NULL); */
 
                lt->bb_last_use = -1;
                lt->bb_first_def = ls->basicblockcount;
                
                bv_reset(M, ls->basicblockcount);
                bv_reset(use, ls->basicblockcount);
+               wl_reset(W, ls->basicblockcount);
 
-               use_site = get_first_use_site(lt, &iter);
-               for (;use_site != NULL; use_site = get_next_site(&iter)) {
+               use_site = lt_get_first_use_site(lt, &iter);
+
+               /* Make unused Vars life at their Def Site */
+
+               if (use_site == NULL) {
+                       lt_is_live(ls, lt, lt->def->b_index, lt->def->iindex);
+                       if (lt->def->iindex < 0) {
+
+                               /* def only in phi function */
+
+                               lt_is_live(ls, lt, lt->def->b_index, 0);
+                       }
+               }
+               for (;use_site != NULL; use_site = lt_get_next_site(&iter)) {
                        iindex  = use_site->iindex;
                        if ((lt->def->b_index == use_site->b_index) &&
                                (iindex < 0) &&
                                (iindex <= lt->def->iindex)) {
-                               if (iindex == lt->def->iindex) /* check this */
-                                       continue;
+
+/*                             bv_set_bit(use, use_site->b_index); */
                                /* do normal analysis */
                                /* there is a use in a phi function before def site */
-                       } else if (bv_get_bit(use, use_site->b_index)) {
+
+                       }
+                       else if (bv_get_bit(use, use_site->b_index)) {
                                continue;
-                       } else {
+                       }
+                       else {
                                bv_set_bit(use, use_site->b_index);
+
                                /* use sites of this basic block not visited till now */
-                               /* get use site of this bb with highest iindex (lower than def site)*/
+                               /* get use site of this bb with highest iindex lower than */
+                               /* def site */
+
                                iindex1 = -1;
                                u_site = use_site;
-                               for(iter1= iter; u_site != NULL; u_site = get_next_site(&iter1)) {
+                               for(iter1= iter; u_site != NULL;
+                                       u_site = lt_get_next_site(&iter1)) {
                                        if ((u_site->b_index == use_site->b_index) &&
                                                (lt->def->b_index == use_site->b_index) &&
                                                (u_site->iindex >= 0) &&
@@ -568,12 +348,14 @@ void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd) {
                                if (iindex1 != -1)
                                        iindex = iindex1;
                        }
+
 #ifdef LT_DEBUG_VERBOSE
        if (compileverbose)
                        printf("(%3i,%3i)", use_site->b_index, iindex);
 #endif
 
                        if (iindex < 0) {
+
                                /* use in phi function */
                                /* ls->phi[use_site->b_index][-use_site->iindex-1]*/
 
@@ -581,50 +363,38 @@ void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd) {
 
                                phi = ls->phi[use_site->b_index][-iindex-1];
                                _LT_ASSERT(phi != NULL);
-
-                               if (lt->v_index != phi[0]) { /* check this */
-                                       /* ignore "Self use/def" in phi function */
-                                       
                                
                                        pred = graph_get_first_predecessor(gd, use_site->b_index,
                                                                                                           &pred_iter);
                                        for(i = 1; (pred != -1); i++,pred = 
                                                        graph_get_next(&pred_iter))
-                                               if (lt->v_index == phi[i]) 
-                                                       LifeOutAtBlock(ls, gd, M, pred, lt);
-                               }
-                       } else
-                               LifeInAtStatement(ls, gd, M, use_site->b_index, 
-                                                                 iindex, lt);
+                                               if (lt->v_index == phi[i]) {
+
+                                                       /* Add "Life out Basic Blocks to Worklist */
+
+                                                       wl_add(W, pred);
+                                               }
+                       } 
+                       else /* lt is live-in at this statement */
+                               lt_lifeatstatement(ls, gd, use_site->b_index, 
+                                                                  iindex, lt, true, W);
+               } /* for (;use_site != NULL; use_site = lt_get_next_site(&iter)) */
+
+               /* process Worklist */
+          
+               while (!wl_is_empty(W)) {
+                       b_index = wl_get(W);
+                       lt_lifeoutatblock(ls, gd, M, b_index, lt, W);
                }
+                       
+
 #ifdef LT_DEBUG_VERBOSE
-       if (compileverbose)
+               if (compileverbose)
                        printf("\n");
 #endif
 
-#if 0
-               if (measure) {
-                       if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,&(time_end)) != 0) {
-                               fprintf(stderr,"could not get time: %s\n",strerror(errno));
-                               abort();
-                       }
-
-                       {
-                               long diff;
-                               time_t atime;
+       } /* for(lt_index = 0; lt_index < ls->lifetimecount; lt_index++) */
 
-                               diff = (time_end.tv_nsec - time_start.tv_nsec) / 1000;
-                               atime = time_start.tv_sec;
-                               while (atime < time_end.tv_sec) {
-                                       atime++;
-                                       diff += 1000000;
-                               }
-                               printf("%8li %3i %s.%s.%s\n",diff, lt_index, m->class->name->text, m->name->text,
-                                          m->descriptor->text);
-                       }
-               }
-#endif
-       }
 #ifdef MEASURE_RT
        if (clock_gettime(CLOCK_THREAD_CPUTIME_ID,&(time_end)) != 0) {
                fprintf(stderr,"could not get time: %s\n",strerror(errno));
@@ -645,423 +415,167 @@ void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd) {
                           m->descriptor->text);
        }
 #endif
+}
 
-#if defined(JOIN_PHI_LT)
-#if defined(LT_DEBUG_VERBOSE)
-       if (compileverbose) {
-               struct igraph_interference *inter;
-               printf("Interferences: ");
-               for(i = 0; i < ls->igraph_top; i++) {
-                       if (ls->igraph[i].inter != NULL) {
-                               for(inter = ls->igraph[i].inter; inter != NULL; inter = inter->next)
-                                       printf("%3i(%3i,%3i) ",i,inter->v1,inter->v2);
-                       }
-               }
-               printf("\n");
-       }
-#endif
+/*******************************************************************************
+lt_lifeatstatement
 
-       {
-       struct igraph_vars *var, *var1;
-       struct igraph_interference *inter;
-       struct lifetime *lt1, *lt2;
-       struct stackslot *ss;
-       struct site *s;
-       int j, k, l;
-       instruction *iptr;
+
+IN:     lsradata *ls    pointer to worklist created with wl_new
+        graphdata *gd
+        int b_index     Basic block index of instruction
+        int iindex      index of instruction in Basic Block
+        struct lifetime *lt  Pointer to lifetime structure
+        bool life_in    TRUE  lifetime lt is life 'into' that instruction
+                        FALSE lifetime lt is life 'out' of that instruction
+
+IN/OUT: worklist *W     Worklist of Basic Blocks, where lt is life-out
+*******************************************************************************/
+void lt_lifeatstatement(lsradata *ls, graphdata *gd, int b_index, 
+                                               int iindex, struct lifetime *lt, bool life_in,
+                                               worklist *W) {
+
+       int prev_iindex; /* Statement before iindex */
        int pred;
-       graphiterator iter;
+       graphiterator pred_iter;
+       instruction *iptr;
 
-       /* join phi arguments that do not interfere */
-       printf("this should not be seen \n");
-       for(i = 0; i < ls->igraph_top; i++) {
-               if (ls->igraph[i].inter == NULL) {
-                       lt1 = lt2 = NULL;
-                       for(var = ls->igraph[i].vars; var != NULL; var = var->next) {
-                               if (lt1 == NULL) {
-                                       if (var->v >= 0) {
-                                               lt1 = &(ls->lifetime[ls->maxlifetimes + var->v]);
-                                       } else {
-                                               lt1 = &(ls->lifetime[-var->v - 1]);
-                                       }
-                                       _LT_ASSERT(lt1->v_index == var->v);
-                                       continue;
-                               } else {
-                                       if (var->v >= 0) {
-                                               lt2 = &(ls->lifetime[ls->maxlifetimes + var->v]);
-                                       } else {
-                                               lt2 = &(ls->lifetime[-var->v - 1]);
-                                       }
-                                       _LT_ASSERT(lt2->v_index == var->v);
-                               }
+       while (true) {
+               if (!life_in) {
+#ifdef LT_DEBUG_VERBOSE
+                       if ((compileverbose) && (iindex >= 0))
+                               printf("LO@ST: vi %3i bi %3i ii %3i\n",
+                                          lt->v_index, b_index, iindex);
+#endif
 
-                               if ((lt1->v_index < 0) && (lt2->v_index >=0)) {
-                                       /* swap lt1 and lt2 - cannot join Stackslotlifetime */
-                                       /* into Localvar lifetimes */
+                       /* lt->v_index is life-out at statement at (b_index,iindex) */
 
-                                       lt = lt1;
-                                       lt1 = lt2;
-                                       lt2 = lt;
-                               }
+                       /* Once a interference graph is needed, add here an edge (v,w) */
+                       /* to the ig, for each variable w defined at this instruction  */
+                       /* except v=lt->v_index */
 
-                               if ((lt1->v_index >=0) && (lt2->v_index >=0)) {
-                                       for(s = lt2->def; s != NULL; s = s->next) {
-                                               if ((s->b_index == 0) && (s->iindex ==0)) {
-                                                       /* swap lt1 and lt2 - lt2 is initialized by a param*/
+                       if (!lt_v_is_defined_at_s(ls, b_index, iindex, lt)) {
 
-                                                       _LT_ASSERT((lt1->def->b_index != 0)
-                                                                          || (lt1->def->iindex !=0));
-                                                       lt = lt1;
-                                                       lt1 = lt2;
-                                                       lt2 = lt;
-                                                       break;
-                                               }
-                                       }
-                               }
+                               /* v is life in at out of statement -> check if the SAVEDVAR */
+                               /* flag is needed to be set */
 
-                               /* already joined */
-                               if ((lt2->type == -1) || (lt1 == lt2))
-                                       continue;
-#if defined(LT_DEBUG_VERBOSE)
-                               if (compileverbose) {
-                                       printf("Joining %3i into %3i\n",lt2->v_index, lt1->v_index);
-                               }
-#endif
+                               if ((iindex >= 0) && (b_index != 0)) {
 
-                               /* copy local_ss from lt2 to lt1 & rename local_ss->s->varnum */
-                               while (lt2->local_ss != NULL) {
-                                       if (lt1->v_index >= 0) {
-                                               lt2->local_ss->s->varkind = LOCALVAR;
-                                       }
-                                       /* other direction not possible! (LOCALVAR->TEMPVAR) */
-                                       /* see 'if' above */
-                                       lt2->local_ss->s->varnum  = lt1->v_index;
-
-                                       ss = lt1->local_ss;
-                                       lt1->local_ss = lt2->local_ss;
-                                       lt2->local_ss = lt2->local_ss->next;
-                                       lt1->local_ss->next = ss;
-                               }
+                                       /* real ICMD, no phi-function, no param initialisation */
 
-                               /* look at the use sites */
-                               for(s = lt2->use; s != NULL; s = s->next) {
-                                       if (s->iindex < 0) {
-                                               /* use in phi function -> change */
-                                               pred=graph_get_first_predecessor(gd, s->b_index, &iter);
-                                               for (j = 1; pred != -1; j++,
-                                                                pred = graph_get_next(&iter)) {
-                                                       if (ls->phi[s->b_index][-s->iindex-1][j] ==
-                                                               lt2->v_index) { 
-                                                               ls->phi[s->b_index][-s->iindex-1][j]
-                                                                       = lt1->v_index;
-                                                               /* change in appropriate phi_move, too */
-                                                               for(k=0; k<ls->num_phi_moves[pred]; k++) {
-                                                                       if (ls->phi_moves[pred][k][1] ==
-                                                                               lt2->v_index) {
-                                                                               ls->phi_moves[pred][k][1]=lt1->v_index;
-                                                                       }
-/*                                                                     if (ls->phi_moves[pred][k][0] == */
-/*                                                                             lt2->v_index) { */
-/*                                                                             ls->phi_moves[pred][k][0]=lt1->v_index; */
-/*                                                                     } */
-                                                               }
-                                                       }
-                                               }
-                                               /* change in appropriate phi_move, too */
-                                       } else {
-                                               if (lt2->v_index >= 0) {
-                                                       /* lt1&&lt2 are LOCALVAR, XSTORE,IINC and XLOAD */
-                                                       /* have to be changed */
-                                                       iptr = ls->basicblocks[s->b_index]->iinstr +
-                                                               s->iindex;
-                                                       if (iptr != NULL) {
-                                                               /* no edge splitting block from SSA */
-                                                               switch(iptr->opc) {
-                                                               case ICMD_ILOAD:
-                                                               case ICMD_LLOAD:
-                                                               case ICMD_FLOAD:
-                                                               case ICMD_DLOAD:
-                                                               case ICMD_ALOAD:/* iptr->op1 == USE */
-                                                               case ICMD_ISTORE:
-                                                               case ICMD_LSTORE:
-                                                               case ICMD_FSTORE:
-                                                               case ICMD_DSTORE:
-                                                               case ICMD_ASTORE:
-                                                               case ICMD_IINC: /* iptr->op1 == USE */
-                                                                       if (iptr->op1 == lt2->v_index)
-                                                                               iptr->op1 = lt1->v_index;
-                                                                       break;
-                                                                       /*                                                      default: */
-                                                                       /* could be in another than the top stackslot */
-                                                                       /* too! */
-                                                                       /*                                                              _LT_ASSERT((iptr-1)->dst->varnum == */
-                                                                       /*                                                                                 lt1->v_index); */
-                                                               }
-                                                       }
-                                               }
-                                               /* uses in stackslots are already changed above by */
-                                               /* renameing and copying of local_ss */
-                                       }
-                               } /* for(s = lt2->use; s != NULL; s = s->next) */
-                               if (lt2->v_index >= 0) {
-                                       /* change def site */
-                                       _LT_ASSERT(lt2->def != NULL);
-                                       /* no SSA Anymore -> cyle through all def sites */
-                                       /*                                              _LT_ASSERT(lt2->def->next == NULL); */
-
-                                       for(s = lt2->def; s != NULL; s = s->next) {
-                                               if (s->iindex < 0) {
-                                                       /* change phi */
-                                                       if (ls->phi[s->b_index][-s->iindex-1][0] == lt2->v_index)
-                                                               ls->phi[s->b_index][-s->iindex-1][0] = lt1->v_index;
-                                                       pred=graph_get_first_predecessor(gd, s->b_index, &iter);
-                                                       for (; pred != -1; pred = graph_get_next(&iter)) {
-                                                               /* change in appropriate phi_move, too */
-                                                               for(k=0; k<ls->num_phi_moves[pred]; k++) {
-                                                                       if (ls->phi_moves[pred][k][0] ==
-                                                                               lt2->v_index) {
-                                                                               ls->phi_moves[pred][k][0]=lt1->v_index;
-                                                                       }
-                                                               }
-                                                       }
-                                               } else {
-                                                       /* change ICMD */
-
-                                                       iptr = ls->basicblocks[s->b_index]->iinstr
-                                                               + s->iindex;
-                                                       switch(iptr->opc) {
-                                                       case ICMD_ILOAD:
-                                                       case ICMD_LLOAD:
-                                                       case ICMD_FLOAD:
-                                                       case ICMD_DLOAD:
-                                                       case ICMD_ALOAD:
-                                                       case ICMD_ISTORE:
-                                                       case ICMD_LSTORE:
-                                                       case ICMD_FSTORE:
-                                                       case ICMD_DSTORE:
-                                                       case ICMD_ASTORE: /* iptr->op1 == DEF */
-                                                               if(iptr->op1 == lt2->v_index)
-                                                                       iptr->op1 = lt1->v_index;
-                                                               break;
-                                                       case ICMD_IINC: /* iptr->val._i.op1_t == DEF */
-                                                               if (iptr->val._i.op1_t == lt2->v_index)
-                                                                       iptr->val._i.op1_t = lt1->v_index;
-                                                               break;
-                                                               /*                                                      default: */
-                                                               /* could be in another than the top stackslot */
-                                                               /* too! */
-                                                               /*                                                              _LT_ASSERT((iptr->dst->varnum == lt1->v_index)); */
-                                                       }
-                                               }
-                                       }
-                               }
-                               
-                               /* combine def sites (SSA is dead now)*/
-                               _LT_ASSERT(lt2->def != NULL);
-                               for(s = lt2->def; s->next != NULL; s = s->next);
-                               s->next = lt1->def;
-                               lt1->def = lt2->def;
-
-                               /* combine use sites */
-                               _LT_ASSERT(lt2->use != NULL);
-                               for(s = lt2->use; s->next != NULL; s = s->next);
-                               s->next = lt1->use;
-                               lt1->use = lt2->use;
-
-                               /* combine first_def and last_use */
-                               if (lt1->bb_first_def == lt2->bb_first_def) {
-                                       lt1->i_first_def = min(lt1->i_first_def, lt2->i_first_def);
-                               } else if (lt1->bb_first_def > lt2->bb_first_def) {
-                                       lt1->bb_first_def = lt2->bb_first_def;
-                                       lt1->i_first_def  = lt2->i_first_def;
-                               }
-                               if (lt1->bb_last_use == lt2->bb_last_use) {
-                                       lt1->i_last_use = max(lt1->i_last_use, lt2->i_last_use);
-                               } else if (lt1->bb_last_use < lt2->bb_last_use) {
-                                       lt1->bb_last_use = lt2->bb_last_use;
-                                       lt1->i_last_use  = lt2->i_last_use;
+                                       _LT_ASSERT(ls->basicblocks[b_index]->iinstr != NULL);
+                                       iptr = ls->basicblocks[b_index]->iinstr + iindex;
+                                       if (icmd_table[iptr->opc].flags & ICMDTABLE_CALLS)
+                                               lt->savedvar = SAVEDVAR;
                                }
 
-                               /* combine savedvar flags */
-                               lt1->savedvar |= lt2->savedvar;
-                               _LT_ASSERT(lt1->type == lt2->type);
-                               lt2->type = -1;
-                               /* change the var in all future references of ls->igraph */
-                               /* TODO: do something against this!! */
-/*                             for(j = i + 1; j < ls->igraph_top; j++) { */
-/*                                     if (ls->igraph[j].inter == NULL) { */
-/*                                             for(var1 = ls->igraph[j].vars; var1 != NULL;  */
-/*                                                     var1 = var1->next) { */
-/*                                                     if (var1->v == lt2->v_index) */
-/*                                                             var1->v = lt1->v_index; */
-/*                                             } */
-/*                                     } */
-#if 0
-                                       /* not needed by now, since only for phi functions */
-                                       /* with absolutely no interference is checked */
-                                       else {
-                                               inter = ls->igraph[j].inter;
-                                               for(;inter != NULL; inter = inter->next) {
-                                                       if (inter->v1 == lt2->v_index)
-                                                               inter->v1 = lt1->v_index;
-                                                       if (inter->v2 == lt2->v_index)
-                                                               inter->v2 = lt1->v_index;
-                                               }
-                                       }
-#endif
-/*                             } */
-
-                               /* look through all phi functions */
-                               for(j = 0; j < ls->basicblockcount; j++) {
-                                       for(k = 0; k < ls->max_vars; k++) {
-                                               if (ls->phi[j][k] != NULL) {
-                                                       if (ls->phi[j][k][0] == lt2->v_index)
-                                                               ls->phi[j][k][0] = lt1->v_index;        
-                                                       for (l = 1; l < graph_get_num_predecessor(gd, j); l++) {
-                                                               if (ls->phi[j][k][l] == lt2->v_index)
-                                                                       ls->phi[j][k][l] = lt1->v_index;        
-                                                       }
-                                               }
-                                       }
-                                       /* change in phi move, too */
-                                       for(k = 0; k < ls->num_phi_moves[j]; k++) {
-                                               if (ls->phi_moves[j][k][1] == lt2->v_index)
-                                                       ls->phi_moves[j][k][1] = lt1->v_index;
-                                               if (ls->phi_moves[j][k][0] == lt2->v_index)
-                                                       ls->phi_moves[j][k][0] = lt1->v_index;
-                                       }
-                               }
-                       } /* for(var = ls->igraph[i].vars; var != NULL; var = var->next) */
-               } /* if (ls->igraph[i].inter == NULL) */
-       } /* for(i = 0; i < ls->igraph_top; i++) */
-       }
+                               /* lt stays life-in at statement */
+
+                               life_in = true;
+                       } else {
+
+                               /* print LO verbose message only for phi functions, which */
+                               /* define this var */
+
+#ifdef LT_DEBUG_VERBOSE
+                               if ((compileverbose) && (iindex < 0))
+                                       printf("LO@ST: vi %3i bi %3i ii %3i\n",
+                                                  lt->v_index, b_index, iindex);
+                               if ((compileverbose))
+                                       printf("--> definition\n");
 #endif
-}
 
-void LifeOutAtBlock(lsradata *ls, graphdata *gd, int *M, int n, 
-                                       struct lifetime *lt) {
-       /* lt->v_index is life at Block n */
-       if (!bv_get_bit(M,n)) { /* n no Element of M */
-               bv_set_bit(M,n);
+                               lt_is_live(ls, lt, b_index, iindex);
 
-               /* lt->v_index is life at last Statement of n */
-               if (n != 0) {
-                       int i;
-                       i = ls->basicblocks[n]->icount - 1;
-                       for (;((i>0) && (ls->basicblocks[n]->iinstr+i == ICMD_NOP)); i--);
-                       LifeOutAtStatement(ls, gd, M, n, i,lt);
+                               /* Stop - lt is defined and not life before this instruction */
+
+                               break;
+                       }
                }
-               else
-                       LifeOutAtStatement(ls, gd, M, n, 0, lt);
-       }
-}
 
-void LifeInAtStatement(lsradata *ls, graphdata *gd, int *M, int b_index, 
-                                          int iindex, struct lifetime *lt) {
-       /* lt->v_index is live-in at s */
-       int prev_iindex; /* Statement before iindex */
-       int pred;
-       graphiterator pred_iter;
+               if (life_in) {
+
+                       /* lt->v_index is live-in at statement (b_index,iindex) */
        
-       lt_is_live(ls, lt, b_index, iindex);
-
-       prev_iindex = iindex - 1;
-       if (prev_iindex < 0)
-               /* look through phi functions */
-               for(; prev_iindex > -ls->max_vars-1; 
-                       prev_iindex--)
-                       if (ls->phi[b_index][-prev_iindex-1] != NULL)
-                               break;
+#ifdef LT_DEBUG_VERBOSE
+                       if ((compileverbose) && (iindex >= 0))
+                               printf("LI@ST: vi %3i bi %3i ii %3i\n", 
+                                          lt->v_index, b_index, iindex);
+#endif
 
-       if (iindex == -ls->max_vars-1) { 
-               /* iindex is the first statement of b_index */
-               /* Statements -ls->max_vars-1 .. -1 are possible phi functions */
-               /* lt->v_index is live-in at b_index */
-               
-               pred = graph_get_first_predecessor(gd, b_index, &pred_iter);
-               for(; pred != -1; pred = graph_get_next(&pred_iter))
-                       LifeOutAtBlock(ls, gd, M, pred, lt);
-       } else
-               LifeOutAtStatement(ls, gd, M, b_index, prev_iindex, lt);
-}
+                       lt_is_live(ls, lt, b_index, iindex);
 
-void LifeOutAtStatement(lsradata *ls, graphdata *gd, int *M, int b_index, 
-                                               int iindex, struct lifetime *lt) {
-       instruction *iptr;
-       int igraph_index;
-       int var;
-       /* lt->v_index is life-out at s */
 
-       /* for each variable w defined at s except v=lt->v_index, add a edge */
-       /* (v,w) to the interference graph, once one is needed */
+                       if (iindex == -ls->varcount-1) { 
 
-#if defined(JOIN_PHI_LT)
-       /* Build interference Graph for variables involved in phi functions */
-       /* it is essential, that these variables get merged, if possible!   */
-       build_interference(ls, b_index, iindex, lt);
+#ifdef LT_DEBUG_VERBOSE
+                               if ((compileverbose))
+                                       printf("LI@ST: vi %3i bi %3i ii %3i\n", 
+                                                  lt->v_index, b_index, iindex);
 #endif
-       if (!v_is_defined_at_s(ls, b_index, iindex, lt)) {
-               /* v is life in at out of statement -> check if the SAVEDVAR */
-               /* flag is needed to be set */
-               if ((iindex >= 0) && (b_index != 0)) {
-                       /* real ICMD */
-                       _LT_ASSERT(ls->basicblocks[b_index]->iinstr != NULL);
-                       iptr = ls->basicblocks[b_index]->iinstr + iindex;
-                       if (icmd_table[iptr->opc].flags & ICMDTABLE_CALLS)
-                               lt->savedvar = SAVEDVAR;
-               }
-               LifeInAtStatement(ls, gd, M, b_index, iindex, lt);
-       } else
-               lt_is_live(ls, lt, b_index, iindex);
-}
+                               /* iindex is the first statement of b_index */
+                               /* Statements -ls->max_vars-1 .. -1 are possible phi functions*/
+                               /* lt->v_index is live-in at b_index */
+               
+                               pred = graph_get_first_predecessor(gd, b_index, &pred_iter);
 
-struct stackslot *lsra_make_ss(stackptr s, int bb_index)
-{
-       struct stackslot *ss;
+                               /* Add "Life out Basic Blocks to Worklist */
 
-       ss=DNEW(struct stackslot);
-       ss->bb=bb_index;
-       ss->s=s;
-       return ss;
-}
+                               for(; pred != -1; pred = graph_get_next(&pred_iter))
+                                       wl_add(W, pred); 
 
-void lsra_add_ss(struct lifetime *lt, stackptr s) {
-       struct stackslot *ss;
-       bool  insert_s;
-       /* Stackslot noch nicht eingetragen? */
+                               /* Stop here - beginning of Basic Block reached */
 
-       insert_s = true;
+                               break;
+                       } else {
 
-       for (ss = lt->local_ss; (!insert_s) && (ss != NULL); ss = ss->next)
-               insert_s = (ss->s == s);
-               
+                               prev_iindex = iindex - 1;
+                               if (prev_iindex < 0)
 
-       /* local_ss == NULL -> stack lt was set in ssa -> create Stack entry */
-       if ((lt->local_ss == NULL) || (insert_s)) {
-               ss = DNEW(struct stackslot);
-               ss->s = s;
-               ss->s->varnum = lt->v_index;
-               ss->next = lt->local_ss;
-               lt->local_ss = ss;
-               if (s != NULL) lt->savedvar |= s->flags & SAVEDVAR;
-               if (s != NULL) lt->type = s->type;
-       }
+                                       /* look through phi functions */
+
+                                       for(; prev_iindex > -ls->varcount-1; prev_iindex--)
+                                               if (ls->phi[b_index][-prev_iindex-1] != NULL)
+                                                       break;
+
+                               /* lt is live out at instruction prev_iindex */
+
+                               iindex = prev_iindex;
+                               life_in = false;
+                       }
+               }
+       }       
 }
 
-void move_stackslots(struct lifetime *from, struct lifetime *to) {
-       struct stackslot *ss;
-       
-       if (from->local_ss == NULL)
-               /* nothing to move */
-               return;
 
-       for(ss = from->local_ss; ss->next != NULL; ss = ss->next);
+void lt_lifeoutatblock(lsradata *ls, graphdata *gd, int *M, int b_index, 
+                                          struct lifetime *lt, worklist *W) {
+
+#if defined(LT_DEBUG_VERBOSE)
+       if (compileverbose) {
+               printf("V %3i LO at BB %3i\n",lt->v_index, b_index);
+       }
+#endif
+
+       /* lt->v_index is life out of Block b_index */
+       if (!bv_get_bit(M, b_index)) { /* BB b_index not visited till now */
+               bv_set_bit(M, b_index);
 
-       ss->next = to->local_ss;
-       to->local_ss = from->local_ss;
-       from->local_ss = NULL;
+               /* lt->v_index is life out of last Statement of b_index */
+
+               if (b_index != 0) {
+                       int i;
+                       i = ls->basicblocks[b_index]->icount - 1;
+                       for (;((i>0) && (ls->basicblocks[b_index]->iinstr+i == ICMD_NOP));
+                                i--);
+                       lt_lifeatstatement(ls, gd, b_index, i, lt, false, W);
+               }
+               else
+                       lt_lifeatstatement(ls, gd, b_index, 0, lt, false, W);
+       }
 }
-void move_use_sites(struct lifetime *from, struct lifetime *to) {
+
+void lt_move_use_sites(struct lifetime *from, struct lifetime *to) {
        struct site *s;
 
        _LT_ASSERT(from->use != NULL);
@@ -1074,7 +588,7 @@ void move_use_sites(struct lifetime *from, struct lifetime *to) {
        from->use = NULL;
 }
 
-void add_use_site(struct lifetime *lt, int block, int iindex) {
+void lt_add_use_site(struct lifetime *lt, int block, int iindex) {
        struct site *n;
 
        n = DNEW(struct site);
@@ -1085,22 +599,28 @@ void add_use_site(struct lifetime *lt, int block, int iindex) {
 
        /* CFG is analysed from the end to the start -> so first found use site */
        /* is the last use of the Local Var */
+
        if (lt->last_use == NULL)
                lt->last_use = n;
 }
 
-void remove_use_site(struct lifetime *lt, int block, int iindex) {
+void lt_remove_use_site(struct lifetime *lt, int block, int iindex) {
        struct site *n;
 
        /* check lt->use itself */
+
        if ((lt->use->b_index == block) && (lt->use->iindex == iindex)) {
                /* found */
                lt->use = lt->use->next;
        } else {
+
                /* look through list */
+
                for (n = lt->use; (n->next != NULL) && ((n->next->b_index != block) ||
                                                                        (n->next->iindex != iindex)); n = n->next);
+
                /* assert, that lt was found */
+
                _LT_ASSERT(n->next != NULL);
                _LT_ASSERT(n->next->b_index == block);
                _LT_ASSERT(n->next->iindex == iindex);
@@ -1109,10 +629,11 @@ void remove_use_site(struct lifetime *lt, int block, int iindex) {
        }
 }
 
-void add_def_site(struct lifetime *lt, int block, int iindex) {
+void lt_add_def_site(struct lifetime *lt, int block, int iindex) {
        struct site *n;
 
        /* SSA <-> only one definition per lifetime! */
+
        _LT_ASSERT(lt->def == NULL);
        n = DNEW(struct site);
        n->b_index = block;
@@ -1121,101 +642,22 @@ void add_def_site(struct lifetime *lt, int block, int iindex) {
        lt->def = n;
 }
 
-struct lifetime *get_ss_lifetime(lsradata *ls, stackptr s) {
-       struct lifetime *n;
-       
-       if (s->varnum >= 0) { /* new stackslot lifetime */
-               if (-ls->v_index - 1 >= ls->maxlifetimes) {
-                       printf("%i %i\n", -ls->v_index - 1, ls->maxlifetimes);
-               }
-               _LT_ASSERT(-ls->v_index - 1 < ls->maxlifetimes);
-
-               n = &(ls->lifetime[-ls->v_index - 1]);
-               n->type = s->type;
-               n->v_index = ls->v_index--;
-               n->usagecount = 0;
-               
-               n->bb_last_use = -1;
-               n->bb_first_def = -1;
-               n->local_ss = NULL;
-               n->savedvar = 0;
-               n->flags = 0;
-               
-               n->use = NULL;
-               n->def = NULL;
-               n->last_use = NULL;
-       } else {
-               _LT_ASSERT(-s->varnum - 1 < ls->maxlifetimes);
-               n = &(ls->lifetime[-s->varnum - 1]);
-       }
-
-       lsra_add_ss( n, s);
-       return n;
-}
-
-#define lsra_new_stack(ls, s, block, instr) \
-       if ((s)->varkind != ARGVAR) _lsra_new_stack(ls, s, block, instr, LSRA_STORE)
-void _lsra_new_stack(lsradata *ls, stackptr s, int block, int instr, int store)
-{
-       struct lifetime *n;
-
-       if (s->varkind == LOCALVAR) {
-/*             _LT_ASSERT(0); */
-               lsra_usage_local(ls, s->varnum, s->type, block, instr, LSRA_LOAD);
-       } else {
-               
-
-               n=get_ss_lifetime( ls, s );
-               if (store == LSRA_STORE) {
-                       /* for LSRA_BB_[IN|OUT] do not add a def site, just add s to */
-                       /* local_ss */
-                       add_def_site(n, block, instr);
-               }
-       }
-}
-
-#define lsra_from_stack(ls, s, block, instr) \
-       if ((s)->varkind != ARGVAR) _lsra_from_stack(ls, s, block, instr, LSRA_LOAD)
-#define lsra_pop_from_stack(ls, s, block, instr) \
-       if ((s)->varkind != ARGVAR) _lsra_from_stack(ls, s, block, instr, LSRA_POP)
-void _lsra_from_stack(lsradata *ls, stackptr s, int block, int instr, int store)
-{
-       struct lifetime *n;
-
-       if (s->varkind == LOCALVAR) {
-/*             _LT_ASSERT(0); */
-               lsra_usage_local(ls, s->varnum, s->type, block, instr, LSRA_LOAD);
-       } else /* if (s->varkind != ARGVAR) */ {
-               if (s->varkind == STACKVAR ) {
-/*                     _LT_ASSERT(0); */
-                       printf("---------STACKVAR left over! \n");
-                       /* No STACKVARS possible with lsra! */
-                       s->varkind = TEMPVAR;
-               }
-       }
-
-               n=get_ss_lifetime( ls, s );
-               
-               /* LSRA_POP -> invalidate Stackslot ?! */
-#ifdef USAGE_COUNT
-               n->usagecount += ls->nesting[block];
-#endif
-
-               add_use_site(n, block, instr);
-
-}
-
-void lsra_usage_local(lsradata *ls, s4 v_index, int type, int block, int instr,
+void lt_usage(jitdata *jd,s4 v_index, int block, int instr,
                                          int store)
 {
        struct lifetime *n;
+       lsradata *ls;
+
+       ls = jd->ls;
 
-       n = &(ls->lifetime[ls->maxlifetimes + v_index]);
+       n = ls->lifetime + v_index;
 
        if (n->type == -1) { /* new local lifetime */
-               n->local_ss=NULL;
+               _LT_ASSERT(0);
                n->v_index=v_index;
-               n->type=type;
+               n->type=VAR(v_index)->type;
+               /* TODO: check!!!!  */
+               /* All var are SAVEDVARS or this gets reset afterwards???? */
                n->savedvar = SAVEDVAR;
                n->flags = 0;
                n->usagecount = 0;
@@ -1227,20 +669,21 @@ void lsra_usage_local(lsradata *ls, s4 v_index, int type, int block, int instr,
                n->def = NULL;
                n->last_use = NULL;
        }
-       _LT_ASSERT(type == n->type);
+       _LT_ASSERT(VAR(v_index)->type == n->type);
 
        /* add access at (block, instr) to instruction list */
        /* remember last USE, so only write, if USE Field is undefined (==-1)   */
        /* count store as use, too -> defined and not used vars would overwrite */
        /* other vars */
-       if (store == LSRA_LOAD) {
+
+       if (store == LT_USE) {
 #ifdef USAGE_COUNT
                n->usagecount += ls->nesting[block];
 #endif
-               add_use_site(n, block, instr);
+               lt_add_use_site(n, block, instr);
        }
-       if (store == LSRA_STORE) {
-               add_def_site(n, block, instr);
+       if (store == LT_DEF) {
+               lt_add_def_site(n, block, instr);
        }
 }      
 
@@ -1248,124 +691,67 @@ void lsra_usage_local(lsradata *ls, s4 v_index, int type, int block, int instr,
 use sites: dead code elemination, LifenessAnalysis
 def sites: dead code elemination
 ***************************************************************************/
-void _scan_lifetimes(registerdata *rd, lsradata *ls, graphdata *gd,
-                                       basicblock *bptr)
+void _lt_scanlifetimes(jitdata *jd, graphdata *gd, basicblock *bptr,
+                                          int b_index)
 {
 /*     methodinfo         *lm; */
        builtintable_entry *bte;
        methoddesc         *md;
        int i, j, t, v;
-       int opcode;
-       int iindex, b_index;
-       stackptr    src;
-       stackptr    dst;
+       int iindex/*, b_index*/;
        instruction *iptr;
-   
-       struct lifetime *lt;
+       s4 *argp;
+
+       lsradata *ls;
+       
+       ls = jd->ls;
 
+#ifdef LT_DEBUG_VERBOSE
+       if (compileverbose)
+               printf("_lt_scanlifetimes: BB %3i flags %3i\n", b_index, bptr->flags);
+#endif
 
        if (bptr->flags >= BBREACHED) {
 
-               b_index = bptr->nr;
+/*             b_index = bptr->nr; */
 
                /* get instruction count for BB */
+
                iindex = bptr->icount - 1;
-               /* regard not setup new BB with maybee just in and outstack */
-               if (iindex < 0) iindex = 0;
+
+               /* regard not setup new BB with maybe just in and outstack */
+
+               if (iindex < 0)
+                       iindex = 0;
 
                /* Regard phi_functions (Definition of target, Use of source) */
-               for(i = 0; i < ls->max_vars; i++) {
+
+               for(i = 0; i < ls->ssavarcount; i++) {
                        if (ls->phi[b_index][i] != NULL) {
                                /* Phi Function for var i at b_index exists */
                                v = ls->phi[b_index][i][0];
-                               _LT_ASSERT( v != ls->max_vars_with_indices);
-                               if (v >= 0) {
-                                       /* Local Var */
-                                       for(t = 0;(t < 5) && (rd->locals[v][t].type==-1); t++);
-                                       _LT_ASSERT(t != 5);
-                                       /* Add definition of target add - phi index -1*/
-                                       lsra_usage_local(ls, v, t, b_index, -i-1,
-                                                                        LSRA_STORE);
-                                       /* Add Use of sources */
-                                       for (j = 1; j <= graph_get_num_predecessor(gd, b_index);
-                                                j++) {
-                                               if (ls->phi[b_index][i][j] != ls->max_vars_with_indices)
-                                                       lsra_usage_local(ls, ls->phi[b_index][i][j], t,
-                                                                                        b_index, -i-1, LSRA_LOAD);
-                                       }
-                               } else {
-                                       /* Interface Stackslot */
-                                       /* Add definition of target */
-                                       lt = &(ls->lifetime[-v-1]);
-                                       add_def_site(lt, b_index, -i-1);
-                                       /* add use of sources */
-                                       for (j = 1; j <= graph_get_num_predecessor(gd, b_index);
-                                                j++) {
-                                               if (ls->phi[b_index][i][j] != ls->max_vars_with_indices)
-                                               {
-                                                       lt = &(ls->lifetime[-ls->phi[b_index][i][j]-1]);
-                                                       add_use_site(lt, b_index, -i-1);
-                                               }
-                                       }
+                               _LT_ASSERT( v != ls->varcount_with_indices);
+                               t = VAR(i)->type;
+
+                               /* Add definition of target add - phi index -1*/
+#ifdef LT_DEBUG_VERBOSE
+                               if (compileverbose)
+                                       printf("_lt_scanlifetimes: phi_def: v: %3i\n i: %3i\n", 
+                                                  v, -i-1);
+#endif
+                               lt_usage(jd, v, b_index, -i-1, LT_DEF);
+
+                               /* Add Use of sources */
+
+                               for (j = 1; j <= graph_get_num_predecessor(gd, b_index); j++) {
+                                       if (ls->phi[b_index][i][j] != ls->varcount_with_indices)
+                                               if (ls->phi[b_index][i][j] != UNUSED)
+                                                       lt_usage(jd, ls->phi[b_index][i][j], b_index, 
+                                                                        -i-1, LT_USE);
                                }
                        } 
                }
 
-               src = bptr->instack;
-               if (bptr->type != BBTYPE_STD) {
-#ifdef LT_DEBUG_CHECK
-                       if (src == NULL) {
-                          log_text("No Incoming Stackslot for Exception/Subroutine BB\n");
-                               _LT_ASSERT(0);
-                       }
-#endif
-                       _LT_ASSERT(src != NULL);
-                       lsra_new_stack(ls, src, b_index, 0);
-                       if (src->varkind == STACKVAR)
-                               src->varkind = TEMPVAR;
-                       src = src->prev;
-               }
-               for (;src != NULL; src=src->prev) {
-                       /* no ARGVAR possible at BB Boundaries with LSRA! */
-                       /* -> change to TEMPVAR                           */
-
-                       if (src->varkind == ARGVAR ) {
-                               src->varkind = TEMPVAR;
-                               /* On Architectures with own return registers a return    */
-                               /* stackslot is marked as varkind=ARGVAR with varnum=-1   */
-                               /* but for lsra a varkind==TEMPVAR, varnum=-1 would mean, */
-                               /* that already a lifetime was allocated! */
-                               if (src->varnum < 0) src->varnum = 0;
-                       }
-                       else if (src->varkind == LOCALVAR )
-                               /* only allowed for topmost ss at sbr or exh entries! */
-                               { log_text("LOCALVAR at basicblock instack\n"); exit(1); } 
-                       else {
-                               /* no Interfaces (STACKVAR) at BB Boundaries with LSRA! */
-                               /* -> change to TEMPVAR                      */
-                               if (src->varkind == STACKVAR )
-                                       src->varkind = TEMPVAR;
-/*                             _lsra_new_stack(ls, src, b_index, 0, LSRA_BB_IN); */
-                               _lsra_from_stack(ls, src, b_index, 0, LSRA_BB_OUT);
-                       }
-               }
-               /* Should not be necessary to check out stackslots, too */
-               /* either they are identical to the instacks or handled */
-               /* by their phi functions */
-               src = bptr->outstack;
-               for (;src != NULL; src=src->prev) {
-                       if (src->varkind == ARGVAR )  
-                               { log_text("ARGVAR at basicblock outstack\n"); exit(1); }
-                       else if (src->varkind == LOCALVAR )
-                               { log_text("LOCALVAR at basicblock outstack\n"); exit(1); }
-                       else {
-                               /* no Interfaces at BB Boundaries with LSRA! */
-                               /* -> change to TEMPVAR                      */
-                               if (src->varkind == STACKVAR )
-                                       src->varkind = TEMPVAR;
-/*                             _lsra_from_stack(ls, src, b_index, iindex, LSRA_BB_OUT); */
-                       }
-               }
 
                if (bptr->iinstr != NULL) {
                        /* set iptr to last instruction of BB */
@@ -1374,531 +760,66 @@ void _scan_lifetimes(registerdata *rd, lsradata *ls, graphdata *gd,
                        iindex = -1;
 
                for (;iindex >= 0; iindex--, iptr--)  {
-                       /* Get source and destination Stack for the current           */
-                       /* instruction. Destination stack is available as iptr->dst   */
-                       dst = iptr->dst;
-                       /* source stack is either the destination stack of the previos*/
-                       /* instruction, or the basicblock instack for the             */
-                       /* first instruction */
-                       if (iindex) /* != 0 is > 0 here, since iindex ist always >= 0 */
-                               src=(iptr-1)->dst;
-                       else
-                               src=bptr->instack;
-
-                       opcode = iptr->opc;
-                       switch (opcode) {
-
-                               /* pop 0 push 0 */
-                       case ICMD_RET:
-                               /* local read (return adress) */
-                               lsra_usage_local(ls, iptr->op1, TYPE_ADR, b_index, iindex,
-                                                                LSRA_LOAD);
-                               break;
-                       case ICMD_NOP:
-/*                     case ICMD_ELSE_ICONST: */
-                       case ICMD_CHECKNULL:
-                       case ICMD_JSR:
-                       case ICMD_RETURN:
-                       case ICMD_GOTO:
-                       case ICMD_PUTSTATICCONST:
-                       case ICMD_INLINE_START:
-                       case ICMD_INLINE_END:
-                       case ICMD_INLINE_GOTO:
-                               break;
-                             
-                       case ICMD_IINC:
-                               /* local = local+<const> */
-                               lsra_usage_local(ls, iptr->op1, TYPE_INT, b_index, iindex, 
-                                                                LSRA_LOAD);
-                               lsra_usage_local(ls, iptr->val._i.op1_t, TYPE_INT, b_index,
-                                                                iindex, LSRA_STORE);
-                               break;
+                       i = UNUSED;
+                       v = UNUSED;
 
-                               /* pop 0 push 1 const: const->stack */
-                       case ICMD_ICONST:
-                       case ICMD_LCONST:
-                       case ICMD_FCONST:
-                       case ICMD_DCONST:
-                       case ICMD_ACONST:
-                               /* new stack slot */
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                               /* pop 0 push 1 load: local->stack */
-                       case ICMD_ILOAD:
-                       case ICMD_LLOAD:
-                       case ICMD_FLOAD:
-                       case ICMD_DLOAD:
-                       case ICMD_ALOAD:
-                               if (dst->varkind != LOCALVAR) {
-                                       /* local->value on stack */
-                                       lsra_usage_local(ls, iptr->op1, opcode - ICMD_ILOAD,
-                                                                        b_index,  iindex, LSRA_LOAD);
-                                       lsra_new_stack(ls, dst, b_index, iindex); 
-                               } else /* if (dst->varnum != iptr->op1) */ {
-                                       /* local -> local */
-                                       lsra_usage_local(ls, iptr->op1, opcode - ICMD_ILOAD,
-                                                                        b_index,  iindex,LSRA_LOAD); 
-                                       lsra_usage_local(ls, dst->varnum, opcode - ICMD_ILOAD,
-                                                                        b_index, iindex, LSRA_STORE);
-                               }
-
-                               break;
-
-                               /* pop 2 push 1 */
-                               /* Stack(arrayref,index)->stack */
-                       case ICMD_IALOAD:
-                       case ICMD_LALOAD:
-                       case ICMD_FALOAD:
-                       case ICMD_DALOAD:
-                       case ICMD_AALOAD:
-
-                       case ICMD_BALOAD:
-                       case ICMD_CALOAD:
-                       case ICMD_SALOAD:
-                               /* stack->index */
-                               lsra_from_stack(ls, src, b_index, iindex); 
-                               /* stack->arrayref */
-                               lsra_from_stack(ls, src->prev, b_index, iindex); 
-                               /* arrayref[index]->stack */
-                               lsra_new_stack(ls, dst, b_index, iindex); 
-                               break;
-
-                               /* pop 3 push 0 */
-                               /* stack(arrayref,index,value)->arrayref[index]=value */
-                       case ICMD_IASTORE:
-                       case ICMD_LASTORE:
-                       case ICMD_FASTORE:
-                       case ICMD_DASTORE:
-                       case ICMD_AASTORE:
-
-                       case ICMD_BASTORE:
-                       case ICMD_CASTORE:
-                       case ICMD_SASTORE:
-
-                               lsra_from_stack(ls, src,b_index, iindex);
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-                               lsra_from_stack(ls, src->prev->prev, b_index, iindex); 
-                               break;
-
-                               /* pop 1 push 0 store: stack -> local */
-                       case ICMD_ISTORE:
-                       case ICMD_LSTORE:
-                       case ICMD_FSTORE:
-                       case ICMD_DSTORE:
-                       case ICMD_ASTORE:
-                               if (src->varkind != LOCALVAR) {
-                                       lsra_from_stack(ls, src, b_index, iindex);
-                                       lsra_usage_local(ls, iptr->op1, opcode-ICMD_ISTORE,
-                                                                        b_index, iindex, LSRA_STORE);
-                               } else /* if (src->varnum != iptr->op1) */ {
-                                       lsra_usage_local(ls, iptr->op1, opcode-ICMD_ISTORE,
-                                                                        b_index, iindex, LSRA_STORE);
-                                       lsra_usage_local(ls, src->varnum, opcode-ICMD_ISTORE,
-                                                                        b_index,  iindex, LSRA_LOAD); 
-                               }
-                               break;
+                       if (icmd_table[iptr->opc].dataflow >= DF_DST_BASE)
+                               v = iptr->dst.varindex;
 
-                               /* pop 1 push 0 */
-                       case ICMD_POP: /* throw away a stackslot */
-                               /* TODO: check if used anyway (DUP...) and change codegen */
-                               /* to ignore this stackslot */
-#if 0
-                               lsra_pop_from_stack(ls, src, b_index, iindex);
-#endif
-                       break;
-
-                               /* pop 1 push 0 */
-                       case ICMD_IRETURN:
-                       case ICMD_LRETURN:
-                       case ICMD_FRETURN:
-                       case ICMD_DRETURN:
-                       case ICMD_ARETURN: /* stack(value) -> [empty]    */
-
-                       case ICMD_ATHROW:  /* stack(objref) -> undefined */
-
-                       case ICMD_PUTSTATIC: /* stack(value) -> static_field */
-                       case ICMD_PUTFIELDCONST:
-
-                               /* pop 1 push 0 branch */
-                       case ICMD_IFNULL: /* stack(value) -> branch? */
-                       case ICMD_IFNONNULL:
-
-                       case ICMD_IFEQ:
-                       case ICMD_IFNE:
-                       case ICMD_IFLT:
-                       case ICMD_IFGE:
-                       case ICMD_IFGT:
-                       case ICMD_IFLE:
-
-                       case ICMD_IF_LEQ:
-                       case ICMD_IF_LNE:
-                       case ICMD_IF_LLT:
-                       case ICMD_IF_LGE:
-                       case ICMD_IF_LGT:
-                       case ICMD_IF_LLE:
-
-                               /* pop 1 push 0 table branch */
-                       case ICMD_TABLESWITCH:
-                       case ICMD_LOOKUPSWITCH:
-
-                       case ICMD_MONITORENTER:
-                       case ICMD_MONITOREXIT:
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               break;
-
-                               /* pop 2 push 0 */
-                       case ICMD_POP2: /* throw away 2 stackslots */
-#if 0
-                               /* TODO: check if used anyway (DUP...) and change codegen */
-                               /* to ignore this stackslot */
-                               lsra_pop_from_stack(ls, src, b_index, iindex);
-                               lsra_pop_from_stack(ls, src->prev, b_index, iindex);
-#endif
-                               break;
-
-                               /* pop 2 push 0 branch */
-
-                       case ICMD_IF_ICMPEQ: /* stack (v1,v2) -> branch(v1,v2) */
-                       case ICMD_IF_ICMPNE:
-                       case ICMD_IF_ICMPLT:
-                       case ICMD_IF_ICMPGE:
-                       case ICMD_IF_ICMPGT:
-                       case ICMD_IF_ICMPLE:
-
-                       case ICMD_IF_LCMPEQ:
-                       case ICMD_IF_LCMPNE:
-                       case ICMD_IF_LCMPLT:
-                       case ICMD_IF_LCMPGE:
-                       case ICMD_IF_LCMPGT:
-                       case ICMD_IF_LCMPLE:
-
-                       case ICMD_IF_ACMPEQ:
-                       case ICMD_IF_ACMPNE:
-
-                               /* pop 2 push 0 */
-                       case ICMD_PUTFIELD: /* stack(objref,value) -> objref = value */
-
-                       case ICMD_IASTORECONST:
-                       case ICMD_LASTORECONST:
-                       case ICMD_AASTORECONST:
-                       case ICMD_BASTORECONST:
-                       case ICMD_CASTORECONST:
-                       case ICMD_SASTORECONST:
-                               lsra_from_stack(ls, src, b_index, iindex);       
-                               lsra_from_stack(ls, src->prev, b_index, iindex); 
-                               break;
+                       /* check for use (s1, s2, s3 or special (argp) ) */
+                       /* and definitions (dst) */
+                       switch(icmd_table[iptr->opc].dataflow) {
+                       case DF_3_TO_0:
+                       case DF_3_TO_1: /* icmd has s1, s2 and s3 */
+                               lt_usage(jd, iptr->sx.s23.s3.varindex, b_index, iindex, LT_USE);
 
-                               /* pop 0 push 1 dup */
-                       case ICMD_DUP: 
-                               /* src == dst->prev */
-                               /* ---------------- */
-                               /* src -> dst       */
+                               /* now "fall through" for handling of s2 and s1 */
 
-                               /* Add the use site for src==dst */
-                               lsra_from_stack(ls, src, b_index, iindex);
+                       case DF_2_TO_0:
+                       case DF_2_TO_1: /* icmd has s1 and s2 */
+                               lt_usage(jd, iptr->sx.s23.s2.varindex, b_index, iindex, LT_USE);
 
-                               lsra_new_stack(ls, dst, b_index, iindex);
+                               /* now "fall through" for handling of s1 */
 
+                       case DF_1_TO_0:
+                       case DF_1_TO_1:
+                       case DF_MOVE:
+                       case DF_COPY: /* icmd has s1 */
+                               lt_usage(jd, iptr->s1.varindex, b_index, iindex, LT_USE);
                                break;
 
-                               /* pop 0 push 2 dup */
-                       case ICMD_DUP2:
-                               /* src       == dst->prev->prev       */
-                               /* src->prev == dst->prev->prev->prev */
-                               /* ---------------- */
-                               /* src       -> dst                   */
-                               /* src->prev -> dst->prev             */
-                               /* src & src->prev "continue" living -> so no conflicts */
-                               /* with dst and dst->prec possible                      */
-                               
-                               /* add the use site for src == dst->prev->prev */
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               /* add the use site for src->prev == dst->prev->prev->prev */
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-
-                       
-                               lsra_new_stack(ls, dst->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex); 
-
-                               break;
-
-                               /* pop 2 push 3 dup */
-                       case ICMD_DUP_X1:
-                               /* src       -> dst             */
-                               /* src->prev -> dst->prev       */
-                               /* src       -> dst->prev->prev */
-                               /* !!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-                               /* Copy Conflicts possible!     */
-                               /* -> instack [    t1 t0 ]      */
-                               /* -> outstack[ t0 t1 t3 ]      */
-                               /* -> t1->t0, t0->t1, t1->t3 !! */
-                               /* -> Remove src->prev on iindex+1 instead of iindex! */
-                               lsra_from_stack(ls, src, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex); 
-
-                               break;
-
-                               /* pop 3 push 4 dup */
-                       case ICMD_DUP_X2:
-                               /* src             -> dst  */
-                               /* src             -> dst->prev->prev->prev */
-                               /* src->prev       -> dst->prev */
-                               /* src->prev->prev -> dst->prev->prev */
-                               /* Conflicts possible! -> remove srces at iindex + 1 */
-                               lsra_from_stack(ls, src,b_index, iindex); 
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-                               lsra_from_stack(ls, src->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex); 
-
-                               break;
-
-                               /* pop 3 push 5 dup */
-                       case ICMD_DUP2_X1:
-                               /* src             -> dst  */
-                               /* src             -> dst->prev->prev->prev */
-                               /* src->prev       -> dst->prev->prev->prev->prev */
-                               /* src->prev       -> dst->prev */
-                               /* src->prev->prev -> dst->prev->prev */
-                               /* Conflicts possible! -> remove srces at iindex + 1 */
-                               lsra_from_stack(ls, src, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev->prev, b_index, iindex); 
-                               lsra_new_stack(ls, dst->prev->prev->prev->prev, b_index,
-                                                          iindex);
-                               lsra_new_stack(ls, dst->prev->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex); 
-
-
-                               break;
-
-                               /* pop 4 push 6 dup */
-                       case ICMD_DUP2_X2:
-                               /* src                   -> dst  */
-                               /* src                   -> dst->prev->prev->prev->prev */
-                               /* src->prev         -> dst->prev->prev->prev->prev->prev */
-                               /* src->prev             -> dst->prev */
-                               /* src->prev->prev       -> dst->prev->prev */
-                               /* src->prev->prev->prev -> dst->prev->prev->prev */
-                               /* Conflicts possible! -> remove srcs at iindex + 1 */
-                               lsra_from_stack(ls, src, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev->prev, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev->prev->prev, b_index, iindex); 
-                               lsra_new_stack(ls, dst->prev->prev->prev->prev->prev,
-                                                          b_index, iindex);
-                               lsra_new_stack(ls, dst->prev->prev->prev->prev, b_index,
-                                                          iindex);
-                               lsra_new_stack(ls, dst->prev->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex); 
-
-                               break;
-
-                               /* pop 2 push 2 swap */
-                       case ICMD_SWAP:
-                               /* src                   -> dst->prev  */
-                               /* src->prev             -> dst */
-                               /* Conflicts possible -> remove src at iindex + 1 */
-                               lsra_from_stack(ls, src, b_index, iindex); 
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                               /* pop 2 push 1 */
-                                       
-                       case ICMD_LADD:
-                       case ICMD_LSUB:
-                       case ICMD_LMUL:
-
-                       case ICMD_LOR:
-                       case ICMD_LAND:
-                       case ICMD_LXOR:
-
-                       case ICMD_LSHL:
-                       case ICMD_LSHR:
-                       case ICMD_LUSHR:
-
-                       case ICMD_IADD:
-                       case ICMD_IMUL:
-
-                       case ICMD_ISHL:
-                       case ICMD_ISHR:
-                       case ICMD_IUSHR:
-                       case ICMD_IAND:
-                       case ICMD_IOR:
-                       case ICMD_IXOR:
-
-
-                       case ICMD_FADD:
-                       case ICMD_FSUB:
-                       case ICMD_FMUL:
-
-                       case ICMD_DADD:
-                       case ICMD_DSUB:
-                       case ICMD_DMUL:
-                       case ICMD_DDIV:
-                       case ICMD_DREM:
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                       case ICMD_ISUB:
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               lsra_from_stack(ls, src->prev,b_index,iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                       case ICMD_LDIV:
-                       case ICMD_LREM:
-
-                       case ICMD_IDIV:
-                       case ICMD_IREM:
-
-                       case ICMD_FDIV:
-                       case ICMD_FREM:
-
-                       case ICMD_LCMP:
-                       case ICMD_FCMPL:
-                       case ICMD_FCMPG:
-                       case ICMD_DCMPL:
-                       case ICMD_DCMPG:
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               lsra_from_stack(ls, src->prev, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                               /* pop 1 push 1 */
-                       case ICMD_LADDCONST:
-                       case ICMD_LSUBCONST:
-                       case ICMD_LMULCONST:
-                       case ICMD_LMULPOW2:
-                       case ICMD_LDIVPOW2:
-                       case ICMD_LREMPOW2:
-                       case ICMD_LANDCONST:
-                       case ICMD_LORCONST:
-                       case ICMD_LXORCONST:
-                       case ICMD_LSHLCONST:
-                       case ICMD_LSHRCONST:
-                       case ICMD_LUSHRCONST:
-
-                       case ICMD_IADDCONST:
-                       case ICMD_ISUBCONST:
-                       case ICMD_IMULCONST:
-                       case ICMD_IMULPOW2:
-                       case ICMD_IDIVPOW2:
-                       case ICMD_IREMPOW2:
-                       case ICMD_IANDCONST:
-                       case ICMD_IORCONST:
-                       case ICMD_IXORCONST:
-                       case ICMD_ISHLCONST:
-                       case ICMD_ISHRCONST:
-                       case ICMD_IUSHRCONST:
-
-/*                     case ICMD_IFEQ_ICONST: */
-/*                     case ICMD_IFNE_ICONST: */
-/*                     case ICMD_IFLT_ICONST: */
-/*                     case ICMD_IFGE_ICONST: */
-/*                     case ICMD_IFGT_ICONST: */
-/*                     case ICMD_IFLE_ICONST: */
-
-                       case ICMD_INEG:
-                       case ICMD_INT2BYTE:
-                       case ICMD_INT2CHAR:
-                       case ICMD_INT2SHORT:
-                       case ICMD_LNEG:
-                       case ICMD_FNEG:
-                       case ICMD_DNEG:
-
-                       case ICMD_I2L:
-                       case ICMD_I2F:
-                       case ICMD_I2D:
-                       case ICMD_L2I:
-                       case ICMD_L2F:
-                       case ICMD_L2D:
-                       case ICMD_F2I:
-                       case ICMD_F2L:
-                       case ICMD_F2D:
-                       case ICMD_D2I:
-                       case ICMD_D2L:
-                       case ICMD_D2F:
-
-                       case ICMD_CHECKCAST:
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                       case ICMD_ARRAYLENGTH:
-                       case ICMD_INSTANCEOF:
-
-                       case ICMD_NEWARRAY:
-                       case ICMD_ANEWARRAY:
-
-                       case ICMD_GETFIELD:
-                               lsra_from_stack(ls, src, b_index, iindex);
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                               /* pop 0 push 1 */
-                       case ICMD_GETSTATIC:
-
-                       case ICMD_NEW:
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
-
-                               /* pop many push any */
-
-                       case ICMD_INVOKESTATIC:
-                       case ICMD_INVOKESPECIAL:
-                       case ICMD_INVOKEVIRTUAL:
-                       case ICMD_INVOKEINTERFACE:
+                       case DF_INVOKE:
                                INSTRUCTION_GET_METHODDESC(iptr,md);
                                i = md->paramcount;
-                               while (--i >= 0) {
-                                       lsra_from_stack(ls, src, b_index, iindex);
-                                       src = src->prev;
-                               }
-                               if (md->returntype.type != TYPE_VOID)
-                                       lsra_new_stack(ls, dst, b_index, iindex);
+                               if (md->returntype.type == TYPE_VOID)
+                                       v = UNUSED;
                                break;
 
-                       case ICMD_BUILTIN:
-                               bte = iptr->val.a;
+                       case DF_BUILTIN:
+                               bte = iptr->sx.s23.s3.bte;
                                md = bte->md;
                                i = md->paramcount;
-                               while (--i >= 0) {
-                                       lsra_from_stack(ls, src, b_index, iindex);
-                                       src = src->prev;
-                               }
-                               if (md->returntype.type != TYPE_VOID)
-                                       lsra_new_stack(ls, dst, b_index, iindex);
+                               if (md->returntype.type == TYPE_VOID)
+                                       v = UNUSED;
+                               break;
+
+                       case DF_N_TO_1:
+                               i = iptr->s1.argcount;
                                break;
 
-                       case ICMD_MULTIANEWARRAY:
-                               i = iptr->op1;
+                       }
+
+                       if (i != UNUSED) {
+                               argp = iptr->sx.s23.s2.args;
                                while (--i >= 0) {
-                                       lsra_from_stack(ls, src, b_index, iindex);
-                                       src = src->prev;
+                                       lt_usage(jd, *argp, b_index, iindex, LT_USE);
+                                       argp++;
                                }
-                               lsra_new_stack(ls, dst, b_index, iindex);
-                               break;
+                       }
 
-                       default:
-/*                             assert(0); */
-                               throw_cacao_exception_exit(string_java_lang_InternalError,
-                                                                                  "Unknown ICMD %d during register allocation", iptr->opc);
-                       } /* switch */
+                       if (v != UNUSED) {
+                               lt_usage(jd, v, b_index, iindex, LT_DEF);
+                       }
                } /* for (;iindex >= 0; iindex--, iptr--) */
        } /* if (bptr->flags >= BBREACHED) */
 } /* scan_lifetimes */
index 068d8839378fc3d1de4d7c7190f279539b4cdc0c..e6776ea4907cac4ea2e92fc0903a329e0ece7107 100644 (file)
@@ -39,7 +39,7 @@
 #if !defined(NDEBUG)
 # include <assert.h>
 # define LT_DEBUG_CHECK
-# define LT_DEBUG_VERBOSE
+/* # define LT_DEBUG_VERBOSE */
 #endif
 
 #ifdef LT_DEBUG_CHECK
 # define _LT_ASSERT(a)
 #endif
 
-#define LSRA_BB_IN 3
-#define LSRA_BB_OUT 2
-#define LSRA_STORE 1
-#define LSRA_LOAD 0
-#define LSRA_POP -1
+#define LT_BB_IN 3
+#define LT_BB_OUT 2
+#define LT_DEF 1
+#define LT_USE 0
 
 typedef struct site *lt_iterator;
-void scan_lifetimes(methodinfo *m, codegendata *cd, registerdata *rd,
-                                       lsradata *ls, graphdata *gd, dominatordata *dd);
-void lsra_add_ss(struct lifetime *, stackptr );
-void remove_use_site(struct lifetime *lt, int block, int iindex);
-void move_use_sites(struct lifetime *from, struct lifetime *to);
-void move_stackslots(struct lifetime *from, struct lifetime *to);
-void LifenessAnalysis(methodinfo *m, lsradata *ls, graphdata *gd);
+void lt_scanlifetimes(jitdata *, graphdata *, dominatordata *);
+void lt_add_ss(struct lifetime *, stackptr );
+void lt_remove_use_site(struct lifetime *lt, int block, int iindex);
+void lt_move_use_sites(struct lifetime *from, struct lifetime *to);
+void lt_lifeness_analysis(jitdata *, graphdata *);
 #endif /* _LIFETIMES_H */
 
 /*
index 2ec31e7e02cfcd77a0ccdd56a4067fb92688c451..693798e5de8502da9469c7b818344072d73fa2ac 100644 (file)
@@ -41,8 +41,9 @@
 
 #include "toolbox/bitvector.h"
 
-#include "vm/statistics.h"
-#include "vm/options.h"
+#include "vmcore/statistics.h"
+#include "vmcore/options.h"
+#include "vmcore/method.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/reg.h"
@@ -92,7 +93,6 @@ void lsra_alloc(jitdata *, int *, int,
                                int *);
 int lsra_getmem(struct lifetime *, struct freemem *, int *);
 struct freemem *lsra_getnewmem(int *);
-void lsra_setflags(int *, int);
 
 void lsra(jitdata *jd) {
        methodinfo *m;
@@ -100,14 +100,16 @@ void lsra(jitdata *jd) {
        registerdata *rd;
        lsradata *ls;
        graphdata *gd;
-#if defined(STATISTICS)
+#if defined(ENABLE_STATISTICS)
        int locals_start;
        int i,j;
 #endif 
 #if defined(LSRA_DEBUG_CHECK)
+#if 0
        int b_index;
        stackptr in,out;
        int      ind, outd;
+#endif
 #endif
 
        m = jd->m;
@@ -116,10 +118,11 @@ void lsra(jitdata *jd) {
        ls = jd->ls;
 
 #if defined(LSRA_DEBUG_CHECK)
+#if 0
        b_index = 0;
-       while (b_index < m->basicblockcount ) {
+       while (b_index < jd->basicblockcount ) {
 
-               if (m->basicblocks[b_index].flags >= BBREACHED) {
+               if (jd->basicblocks[b_index].flags >= BBREACHED) {
 
                        in=m->basicblocks[b_index].instack;
                        ind=m->basicblocks[b_index].indepth;
@@ -145,6 +148,7 @@ void lsra(jitdata *jd) {
                        b_index++;
        }
 #endif
+#endif
 
 #if defined(LSRA_DEBUG_CHECK) || defined(LSRA_DEBUG_VERBOSE)
 #if defined(LSRA_DEBUG_VERBOSE)
@@ -166,8 +170,6 @@ void lsra(jitdata *jd) {
 #endif
 
     lsra_init(jd);
-
-       
        gd = lsra_setup(jd);
 
 #if defined(ENABLE_STATISTICS)
@@ -204,8 +206,6 @@ void lsra_init(jitdata *jd)
        /* allocate lifetimes for all Basicblocks */
 
        ls->v_index = -1;
-   
-
 }
 
 graphdata *lsra_setup(jitdata *jd)
@@ -237,12 +237,10 @@ graphdata *lsra_setup(jitdata *jd)
        /* Generate the Control Flow Graph */
        /* Add one for a Basic Block 0 to be inserted, so lateron */
        /* with SSA Parameter initialization is handled right */
-       gd = graph_init(m->basicblockcount + 1);
+       gd = graph_init(jd->basicblockcount + 1);
        graph_make_cfg(jd, gd);
-
        ssa(jd, gd);
-
-       LifenessAnalysis(m, ls, gd);
+       lt_lifeness_analysis(jd, gd);
 
 #ifdef LSRA_DEBUG_VERBOSE
        if (compileverbose) {
@@ -313,18 +311,18 @@ void lsra_reg_setup(jitdata *jd,
 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                                        if (IS_2_WORD_TYPE(md->paramtypes[i].type)) {
                                                int_reg->sav_reg[--int_sav_top] = 
-                                                       rd->argintregs[GET_HIGH_REG(md->params[i].regoff)];
+                                                       GET_HIGH_REG(md->params[i].regoff);
                                                intarg_used[GET_HIGH_REG(md->params[i].regoff)]=true;
                                                /*used -> don't copy later on */
                                                int_reg->sav_reg[--int_sav_top] = 
-                                                       rd->argintregs[GET_LOW_REG(md->params[i].regoff)];
+                                                       GET_LOW_REG(md->params[i].regoff);
                                                intarg_used[GET_LOW_REG(md->params[i].regoff)]=true;
                                                /*used -> don't copy later on */
                                        } else
 #endif
                                        { /* !IS_2_WORD_TYPE(md->paramtypes[i].type */
                                                int_reg->sav_reg[--int_sav_top] = 
-                                                       rd->argintregs[md->params[i].regoff];
+                                                       md->params[i].regoff;
                                                intarg_used[md->params[i].regoff]=true;
                                                /*used -> don't copy later on */
                                        }
@@ -335,7 +333,7 @@ void lsra_reg_setup(jitdata *jd,
                                /* still be used in the method! */
                                else { /* IS_FLT_DBL_TYPE(md->paramtypes[i].type */
                                                flt_reg->sav_reg[--flt_sav_top] = 
-                                                       rd->argfltregs[md->params[i].regoff];
+                                                       md->params[i].regoff;
                                                fltarg_used[md->params[i].regoff]=true;
                                }
 #endif
@@ -347,10 +345,10 @@ void lsra_reg_setup(jitdata *jd,
                /* int_reg->sav_reg; */
                for (i=0; i < INT_ARG_CNT; i++)
                        if (!intarg_used[i])
-                               int_reg->sav_reg[--int_sav_top]=rd->argintregs[i];
+                               int_reg->sav_reg[--int_sav_top]=i;
                for (i=0; i < FLT_ARG_CNT; i++)
                        if (!fltarg_used[i])
-                               flt_reg->sav_reg[--flt_sav_top]=rd->argfltregs[i];
+                               flt_reg->sav_reg[--flt_sav_top]=i;
 
                /* copy temp registers to flt_reg->sav_reg and int_reg->sav_reg */
                for (i=0; i < INT_TMP_CNT; i++)
@@ -368,6 +366,7 @@ void lsra_reg_setup(jitdata *jd,
                /* with Locals as non SAVEDVAR, the used arg[int|flt] as in params */
                /* of the method itself have to be regarded, or mismatch before    */
                /* block 0 with parameter copy could happen! */
+
                argintreguse = max(rd->argintreguse, md->argintreguse);
                argfltreguse = max(rd->argfltreguse, md->argfltreguse);
 
@@ -385,14 +384,23 @@ void lsra_reg_setup(jitdata *jd,
 
                /* copy temp and unused argument registers to flt_reg->tmp_reg and */
                /* int_reg->tmp_reg */
+
                for (i=0; i < INT_TMP_CNT; i++)
                        int_reg->tmp_reg[i]=rd->tmpintregs[i];
+
+               /* quick and dirty patch for the drop of rd->argxxxreg[] - but will */
+               /* work anyhow on i386, !! has to be made "real" for other archs    */
+
                for (j = argintreguse; j < INT_ARG_CNT; j++, i++)
-                       int_reg->tmp_reg[i]=rd->argintregs[j];
+                       int_reg->tmp_reg[i]=j;
                for (i=0; i < FLT_TMP_CNT; i++)
                        flt_reg->tmp_reg[i]=rd->tmpfltregs[i];
+
+               /* quick and dirty patch for the drop of rd->argxxxreg[] - but will */
+               /* work anyhow on i386, !! has to be made "real" for other archs    */
+
                for (j = argfltreguse; j < FLT_ARG_CNT; j++, i++)
-                       flt_reg->tmp_reg[i]=rd->argfltregs[j];
+                       flt_reg->tmp_reg[i]=j;
        }
 
        /* now copy saved registers to flt_reg->sav_reg and int_reg->sav_reg */
@@ -561,6 +569,8 @@ void lsra_main(jitdata *jd)
                printf("Rest RA complete \n");
                printf("Lifetimes after leftt:\n");
                print_lifetimes(jd, ls->lt_mem, ls->lt_mem_count);
+
+               printf("jd->varcount: %i jd->vartop %i\n", jd->varcount, jd->vartop);
        }
 #endif
 }
@@ -570,7 +580,6 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
        int flags,regoff;
        struct lifetime *lt;
        struct freemem *fmem;
-       struct stackslot *n;
        int lt_index;
 #ifdef HAS_4BYTE_STACKSLOT
        struct freemem *fmem_2;
@@ -593,51 +602,29 @@ void lsra_alloc(jitdata *jd, int *lifet, int lifetimecount, int *mem_use)
 #endif
 
        for (lt_index = 0; lt_index < lifetimecount; lt_index ++) {
-               lt = &(ls->lifetime[lifet[lt_index]]);
+               lt = ls->lifetime + lifet[lt_index];
 #ifdef LSRA_MEMORY
                lt->reg=-1;
 #endif
-               if (lt->reg==-1) {
-                       flags=INMEMORY;
+               if (lt->regoff == -1) {
+                       flags = INMEMORY;
 #ifdef HAS_4BYTE_STACKSLOT
                        if (IS_2_WORD_TYPE(lt->type))
-                               regoff=lsra_getmem(lt, fmem_2, mem_use);
+                               regoff = lsra_getmem(lt, fmem_2, mem_use);
                        else
 #endif
-                       regoff=lsra_getmem(lt, fmem, mem_use);
+                       regoff = lsra_getmem(lt, fmem, mem_use);
                } else {
-                       flags=lt->savedvar;
-                       regoff=lt->reg;
-               }
-
-               for (n=lt->local_ss; n!=NULL; n=n->next) {
-                       lsra_setflags( &(n->s->flags), flags);
-                       n->s->regoff=regoff;
-               }
-               if (lt->v_index >= 0) {
-                       if (rd->locals[lt->v_index][lt->type].type>=0) {
-                               rd->locals[lt->v_index][lt->type].flags= flags;
-                               rd->locals[lt->v_index][lt->type].regoff=regoff;
-                       } else { log_text("Type Data mismatch 1\n"); exit(1); }
+                       flags = lt->savedvar;
+                       regoff = lt->regoff;
                }
 
-               lt->reg = regoff;
+               lt->regoff = regoff;
+               VAR(lt->v_index)->vv.regoff = regoff;
+               VAR(lt->v_index)->flags  = flags;
        }
 }
 
-void lsra_setflags(int *flags, int newflags)
-{
-       if ( newflags & INMEMORY)
-               *flags |= INMEMORY;
-       else
-               *flags &= ~INMEMORY;
-       
-       if (newflags & SAVEDVAR)
-               *flags |= SAVEDVAR;
-       else
-               *flags &= ~SAVEDVAR;
-}
-
 int lsra_getmem(struct lifetime *lt, struct freemem *fmem, int *mem_use)
 {
        struct freemem *fm, *p;
@@ -701,7 +688,7 @@ void _lsra_main( jitdata *jd, int *lifet, int lifetimecount,
 
                /* no registers available */
                for (lt_index = 0; lt_index < lifetimecount; lt_index++)
-                       ls->lifetime[lifet[lt_index]].reg = -1;
+                       ls->lifetime[lifet[lt_index]].regoff = -1;
                return;
        }
 
@@ -759,7 +746,7 @@ void _lsra_main( jitdata *jd, int *lifet, int lifetimecount,
                if (reg_index == -1) /* no reg is available anymore... -> spill */
                        spill_at_intervall(jd, lt);
                else {
-                       lt->reg = reg_index;
+                       lt->regoff = reg_index;
                        if (temp)
                                lsra_add_active(lt, ls->active_tmp, &(ls->active_tmp_top));
                        else {
@@ -813,7 +800,7 @@ void _lsra_expire_old_intervalls(jitdata *jd, struct lifetime *lt,
                                reg->sav_reg[reg->sav_top++] = GET_HIGH_REG(active[i]->reg);
                        } else
 #endif
-                               reg->sav_reg[reg->sav_top++] = active[i]->reg;
+                               reg->sav_reg[reg->sav_top++] = active[i]->regoff;
                } else { 
                        /* no leafmethod -> distinguish between temp and saved register */
 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
@@ -829,10 +816,10 @@ void _lsra_expire_old_intervalls(jitdata *jd, struct lifetime *lt,
                                }
                        } else
 #endif
-                       if ( reg->nregdesc[active[i]->reg] == REG_SAV) {
-                                       reg->sav_reg[reg->sav_top++] = active[i]->reg;
+                       if ( reg->nregdesc[active[i]->regoff] == REG_SAV) {
+                                       reg->sav_reg[reg->sav_top++] = active[i]->regoff;
                        } else {
-                                       reg->tmp_reg[reg->tmp_top++] = active[i]->reg;
+                                       reg->tmp_reg[reg->tmp_top++] = active[i]->regoff;
                        }
                }
        }
@@ -856,7 +843,7 @@ void spill_at_intervall(jitdata *jd, struct lifetime *lt )
                _spill_at_intervall(lt, ls->active_sav, &(ls->active_sav_top));
        } else {
                _spill_at_intervall(lt, ls->active_tmp, &(ls->active_tmp_top));
-               if (lt->reg == -1) { /* kein tmp mehr frei gewesen */
+               if (lt->regoff == -1) { /* kein tmp mehr frei gewesen */
                        _spill_at_intervall(lt, ls->active_sav, &(ls->active_sav_top));
                }
        }
@@ -873,7 +860,7 @@ void _spill_at_intervall(struct lifetime *lt, struct lifetime **active,
 #endif /* 0 */
 
        if (*active_top == 0) {
-               lt->reg=-1;
+               lt->regoff = -1;
                return;
        }
        
@@ -907,8 +894,8 @@ void _spill_at_intervall(struct lifetime *lt, struct lifetime **active,
                        return;
 #endif
                
-               lt->reg=active[i]->reg;
-               active[i]->reg=-1;
+               lt->regoff = active[i]->regoff;
+               active[i]->regoff = -1;
 
                (*active_top)--;
                for (j = i; j < *active_top; j++)
@@ -916,7 +903,7 @@ void _spill_at_intervall(struct lifetime *lt, struct lifetime **active,
                
                lsra_add_active(lt, active, active_top);
        } else {
-               lt->reg=-1;
+               lt->regoff = -1;
        }
 }
 
@@ -931,7 +918,6 @@ void lsra_calc_lifetime_length(jitdata *jd)
                   /* 1 INTREG   -> ls->lt_int  */
                   /* 2 FLTREG   -> ls->lt_flt  */
 
-       instruction *iptr;
        lsradata *ls;
 
        ls = jd->ls;
@@ -941,7 +927,7 @@ void lsra_calc_lifetime_length(jitdata *jd)
        for (i=1; i < ls->basicblockcount; i++) {
                if (ls->sorted[i-1] != -1)
                        icount += ls->basicblocks[ls->sorted[i-1]]->icount + 1 + 
-                               ls->max_vars_with_indices;
+                               ls->varcount_with_indices;
                if (ls->sorted[i] != -1)
                        icount_block[i] = icount;
        }
@@ -966,25 +952,9 @@ void lsra_calc_lifetime_length(jitdata *jd)
                        /* i_last_use */
 
                        _LSRA_ASSERT(lt->def != NULL);
-                       _LSRA_ASSERT(lt->use != NULL);
-
-                       /* there are conflicts possible between in and outstacks of */
-                       /* DUP* ICMDs. So extend lifetime of outstacks by one */
-                       if (lt->i_first_def >= 0 && (lt->bb_first_def != 0)) {
-                               iptr = ls->basicblocks[ls->sorted[lt->bb_first_def]]->iinstr + 
-                                       lt->i_first_def;
-                               switch (iptr->opc) {
-/*                             case ICMD_DUP:  */
-                               case ICMD_DUP2:
-                               case ICMD_DUP_X1:
-                               case ICMD_DUP_X2:
-                               case ICMD_DUP2_X1:
-                               case ICMD_DUP2_X2:
-                               case ICMD_SWAP:
-/*                                     _LSRA_ASSERT(lt->i_first_def != 0); */
-                                       lt->i_first_def--;
-                               }
-                       }
+                       /*                      _LSRA_ASSERT(lt->use != NULL);*/
+                       if (lt->use == NULL)
+                               lt->use = lt->def;
 
 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
                        /* prevent conflicts between lifetimes of type long by increasing */
@@ -1000,7 +970,7 @@ void lsra_calc_lifetime_length(jitdata *jd)
 
 /* distribute lifetimes to lt_int, lt_flt and lt_mem */
 
-                       lt->reg = -1;
+                       lt->regoff = -1;
 
                        switch (lt->type) {
                        case TYPE_LNG:
@@ -1052,7 +1022,15 @@ void lsra_calc_lifetime_length(jitdata *jd)
                        lt->i_start = icount_block[lt->bb_first_def] + lt->i_first_def;
 
                        if (lt->bb_last_use == -1) {
-                               printf("--------- Warning: variable not used! --------------------vi: %i start: %i end: %i\n", lt->v_index, lt->i_start, lt->i_end);
+                               /* unused Vars are not regarded by lifeness_analysis! */
+                               _LSRA_ASSERT(lt->def != NULL)
+                               _LSRA_ASSERT(lt->def->next == NULL)
+                               
+                               if (compileverbose) {
+                                       printf("--------- Warning: variable not used! ---------");
+                                       printf("vi: %i start: %i end: %i\n", lt->v_index, 
+                                                  lt->i_start, lt->i_end);
+                               }
                                lt->bb_last_use = lt->bb_first_def;
                                lt->i_last_use = lt->i_first_def;
                        }
@@ -1078,7 +1056,6 @@ void print_lifetimes(jitdata *jd, int *lt, int lifetimecount)
 {
        struct lifetime *n;
        int lt_index;
-       int type,flags,regoff,varkind;
        lsradata *ls;
        registerdata *rd;
 
@@ -1086,22 +1063,8 @@ void print_lifetimes(jitdata *jd, int *lt, int lifetimecount)
        ls = jd->ls;
 
        for (lt_index = 0; lt_index < lifetimecount; lt_index++) {
-               n = &(ls->lifetime[lt[lt_index]]);
-               if (n->v_index < 0) { /* stackslot */
-                       type = n->local_ss->s->type;
-                       flags=n->local_ss->s->flags;
-                       regoff=n->local_ss->s->regoff;
-                       varkind=n->local_ss->s->varkind;
-               } else { /* local var */
-                       if (rd->locals[n->v_index][n->type].type>=0) {
-                               type = rd->locals[n->v_index][n->type].type;
-                               flags=rd->locals[n->v_index][n->type].flags;
-                               regoff=rd->locals[n->v_index][n->type].regoff;
-                               varkind=-1;
-                       } else 
-                               { log_text("Type Data mismatch 3\n"); assert(0); }
-               }
-               printf("i_Start: %3i(%3i,%3i) i_stop: %3i(%3i,%3i) reg: %3i VI: %3i type: %3i flags: %3i varkind: %3i usage: %3li ltflags: %xi \n",n->i_start, ls->sorted[n->bb_first_def], n->i_first_def,n->i_end, ls->sorted[n->bb_last_use], n->i_last_use,regoff,n->v_index,type,flags, varkind, n->usagecount, n->flags);
+               n = ls->lifetime + lt[lt_index];
+               printf("i_Start: %3i(%3i,%3i) i_stop: %3i(%3i,%3i) reg: %3i VI: %3i type: %3i flags: %3i usage: %3li ltflags: %xi \n",n->i_start, ls->sorted[n->bb_first_def], n->i_first_def,n->i_end, ls->sorted[n->bb_last_use], n->i_last_use,n->regoff,n->v_index,n->type,n->flags, n->usagecount, n->flags);
        }
        printf( "%3i Lifetimes printed \n",lt_index);
 }
@@ -1110,7 +1073,6 @@ void print_all_lifetimes(jitdata *jd)
 {
        struct lifetime *n;
        int lt_index;
-       int type,flags,regoff,varkind;
        lsradata *ls;
        registerdata *rd;
 
@@ -1120,21 +1082,7 @@ void print_all_lifetimes(jitdata *jd)
        for (lt_index = 0; lt_index < ls->lifetimecount; lt_index++) {
                n = &(ls->lifetime[lt_index]);
                if (n->type != -1) {
-                       if (n->v_index < 0) { /* stackslot */
-                               type = n->local_ss->s->type;
-                               flags=n->local_ss->s->flags;
-                               regoff=n->local_ss->s->regoff;
-                               varkind=n->local_ss->s->varkind;
-                       } else { /* local var */
-                               if (rd->locals[n->v_index][n->type].type>=0) {
-                                       type = rd->locals[n->v_index][n->type].type;
-                                       flags=rd->locals[n->v_index][n->type].flags;
-                                       regoff=rd->locals[n->v_index][n->type].regoff;
-                                       varkind=-1;
-                               } else 
-                                       { log_text("Type Data mismatch 3\n"); assert(0); }
-                       }
-                       printf("i_Start: %3i(%3i,%3i) i_stop: %3i(%3i,%3i) VI: %3i type: %3i flags: %3i varkind: %3i usage: %3li ltflags: %xi \n",n->i_start, ls->sorted[n->bb_first_def], n->i_first_def,n->i_end, ls->sorted[n->bb_last_use], n->i_last_use,n->v_index,type,flags, varkind, n->usagecount, n->flags);
+                       printf("i_Start: %3i(%3i,%3i) i_stop: %3i(%3i,%3i) VI: %3i type: %3i flags: %3i usage: %3li ltflags: %xi \n",n->i_start, ls->sorted[n->bb_first_def], n->i_first_def,n->i_end, ls->sorted[n->bb_last_use], n->i_last_use,n->v_index,n->type,n->flags, n->usagecount, n->flags);
                }
        }
        printf( "%3i Lifetimes printed \n",lt_index);
index 834ce9f87647891eec3ec6a26680a55195979b17..d758139f14d4f1dea5c98d1fbba2c9db9fa9cac5 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "toolbox/bitvector.h"
 
+
 #if !defined(NDEBUG)
 # include <assert.h>
 # define LSRA_DEBUG_CHECK
@@ -86,10 +87,10 @@ struct lifetime {
        int v_index;           /* local variable index or negative for stackslots */
        int type;                   /* TYPE_XXX or -1 for unused lifetime */
        long usagecount;            /* number of references*/
-       int reg;                    /* regoffset allocated by lsra*/
+       int regoff;                    /* regoffset allocated by lsra*/
        int savedvar;
        int flags;
-       struct stackslot *local_ss; /* Stackslots for this Lifetime or NULL ( ==  */
+       /* struct stackslot *local_ss; */ /* Stackslots for this Lifetime or NULL ( ==  */
                                 /* "pure" Local Var) */
        int bb_last_use;
        int i_last_use;
@@ -107,11 +108,13 @@ struct l_loop {
        int nesting;
 };
 
+/*
 struct stackslot {
        stackptr s;
        int bb;
        struct stackslot *next;
 };
+*/
 
 struct lsra_register {
        int *sav_reg;
@@ -149,6 +152,26 @@ struct igraph {
 
 
 struct lsradata {
+       /* int *var; */           /* unused entries are set to UNUSED    */
+                           /* maps to jd->vars array */
+       int varcount;       /* size of vars array */
+       int ssavarcount;    /* ls->vars[0..ssavarcount[ are all locals and iovars */
+                           /* they are regarded for ssa renaming */
+                           /* the rest (ls->vars[ssavarcount..varcount[ are      */
+                           /* TEMP or PREALLOC vars with just on definition and  */
+                           /* use within one basicblock -> not of interest for   */
+                           /* ssa renaming procedures */
+       int vartop;         /* next free var */
+       int varcount_with_indices;
+       int *new_varindex;  /* new_varindex[0..jd->varcount[ points to the new    */
+                           /* unique index of ls->vars(maps jd->vars to ls->vars)*/
+
+       int *var_0;        /* [0..ls->varcount]  */
+                          /* var_0[a] with a in [0..ls->varcount[ holds the */
+                          /* index of La,0 */
+                          /* var_0[ls->varcount] holds the number of vars with */
+                          /*indices */
+
        int *sorted;         /* BB sorted in reverse post order */
        int *sorted_rev;     /* BB reverse lookup of sorted */
 
@@ -157,9 +180,6 @@ struct lsradata {
 
        long *nesting;    /* Nesting level of BB*/
 
-       int maxlifetimes; /* copy from methodinfo to prevent passing methodinfo   */
-                      /* as parameter */
-
        struct lifetime *lifetime; /* array of lifetimes */
        int lifetimecount;         /* number of lifetimes */
        int *lt_used;              /* index to lifetimearray for used lifetimes   */
@@ -180,7 +200,7 @@ struct lsradata {
 
        /* SSA fields */
        bitvector *var_def; /* LocalVar Definition Bitvector [0..ls->bbcount]  */
-                      /* Bitvector holds ls->max_vars Bits              */
+                           /* Bitvector holds ls->max_vars Bits               */
        bitvector *use_sites; /* LocalVar Use Bitvector[0..ls->maxvars] */
        int **num_var_use; /* count of var_use[bb][var_index] */
        int **var; /* [0..cd->maxlocal+cd->maxstack[[0..4] */
index 898d8710a60473422dea1e450fd6e96c7fc5013f..9f0a43bf9681f9dd09a76f3b94e053f0577c5a30 100644 (file)
@@ -38,8 +38,6 @@
 
 #include "threads/threads-common.h"
 
-#include "threads/native/threads.h"
-
 #include "vm/builtin.h"
 #include "vm/stringlocal.h"
 
 #include "vmcore/options.h"
 
 
-/* global variables ***********************************************************/
-
-#if defined(ENABLE_THREADS)
-static threadobject *thread_profile;
-#endif
-
-
 /* profile_init ****************************************************************
 
    Initializes the profile global lock.
@@ -103,66 +94,71 @@ static void profile_thread(void)
                threads_sleep(0, nanos);
                runs++;
 
-               /* iterate over all started threads */
+               /* lock the threads table */
 
-               t = mainthreadobj;
+               threads_table_lock();
+
+               /* iterate over all started threads */
 
-               do {
+               for (t = threads_table_first(); t != NULL; t = threads_table_next(t)) {
                        /* is this a Java thread? */
 
-                       if (t->flags & THREAD_FLAG_JAVA) {
-                               /* send SIGUSR2 to thread to get the current PC */
+                       if (!(t->flags & THREAD_FLAG_JAVA))
+                               continue;
 
-                               pthread_kill(t->tid, SIGUSR2);
+                       /* send SIGUSR2 to thread to get the current PC */
 
-                               /* the thread object now contains the current thread PC */
+                       pthread_kill(t->tid, SIGUSR2);
 
-                               pc = t->pc;
+                       /* the thread object now contains the current thread PC */
 
-                               /* get the PV for the current PC */
+                       pc = t->pc;
 
-                               pv = codegen_get_pv_from_pc_nocheck(pc);
+                       /* get the PV for the current PC */
 
-                               /* get methodinfo pointer from data segment */
+                       pv = codegen_get_pv_from_pc_nocheck(pc);
 
-                               if (pv == NULL) {
-                                       misses++;
-                               }
-                               else {
-                                       code = *((codeinfo **) (pv + CodeinfoPointer));
+                       /* get methodinfo pointer from data segment */
 
-                                       /* For asm_vm_call_method the codeinfo pointer is
-                                          NULL (which is also in the method tree). */
+                       if (pv == NULL) {
+                               misses++;
+                       }
+                       else {
+                               code = *((codeinfo **) (pv + CodeinfoPointer));
 
-                                       if (code != NULL) {
-                                               m = code->m;
+                               /* For asm_vm_call_method the codeinfo pointer is NULL
+                                  (which is also in the method tree). */
 
-                                               /* native methods are never recompiled */
+                               if (code != NULL) {
+                                       m = code->m;
 
-                                               if (!(m->flags & ACC_NATIVE)) {
-                                                       /* increase the method incovation counter */
+                                       /* native methods are never recompiled */
 
-                                                       code->frequency++;
-                                                       hits++;
+                                       if (!(m->flags & ACC_NATIVE)) {
+                                               /* increase the method incovation counter */
 
-                                                       if (code->frequency > 500) {
-                                                               /* clear frequency count before
-                                                                  recompilation */
+                                               code->frequency++;
+                                               hits++;
 
-                                                               code->frequency = 0;
+                                               if (code->frequency > 500) {
+                                                       /* clear frequency count before
+                                                          recompilation */
 
-                                                               /* add this method to the method list
-                                                                  and start recompilation */
+                                                       code->frequency = 0;
 
-                                                               recompile_queue_method(m);
-                                                       }
+                                                       /* add this method to the method list and
+                                                          start recompilation */
+
+                                                       recompile_queue_method(m);
                                                }
                                        }
                                }
                        }
+               }
 
-                       t = t->next;
-               } while ((t != NULL) && (t != mainthreadobj));
+               /* unlock the threads table */
+
+               threads_table_unlock();
        }
 }
 #endif
@@ -181,15 +177,9 @@ bool profile_start_thread(void)
 
        name = utf_new_char("Profiling Sampler");
 
-       thread_profile = threads_create_thread(name);
-
-       if (thread_profile == NULL)
+       if (!threads_thread_start_internal(name, profile_thread))
                return false;
 
-       /* actually start the profile sampling thread */
-
-       threads_start_thread(thread_profile, profile_thread);
-
        /* everything's ok */
 
        return true;
index fe596c1d84d9a02b872917766af1501927fa24a8..bca3ef36cf733474b14c786702962ae98763bda2 100644 (file)
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/threads-common.h"
-
-# include "threads/native/lock.h"
-# include "threads/native/threads.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
 
 #include "toolbox/list.h"
 
@@ -59,7 +55,6 @@
 
 /* global variables ***********************************************************/
 
-static threadobject      *thread_recompile;
 static java_objectheader *lock_thread_recompile;
 static list_t            *list_recompile_methods;
 
@@ -221,15 +216,9 @@ bool recompile_start_thread(void)
 
        name = utf_new_char("Recompiler");
 
-       thread_recompile = threads_create_thread(name);
-
-       if (thread_recompile == NULL)
+       if (!threads_thread_start_internal(name, recompile_thread))
                return false;
 
-       /* actually start the recompilation thread */
-
-       threads_start_thread(thread_recompile, recompile_thread);
-
        /* everything's ok */
 
        return true;
index e92defb388c0818adfe35d235833d2589dae5027..a842537c1f2a7b112fae171f4efe477eb0800c98 100644 (file)
 #include "toolbox/bitvector.h"
 #include "toolbox/worklist.h"
 
+#include "vm/builtin.h"
+
+#include "vm/jit/jit.h" /* icmd_table */
+
 #include "vm/jit/optimizing/dominators.h"
 #include "vm/jit/optimizing/graph.h"
 #include "vm/jit/optimizing/lifetimes.h"
 #include "vm/jit/optimizing/ssa.h"
 
 #if defined(SSA_DEBUG_VERBOSE)
-#include "vm/options.h"   /* compileverbose */
-#include "vm/jit/jit.h"          /* icmd_table */
+#include "vmcore/options.h"   /* compileverbose */
 #endif
 
 /* function prototypes */
-void dead_code_elimination(methodinfo *m, registerdata *rd, lsradata *ls,
-                                                  graphdata *gd);
-void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
-                                         graphdata *gd);
-void replace_use_sites( lsradata *ls, graphdata *gd, struct lifetime *lt,
-                                               int new_v_index, worklist *W);
-void ssa_place_phi_functions(codegendata *cd, lsradata *ls, graphdata *gd,
-                                                        dominatordata *dd);
-void ssa_Rename_init(methodinfo *m, codegendata *cd, lsradata *ls,
-                                        graphdata *gd);
-void ssa_Rename(methodinfo *m, codegendata *cd, registerdata *rd, lsradata *ls, 
-                               graphdata *gd, dominatordata *dd);
-void ssa_Rename_(codegendata *cd, lsradata *ls, graphdata *gd, 
-                                dominatordata *dd, int n);
+void ssa_set_local_def(lsradata *, int , int);
+void ssa_set_interface(jitdata *, basicblock *, s4 *);
+
+void dead_code_elimination(jitdata *jd, graphdata *gd);
+void copy_propagation(jitdata *jd, graphdata *gd);
+void ssa_replace_use_sites(jitdata *, graphdata *, struct lifetime *,
+                                               int , worklist *);
+void ssa_place_phi_functions(jitdata *jd, graphdata *gd, dominatordata *dd);
+void ssa_rename_init(jitdata *jd, graphdata *gd);
+void ssa_rename(jitdata *jd, graphdata *gd, dominatordata *dd);
+void ssa_rename_(jitdata *jd,  graphdata *gd, dominatordata *dd, int n);
+
+void ssa_set_def(lsradata *, int , int );
+void ssa_set_local_def(lsradata *, int , int );
+void ssa_set_iovar(lsradata *, s4 , int , s4 *);
+void ssa_set_interface(jitdata *, basicblock *, s4 *);
+
+void ssa_generate_phi_moves(jitdata *, graphdata *);
+int ssa_rename_def_(lsradata *ls, int a);
 
 #ifdef SSA_DEBUG_VERBOSE
-void ssa_print_trees(methodinfo *m, codegendata *cd, lsradata *ls,
-                                        graphdata *gd, dominatordata *dd);
+void ssa_print_trees(jitdata *jd, graphdata *gd, dominatordata *dd);
 void ssa_print_lt(lsradata *ls);
+void ssa_show_variable(jitdata *jd, int index, varinfo *v, int stage);
+void ssa_print_phi(lsradata *, graphdata *);
 #endif
-/*********************************************************
-Data Collection (Use/Definition) while analyze_stack:
-Basic Block indices of definition are needed for generation
-of the phi Functions.
-
-ssa_set_local_def
-ssa_set_interface
-ssa_set_use
-
-These two functions use the internal Helpers:
-ssa_set_def
-ssa_set_interface_
-*********************************************************/
-void ssa_set_use(lsradata *ls, int b_index, int local_index, int type) {
-       /* just count uses to determine the needed max size for use def */
-       /* data structures */
-       ls->uses++;
-}
 
-void ssa_set_def(lsradata *ls, int b_index, int var_index) {
+/* ssa ************************************************************************
 
-       /* b_index + 1 to leave space for the param init block 0 */
-       bv_set_bit(ls->var_def[b_index + 1], var_index);
-       /* count number of defs for every var since SSA */
-       /* will create a new var for every definition */
-       ls->num_defs[var_index]++;
-}
+SSA main procedure:
 
-void ssa_set_local_def(lsradata *ls, int b_index, int local_index, int type) {
+******************************************************************************/
 
-       if (ls->var[local_index][type] == -1) {
-               /* New Local Variable encountered -> create a new unique index */
-               ls->var[local_index][type] = ls->max_vars;
-               ls->var_to_index[ls->max_vars] = ls->max_locals++;
-               ls->max_vars++;
-#ifdef SSA_DEBUG_VERBOSE
-               if (compileverbose)
-                       printf("Local %3i,%3i -> Var %3i\n",local_index,type,ls->max_vars-1);
-#endif
-       }
+void ssa(jitdata *jd, graphdata *gd) {
+       struct dominatordata *dd;
+       lsradata *ls;
 
-       ssa_set_def(ls, b_index, ls->var[local_index][type]);
-}
+       ls = jd->ls;
 
-void ssa_set_interface_(codegendata *cd, lsradata *ls, basicblock *bptr,
-                                  stackptr s, int depth) {
-       int var_index;
+       dd = compute_Dominators(gd, ls->basicblockcount);
+       computeDF(gd, dd, ls->basicblockcount, 0);
 
-       var_index = depth + jd->maxlocals;
-       if (ls->var[var_index][s->type] == -1) {
-               /* New Interface Stackslot encountered -> create a new unique index */
-               ls->var[var_index][s->type] = ls->max_vars;
-               ls->var_to_index[ls->max_vars] = ls->max_interfaces--;
-               ls->max_vars++;
+       ssa_place_phi_functions(jd, gd, dd);
+       ssa_rename(jd, gd, dd);
 #ifdef SSA_DEBUG_VERBOSE
-               if (compileverbose)
-                       printf("Interface SS %3i,%3i -> Var %3i\n",bptr->nr+1,depth,ls->max_vars-1);
+       if (compileverbose) {
+               printf("Phi before Cleanup\n");
+               ssa_print_phi(ls, gd);
+               ssa_print_lt(ls);
+       }
 #endif
+       lt_scanlifetimes(jd, gd, dd);
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
+               ssa_print_lt(ls);
        }
-       ssa_set_def(ls, bptr->nr, ls->var[var_index][s->type]);
-}
+#endif
+/*     dead_code_elimination(jd, gd); */
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
+               printf("Phi after dead code elemination\n");
+               ssa_print_phi(ls, gd);
+               ssa_print_lt(ls);
+       }
+#endif
+/*     copy_propagation(jd, gd); */
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
+               printf("Phi after copy propagation\n");
+               ssa_print_phi(ls, gd);
+               ssa_print_lt(ls);
+       }
+#endif
 
-void ssa_set_interface(codegendata *cd, lsradata *ls, basicblock *bptr) {
-       stackptr out, in;
-       int in_d, out_d;
+       ssa_generate_phi_moves(jd, gd);
+       transform_BB(jd, gd);
 
-       out = bptr->outstack;
-       in = bptr->instack;
-       in_d = bptr->indepth;
-       out_d = bptr->outdepth;
 
-       /* ignore top Stackelement of instack in case of EXH or SBR blocks */
-       /* These are no Interface stackslots! */
-       if ((bptr->type == BBTYPE_EXH) ||
-               (bptr->type == BBTYPE_SBR)) {
-               in_d--;
-               in = in->prev;
-       }
+#ifdef SSA_DEBUG_CHECK
+       {
+               int i, j, pred, in_d, out_d;
+               graphiterator iter_pred;
+               s4 *in, *out;
+               bool phi_define;
+               methodinfo *m;
 
-       for(;(in_d > out_d); in_d--, in = in->prev);
+               m = jd->m;
 
-       while((out != NULL)) {
-               if (in_d == out_d) {
-                       if (in != out) {
-                               /* out interface stackslot is defined in this basic block */
-                               ssa_set_interface_(cd, ls, bptr, out, out_d - 1);
+               for(i = 0; i < ls->basicblockcount; i++) {
+                       if (ls->basicblocks[i]->indepth != 0) {
+                               pred = graph_get_first_predecessor(gd, i, &iter_pred);
+                               for (; (pred != -1); pred = graph_get_next(&iter_pred)) {
+                                       in_d = ls->basicblocks[i]->indepth - 1;
+                                       in = ls->basicblocks[i]->invars;
+                                       for (; in_d >= 0; in_d--) {
+                                               phi_define = false;
+                                               for (j = 0; (!phi_define) && (j<ls->ssavarcount); j++) {
+                                                       if (ls->phi[i][j] != NULL)
+                                                               if (ls->phi[i][j][0] == in[in_d])
+                                                                       phi_define = true;
+                                               }
+                                               if (!phi_define) {
+                                                       /* in not defined in phi function -> check with */
+                                                       /* outstack(s)  of predecessor(s) */
+                                                       out_d = ls->basicblocks[pred]->outdepth - 1;
+                                                       out = ls->basicblocks[pred]->outvars;
+                                                       _SSA_ASSERT(out_d >= in_d);
+                                                       for(; out_d > in_d; out_d--);
+                                                       if ((in[in_d] != out[out_d]) || 
+                                                       (VAR(in[in_d])->flags != VAR(out[out_d])->flags)) {
+                                                               printf("Method: %s %s\n",
+                                                                          m->class->name->text, m->name->text);
+                                                                       printf("Error: Stack Varnum Mismatch BBin %3i BBout %3i Stackdepth %3i\n", i, pred, in_d);
+                                                               if (compileverbose)
+                                                                       printf("Error: Stack Varnum Mismatch BBin %3i BBout %3i Stackdepth %3i\n", i, pred, in_d);
+/*                                                             else */
+/*                                                                     _SSA_ASSERT(0); */
+                                                       }
+                                               }
+                                       }
+                               }
                        }
-                       out = out->prev;
-                       out_d--;
-                       in = in->prev;
-                       in_d--;
-               } else if (in_d < out_d ) {
-                       /* out interface stackslot is defined in this basic block */
-                       ssa_set_interface_(cd, ls, bptr, out, out_d - 1);
-                       out = out->prev;
-                       out_d--;
                }
        }
+
+#endif
+
+
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose)
+               ssa_print_trees(jd, gd, dd);
+#endif
 }
 
-/*********************************************************************
-Initialise needed Data structures
-*********************************************************************/
+/* ssa_init *******************************************************************
+
+Initialise data structures for ssa
+
+IOVARS of same stackdepth and same type are coalesced:
+interface_map[ 5 * stackdepth + type ] = new_varindex with
+0 <= new_varindex < ls->ssavarcount
+
+TODO: check if coalescing of IOVARS of same stackdepth and type only of adjacent
+basic blocks could decrease the number of phi functions and so improve ssa 
+analysis performance!
+
+All LOCALVARS and IOVARS get a new unique varindex:
+ls->new_varindex[0..jd->varcount[ = new_varindex with
+0 <= new_varindex < ls->ssavarcount
+
+The jd->varcount bits long bitvectors ls->var_def[0..jd->basicblockindex+1[
+ are set  to the definitions of LOCALVARS and IOVARS. (So the only the first 
+ls->ssavarcount bits of each of these vectors contain valid data, but 
+ls->ssavarcount is computed at the same time as the definitons are stored.)
+
+The basic block number used as index for the bitvector array ls->var_def is 
+already shifted by one to make space for the new basic block 0 for parameter
+initialization.
+
+******************************************************************************/
 
 void ssa_init(jitdata *jd) {
-       int  p, t;
-       methoddesc *md;
-       int i, b_index, len;
-       int lifetimes;
-       stackptr src, dst, tmp;
+       int         p, t, v;
+       methoddesc  *md;
+       int         i, l, b_index, len;
        instruction *iptr;
        basicblock  *bptr;
+       s4          *interface_map; /* holds an new unique index for every used  */
+                                   /* basic block inoutvar described by a dupel */
+                                /*(depth,type). Used to coalesce the inoutvars*/
+       methodinfo   *m;
+       lsradata     *ls;
+       builtintable_entry *bte;
 
-       methodinfo *m;
-       codegendata *cd;
-       registerdata *rd;
-       lsradata *ls;
-
-       m = jd->m;
-       cd = jd->cd;
-       rd = jd->rd;
        ls = jd->ls;
+       m = jd->m;
        md = m->parseddesc;
 
+
 #if defined(SSA_DEBUG_CHECK) || defined(SSA_DEBUG_VERBOSE)
-#if defined(SSA_DEBUG_VERBOSE)
+# if defined(SSA_DEBUG_VERBOSE)
        if (compileverbose) {
                printf("%s %s ",m->class->name->text, m->name->text);
                if (jd->isleafmethod)
                        printf("**Leafmethod**");
                printf("\n");
        }
-#endif
-       if (strcmp(m->class->name->text,"java/util/Properties")==0)
-               if (strcmp(m->name->text,"load")==0)
-#if defined(SSA_DEBUG_VERBOSE)
+# endif
+       if (strcmp(m->class->name->text,"spec/benchmarks/_213_javac/Parser")==0)
+               if (strcmp(m->name->text,"parseTerm")==0)
+# if defined(SSA_DEBUG_VERBOSE)
                        if (compileverbose) 
                                printf("12-------------------12\n");
-#else
+# else
                { int dummy=1; dummy++; }
-#endif
+# endif
 #endif
 
 #ifdef SSA_DEBUG_VERBOSE
     if (compileverbose) 
-               printf("ssa_init: basicblockcount %3i maxlocals %3i\n",
-                          m->basicblockcount, jd->maxlocals);
+               printf("ssa_init: basicblockcount %3i localcount %3i\n",
+                          jd->basicblockcount, jd->localcount);
 #endif
-       ls->num_defs = DMNEW(int, jd->maxlocals * 5 + cd->maxstack * 5);
-       ls->var_to_index = DMNEW(int, jd->maxlocals * 5 + cd->maxstack * 5);
-       ls->var = DMNEW(int *, jd->maxlocals + cd->maxstack);
-       t = 0;
-       for(p = 0; p < jd->maxlocals + cd->maxstack; p++) {
-               ls->var[p] = DMNEW(int, 5);
-               for(i = 0; i < 5; i++) {
-                       ls->var[p][i] = -1;
-                       ls->num_defs[t++] = 0;
-               }
+
+       /* As first step all definitions of local variables and in/out vars are */
+       /* gathered. in/outvars are coalesced for same type and depth           */
+       /* "normal" tempvars (just living within one basicblock are) ignored    */
+
+       /* ls->var holds the index to jd->vars  */
+
+       ls->num_defs = DMNEW(int, jd->varcount);
+       ls->new_varindex = DMNEW(int , jd->varcount);
+
+       for(p = 0; p < jd->varcount; p++) {
+               ls->num_defs[p] = 0;
+               ls->new_varindex[p] = UNUSED;
        }
+
        /* init Var Definition bitvectors */
-       ls->var_def = DMNEW(int *, m->basicblockcount + 1);
-       for(i = 0; i <= m->basicblockcount; i++) {
-               ls->var_def[i] =  bv_new(jd->maxlocals * 5 + cd->maxstack * 5);
+
+       ls->var_def = DMNEW(int *, jd->basicblockcount + 1);
+       for(i = 0; i < jd->basicblockcount + 1; i++) {
+               ls->var_def[i] =  bv_new(jd->varcount);
        }
-       ls->uses = 0;
-       ls->max_vars = 0;    /* no Vars seen till now */
-                            /* A new Var Index will be created by SSA      */
-                            /* since locals[Index][Type] is a quite sparse array */
-                            /* and locals will be renamed anyway by SSA          */
-       ls->max_locals = 0;  /* unique index for every local_var/type pair*/
-       ls->max_interfaces = -1; /* unique index for every interface/type pair*/
-                                /* interfaces are < 0, locals > 0 */
+
+       ls->ssavarcount = 0;
+
        /* Add parameters first in right order, so the new local indices */
        /* 0..p will correspond to "their" parameters */
        /* They get defined at the artificial Block 0, the real method bbs will be*/
        /* moved to start at block 1 */
-       for (p = 0, i = 0; p < md->paramcount; p++) {
-               t = md->paramtypes[p].type;
 
-               ssa_set_local_def(ls, -1, i, t);
-               i++;
+       /* don't look at already eliminated (not used) parameters (locals) */
+
+       for (p = 0, l = 0; p < md->paramcount; p++) {
+               t = md->paramtypes[p].type;
+               i = jd->local_map[l * 5 + t];
+               l++;
                if (IS_2_WORD_TYPE(t))    /* increment local counter a second time  */
-                       i++;                  /* for 2 word types */
+                       l++;                  /* for 2 word types */
+               if (i == UNUSED)
+                       continue;
+               ssa_set_local_def(ls, -1, i);
        }
 
-       lifetimes = 0;
-       bptr = m->basicblocks;
+       _SSA_ASSERT(ls->ssavarcount < jd->varcount);
+
+       /* coalesce bb in/out vars */
+
+       interface_map = DMNEW(s4, jd->stackcount * 5);
+       for(i = 0; i < jd->stackcount * 5; i++)
+               interface_map[i] = UNUSED;
+
+       bptr = jd->basicblocks;
 
        for(; bptr != NULL; bptr = bptr->next) {
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose)
+               printf("ssa_init: BB %3i flags %3x\n",bptr->nr, bptr->flags);
+#endif
                if (bptr->flags >= BBREACHED) {
+
                        /* 'valid' Basic Block */
+
                        b_index = bptr->nr;
 
-                       /* Scan Number of Stack Lifetimes */
-                       lifetimes += m->basicblocks[b_index].indepth;
+                       len = bptr->icount;
+                       iptr = bptr->iinstr;
+                       ssa_set_interface(jd, bptr, interface_map);
 
-                       dst = m->basicblocks[b_index].instack;
-                       len = m->basicblocks[b_index].icount;
-                       iptr = m->basicblocks[b_index].iinstr;
-                       for (;len>0; len--, iptr++) {
-                               src = dst;
-                               dst = iptr->dst;
-                               
-                               /* Reset "leftover" LOCALVAR stackslots */
-                               switch(iptr->opc) {
-                               case ICMD_DUP:
-                                       lifetimes +=1;
-                                       if (dst->varkind != ARGVAR)
-                                               dst->varkind = TEMPVAR;
-                               case ICMD_SWAP:
-                               case ICMD_DUP2:
-                                       lifetimes += 2;
-                                       for(i=0, tmp = dst; i < 2; i++, tmp = tmp->prev)
-                                               if (tmp->varkind != ARGVAR)
-                                                       tmp->varkind = TEMPVAR;
-                                       break;
-                               case ICMD_DUP_X1:
-                                       lifetimes += 3;
-                                       for(i=0, tmp = dst; i < 3; i++, tmp = tmp->prev)
-                                               if (tmp->varkind != ARGVAR)
-                                                       tmp->varkind = TEMPVAR;
-                                       break;
-                               case ICMD_DUP2_X1:
-                                       lifetimes += 5;
-                                       for(i=0, tmp = dst; i < 5; i++, tmp = tmp->prev)
-                                               if (tmp->varkind != ARGVAR)
-                                                       tmp->varkind = TEMPVAR;
-                                       break;
-                               case ICMD_DUP_X2:
-                                       lifetimes += 4;
-                                       for(i=0, tmp = dst; i < 4; i++, tmp = tmp->prev)
-                                               if (tmp->varkind != ARGVAR)
-                                                       tmp->varkind = TEMPVAR;
-                                       break;
-                               case ICMD_DUP2_X2:
-                                       lifetimes += 6;
-                                       for(i=0, tmp = dst; i < 6; i++, tmp = tmp->prev)
-                                               if (tmp->varkind != ARGVAR)
-                                                       tmp->varkind = TEMPVAR;
-                                       break;
+                       /* !!!!!!!!! not true for now !!!!!!!!! */
+                       /* All baseline optimizations from stack.c are turned off for */
+                       /* SSA! */
 
-                               case ICMD_ILOAD:
-                               case ICMD_LLOAD:
-                               case ICMD_FLOAD:
-                               case ICMD_DLOAD:
-                               case ICMD_ALOAD:
-                                       if (( dst != NULL) && (src != dst))
-                                               lifetimes++;
-                                       dst->varkind = TEMPVAR;
-                                       if (dst->varnum < 0)
-                                               dst->varnum = 0;
-                                       ssa_set_use(ls, b_index, iptr->op1,
-                                                               iptr->opc - ICMD_ILOAD);
-                                       break;
-                                       
-                               case ICMD_IINC:
-                                       if (( dst != NULL) && (src != dst))
-                                               lifetimes++;
-                                       /* For SSA IINC has to be handled as a seperate LOAD */
-                                       /* and STORE. The target local index is held in      */
-                                       /* val._i.op1_t, The immediate val.i is held in     */
-                                       /* val._i.i */
-                                       {
-                                               int v;
-                                               v = iptr->val.i;
-                                               iptr->val._i.op1_t = iptr->op1;
-                                               iptr->val._i.i     = v;
-                                       }
+                       for (; len > 0; len--, iptr++) {
 
-                                       ssa_set_use(ls, b_index, iptr->op1,TYPE_INT);
-                                       ssa_set_local_def(ls, b_index,
-                                                                         iptr->val._i.op1_t, TYPE_INT);
-                                       break;
+                               /* Look for definitions (iptr->dst). INVOKE and BUILTIN have */
+                               /* an optional dst - so they to be checked first */
 
-                               case ICMD_ISTORE:
-                               case ICMD_LSTORE:
-                               case ICMD_FSTORE:
-                               case ICMD_DSTORE:
-                               case ICMD_ASTORE:
-                                       src->varkind = TEMPVAR;
-                                       if (src->varnum < 0)
-                                               src->varnum =0;
-                                       ssa_set_local_def(ls, b_index, iptr->op1, 
-                                                                         iptr->opc - ICMD_ISTORE);
-                                       break;
+                               v = UNUSED;
+                               if (icmd_table[iptr->opc].dataflow == DF_INVOKE) {
+                                               INSTRUCTION_GET_METHODDESC(iptr,md);
+                                               if (md->returntype.type != TYPE_VOID)
+                                                       v = iptr->dst.varindex;
+                               }
+                               else if (icmd_table[iptr->opc].dataflow == DF_BUILTIN) {
+                                               bte = iptr->sx.s23.s3.bte;
+                                               md = bte->md;
+                                               if (md->returntype.type != TYPE_VOID)
+                                                       v = iptr->dst.varindex;
+                               }
+                               else if (icmd_table[iptr->opc].dataflow >= DF_DST_BASE) {
+                                       v = iptr->dst.varindex;
+                               }
 
+                               if (v != UNUSED) {
+                                       if (( v < jd->localcount) || ( VAR(v)->flags & INOUT )) {
+                                 /* !IS_TEMPVAR && !IS_PREALLOC == (IS_LOCALVAR || IS_INOUT) */
+
+/*                                             _SSA_ASSERT(ls->new_varindex[v] != UNUSED); */
+                                               ssa_set_local_def(ls, b_index, v);
+                                       }
+                               }
+                       }
+               }
+       }
+       _SSA_ASSERT(ls->ssavarcount < jd->varcount);
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
 
-                               default:
-                                       if (( dst != NULL) && (src != dst))
-                                               lifetimes++;
+               printf("ssa_init: Vars: Orig:%3i SSAVar: %3i\n", jd->varcount, 
+                          ls->ssavarcount);
+               for(i = 0; i < jd->varcount; i++) {
+                       if ((i < jd->localcount) || ( VAR(i)->flags & INOUT)) {
+                               printf("%3i(%3i,%3x) ",i,VAR(i)->type, VAR(i)->flags);
+                               ssa_show_variable(jd, i, VAR(i),0);
+                               if (i < ls->ssavarcount) {
+                                       printf(" -> %3i", ls->new_varindex[i]);
                                }
+                               printf("\n");
                        }
-                       ssa_set_interface(cd, ls, &(m->basicblocks[b_index]));
                }
        }
-       ls->maxlifetimes = lifetimes;
-       ls->lifetimecount = lifetimes + jd->maxlocals * (TYPE_ADR+1);
+#endif
+}
+
+/* ssa_set_def ****************************************************************
+
+Helper for ssa_set_local_def and ssa_set_interface
+
+The definition of a var is stored in the bitvector array ls->var_def.
+
+The number of definitons of each var is counted, so the number of new vars with
+SSA is known.
+
+******************************************************************************/
+
+void ssa_set_def(lsradata *ls, int b_index, int varindex) {
+
+       /* b_index + 1 to leave space for the param init block 0 */
+
+       bv_set_bit(ls->var_def[b_index + 1], varindex);
+
+       /* count number of defs for every var since SSA */
+       /* will create a new var for every definition */
+
+       ls->num_defs[varindex]++;
+}
+
+/* ssa_set_local_def **********************************************************
+
+Helper for ssa_init
+
+Assigns a new unique index for the local var varindex (if not already done so)
+and then calls ssa_set_def to remember the definition in the bitvector array
+ls->var_def
+
+******************************************************************************/
+
+void ssa_set_local_def(lsradata *ls, int b_index, int varindex) {
+
+       if (ls->new_varindex[varindex] == UNUSED) {
+               ls->new_varindex[varindex] = ls->ssavarcount++;
+       }
+
+       ssa_set_def(ls, b_index, ls->new_varindex[varindex]);
+}
+
+/* ssa_set_local_def **********************************************************
+
+Helper for ssa_set_interface
+
+IN: ls              pointer to lsradata structure
+    iovar           varindex of INOUTVAR to process
+       map_index       stackdepth * 5 + type, used for coalescing IOVARS.
+
+IN/OUT
+       interface_map   used for coalescing IOVARS. interface_map[map_index] == 
+                       UNUSED, if this map_index (==stackdepth,type tupel) did not
+                                       occur till now. Then interface_map[map_index] will be set
+                                       to a new unique index.
+       ls->new_varindex will be set to this new unique index to map the old
+                        varindizes to the new ones.
+
+Assigns a new unique index for the local var varindex (if not already done so)
+and then calls ssa_set_def to remember the definition in the bitvector array
+ls->var_def
+
+******************************************************************************/
+
+void ssa_set_iovar(lsradata *ls, s4 iovar, int map_index, s4 *interface_map) {
+               if (interface_map[map_index] == UNUSED) 
+                       interface_map[map_index] = ls->ssavarcount++;
+
+               ls->new_varindex[iovar] = interface_map[map_index];
+}
+
+
+/* ssa_set_interface ***********************************************************
+
+Helper for ssa_init
+
+IN: ls              pointer to lsradata structure
+    *bptr           pointer to the basic block to be processed
+
+IN/OUT
+       interface_map   used for coalescing IOVARS. interface_map[map_index] == 
+                       UNUSED, if this map_index (==stackdepth,type tupel) did not
+                                       occur till now. Then interface_map[map_index] will be set
+                                       to a new unique index. (see ssa_set_iovar)
+
+Searches the basic block given by *bptr for IN and OUTVARS and coalesces them
+for each unique stackdepth,type dupel. For each OUTVAR with a different or no 
+INVAR at the same stackdepth the definition of this OUTVAR in this basic block 
+is remembered in ls->var_def. (see ssa_set_def)
+
+******************************************************************************/
+
+void ssa_set_interface(jitdata *jd, basicblock *bptr, s4 *interface_map) {
+       s4 *out, *in;
+       int in_d, out_d;
+       int o_map_index, i_map_index;
+       lsradata *ls;
+
+       ls = jd->ls;
+
+       out = bptr->outvars;
+       in = bptr->invars;
+       in_d = bptr->indepth - 1;
+       out_d = bptr->outdepth - 1;
+
+       /* ignore top Stackelement of instack in case of EXH or SBR blocks */
+       /* These are no Interface stackslots! */
+       if ((bptr->type == BBTYPE_EXH) ||
+               (bptr->type == BBTYPE_SBR)) {
+               in_d--;
+       }
+
+       /* invars with no corresponding outvars are not defined here */
+       /* just set up the interface_map */
+
+       for(;(in_d > out_d); in_d--) {
+               i_map_index = in_d * 5 + VAR(in[in_d])->type;
+               ssa_set_iovar(ls, in[in_d], i_map_index, interface_map);
+       }
+
+       while((out_d >= 0)) {
+               /* set up interface_map */
+
+               o_map_index = out_d * 5 + VAR(out[out_d])->type;
+               if (in_d >= 0) {
+                       i_map_index = in_d * 5 + VAR(in[in_d])->type;
+                       ssa_set_iovar(ls, in[in_d], i_map_index, interface_map);
+               }
+               ssa_set_iovar(ls, out[out_d], o_map_index, interface_map);
+               if (in_d == out_d) {
+                       if (in[in_d] != out[out_d]) {
+
+                               /* out interface stackslot is defined in this basic block */
+
+/*                             ssa_set_def(ls, bptr->nr + 1, ls->new_varindex[out[out_d]]); */
+                       }
+                       out_d--;
+                       in_d--;
+               }
+               else {
 
+                       /* in_d < out_d */
+                       /* out interface stackslot is defined in this basic block */
+
+/*                     ssa_set_def(ls, bptr->nr + 1, ls->new_varindex[out[out_d]]); */
+                       out_d--;
+               }
+       }
 }
 
+/* ssa_place_phi_functions *****************************************************
+
+ls->phi[n][a][p] is created and populated.
+
+For each basicblock Y in the dominance frontier of a basicblock n (0 <= n < 
+ls->basicblockcount)in which a variable (0 <= a < ls->ssavarcount) is defined an
+entry in ls->phi[Y][a] is created.
+This entry is an array with the number of predecessors of Y elements + 1 elements.
+This elements are all set to the variable a and represent the phi function which
+will get ai = phi(ai1, ai2, ..., aip) after ssa_rename.
+
+*******************************************************************************/
+
 
-void ssa_place_phi_functions(codegendata *cd, lsradata *ls, graphdata *gd,
-                                                        dominatordata *dd)
+void ssa_place_phi_functions(jitdata *jd, graphdata *gd, dominatordata *dd)
 {
        int a,i,j,n,Y;
        bitvector *def_sites;
-       bitvector *A_phi;    /* [0..ls->basicblockcount[ of ls->max_vars Bit */
+       bitvector *A_phi;    /* [0..ls->basicblockcount[ of ls->ssavarcount Bit */
        worklist *W;
        int num_pred;
-       bool add_phi;
-       stackptr s;
+
+       lsradata *ls;
+
+       ls = jd->ls;
 
        W = wl_new(ls->basicblockcount);
 
-       def_sites = DMNEW(bitvector, ls->max_vars);
-       for(a = 0; a < ls->max_vars; a++)
+       def_sites = DMNEW(bitvector, ls->ssavarcount);
+       for(a = 0; a < ls->ssavarcount; a++)
                def_sites[a] = bv_new(ls->basicblockcount);
 
        ls->phi = DMNEW(int **, ls->basicblockcount);
        A_phi = DMNEW(bitvector, ls->basicblockcount);
        for(i = 0; i < ls->basicblockcount; i++) {
-               ls->phi[i] = DMNEW(int *, ls->max_vars);
-               for(j = 0; j < ls->max_vars; j++)
+               ls->phi[i] = DMNEW(int *, ls->ssavarcount);
+               for(j = 0; j < ls->ssavarcount; j++)
                        ls->phi[i][j] = NULL;
-               A_phi[i] = bv_new(ls->max_vars);
+               A_phi[i] = bv_new(ls->ssavarcount);
        }
 
-       for(n = 0; n < ls->basicblockcount; n++)
-               for(a = 0; a < ls->max_vars; a++)
+       /* copy var_def to def_sites */
+       /* var_def is valid for 0.. jd->basicblockcount (bb 0 for param init) */
+
+       for(n = 0; n <= jd->basicblockcount; n++)
+               for(a = 0; a < ls->ssavarcount; a++)
                        if (bv_get_bit(ls->var_def[n], a))
                                bv_set_bit(def_sites[a], n);
 #ifdef SSA_DEBUG_VERBOSE
        if (compileverbose) {
                printf("var Definitions:\n");
-               for(i = 0; i < ls->max_vars; i++) {
+               for(i = 0; i < ls->ssavarcount; i++) {
                        printf("def_sites[%3i]=%p:",i,(void *)def_sites[i]);
                        for(j = 0; j < ls->basicblockcount; j++) {
                                if ((j % 5) == 0) printf(" ");
@@ -420,8 +596,10 @@ void ssa_place_phi_functions(codegendata *cd, lsradata *ls, graphdata *gd,
        }
 #endif
 
-       for(a = 0; a < ls->max_vars; a++) {
+       for(a = 0; a < ls->ssavarcount; a++) {
+
                /* W<-def_sites(a) */
+
                for(n = 0; n < ls->basicblockcount; n++)
                        if (bv_get_bit(def_sites[a],n)) {
                                wl_add(W, n);
@@ -439,57 +617,31 @@ void ssa_place_phi_functions(codegendata *cd, lsradata *ls, graphdata *gd,
                                        /* a is not a Element of A_phi[Y] */
                                        /* a <- phi(a,a...,a) to be inserted at top of Block Y */
                                        /* phi has as many arguments, as Y has predecessors    */
-
+#if 0
 #if 0
                                        /* do not add a phi function for interface stackslots */
                                        /* if a predecessor is not a def site of a <==>       */
                                        /* the block does not have the corresponding inslot*/
-                                       if ((ls->var_to_index[a] >= 0) ||
-                                               (bv_get_bit(def_sites[a], 
-                                                                       graph_get_first_predecessor(gd, Y, &iter))))
+
+/*                                     if ((ls->var_to_index[a] >= 0) || */
+/*                                             (bv_get_bit(def_sites[a],  */
+/*                                                                     graph_get_first_predecessor(gd, Y, &iter)))) */
+
 #endif
                                        /* for interface stackslots add a phi function only */
                                        /* if the basicblock has the corresponding incoming */
                                        /* stackslot -> it could be, that the stackslot is */
                                        /* not live anymore at Y */
 
-#ifdef SSA_DEBUG_VERBOSE
-                                       if (compileverbose)
-                                               if (ls->var_to_index[a] < 0)
-                                                       printf("SS CHeck BB %3i ID %3i V2I %3i A %3i ML %3i\n",Y,
-                                                                  ls->basicblocks[Y]->indepth, 
-                                                                  ls->var_to_index[a], a, jd->maxlocals);
-#endif
-                                       /* Add Locals in any case */
-                                       add_phi = (ls->var_to_index[a] >= 0);
-                                       if (!add_phi) {
-                                               /* Stackslot */
-                                               s = ls->basicblocks[Y]->instack;
-                                               for(i = ls->basicblocks[Y]->indepth-1; i>=0; i--, s = s->prev) {
-                                                       _SSA_ASSERT(s != 0);
-#ifdef SSA_DEBUG_VERBOSE
-                                       if (compileverbose)
-                                               if (ls->var_to_index[a] < 0)
-                                                       printf(" Depth %3i Var %3i\n",i,
-                                                                  ls->var[i + jd->maxlocals][s->type]);
 #endif
-                                                       if (ls->var[i + jd->maxlocals][s->type] == a) {
-                                                               add_phi=true;
-                                                               break;
-                                                       }
-                                               }
-                                       }
-                                       if (add_phi)
-                                       {
-                                               num_pred =  graph_get_num_predecessor(gd, Y);
-                                               ls->phi[Y][a] = DMNEW(int, num_pred + 1);
-                                               for (j = 0; j < num_pred + 1; j++)
-                                                       ls->phi[Y][a][j] = a;
-                                               /* increment the number of definitions of a by one */
-                                               /* for this phi function */
-                                               ls->num_defs[a]++;
-                                       }
-
+                                       num_pred =  graph_get_num_predecessor(gd, Y);
+                                       ls->phi[Y][a] = DMNEW(int, num_pred + 1);
+                                       for (j = 0; j < num_pred + 1; j++)
+                                               ls->phi[Y][a][j] = a;
+                                       /* increment the number of definitions of a by one */
+                                       /* for this phi function */
+                                       ls->num_defs[a]++;
+                                       
                                        bv_set_bit(A_phi[Y], a);
                                        if (bv_get_bit(ls->var_def[Y],a)==0) {
                                                /* Iterated Dominance Frontier Criterion:*/
@@ -504,80 +656,286 @@ void ssa_place_phi_functions(codegendata *cd, lsradata *ls, graphdata *gd,
        }
 }
 
-void ssa_Rename_init(methodinfo *m, codegendata *cd, lsradata *ls, graphdata *gd) 
+/* ssa_rename ******************************************************************
+
+Rename the variables a (0 <= a < ls->ssavarcount) so that each new variable
+has only one definition (SSA form).
+
+ls->def_count[0..ls->ssavarcount[ holds the number of definitions of each var.
+ls->var_0[0..ls->ssavarcount[ will be set to the new index of the first 
+                              definition of each old var.
+ls->varcount_with_indices     will be se to the new maximum varcount of LOCAL
+                              and IOVARS.
+
+All other vars (TEMPVAR and PREALLOC) will get a new unique index above 
+ls->varcount_with_indices.
+
+jd->var and jd->varcount will be set for this renamed vars.
+
+*******************************************************************************/
+
+void ssa_rename(jitdata *jd, graphdata *gd, dominatordata *dd)
 {
+       int i, mi, l, j, p, t;
+       int type, flags;
+       methoddesc *md = jd->m->parseddesc;
+
+       varinfo *new_vars;
+       lsradata *ls;
+
+       ls = jd->ls;
+       
+       ssa_rename_init(jd, gd);
+
+       /* Consider definition of Local Vars initialized with Arguments */
+       /* in Block 0 */
+       /* init is regarded as use too-> ssa_rename_use ->bullshit!!*/
+       for (p = 0, l= 0; p < md->paramcount; p++) {
+               t = md->paramtypes[p].type;
+               mi = l * 5 + t;
+               i = jd->local_map[mi];
+               l++;
+               if (IS_2_WORD_TYPE(t))
+                       l++;
+               if (i == UNUSED)
+                       continue;
+               /* !!!!! locals are now numbered as the parameters !!!! */
+               /* !!!!! no additional increment for 2 word types !!!!! */
+               /* this happens later on! here we still need the increment */
+           /* index of var can be in the range from 0 up to not including */
+           /* CD->maxlocals */
+
+               /* ignore return value, since first definition gives 0 -> */
+               /* no rename necessary */
                
-       int a, i, t, p;
-       int i_l, i_i;
+               i = ls->new_varindex[i];
+               j = ssa_rename_def_(ls, i);
+               _SSA_ASSERT(j == 0);
+               jd->local_map[mi] = i;
+       }
+       ssa_rename_(jd, gd, dd, 0);
+
+#if 0
+       /* DO _NOT_ DO THIS! Look at java.util.stringtokenizer.counttokens! */
+       /* if there is no use of the defined Var itself by the phi function */
+       /* for a loop path, in which this var is not used, it will not be life */
+       /* in this path and overwritten! */
+
+       /* Invalidate all xij from phi(xi0)=xi1,xi2,xi3,..,xin with xij == xi0 */
+       /* this happens if the phi function is the first definition of x or in a */
+       /* path with a backedge xi has no definition */ 
+       /* a phi(xij) = ...,xij,... with the only use and definition of xij by */
+       /* this phi function would otherwise "deadlock" the dead code elemination */
+       /* invalidate means set it to ls->max_vars_with_indices */
+       /* a phi function phi(xi0)=xi1,xi2,...xin wiht xij == xi0 for all j in */
+       /* [1,n] can be removed */
+
+       for(i = 0; i < ls->ssavarcount; i++) {
+               for(t = 0; t < ls->basicblockcount; t++) {
+                       if (ls->phi[t][i] != 0) {
+                               remove_phi = true;
+                               for(p = 1; p <= graph_get_num_predecessor(gd, t); p++) {
+                                       if (ls->phi[t][i][0] == ls->phi[t][i][p])
+                                               ls->phi[t][i][p] = ls->varcount_with_indices;
+                                       else 
+                                               remove_phi = false;
+                               }
+                       }
+                       if (remove_phi)
+                               ls->phi[t][i] = NULL;
+               }
+       }
+#endif
+
+#if defined(SSA_DEBUG_CHECK) || defined(SSA_DEBUG_VERBOSE)
+# if defined(SSA_DEBUG_VERBOSE)
+       if (compileverbose) {
+               printf("%s %s ",jd->m->class->name->text, jd->m->name->text);
+               if (jd->isleafmethod)
+                       printf("**Leafmethod**");
+               printf("\n");
+       }
+# endif
+       if (strcmp(jd->m->class->name->text,"fp")==0)
+               if (strcmp(jd->m->name->text,"testfloat")==0)
+# if defined(SSA_DEBUG_VERBOSE)
+                       if (compileverbose) 
+                               printf("12-------------------12\n");
+# else
+               { int dummy=1; dummy++; }
+# endif
+#endif
+       /* recreate rd->locals[][] */
+       /* now only one (local_index/type) pair exists anymore     */
+       /* all var[t][i] with var_to_index[var[t][i]] >= 0 are locals */
+       /* max local index after SSA indexing is in ls->local_0[ls->max_locals] */
+       
+       new_vars = DMNEW(varinfo, ls->vartop);
+       for(i = 0; i < ls->vartop ; i++)
+               new_vars[i].type = UNUSED;
+       for(i = 0; i < jd->varcount; i++) {
+                       p = ls->new_varindex[i];
+                       if (p != UNUSED) {
+                               if (p < ls->ssavarcount)
+                                       p = ls->var_0[p];
+                               new_vars[p].type  = VAR(i)->type;
+                               new_vars[p].flags = VAR(i)->flags;
+                               ls->lifetime[p].v_index = p;
+                               ls->lifetime[p].type = VAR(i)->type;
+                       }
+       }
+
+       /* take care of newly indexed local & in/out vars */
+
+       for(i = 0; i < ls->ssavarcount; i++) {
+               j = ls->var_0[i];
+               type = new_vars[j].type;
+               flags = new_vars[j].flags;
+               j++;
+               for (; j < ls->var_0[i + 1]; j++) {
+                       new_vars[j].type = type;
+                       new_vars[j].flags = flags;
+                       ls->lifetime[j].v_index = j;
+                       ls->lifetime[j].type = type;
+               }
+       }
+
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
+
+               printf("ssa_rename: Vars: Orig:%3i SSAVar: %3i\n", jd->varcount,
+                          ls->ssavarcount);
+               for(i = 0; i < jd->varcount; i++) {
+                       printf("%3i(%3i,%3x) ",i,VAR(i)->type, VAR(i)->flags);
+                       ssa_show_variable(jd, i, VAR(i),0);
+                       j = ls->new_varindex[i];
+                       if ((j != UNUSED) && (j < ls->ssavarcount))
+                               printf(" -> %3i ... %3i", ls->var_0[j], ls->var_0[j + 1] - 1);
+                       else
+                               printf(" -> %3i", j);
+                       printf("\n");
+               }
+       }
+#endif
+
+       jd->var = new_vars;
+       jd->varcount = ls->vartop;
+       jd->vartop = ls->vartop;
+
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
+               printf("ssa_rename: Vars: Orig:%3i SSAVar: %3i\n", jd->varcount,
+                          ls->ssavarcount);
+               for(i = 0; i < jd->varcount; i++) {
+                       printf("%3i(%3i,%3x) ",i,VAR(i)->type, VAR(i)->flags);
+                       ssa_show_variable(jd, i, VAR(i),0);
+                       printf("\n");
+               }
+       }
+#endif
+}
+
+/* ssa_rename_init *************************************************************
+
+Setup the data structure for ssa_rename
+
+ls->def_count[0..ls->ssavarcount[ holds the number of definitions of each var.
+ls->var_0[0..ls->ssavarcount[ will be set to the new index of the first 
+                              definition of each old var.
+ls->varcount_with_indices     will be se to the new maximum varcount of LOCAL
+                              and IOVARS.
+
+All other vars (TEMPVAR and PREALLOC) will get a new unique index above 
+ls->varcount_with_indices.
+
+jd->var and jd->varcount will be set for this renamed vars.
+
+*******************************************************************************/
+
+void ssa_rename_init(jitdata *jd, graphdata *gd) 
+{
+       int a, i, p;
+       lsradata *ls;
+
+       ls = jd->ls;
        
        /* set up new locals */
-       /* ls->var[index][type] holds the new unique index  */
-       /* in the range of [0..ls-max_vars[                 */
+       /* ls->new_varindex[0..jd->varcount[ holds the new unique index */
+       /* for locals and iovars */
+
        /* ls->num_defs[index] gives the number of indizes which will be created  */
        /* from SSA */
-       /* -> vars will be numbered in this sequence: L0(0)..L0(i) L1(0)..L1(j).*/
-       /* ls->var[index][type] will point to each LX(0)  */
-
-       /* as first step cummulate the num_defs array */
-       /* for locals */
-       /* last element is the maximum local count */
-       ls->local_0 = DMNEW(int, ls->max_locals + 1);
-       ls->interface_0 = DMNEW(int, -ls->max_interfaces);
-       ls->local_0[0] = 0;
-       ls->interface_0[0] = 0;
-       ls->max_vars_with_indices = 0;
-       for(i = 0, i_i = 1, i_l = 1; i < ls->max_vars; i++) {
-               ls->max_vars_with_indices += ls->num_defs[i];
-               if (ls->var_to_index[i] >= 0) {
-                       /* local var */
-                       ls->local_0[i_l] = ls->local_0[i_l-1] + ls->num_defs[i];
-                       ls->var_to_index[i] = ls->local_0[i_l-1];
-                       i_l++;
-               } else {
-                       /* interface stackslot */
-                       ls->interface_0[i_i] = ls->interface_0[i_i-1] + ls->num_defs[i];
-                       ls->var_to_index[i] = -ls->interface_0[i_i-1] - 1;
-                       i_i++;
-               }
+
+       /* -> vars will be numbered in this sequence: L0(0)..L0(i) L1(0)..L1(j) ..*/
+       /* ls->var_0[X] will point to each LX(0)  */
+       /* ls->var_0[ls->ssavarcount] will hold ls->varcount_with_indices */
+
+       /* as first step cummulate the num_defs array for locals and iovars       */
+       /* last element is the maximum var count */
+
+       ls->var_0 = DMNEW(int, max(1, ls->ssavarcount + 1));
+       ls->var_0[0] = 0;
+       ls->varcount_with_indices = 0;
+       for(i = 0; i < ls->ssavarcount; i++) {
+               ls->varcount_with_indices += ls->num_defs[i];
+               ls->var_0[i+1] = ls->var_0[i] + ls->num_defs[i];
        }
 
+#if 0
        /* Change the var indices in phi from La to La(0) */
+
        for(i = 0; i < ls->basicblockcount; i++)
-               for (t = 0; t < ls->max_vars; t++)
-                       if (ls->phi[i][t] != NULL)
+               for (a = 0; a < ls->ssavarcount; a++)
+                       if (ls->phi[i][a] != NULL)                              
                                for(p = 0; p < graph_get_num_predecessor(gd, i) + 1; p++)
-                                       ls->phi[i][t][p] = ls->var_to_index[t];
+                                       ls->phi[i][a][p] = ls->var_0[a];
+#endif
        
        /* Initialization */
-       ls->count     = DMNEW(int, ls->max_vars);
-       ls->stack     = DMNEW(int *, ls->max_vars);
-       ls->stack_top = DMNEW(int, ls->max_vars);
-       for(a = 0; a < ls->max_vars; a++) {
+
+       ls->count     = DMNEW(int, max(1, ls->ssavarcount));
+       ls->stack     = DMNEW(int *, max(1, ls->ssavarcount));
+       ls->stack_top = DMNEW(int, max(1, ls->ssavarcount));
+       for(a = 0; a < ls->ssavarcount; a++) {
                ls->count[a] = 0;
                ls->stack_top[a] = 0;
+
                /* stack a has to hold number of defs of a Elements + 1 */
+
                ls->stack[a] = DMNEW(int, ls->num_defs[a] + 1);
                ls->stack[a][ls->stack_top[a]++] = 0;
        }
-       if (ls->max_locals > 0) {
+
+       if (ls->ssavarcount > 0) {
+
                /* Create the num_var_use Array */
+
                ls->num_var_use = DMNEW(int *, ls->basicblockcount);
                for(i = 0; i < ls->basicblockcount; i++) {
-                       ls->num_var_use[i] =DMNEW(int, max(1, ls->local_0[ls->max_locals]));
-                       for(a = 0; a < ls->local_0[ls->max_locals]; a++)
+                       ls->num_var_use[i] =DMNEW(int, max(1, ls->varcount_with_indices));
+                       for(a = 0; a < ls->varcount_with_indices; a++)
                                ls->num_var_use[i][a] = 0;
                }
+
                /* Create the use_sites Array of Bitvectors*/
                /* use max(1,..), to ensure that the array is created! */
-               ls->use_sites =  DMNEW(bitvector, max(1, ls->local_0[ls->max_locals]));
-               for(a = 0; a < ls->local_0[ls->max_locals]; a++)
+
+               ls->use_sites =  DMNEW(bitvector, max(1, ls->varcount_with_indices));
+               for(a = 0; a < ls->varcount_with_indices; a++)
                        ls->use_sites[a] = bv_new(ls->basicblockcount);
        }
+
        /* init lifetimes */
+       /* count number of TEMPVARs */
+
+       ls->lifetimecount = 0;
+       for(i = 0; i < jd->varcount; i++)
+               if ((i >= jd->localcount) || (!(jd->var[i].flags & (INOUT | PREALLOC))))
+                       ls->lifetimecount++;
 
-       ls->maxlifetimes = /*m*/ ls->maxlifetimes + ls->basicblockcount * m->maxstack;
-       ls->lifetimecount = ls->maxlifetimes + ls->local_0[ls->max_locals] 
-               + cd->maxstack * 5;
+       ls->varcount = ls->varcount_with_indices + ls->lifetimecount;
+
+       ls->lifetimecount = ls->varcount;
        ls->lifetime = DMNEW(struct lifetime, ls->lifetimecount);
        ls->lt_used = DMNEW(int, ls->lifetimecount);
        ls->lt_int = DMNEW(int, ls->lifetimecount);
@@ -586,14 +944,45 @@ void ssa_Rename_init(methodinfo *m, codegendata *cd, lsradata *ls, graphdata *gd
        ls->lt_flt_count = 0;
        ls->lt_mem = DMNEW(int, ls->lifetimecount);
        ls->lt_mem_count = 0;
-       for (i=0; i < ls->lifetimecount; i++) ls->lifetime[i].type = -1;
+       for (i=0; i < ls->lifetimecount; i++) {
+               ls->lifetime[i].type = UNUSED;
+               ls->lifetime[i].savedvar = 0;           
+               ls->lifetime[i].flags = 0;
+               ls->lifetime[i].usagecount = 0;
+               ls->lifetime[i].bb_last_use = -1;
+               ls->lifetime[i].bb_first_def = -1;
+               ls->lifetime[i].use = NULL;
+               ls->lifetime[i].def = NULL;
+               ls->lifetime[i].last_use = NULL;
+       }
 
+       /* for giving TEMP and PREALLOC vars a new unique index */
+
+       ls->vartop = ls->varcount_with_indices; 
+
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose) {
+               printf("ssa_rename_init: Vars: Orig:%3i SSAVar: %3i\n", jd->varcount,
+                          ls->ssavarcount);
+               for(i = 0; i < jd->varcount; i++) {
+                       if ((i < jd->localcount) || ( VAR(i)->flags & INOUT)) {
+                               printf("%3i(%3i,%3x) ",i,VAR(i)->type, VAR(i)->flags);
+                               ssa_show_variable(jd, i, VAR(i),0);
+                               if ((i < ls->ssavarcount) || (VAR(i)->flags & INOUT)) {
+                                       printf(" -> %3i", ls->new_varindex[i]);
+                               }
+                               printf("\n");
+                       }
+               }
+               ssa_print_phi(ls, gd);
+       }
+#endif
 }
 
-int ssa_Rename_def(lsradata *ls, int n, int a) {
+int ssa_rename_def_(lsradata *ls, int a) {
        int i;
        
-       _SSA_CHECK_BOUNDS(a,0,ls->max_vars);
+       _SSA_CHECK_BOUNDS(a,0,ls->ssavarcount);
        ls->count[a]++;
        i = ls->count[a] - 1;
        /* push i on stack[a] */
@@ -602,393 +991,375 @@ int ssa_Rename_def(lsradata *ls, int n, int a) {
        return i;
 }
 
-void ssa_Rename_use(lsradata *ls, int n, int a) {
-       if (ls->max_locals > 0) {
+int ssa_rename_def(jitdata *jd, int *def_count, int a) {
+       int i, a1, ret;
+       lsradata *ls;
+
+       ls = jd->ls;
+       
+       a1 = ls->new_varindex[a];
+       _SSA_CHECK_BOUNDS(a1, UNUSED, ls->varcount);
+       if ((a1 != UNUSED) && (a1 < ls->ssavarcount)) {
+               /* local or inoutvar -> normal ssa renaming */
+               _SSA_ASSERT((a < jd->localcount) || (VAR(a)->flags & INOUT));
+               /* !IS_TEMPVAR && !IS_PREALLOC == (IS_LOCALVAR || IS_INOUT) */
+
+               def_count[a1]++;
+               i = ssa_rename_def_(ls, a1);
+               ret = ls->var_0[a1] + i;
+       }
+       else {
+               /* TEMP or PREALLOC var */
+               if (a1 == UNUSED) {
+                       ls->new_varindex[a] = ls->vartop;
+                       ret = ls->vartop;
+                       ls->vartop++;
+                       _SSA_ASSERT( ls->vartop < ls->varcount);
+               }
+               else
+                       ret = a1;
+       }
+       return ret;
+}
+
+void ssa_rename_use_(lsradata *ls, int n, int a) {
+       _SSA_CHECK_BOUNDS(a, 0, ls->varcount_with_indices);
+       if (ls->ssavarcount > 0) {
                bv_set_bit(ls->use_sites[a], n);
                ls->num_var_use[n][a]++;
        }
 }
 
-void ssa_Rename_(codegendata *cd, lsradata *ls, graphdata *gd, 
-                                dominatordata *dd, int n) {
-       int a, i, j, k, iindex, Y;
+int ssa_rename_use(lsradata *ls, int n, int a) {
+       int a1, i;
+       int ret;
+
+       a1 = ls->new_varindex[a];
+       _SSA_CHECK_BOUNDS(a1, UNUSED, ls->varcount);
+       if ((a1 != UNUSED) && (a1 < ls->ssavarcount)) {
+               /* local or inoutvar -> normal ssa renaming */
+               /* i <- top(stack[a]) */
+
+               _SSA_CHECK_BOUNDS(ls->stack_top[a1]-1, 0, ls->num_defs[a1]+1);
+               i = ls->stack[a1][ls->stack_top[a1] - 1]; 
+               _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a1]);
+
+               ret = ls->var_0[a1] + i;
+       }
+       else {
+               /* TEMP or PREALLOC var */
+               if (a1 == UNUSED) {
+                       ls->new_varindex[a] = ls->vartop;
+                       ret = ls->vartop;
+                       ls->vartop++;
+                       _SSA_ASSERT( ls->vartop < ls->varcount);
+               }
+               else
+                       ret = a1;
+       }
+
+       return ret;
+}
+
+#ifdef SSA_DEBUG_VERBOSE
+void ssa_rename_print(instruction *iptr, char *op, int from,  int to) {
+       if (compileverbose) {
+               printf("ssa_rename_: ");
+               if (iptr != NULL)
+                       printf("%s ", opcode_names[iptr->opc]);
+               else
+                       printf("       ");
+
+               printf("%s: %3i->%3i\n", op, from, to);
+       }
+}
+#endif
+
+void ssa_rename_(jitdata *jd, graphdata *gd, dominatordata *dd, int n) {
+       int a, i, j, k, iindex, Y, v;
        int in_d, out_d;
-       instruction *iptr;
-       int *def_count;    
-       /* [0..ls->max_vars[ Number of Definitions of this var in this  */
+       int *def_count;
+       /* [0..ls->varcount[ Number of Definitions of this var in this  */
        /* Basic Block. Used to remove the entries off the stack at the */
        /* end of the function */
-
-       stackptr in, out;
+       instruction *iptr;
+       s4 *in, *out, *argp;
        graphiterator iter_succ, iter_pred;
        struct lifetime *lt;
 
+       methoddesc *md;
+       methodinfo *m;
+       builtintable_entry *bte;
+       lsradata *ls;
+
+       ls = jd->ls;
+       m  = jd->m;
+
+#ifdef SSA_DEBUG_VERBOSE
+       if (compileverbose)
+               printf("ssa_rename_: BB %i\n",n);
+#endif
+
        _SSA_CHECK_BOUNDS(n, 0, ls->basicblockcount);
 
-       def_count = DMNEW(int, ls->max_vars);
-       for(i = 0; i < ls->max_vars; i++)
+       def_count = DMNEW(int, max(1, ls->ssavarcount));
+       for(i = 0; i < ls->ssavarcount; i++)
                def_count[i] = 0;
 
-       /* change Store of possible phi functions from a0 to ai*/
-       for(a = 0; a < ls->max_vars; a++)
+       /* change Store of possible phi functions from a to ai*/
+
+       for(a = 0; a < ls->ssavarcount; a++)
                if (ls->phi[n][a] != NULL) {
                        def_count[a]++;
                                /* do not mark this store as use - maybee this phi function */
                                /* can be removed for unused Vars*/
-                       if (ls->var_to_index[a] >= 0)
-                               /* local var */
-                               ls->phi[n][a][0] += ssa_Rename_def(ls, n, a);
-                       else
-                               /* interface */
-                               ls->phi[n][a][0] -= ssa_Rename_def(ls, n, a);
+                       j = ls->var_0[a] + ssa_rename_def_(ls, a);
+#ifdef SSA_DEBUG_VERBOSE
+                       ssa_rename_print( NULL, "phi-st", ls->phi[n][a][0], j);
+#endif
+                       ls->phi[n][a][0] = j;
                }
 
-       in = ls->basicblocks[n]->instack;
-       in_d = ls->basicblocks[n]->indepth;
+       in   = ls->basicblocks[n]->invars;
+       in_d = ls->basicblocks[n]->indepth - 1;
+
        /* change use of instack Interface stackslots except top SBR and EXH */
        /* stackslots */
+
        if ((ls->basicblocks[n]->type == BBTYPE_EXH) ||
                (ls->basicblocks[n]->type == BBTYPE_SBR)) {
                in_d--;
-               in = in->prev;
        }
-       out = ls->basicblocks[n]->outstack;
-       out_d = ls->basicblocks[n]->outdepth;
+/*     out   = ls->basicblocks[n]->outvars; */
+/*     out_d = ls->basicblocks[n]->outdepth - 1; */
+
+/*     for(; out_d > in_d; out_d--); */
 
-       for(;out_d > in_d; out = out->prev, out_d--);
+       for (; in_d >= 0; in_d--) {
+               /* Possible Use of ls->new_varindex[jd->var[in_d]] */
+               _SSA_ASSERT(ls->new_varindex[in[in_d]] != UNUSED);
+
+               a = ls->new_varindex[in[in_d]];
+               _SSA_CHECK_BOUNDS(a, 0, ls->ssavarcount);
 
-       for (;in != NULL; in = in->prev, in_d--) {
-               /* Possible Use of                             */
-               /* ls->var[in_d - 1 + jd->maxlocals][in->type] */
-               _SSA_CHECK_BOUNDS(in_d - 1 + jd->maxlocals, 0, jd->maxlocals + cd->maxstack);
-               a = ls->var[in_d - 1 + jd->maxlocals][in->type];
-               _SSA_CHECK_BOUNDS(a, 0, ls->max_vars);
                /* i <- top(stack[a]) */
+
                _SSA_CHECK_BOUNDS(ls->stack_top[a]-1, 0, ls->num_defs[a]+1);
                i = ls->stack[a][ls->stack_top[a]-1]; 
                _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
+
                /* Replace use of x with xi */
+
 #ifdef SSA_DEBUG_VERBOSE
-               if (compileverbose)
-                       printf("Ren Use:BB %3i: stackslot: depth %3i old val: %3i Var,0: %3i varind: %3i\n", n, in_d, in->varnum, ls->var_to_index[a], ls->var_to_index[a]-i);
+                       ssa_rename_print( NULL, "invar", in[in_d], ls->var_0[a]+i);
 #endif
-               in->varnum = ls->var_to_index[a] - i;
-               lt = &(ls->lifetime[-in->varnum-1]);
-               lt->v_index = in->varnum;
+               in[in_d] = ls->var_0[a] + i;
+               lt = ls->lifetime + in[in_d];
+
+               lt->v_index = in[in_d];
                lt->bb_last_use = -1;
-               lsra_add_ss(lt, in);
-               in->varkind = TEMPVAR;
        }
-       in = ls->basicblocks[n]->instack;
-               
+
        iptr = ls->basicblocks[n]->iinstr;
+
        for(iindex = 0; iindex < ls->basicblocks[n]->icount; iindex++, iptr++) {
-               switch(iptr->opc) {
-               case ICMD_ILOAD:
-               case ICMD_LLOAD:
-               case ICMD_FLOAD:
-               case ICMD_DLOAD:
-               case ICMD_ALOAD:
-                       _SSA_CHECK_BOUNDS(iptr->op1, 0, jd->maxlocals);
-                       a = ls->var[iptr->op1][iptr->opc - ICMD_ILOAD];
-                       _SSA_CHECK_BOUNDS(a, 0, ls->max_vars);
-                       /* i <- top(stack[a]) */
-                       _SSA_CHECK_BOUNDS(ls->stack_top[a]-1, 0, ls->num_defs[a]+1);
-                       i = ls->stack[a][ls->stack_top[a]-1]; 
-                       _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
-                       /* Replace use of x with xi */
-#if 0
-                       /* there are no LOCALVAR Stackslots with SSA */
-                       if ((iptr->dst->varkind == LOCALVAR) &&
-                               (iptr->dst->varnum == iptr->op1))
-                               iptr->dst->varnum = ls->var_to_index[a] + i;
-#endif
-                       iptr->op1 = ls->var_to_index[a] + i;
 
-                       ssa_Rename_use(ls, n, ls->var_to_index[a] + i);
+               /* check for use (s1, s2, s3 or special (argp) ) */
 
-                       break;
-               case ICMD_ISTORE:
-               case ICMD_LSTORE:
-               case ICMD_FSTORE:
-               case ICMD_DSTORE:
-               case ICMD_ASTORE:
-                       /* replace definition of a with def of ai */
-                       _SSA_CHECK_BOUNDS(iptr->op1, 0, jd->maxlocals);
-                       a = ls->var[iptr->op1][iptr->opc - ICMD_ISTORE];
-                       _SSA_CHECK_BOUNDS(a, 0, ls->max_vars);
-                       def_count[a]++;
+               switch (icmd_table[iptr->opc].dataflow) {
+               case DF_3_TO_0:
+               case DF_3_TO_1: /* icmd has s1, s2 and s3 */
+                       j = ssa_rename_use(ls, n, iptr->sx.s23.s3.varindex);
+#ifdef SSA_DEBUG_VERBOSE
+                       ssa_rename_print( iptr, "s3 ", iptr->sx.s23.s3.varindex, j);
+#endif
+                       iptr->sx.s23.s3.varindex = j;
 
-                       i = ssa_Rename_def(ls, n, a);
-                       _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
+                       /* now "fall through" for handling of s2 and s1 */
 
-                       iptr->op1 = ls->var_to_index[a] + i;
-                       /* Mark Def as use, too. Since param initialisation is in var_def */
-                       /* and this would not remove this locals, if not used elsewhere   */
-                       ssa_Rename_use(ls, n, ls->var_to_index[a] + i);
-                       break;
-               case ICMD_IINC:
-
-                       /* Load from iptr->op1 */
-                       _SSA_CHECK_BOUNDS(iptr->op1, 0, jd->maxlocals);
-                       a = ls->var[iptr->op1][TYPE_INT];
-                       _SSA_CHECK_BOUNDS(a, 0, ls->max_vars);
-                       /* i <- top(stack[a]) */
-                       _SSA_CHECK_BOUNDS(ls->stack_top[a]-1, 0, ls->num_defs[a]+1);
-                       i = ls->stack[a][ls->stack_top[a]-1]; 
-                       _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
-                       /* Replace use of x with xi */
-                       iptr->op1 = ls->var_to_index[a] + i;
-
-                       ssa_Rename_use(ls, n, ls->var_to_index[a] + i);                 
-                       /*  Store new(iinced) value in iptr->val._i.opq_t */
-
-                       /* replace definition of a with def of ai */
-                       _SSA_CHECK_BOUNDS(iptr->val._i.op1_t, 0, jd->maxlocals);
-                       a = ls->var[iptr->val._i.op1_t][TYPE_INT];
-                       _SSA_CHECK_BOUNDS(a, 0, ls->max_vars);
-                       def_count[a]++;
+               case DF_2_TO_0:
+               case DF_2_TO_1: /* icmd has s1 and s2 */
+                       j = ssa_rename_use(ls, n, iptr->sx.s23.s2.varindex);
+#ifdef SSA_DEBUG_VERBOSE
+                       ssa_rename_print( iptr, "s2 ", iptr->sx.s23.s2.varindex, j);
+#endif
+                       iptr->sx.s23.s2.varindex = j;
 
-                       i = ssa_Rename_def(ls, n, a);
-                       _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
+                       /* now "fall through" for handling of s1 */
 
-                       iptr->val._i.op1_t = ls->var_to_index[a] + i;
-                       /* Mark Def as use, too. Since param initialisation is in var_def */
-                       /* and this would not remove this locals, if not used elsewhere   */
-                       ssa_Rename_use(ls, n, ls->var_to_index[a] + i);
+               case DF_1_TO_0:
+               case DF_1_TO_1:
+               case DF_MOVE:
+               case DF_COPY:
+                       j = ssa_rename_use(ls, n, iptr->s1.varindex);
+#ifdef SSA_DEBUG_VERBOSE
+                       ssa_rename_print( iptr, "s1 ", iptr->s1.varindex, j);
+#endif
+                       iptr->s1.varindex = j;
+                       break;
 
+               case DF_INVOKE:
+               case DF_BUILTIN:
+               case DF_N_TO_1:
+                       /* do not use md->paramcount, pass-through stackslots have */
+                       /* to be renamed, too */
+                       i = iptr->s1.argcount;
+                       argp = iptr->sx.s23.s2.args;
+                       while (--i >= 0) {
+                               j = ssa_rename_use(ls, n, *argp);
+#ifdef SSA_DEBUG_VERBOSE
+                               ssa_rename_print( iptr, "arg", *argp, j);
+#endif
+                               *argp = j;
+                               argp++;
+                       }
                        break;
                }
-               in = iptr->dst;
-       }
-       /* change def of outstack Interface stackslots */
-       in = ls->basicblocks[n]->instack;
-       in_d = ls->basicblocks[n]->indepth;
-       out = ls->basicblocks[n]->outstack;
-       out_d = ls->basicblocks[n]->outdepth;
-
-       for(;in_d > out_d; in = in->prev, in_d--);
-
-       for (;out != NULL; out = out->prev, out_d--) {
-               if ((in_d < out_d) || (out != in)) {
-                       /* Def of ls->var[out_d - 1 + jd->maxlocals][out->type] */
-                       _SSA_CHECK_BOUNDS(out_d - 1 + jd->maxlocals, 0, jd->maxlocals + cd->maxstack);
-                       a = ls->var[out_d - 1 + jd->maxlocals][out->type];
-                       _SSA_CHECK_BOUNDS(a, 0, ls->max_vars);
-                       def_count[a]++;
-                       i = ssa_Rename_def(ls, n, a); 
-                       _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
-                       /* Replace use of x with xi */
- #ifdef SSA_DEBUG_VERBOSE
-                       if (compileverbose)
-                               printf("Ren def:BB %3i: stackslot: depth %3i old val: %3i Var,0: %3i varind: %3i\n", n, in_d, out->varnum, ls->var_to_index[a], ls->var_to_index[a]-i);
-#endif
-                       out->varnum = ls->var_to_index[a] - i;
-                       lt = &(ls->lifetime[-out->varnum-1]);
-                       out->varkind = TEMPVAR;
-                       lt->v_index = out->varnum;
-                       lsra_add_ss(lt, out);
                        
-                       ls->lifetime[-out->varnum-1].bb_last_use = -1;
-               }
-               if (out_d == in_d) {
-                       in_d--;
-                       in = in->prev;
-               }
-       }
-
-       /* change phi Functions of Successors */
-       Y = graph_get_first_successor(gd, n, &iter_succ);
-       for(; Y != -1; Y = graph_get_next(&iter_succ)) {
-               _SSA_CHECK_BOUNDS(Y, 0, ls->basicblockcount);
-               k = graph_get_first_predecessor(gd, Y, &iter_pred);
-               for (j = 0; (k != -1) && (k != n); j++, k = graph_get_next(&iter_pred));
-               _SSA_ASSERT(k == n);
-               /* n is jth Predecessor of Y */
-               for(a = 0; a < ls->max_vars; a++)
-                       if (ls->phi[Y][a] != NULL) {
-                               /* i <- top(stack[a]) */
-                               _SSA_CHECK_BOUNDS(ls->stack_top[a]-1, 0, ls->num_defs[a]+1);
-                               i = ls->stack[a][ls->stack_top[a]-1]; 
-                               _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
-                               /* change jth operand from a0 to ai */
-                               if (ls->var_to_index[a] >= 0) {
-                                       /* local var */
-                                       ls->phi[Y][a][j+1] += i;
-                                       _SSA_CHECK_BOUNDS(ls->phi[Y][a][j+1], 0,
-                                                                ls->local_0[ls->max_locals]);
-                                       /* use by phi function has to be remembered, too */
-                                       ssa_Rename_use(ls, n, ls->phi[Y][a][j+1]);
-                               } else {
-                                       /* interface */
-                                       ls->phi[Y][a][j+1] -= i;
-/*                                     _SSA_CHECK_BOUNDS(ls->phi[Y][a][j+1], */
-/*                                                              ls->interface_0[-ls->max_interfaces-1], 0); */
-                               }
-                       }
-       }
-       
-       /* Call ssa_Rename_ for all Childs of n of the Dominator Tree */
-       for(i = 0; i < ls->basicblockcount; i++)
-               if (dd->idom[i] == n)
-                       ssa_Rename_(cd, ls, gd, dd, i);
 
-       /* pop Stack[a] for each definition of a var a in the original S */
-       for(a = 0; a < ls->max_vars; a++) {
-               ls->stack_top[a] -= def_count[a];
-               _SSA_ASSERT(ls->stack_top[a] >= 0);
-       }
-}
+               /* Look for definitions (iptr->dst). INVOKE and BUILTIN have */
+               /* an optional dst - so they to be checked first */
 
-void ssa_Rename(methodinfo *m, codegendata *cd, registerdata *rd, lsradata *ls, 
-                               graphdata *gd, dominatordata *dd)
-{
-       int i, p, t, type, flags;
-       methoddesc *md = m->parseddesc;
+               v = UNUSED;
+               if (icmd_table[iptr->opc].dataflow == DF_INVOKE) {
+                       INSTRUCTION_GET_METHODDESC(iptr,md);
+                       if (md->returntype.type != TYPE_VOID)
+                               v = iptr->dst.varindex;
+               }
+               else if (icmd_table[iptr->opc].dataflow == DF_BUILTIN) {
+                       bte = iptr->sx.s23.s3.bte;
+                       md = bte->md;
+                       if (md->returntype.type != TYPE_VOID)
+                               v = iptr->dst.varindex;
+               }
+               else if (icmd_table[iptr->opc].dataflow >= DF_DST_BASE) {
+                       v = iptr->dst.varindex;
+               }
 
-       varinfo5 *locals;
+               if (v != UNUSED) {
+                       j = ssa_rename_def(jd, def_count, iptr->dst.varindex);
 #ifdef SSA_DEBUG_VERBOSE
-       int j;
+                       ssa_rename_print( iptr, "dst", iptr->dst.varindex, j);
 #endif
+                       iptr->dst.varindex = j;
+               }
 
-       if (ls->max_vars == 0) {
-               /* no locals or interfaces to rename */
-       /* init lifetimes */
+                               /* ?????????????????????????????????????????????????????????? */
+                               /* Mark Def as use, too. Since param initialisation is in     */
+                               /* var_def and this would not remove this locals, if not used */
+                               /* elsewhere   */
+                               /* ?????????????????????????????????????????????????????????? */
 
-               ls->maxlifetimes = /*m*/ ls->maxlifetimes + ls->basicblockcount * m->maxstack;
-               ls->lifetimecount = ls->maxlifetimes + ls->max_locals + cd->maxstack *5;
-               ls->lifetime = DMNEW(struct lifetime, ls->lifetimecount);
-               ls->lt_used = DMNEW(int, ls->lifetimecount);
-               ls->lt_int = DMNEW(int, ls->lifetimecount);
-               ls->lt_int_count = 0;
-               ls->lt_flt = DMNEW(int, ls->lifetimecount);
-               ls->lt_flt_count = 0;
-               ls->lt_mem = DMNEW(int, ls->lifetimecount);
-               ls->lt_mem_count = 0;
-               for (i=0; i < ls->lifetimecount; i++) ls->lifetime[i].type = -1;
-               return;
        }
-       
-       ssa_Rename_init(m, cd, ls, gd);
 
-       /* Consider definition of Local Vars initialized with Arguments */
-       /* in Block 0 */
-       /* init is regarded as use too-> ssa_Rename_use ->bullshit!!*/
-       for (p = 0, i= 0; p < md->paramcount; p++) {
-               t = md->paramtypes[p].type;
+       /* change outstack Interface stackslots */
+       out = ls->basicblocks[n]->outvars;
+       out_d = ls->basicblocks[n]->outdepth - 1;
 
-               /* !!!!! locals are now numbered as the parameters !!!! */
-               /* !!!!! no additional increment for 2 word types !!!!! */
-               /* this happens later on! here we still need the increment */
-           /* index of var can be in the range from 0 up to not including */
-           /* jd->maxlocals */
-               _SSA_CHECK_BOUNDS(i,0,jd->maxlocals);
-               _SSA_CHECK_BOUNDS(ls->var[i][t], 0, ls->local_0[ls->max_locals]);
-               ssa_Rename_def(ls, 0, ls->var[i][t]);
-               i++;
-               if (IS_2_WORD_TYPE(t))
-                       i++;
-       }
-       ssa_Rename_(cd, ls, gd, dd, 0);
+       for (;out_d >= 0; out_d--) {
+               /* Possible Use of ls->new_varindex[jd->var[out_d]] */
+               _SSA_ASSERT(ls->new_varindex[out[out_d]] != UNUSED);
 
-#if 0
-       /* DO _NOT_ DO THIS! Look at java.util.stringtokenizer.counttokens! */
-       /* if there is no use of the defined Var itself by the phi function */
-       /* for an loop path, in which this var is not used, it will not be life */
-       /* in this path and overwritten! */
+               a = ls->new_varindex[out[out_d]];
+               _SSA_CHECK_BOUNDS(a, 0, ls->ssavarcount);
 
-       /* Invalidate all xij from phi(xi0)=xi1,xi2,xi3,..,xin with xij == xi0 */
-       /* this happens if the phi function is the first definition of x or in a */
-       /* path with a backedge xi has no definition */ 
-       /* a phi(xij) = ...,xij,... with the only use and definition of xij by */
-       /* this phi function would otherwise "deadlock" the dead code elemination */
-       /* invalidate means set it to ls->max_vars_with_indices */
-       /* a phi function phi(xi0)=xi1,xi2,...xin wiht xij == xi0 for all j in */
-       /* [1,n] can be removed */
+               /* i <- top(stack[a]) */
 
-       for(i = 0; i < ls->max_vars; i++) {
-               for(t = 0; t < ls->basicblockcount; t++) {
-                       if (ls->phi[t][i] != 0) {
-                               remove_phi = true;
-                               for(p = 1; p <= graph_get_num_predecessor(gd, t); p++) {
-                                       if (ls->phi[t][i][0] == ls->phi[t][i][p])
-                                               ls->phi[t][i][p] = ls->max_vars_with_indices;
-                                       else 
-                                               remove_phi = false;
-                               }
-                       }
-                       if (remove_phi)
-                               ls->phi[t][i] = NULL;
-               }
-       }
-#endif
+               _SSA_CHECK_BOUNDS(ls->stack_top[a]-1, 0, ls->num_defs[a]+1);
+               i = ls->stack[a][ls->stack_top[a]-1]; 
+               _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
+
+               /* Replace use of x with xi */
 
-       /* recreate rd->locals[][] */
-       /* now only one (local_index/type) pair exists anymore     */
-       /* all var[t][i] with var_to_index[var[t][i]] >= 0 are locals */
-       /* max local index after SSA indexing is in ls->local_0[ls->max_locals] */
-       
-       locals = DMNEW(varinfo5, ls->local_0[ls->max_locals]);
-       for(i = 0; i < ls->local_0[ls->max_locals] ; i++)
-               for(t = 0; t < 5; t++)
-                       locals[i][t].type = -1;
-       for(t = 0; t < 5; t++) {
-               for(i = 0; i < jd->maxlocals; i++) {
-                       p = ls->var[i][t];
-                       if (p != -1) {
-                               _SSA_ASSERT(ls->var_to_index[p] >= 0);
-                               /* It's a local variable */
-                               p = ls->var_to_index[p];
-                               locals[p][t].type = t;
-                               locals[p][t].flags = rd->locals[i][t].flags;
 #ifdef SSA_DEBUG_VERBOSE
-                               if (compileverbose)
-                                       printf("locals %3i %3i .type = %3i\n",p,t,t);
+                       ssa_rename_print( NULL, "outvar", out[out_d], ls->var_0[a]+i);
 #endif
-                       }
-               }
+               out[out_d] = ls->var_0[a] + i;
+               lt = ls->lifetime + out[out_d];
+
+               lt->v_index = out[out_d];
+               lt->bb_last_use = -1;
        }
-       
-       type = -1;
-       flags = -1;
+
+       /* change use in phi Functions of Successors */
+
+       Y = graph_get_first_successor(gd, n, &iter_succ);
+       for(; Y != -1; Y = graph_get_next(&iter_succ)) {
+               _SSA_CHECK_BOUNDS(Y, 0, ls->basicblockcount);
+               k = graph_get_first_predecessor(gd, Y, &iter_pred);
+               for (j = 0; (k != -1) && (k != n); j++)
+                       k = graph_get_next(&iter_pred);
+               _SSA_ASSERT(k == n);
+
+               /* n is jth Predecessor of Y */
+
+               for(a = 0; a < ls->ssavarcount; a++)
+                       if (ls->phi[Y][a] != NULL) {
+
+                               /* i <- top(stack[a]) */
+                               
+                               if (ls->stack_top[a] == 1) {
+                                       /* no definition till now in controll flow */
 #ifdef SSA_DEBUG_VERBOSE
-       p = -1;
-       j = 0;
+                                       if (compileverbose) {
+                                               printf("Succ %3i Arg %3i \n", Y, j);
+                                               ssa_rename_print( NULL, "phi-use", ls->phi[Y][a][j+1], UNUSED);
+                                       }
 #endif
-       for(i = 0; i < ls->local_0[ls->max_locals]; i++) {
-               for(t = 0; (t < 5) && (locals[i][t].type == -1); t++);
-               if (t == 5) {
-                       _SSA_ASSERT(type != -1);
+                                       ls->phi[Y][a][j+1] = UNUSED;
+                               }
+                               else {
+                                       _SSA_CHECK_BOUNDS(ls->stack_top[a]-1, 0, ls->num_defs[a]+1);
+                                       i = ls->stack[a][ls->stack_top[a]-1]; 
+                                       _SSA_CHECK_BOUNDS(i, 0, ls->num_defs[a]);
+
+                                       /* change jth operand from a0 to ai */
+
+                                       i = ls->var_0[a] + i;
 #ifdef SSA_DEBUG_VERBOSE
-                       if (compileverbose) {
-                               printf("L%3i=L%3i(%3i) type %3i\n",i,p,j,type);
-                               j++;
-                       }
+                                       if (compileverbose) {
+                                               printf("Succ %3i Arg %3i \n", Y, j);
+                                               ssa_rename_print( NULL, "phi-use", ls->phi[Y][a][j+1], i);
+                                       }
 #endif
-                       locals[i][type].type = type;
-                       locals[i][type].flags = flags;
-               } else {
-                       type = locals[i][t].type;
-                       flags = locals[i][t].flags;
-#ifdef SSA_DEBUG_VERBOSE
-                       if (compileverbose) {
-                               j=0;
-                               p++;
-                               printf("L%3i=L%3i(%3i) type %3i\n",i,p,j,type);
-                               j++;
+                                       ls->phi[Y][a][j+1] = i;
+                                       _SSA_CHECK_BOUNDS(ls->phi[Y][a][j+1], 0,
+                                                                         ls->varcount_with_indices);
+
+                                       /* use by phi function has to be remembered, too */
+
+                                       ssa_rename_use_(ls, n, ls->phi[Y][a][j+1]);
+                               }
+
+                               /* ????????????????????????????????????????????? */
+                               /* why was this only for local vars before ?     */
+                               /* ????????????????????????????????????????????? */
+
                        }
-#endif
-               }
        }
-       rd->locals = locals;
-       jd->maxlocals = ls->local_0[ls->max_locals];
+       
+       /* Call ssa_rename_ for all Childs of n of the Dominator Tree */
+       for(i = 0; i < ls->basicblockcount; i++)
+               if (dd->idom[i] == n)
+                       ssa_rename_(jd, gd, dd, i);
+
+       /* pop Stack[a] for each definition of a var a in the original S */
+       for(a = 0; a < ls->ssavarcount; a++) {
+               ls->stack_top[a] -= def_count[a];
+               _SSA_ASSERT(ls->stack_top[a] >= 0);
+       }
 }
 
+
+
 #ifdef SSA_DEBUG_VERBOSE
-void ssa_print_trees(methodinfo *m, codegendata *cd, lsradata *ls,
-                                        graphdata *gd, dominatordata *dd) {
+void ssa_print_trees(jitdata *jd, graphdata *gd, dominatordata *dd) {
        int i,j;
-       printf("ssa_printtrees: maxlocals %3i", jd->maxlocals);
+       lsradata *ls;
+
+       ls = jd->ls;
+
+       printf("ssa_printtrees: maxlocals %3i", jd->localcount);
                
        printf("Dominator Tree: \n");
        for(i = 0; i < ls->basicblockcount; i++) {
@@ -1009,10 +1380,10 @@ void ssa_print_trees(methodinfo *m, codegendata *cd, lsradata *ls,
                }
                printf("\n");
        }
-
-       if (ls->max_locals > 0) {
+#if 0
+       if (ls->ssavarcount > 0) {
        printf("Use Sites\n");
-       for(i = 0; i < ls->max_locals; i++) {
+       for(i = 0; i < ls->ssavarcount; i++) {
                printf("use_sites[%3i]=%p:",i,(void *)ls->use_sites[i]);
                for(j = 0; j < ls->basicblockcount; j++) {
                        if ((j % 5) == 0) printf(" ");
@@ -1024,11 +1395,11 @@ void ssa_print_trees(methodinfo *m, codegendata *cd, lsradata *ls,
                printf("\n");
        }
        }
-
+#endif
        printf("var Definitions:\n");
-       for(i = 0; i < ls->basicblockcount; i++) {
+       for(i = 0; i < jd->basicblockcount; i++) {
                printf("var_def[%3i]=%p:",i,(void *)ls->var_def[i]);
-               for(j = 0; j < ls->max_vars; j++) {
+               for(j = 0; j < ls->ssavarcount; j++) {
                        if ((j % 5) == 0) printf(" ");
                        if (bv_get_bit(ls->var_def[i], j))
                                printf("1");
@@ -1036,20 +1407,20 @@ void ssa_print_trees(methodinfo *m, codegendata *cd, lsradata *ls,
                                printf("0");
                }
                printf(" (");
-               for(j=0; j < ((((ls->max_vars * 5+7)/8) + sizeof(int) - 1)/sizeof(int));
+               for(j=0; j < ((((ls->ssavarcount * 5+7)/8) + sizeof(int) - 1)/sizeof(int));
                        j++)
                        printf("%8x",ls->var_def[i][j]);
-               printf("\n");
+               printf(")\n");
        }
 }
 
 void ssa_print_phi(lsradata *ls, graphdata *gd) {
        int i,j,k;
 
-       printf("phi Functions (max_vars_with_indices: %3i):\n", 
-                  ls->max_vars_with_indices);
+       printf("phi Functions (varcount_with_indices: %3i):\n", 
+                  ls->varcount_with_indices);
        for(i = 0; i < ls->basicblockcount; i++) {
-               for(j = 0; j < ls->max_vars; j++) {
+               for(j = 0; j < ls->ssavarcount; j++) {
                        if (ls->phi[i][j] != NULL) {
                                printf("BB %3i %3i = phi(", i, ls->phi[i][j][0]);
                                for(k = 1; k <= graph_get_num_predecessor(gd, i); k++)
@@ -1063,20 +1434,39 @@ void ssa_print_phi(lsradata *ls, graphdata *gd) {
 
 #endif
 
-void ssa_generate_phi_moves(lsradata *ls, graphdata *gd) {
+void ssa_generate_phi_moves(jitdata *jd, graphdata *gd) {
        int a, i, j, pred;
        graphiterator iter;
+       lsradata *ls;
+
+       ls = jd->ls;
 
        /* count moves to be inserted at the end of each block in moves[] */
        ls->num_phi_moves = DMNEW(int, ls->basicblockcount);
        for(i = 0; i < ls->basicblockcount; i++)
                ls->num_phi_moves[i] = 0;
        for(i = 0; i < ls->basicblockcount; i++)
-               for(a = 0; a < ls->max_vars; a++)
+               for(a = 0; a < ls->ssavarcount; a++)
                        if (ls->phi[i][a] != NULL) {
-                               pred = graph_get_first_predecessor(gd, i, &iter);
-                               for(; pred != -1; pred = graph_get_next(&iter)) {
-                                       ls->num_phi_moves[pred]++;
+#if 0
+                               if (ls->lifetime[ls->phi[i][a][0]].use == NULL) {
+                                       /* Var defined (only <- SSA Form!) in this phi function */
+                                       /* and not used anywhere -> delete phi function and set */
+                                       /* var to unused */
+
+                                       /* TODO: first delete use sites of arguments of phi */
+                                       /* function */
+                                       VAR(ls->lifetime[ls->phi[i][a][0]].v_index)->type = UNUSED;
+                                       ls->lifetime[ls->phi[i][a][0]].def = NULL;
+                                       ls->phi[i][a] = NULL;
+                               }
+                               else 
+#endif
+                                       {
+                                       pred = graph_get_first_predecessor(gd, i, &iter);
+                                       for(; pred != -1; pred = graph_get_next(&iter)) {
+                                               ls->num_phi_moves[pred]++;
+                                       }
                                }
                        }
 
@@ -1086,24 +1476,29 @@ void ssa_generate_phi_moves(lsradata *ls, graphdata *gd) {
                ls->phi_moves[i] = DMNEW( int *, ls->num_phi_moves[i]);
                for(j = 0; j <ls->num_phi_moves[i]; j++)
                        ls->phi_moves[i][j] = DMNEW(int, 2);
+#ifdef SSA_DEBUG_VERBOSE
+               if (compileverbose)
+                       printf("ssa_generate_phi_moves: ls_num_phi_moves[%3i] = %3i\n",
+                                  i, ls->num_phi_moves[i]);
+#endif
        }
 
        /* populate ls->phi_moves */
        for(i = 0; i < ls->basicblockcount; i++)
                ls->num_phi_moves[i] = 0;
        for(i = 0; i < ls->basicblockcount; i++)
-               for(a = 0; a < ls->max_vars; a++)
+               for(a = 0; a < ls->ssavarcount; a++)
                        if (ls->phi[i][a] != NULL) {
                                pred = graph_get_first_predecessor(gd, i, &iter);
                                for(j = 0; pred != -1; j++, pred = graph_get_next(&iter)) {
                                        /* target is phi[i][a][0] */
                                        /* source is phi[i][a][j+1] */
-                                       if (ls->phi[i][a][j+1] != ls->max_vars_with_indices) {
+                                       if (ls->phi[i][a][j+1] != ls->varcount_with_indices) {
                                                /* valid move */
                                                if (ls->phi[i][a][0] != ls->phi[i][a][j+1]) {
                                                        ls->phi_moves[pred][ls->num_phi_moves[pred]][0] =
                                                                ls->phi[i][a][0];
-                                                       ls->phi_moves[pred][(ls->num_phi_moves[pred])++][1] = 
+                                                       ls->phi_moves[pred][(ls->num_phi_moves[pred])++][1]=
                                                                ls->phi[i][a][j+1];
                                                }
                                        }
@@ -1111,129 +1506,32 @@ void ssa_generate_phi_moves(lsradata *ls, graphdata *gd) {
                        }
 }
 
-
-void ssa(jitdata *jd, graphdata *gd) {
-       struct dominatordata *dd;
-       methodinfo *m;
-       codegendata *cd;
-       registerdata *rd;
-       lsradata *ls;
-
-       m = jd->m;
-       cd = jd->cd;
-       rd = jd->rd;
-       ls = jd->ls;
-
-       dd = compute_Dominators(gd, ls->basicblockcount);
-       computeDF(gd, dd, ls->basicblockcount, 0);
-
-       ssa_place_phi_functions(cd, ls, gd, dd);
-       ssa_Rename(m, cd, rd, ls, gd, dd);
-#ifdef SSA_DEBUG_VERBOSE
-       if (compileverbose) {
-               printf("Phi before Cleanup\n");
-               ssa_print_phi(ls, gd);
-               ssa_print_lt(ls);
-       }
-#endif
-       scan_lifetimes(m, cd, rd, ls, gd, dd);
-#ifdef SSA_DEBUG_VERBOSE
-       if (compileverbose) {
-               ssa_print_lt(ls);
-       }
-#endif
-       dead_code_elimination(m, rd, ls, gd);
-#ifdef SSA_DEBUG_VERBOSE
-       if (compileverbose) {
-               printf("Phi after dead code elemination\n");
-               ssa_print_phi(ls, gd);
-               ssa_print_lt(ls);
-       }
-#endif
-       copy_propagation(m, rd, ls, gd);
-#ifdef SSA_DEBUG_VERBOSE
-       if (compileverbose) {
-               printf("Phi after copy propagation\n");
-               ssa_print_phi(ls, gd);
-               ssa_print_lt(ls);
-       }
-#endif
-
-       ssa_generate_phi_moves(ls, gd);
-       transform_BB(jd, gd);
-
-
-#ifdef SSA_DEBUG_CHECK
-       {
-               int i, j, pred, in_d, out_d;
-               graphiterator iter_pred;
-               stackptr in, out;
-               bool phi_define;
-
-               for(i = 0; i < ls->basicblockcount; i++) {
-                       if (ls->basicblocks[i]->indepth != 0) {
-                               pred = graph_get_first_predecessor(gd, i, &iter_pred);
-                               for (; (pred != -1); pred = graph_get_next(&iter_pred)) {
-                                       in_d = ls->basicblocks[i]->indepth;
-                                       in = ls->basicblocks[i]->instack;
-                                       for (;in_d > 0; in_d--, in = in->prev) {
-                                               phi_define = false;
-                                               for (j = 0; (!phi_define) && (j < ls->max_vars); j++) {
-                                                       if (ls->phi[i][j] != NULL)
-                                                               if (ls->phi[i][j][0] == in->varnum)
-                                                                       phi_define = true;
-                                               }
-                                               if (!phi_define) {
-                                                       /* in not defined in phi function -> check with outstack(s) */
-                                                       /* of predecessor(s) */
-                                                       out_d = ls->basicblocks[pred]->outdepth;
-                                                       out = ls->basicblocks[pred]->outstack;
-                                                       _SSA_ASSERT(out_d >= in_d);
-                                                       for(; out_d > in_d; out_d--, out = out->prev);
-                                                       if ((in->varnum != out->varnum) || 
-                                                               (in->varkind != out->varkind)) {
-                                                               printf("Method: %s %s\n", m->class->name->text, m->name->text);
-                                                                       printf("Error: Stack Varnum Mismatch BBin %3i BBout %3i Stackdepth %3i\n", i, pred, in_d);
-                                                               if (compileverbose)
-                                                                       printf("Error: Stack Varnum Mismatch BBin %3i BBout %3i Stackdepth %3i\n", i, pred, in_d);
-/*                                                             else */
-/*                                                                     _SSA_ASSERT(0); */
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-
-#endif
-
-
-#ifdef SSA_DEBUG_VERBOSE
-       if (compileverbose)
-               ssa_print_trees(m,cd,ls, gd, dd);
-#endif
-}
-
 /****************************************************************************
-Optimization
+Optimizations
 ****************************************************************************/
 
 
 /****************************************************************************
 Dead Code Elimination
 ****************************************************************************/
-void dead_code_elimination(methodinfo *m,registerdata *rd, lsradata *ls, graphdata *gd) {
+void dead_code_elimination(jitdata *jd, graphdata *gd) {
        int a, i, source;
        worklist *W;
 
        instruction *iptr;
-       stackptr src;
        struct lifetime *lt, *s_lt;
 
        bool remove_statement;
        struct site *use;
 
+       lsradata *ls;
+#ifdef SSA_DEBUG_VERBOSE
+       methodinfo *m;
+
+       m  = jd->m;
+#endif
+       ls = jd->ls;
+
        W = wl_new(ls->lifetimecount);
        if (ls->lifetimecount > 0) {
                /* put all lifetimes on Worklist */
@@ -1288,28 +1586,24 @@ void dead_code_elimination(methodinfo *m,registerdata *rd, lsradata *ls, graphda
                                for (i = 1;i <= graph_get_num_predecessor(gd, lt->def->b_index);
                                         i++) 
                                        {
-                                               source = ls->phi[lt->def->b_index][-lt->def->iindex-1][i];
-                                               if ((source != ls->max_vars_with_indices) && 
+                                               source =
+                                                       ls->phi[lt->def->b_index][-lt->def->iindex-1][i];
+                                               if ((source != ls->varcount_with_indices) && 
                                                        (source != lt->v_index)) {
+
                                                        /* phi Argument was not already removed (already in 
                                                           because of selfdefinition) */
-                                                       if (source >= 0) {
-                                                               /* Local Var */
-                                                               s_lt = &(ls->lifetime[ls->maxlifetimes + source]);
-                                                       } else {
-                                                               /* Interface Stackslot */
-                                                               s_lt = &(ls->lifetime[-source-1]);
-                                                       }
+
+                                                       s_lt = &(ls->lifetime[source]);
+
                                                        /* remove it */
-                                                       remove_use_site(s_lt,lt->def->b_index, lt->def->iindex);
+
+                                                       lt_remove_use_site(s_lt,lt->def->b_index,
+                                                                                       lt->def->iindex);
+
                                                        /*  put it on the Worklist */
-                                                       if (source >= 0) {
-                                                               /* Local Var */
-                                                               wl_add(W, ls->maxlifetimes + source);
-                                                       } else {
-                                                               /* Interface Stackslot */
-                                                               wl_add(W, -source - 1);
-                                                       }
+
+                                                       wl_add(W, source);
                                                }
                                        }
                                /* now delete phi function itself */
@@ -1318,210 +1612,68 @@ void dead_code_elimination(methodinfo *m,registerdata *rd, lsradata *ls, graphda
                                /* "normal" Use by ICMD */
                                remove_statement = false;
                                if (lt->def->b_index != 0) {
+
                                        /* do not look at artificial block 0 (parameter init) */
+
                                        iptr = ls->basicblocks[lt->def->b_index]->iinstr + 
                                                lt->def->iindex;
 
                                        if (icmd_table[iptr->opc].flags & ICMDTABLE_PEI)
                                                remove_statement = false;
+
                                        /* if ICMD could throw an exception do not remove it! */
-                                       else {
-                                               /* get src stack */
-                                               if (lt->def->iindex == 0)
-                                                       src = ls->basicblocks[lt->def->b_index]->instack;
-                                               else
-                                                       src = (iptr-1)->dst;
-        
-                                               remove_statement = true;
-                                               /* Statement has side effects? (== ICMD_INVOKE*) */
-                                               switch (iptr->opc) {
-                                               case ICMD_INVOKEVIRTUAL:
-                                               case ICMD_INVOKESPECIAL:
-                                               case ICMD_INVOKESTATIC:
-                                               case ICMD_INVOKEINTERFACE:
-                                               case ICMD_BUILTIN:   
-                                                       /* check if really a side effect is possible */
-                                               case ICMD_MULTIANEWARRAY: /* here, too */
-                                                       /* side effects by Statement possible -> 
-                                                          do not remove it */
-                                                       remove_statement = false;
-                                                       break;
 
-                                                       /* delete use of vars by these statments: */
-
-                                                       /* use of iptr->op1 */
-                                               case ICMD_IINC:
-                                               case ICMD_ILOAD:
-                                               case ICMD_LLOAD:
-                                               case ICMD_FLOAD:
-                                               case ICMD_DLOAD:
-                                               case ICMD_ALOAD:
-                                                       s_lt = &(ls->lifetime[ls->maxlifetimes + iptr->op1]);
-                                                       remove_use_site(s_lt,lt->def->b_index, lt->def->iindex);
-                                                       /* put it on the Worklist */
-                                                       wl_add(W, ls->maxlifetimes + iptr->op1);
-                                                       break;
+                                       else {
 
-                                                       /* remove src->prev and src */
-                                               case ICMD_IALOAD:
-                                               case ICMD_LALOAD:
-                                               case ICMD_FALOAD:
-                                               case ICMD_DALOAD:
-                                               case ICMD_AALOAD:
-
-                                               case ICMD_BALOAD:
-                                               case ICMD_CALOAD:
-                                               case ICMD_SALOAD:
-
-                                               case ICMD_LADD:
-                                               case ICMD_LSUB:
-                                               case ICMD_LMUL:
-
-                                               case ICMD_LOR:
-                                               case ICMD_LAND:
-                                               case ICMD_LXOR:
-
-                                               case ICMD_LSHL:
-                                               case ICMD_LSHR:
-                                               case ICMD_LUSHR:
-
-                                               case ICMD_IADD:
-                                               case ICMD_IMUL:
-
-                                               case ICMD_ISHL:
-                                               case ICMD_ISHR:
-                                               case ICMD_IUSHR:
-                                               case ICMD_IAND:
-                                               case ICMD_IOR:
-                                               case ICMD_IXOR:
-
-
-                                               case ICMD_FADD:
-                                               case ICMD_FSUB:
-                                               case ICMD_FMUL:
-
-                                               case ICMD_DADD:
-                                               case ICMD_DSUB:
-                                               case ICMD_DMUL:
-                                               case ICMD_DDIV:
-                                               case ICMD_DREM:
-                                               case ICMD_ISUB:
-                                               case ICMD_LDIV:
-                                               case ICMD_LREM:
-
-                                               case ICMD_IDIV:
-                                               case ICMD_IREM:
-
-                                               case ICMD_FDIV:
-                                               case ICMD_FREM:
-
-                                               case ICMD_LCMP:
-                                               case ICMD_FCMPL:
-                                               case ICMD_FCMPG:
-                                               case ICMD_DCMPL:
-                                               case ICMD_DCMPG:
-                                                       /* Remove src->prev and then "fall through" for removal
-                                                          of src */
-                                                       s_lt = &(ls->lifetime[-src->prev->varnum-1]);
-                                                       remove_use_site(s_lt,lt->def->b_index, lt->def->iindex);
-                                                       /* put it on the Worklist */
-                                                       wl_add(W, -src->prev->varnum - 1);
-                                                       /* remove src */
-                                               case ICMD_ISTORE:
-                                               case ICMD_LSTORE:
-                                               case ICMD_FSTORE:
-                                               case ICMD_DSTORE:
-                                               case ICMD_ASTORE:
-                                               case ICMD_LADDCONST:
-                                               case ICMD_LSUBCONST:
-                                               case ICMD_LMULCONST:
-                                               case ICMD_LMULPOW2:
-                                               case ICMD_LDIVPOW2:
-                                               case ICMD_LREMPOW2:
-                                               case ICMD_LANDCONST:
-                                               case ICMD_LORCONST:
-                                               case ICMD_LXORCONST:
-                                               case ICMD_LSHLCONST:
-                                               case ICMD_LSHRCONST:
-                                               case ICMD_LUSHRCONST:
-
-                                               case ICMD_IADDCONST:
-                                               case ICMD_ISUBCONST:
-                                               case ICMD_IMULCONST:
-                                               case ICMD_IMULPOW2:
-                                               case ICMD_IDIVPOW2:
-                                               case ICMD_IREMPOW2:
-                                               case ICMD_IANDCONST:
-                                               case ICMD_IORCONST:
-                                               case ICMD_IXORCONST:
-                                               case ICMD_ISHLCONST:
-                                               case ICMD_ISHRCONST:
-                                               case ICMD_IUSHRCONST:
-
-                                                       /*                                      case ICMD_IFEQ_ICONST: */
-                                                       /*                                      case ICMD_IFNE_ICONST: */
-                                                       /*                                      case ICMD_IFLT_ICONST: */
-                                                       /*                                      case ICMD_IFGE_ICONST: */
-                                                       /*                                      case ICMD_IFGT_ICONST: */
-                                                       /*                                      case ICMD_IFLE_ICONST: */
-
-                                               case ICMD_INEG:
-                                               case ICMD_INT2BYTE:
-                                               case ICMD_INT2CHAR:
-                                               case ICMD_INT2SHORT:
-                                               case ICMD_LNEG:
-                                               case ICMD_FNEG:
-                                               case ICMD_DNEG:
-
-                                               case ICMD_I2L:
-                                               case ICMD_I2F:
-                                               case ICMD_I2D:
-                                               case ICMD_L2I:
-                                               case ICMD_L2F:
-                                               case ICMD_L2D:
-                                               case ICMD_F2I:
-                                               case ICMD_F2L:
-                                               case ICMD_F2D:
-                                               case ICMD_D2I:
-                                               case ICMD_D2L:
-                                               case ICMD_D2F:
-                                               case ICMD_CHECKCAST:
-                                               case ICMD_ARRAYLENGTH:
-                                               case ICMD_INSTANCEOF:
-
-                                               case ICMD_NEWARRAY:
-                                               case ICMD_ANEWARRAY:
-
-                                               case ICMD_GETFIELD:
-                                                       /* Remove src->prev and then "fall through" for removal
-                                                          of src */
-                                                       s_lt = &(ls->lifetime[-src->varnum-1]);
-                                                       remove_use_site(s_lt,lt->def->b_index, lt->def->iindex);
-                                                       /* put it on the Worklist */
-                                                       wl_add(W, -src->varnum - 1);
-                                                       break;
-                                                       /* ignore these for now */
-                                               case ICMD_DUP:
-                                               case ICMD_DUP2:
-                                               case ICMD_DUP_X1:
-                                               case ICMD_DUP_X2:
-                                               case ICMD_DUP2_X1:
-                                               case ICMD_DUP2_X2:
-                                               case ICMD_SWAP:
-#ifdef SSA_DEBUG_VERBOSE
-                                                       if (compileverbose)
-                                                               printf("INFO2: ICMD_DUPX to be removed\n");
-#endif
-                                                       /* DUPX has sideefects - cannot be removed, only because
-                                                          one of the output vars is unused
-                                                          TODO: extend the dead code elimination, so that all 
-                                                          output ss are checked*/
-                                                       remove_statement = false;
-                                                       break;
-                                               } /* switch (iptr->opc) */
+                                               /* ICMD_INVOKE*, ICMD_BUILTIN and ICMD_MULTIANEWARRAY */
+                                               /* have possible sideeffects -> do not remove them    */
+
+/*                                             remove_statement = !(ICMD_HAS_SPECIAL(iptr->opc)); */
+
+                                               remove_statement = !(
+                                                       (icmd_table[iptr->opc].dataflow == DF_INVOKE) ||
+                                                       (icmd_table[iptr->opc].dataflow == DF_BUILTIN) ||
+                                                       (icmd_table[iptr->opc].dataflow == DF_N_TO_1));
+
+                                               if (remove_statement) {
+                                                       switch (icmd_table[iptr->opc].dataflow) {
+                                                       case DF_3_TO_0:
+                                                       case DF_3_TO_1: /* icmd has s1, s2 and s3 */
+                                                               a = iptr->sx.s23.s3.varindex;
+                                                               s_lt = ls->lifetime + a;
+                                                               lt_remove_use_site(s_lt, lt->def->b_index,
+                                                                                                  lt->def->iindex);
+                                                               wl_add(W, a);
+
+                                                               /* now "fall through" for handling of s2 and s1 */
+
+                                                       case DF_2_TO_0:
+                                                       case DF_2_TO_1: /* icmd has s1 and s2 */
+                                                               a = iptr->sx.s23.s2.varindex;
+                                                               s_lt = ls->lifetime + a;
+                                                               lt_remove_use_site(s_lt, lt->def->b_index,
+                                                                                                  lt->def->iindex);
+                                                               wl_add(W, a);
+
+                                                               /* now "fall through" for handling of s1 */
+
+                                                       case DF_1_TO_0:
+                                                       case DF_1_TO_1:
+                                                       case DF_MOVE:
+                                                       case DF_COPY:
+                                                               a = iptr->s1.varindex;
+                                                               s_lt = ls->lifetime + a;
+                                                               lt_remove_use_site(s_lt, lt->def->b_index,
+                                                                                                  lt->def->iindex);
+                                                               wl_add(W, a);
+                                                       }
+                                               }
                                        }
+
                                        if (remove_statement) {
+
                                                /* remove statement */
+
 #ifdef SSA_DEBUG_VERBOSE
                                                if (compileverbose)
                                                        printf("INFO: %s %s:at BB %3i II %3i NOP-<%s\n",
@@ -1533,117 +1685,27 @@ void dead_code_elimination(methodinfo *m,registerdata *rd, lsradata *ls, graphda
                                        }
                                } /* (lt->def->b_index != 0) */
                        } /* if (lt->def->iindex < 0 ) else */
+
                        /* remove definition of a */
-                       if (lt->v_index >= 0) {
-                               /* local var */
-                               rd->locals[lt->v_index][lt->type].type = -1;
-                       }
+
+                       VAR(lt->v_index)->type = -1;
                        lt->type = -1;
                        lt->def = NULL;
                } /* if (lt->use == NULL) */
-               
        } /* while(!wl_is_empty(W)) */
 } /* dead_code_elimination */
 
-
-
-#if 0
-void dead_code_elimination(registerdata *rd, lsradata *ls, graphdata *gd) {
-       int A,a,i,n,t;
-       bool is_empty;
-
-       int *W_stack;
-       int W_top;
-
-       W_top = 0;
-       if (ls->max_locals > 0) {
-               W_stack = DMNEW(int, ls->max_vars);
-               /* put unused local vars on Worklist */
-               for(a = 0; a < ls->local_0[ls->max_locals]; a++) {
-                       if (bv_is_empty(ls->use_sites[a], ls->basicblockcount)) {
-                               /* a is not used */
-                               W_stack[W_top++] = a;
-                       }
-               }
-       }
-       /* Remove unused local vars */
-       while(W_top > 0) {
-               /* take a var out of Worklist */
-               a = W_stack[--W_top];
-
-               if (bv_is_empty(ls->use_sites[a], ls->basicblockcount)) {
-                       for(t = 0; t < 5; t++)
-                               rd->locals[a][t].type = -1;
-               }
-               /* Change and if necessary delete phi functions */
-               for(n = 0; n < ls->basicblockcount; n++) {
-                       for(A = 0; A < ls->max_vars; A++) {
-                               if (ls->var_to_index[A] >= 0) {
-                               if (ls->phi[n][A] != NULL) {
-                                       is_empty = true;
-                                       /* look through the arguments of the phi function */
-                                       for(i = 1; i < (graph_get_num_predecessor(gd, n)+1); i++) {
-                                               /* check if entry was not already removed */
-                                               if (ls->phi[n][A][i] != -1) {
-                                                       if (bv_is_empty(ls->use_sites[ls->phi[n][A][i]],
-                                                                                               ls->basicblockcount))
-                                                               {
-                                                                       ls->num_var_use[n][ls->phi[n][A][i]]--;
-                                                                       if (ls->num_var_use[n][ls->phi[n][A][i]] ==
-                                                                               0) {
-                                                                /* this was the only use in this Basic Block */
-                                                                               bv_reset_bit(
-                                                                                    ls->use_sites[ls->phi[n][A][i]],n);
-                                                                               if (bv_is_empty(
-                                                                                           ls->use_sites[ls->phi[n][A][i]],
-                                                                                               ls->basicblockcount))
-                                                                                       {
-                                                                /* this was the only use in the whole Method */
-                                                                /* -> put this local var on the Worklist     */
-                                                                                               W_stack[W_top++] =
-                                                                                                       ls->phi[n][A][i];
-                                                                                       }
-                                                                       }
-                                                                       ls->phi[n][A][i] = -1;
-                                                               } else
-                                                               is_empty = false;
-                                               }
-                                       }
-                                       /* look at the target of the phi function */
-                                       /* Remove it,if target is not used or all arguments where */
-                                       /* removed */
-                                       if (bv_is_empty(ls->use_sites[ls->phi[n][A][0]],
-                                                                               ls->basicblockcount) || is_empty) {
-                                               /* phi function can be removed */
-                                               ls->phi[n][A] = NULL;
-                                       }
-                               } /* if (ls->phi[n][A] != NULL) */
-                               } /* if (ls->var_to_index[A] >= 0 */
-                       } /* for(li = 0; li < ls->max_locals; li++) */
-               } /* for(n = 0; n < ls->basicblockcount; n++) */
-       } /* while(W_top>0) */
-       /* Remove unused Local Vars from rd->local */
-       if (ls->max_locals > 0)
-               for(a = 0; a < ls->local_0[ls->max_locals]; a++) {
-                       if (bv_is_empty(ls->use_sites[a], ls->basicblockcount)) {
-                               /* a is not used */
-                               for(t = 0; t < 5; t++)
-                                       rd->locals[a][t].type = -1;
-                       }
-               }       
-}
-#endif
 /****************************************************************************
 Simple Constant Propagation
 ****************************************************************************/
 
 void simple_constant_propagation() {
 }
+
 /****************************************************************************
 Optimization
 *******************************************************************************/
-void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
-                                         graphdata *gd) {
+void copy_propagation(jitdata *jd, graphdata *gd) {
        int a, i, source;
        int only_source;
 
@@ -1651,8 +1713,11 @@ void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
 
        instruction *iptr;
        struct lifetime *lt, *s_lt;
-       struct stackslot *ss;
-       stackptr in;
+       s4 *in;
+
+       lsradata *ls;
+
+       ls = jd->ls;
 
        W = wl_new(ls->lifetimecount);
        if (ls->lifetimecount > 0) {
@@ -1668,69 +1733,70 @@ void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
                /* take a var out of Worklist */
                a = wl_get(W);
 
-               lt = &(ls->lifetime[a]);
+               lt = ls->lifetime + a;
                if (lt->type == -1)
                        continue;
                _SSA_ASSERT(lt->def != NULL);
                _SSA_ASSERT(lt->use != NULL);
                if (lt->def->iindex < 0 ) {
+
                        /* phi function */
                        /* look, if phi function degenerated to a x = phi(y) */
                        /* and if so, substitute y for every use of x */
 
                        _SSA_ASSERT(ls->phi[lt->def->b_index][-lt->def->iindex-1] != NULL);
 
-                       only_source = ls->max_vars_with_indices;
+                       only_source = ls->varcount_with_indices;
                        for (i = 1; i <= graph_get_num_predecessor(gd, lt->def->b_index);
                                 i++) {
                                        source = ls->phi[lt->def->b_index][-lt->def->iindex-1][i];
-                                       if (source != ls->max_vars_with_indices) {      
-                                               if (only_source == ls->max_vars_with_indices) {
+                                       if (source != ls->varcount_with_indices) {      
+                                               if (only_source == ls->varcount_with_indices) {
                                                        /* first valid source argument of phi function */
                                                        only_source = source;
                                                } else {
                                                        /* second valid source argument of phi function */
                                                        /* exit for loop */
-                                                       only_source = ls->max_vars_with_indices;
+                                                       only_source = ls->varcount_with_indices;
                                                        break;
                                                }
                                        }
                        }
-                       if (only_source != ls->max_vars_with_indices) {
+                       if (only_source != ls->varcount_with_indices) {
+                               
                                /* replace all use sites of lt with the var_index only_source */
-                               replace_use_sites( ls, gd, lt, only_source, W);
+
+                               ssa_replace_use_sites( jd, gd, lt, only_source, W);
 
                                /* delete def of lt and replace uses of lt with "only_source" */
+
                                ls->phi[lt->def->b_index][-lt->def->iindex-1] = NULL;
 
-                               if (only_source >= 0) {
-                                       /* Local Var */
-                                       s_lt = &(ls->lifetime[ls->maxlifetimes + only_source]);
-                                       rd->locals[lt->v_index][lt->type].type = -1;
-                               } else {
-                                       /* Interface Stackslot */
-                                       s_lt = &(ls->lifetime[-only_source-1]);
-                               }
-                               remove_use_site(s_lt, lt->def->b_index, lt->def->iindex);
+                               s_lt = ls->lifetime + only_source;
+
+                               VAR(lt->v_index)->type = -1;
+                               lt_remove_use_site(s_lt, lt->def->b_index, lt->def->iindex);
                                lt->def = NULL;
                                /* move use sites from lt to s_lt */
-                               move_use_sites(lt, s_lt);
-                               move_stackslots(lt, s_lt);
+                               lt_move_use_sites(lt, s_lt);
                                lt->type = -1;
-                       } /* if (only_source != ls->max_vars_with_indices) */
+                       } /* if (only_source != ls->varcount_with_indices) */
                } else { /* if (lt->def->iindex < 0 )*/ 
                        /* def in "normal" ICMD */
+#if 0
                        iptr = ls->basicblocks[lt->def->b_index]->iinstr + 
                                lt->def->iindex;
-                       if (lt->v_index >= 0) {
+               
+                       if ( localvar ) {
                                if (lt->def->b_index == 0)
                                        continue;
+                               
                                switch(iptr->opc) {
                                case ICMD_ISTORE:
                                case ICMD_LSTORE:
                                case ICMD_FSTORE:
                                case ICMD_DSTORE:
-                               case ICMD_ASTORE:
+                       case ICMD_ASTORE:
                                        if (lt->def->iindex == 0) {
                                                /* first instruction in bb -> instack==bb->instack */
                                                in = ls->basicblocks[lt->def->b_index]->instack;
@@ -1745,16 +1811,16 @@ void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
                                                        printf("copy propagation xstore: BB %3i I %3i: %3i -> %3i\n", lt->def->b_index, lt->def->iindex, iptr->op1, in->varnum);
 #endif
                                                s_lt = &(ls->lifetime[-in->varnum-1]);
-
+                                               
                                                for (ss = s_lt->local_ss; ss != NULL; ss = ss->next) {
                                                        ss->s->varkind = LOCALVAR;
                                                        ss->s->varnum = iptr->op1;
                                                }
-
+                                               
                                                /* replace all use sites of s_lt with the var_index */
                                                /* iptr->op1 */
 
-                                               replace_use_sites(ls, gd, s_lt, iptr->op1, W);
+                                               ssa_replace_use_sites(jd, gd, s_lt, iptr->op1, W);
                                
                                                /* s_lt->def is the new def site of lt */
                                                /* the old ->def site will get a use site of def */
@@ -1816,7 +1882,7 @@ void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
 
                                                /* replace all use sites of lt with the var_index iptr->op1*/
 
-                                               replace_use_sites( ls, gd, lt, iptr->op1, W);
+                                               ssa_replace_use_sites(jd, gd, lt, iptr->op1, W);
                                
                                                lt->def = NULL;
 
@@ -1830,34 +1896,45 @@ void copy_propagation(methodinfo *m,registerdata *rd, lsradata *ls,
                                                if (lt->local_ss->s->varnum != iptr->op1)
                                                        printf("copy propagation: ILOAD -> LOCALVAR ss BB %i II %i\n",
                                                                   lt->def->b_index, lt->def->iindex);
-
+                                       
                                        break;
                                }
-                       }       
-               }
-       }
+                       } /* localvar or interface stackslot */
+#endif
+               } /* i(lt->def->iindex < 0 ) */
+               
+       } /* while(!wl_is_empty(W)) */
 }
 
-void replace_use_sites( lsradata *ls, graphdata *gd, struct lifetime *lt,
-                                               int new_v_index, worklist *W) {
+void ssa_replace_use_sites(jitdata *jd, graphdata *gd, struct lifetime *lt,
+                                                  int new_v_index, worklist *W) {
        struct site *s;
        int i, source;
        instruction *iptr;
-       struct stackslot *ss;
+       s4 *argp;
+
+       methoddesc *md;
+       builtintable_entry *bte;
+       lsradata *ls;
+
+       ls = jd->ls;
+       md = jd->m->parseddesc;
+       
 
        for(s = lt->use; s != NULL; s = s->next) {
                if (s->iindex < 0) {
+
                        /* Use in phi function */
-                       for (i = 1;i <= graph_get_num_predecessor(gd,s->b_index);
-                                i++) {
+
+                       for (i = 1;i <= graph_get_num_predecessor(gd, s->b_index); i++) {
                                source = ls->phi[s->b_index][-s->iindex-1][i];
                                if (source == lt->v_index) {    
 #ifdef SSA_DEBUG_VERBOSE
                                        if (W != NULL) {
-                                       if (compileverbose)
-                                               printf("copy propagation phi: BB %3i I %3i: %3i -> \
+                                               if (compileverbose)
+                                                       printf("copy propagation phi: BB %3i I %3i: %3i -> \
                                      %3i\n", s->b_index, s->iindex,
-                                                          new_v_index, source);
+                                                                  new_v_index, source);
                                        }
 #endif
                                        ls->phi[s->b_index][-s->iindex-1][i]
@@ -1865,67 +1942,110 @@ void replace_use_sites( lsradata *ls, graphdata *gd, struct lifetime *lt,
                                }
                        }
                        if (W != NULL) {
+
                                /* Add var, which is defined by this phi function to */
                                /* the worklist */
+
                                source = ls->phi[s->b_index][-s->iindex-1][0];
-                               if (source >= 0) {
-                                       /* Local Var */
-                                       wl_add(W, ls->maxlifetimes + source);
-                               } else {
-                                       /* Interface Stackslot */
-                                       wl_add(W, -source - 1);
-                               }
+                               wl_add(W, source);
                        }
-               } else {
-                       /* use in ICMD */
+               }
+               else { /* use in ICMD */
        
                        iptr = ls->basicblocks[s->b_index]->iinstr + 
                                s->iindex;
-                       if (lt->v_index >= 0) {
-                               /* Local Var use */
-                               switch(iptr->opc) {
-                               case ICMD_ILOAD:
-                               case ICMD_LLOAD:
-                               case ICMD_FLOAD:
-                               case ICMD_DLOAD:
-                               case ICMD_ALOAD:
-                               case ICMD_ISTORE:
-                               case ICMD_LSTORE:
-                               case ICMD_FSTORE:
-                               case ICMD_DSTORE:
-                               case ICMD_ASTORE:
-                               case ICMD_IINC: /* iptr->op1 == USE */
-                                       /* TODO: check if for XSTORE not src->varnum has */
-                                       /* to be changed instead of iptr->op1 */
-                                       _SSA_ASSERT(iptr->op1 == lt->v_index);
+
+               /* check for use (s1, s2, s3 or special (argp) ) */
+
+                       i = UNUSED;
+                       switch (icmd_table[iptr->opc].dataflow) {
+                       case DF_3_TO_0:
+                       case DF_3_TO_1: /* icmd has s1, s2 and s3 */
+                               if (iptr->sx.s23.s3.varindex == lt->v_index) {
 #ifdef SSA_DEBUG_VERBOSE
                                        if (W != NULL) {
-                                       if (compileverbose)
-                                               printf("copy propagation loc: BB %3i I %3i: %3i -> \
+                                               if (compileverbose)
+                                                       printf("copy propagation loc: BB %3i I %3i: %3i -> \
                                     %3i\n", s->b_index, s->iindex,
-                                                          new_v_index, iptr->op1);
+                                                                  new_v_index, iptr->sx.s23.s3.varindex);
                                        }
 #endif
-                                       iptr->op1 = new_v_index;
-                                       break;
-                               default:
-                                       exit(1);
+                                       iptr->sx.s23.s3.varindex = new_v_index;
                                }
-                       } else {
-                               /* Interface Stackslot Use */
+
+                               /* now "fall through" for handling of s2 and s1 */
+
+                       case DF_2_TO_0:
+                       case DF_2_TO_1: /* icmd has s1 and s2 */
+                               if (iptr->sx.s23.s2.varindex == lt->v_index) {
+#ifdef SSA_DEBUG_VERBOSE
+                                       if (W != NULL) {
+                                               if (compileverbose)
+                                                       printf("copy propagation loc: BB %3i I %3i: %3i -> \
+                                    %3i\n", s->b_index, s->iindex,
+                                                                  new_v_index, iptr->sx.s23.s2.varindex);
+                                       }
+#endif
+                                       iptr->sx.s23.s2.varindex = new_v_index;
+                               }
+
+                               /* now "fall through" for handling of s1 */
+
+                       case DF_1_TO_0:
+                       case DF_1_TO_1:
+                       case DF_MOVE:
+                       case DF_COPY:
+                               if (iptr->s1.varindex == lt->v_index) {
 #ifdef SSA_DEBUG_VERBOSE
-                               if (compileverbose)
-                                       printf("copy propagation int: BB %3i I %3i: %3i -> \
-                                 %3i\n", s->b_index, s->iindex, new_v_index,
-                                                  lt->local_ss->s->varnum);
+                                       if (W != NULL) {
+                                               if (compileverbose)
+                                                       printf("copy propagation loc: BB %3i I %3i: %3i -> \
+                                    %3i\n", s->b_index, s->iindex,
+                                                                  new_v_index, iptr->s1.varindex);
+                                       }
 #endif
-                               for (ss = lt->local_ss; ss != NULL; ss = ss->next) {
-                                       ss->s->varkind = LOCALVAR;
-                                       ss->s->varnum = new_v_index;
+                                       iptr->s1.varindex = new_v_index;
                                }
+                               break;
+
+                               /* TODO: */
+                               /* ? really look at md->paramcount or iptr->s1.argcount */
+                               /* has to be taken, so that pass-through stackslots get */
+                               /* renamed, too? */
+
+                       case DF_INVOKE:
+                               INSTRUCTION_GET_METHODDESC(iptr,md);
+                               i = md->paramcount;
+                               break;
+                       case DF_BUILTIN:
+                               bte = iptr->sx.s23.s3.bte;
+                               md = bte->md;
+                               i = md->paramcount;
+                               break;
+                       case DF_N_TO_1:
+                               i = iptr->s1.argcount;
+                               break;
+                       }
+                       if (i != UNUSED) {
+                               argp = iptr->sx.s23.s2.args;
+                               while (--i >= 0) {
+                                       if (*argp == lt->v_index) {
+#ifdef SSA_DEBUG_VERBOSE
+                                               if (W != NULL) {
+                                                       if (compileverbose)
+                                                               printf(
+                                                                          "copy propagation loc: BB %3i I %3i: %3i -> %3i\n"
+                                                                          , s->b_index, s->iindex, new_v_index, *argp);
+                                               }
+#endif
+                                               *argp = new_v_index;
                                                        
-                       }       
-               }
+                                       }
+                                       argp++;
+                               }
+                       }
+
+               } /* if (s->iindex < 0) */
        } /* for(s = lt->use; s != NULL; s = s->next) */
 }
 
@@ -1937,8 +2057,8 @@ void ssa_print_lt(lsradata *ls) {
 
        printf("SSA LT Def/Use\n");
        for(i = 0; i < ls->lifetimecount; i++) {
-               lt = &(ls->lifetime[i]);
-               if (lt->type != -1) {
+               lt = ls->lifetime + i;
+               if (lt->type != UNUSED) {
                        printf("VI %3i Type %3i Def: ",lt->v_index, lt->type);
                        if (lt->def != NULL)
                                printf("%3i,%3i Use: ",lt->def->b_index, lt->def->iindex);
@@ -1950,7 +2070,49 @@ void ssa_print_lt(lsradata *ls) {
                }
        }
 }
+
+void ssa_show_variable(jitdata *jd, int index, varinfo *v, int stage)
+{
+       char type;
+       char kind;
+
+       switch (v->type) {
+               case TYPE_INT: type = 'i'; break;
+               case TYPE_LNG: type = 'l'; break;
+               case TYPE_FLT: type = 'f'; break;
+               case TYPE_DBL: type = 'd'; break;
+               case TYPE_ADR: type = 'a'; break;
+               case TYPE_RET: type = 'r'; break;
+               default:       type = '?';
+       }
+
+       if (index < jd->localcount) {
+               kind = 'L';
+               if (v->flags & (PREALLOC | INOUT))
+                               printf("<INVALID FLAGS!>");
+       }
+       else {
+               if (v->flags & PREALLOC) {
+                       kind = 'A';
+                       if (v->flags & INOUT)
+                               printf("<INVALID FLAGS!>");
+               }
+               else if (v->flags & INOUT)
+                       kind = 'I';
+               else
+                       kind = 'T';
+       }
+
+       printf("%c%c%3d", kind, type, index);
+
+       if (v->flags & SAVEDVAR)
+               putchar('!');
+
+       putchar(' ');
+       fflush(stdout);
+}
 #endif
+
 /****************************************************************************
 Optimization
 ****************************************************************************/
index 56f876c5d3eb99c08c1ee0d4b24cf4c0181f9302..df8dbf424312db1fee6dddc12a99f2197a8c2d9b 100644 (file)
 # define _SSA_ASSERT(a)
 #endif
 
-/* #define JOIN_PHI_LT */ /* build intereference graph for lt used in phi */
-                          /* funcs and try to merge them */
-
 /* function prototypes */
 void ssa_init(jitdata *);
-void ssa_set_local_def(lsradata *, int , int , int);
-void ssa_set_use(lsradata *, int , int , int );
-void ssa_set_interface(codegendata *, lsradata *, basicblock *);
 void ssa(jitdata *, graphdata *);
 
 #endif /* _SSA_H */
@@ -70,7 +64,8 @@ void ssa(jitdata *, graphdata *);
  * Local variables:
  * mode: c
  * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
+ * c-basic-offset): 4
+ * tab-width): 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */
diff --git a/src/vm/jit/parisc/.cvsignore b/src/vm/jit/parisc/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
diff --git a/src/vm/jit/parisc/linux/.cvsignore b/src/vm/jit/parisc/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 2575c3308b1d0f5345849b8ef04f0d0ccdea5a45..49655c68cbbc4fc9e371de3c33c3064601a97757 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: parse.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: parse.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/logging.h"
 
index 9b2c5916c99c9267ceed107dd48fb65e357bda82..a321ce7fe2c4a19597b1efb49626de6f99f72d56 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/patcher.h - code patching functions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Christian Thalinger
-
-   Changes: Edwin Steiner
-
-   $Id: patcher.h 5929 2006-11-06 17:13:40Z twisti $
+   $Id: patcher.h 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
@@ -42,9 +36,7 @@
 
 #include "vm/types.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/global.h"
 
diff --git a/src/vm/jit/powerpc/.cvsignore b/src/vm/jit/powerpc/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index 27a42d8c6414f12a5c8a8c7ad7d1b45a98897898..9bb705c19f6fc1c861a206fce176f3d2c5192936 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #include "vm/jit/powerpc/codegen.h"
 
 #include "mm/memory.h"
+
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -2562,20 +2561,6 @@ gen_method:
 
 
                case ICMD_CHECKCAST:  /* ..., objectref ==> ..., objectref            */
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *
-                        *  OK if ((sub == NULL) ||
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL));
-                        *
-                        *  superclass is a class:
-                        *
-                        *  OK if ((sub == NULL) || (0
-                        *         <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *         super->vftbl->diffvall));
-                        */
 
                        if (!(iptr->flags.bits & INS_FLAG_ARRAY)) {
                                /* object type cast-check */
@@ -2592,9 +2577,8 @@ gen_method:
                                        superindex = super->index;
                                }
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+                                       CODEGEN_CRITICAL_SECTION_NEW;
 
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
@@ -2667,17 +2651,17 @@ gen_method:
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       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));
-#if defined(ENABLE_THREADS)
-                                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                               CODEGEN_CRITICAL_SECTION_END;
+
                                                M_ISUB(REG_ITMP3, REG_ITMP1, REG_ITMP3);
                                        }
                                        else {
@@ -2685,9 +2669,8 @@ 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));
-#if defined(ENABLE_THREADS)
-                                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                               CODEGEN_CRITICAL_SECTION_END;
                                        }
                                        M_CMPU(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1);
@@ -2735,20 +2718,6 @@ gen_method:
                        break;
 
                case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult            */
-                                     /* val.a: (classinfo*) superclass               */
-
-                       /*  superclass is an interface:
-                        *
-                        *  return (sub != NULL) &&
-                        *         (sub->vftbl->interfacetablelength > super->index) &&
-                        *         (sub->vftbl->interfacetable[-super->index] != NULL);
-                        *
-                        *  superclass is a class:
-                        *
-                        *  return ((sub != NULL) && (0
-                        *          <= (sub->vftbl->baseval - super->vftbl->baseval) <=
-                        *          super->vftbl->diffvall));
-                        */
 
                        {
                        classinfo *super;
@@ -2763,9 +2732,9 @@ gen_method:
                                superindex = super->index;
                        }
                        
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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);
@@ -2843,15 +2812,15 @@ gen_method:
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_CMPU(REG_ITMP1, REG_ITMP2);
                                M_CLR(d);
diff --git a/src/vm/jit/powerpc/darwin/.cvsignore b/src/vm/jit/powerpc/darwin/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index f38f2dbb3271f7bd2e13615e49fdd852e7c4ba57..5f8fd45e4e97faa79079709a0793f8f7350b9f17 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 4398 2006-01-31 23:43:08Z twisti $
+   $Id: emit.c 7816 2007-04-25 19:38:46Z twisti $
 
 */
 
@@ -39,9 +39,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
diff --git a/src/vm/jit/powerpc/linux/.cvsignore b/src/vm/jit/powerpc/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 3c33bb3e9ad7f477ed8ebaed59c4d89556cebf94..c26a7f0c04b6b0c1b1b27edd2f9605d613ffdff8 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-abi.c 7713 2007-04-15 21:49:48Z twisti $
+   $Id: md-abi.c 7814 2007-04-25 19:36:15Z twisti $
 
 */
 
@@ -152,13 +152,12 @@ const s4 abi_registers_float_temporary[] = {
        11, /* ft2  */
        12, /* ft3  */
        13, /* ft4  */
-       17, /* ft5  */
-       18, /* ft6  */
-       19, /* ft7  */
-       20, /* ft8  */
-       21, /* ft9  */
-       22, /* ft10 */
-       23, /* ft11 */
+       18, /* ft5  */
+       19, /* ft6  */
+       20, /* ft7  */
+       21, /* ft8  */
+       22, /* ft9  */
+       23, /* ft10 */
 };
 
 
index 91ef7e03c595d2329c8a331875b42195d83b4d3e..7129ce511ed2c101c29c3c8851b80c0adc2a6b5d 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7617 2007-03-29 23:22:07Z twisti $
+   $Id: md-os.c 7864 2007-05-03 21:17:26Z twisti $
 
 */
 
@@ -63,6 +63,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
        ucontext_t        *_uc;
        mcontext_t        *_mc;
+       unsigned long     *_gregs;
        u1                *pv;
        u1                *sp;
        u1                *ra;
@@ -77,12 +78,19 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        java_objectheader *o;
 
        _uc = (ucontext_t *) _p;
-       _mc = _uc->uc_mcontext.uc_regs;
 
-       pv  = (u1 *) _mc->gregs[REG_PV];
-       sp  = (u1 *) _mc->gregs[REG_SP];
-       ra  = (u1 *) _mc->gregs[PT_LNK];         /* this is correct for leafs */
-       xpc = (u1 *) _mc->gregs[PT_NIP];
+#if defined(__UCLIBC__)
+       _mc    = &(_uc->uc_mcontext);
+       _gregs = _mc->regs->gpr;
+#else
+       _mc    = _uc->uc_mcontext.uc_regs;
+       _gregs = _mc->gregs;
+#endif
+
+       pv  = (u1 *) _gregs[REG_PV];
+       sp  = (u1 *) _gregs[REG_SP];
+       ra  = (u1 *) _gregs[PT_LNK];                 /* this is correct for leafs */
+       xpc = (u1 *) _gregs[PT_NIP];
 
        /* get exception-throwing instruction */
 
@@ -92,7 +100,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        disp = M_INSTR_OP2_IMM_I(mcode);
        d    = M_INSTR_OP2_IMM_D(mcode);
 
-       val  = _mc->gregs[d];
+       val  = _gregs[d];
 
        /* check for special-load */
 
@@ -105,7 +113,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                /* This is a normal NPE: addr must be NULL and the NPE-type
                   define is 0. */
 
-               addr = _mc->gregs[s1];
+               addr = _gregs[s1];
                type = EXCEPTION_HARDWARE_NULLPOINTER;
 
                if (addr != 0)
@@ -118,9 +126,9 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        /* set registers */
 
-       _mc->gregs[REG_ITMP1_XPTR] = (ptrint) o;
-       _mc->gregs[REG_ITMP2_XPC]  = (ptrint) xpc;
-       _mc->gregs[PT_NIP]         = (ptrint) asm_handle_exception;
+       _gregs[REG_ITMP1_XPTR] = (ptrint) o;
+       _gregs[REG_ITMP2_XPC]  = (ptrint) xpc;
+       _gregs[PT_NIP]         = (ptrint) asm_handle_exception;
 }
 
 
@@ -134,6 +142,7 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
 {
        ucontext_t        *_uc;
        mcontext_t        *_mc;
+       unsigned long     *_gregs;
        u1                *pv;
        u1                *sp;
        u1                *ra;
@@ -145,12 +154,19 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
        java_objectheader *o;
 
        _uc = (ucontext_t *) _p;
-       _mc = _uc->uc_mcontext.uc_regs;
 
-       pv  = (u1 *) _mc->gregs[REG_PV];
-       sp  = (u1 *) _mc->gregs[REG_SP];
-       ra  = (u1 *) _mc->gregs[PT_LNK];         /* this is correct for leafs */
-       xpc = (u1 *) _mc->gregs[PT_NIP];
+#if defined(__UCLIBC__)
+       _mc    = &(_uc->uc_mcontext);
+       _gregs = _mc->regs->gpr;
+#else
+       _mc    = _uc->uc_mcontext.uc_regs;
+       _gregs = _mc->gregs;
+#endif
+
+       pv  = (u1 *) _gregs[REG_PV];
+       sp  = (u1 *) _gregs[REG_SP];
+       ra  = (u1 *) _gregs[PT_LNK];                 /* this is correct for leafs */
+       xpc = (u1 *) _gregs[PT_NIP];
 
        /* get exception-throwing instruction */
 
@@ -161,7 +177,7 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
        /* for now we only handle ArrayIndexOutOfBoundsException */
 
        type = EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS;
-       val  = _mc->gregs[s1];
+       val  = _gregs[s1];
 
        /* generate appropriate exception */
 
@@ -169,9 +185,9 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
 
        /* set registers */
 
-       _mc->gregs[REG_ITMP1_XPTR] = (ptrint) o;
-       _mc->gregs[REG_ITMP2_XPC]  = (ptrint) xpc;
-       _mc->gregs[PT_NIP]         = (ptrint) asm_handle_exception;
+       _gregs[REG_ITMP1_XPTR] = (ptrint) o;
+       _gregs[REG_ITMP2_XPC]  = (ptrint) xpc;
+       _gregs[PT_NIP]         = (ptrint) asm_handle_exception;
 }
 
 
@@ -184,36 +200,61 @@ void md_signal_handler_sigtrap(int sig, siginfo_t *siginfo, void *_p)
 #if defined(ENABLE_THREADS)
 void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 {
-       threadobject *tobj;
-       ucontext_t   *_uc;
-       mcontext_t   *_mc;
-       u1           *pc;
+       threadobject  *tobj;
+       ucontext_t    *_uc;
+       mcontext_t    *_mc;
+       unsigned long *_gregs;
+       u1            *pc;
 
        tobj = THREADOBJECT;
 
        _uc = (ucontext_t *) _p;
-       _mc = _uc->uc_mcontext.uc_regs;
 
-       pc = (u1 *) _mc->gregs[PT_NIP];
+#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];
 
        tobj->pc = pc;
 }
 
 
-void thread_restartcriticalsection(ucontext_t *_uc)
+/* md_critical_section_restart *************************************************
+
+   Search the critical sections tree for a matching section and set
+   the PC to the restart point, if necessary.
+
+*******************************************************************************/
+
+void md_critical_section_restart(ucontext_t *_uc)
 {
-       mcontext_t *_mc;
-       u1         *pc;
-       void       *critical;
+       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
 
-       _mc = _uc->uc_mcontext.uc_regs;
+       pc = (u1 *) _gregs[PT_NIP];
 
-       pc = (u1 *) _mc->gregs[PT_NIP];
+       npc = critical_find_restart_point(pc);
 
-       critical = critical_find_restart_point(pc);
+       if (npc != NULL) {
+               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
 
-       if (critical)
-               _mc->gregs[PT_NIP] = (ptrint) critical;
+               _gregs[PT_NIP] = (ptrint) npc;
+       }
 }
 #endif
 
diff --git a/src/vm/jit/powerpc/netbsd/.cvsignore b/src/vm/jit/powerpc/netbsd/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/powerpc64/.cvsignore b/src/vm/jit/powerpc64/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index af871ae593ace58e176260d07a51f93bcbbdbc54..f073ab6f06983353f966fb7c08daa370d32ad931 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.S 7678 2007-04-09 17:23:55Z twisti $
+   $Id: asmpart.S 7909 2007-05-15 10:32:16Z tbfg $
 
 */
 
        std     s0,8*8(sp)                /* save used callee saved registers     */
        std     a0,9*8(sp)                /* save method pointer for compiler     */
 
-#if defined(__DARWIN__)
-       std     itmp1,10*8(sp)            /* register r11 is callee saved         */
-#endif
        std     pv,11*8(sp)               /* save PV register                     */
 
        std     itmp3,12*8(sp)            /* registers r14-r31 are callee saved   */
        stfd    ftmp1,13*8(sp)            /* registers f14-f31 are callee saved   */
        stfd    ftmp2,14*8(sp)
 
-#if defined(__DARWIN__)
-       std     t1,15*8(r1)
-       std     t2,16*8(r1)
-       std     t3,17*8(r1)
-       std     t4,18*8(r1)
-       std     t5,19*8(r1)
-       std     t6,20*8(r1)
-       std     t7,21*8(r1)
-
-       stfd    ft0,22*8(r1)
-       stfd    ft1,23*8(r1)
-       stfd    ft2,24*8(r1)
-       stfd    ft3,25*8(r1)
-       stfd    ft4,26*8(r1)
-       stfd    ft5,27*8(r1)
-#else
-       SAVE_TEMPORARY_REGISTERS(15)      /* the offset has to be even            */
-#endif
+       SAVE_TEMPORARY_REGISTERS(15)     
 
        mr      itmp2,a1                  /* arg count                            */
        mr      itmp1,a2                  /* pointer to arg block                 */
@@ -204,31 +184,26 @@ L_register_handle_int:
        cmpwi   t6,INT_ARG_CNT            /* are we out of integer argument       */
        beq     L_register_copy           /* registers? yes, next loop            */
 
+       cmpwi   itmp3,0x0004              /* is it TYPE_ADR? */
+       beq     L_register_handle_long
+
        andi.   r0,itmp3,0x0001           /* is this a 2-word type?               */
        bne     L_register_handle_long
 
-#if defined(__DARWIN__)
-       #error "FIXME for darwin"
-#else
        lis     itmp3,L_jumptable_int@highest           /* load 64bit address   */
        ori     itmp3,itmp3,L_jumptable_int@higher
        rldicr  itmp3,itmp3,32,31
        oris    itmp3,itmp3,L_jumptable_int@h
        ori     itmp3,itmp3,L_jumptable_int@l
-#endif
        b       L_register_do_copy_longint
 
 L_register_handle_long:
 
-#if defined(__DARWIN__)
-       #error "FIXME for darwin"
-#else
        lis     itmp3,L_jumptable_long@highest          /* load 64bit address   */
        ori     itmp3,itmp3,L_jumptable_long@higher
        rldicr  itmp3,itmp3,32,31
        oris    itmp3,itmp3,L_jumptable_long@h
        ori     itmp3,itmp3,L_jumptable_long@l
-#endif
 
 L_register_do_copy_longint:
        slwi    t2,t6,3                   /* multiple of 8-bytes                  */
@@ -246,28 +221,20 @@ L_register_handle_float:
        andi.   r0,itmp3,0x0001           /* is this a 2-word type?               */
        bne     L_register_handle_double
 
-#if defined(__DARWIN__)
-       #error "FIXME for darwin"
-#else
        lis     itmp3,L_jumptable_float@highest         /* load 64bit address   */
        ori     itmp3,itmp3,L_jumptable_float@higher
        rldicr  itmp3,itmp3,32,31
        oris    itmp3,itmp3,L_jumptable_float@h
        ori     itmp3,itmp3,L_jumptable_float@l
-#endif
        b L_register_do_copy_floatdouble
 
 L_register_handle_double:
 
-#if defined(__DARWIN__)
-       #error "FIXME for darwin"
-#else
        lis     itmp3,L_jumptable_double@highest                /* load 64bit address   */
        ori     itmp3,itmp3,L_jumptable_double@higher
        rldicr  itmp3,itmp3,32,31
        oris    itmp3,itmp3,L_jumptable_double@h
        ori     itmp3,itmp3,L_jumptable_double@l
-#endif
 
 
 L_register_do_copy_floatdouble:
@@ -356,16 +323,11 @@ L_stack_handle_double:
 L_stack_copy_done:
        ld      itmp1,9*8(s0)             /* pass method pointer via tmp1         */
 
-#if defined(__DARWIN__)
-       addis   mptr,t3,ha16(L_asm_call_jit_compiler - L_asm_vm_call_method_get_pc)
-       la      mptr,lo16(L_asm_call_jit_compiler - L_asm_vm_call_method_get_pc)(mptr)
-#else
        lis     mptr,L_asm_call_jit_compiler@highest    /* load 64bit address   */
        ori     mptr,mptr,L_asm_call_jit_compiler@higher
        rldicr  mptr,mptr,32,31
        oris    mptr,mptr,L_asm_call_jit_compiler@h
        ori     mptr,mptr,L_asm_call_jit_compiler@l
-#endif
        std     mptr,7*8(s0)
        addi    mptr,s0,7*8
 
@@ -374,48 +336,25 @@ L_stack_copy_done:
        bctrl
 1:
        mflr    itmp1
-#if defined(__DARWIN__)
-       addi    pv,itmp1,lo16(.asm_vm_call_method - 1b)
-#else
+
        addi    pv,itmp1,(.asm_vm_call_method - 1b)@l
-#endif
 
 L_asm_vm_call_method_return:
        mr      sp,s0                     /* restore the function's sp            */
 
        ld      s0,8*8(sp)                /* restore used callee saved registers  */
 
-#if defined(__DARWIN__)
-       lwz     itmp1,10*4(sp)            /* register r11 is callee saved         */
-#endif
        ld      pv,11*8(sp)               /* save PV register                     */
 
        ld      itmp3,12*8(sp)
        lfd     ftmp1,13*8(sp)            /* registers f14-f31 are callee saved   */
        lfd     ftmp2,14*8(sp)
 
-#if defined(__DARWIN__)
-       lwz     t1,18*4(r1)
-       lwz     t2,19*4(r1)
-       lwz     t3,20*4(r1)
-       lwz     t4,21*4(r1)
-       lwz     t5,22*4(r1)
-       lwz     t6,23*4(r1)
-       lwz     t7,24*4(r1)
-
-       lfd     ft0,26*4(r1)
-       lfd     ft1,28*4(r1)
-       lfd     ft2,30*4(r1)
-       lfd     ft3,32*4(r1)
-       lfd     ft4,34*4(r1)
-       lfd     ft5,36*4(r1)
-#else
-       RESTORE_TEMPORARY_REGISTERS(15)   /* the offset has to be even            */
-#endif
+       RESTORE_TEMPORARY_REGISTERS(15) 
 
        ld     r0,40*8+LA_LR_OFFSET(r1)
-       mtlr    r0
-       addi    r1,r1,40*8
+       mtlr   r0
+       addi   r1,r1,40*8
        blr
 
 asm_vm_call_method_exception_handler:
@@ -644,32 +583,7 @@ L_asm_call_jit_compiler:                /* required for PIC code              */
        std     r0,LA_LR_OFFSET(sp)         /* save return address                */
        stdu    r1,-(LA_SIZE+PA_SIZE+ARG_CNT*8)(sp)
 
-#if defined(__DARWIN__)
-       stw     a0,LA_SIZE+(5+0)*8(r1)
-       stw     a1,LA_SIZE+(5+1)*8(r1)
-       stw     a2,LA_SIZE+(5+2)*8(r1)
-       stw     a3,LA_SIZE+(5+3)*8(r1)
-       stw     a4,LA_SIZE+(5+4)*8(r1)
-       stw     a5,LA_SIZE+(5+5)*8(r1)
-       stw     a6,LA_SIZE+(5+6)*8(r1)
-       stw     a7,LA_SIZE+(5+7)*8(r1)
-
-       stfd    fa0,LA_SIZE+(5+8)*8(r1)
-       stfd    fa1,LA_SIZE+(5+10)*8(r1)
-       stfd    fa2,LA_SIZE+(5+12)*8(r1)
-       stfd    fa3,LA_SIZE+(5+14)*8(r1)
-       stfd    fa4,LA_SIZE+(5+16)*8(r1)
-       stfd    fa5,LA_SIZE+(5+18)*8(r1)
-       stfd    fa6,LA_SIZE+(5+20)*8(r1)
-       stfd    fa7,LA_SIZE+(5+22)*8(r1)
-       stfd    fa8,LA_SIZE+(5+24)*8(r1)
-       stfd    fa9,LA_SIZE+(5+26)*8(r1)
-       stfd    fa10,LA_SIZE+(5+28)*8(r1)
-       stfd    fa11,LA_SIZE+(5+30)*8(r1)
-       stfd    fa12,LA_SIZE+(5+32)*8(r1)
-#else
        SAVE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS)
-#endif
 
        mr      a0,itmp1
        mr      a1,mptr
@@ -679,32 +593,7 @@ L_asm_call_jit_compiler:                /* required for PIC code              */
        ori     r0,r0,0                     /* nop needed after jump to function desc. */
        mr      pv,v0                       /* move address to pv register        */
 
-#if defined(__DARWIN__)
-       lwz     a0,LA_SIZE+(+5+0)*8(r1)
-       lwz     a1,LA_SIZE+(+5+1)*8(r1)
-       lwz     a2,LA_SIZE+(+5+2)*8(r1)
-       lwz     a3,LA_SIZE+(+5+3)*8(r1)
-       lwz     a4,LA_SIZE+(+5+4)*8(r1)
-       lwz     a5,LA_SIZE+(+5+5)*8(r1)
-       lwz     a6,LA_SIZE+(+5+6)*8(r1)
-       lwz     a7,LA_SIZE+(+5+7)*8(r1)
-
-       lfd     fa0,LA_SIZE+(+5+8)*8(r1)
-       lfd     fa1,LA_SIZE+(+5+10)*8(r1)
-       lfd     fa2,LA_SIZE+(+5+12)*8(r1)
-       lfd     fa3,LA_SIZE+(+5+14)*8(r1)
-       lfd     fa4,LA_SIZE+(+5+16)*8(r1)
-       lfd     fa5,LA_SIZE+(+5+18)*8(r1)
-       lfd     fa6,LA_SIZE+(+5+20)*8(r1)
-       lfd     fa7,LA_SIZE+(+5+22)*8(r1)
-       lfd     fa8,LA_SIZE+(+5+24)*8(r1)
-       lfd     fa9,LA_SIZE+(+5+26)*8(r1)
-       lfd     fa10,LA_SIZE+(+5+28)*8(r1)
-       lfd     fa11,LA_SIZE+(+5+30)*8(r1)
-       lfd     fa12,LA_SIZE+(+5+32)*8(r1)
-#else
        RESTORE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS)
-#endif
 
        ld     itmp1,(LA_SIZE + PA_SIZE + ARG_CNT*8)+LA_LR_OFFSET(sp)
        mtlr   itmp1
@@ -770,11 +659,8 @@ asm_handle_exception:
 L_asm_handle_exception:                 /* required for PIC code              */
        addi    sp,sp,-(ARG_CNT+TMP_CNT)*8  /* create maybe-leaf stackframe       */
 
-#if defined(__DARWIN__)
-#else
        SAVE_ARGUMENT_REGISTERS(0)          /* we save arg and temp registers in  */
        SAVE_TEMPORARY_REGISTERS(ARG_CNT)   /* case this is a leaf method         */
-#endif
 
        addi    sp,sp,-(LA_SIZE+PA_SIZE+(4+6)*8)        /* allocate stack                     */
        std     xptr,LA_SIZE+PA_SIZE+(4+0)*8(sp)        /* save exception pointer             */
@@ -807,11 +693,8 @@ L_asm_handle_exception_continue:
        mr.     t0,t0
        beq     L_asm_handle_exception_no_leaf
 
-#if defined(__DARWIN__)
-#else
        RESTORE_ARGUMENT_REGISTERS(0)       /* if this is a leaf method, we have  */
        RESTORE_TEMPORARY_REGISTERS(ARG_CNT)/* to restore arg and temp registers  */
-#endif
 
        addi    sp,sp,(ARG_CNT+TMP_CNT)*8   /* remove maybe-leaf stackframe       */
 
@@ -851,11 +734,7 @@ L_asm_handle_exception_no_ra_restore:
        bl      ex_int1
 ex_int1:
        mflr    t3                          /* t3 = current pc                    */
-#if defined(__DARWIN__)
-       addi    t2,t2,lo16(ex_int2-ex_int1)
-#else
        addi    t3,t3,(ex_int2-ex_int1)@l
-#endif
        slwi    t2,t2,2                     /* t2 = register count * 4            */
        subf    t3,t2,t3                    /* t3 = IntSave - t2                  */
        mtctr   t3
@@ -877,11 +756,7 @@ ex_int2:
        bl      ex_flt1
 ex_flt1:
        mflr    t3
-#if defined(__DARWIN__)
-       addi    t2,t2,lo16(ex_flt2-ex_flt1)
-#else
        addi    t3,t3,(ex_flt2-ex_flt1)@l
-#endif
        slwi    t2,t2,2                     /* t2 = register count * 4            */
        subf    t3,t2,t3                    /* t3 = FltSave - t2                  */
        mtctr   t3
@@ -913,12 +788,12 @@ ex_flt2:
 
 asm_abstractmethoderror:
        mflr    r0
-       stw     r0,LA_LR_OFFSET(sp)
-       stwu    sp,-LA_SIZE_ALIGNED(sp)     /* preserve linkage area              */
+       std     r0,LA_LR_OFFSET(sp)
+       stdu    sp,-LA_SIZE_ALIGNED(sp)     /* preserve linkage area              */
        addi    a0,sp,LA_SIZE_ALIGNED       /* pass java sp                       */
        mr      a1,r0                       /* pass exception address             */
        bl      exceptions_asm_new_abstractmethoderror
-       lwz     r0,LA_SIZE_ALIGNED+LA_LR_OFFSET(sp)
+       l     r0,LA_SIZE_ALIGNED+LA_LR_OFFSET(sp)
        mtlr    r0                          /* restore return address             */
        addi    sp,sp,LA_SIZE_ALIGNED
 
@@ -948,49 +823,8 @@ asm_patcher_wrapper:
                                      /* keep stack 16-bytes aligned: 6+1+37 = 44 */
        stdu    sp,-(LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8)(sp)
 
-#if defined(__DARWIN__)
-       stw     a0,LA_SIZE+(5+0)*8(r1)      /* save argument registers            */
-       stw     a1,LA_SIZE+(5+1)*8(r1)      /* preserve linkage area (24 bytes)   */
-       stw     a2,LA_SIZE+(5+2)*8(r1)      /* and 4 bytes for 4 argument         */
-       stw     a3,LA_SIZE+(5+3)*8(r1)
-       stw     a4,LA_SIZE+(5+4)*8(r1)
-       stw     a5,LA_SIZE+(5+5)*8(r1)
-       stw     a6,LA_SIZE+(5+6)*8(r1)
-       stw     a7,LA_SIZE+(5+7)*8(r1)
-
-       stfd    fa0,LA_SIZE+(5+8)*8(sp)
-       stfd    fa1,LA_SIZE+(5+10)*8(sp)
-       stfd    fa2,LA_SIZE+(5+12)*8(sp)
-       stfd    fa3,LA_SIZE+(5+14)*8(sp)
-       stfd    fa4,LA_SIZE+(5+16)*8(sp)
-       stfd    fa5,LA_SIZE+(5+18)*8(sp)
-       stfd    fa6,LA_SIZE+(5+20)*8(sp)
-       stfd    fa7,LA_SIZE+(5+22)*8(sp)
-       stfd    fa8,LA_SIZE+(5+24)*8(sp)
-       stfd    fa9,LA_SIZE+(5+26)*8(sp)
-       stfd    fa10,LA_SIZE+(5+28)*8(sp)
-       stfd    fa11,LA_SIZE+(5+30)*8(sp)
-       stfd    fa12,LA_SIZE+(5+32)*8(sp)       /* XXX */
-
-       stw     t0,LA_SIZE+(+5+33)*8(r1)
-       stw     t1,LA_SIZE+(+5+34)*8(r1)
-       stw     t2,LA_SIZE+(+5+35)*8(r1)
-       stw     t3,LA_SIZE+(+5+36)*8(r1)
-       stw     t4,LA_SIZE+(+5+37)*8(r1)
-       stw     t5,LA_SIZE+(+5+38)*8(r1)
-       stw     t6,LA_SIZE+(+5+39)*8(r1)
-       stw     t7,LA_SIZE+(+5+40)*8(r1)
-
-       stfd    ft0,LA_SIZE+(+5+42)*8(r1)
-       stfd    ft1,LA_SIZE+(+5+44)*8(r1)
-       stfd    ft2,LA_SIZE+(+5+46)*8(r1)
-       stfd    ft3,LA_SIZE+(+5+48)*8(r1)
-       stfd    ft4,LA_SIZE+(+5+50)*8(r1)
-       stfd    ft5,LA_SIZE+(+5+52)*8(r1)
-#else
        SAVE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS) /* save 8 int/8 float arguments   */
        SAVE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS+ARG_CNT)
-#endif
 
        std     itmp1,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+1*8(sp)
        std     itmp2,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+2*8(sp)
@@ -1002,49 +836,9 @@ asm_patcher_wrapper:
        bl      patcher_wrapper
        std     v0,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+4*8(sp)     /* save return value                  */
 
-#if defined(__DARWIN__)
-       lwz     a0,LA_SIZE+(5+0)*8(r1)
-       lwz     a1,LA_SIZE+(5+1)*8(r1)
-       lwz     a2,LA_SIZE+(5+2)*8(r1)
-       lwz     a3,LA_SIZE+(5+3)*8(r1)
-       lwz     a4,LA_SIZE+(5+4)*8(r1)
-       lwz     a5,LA_SIZE+(5+5)*8(r1)
-       lwz     a6,LA_SIZE+(5+6)*8(r1)
-       lwz     a7,LA_SIZE+(5+7)*8(r1)
-
-       lfd     fa0,LA_SIZE+(5+8)*8(sp)
-       lfd     fa1,LA_SIZE+(5+10)*8(sp)
-       lfd     fa2,LA_SIZE+(5+12)*8(sp)
-       lfd     fa3,LA_SIZE+(5+14)*8(sp)
-       lfd     fa4,LA_SIZE+(5+16)*8(sp)
-       lfd     fa5,LA_SIZE+(5+18)*8(sp)
-       lfd     fa6,LA_SIZE+(5+20)*8(sp)
-       lfd     fa7,LA_SIZE+(5+22)*8(sp)
-       lfd     fa8,LA_SIZE+(5+24)*8(sp)
-       lfd     fa9,LA_SIZE+(5+26)*8(sp)
-       lfd     fa10,LA_SIZE+(5+28)*8(sp)
-       lfd     fa11,LA_SIZE+(5+30)*8(sp)
-       lfd     fa12,LA_SIZE+(5+32)*8(sp)
-
-       lwz     t0,LA_SIZE+(+5+33)*8(r1)
-       lwz     t1,LA_SIZE+(+5+34)*8(r1)
-       lwz     t2,LA_SIZE+(+5+35)*8(r1)
-       lwz     t3,LA_SIZE+(+5+36)*8(r1)
-       lwz     t4,LA_SIZE+(+5+37)*8(r1)
-       lwz     t5,LA_SIZE+(+5+38)*8(r1)
-       lwz     t6,LA_SIZE+(+5+39)*8(r1)
-       lwz     t7,LA_SIZE+(+5+40)*8(r1)
-
-       lfd     ft0,LA_SIZE+(+5+42)*8(r1)
-       lfd     ft1,LA_SIZE+(+5+44)*8(r1)
-       lfd     ft2,LA_SIZE+(+5+46)*8(r1)
-       lfd     ft3,LA_SIZE+(+5+48)*8(r1)
-       lfd     ft4,LA_SIZE+(+5+50)*8(r1)
-       lfd     ft5,LA_SIZE+(+5+52)*8(r1)
-#else
+
        RESTORE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS) /* restore 8 int/8 float args  */
        RESTORE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS+ARG_CNT)
-#endif
 
        ld     itmp1,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+1*8(sp)
        ld     itmp2,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+2*8(sp)
@@ -1103,38 +897,38 @@ asm_replacement_out:
        mflr    r16
 
        /* save registers in execution state */
-       stw     r0 ,( 0*8+offes_intregs)(sp)
-       stw     r1 ,( 1*8+offes_intregs)(sp)
-       stw     r2 ,( 2*8+offes_intregs)(sp)
-       stw     r3 ,( 3*8+offes_intregs)(sp)
-       stw     r4 ,( 4*8+offes_intregs)(sp)
-       stw     r5 ,( 5*8+offes_intregs)(sp)
-       stw     r6 ,( 6*8+offes_intregs)(sp)
-       stw     r7 ,( 7*8+offes_intregs)(sp)
-       stw     r8 ,( 8*8+offes_intregs)(sp)
-       stw     r9 ,( 9*8+offes_intregs)(sp)
-       stw     r10,(10*8+offes_intregs)(sp)
-       stw     r11,(11*8+offes_intregs)(sp)
-       stw     r12,(12*8+offes_intregs)(sp)
-       stw     r13,(13*8+offes_intregs)(sp)
-       stw     r14,(14*8+offes_intregs)(sp)
-       stw     r15,(15*8+offes_intregs)(sp)
-       stw     r16,(16*8+offes_intregs)(sp) /* link register */
-       stw     r17,(17*8+offes_intregs)(sp)
-       stw     r18,(18*8+offes_intregs)(sp)
-       stw     r19,(19*8+offes_intregs)(sp)
-       stw     r20,(20*8+offes_intregs)(sp)
-       stw     r21,(21*8+offes_intregs)(sp)
-       stw     r22,(22*8+offes_intregs)(sp)
-       stw     r23,(23*8+offes_intregs)(sp)
-       stw     r24,(24*8+offes_intregs)(sp)
-       stw     r25,(25*8+offes_intregs)(sp)
-       stw     r26,(26*8+offes_intregs)(sp)
-       stw     r27,(27*8+offes_intregs)(sp)
-       stw     r28,(28*8+offes_intregs)(sp)
-       stw     r29,(29*8+offes_intregs)(sp)
-       stw     r30,(30*8+offes_intregs)(sp)
-       stw     r31,(31*8+offes_intregs)(sp)
+       std     r0 ,( 0*8+offes_intregs)(sp)
+       std     r1 ,( 1*8+offes_intregs)(sp)
+       std     r2 ,( 2*8+offes_intregs)(sp)
+       std     r3 ,( 3*8+offes_intregs)(sp)
+       std     r4 ,( 4*8+offes_intregs)(sp)
+       std     r5 ,( 5*8+offes_intregs)(sp)
+       std     r6 ,( 6*8+offes_intregs)(sp)
+       std     r7 ,( 7*8+offes_intregs)(sp)
+       std     r8 ,( 8*8+offes_intregs)(sp)
+       std     r9 ,( 9*8+offes_intregs)(sp)
+       std     r10,(10*8+offes_intregs)(sp)
+       std     r11,(11*8+offes_intregs)(sp)
+       std     r12,(12*8+offes_intregs)(sp)
+       std     r13,(13*8+offes_intregs)(sp)
+       std     r14,(14*8+offes_intregs)(sp)
+       std     r15,(15*8+offes_intregs)(sp)
+       std     r16,(16*8+offes_intregs)(sp) /* link register */
+       std     r17,(17*8+offes_intregs)(sp)
+       std     r18,(18*8+offes_intregs)(sp)
+       std     r19,(19*8+offes_intregs)(sp)
+       std     r20,(20*8+offes_intregs)(sp)
+       std     r21,(21*8+offes_intregs)(sp)
+       std     r22,(22*8+offes_intregs)(sp)
+       std     r23,(23*8+offes_intregs)(sp)
+       std     r24,(24*8+offes_intregs)(sp)
+       std     r25,(25*8+offes_intregs)(sp)
+       std     r26,(26*8+offes_intregs)(sp)
+       std     r27,(27*8+offes_intregs)(sp)
+       std     r28,(28*8+offes_intregs)(sp)
+       std     r29,(29*8+offes_intregs)(sp)
+       std     r30,(30*8+offes_intregs)(sp)
+       std     r31,(31*8+offes_intregs)(sp)
        
        stfd    fr0 ,( 0*8+offes_fltregs)(sp)
        stfd    fr1 ,( 1*8+offes_fltregs)(sp)
@@ -1200,42 +994,42 @@ asm_replacement_out:
        /* a0 == executionstate *es */
 
        /* set new sp and pv */
-       lwz     sp,(offes_sp)(a0)
-       lwz     pv,(offes_pv)(a0)
+       ld     sp,(offes_sp)(a0)
+       ld     pv,(offes_pv)(a0)
        
        /* copy registers from execution state */
-       lwz     r0 ,( 0*8+offes_intregs)(a0)
+       ld     r0 ,( 0*8+offes_intregs)(a0)
        /* r1 is sp                       */
        /* r2 is reserved                 */
        /* a0 is loaded below             */
-       lwz     r4 ,( 4*8+offes_intregs)(a0)
-       lwz     r5 ,( 5*8+offes_intregs)(a0)
-       lwz     r6 ,( 6*8+offes_intregs)(a0)
-       lwz     r7 ,( 7*8+offes_intregs)(a0)
-       lwz     r8 ,( 8*8+offes_intregs)(a0)
-       lwz     r9 ,( 9*8+offes_intregs)(a0)
-       lwz     r10,(10*8+offes_intregs)(a0)
-       lwz     r11,(11*8+offes_intregs)(a0)
-       lwz     r12,(12*8+offes_intregs)(a0)
+       ld     r4 ,( 4*8+offes_intregs)(a0)
+       ld     r5 ,( 5*8+offes_intregs)(a0)
+       ld     r6 ,( 6*8+offes_intregs)(a0)
+       ld     r7 ,( 7*8+offes_intregs)(a0)
+       ld     r8 ,( 8*8+offes_intregs)(a0)
+       ld     r9 ,( 9*8+offes_intregs)(a0)
+       ld     r10,(10*8+offes_intregs)(a0)
+       ld     r11,(11*8+offes_intregs)(a0)
+       ld     r12,(12*8+offes_intregs)(a0)
        /* r13 is pv                      */
-       lwz     r14,(14*8+offes_intregs)(a0)
-       lwz     r15,(15*8+offes_intregs)(a0)
-       lwz     r16,(16*8+offes_intregs)(a0) /* link register */
-       lwz     r17,(17*8+offes_intregs)(a0)
-       lwz     r18,(18*8+offes_intregs)(a0)
-       lwz     r19,(19*8+offes_intregs)(a0)
-       lwz     r20,(20*8+offes_intregs)(a0)
-       lwz     r21,(21*8+offes_intregs)(a0)
-       lwz     r22,(22*8+offes_intregs)(a0)
-       lwz     r23,(23*8+offes_intregs)(a0)
-       lwz     r24,(24*8+offes_intregs)(a0)
-       lwz     r25,(25*8+offes_intregs)(a0)
-       lwz     r26,(26*8+offes_intregs)(a0)
-       lwz     r27,(27*8+offes_intregs)(a0)
-       lwz     r28,(28*8+offes_intregs)(a0)
-       lwz     r29,(29*8+offes_intregs)(a0)
-       lwz     r30,(30*8+offes_intregs)(a0)
-       lwz     r31,(31*8+offes_intregs)(a0)
+       ld     r14,(14*8+offes_intregs)(a0)
+       ld     r15,(15*8+offes_intregs)(a0)
+       ld     r16,(16*8+offes_intregs)(a0) /* link register */
+       ld     r17,(17*8+offes_intregs)(a0)
+       ld     r18,(18*8+offes_intregs)(a0)
+       ld     r19,(19*8+offes_intregs)(a0)
+       ld     r20,(20*8+offes_intregs)(a0)
+       ld     r21,(21*8+offes_intregs)(a0)
+       ld     r22,(22*8+offes_intregs)(a0)
+       ld     r23,(23*8+offes_intregs)(a0)
+       ld     r24,(24*8+offes_intregs)(a0)
+       ld     r25,(25*8+offes_intregs)(a0)
+       ld     r26,(26*8+offes_intregs)(a0)
+       ld     r27,(27*8+offes_intregs)(a0)
+       ld     r28,(28*8+offes_intregs)(a0)
+       ld     r29,(29*8+offes_intregs)(a0)
+       ld     r30,(30*8+offes_intregs)(a0)
+       ld     r31,(31*8+offes_intregs)(a0)
        
        lfd     fr0 ,( 0*8+offes_fltregs)(a0)
        lfd     fr1 ,( 1*8+offes_fltregs)(a0)
@@ -1276,11 +1070,11 @@ asm_replacement_out:
        
        /* load new pc */
 
-       lwz     itmp3,offes_pc(a0)
+       ld     itmp3,offes_pc(a0)
 
        /* load a0 */
        
-       lwz     a0,(3*8+offes_intregs)(a0)
+       ld     a0,(3*8+offes_intregs)(a0)
 
        /* jump to new code */
 
@@ -1366,190 +1160,6 @@ asm_criticalsections:
 #endif
        .quad 0
 
-
-#if defined(__DARWIN__)
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_builtin_throw_exception$stub:
-       .indirect_symbol _builtin_throw_exception
-       mflr r0
-       bcl 20,31,L00$_builtin_throw_exception
-L00$_builtin_throw_exception:
-       mflr r11
-       addis r11,r11,ha16(L_builtin_throw_exception$lazy_ptr - L00$_builtin_throw_exception)
-       mtlr r0
-       lwzu r12,lo16(L_builtin_throw_exception$lazy_ptr - L00$_builtin_throw_exception)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_builtin_throw_exception$lazy_ptr:
-       .indirect_symbol _builtin_throw_exception
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_exceptions_handle_exception$stub:
-       .indirect_symbol _exceptions_handle_exception
-       mflr r0
-       bcl 20,31,L00$_exceptions_handle_exception
-L00$_exceptions_handle_exception:
-       mflr r11
-       addis r11,r11,ha16(L_exceptions_handle_exception$lazy_ptr - L00$_exceptions_handle_exception)
-       mtlr r0
-       lwzu r12,lo16(L_exceptions_handle_exception$lazy_ptr - L00$_exceptions_handle_exception)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_exceptions_handle_exception$lazy_ptr:
-       .indirect_symbol _exceptions_handle_exception
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_stacktrace_create_extern_stackframeinfo$stub:
-       .indirect_symbol _stacktrace_create_extern_stackframeinfo
-       mflr r0
-       bcl 20,31,L00$_stacktrace_create_extern_stackframeinfo
-L00$_stacktrace_create_extern_stackframeinfo:
-       mflr r11
-       addis r11,r11,ha16(L_stacktrace_create_extern_stackframeinfo$lazy_ptr - L00$_stacktrace_create_extern_stackframeinfo)
-       mtlr r0
-       lwzu r12,lo16(L_stacktrace_create_extern_stackframeinfo$lazy_ptr - L00$_stacktrace_create_extern_stackframeinfo)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_stacktrace_create_extern_stackframeinfo$lazy_ptr:
-       .indirect_symbol _stacktrace_create_extern_stackframeinfo
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_jit_asm_compile$stub:
-       .indirect_symbol _jit_asm_compile
-       mflr r0
-       bcl 20,31,L00$_jit_asm_compile
-L00$_jit_asm_compile:
-       mflr r11
-       addis r11,r11,ha16(L_jit_asm_compile$lazy_ptr - L00$_jit_asm_compile)
-       mtlr r0
-       lwzu r12,lo16(L_jit_asm_compile$lazy_ptr - L00$_jit_asm_compile)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_jit_asm_compile$lazy_ptr:
-       .indirect_symbol _jit_asm_compile
-       .long dyld_stub_binding_helper
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_stacktrace_remove_stackframeinfo$stub:
-       .indirect_symbol _stacktrace_remove_stackframeinfo
-       mflr r0
-       bcl 20,31,L00$_stacktrace_remove_stackframeinfo
-L00$_stacktrace_remove_stackframeinfo:
-       mflr r11
-       addis r11,r11,ha16(L_stacktrace_remove_stackframeinfo$lazy_ptr - L00$_stacktrace_remove_stackframeinfo)
-       mtlr r0
-       lwzu r12,lo16(L_stacktrace_remove_stackframeinfo$lazy_ptr - L00$_stacktrace_remove_stackframeinfo)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_stacktrace_remove_stackframeinfo$lazy_ptr:
-       .indirect_symbol _stacktrace_remove_stackframeinfo
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_exceptions_get_and_clear_exception$stub:
-       .indirect_symbol _exceptions_get_and_clear_exception
-       mflr r0
-       bcl 20,31,L00$_exceptions_get_and_clear_exception
-L00$_exceptions_get_and_clear_exception:
-       mflr r11
-       addis r11,r11,ha16(L_exceptions_get_and_clear_exception$lazy_ptr - L00$_exceptions_get_and_clear_exception)
-       mtlr r0
-       lwzu r12,lo16(L_exceptions_get_and_clear_exception$lazy_ptr - L00$_exceptions_get_and_clear_exception)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_exceptions_get_and_clear_exception$lazy_ptr:
-       .indirect_symbol _exceptions_get_and_clear_exception
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_exceptions_asm_new_abstractmethoderror$stub:
-       .indirect_symbol _exceptions_asm_new_abstractmethoderror
-       mflr r0
-       bcl 20,31,L00$_exceptions_asm_new_abstractmethoderror
-L00$_exceptions_asm_new_abstractmethoderror:
-       mflr r11
-       addis r11,r11,ha16(L_exceptions_asm_new_abstractmethoderror$lazy_ptr - L00$_exceptions_asm_new_abstractmethoderror)
-       mtlr r0
-       lwzu r12,lo16(L_exceptions_asm_new_abstractmethoderror$lazy_ptr - L00$_exceptions_asm_new_abstractmethoderror)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_exceptions_asm_new_abstractmethoderror$lazy_ptr:
-       .indirect_symbol _exceptions_asm_new_abstractmethoderror
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_patcher_wrapper$stub:
-       .indirect_symbol _patcher_wrapper
-       mflr r0
-       bcl 20,31,L00$_patcher_wrapper
-L00$_patcher_wrapper:
-       mflr r11
-       addis r11,r11,ha16(L_patcher_wrapper$lazy_ptr - L00$_patcher_wrapper)
-       mtlr r0
-       lwzu r12,lo16(L_patcher_wrapper$lazy_ptr - L00$_patcher_wrapper)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_patcher_wrapper$lazy_ptr:
-       .indirect_symbol _patcher_wrapper
-       .long dyld_stub_binding_helper
-
-
-.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
-       .align 2
-L_replace_me$stub:
-       .indirect_symbol _replace_me
-       mflr r0
-       bcl 20,31,L00$_replace_me
-L00$_replace_me:
-       mflr r11
-       addis r11,r11,ha16(L_replace_me$lazy_ptr - L00$_replace_me)
-       mtlr r0
-       lwzu r12,lo16(L_replace_me$lazy_ptr - L00$_replace_me)(r11)
-       mtctr r12
-       bctr
-.data
-.lazy_symbol_pointer
-L_replace_me$lazy_ptr:
-       .indirect_symbol _replace_me
-       .long dyld_stub_binding_helper
-
-#endif /* defined(__DARWIN__) */
-
-
 /* disable exec-stacks ********************************************************/
 
 #if defined(__linux__) && defined(__ELF__)
index 75c9de688725af4c6cc2176ee24a4744745c5d31..3df801b9bb4e8b422adae998567ceb849924505a 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7891 2007-05-09 16:37:20Z tbfg $
 
 */
 
@@ -44,6 +44,8 @@
 
 #include "native/native.h"
 
+#include "threads/lock-common.h"
+
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
 # include "vm/jit/allocator/lsra.h"
 #endif
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
-
 
 /* codegen_emit ****************************************************************
 
@@ -2320,36 +2318,18 @@ gen_method:
                                        super = iptr->sx.s23.s3.c.cls;
                                        superindex = super->index;
                                }
-                       
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
-                               s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-
-                               /* calculate interface checkcast code size */
-
-                               s2 = 9;
-#if defined(SOFTEX)
-                               s2 += CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) ? 2 : 0;
-#endif
-                               if (super == NULL)
-                                       s2 += (opt_shownops ? 1 : 0);
-
-                               /* calculate class checkcast code size */
+               
+                               if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
+                                       CODEGEN_CRITICAL_SECTION_NEW;
+                               }
 
-                               s3 = 10 + (s1 == REG_ITMP1);
-#if defined(SOFTEX)
-                               s3 += CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd) ? 1 : 0;
-#endif
-                               if (super == NULL)
-                                       s3 += (opt_shownops ? 1 : 0);
+                               s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
                                /* if class is not resolved, check which code to call */
 
                                if (super == NULL) {
                                        M_TST(s1);
-                                       M_BEQ(3 + (opt_shownops ? 1 : 0) + s2 + 1 + s3);
-
+                                       emit_label_beq(cd, BRANCH_LABEL_1);
                                        disp = dseg_add_unique_s4(cd, 0);                     /* super->flags */
 
                                        codegen_addpatchref(cd,
@@ -2359,7 +2339,8 @@ gen_method:
 
                                        M_ILD(REG_ITMP2, REG_PV, disp);
                                        M_AND_IMM(REG_ITMP2, ACC_INTERFACE, REG_ITMP2);
-                                       M_BEQ(s2 + 1);
+
+                                       emit_label_beq(cd, BRANCH_LABEL_2);
                                }
 
                                /* interface checkcast code */
@@ -2372,7 +2353,7 @@ gen_method:
                                                                                        0);
                                        } else {
                                                M_TST(s1);
-                                               M_BEQ(s2);
+                                               emit_label_beq(cd, BRANCH_LABEL_3);
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
@@ -2385,14 +2366,19 @@ gen_method:
                                        M_TST(REG_ITMP3);
                                        emit_classcast_check(cd, iptr, BRANCH_EQ, REG_ITMP3, s1);
 
-                                       if (!super)
-                                               M_BR(s3);
+                                       if (super == NULL)      {
+                                               emit_label_br(cd, BRANCH_LABEL_4);
+                                       } else  {
+                                               emit_label(cd, BRANCH_LABEL_3);
+                                       }
                                }
 
                                /* class checkcast code */
 
                                if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
                                        if (super == NULL) {
+                                               emit_label(cd, BRANCH_LABEL_2);
+
                                                disp = dseg_add_unique_address(cd, NULL);
                                                codegen_addpatchref(cd, PATCHER_checkcast_class,
                                                                                        iptr->sx.s23.s3.c.ref,
@@ -2400,21 +2386,21 @@ gen_method:
                                        } else {
                                                disp = dseg_add_address(cd, super->vftbl);
                                                M_TST(s1);
-                                               M_BEQ(s3);
+                                               emit_label_beq(cd, BRANCH_LABEL_5);
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       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));
-#if defined(ENABLE_THREADS)
-                                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                               CODEGEN_CRITICAL_SECTION_END;
+
                                                M_SUB(REG_ITMP3, REG_ITMP1, REG_ITMP3);
                                                M_EXTSW(REG_ITMP3, REG_ITMP3);
                                        } else {
@@ -2423,12 +2409,20 @@ 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));
-#if defined(ENABLE_THREADS)
-                                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                               CODEGEN_CRITICAL_SECTION_END;
+
                                        }
                                        M_CMPU(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_GT, REG_ITMP3, s1);
+                                       
+                                       if (super != NULL)
+                                               emit_label(cd, BRANCH_LABEL_5);
+                               }
+
+                               if (super == NULL) {
+                                       emit_label(cd, BRANCH_LABEL_1);
+                                       emit_label(cd, BRANCH_LABEL_4);
                                }
                                d = codegen_reg_of_dst(jd, iptr, s1);
 
@@ -2489,17 +2483,16 @@ gen_method:
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                super = NULL;
                                superindex = 0;
-                               supervftbl = NULL;
                        }
                        else {
                                super = iptr->sx.s23.s3.c.cls;
                                superindex = super->index;
-                               supervftbl = super->vftbl;
                        }
                        
-#if defined(ENABLE_THREADS)
-            codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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) {
@@ -2507,26 +2500,13 @@ gen_method:
                                s1 = REG_ITMP1;
                        }
 
-                       /* calculate interface instanceof code size */
-
-                       s2 = 8;
-                       if (!super)
-                               s2 += (opt_shownops ? 1 : 0);
-
-                       /* calculate class instanceof code size */
-
-                       s3 = 11;
-                       if (super == NULL)
-                               s3 += (opt_shownops ? 1 : 0);
-
                        M_CLR(d);
 
                        /* if class is not resolved, check which code to call */
 
                        if (super == NULL) {
                                M_TST(s1);
-                               M_BEQ(3 + (opt_shownops ? 1 : 0) + s2 + 1 + s3);
-
+                               emit_label_beq(cd, BRANCH_LABEL_1);
                                disp = dseg_add_unique_s4(cd, 0);                     /* super->flags */
 
                                codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
@@ -2534,20 +2514,20 @@ gen_method:
 
                                M_ILD(REG_ITMP3, REG_PV, disp);
                                M_AND_IMM(REG_ITMP3, ACC_INTERFACE, REG_ITMP3);
-                               M_BEQ(s2 + 1);
+                               emit_label_beq(cd, BRANCH_LABEL_2);
                        }
 
                        /* interface instanceof code */
 
-                       if (!super || (super->flags & ACC_INTERFACE)) {
-                               if (super) {
-                                       M_TST(s1);
-                                       M_BEQ(s2);
-
-                               } else {
+                       if ((super == NULL) || (super->flags & ACC_INTERFACE)) {
+                               if (super == NULL) {
                                        codegen_addpatchref(cd,
                                                                                PATCHER_instanceof_interface,
                                                                                iptr->sx.s23.s3.c.ref, 0);
+
+                               } else {
+                                       M_TST(s1);
+                                       emit_label_beq(cd, BRANCH_LABEL_3);
                                }
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
@@ -2561,44 +2541,58 @@ gen_method:
                                M_BEQ(1);
                                M_IADD_IMM(REG_ZERO, 1, d);
 
-                               if (super == NULL)
-                                       M_BR(s3);
+                               if (super == NULL)      {
+                                       emit_label_br(cd, BRANCH_LABEL_4);
+                               } else  {
+                                       emit_label(cd, BRANCH_LABEL_3);
+                               }
                        }
 
                        /* class instanceof code */
 
                        if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
 
-                               if (super) {
-                                       disp = dseg_add_address(cd, supervftbl);
-                                       M_TST(s1);
-                                       M_BEQ(s3);
+                               if (super == NULL) {
+                                       emit_label(cd, BRANCH_LABEL_2);
 
-                               } else {
                                        disp = dseg_add_unique_address(cd, NULL);
                                        codegen_addpatchref(cd, PATCHER_instanceof_class,
                                                                                iptr->sx.s23.s3.c.ref,
                                                                                disp);
+
+                               } else {
+                                       disp = dseg_add_address(cd, super->vftbl);
+                                       M_TST(s1);
+                                       emit_label_beq(cd, BRANCH_LABEL_5);
                                }
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_SUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_EXTSW(REG_ITMP1, REG_ITMP1);
                                M_CMPU(REG_ITMP1, REG_ITMP2);
                                M_CLR(d);
                                M_BGT(1);
                                M_IADD_IMM(REG_ZERO, 1, d);
+
+                               if (super != NULL)
+                                       emit_label(cd, BRANCH_LABEL_5);
                        }
+
+                       if (super == NULL) {
+                               emit_label(cd, BRANCH_LABEL_1);
+                               emit_label(cd, BRANCH_LABEL_4);
+                       }
+
                        emit_store_dst(jd, iptr, d);
                        }
                        break;
index 6656f4422a9116ac998097c5506a92079b946e63..237263729949640869153871795c430f7dacc3ae 100644 (file)
@@ -38,7 +38,7 @@
 #include "md-abi.h"
 #include "vm/jit/powerpc64/codegen.h"
 
-#include "vmcore/options.h"
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -49,9 +49,7 @@
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "vmcore/options.h"
 
 
 /* emit_load *******************************************************************
diff --git a/src/vm/jit/powerpc64/linux/.cvsignore b/src/vm/jit/powerpc64/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 730435c0294af9d7d26a306573c6dbfe6da7d32e..5c7648744ec5615ca70fa4e133d0ac3126b37390 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-os.c 7596 2007-03-28 21:05:53Z twisti $
+   $Id: md-os.c 7888 2007-05-09 08:36:16Z tbfg $
 
 */
 
@@ -135,7 +135,7 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 }
 
 
-void thread_restartcriticalsection(ucontext_t *_uc)
+void md_critical_section_restart(ucontext_t *_uc)
 {
        mcontext_t *_mc;
        u1         *pc;
@@ -147,8 +147,10 @@ void thread_restartcriticalsection(ucontext_t *_uc)
 
        critical = critical_find_restart_point(pc);
 
-       if (critical != NULL)
+       if (critical != NULL)   {
+               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, critical);
                _mc->gp_regs[PT_NIP] = (ptrint) critical;
+       }
 }
 #endif
 
index 831c076d0e49b19f7b5419ee2656aab9ccf5a12b..dce048b35ecb01f911b233ce35151a49a43bee92 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: patcher.c 7694 2007-04-12 15:35:13Z tbfg $
+   $Id: patcher.c 7909 2007-05-15 10:32:16Z tbfg $
 
 */
 
@@ -666,7 +666,7 @@ bool patcher_checkcast_interface(u1 *sp)
        *((s4 *)(ra + 5*4)) |= (disp & 0x0000ffff);
 
        /* sync instruction cache */
-       md_icacheflush(ra, 5*4);
+       md_icacheflush(ra, 6*4);
 
        return true;
 }
@@ -818,11 +818,14 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 {
        constant_classref *cr;
        s4                 disp;
-       u1                *pv;
+       u1                *pv, *ra;
+       u4         mcode;
        classinfo         *c;
 
        /* get stuff from the stack */
 
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u4 *)     (sp + 3 * 8));
        cr   = (constant_classref *) *((ptrint *) (sp + 2 * 8));
        disp =                       *((s4 *)     (sp + 1 * 8));
        pv   = (u1 *)                *((ptrint *) (sp + 0 * 8));
@@ -832,6 +835,14 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
        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 *) (pv + disp)) = (ptrint) c;
@@ -918,11 +929,14 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
 {
        constant_classref *cr;
        s4                 disp;
-       u1                *pv;
+       u1                *pv, *ra;
+       u4         mcode;
        classinfo         *c;
 
        /* get stuff from the stack */
 
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u4 *)     (sp + 3 * 8));
        cr   = (constant_classref *) *((ptrint *) (sp + 2 * 8));
        disp =                       *((s4 *)     (sp + 1 * 8));
        pv   = (u1 *)                *((ptrint *) (sp + 0 * 8));
@@ -932,6 +946,14 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
        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 *) (pv + disp)) = (ptrint) c->vftbl;
@@ -956,11 +978,14 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
 {
        constant_classref *cr;
        s4                 disp;
-       u1                *pv;
+       u1                *pv, *ra;
+       u4         mcode;
        classinfo         *c;
 
        /* get stuff from the stack */
 
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u4 *)     (sp + 3 * 8));
        cr   = (constant_classref *) *((ptrint *) (sp + 2 * 8));
        disp =                       *((s4 *)     (sp + 1 * 8));
        pv   = (u1 *)                *((ptrint *) (sp + 0 * 8));
@@ -970,6 +995,14 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
        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 *) (pv + disp)) = (s4) c->flags;
diff --git a/src/vm/jit/s390/.cvsignore b/src/vm/jit/s390/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index e5f96bcd9e45acee77dc0ed3e133926200874c03..95edc5d159636f9b64610cb4baa1fcf5c5d39873 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: arch.h 7695 2007-04-12 19:49:34Z twisti $
+   $Id: arch.h 7839 2007-04-29 22:46:56Z pm $
 
 */
 
 #define CONSECUTIVE_INTEGER_ARGS
 #define CONSECUTIVE_FLOAT_ARGS
 
+/* branches *******************************************************************/
+
+#define SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER       1
+#define SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER     0
+#define SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS    0
+#define SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS      0
+
+/* exceptions *****************************************************************/
+
+#define SUPPORT_HARDWARE_DIVIDE_BY_ZERO  1
+
+/* misc ***********************************************************************/
+
 #define HAS_4BYTE_STACKSLOT
 #define SUPPORT_COMBINE_INTEGER_REGISTERS
 
index 1cceb97d3d313dd1eaa5d6f94e848daa5668fbc8..d8a30e6fe3b9ee37e2b5ba27c351adc244d19f15 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.S 7680 2007-04-10 05:02:20Z pm $
+   $Id: asmpart.S 7839 2007-04-29 22:46:56Z pm $
 
 */
 
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/methodheader.h"
 
-/* Copy a call to a PIC function from gcc -S
- * We setup a temporary literal pool pointer.
- */
-
        .text
 
 
@@ -181,7 +177,7 @@ L_register_copy:
        ahi   itmp2, -1                       /* decrement arg count */
        je    L_register_copy_done            /* no arguments left */
 
-       tm    offvmargtype(itmp1), 0x02       /* is this a float/double type? */
+       tm    offvmargtype+7(itmp1), 0x02     /* is this a float/double type? */
        jne   L_register_handle_float
 
 L_register_handle_int:
@@ -189,7 +185,7 @@ L_register_handle_int:
        chi   s2, INT_ARG_CNT                 /* are we out of integer arg registers ? */
        je    L_register_copy                 /* yes, next loop */
 
-       tm    offvmargtype(itmp1), 0x01       /* is this a 2 word type ? */
+       tm    offvmargtype+7(itmp1), 0x01       /* is this a 2 word type ? */
        jne   L_register_handle_long
 
        ahi   s0, 1                           /* increment integer arg counter */
@@ -222,13 +218,13 @@ L_register_handle_long_continue:
 
        /* handle argument */
 
-       chi   s2, 1
-       je    L_handle_l0
        chi   s2, 2
-       je    L_handle_l1
+       je    L_handle_l0
        chi   s2, 3
-       je    L_handle_l2
+       je    L_handle_l1
        chi   s2, 4
+       je    L_handle_l2
+       chi   s2, 5
        je    L_handle_l3
 
 L_register_handle_float:
@@ -238,7 +234,7 @@ L_register_handle_float:
 
        ahi   s1, 1                           /* increment float argument counter */
 
-       tm    offvmargtype(itmp1), 0x01       /* is this a 2 word type ? */
+       tm    offvmargtype+7(itmp1), 0x01     /* is this a 2 word type ? */
        jne   L_register_handle_double
 
        /* handle argument */
@@ -297,7 +293,7 @@ L_stack_copy_loop:
        ahi   itmp2, -1                     /* decrement argument counter */
        je    L_copy_done                   /* all arguments done */
 
-       tm    offvmargtype(itmp1), 0x0      /* is this a float/double type? */
+       tm    offvmargtype+7(itmp1), 0x02   /* is this a float/double type? */
        jne   L_stack_handle_float
 
 L_stack_handle_int:
@@ -305,10 +301,10 @@ L_stack_handle_int:
        ahi   s0, -1                         /* decrement number of integer arguments in regs */
        jhe   L_stack_copy_loop              /* argument is in register */
 
-       tm    offvmargtype(itmp1), 0x01      /* is this a 2 word type ? */
+       tm    offvmargtype+7(itmp1), 0x01    /* is this a 2 word type ? */
        jne   L_stack_handle_long
 
-       mvc   0(4, s2), offvmargdata+4(itmp1) /* copy integer value */
+       mvc   0(4, s2), offvmargdata+4(itmp1)/* copy integer value */
        ahi   s2, 4
        j     L_stack_copy_loop
 
@@ -323,7 +319,7 @@ L_stack_handle_float:
        ahi   s1, -1                         /* decrement number of float arguments in regs */
        jhe   L_stack_copy_loop              /* argument is in register */
 
-       tm    offvmargtype(itmp1), 0x01      /* is this a 2 word type ? */
+       tm    offvmargtype+7(itmp1), 0x01    /* is this a 2 word type ? */
        jne   L_stack_handle_double
 
        mvc   0(4, s2), offvmargdata(itmp1)  /* copy float value */
index e349712d1dcf8719149b0dd3f4da1c20556ca0e0..bf0b938813b8e60723e0c45f3aff4ffab4ecda81 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: codegen.c 7848 2007-05-01 21:40:26Z pm $
 
 */
 
@@ -67,6 +67,8 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/abi.h"
+#include "vm/jit/emit-common.h"
 
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
@@ -83,7 +85,7 @@ void panic() { }
 *******************************************************************************/
 
 
-bool codegen(jitdata *jd)
+bool codegen_emit(jitdata *jd)
 {
        methodinfo         *m;
        codeinfo           *code;
@@ -142,12 +144,19 @@ bool codegen(jitdata *jd)
         */
 
 #if defined(ENABLE_THREADS)
-       /* space to save argument of monitor_enter */
-       OOPS(); /* see powerpc  */
-#if 0
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               cd->stackframesize++;
-#endif
+       /* Space to save argument of monitor_enter and Return Values to
+          survive monitor_exit. The stack position for the argument can
+          not be shared with place to save the return register
+          since both values reside in R2. */
+
+       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+               /* reserve 2 slots for long/double return values for monitorexit */
+
+               if (IS_2_WORD_TYPE(m->parseddesc->returntype.type))
+                       cd->stackframesize += 3;
+               else
+                       cd->stackframesize += 2;
+       }
 #endif
 
        /* Keep stack of non-leaf functions 16-byte aligned for calls into
@@ -174,10 +183,8 @@ bool codegen(jitdata *jd)
                (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 4); /* IsSync        */
        else
 #endif
-/*
-               (void) dseg_add_unique_s4(cd, 0);*/                  /* IsSync          */
 
-       disp = dseg_add_unique_address(cd, 0);
+               (void) dseg_add_unique_s4(cd, 0);                    /* IsSync          */
 
        (void) dseg_add_unique_s4(cd, jd->isleafmethod);               /* IsLeaf  */
        (void) dseg_add_unique_s4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave */
@@ -216,9 +223,6 @@ bool codegen(jitdata *jd)
        if (cd->stackframesize)
                M_ASUB_IMM(cd->stackframesize * 4, REG_SP);
 
-       N_LHI(REG_ITMP2, disp);
-       N_ST(REG_SP, 0, REG_ITMP2, REG_PV);
-
        /* save used callee saved registers and return address */
 
        p = cd->stackframesize;
@@ -250,11 +254,14 @@ bool codegen(jitdata *jd)
 
                s1 = md->params[p].regoff;
                if (IS_INT_LNG_TYPE(t)) {                    /* integer args          */
-                       if (IS_2_WORD_TYPE(t))
-                               s2 = PACK_REGS(rd->argintregs[GET_LOW_REG(s1)],
-                                                          rd->argintregs[GET_HIGH_REG(s1)]);
-                       else
-                               s2 = rd->argintregs[s1];
+                       if (IS_2_WORD_TYPE(t)) {
+                               s2 = PACK_REGS(
+                                       GET_LOW_REG(s1),
+                                       GET_HIGH_REG(s1)
+                               );
+                       } else {
+                               s2 = s1;
+                       }
                        if (!md->params[p].inmemory) {           /* register arguments    */
                                if (!IS_INMEMORY(var->flags)) {      /* reg arg -> register   */
                                        if (IS_2_WORD_TYPE(t))
@@ -288,7 +295,7 @@ bool codegen(jitdata *jd)
 
                } else {                                     /* floating args         */
                        if (!md->params[p].inmemory) {           /* register arguments    */
-                               s2 = rd->argfltregs[s1];
+                               s2 = s1;
                                if (!IS_INMEMORY(var->flags)) {      /* reg arg -> register   */
                                        M_FLTMOVE(s2, var->vv.regoff);
 
@@ -330,42 +337,52 @@ bool codegen(jitdata *jd)
 
                s1 = rd->memuse;
 
+#if !defined(NDEBUG)
                if (opt_verbosecall) {
-                       M_LSUB_IMM((INT_ARG_CNT + FLT_ARG_CNT) * 8, REG_SP);
+                       M_ASUB_IMM((INT_ARG_CNT + FLT_ARG_CNT) * 8, REG_SP);
 
                        for (p = 0; p < INT_ARG_CNT; p++)
-                               M_LST(rd->argintregs[p], REG_SP, p * 8);
+                               M_IST(abi_registers_integer_argument[p], REG_SP, p * 8);
 
                        for (p = 0; p < FLT_ARG_CNT; p++)
-                               M_DST(rd->argfltregs[p], REG_SP, (INT_ARG_CNT + p) * 8);
+                               M_FST(abi_registers_float_argument[p], REG_SP, (INT_ARG_CNT + p) * 8);
 
-                       s1 += INT_ARG_CNT + FLT_ARG_CNT;
+                       s1 += ((INT_ARG_CNT + FLT_ARG_CNT) * 2);
                }
+#endif
 
                /* decide which monitor enter function to call */
 
                if (m->flags & ACC_STATIC) {
-                       M_MOV_IMM(&m->class->object.header, REG_A0);
+                       disp = dseg_add_address(cd, &m->class->object.header);
+                       M_ALD(REG_A0, REG_PV, disp);
                }
                else {
                        M_TEST(REG_A0);
-                       M_BEQ(0);
-                       codegen_add_nullpointerexception_ref(cd);
+                       M_BNE(SZ_BRC + SZ_ILL);
+                       M_ILL(EXCEPTION_HARDWARE_NULLPOINTER);
                }
 
-               M_AST(REG_A0, REG_SP, s1 * 8);
-               M_MOV_IMM(LOCK_monitor_enter, REG_ITMP1);
-               M_CALL(REG_ITMP1);
+               disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
+               M_ALD(REG_ITMP3, REG_PV, disp);
+
+               M_AST(REG_A0, REG_SP, s1 * 4);
+
+               M_ASUB_IMM(96, REG_SP); 
+               M_CALL(REG_ITMP3);
+               M_AADD_IMM(96, REG_SP); 
 
+#if !defined(NDEBUG)
                if (opt_verbosecall) {
                        for (p = 0; p < INT_ARG_CNT; p++)
-                               M_LLD(rd->argintregs[p], REG_SP, p * 8);
+                               M_ILD(abi_registers_integer_argument[p], REG_SP, p * 8);
 
                        for (p = 0; p < FLT_ARG_CNT; p++)
-                               M_DLD(rd->argfltregs[p], REG_SP, (INT_ARG_CNT + p) * 8);
+                               M_FLD(abi_registers_float_argument[p], REG_SP, (INT_ARG_CNT + p) * 8);
 
-                       M_LADD_IMM((INT_ARG_CNT + FLT_ARG_CNT) * 8, REG_SP);
+                       M_AADD_IMM((INT_ARG_CNT + FLT_ARG_CNT) * 8, REG_SP);
                }
+#endif
        }
 #endif
 
@@ -486,9 +503,7 @@ bool codegen(jitdata *jd)
 
                case ICMD_CHECKNULL:  /* ..., objectref  ==> ..., objectref           */
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                       M_TEST(s1);
-                       M_BEQ(0);
-                       codegen_add_nullpointerexception_ref(cd);
+                       emit_nullpointer_check(cd, iptr, s1);
                        break;
 
                /* constant operations ************************************************/
@@ -616,9 +631,9 @@ bool codegen(jitdata *jd)
                case ICMD_INT2BYTE:   /* ..., value  ==> ..., value                   */
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
-                       M_SLA_IMM(24, d);
-                       M_SRA_IMM(24, d);
                        M_INTMOVE(s1, d);
+                       M_SLL_IMM(24, d);
+                       M_SRA_IMM(24, d);
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -635,9 +650,9 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
-                       M_SLA_IMM(16, d);
-                       M_SRA_IMM(16, d);
                        M_INTMOVE(s1, d);
+                       M_SLL_IMM(16, d);
+                       M_SRA_IMM(16, d);
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -666,8 +681,7 @@ bool codegen(jitdata *jd)
                        if (N_VALID_IMM(iptr->sx.val.i)) {
                                M_IADD_IMM(iptr->sx.val.i, d);
                        } else {
-                               disp = dseg_add_s4(cd, iptr->sx.val.i);
-                               M_ILD(REG_ITMP2, REG_PV, disp);
+                               ICONST(REG_ITMP2, iptr->sx.val.i);
                                M_IADD(REG_ITMP2, d);   
                        }
                        emit_store_dst(jd, iptr, d);
@@ -675,9 +689,11 @@ bool codegen(jitdata *jd)
 
                case ICMD_LADD:       /* ..., val1, val2  ==> ..., val1 + val2        */
 
+                       /* M, (r, q) -> (r, q) */
+
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
 
-                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(d));
+                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(REG_ITMP12_PACKED));
                        s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        dd = GET_HIGH_REG(d);
 
@@ -688,7 +704,7 @@ bool codegen(jitdata *jd)
                                M_IADD(s2, dd);
                        }
 
-                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(d));
+                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(REG_ITMP12_PACKED));
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP3);
                        dd = GET_LOW_REG(d);
 
@@ -709,25 +725,27 @@ bool codegen(jitdata *jd)
                                      /* sx.val.l = constant                             */
 
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
+                       dd = GET_HIGH_REG(d);
 
-                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(d));
+                       s1 = emit_load_s1_high(jd, iptr, dd);
                        s3 = iptr->sx.val.l >> 32;
 
-                       M_INTMOVE(s1, GET_HIGH_REG(d));
+                       M_INTMOVE(s1, dd);
 
                        if (N_VALID_IMM(s3)) {
-                               N_AHI(s1, s3);
+                               M_IADD_IMM(s3, dd);
                        } else {
                                ICONST(REG_ITMP3, s3);
-                               M_IADD(REG_ITMP3, s1);
+                               M_IADD(REG_ITMP3, dd);
                        }
 
-                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(d));
+                       dd = GET_LOW_REG(d);
+                       s1 = emit_load_s1_low(jd, iptr, dd);
                        s3 = iptr->sx.val.l & 0xffffffff;
                        ICONST(REG_ITMP3, s3);
 
-                       M_INTMOVE(s1, GET_LOW_REG(d));
-                       N_ALR(GET_LOW_REG(d), REG_ITMP3);
+                       M_INTMOVE(s1, dd);
+                       N_ALR(dd, REG_ITMP3);
 
                        N_BRC(8 | 4, SZ_BRC + SZ_AHI); 
                        N_AHI(GET_HIGH_REG(d), 1);
@@ -758,12 +776,11 @@ bool codegen(jitdata *jd)
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
                        M_INTMOVE(s1, d);
-                       /* TODO range */
-                       if (N_VALID_IMM(iptr->sx.val.i)) {
+
+                       if (N_VALID_IMM(-iptr->sx.val.i)) {
                                M_ISUB_IMM(iptr->sx.val.i, d);
                        } else {
-                               disp = dseg_add_s4(cd, iptr->sx.val.i);
-                               M_ILD(REG_ITMP2, REG_PV, disp);
+                               ICONST(REG_ITMP2, iptr->sx.val.i);
                                M_ISUB(REG_ITMP2, d);
                        }
                        emit_store_dst(jd, iptr, d);
@@ -774,7 +791,7 @@ bool codegen(jitdata *jd)
 
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
 
-                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(d));
+                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(REG_ITMP12_PACKED));
                        s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        dd = GET_HIGH_REG(d);
 
@@ -786,7 +803,7 @@ bool codegen(jitdata *jd)
                        M_INTMOVE(s1, dd);
                        M_ISUB(s2, dd);
 
-                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(d));
+                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(REG_ITMP12_PACKED));
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP3);
                        dd = GET_LOW_REG(d);
 
@@ -809,23 +826,26 @@ bool codegen(jitdata *jd)
 
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
 
-                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(d));
+                       dd = GET_HIGH_REG(d);
+                       s1 = emit_load_s1_high(jd, iptr, dd);
                        s3 = iptr->sx.val.l >> 32;
 
-                       M_INTMOVE(s1, GET_HIGH_REG(d));
+                       M_INTMOVE(s1, dd);
 
                        if (N_VALID_IMM(-s3)) {
-                               M_IADD_IMM(-s3, s1);
+                               M_IADD_IMM(-s3, dd);
                        } else {
                                ICONST(REG_ITMP3, s3);
-                               M_ISUB(REG_ITMP3, s1);
+                               M_ISUB(REG_ITMP3, dd);
                        }
 
-                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(d));
+                       dd = GET_LOW_REG(d);
+                       s1 = emit_load_s1_low(jd, iptr, dd);
                        s3 = iptr->sx.val.l & 0xffffffff;
                        ICONST(REG_ITMP3, s3);
 
-                       N_SLR(GET_LOW_REG(d), REG_ITMP3);
+                       M_INTMOVE(s1, dd);
+                       N_SLR(dd, REG_ITMP3);
 
                        N_BRC(1 | 2, SZ_BRC + SZ_AHI); 
                        N_AHI(GET_HIGH_REG(d), -1);
@@ -868,17 +888,18 @@ bool codegen(jitdata *jd)
                case ICMD_IDIV:       /* ..., val1, val2  ==> ..., val1 / val2        */
                case ICMD_IREM:       /* ..., val1, val2  ==> ..., val1 % val2        */
 
+                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
+                       emit_arithmetic_check(cd, iptr, s2);
+
                        /* For this operation we need a register pair.
                         * We will use r0 and itmp1 and will backup r0.
                         */
 
                        M_INTMOVE(R0, REG_ITMP3);
 
-                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
-
-                       M_TEST(s2);
-                       M_BEQ(0);
-                       codegen_add_arithmeticexception_ref(cd);
+                       /* We won't check for division by 0, we catch a SIGFPE instead
+                        * Special case 0x80000000 / 0xffffffff handled by signal handler too.
+                        */
 
                        s1 = emit_load_s1(jd, iptr, R0);
                        M_INTMOVE(s1, R0);
@@ -900,7 +921,13 @@ bool codegen(jitdata *jd)
 
                        emit_store_dst(jd, iptr, d);
 
-                       M_INTMOVE(REG_ITMP3, R0);
+                       /* If destionation of operation was not register R0,
+                        * restore R0.
+                        */
+
+                       if (! ((d == R0) && !IS_INMEMORY(VAROP(iptr->dst)->flags))) {
+                               M_INTMOVE(REG_ITMP3, R0);
+                       }
 
                        break;
 
@@ -915,8 +942,9 @@ bool codegen(jitdata *jd)
                        s2 = emit_load_s2(jd, iptr, REG_ITMP12_PACKED);
                        M_INTMOVE(GET_LOW_REG(s2), REG_ITMP3);
                        M_IOR(GET_HIGH_REG(s2), REG_ITMP3);
-                       M_BEQ(0);
-                       codegen_add_arithmeticexception_ref(cd);
+                       emit_arithmetic_check(cd, iptr, REG_ITMP3);
+
+                       /* TODO SIGFPE? */
 
                        disp = dseg_add_functionptr(cd, bte->fp);
 
@@ -948,18 +976,20 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP1);
-                       s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
+                       s2 = emit_load_s2(jd, iptr, REG_ITMP2);
 
-                       if (s2 == d) {
-                               M_INTMOVE(s2, REG_ITMP2);
-                               s2 = REG_ITMP2;
-                       }
+                       /* Use only 5 bits of sencond operand. */
+
+                       M_INTMOVE(s2, REG_ITMP2);
+                       s2 = REG_ITMP2;
+                       ICONST(REG_ITMP3, 0x1F);
+                       M_IAND(REG_ITMP3, s2);
 
                        M_INTMOVE(s1, d);
 
                        switch (iptr->opc) {
                                case ICMD_ISHL:
-                                       M_SLA(s2, d);
+                                       M_SLL(s2, d);
                                        break;
                                case ICMD_ISHR:
                                        M_SRA(s2, d);
@@ -1045,24 +1075,17 @@ bool codegen(jitdata *jd)
 
                        M_INTMOVE(s1, d);
 
-                       if (N_VALID_DISP(iptr->sx.val.i)) {
-                               disp = iptr->sx.val.i;
-                               s3 = RN;
-                       } else {
-                               ICONST(REG_ITMP3, iptr->sx.val.i);
-                               disp = 0;
-                               s3 = REG_ITMP3;
-                       }
+                       disp = iptr->sx.val.i & 0x1F; /* Use only 5 bits of value */
 
                        switch (iptr->opc) {
                                case ICMD_ISHLCONST:
-                                       N_SLA(d, disp, s3);
+                                       N_SLL(d, disp, RN);
                                        break;
                                case ICMD_ISHRCONST:
-                                       N_SRA(d, disp, s3);
+                                       N_SRA(d, disp, RN);
                                        break;
                                case ICMD_IUSHRCONST:
-                                       N_SRL(d, disp, s3);
+                                       N_SRL(d, disp, RN);
                                        break;
                                default:
                                        assert(0);
@@ -1077,9 +1100,17 @@ bool codegen(jitdata *jd)
 
                case ICMD_LUSHR:      /* ..., val1, val2  ==> ..., val1 >>> val2      */
 
-                       d = emit_alloc_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP3); /* d wont contain REG_ITMP3 */
 
+                       /* Use only 6 bits of second operand */
+
+                       M_INTMOVE(s2, REG_ITMP3);
+                       s2 = REG_ITMP3;
+                       ICONST(REG_ITMP2, 0x3F);
+                       M_IAND(REG_ITMP2, s2);
+
+                       d = emit_alloc_dst_even_odd(jd, iptr, R0, REG_ITMP1, REG_ITMP2);
+
                        if ((s2 == GET_LOW_REG(d)) || (s2 == GET_HIGH_REG(d))) {
                                M_INTMOVE(s2, REG_ITMP3);
                                s2 = REG_ITMP3;
@@ -1091,7 +1122,7 @@ bool codegen(jitdata *jd)
 
                        switch (iptr->opc) {
                                case ICMD_LSHL:
-                                       M_SLDA(s2, GET_HIGH_REG(d));
+                                       M_SLDL(s2, GET_HIGH_REG(d));
                                        break;
                                case ICMD_LSHR:
                                        M_SRDA(s2, GET_HIGH_REG(d));
@@ -1122,27 +1153,20 @@ bool codegen(jitdata *jd)
                
                        M_LNGMOVE(s1, d);
 
-                       if (N_VALID_DISP(iptr->sx.val.i)) {
-                               disp = iptr->sx.val.i;
-                               s3 = RN;
-                       } else {
-                               ICONST(REG_ITMP3, iptr->sx.val.i);
-                               disp = 0;
-                               s3 = REG_ITMP3;
-                       }
+                       disp = iptr->sx.val.i & 0x3F; /* Use only 6 bits of operand */
 
                        switch (iptr->opc) {
                                case ICMD_LSHLCONST:
-                                       N_SLDA(GET_HIGH_REG(d), disp, s3);
+                                       N_SLDL(GET_HIGH_REG(d), disp, RN);
                                        break;
                                case ICMD_LSHRCONST:
-                                       N_SRDA(GET_HIGH_REG(d), disp, s3);
+                                       N_SRDA(GET_HIGH_REG(d), disp, RN);
                                        break;
                                case ICMD_LUSHRCONST:
-                                       N_SRDL(GET_HIGH_REG(d), disp, s3);
+                                       N_SRDL(GET_HIGH_REG(d), disp, RN);
                                        break;
                                case ICMD_LMULPOW2:
-                                       N_SLDL(GET_HIGH_REG(d), disp, s3);
+                                       N_SLDL(GET_HIGH_REG(d), disp, RN);
                                        break;
                                default:
                                        assert(0);
@@ -1238,7 +1262,7 @@ bool codegen(jitdata *jd)
 
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
 
-                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(d));
+                       s1 = emit_load_s1_low(jd, iptr, GET_LOW_REG(REG_ITMP12_PACKED));
                        s2 = emit_load_s2_low(jd, iptr, REG_ITMP3);
                        dd = GET_LOW_REG(d);
 
@@ -1271,7 +1295,7 @@ bool codegen(jitdata *jd)
                                        assert(0);
                        }
 
-                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(d));
+                       s1 = emit_load_s1_high(jd, iptr, GET_HIGH_REG(REG_ITMP12_PACKED));
                        s2 = emit_load_s2_high(jd, iptr, REG_ITMP3);
                        dd = GET_HIGH_REG(d);
 
@@ -1574,7 +1598,8 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP3);
-                       gen_nullptr_check(s1);
+                       /* TODO softnull */
+                       /* implicit null-pointer check */
                        M_ILD(d, s1, OFFSET(java_arrayheader, size));
                        emit_store_dst(jd, iptr, d);
 
@@ -1585,12 +1610,14 @@ bool codegen(jitdata *jd)
                        s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        N_IC(d, OFFSET(java_bytearray, data[0]), s2, s1);
-                       /* TODO improove this */
+
                        M_SLL_IMM(24, d);
-                       M_SRL_IMM(24, d);
+                       M_SRA_IMM(24, d);
+
                        emit_store_dst(jd, iptr, d);
                        break;
 
@@ -1600,12 +1627,19 @@ bool codegen(jitdata *jd)
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(1, REG_ITMP2);
 
                        N_LH(d, OFFSET(java_chararray, data[0]), REG_ITMP2, s1);
+
+                       /* N_LH does sign extends, undo ! */
+
+                       M_SLL_IMM(16, d);
+                       M_SRL_IMM(16, d);
+
                        emit_store_dst(jd, iptr, d);
                        break;                  
 
@@ -1614,7 +1648,8 @@ bool codegen(jitdata *jd)
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(1, REG_ITMP2);
@@ -1627,7 +1662,9 @@ bool codegen(jitdata *jd)
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(2, REG_ITMP2); /* scale index by 4 */
@@ -1641,7 +1678,9 @@ bool codegen(jitdata *jd)
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
 
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP12_PACKED);
-                       emit_array_checks(cd, iptr, s1, s2);
+
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(3, REG_ITMP2); /* scale index by 8 */
@@ -1657,7 +1696,9 @@ bool codegen(jitdata *jd)
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
-                       emit_array_checks(cd, iptr, s1, s2);
+
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(2, REG_ITMP2); /* scale index by 4 */
@@ -1671,7 +1712,9 @@ bool codegen(jitdata *jd)
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_FTMP1);
-                       emit_array_checks(cd, iptr, s1, s2);
+
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(3, REG_ITMP2); /* scale index by 8 */
@@ -1685,7 +1728,9 @@ bool codegen(jitdata *jd)
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(2, REG_ITMP2); /* scale index by 4 */
@@ -1696,7 +1741,8 @@ bool codegen(jitdata *jd)
                case ICMD_BASTORE:    /* ..., arrayref, index, value  ==> ...         */
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2_notzero(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
 
                        N_STC(s3, OFFSET(java_bytearray, data[0]), s2, s1);
@@ -1706,7 +1752,8 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
 
                        M_INTMOVE(s2, REG_ITMP2);
@@ -1719,7 +1766,8 @@ bool codegen(jitdata *jd)
                case ICMD_SASTORE:    /* ..., arrayref, index, value  ==> ...         */
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
 
                        M_INTMOVE(s2, REG_ITMP2);
@@ -1732,7 +1780,8 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        s3 = emit_load_s3(jd, iptr, REG_ITMP3);
 
@@ -1746,7 +1795,8 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
 
                        M_INTMOVE(s2, REG_ITMP2);
                        M_SLL_IMM(3, REG_ITMP2);
@@ -1760,7 +1810,8 @@ bool codegen(jitdata *jd)
                case ICMD_FASTORE:    /* ..., arrayref, index, value  ==> ...         */
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_FTMP1);
 
                        M_INTMOVE(s2, REG_ITMP2);
@@ -1772,7 +1823,8 @@ bool codegen(jitdata *jd)
                case ICMD_DASTORE:    /* ..., arrayref, index, value  ==> ...         */
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_FTMP1);
 
                        M_INTMOVE(s2, REG_ITMP2);
@@ -1785,7 +1837,8 @@ bool codegen(jitdata *jd)
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_A0);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
-                       emit_array_checks(cd, iptr, s1, s2);
+                       /* implicit null-pointer check */
+                       emit_arrayindexoutofbounds_check(cd, iptr, s1, s2);
                        s3 = emit_load_s3(jd, iptr, REG_A1);
 
                        M_INTMOVE(s1, REG_A0);
@@ -1797,9 +1850,7 @@ bool codegen(jitdata *jd)
                        M_JSR(REG_RA, REG_ITMP3);
                        M_AADD_IMM(96, REG_SP);
 
-                       M_TEST(REG_RESULT);
-                       M_BEQ(0);
-                       codegen_add_arraystoreexception_ref(cd);
+                       emit_exception_check(cd, iptr);
 
                        s1 = emit_load_s1(jd, iptr, REG_ITMP1);
                        s2 = emit_load_s2(jd, iptr, REG_ITMP2);
@@ -1919,7 +1970,7 @@ bool codegen(jitdata *jd)
                case ICMD_GETFIELD:   /* ...  ==> ..., value                          */
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
-                       gen_nullptr_check(s1);
+                       emit_nullpointer_check(cd, iptr, s1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                uf        = iptr->sx.s23.s3.uf;
@@ -1969,7 +2020,7 @@ bool codegen(jitdata *jd)
                case ICMD_PUTFIELD:   /* ..., objectref, value  ==> ...               */
 
                        s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
-                       gen_nullptr_check(s1);
+                       emit_nullpointer_check(cd, iptr, s1);
 
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                uf        = iptr->sx.s23.s3.uf;
@@ -2042,15 +2093,13 @@ bool codegen(jitdata *jd)
                case ICMD_GOTO:         /* ... ==> ...                                */
                case ICMD_RET:          /* ... ==> ...                                */
 
-                       M_BR(0);
-                       codegen_add_branch_ref(cd, iptr->dst.block);
+                       emit_br(cd, iptr->dst.block);
 
                        break;
 
                case ICMD_JSR:          /* ... ==> ...                                */
 
-                       M_BR(0);
-                       codegen_add_branch_ref(cd, iptr->sx.s23.s3.jsrtarget.block);
+                       emit_br(cd, iptr->sx.s23.s3.jsrtarget.block);
 
                        break;
                        
@@ -2060,13 +2109,12 @@ bool codegen(jitdata *jd)
                        M_TEST(s1);
                        switch (iptr->opc) {    
                                case ICMD_IFNULL:
-                                       M_BEQ(0);
+                                       emit_beq(cd, iptr->dst.block);
                                        break;
                                case ICMD_IFNONNULL:
-                                       M_BNE(0);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                        }
-                       codegen_add_branch_ref(cd, iptr->dst.block);
                        break;
 
                case ICMD_IFEQ:         /* ..., value ==> ...                         */
@@ -2088,25 +2136,24 @@ bool codegen(jitdata *jd)
 
                        switch (iptr->opc) {
                        case ICMD_IFLT:
-                               M_BLT(0);
+                               emit_blt(cd, iptr->dst.block);
                                break;
                        case ICMD_IFLE:
-                               M_BLE(0);
+                               emit_ble(cd, iptr->dst.block);
                                break;
                        case ICMD_IFNE:
-                               M_BNE(0);
+                               emit_bne(cd, iptr->dst.block);
                                break;
                        case ICMD_IFGT:
-                               M_BGT(0);
+                               emit_bgt(cd, iptr->dst.block);
                                break;
                        case ICMD_IFGE:
-                               M_BGE(0);
+                               emit_bge(cd, iptr->dst.block);
                                break;
                        case ICMD_IFEQ:
-                               M_BEQ(0);
+                               emit_beq(cd, iptr->dst.block);
                                break;
                        }
-                       codegen_add_branch_ref(cd, iptr->dst.block);
 
                        break;
 
@@ -2116,88 +2163,81 @@ bool codegen(jitdata *jd)
                case ICMD_IF_LGE:
                case ICMD_IF_LEQ:
                case ICMD_IF_LNE:
-                       {
 
-                               u1 *out_ref = NULL;
+                       /* ATTENTION: compare high words signed and low words unsigned */
 
-                               /* ATTENTION: compare high words signed and low words unsigned */
-       
-                               s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
+#                      define LABEL_OUT BRANCH_LABEL_1
 
-                               if (N_VALID_IMM(iptr->sx.val.l >> 32))
-                                       M_ICMP_IMM(s1, iptr->sx.val.l >> 32);
-                               else {
-                                       disp = dseg_add_s4(cd, iptr->sx.val.l >> 32);
-                                       ICONST(REG_ITMP2, disp);
-                                       N_C(s1, 0, REG_ITMP2, REG_PV);
-                               }
+                       s1 = emit_load_s1_high(jd, iptr, REG_ITMP1);
 
-                               switch(iptr->opc) {
+                       if (N_VALID_IMM(iptr->sx.val.l >> 32))
+                               M_ICMP_IMM(s1, iptr->sx.val.l >> 32);
+                       else {
+                               disp = dseg_add_s4(cd, iptr->sx.val.l >> 32);
+                               ICONST(REG_ITMP2, disp);
+                               N_C(s1, 0, REG_ITMP2, REG_PV);
+                       }
+
+                       switch(iptr->opc) {
                                case ICMD_IF_LLT:
                                case ICMD_IF_LLE:
-                                       M_BLT(0);
-                                       codegen_addreference(cd, iptr->dst.block);
+                                       emit_blt(cd, iptr->dst.block);
                                        /* EQ ... fall through */
-                                       out_ref = cd->mcodeptr;
-                                       M_BGT(0);
+                                       emit_label_bgt(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LGT:
                                case ICMD_IF_LGE:
-                                       M_BGT(0);
-                                       codegen_addreference(cd, iptr->dst.block);
+                                       emit_bgt(cd, iptr->dst.block);
                                        /* EQ ... fall through */
-                                       out_ref = cd->mcodeptr;
-                                       M_BLT(0);
+                                       emit_label_blt(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LEQ: 
                                        /* EQ ... fall through */
-                                       out_ref = cd->mcodeptr;
-                                       M_BNE(0);
+                                       emit_label_bne(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LNE:
                                        /* EQ ... fall through */
-                                       M_BNE(0);
-                                       codegen_addreference(cd, iptr->dst.block);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                                default:
                                        assert(0);
-                               }
+                       }
 
-                               s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1_low(jd, iptr, REG_ITMP1);
 
-                               disp = dseg_add_s4(cd, (s4)(iptr->sx.val.l & 0xffffffff));
-                               ICONST(REG_ITMP2, disp);
-                               N_CL(s1, 0, REG_ITMP2, REG_PV);
+                       disp = dseg_add_s4(cd, (s4)(iptr->sx.val.l & 0xffffffff));
+                       ICONST(REG_ITMP2, disp);
+                       N_CL(s1, 0, REG_ITMP2, REG_PV);
 
-                               switch(iptr->opc) {
+                       switch(iptr->opc) {
                                case ICMD_IF_LLT:
-                                       M_BLT(0);
+                                       emit_blt(cd, iptr->dst.block);
+                                       emit_label(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LLE:
-                                       M_BLE(0);
+                                       emit_ble(cd, iptr->dst.block);
+                                       emit_label(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LGT:
-                                       M_BGT(0);
+                                       emit_bgt(cd, iptr->dst.block);
+                                       emit_label(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LGE:
-                                       M_BGE(0);
+                                       emit_bge(cd, iptr->dst.block);
+                                       emit_label(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LEQ:
-                                       M_BEQ(0);
+                                       emit_beq(cd, iptr->dst.block);
+                                       emit_label(cd, LABEL_OUT);
                                        break;
                                case ICMD_IF_LNE:
-                                       M_BNE(0);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                                default:
                                        assert(0);
-                               }
-                               codegen_addreference(cd, iptr->dst.block);
-
-                               if (out_ref != NULL) {
-                                       *(u4 *)out_ref |= (u4)(cd->mcodeptr - out_ref) / 2;
-                               }
-
                        }
+
+#                      undef LABEL_OUT
                        break;
 
                case ICMD_IF_ACMPEQ:    /* ..., value, value ==> ...                  */
@@ -2215,17 +2255,15 @@ bool codegen(jitdata *jd)
 
                        switch (iptr->opc) {
                                case ICMD_IF_ACMPEQ:
-                                       M_BEQ(0);
+                                       emit_beq(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_ACMPNE:
-                                       M_BNE(0);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                        }
 
-                       codegen_add_branch_ref(cd, iptr->dst.block);
                        break;
 
-
                case ICMD_IF_ICMPEQ:    /* ..., value, value ==> ...                  */
                case ICMD_IF_ICMPNE:    /* ..., value, value ==> ...                  */
                case ICMD_IF_ICMPLT:    /* ..., value, value ==> ...                  */
@@ -2238,25 +2276,24 @@ bool codegen(jitdata *jd)
                        M_CMP(s1, s2);
                        switch (iptr->opc) {
                                case ICMD_IF_ICMPEQ:
-                                       M_BEQ(0);
+                                       emit_beq(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_ICMPNE:
-                                       M_BNE(0);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_ICMPLT:
-                                       M_BLT(0);
+                                       emit_blt(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_ICMPGT:
-                                       M_BGT(0);
+                                       emit_bgt(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_ICMPLE:
-                                       M_BLE(0);
+                                       emit_ble(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_ICMPGE:
-                                       M_BGE(0);
+                                       emit_bge(cd, iptr->dst.block);
                                        break;
                        }
-                       codegen_add_branch_ref(cd, iptr->dst.block);
 
                        break;
 
@@ -2280,16 +2317,14 @@ bool codegen(jitdata *jd)
                                switch(iptr->opc) {
                                case ICMD_IF_LCMPLT:
                                case ICMD_IF_LCMPLE:
-                                       M_BLT(0);
-                                       codegen_addreference(cd, iptr->dst.block);
+                                       emit_blt(cd, iptr->dst.block);
                                        /* EQ ... fall through */
                                        out_ref = cd->mcodeptr;
                                        M_BGT(0);
                                        break;
                                case ICMD_IF_LCMPGT:
                                case ICMD_IF_LCMPGE:
-                                       M_BGT(0);
-                                       codegen_addreference(cd, iptr->dst.block);
+                                       emit_bgt(cd, iptr->dst.block);
                                        /* EQ ... fall through */
                                        out_ref = cd->mcodeptr;
                                        M_BLT(0);
@@ -2301,8 +2336,7 @@ bool codegen(jitdata *jd)
                                        break;
                                case ICMD_IF_LCMPNE:
                                        /* EQ ... fall through */
-                                       M_BNE(0);
-                                       codegen_addreference(cd, iptr->dst.block);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                                default:
                                        assert(0);
@@ -2315,28 +2349,27 @@ bool codegen(jitdata *jd)
 
                                switch(iptr->opc) {
                                case ICMD_IF_LCMPLT:
-                                       M_BLT(0);
+                                       emit_blt(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_LCMPLE:
-                                       M_BLE(0);
+                                       emit_ble(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_LCMPGT:
-                                       M_BGT(0);
+                                       emit_bgt(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_LCMPGE:
-                                       M_BGE(0);
+                                       emit_bge(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_LCMPEQ:
-                                       M_BEQ(0);
+                                       emit_beq(cd, iptr->dst.block);
                                        break;
                                case ICMD_IF_LCMPNE:
-                                       M_BNE(0);
+                                       emit_bne(cd, iptr->dst.block);
                                        break;
                                default:
                                        assert(0);
                                }
 
-                               codegen_addreference(cd, iptr->dst.block);
 
                                if (out_ref != NULL) {
                                        *(u4 *)out_ref |= (u4)(cd->mcodeptr - out_ref) / 2;
@@ -2401,9 +2434,6 @@ nowperformreturn:
 
 #if defined(ENABLE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
-                               disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
-                               M_ALD(REG_ITMP3, REG_PV, disp);
-                               M_CALL(REG_ITMP3);
 
                                /* we need to save the proper return value */
 
@@ -2424,7 +2454,13 @@ nowperformreturn:
                                }
 
                                M_ALD(REG_A0, REG_SP, rd->memuse * 4);
-                               M_JSR;
+
+                               disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
+                               M_ALD(REG_ITMP3, REG_PV, disp);
+
+                               M_ASUB_IMM(96, REG_SP);
+                               M_CALL(REG_ITMP3);
+                               M_AADD_IMM(96, REG_SP);
 
                                /* and now restore the proper return value */
 
@@ -2499,8 +2535,7 @@ nowperformreturn:
 
                                ICONST(REG_ITMP2, i);
                                M_ICMPU(REG_ITMP1, REG_ITMP2);
-                               M_BGE(0);
-                               codegen_add_branch_ref(cd, table[0].block);
+                               emit_bge(cd, table[0].block);
 
                                /* build jump table top down and use address of lowest entry */
 
@@ -2541,14 +2576,11 @@ nowperformreturn:
                                                ICONST(REG_ITMP2, lookup->value);
                                                M_ICMP(REG_ITMP2, s1);
                                        }
-                                       M_BEQ(0);
-                                       codegen_add_branch_ref(cd, lookup->target.block);
+                                       emit_beq(cd, lookup->target.block);
                                        lookup++;
                                }
 
-                               M_BR(0);
-                       
-                               codegen_add_branch_ref(cd, iptr->sx.s23.s3.lookupdefault.block);
+                               emit_br(cd, iptr->sx.s23.s3.lookupdefault.block);
                        }
                        break;
 
@@ -2595,14 +2627,14 @@ gen_method:
                                        if (!md->params[s3].inmemory) {
                                                if (IS_2_WORD_TYPE(var->type)) {
                                                        s1 = PACK_REGS(
-                                                               rd->argintregs[GET_LOW_REG(md->params[s3].regoff)],
-                                                               rd->argintregs[GET_HIGH_REG(md->params[s3].regoff)]
+                                                               GET_LOW_REG(md->params[s3].regoff),
+                                                               GET_HIGH_REG(md->params[s3].regoff)
                                                        );
                                                        d = emit_load(jd, iptr, var, s1);
                                                        M_LNGMOVE(d, s1);
                                                }
                                                else {
-                                                       s1 = rd->argintregs[md->params[s3].regoff];
+                                                       s1 = md->params[s3].regoff;
                                                        d = emit_load(jd, iptr, var, s1);
                                                        M_INTMOVE(d, s1);
                                                }
@@ -2620,7 +2652,7 @@ gen_method:
                                }
                                else {
                                        if (!md->params[s3].inmemory) {
-                                               s1 = rd->argfltregs[md->params[s3].regoff];
+                                               s1 = md->params[s3].regoff;
                                                d = emit_load(jd, iptr, var, s1);
                                                M_FLTMOVE(d, s1);
                                        }
@@ -2644,11 +2676,10 @@ gen_method:
                                break;
 
                        case ICMD_INVOKESPECIAL:
-                               if (checknull) {
-                                       gen_nullptr_check_intern(REG_A0);
-                               } else {
-                                       M_ILD(REG_ITMP1, REG_A0, 0); /* hardware nullptr   */
-                               }
+                               /* TODO softnull */
+                               /* Implicit NULL pointer check */
+                               M_ILD(REG_ITMP1, REG_A0, 0);
+
                                /* fall through */
 
                        case ICMD_INVOKESTATIC:
@@ -2666,7 +2697,7 @@ gen_method:
                                break;
 
                        case ICMD_INVOKEVIRTUAL:
-                               gen_nullptr_check(REG_A0);
+                               /* TODO softnull REG_A0 */
 
                                if (lm == NULL) {
                                        codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0);
@@ -2678,12 +2709,14 @@ gen_method:
                                                sizeof(methodptr) * lm->vftblindex;
                                }
 
+                               /* implicit null-pointer check */
+
                                M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_PV, REG_METHODPTR, s1);
                                break;
 
                        case ICMD_INVOKEINTERFACE:
-                               gen_nullptr_check(REG_A0);
+                               /* TODO softnull REG_A0 */
 
                                /* s1 will be negative here, so use (0xFFF + s1) as displacement
                                 * and -0xFFF in index register (itmp1)
@@ -2705,6 +2738,7 @@ gen_method:
                                        s2 = sizeof(methodptr) * (lm - lm->class->methods);
                                }
 
+                               /* Implicit null-pointer check */
                                M_ALD(REG_METHODPTR, REG_A0, OFFSET(java_objectheader, vftbl));
                                N_L(REG_METHODPTR, s1, REG_ITMP1, REG_METHODPTR);
                                M_ALD(REG_PV, REG_METHODPTR, s2);
@@ -2715,22 +2749,15 @@ gen_method:
 
                        M_CALL(REG_PV);
                        REPLACEMENT_POINT_INVOKE_RETURN(cd, iptr);
-                       N_BASR(REG_PV, RN);
-                       disp = (s4) (cd->mcodeptr - cd->mcodebase);
-                       M_ASUB_IMM(disp, REG_PV);
+                       emit_restore_pv(cd);
        
                        /* post call finalization */
 
-                       if (iptr->opc == ICMD_BUILTIN) {
-                               M_AADD_IMM(96, REG_SP); /* remove C abi register save area */
-                       }
-
-                       /* actually only used for ICMD_BUILTIN */
-
-                       if (INSTRUCTION_MUST_CHECK(iptr)) {
-                               M_TEST(REG_RESULT);
-                               M_BEQ(0);
-                               codegen_add_fillinstacktrace_ref(cd);
+                       switch (iptr->opc) {
+                               case ICMD_BUILTIN:
+                                       M_AADD_IMM(96, REG_SP); /* remove C abi register save area */
+                                       emit_exception_check(cd, iptr); /* check for exception */
+                                       break;
                        }
 
                        /* store return value */
@@ -2782,8 +2809,11 @@ gen_method:
                                vftbl_t   *supervftbl;
                                s4         superindex;
 
-                               u1        *class_label_refs[] = { 0 }, *class_label;
-                               u1        *exit_label_refs[] = { 0, 0, 0, 0 };
+#                              define LABEL_EXIT_CHECK_NULL BRANCH_LABEL_1
+#                              define LABEL_CLASS BRANCH_LABEL_2
+#                              define LABEL_EXIT_INTERFACE_NULL BRANCH_LABEL_3
+#                              define LABEL_EXIT_INTERFACE_DONE BRANCH_LABEL_4
+#                              define LABEL_EXIT_CLASS_NULL BRANCH_LABEL_5
 
                                if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                        super = NULL;
@@ -2805,8 +2835,7 @@ gen_method:
 
                                if (super == NULL) {
                                        M_TEST(s1);
-                                       exit_label_refs[0] = cd->mcodeptr;
-                                       M_BEQ(0);
+                                       emit_label_beq(cd, LABEL_EXIT_CHECK_NULL);
 
                                        disp = dseg_add_unique_s4(cd, 0);         /* super->flags */
 
@@ -2817,8 +2846,7 @@ gen_method:
                                        ICONST(REG_ITMP2, ACC_INTERFACE);
                                        ICONST(REG_ITMP3, disp); /* TODO negative displacement */
                                        N_N(REG_ITMP2, 0, REG_ITMP3, REG_PV);
-                                       class_label_refs[0] = cd->mcodeptr;
-                                       M_BEQ(0);
+                                       emit_label_beq(cd, LABEL_CLASS);
                                }
 
                                /* interface checkcast code */
@@ -2831,34 +2859,31 @@ gen_method:
                                                                                          0);
                                        } else {
                                                M_TEST(s1);
-                                               exit_label_refs[1] = cd->mcodeptr;
-                                               M_BEQ(0);
+                                               emit_label_beq(cd, LABEL_EXIT_INTERFACE_NULL);
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
                                        M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength));
                                        M_ISUB_IMM(superindex, REG_ITMP3);
-                                       M_BLE(0);
-                                       codegen_add_classcastexception_ref(cd, s1);
+                                       emit_classcast_check(cd, iptr, BRANCH_LE, RN, s1);
                                        N_AHI(
                                                REG_ITMP2,
                                                (s4) (OFFSET(vftbl_t, interfacetable[0]) -
                                                        superindex * sizeof(methodptr*))
                                        );
                                        M_ALD(REG_ITMP2, REG_ITMP2, 0);
-                                       M_TEST(REG_ITMP2);
-                                       M_BEQ(0);
-                                       codegen_add_classcastexception_ref(cd, s1);
+                                       emit_classcast_check(cd, iptr, BRANCH_EQ, REG_ITMP2, s1);
 
                                        if (super == NULL) {
-                                               exit_label_refs[2] = cd->mcodeptr;
-                                               M_BR(0);
+                                               emit_label_br(cd, LABEL_EXIT_INTERFACE_DONE);
                                        }
                                }
 
                                /* class checkcast code */
-
-                               class_label = cd->mcodeptr;
+                               
+                               if (super == NULL) {
+                                       emit_label(cd, LABEL_CLASS);
+                               }
 
                                if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
                                        if (super == NULL) {
@@ -2872,8 +2897,7 @@ gen_method:
                                        else {
                                                disp = dseg_add_address(cd, supervftbl);
                                                M_TEST(s1);
-                                               exit_label_refs[3] = cd->mcodeptr;
-                                               M_BEQ(0);
+                                               emit_label_beq(cd, LABEL_EXIT_CLASS_NULL);
                                        }
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
@@ -2882,15 +2906,6 @@ gen_method:
                                        codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
 #endif
                                        M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
-                                       /*                              if (s1 != REG_ITMP1) { */
-                                       /*                                      M_ILD(REG_ITMP1, REG_ITMP3, OFFSET(vftbl_t, baseval)); */
-                                       /*                                      M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); */
-                                       /*  #if defined(ENABLE_THREADS) */
-                                       /*                                      codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase); */
-                                       /*  #endif */
-                                       /*                                      M_ISUB(REG_ITMP2, REG_ITMP1, REG_ITMP2); */
-
-                                       /*                              } else { */
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, baseval));
                                        M_ISUB(REG_ITMP3, REG_ITMP2);
                                        M_ALD(REG_ITMP3, REG_PV, disp);
@@ -2898,27 +2913,29 @@ gen_method:
 #if defined(ENABLE_THREADS)
                                        codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
 #endif
-                                       /*                              } */
                                        M_CMPU(REG_ITMP2, REG_ITMP3); /* Unsigned compare */
                                        /* M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); itmp3 = (itmp2 <= itmp3) */
-                                       M_BGT(0); /* Branch if greater then */
                                        /* M_BEQZ(REG_ITMP3, 0); branch if (! itmp) -> branch if > */
-                                       codegen_add_classcastexception_ref(cd, s1);
-                               }
-
-                               /* resolve labels by adding the correct displacement */
-
-                               for (s2 = 0; s2 < sizeof(exit_label_refs) / sizeof(exit_label_refs[0]); ++s2) {
-                                       if (exit_label_refs[s2])
-                                               *(u4 *)exit_label_refs[s2] |= (u4)(cd->mcodeptr - exit_label_refs[s2]) / 2;
+                                       /* Branch if greater then */
+                                       emit_classcast_check(cd, iptr, BRANCH_GT, RN, s1);
                                }
 
-                               for (s2 = 0; s2 < sizeof(class_label_refs) / sizeof(class_label_refs[0]); ++s2) {
-                                       if (class_label_refs[s2])
-                                               *(u4 *)class_label_refs[s2] |= (u4)(class_label - class_label_refs[s2]) / 2;
+                               if (super == NULL) {
+                                       emit_label(cd, LABEL_EXIT_CHECK_NULL);
+                                       emit_label(cd, LABEL_EXIT_INTERFACE_DONE);
+                               } else if (super->flags & ACC_INTERFACE) {
+                                       emit_label(cd, LABEL_EXIT_INTERFACE_NULL);
+                               } else {
+                                       emit_label(cd, LABEL_EXIT_CLASS_NULL);
                                }
 
                                d = codegen_reg_of_dst(jd, iptr, s1);
+
+#                              undef LABEL_EXIT_CHECK_NULL
+#                              undef LABEL_CLASS
+#                              undef LABEL_EXIT_INTERFACE_NULL
+#                              undef LABEL_EXIT_INTERFACE_DONE
+#                              undef LABEL_EXIT_CLASS_NULL
                        }
                        else {
                                /* array type cast-check */
@@ -2945,9 +2962,7 @@ gen_method:
                                M_AADD_IMM(96, REG_SP);
 
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
-                               M_TEST(REG_RESULT);
-                               M_BEQ(0);
-                               codegen_add_classcastexception_ref(cd, s1);
+                               emit_classcast_check(cd, iptr, BRANCH_EQ, REG_RESULT, s1);
 
                                d = codegen_reg_of_dst(jd, iptr, s1);
                        }
@@ -2970,6 +2985,10 @@ gen_method:
                         *  return ((sub != NULL) && (0
                         *          <= (sub->vftbl->baseval - super->vftbl->baseval) <=
                         *          super->vftbl->diffvall));
+                        *
+                        *  If superclass is unresolved, we include both code snippets 
+                        *  above, a patcher resolves the class' flags and we select
+                        *  the right code at runtime.
                         */
 
                        {
@@ -2977,10 +2996,6 @@ gen_method:
                        vftbl_t   *supervftbl;
                        s4         superindex;
 
-                       u1        *class_label, *class_label_refs[1] = { 0 };
-                       u1        *exit_label_refs[4] = { 0, 0, 0, 0 };
-                       u1        *label1, *label1_refs[1] = { 0 };
-
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                super = NULL;
                                superindex = 0;
@@ -2992,10 +3007,17 @@ gen_method:
                                supervftbl = super->vftbl;
                        }
 
+#                      define LABEL_EXIT_CHECK_NULL BRANCH_LABEL_1
+#                      define LABEL_CLASS BRANCH_LABEL_2
+#                      define LABEL_EXIT_INTERFACE_NULL BRANCH_LABEL_3
+#                      define LABEL_EXIT_INTERFACE_INDEX_NOT_IN_TABLE BRANCH_LABEL_4
+#                      define LABEL_EXIT_INTERFACE_DONE BRANCH_LABEL_5
+#                      define LABEL_EXIT_CLASS_NULL BRANCH_LABEL_6
+
 #if defined(ENABLE_THREADS)
                        codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
 #endif
-                       s1 = emit_load_s1(jd, iptr, REG_ITMP1);
+                       s1 = emit_load_s1_notzero(jd, iptr, REG_ITMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
                        if (s1 == d) {
                                M_MOV(s1, REG_ITMP1);
@@ -3008,8 +3030,7 @@ gen_method:
                                M_CLR(d);
                                
                                M_TEST(s1);
-                               exit_label_refs[0] = cd->mcodeptr;
-                               M_BEQ(0);
+                               emit_label_beq(cd, LABEL_EXIT_CHECK_NULL);
 
                                disp = dseg_add_unique_s4(cd, 0);             /* super->flags */
 
@@ -3019,8 +3040,7 @@ gen_method:
                                ICONST(REG_ITMP2, ACC_INTERFACE);
                                ICONST(REG_ITMP3, disp); /* TODO negative displacement */
                                N_N(REG_ITMP2, 0, REG_ITMP3, REG_PV);
-                               class_label_refs[0] = cd->mcodeptr;
-                               M_BEQ(0);
+                               emit_label_beq(cd, LABEL_CLASS);
                        }
 
                        /* interface instanceof code */
@@ -3039,15 +3059,15 @@ gen_method:
                                else {
                                        M_CLR(d);
                                        M_TEST(s1);
-                                       exit_label_refs[1] = cd->mcodeptr;
-                                       M_BEQ(0);
+                                       emit_label_beq(cd, LABEL_EXIT_INTERFACE_NULL);
                                }
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ILD(REG_ITMP3, REG_ITMP1, OFFSET(vftbl_t, interfacetablelength));
                                M_ISUB_IMM(superindex, REG_ITMP3);
-                               label1_refs[0] = cd->mcodeptr;
-                               M_BLE(0); 
+
+                               emit_label_ble(cd, LABEL_EXIT_INTERFACE_INDEX_NOT_IN_TABLE);
+
                                N_AHI(
                                        REG_ITMP1,
                                        (s4) (OFFSET(vftbl_t, interfacetable[0]) -
@@ -3061,17 +3081,16 @@ gen_method:
                                M_BEQ(SZ_BRC + SZ_LHI);
                                N_LHI(d, 1);
 
-                               label1 = cd->mcodeptr;
-
                                if (super == NULL) {
-                                       exit_label_refs[2] = cd->mcodeptr;
-                                       M_BR(0);
+                                       emit_label_br(cd, LABEL_EXIT_INTERFACE_DONE);
                                }
                        }
 
                        /* class instanceof code */
 
-                       class_label = cd->mcodeptr;
+                       if (super == NULL) {
+                               emit_label(cd, LABEL_CLASS);
+                       }
 
                        if ((super == NULL) || !(super->flags & ACC_INTERFACE)) {
                                if (super == NULL) {
@@ -3087,8 +3106,7 @@ gen_method:
                                        M_CLR(d);
 
                                        M_TEST(s1);
-                                       exit_label_refs[3] = cd->mcodeptr;
-                                       M_BEQ(0);
+                                       emit_label_beq(cd, LABEL_EXIT_CLASS_NULL);
                                }
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
@@ -3110,23 +3128,24 @@ gen_method:
                                N_LHI(d, 1);
                        }
 
-                       /* resolve labels by adding the correct displacement */
-
-                       for (s2 = 0; s2 < sizeof(exit_label_refs) / sizeof(exit_label_refs[0]); ++s2) {
-                               if (exit_label_refs[s2])
-                                       *(u4 *)exit_label_refs[s2] |= (u4)(cd->mcodeptr - exit_label_refs[s2]) / 2;
-                       }
-
-                       for (s2 = 0; s2 < sizeof(class_label_refs) / sizeof(class_label_refs[0]); ++s2) {
-                               if (class_label_refs[s2])
-                                       *(u4 *)class_label_refs[s2] |= (u4)(class_label - class_label_refs[s2]) / 2;
-                       }
-
-                       for (s2 = 0; s2 < sizeof(label1_refs) / sizeof(label1_refs[0]); ++s2) {
-                               if (label1_refs[s2])
-                                       *(u4 *)label1_refs[s2] |= (u4)(label1 - label1_refs[s2]) / 2;
+                       if (super == NULL) {
+                               emit_label(cd, LABEL_EXIT_CHECK_NULL);
+                               emit_label(cd, LABEL_EXIT_INTERFACE_DONE);
+                               emit_label(cd, LABEL_EXIT_INTERFACE_INDEX_NOT_IN_TABLE);
+                       } else if (super->flags & ACC_INTERFACE) {
+                               emit_label(cd, LABEL_EXIT_INTERFACE_NULL);
+                               emit_label(cd, LABEL_EXIT_INTERFACE_INDEX_NOT_IN_TABLE);
+                       } else {
+                               emit_label(cd, LABEL_EXIT_CLASS_NULL);
                        }
 
+#                      undef LABEL_EXIT_CHECK_NULL
+#                      undef LABEL_CLASS
+#                      undef LABEL_EXIT_INTERFACE_NULL
+#                      undef LABEL_EXIT_INTERFACE_INDEX_NOT_IN_TABLE
+#                      undef LABEL_EXIT_INTERFACE_DONE
+#                      undef LABEL_EXIT_CLASS_NULL
+                               
                        emit_store_dst(jd, iptr, d);
 
                        }
@@ -3184,9 +3203,7 @@ gen_method:
 
                        /* check for exception before result assignment */
 
-                       M_TEST(REG_RESULT);
-                       M_BEQ(0);
-                       codegen_add_fillinstacktrace_ref(cd);
+                       emit_exception_check(cd, iptr);
 
                        s1 = codegen_reg_of_dst(jd, iptr, REG_RESULT);
                        M_INTMOVE(REG_RESULT, s1);
@@ -3221,14 +3238,11 @@ gen_method:
 
        /* generate stubs */
 
-       emit_exception_stubs(jd);
        emit_patcher_stubs(jd);
 #if 0
        emit_replacement_stubs(jd);
 #endif
 
-       codegen_finish(jd);
-
        /* everything's ok */
 
        return true;
@@ -3383,20 +3397,21 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        for (i = 0; i < md->paramcount; i++) {
                if (! md->params[i].inmemory) {
                        s1 = md->params[i].regoff;
+                       t = md->paramtypes[i].type;
 
-                       if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
+                       if (IS_INT_LNG_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
                                        /* todo store multiple */
-                                       N_ST(rd->argintregs[GET_HIGH_REG(s1)], j, RN, REG_SP);
-                                       N_ST(rd->argintregs[GET_LOW_REG(s1)], j + 4, RN, REG_SP);
+                                       N_ST(GET_HIGH_REG(s1), j, RN, REG_SP);
+                                       N_ST(GET_LOW_REG(s1), j + 4, RN, REG_SP);
                                } else {
-                                       N_ST(rd->argintregs[s1], j, RN, REG_SP);
+                                       N_ST(s1, j, RN, REG_SP);
                                }
                        } else {
                                if (IS_2_WORD_TYPE(t)) {
-                                       N_STD(rd->argfltregs[s1], j, RN, REG_SP);
+                                       N_STD(s1, j, RN, REG_SP);
                                } else {
-                                       N_STE(rd->argfltregs[s1], j, RN, REG_SP);
+                                       N_STE(s1, j, RN, REG_SP);
                                }
                        }
 
@@ -3425,20 +3440,21 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        for (i = 0; i < md->paramcount; i++) {
                if (! md->params[i].inmemory) {
                        s1 = md->params[i].regoff;
+                       t = md->paramtypes[i].type;
 
-                       if (IS_INT_LNG_TYPE(md->paramtypes[i].type)) {
+                       if (IS_INT_LNG_TYPE(t)) {
                                if (IS_2_WORD_TYPE(t)) {
                                        /* todo load multiple ! */
-                                       N_L(rd->argintregs[GET_HIGH_REG(s1)], j, RN, REG_SP);
-                                       N_L(rd->argintregs[GET_LOW_REG(s1)], j + 4, RN, REG_SP);
+                                       N_L(GET_HIGH_REG(s1), j, RN, REG_SP);
+                                       N_L(GET_LOW_REG(s1), j + 4, RN, REG_SP);
                                } else {
-                                       N_L(rd->argintregs[s1], j, RN, REG_SP);
+                                       N_L(s1, j, RN, REG_SP);
                                }
                        } else {
                                if (IS_2_WORD_TYPE(t)) {
-                                       N_LD(rd->argfltregs[s1], j, RN, REG_SP);
+                                       N_LD(s1, j, RN, REG_SP);
                                } else {
-                                       N_LE(rd->argfltregs[s1], j, RN, REG_SP);
+                                       N_LE(s1, j, RN, REG_SP);
                                }
                        }
 
@@ -3457,33 +3473,49 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
 
                        if (!md->params[i].inmemory) {
 
-                               s1 = rd->argintregs[md->params[i].regoff];
+                               s1 = md->params[i].regoff;
 
                                if (!nmd->params[j].inmemory) {
-                                       s2 = rd->argintregs[nmd->params[j].regoff];
+                                       s2 = nmd->params[j].regoff;
                                        if (IS_2_WORD_TYPE(t)) {
-                                               N_LR(GET_HIGH_REG(s2), GET_HIGH_REG(s1));
-                                               N_LR(GET_LOW_REG(s2), GET_LOW_REG(s1));
+                                               N_LR(
+                                                       GET_LOW_REG(s2), 
+                                                       GET_LOW_REG(s1)
+                                               );
+                                               N_LR(
+                                                       GET_HIGH_REG(s2), 
+                                                       GET_HIGH_REG(s1)
+                                               );
                                        } else {
-                                               N_LR(s2, s1);
+                                               N_LR(
+                                                       s2, 
+                                                       s1
+                                               );
                                        }
                                } else {
                                        s2 = nmd->params[j].regoff;
                                        if (IS_2_WORD_TYPE(t)) {
-                                               N_STM(GET_LOW_REG(s1), GET_HIGH_REG(s1), 96 + (s2 * 4), REG_SP);
+                                               N_STM(
+                                                       GET_HIGH_REG(s1), 
+                                                       GET_LOW_REG(s1), 
+                                                       96 + (s2 * 4), REG_SP
+                                               );
                                        } else {
-                                               N_ST(s1, 96 + (s2 * 4), RN, REG_SP);
+                                               N_ST(
+                                                       s1, 
+                                                       96 + (s2 * 4), RN, REG_SP
+                                               );
                                        }
                                }
 
                        } else {
-                               s1 = md->params[i].regoff + cd->stackframesize + 1;   /* + 1 (RA) */
+                               s1 = cd->stackframesize + md->params[i].regoff;
                                s2 = nmd->params[j].regoff;
                                
                                if (IS_2_WORD_TYPE(t)) {
-                                       N_MVC(96 + (s2 * 4), 8, REG_SP, s1, REG_SP);
+                                       N_MVC(96 + (s2 * 4), 8, REG_SP, (s1 * 4), REG_SP);
                                } else {
-                                       N_MVC(96 + (s2 * 4), 4, REG_SP, s1, REG_SP);
+                                       N_MVC(96 + (s2 * 4), 4, REG_SP, (s1 * 4), REG_SP);
                                }
                        }
 
@@ -3492,13 +3524,13 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                        /* registers keep unchanged.                                      */
 
                        if (md->params[i].inmemory) {
-                               s1 = md->params[i].regoff + cd->stackframesize + 1;   /* + 1 (RA) */
+                               s1 = cd->stackframesize + md->params[i].regoff;
                                s2 = nmd->params[j].regoff;
 
                                if (IS_2_WORD_TYPE(t)) {
-                                       N_MVC(96 + (s2 * 4), 8, REG_SP, s1, REG_SP);
+                                       N_MVC(96 + (s2 * 4), 8, REG_SP, (s1 * 4), REG_SP);
                                } else {
-                                       N_MVC(96 + (s2 * 4), 4, REG_SP, s1, REG_SP);
+                                       N_MVC(96 + (s2 * 4), 4, REG_SP, (s1 * 4), REG_SP);
                                }
                        }
                }
index 8e4fa4ed3605296328856483fa20cb2e50a0b368..5d01e252eb97a281bc0ede0a10f0b610c239fbfb 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.h 7691 2007-04-12 12:45:10Z twisti $
+   $Id: codegen.h 7848 2007-05-01 21:40:26Z pm $
 
 */
 
 #include "vm/jit/jit.h"
 
 
-/* additional functions and macros to generate code ***************************/
-
-#define CALCOFFSETBYTES(var, reg, val) \
-    if ((s4) (val) < -128 || (s4) (val) > 127) (var) += 4; \
-    else if ((s4) (val) != 0) (var) += 1; \
-    else if ((reg) == RBP || (reg) == RSP || (reg) == R12 || (reg) == R13) (var) += 1;
-
-
-#define CALCIMMEDIATEBYTES(var, val) \
-    if ((s4) (val) < -128 || (s4) (val) > 127) (var) += 4; \
-    else (var) += 1;
-
-
-#define gen_nullptr_check_intern(objreg) \
-       do { \
-               M_TEST(objreg); \
-               M_BEQ(0); \
-               codegen_add_nullpointerexception_ref(cd); \
-       } while (0);
-
-#define gen_nullptr_check(objreg) \
-       if (checknull) { \
-               gen_nullptr_check_intern(objreg); \
-       }
-
-
-#define gen_bound_check \
-    if (checkbounds) { \
-        M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\
-        M_ICMP(REG_ITMP3, s2); \
-        M_BAE(0); \
-        codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \
-    }
-
-
 /* MCODECHECK(icnt) */
 
 #define MCODECHECK(icnt) \
             codegen_increase(cd); \
     } while (0)
 
-
 #define ALIGNCODENOP \
     if ((s4) (((ptrint) cd->mcodeptr) & 7)) { \
         M_NOP; \
     }
 
-
-
-/* branch defines *************************************************************/
-
-#define BRANCH_NOPS \
-    do { \
-        M_NOP; \
-    } while (0)
-
-
 /* some patcher defines *******************************************************/
 
 #define PATCHER_CALL_SIZE    4          /* size in bytes of a patcher call    */
 #define PATCHER_NOPS \
     do { \
         M_NOP; \
-               M_NOP; \ 
+               M_NOP; \
                M_NOP; \
     } while (0)
 
 #define PATCHER_NOPS_SKIP   12 
 
+/* branch defines ************************************************************/
 
- /* stub defines **************************************************************/
+#define BRANCH_NOPS M_NOP /* Size of at least M_BRC */
 
-#define COMPILERSTUB_CODESIZE    (SZ_AHI + SZ_L + SZ_L + SZ_BCR)
+/* stub defines **************************************************************/
 
+#define COMPILERSTUB_CODESIZE    (SZ_AHI + SZ_L + SZ_L + SZ_BCR)
 
 /* *** BIG TODO ***
  * Make all this inline functions !!!!!!!!!!
 #define SZ_RX 4
 
 #define N_RI(op1, op2, r1, i2) \
-       _CODE4( (_OP(op1) << 24) | (_R(r1) << 20) | (_OP4(op2) << 16) | (u2)_I16(i2) )
+       _CODE4( (_OP(op1) << 24) | (_R(r1) << 20) | (_OP4(op2) << 16) | (u2)_SI16(i2) )
+
+#define N_RI2(op1, op2, r1, i2) \
+       _CODE4( (_OP(op1) << 24) | (_R(r1) << 20) | (_OP4(op2) << 16) | (u2)_UI16(i2) )
 
 #define SZ_RI 4
 
 
 /* Misc */
 
-#define N_LONG_0() _CODE4(0)
+/* Trap instruction.
+ * If most significant bits of first opcode byte are 00, then
+ * format is RR (1 byte opcode) or E (2 bytes opcode). 
+ * There seems to be no opcode 0x02 or 0x02**, so we'll define
+ * our trap instruction as:
+ * +--------+--------+
+ * |  0x02  |  data  |
+ * +--------+--------+
+ * 0                 15
+ */
+#define N_ILL(data) _CODE2(0x0200 | _UBITS(data, 8))
+#define SZ_ILL 2
+
+#define N_LONG(l) _CODE4(l)
+#define SZ_LONG 4
 
 /* Chapter 7. General instructions */
 
 #      define SZ_NR SZ_RR
 #define N_N(r1, d2, x2, b2) N_RX(0x54, r1, d2, x2, b2)
 #define N_NI(d1, b1, i2) N_SI(0x94, d1, b1, i2)
-#define N_NC(d1, l, b1, d2, b2) N_NC(0xD4, l, b1, d1, b2, d2)
+#define N_NC(d1, l, b1, d2, b2) N_SS(0xD4, (l - 1), b1, d1, b2, d2)
 #define N_BALR(r1, r2) N_RR(0x05, r1, _OR(r2))
 #define N_BAL(r1, d2, x2, b2) N_RX(0x45, r1, d2, x2, b2)
 #define N_BASR(r1, r2) N_RR(0x0D, r1, _OR(r2))
+#      define SZ_BASR SZ_RR
 #define N_BAS(r1, d2, x2, b2) N_RX(0x4D, r1, d2, x2, b2)
 #define N_BASSM(r1, r2) N_RR(0x0C, r1, _OR(r2))
 #define N_BSM(r1, r2) N_RR(0x0B, r1, _OR(r2))
 #define N_CLR(r1, r2) N_RR(0x15, r1, r2)
 #define N_CL(r1, d2, x2, b2) N_RX(0x55, r1, d2, x2, b2)
 #define N_CLI(d1, b1, i2) N_SI(0x95, d1, b1, i2)
-#define N_CLC(d1, l, b1, d2, b2) N_SS(0xD5, d1, l, b1, d2, b2)
+#define N_CLC(d1, l, b1, d2, b2) N_SS(0xD5, d1, (l - 1), b1, d2, b2)
 #define N_CLM(r1, m3, d2, b2) N_RS(0xBD, r1, m3, d2, b2)
 #define N_CLCL(r1, r2) N_RR(0x0F, r1, r2)
 #define N_CLCLE(r1, r3, d2, b2) N_RS(0xA9, r1, r3, d2, b2)
 #define N_XR(r1, r2) N_RR(0x17, r1, r2)
 #define N_X(r1, d2, x2, b2) N_RX(0x57, r1, d2, x2, b2)
 #define N_XI(d1, b1, i2) N_SI(0x97, d1, b1, i2)
-#define N_XC(d1, l, b1, d2, b2) N_SS(0xD7, d1, l, b1, d2, b2)
+#define N_XC(d1, l, b1, d2, b2) N_SS(0xD7, d1, (l - 1), b1, d2, b2)
 #define N_EX(r1, d2, x2, b2) N_RX(0x44, r1, d2, x2, b2)
 #define N_EAR(r1, r2) N_RRE(0xB24F, r1, r2)
 #define N_IC(r1, d2, x2, b2) N_RX(0x43, r1, d2, x2, b2)
 #define N_LPR(r1, r2) N_RR(0x10, r1, r2)
 #define N_MC(d1, b1, i2) N_SI(0xAF, d1, b1, i2)
 #define N_MVI(d1, b1, i2) N_SI(0x92, d1, b1, i2)
-#define N_MVC(d1, l, b1, d2, b2) N_SS(0xD2, d1, l, b1, d2, b2)
-#define N_MVCIN(d1, l, b1, d2, b2) N_SS(0xEB, d1, l, b1, d2, b2)
+#define N_MVC(d1, l, b1, d2, b2) N_SS(0xD2, d1, (l - 1), b1, d2, b2)
+#define N_MVCIN(d1, l, b1, d2, b2) N_SS(0xEB, d1, (l - 1), b1, d2, b2)
 #define N_MVCL(r1, r2) N_RR(0x0E, r1, r2)
 #define N_MVCLE(r1, r3, d2, b2)  N_RS(0xAB, r1, r3, d2, b2)
-#define N_MVN(d1, l, b1, d2, b2) N_SS(0xD1, d1, l, b1, d2, b2)
+#define N_MVN(d1, l, b1, d2, b2) N_SS(0xD1, d1, (l - 1), b1, d2, b2)
 #define N_MVPG(r1, r2) N_RRE(0xB254, r1, r2)
 #define N_MVST(r1, r2) N_RRE(0xB255, r1, r2)
-#define N_MVO(d1, l1, b1, d2, l2, b2) N_SS2(0xF1, d1, l1, b1, d2, l2, b2)
-#define N_MVZ(d1, l, b1, d2, b2) N_SS(0xD3, d1, l, b1, d2, b2)
+#define N_MVO(d1, l1, b1, d2, l2, b2) N_SS2(0xF1, d1, (l1 - 1), b1, d2, (l2 - 1), b2)
+#define N_MVZ(d1, l, b1, d2, b2) N_SS(0xD3, d1, (l - 1), b1, d2, b2)
 #define N_MR(r1, r2) N_RR(0x1C, r1, r2)
 #define N_M(r1, d2, x2, b2) N_RX(0x5C, r1, d2, x2, b2)
 #define N_MH(r1, d2, x2, b2) N_RX(0x4C, r1, d2, x2, b2)
 #define N_OR(r1, r2) N_RR(0x16, r1, r2)
 #define N_O(r1, d2, x2, b2) N_RX(0x56, r1, d2, x2, b2)
 #define N_OI(d1, b1, i2) N_SI(0x96, d1, b1, i2)
-#define N_OC(d1, l, b1, d2, b2) N_SS(0xD6, d1, l, b1, d2, b2)
-#define N_PACK(d1, l1, b1, d2, l2, b2) N_SS2(0xF2, d1, l1, b1, d2, l2, b2)
+#define N_OC(d1, l, b1, d2, b2) N_SS(0xD6, d1, (l - 1), b1, d2, b2)
+#define N_PACK(d1, l1, b1, d2, l2, b2) N_SS2(0xF2, d1, (l1 - 1), b1, d2, (l2 - 1), b2)
 #define N_PLO(r1, d2, b2, r3, d4, b4) N_SS2(0xEE, d2, r1, b2, d4, r3, b4)
 #define N_SRST(r1, r2) N_RRE(0xB25E, r1, r2)
 #define N_SAR(r1, r2) N_RRE(0xB24E, r1, r2)
 #define N_SVC(i) N_RR2(0x0A, i)
 #define N_TS(d2, b2) N_S2(0x93, d2, b2)
 #define N_TM(d1, b1, i2) N_SI(0x91, d1, b1, i2)
-#define N_TMH(r1, i2) N_RI(0xA7, 0x00, r1, i2)
-#define N_TML(r1, i2) N_RI(0xA7, 0x01, r1, i2)
-#define N_TR(d1, l, b1, d2, b2) N_SS(0xDC, d1, l, b1, d2, b2)
-#define N_TRT(d1, l, b1, d2, b2) N_SS(0xDD, d1, l, b1, d2, b2)
+#define N_TMH(r1, i2) N_RI2(0xA7, 0x00, r1, i2)
+#define N_TML(r1, i2) N_RI2(0xA7, 0x01, r1, i2)
+#define N_TR(d1, l, b1, d2, b2) N_SS(0xDC, d1, (l - 1), b1, d2, b2)
+#define N_TRT(d1, l, b1, d2, b2) N_SS(0xDD, d1, (l - 1), b1, d2, b2)
 #define N_TRE(r1, r2) N_RRE(0xB2A5, r1, r2)
-#define N_UNPK(d1, l1, b1, d2, l2, b2) N_SS2(0xF3, d1, l1, b1, d2, l2, b2)
+#define N_UNPK(d1, l1, b1, d2, l2, b2) N_SS2(0xF3, d1, (l1 - 1), b1, d2, (l2 - 2), b2)
 #define N_UPT() N_E(0x0102)
 
 /* Chapter 9. Floating point instructions */
 /* Alpha like instructions */
 
 #define M_CALL(r2) N_BASR(R14, r2)
+#define M_ILL(data) N_ILL(data)
+#define M_ILL2(data1, data2) N_ILL((_UBITS(data1, 4) << 4) | _UBITS(data2, 4))
+#define M_LONG(l) N_LONG(l)
 
 #define M_ILD(r, b, d) \
        do { \
 #define M_CVTDI(src, dst) N_CFDBR(dst, 5, src)
 #define M_IADD(a, dest) N_AR(dest, a)
 #define M_ISUB(a, dest) N_SR(dest, a)
+#define M_ASUB(a, dest) N_SR(dest, a)
 #define M_IAND(a, dest) N_NR(dest, a)
 #define M_IOR(a, dest) N_OR(dest, a)
 #define M_IXOR(a, dest) N_XR(dest, a)
         } \
     } while (0)
 
+#define M_ISUB_IMM32(imm, tmpreg, reg) \
+       do { \
+               if (N_VALID_IMM(imm)) { \
+                       M_ISUB_IMM(imm, reg); \
+               } else { \
+                       ICONST(tmpreg, imm); \
+                       M_ISUB(tmpreg, reg); \
+               } \
+       } while (0)
+
+#define M_ASUB_IMM32(imm, tmpreg, reg) M_ISUB_IMM32(imm, tmpreg, reg)
+
 /* ----------------------------------------------- */
 
 #define _DEPR(x) \
 #define M_JMP_IMM(a) _DEPR( M_JMP_IMM(a) )
 #define M_CALL_IMM(a) _DEPR( M_CALL_IMM(a) )
 
-
-
-
 #define M_FLD32(a,b,disp) _DEPR( M_FLD32(a,b,disp) )
 #define M_DLD32(a,b,disp) _DEPR( M_DLD32(a,b,disp) )
 
-
 #define M_FST32(a,b,disp) _DEPR( M_FST32(a,b,disp) )
 #define M_DST32(a,b,disp) _DEPR( M_DST32(a,b,disp) )
 
 #define PROFILE_CYCLE_STOP 
 #define __PROFILE_CYCLE_STOP _DEPR( __PROFILE_CYCLE_STOP )
 
-
-/* function gen_resolvebranch **************************************************
-
-    backpatches a branch instruction
-
-    parameters: ip ... pointer to instruction after branch (void*)
-                so ... offset of instruction after branch  (s8)
-                to ... offset of branch target             (s8)
-
-*******************************************************************************/
-
-#define gen_resolvebranch(ip,so,to) \
-    *((s4*) ((ip) - 4)) = (s4) ((to) - (so));
-
 #endif /* _CODEGEN_H */
 
 
 s4 codegen_reg_of_dst_notzero(jitdata *jd, instruction *iptr, s4 tempregnum);
 
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
index 4077fe5251da3a57c2b10f8eb66698ca89ddbf07..234ad92786940c5b309d6d431e2365fac75da4a4 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: disass.c 7219 2007-01-16 22:18:57Z pm $
+   $Id: disass.c 7848 2007-05-01 21:40:26Z pm $
 
 */
 
@@ -69,6 +69,30 @@ char *regs[] = {
 };
 
 
+/* disass_pseudo_instr *********************************************************
+
+   Outputs a disassembler listing of one pseudo instruction instruction on
+   `stdout'.
+       
+   Returns number of bytes consumed or 0 if code does not contain a pseudo 
+   instruction.
+
+   code: pointer to machine code
+
+*******************************************************************************/
+
+static s4 disass_pseudo_instr(u1 *code) {
+       switch (code[0]) {
+               /* Trap */
+               case 0x02:
+                       snprintf(disass_buf, 512, "ill\t0x%02hhx (pseudo)", code[1]);
+                       return 2;
+               /* Not recognized */
+               default:
+                       return 0;
+       }
+}
+
 /* disassinstr *****************************************************************
 
    Outputs a disassembler listing of one machine code instruction on
@@ -99,7 +123,11 @@ u1 *disassinstr(u1 *code)
 
        disass_len = 0;
 
-       seqlen = print_insn_s390((bfd_vma) code, &info);
+       seqlen = disass_pseudo_instr(code);
+
+       if (seqlen == 0) {
+               seqlen = print_insn_s390((bfd_vma) code, &info);
+       }
 
        for (i = 0; i < seqlen; i++, code++) {
                printf("%02x ", *code);
index 0f88e31a8997f7b726ab32c8ab68d45d3bbf398d..ff0b786a875a2ea52eb293cba7a7e8540685a3b7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: emit.c 7848 2007-05-01 21:40:26Z pm $
 
 */
 
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/replace.h"
+#include "vm/jit/abi.h"
 #include "vm/global.h"
 #include "mm/memory.h"
+#include "vm/exceptions.h"
 
 #define __PORTED__
 
@@ -168,25 +170,40 @@ __PORTED__ void emit_copy(jitdata *jd, instruction *iptr)
                   order of getting the destination register and the load. */
 
                if (IS_INMEMORY(src->flags)) {
-                       if (IS_FLT_DBL_TYPE(dst->type))
+                       if (IS_FLT_DBL_TYPE(dst->type)) {
                                d = codegen_reg_of_var(iptr->opc, dst, REG_FTMP1);
-                       else
-                               d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP1);
+                       } else {
+                               if (IS_2_WORD_TYPE(dst->type)) {
+                                       d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP12_PACKED);
+                               } else {
+                                       d = codegen_reg_of_var(iptr->opc, dst, REG_ITMP1);
+                               }
+                       }
                        s1 = emit_load(jd, iptr, src, d);
                }
                else {
-                       if (IS_FLT_DBL_TYPE(src->type))
+                       if (IS_FLT_DBL_TYPE(src->type)) {
                                s1 = emit_load(jd, iptr, src, REG_FTMP1);
-                       else
-                               s1 = emit_load(jd, iptr, src, REG_ITMP1);
+                       } else {
+                               if (IS_2_WORD_TYPE(src->type)) {
+                                       s1 = emit_load(jd, iptr, src, REG_ITMP12_PACKED);
+                               } else {
+                                       s1 = emit_load(jd, iptr, src, REG_ITMP1);
+                               }
+                       }
                        d = codegen_reg_of_var(iptr->opc, dst, s1);
                }
 
                if (s1 != d) {
-                       if (IS_FLT_DBL_TYPE(src->type))
+                       if (IS_FLT_DBL_TYPE(src->type)) {
                                M_FMOV(s1, d);
-                       else
-                               M_MOV(s1, d);
+                       } else {
+                               if (IS_2_WORD_TYPE(src->type)) {
+                                       M_LNGMOVE(s1, d);
+                               } else {
+                                       M_MOV(s1, d);
+                               }
+                       }
                }
 
                emit_store(jd, iptr, dst, d);
@@ -194,126 +211,6 @@ __PORTED__ void emit_copy(jitdata *jd, instruction *iptr)
 }
 
 
-void emit_cmovxx(codegendata *cd, instruction *iptr, s4 s, s4 d)
-{
-#if 0
-       switch (iptr->flags.fields.condition) {
-       case ICMD_IFEQ:
-               M_CMOVEQ(s, d);
-               break;
-       case ICMD_IFNE:
-               M_CMOVNE(s, d);
-               break;
-       case ICMD_IFLT:
-               M_CMOVLT(s, d);
-               break;
-       case ICMD_IFGE:
-               M_CMOVGE(s, d);
-               break;
-       case ICMD_IFGT:
-               M_CMOVGT(s, d);
-               break;
-       case ICMD_IFLE:
-               M_CMOVLE(s, d);
-               break;
-       }
-#endif
-}
-
-
-/* emit_exception_stubs ********************************************************
-
-   Generates the code for the exception stubs.
-
-*******************************************************************************/
-
-__PORTED__ void emit_exception_stubs(jitdata *jd)
-{
-       codegendata  *cd;
-       registerdata *rd;
-       exceptionref *er;
-       s4            branchmpc;
-       s4            targetmpc;
-       s4            targetdisp;
-       s4            disp;
-
-       /* get required compiler data */
-
-       cd = jd->cd;
-       rd = jd->rd;
-
-       /* generate exception stubs */
-
-       targetdisp = 0;
-
-       for (er = cd->exceptionrefs; er != NULL; er = er->next) {
-               /* back-patch the branch to this exception code */
-
-               branchmpc = er->branchpos;
-               targetmpc = cd->mcodeptr - cd->mcodebase;
-
-               md_codegen_patch_branch(cd, branchmpc, targetmpc);
-
-               MCODECHECK(512);
-
-               /* move index register into REG_ITMP1 */
-
-               /* Check if the exception is an
-                  ArrayIndexOutOfBoundsException.  If so, move index register
-                  into a4. */
-
-               if (er->reg != -1)
-                       M_MOV(er->reg, rd->argintregs[4]);
-
-               /* calcuate exception address */
-
-               if (N_VALID_DISP(er->branchpos - 4)) {
-                       M_LDA(rd->argintregs[3], REG_PV, er->branchpos - 4);
-               } else {
-                       M_INTMOVE(REG_PV, rd->argintregs[3]);
-                       M_AADD_IMM(er->branchpos - 4, rd->argintregs[3]);
-               }
-
-               /* move function to call into REG_ITMP! */
-
-               disp = dseg_add_functionptr(cd, er->function);
-               M_ALD(REG_ITMP1, REG_PV, disp);
-
-               if (targetdisp == 0) {
-                       targetdisp = (cd->mcodeptr) - (cd->mcodebase);
-
-                       M_MOV(REG_PV, rd->argintregs[0]);
-                       M_MOV(REG_SP, rd->argintregs[1]);
-
-                       M_ALD(rd->argintregs[2],
-                                 REG_SP, cd->stackframesize * 4 - SIZEOF_VOID_P);
-
-                       M_ASUB_IMM((2 * 4) + 96, REG_SP);       
-
-                       M_AST(rd->argintregs[3], REG_SP, (0 * 4) + 96); /* store XPC */
-
-                       M_JSR(REG_RA, REG_ITMP1);
-
-                       M_MOV(REG_RESULT, REG_ITMP1_XPTR);
-
-                       M_ALD(REG_ITMP2_XPC, REG_SP, (0 * 4) + 96);
-                       M_AADD_IMM((2 * 4) + 96, REG_SP);
-
-                       disp = dseg_add_functionptr(cd, asm_handle_exception);
-                       M_ALD(REG_ITMP3, REG_PV, disp);
-                       M_JMP(RN, REG_ITMP3);
-               }
-               else {
-                       disp = ((cd->mcodebase) + targetdisp) -
-                               (( cd->mcodeptr) );
-
-                       M_BR(disp);
-               }
-
-       }
-}
-
-
 /* emit_patcher_stubs **********************************************************
 
    Generates the code for the patcher stubs.
@@ -489,7 +386,6 @@ void emit_verbosecall_enter(jitdata *jd)
        
        methodinfo   *m;
        codegendata  *cd;
-       registerdata *rd;
        methoddesc   *md;
        s4            i, j, k;
        s4            stackframesize, off, foff, aoff, doff, t, iargctr, fargctr, disp;
@@ -498,7 +394,6 @@ void emit_verbosecall_enter(jitdata *jd)
 
        m  = jd->m;
        cd = jd->cd;
-       rd = jd->rd;
 
        md = m->parseddesc;
 
@@ -520,19 +415,19 @@ void emit_verbosecall_enter(jitdata *jd)
        off = (6 * 8) + (1 * 4);
 
        for (i = 0; i < INT_ARG_CNT; i++, off += 8)
-               M_IST(rd->argintregs[i], REG_SP, off);
+               M_IST(abi_registers_integer_argument[i], REG_SP, off);
 
        for (i = 0; i < FLT_ARG_CNT; i++, off += 8)
-               M_DST(rd->argfltregs[i], REG_SP, off);
+               M_DST(abi_registers_float_argument[i], REG_SP, off);
 
        /* save temporary registers for leaf methods */
 
        if (jd->isleafmethod) {
                for (i = 0; i < INT_TMP_CNT; i++, off += 8)
-                       M_LST(rd->tmpintregs[i], REG_SP, off);
+                       M_LST(abi_registers_integer_temporary[i], REG_SP, off);
 
                for (i = 0; i < FLT_TMP_CNT; i++, off += 8)
-                       M_DST(rd->tmpfltregs[i], REG_SP, off);
+                       M_DST(abi_registers_float_temporary[i], REG_SP, off);
        }
 
        /* Load arguments to new locations */
@@ -638,19 +533,19 @@ void emit_verbosecall_enter(jitdata *jd)
        off = (6 * 8) + (1 * 4);
 
        for (i = 0; i < INT_ARG_CNT; i++, off += 8)
-               M_ILD(rd->argintregs[i], REG_SP, off);
+               M_ILD(abi_registers_integer_argument[i], REG_SP, off);
 
        for (i = 0; i < FLT_ARG_CNT; i++, off += 8)
-               M_DLD(rd->argfltregs[i], REG_SP, off);
+               M_DLD(abi_registers_float_argument[i], REG_SP, off);
 
        /* restore temporary registers for leaf methods */
 
        if (jd->isleafmethod) {
                for (i = 0; i < INT_TMP_CNT; i++, off += 8)
-                       M_ILD(rd->tmpintregs[i], REG_SP, off);
+                       M_ILD(abi_registers_integer_temporary[i], REG_SP, off);
 
                for (i = 0; i < FLT_TMP_CNT; i++, off += 8)
-                       M_DLD(rd->tmpfltregs[i], REG_SP, off);
+                       M_DLD(abi_registers_float_temporary[i], REG_SP, off);
        }
 
        /* remove stackframe */
@@ -724,1721 +619,260 @@ void emit_verbosecall_exit(jitdata *jd)
 #endif /* !defined(NDEBUG) */
 
 
-/* code generation functions **************************************************/
+/* emit_load_high **************************************************************
 
-static void emit_membase(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
-{
-       if ((basereg == REG_SP) || (basereg == R12)) {
-               if (disp == 0) {
-                       emit_address_byte(0, dreg, REG_SP);
-                       emit_address_byte(0, REG_SP, REG_SP);
+   Emits a possible load of the high 32-bits of an operand.
 
-               } else if (IS_IMM8(disp)) {
-                       emit_address_byte(1, dreg, REG_SP);
-                       emit_address_byte(0, REG_SP, REG_SP);
-                       emit_imm8(disp);
+*******************************************************************************/
 
-               } else {
-                       emit_address_byte(2, dreg, REG_SP);
-                       emit_address_byte(0, REG_SP, REG_SP);
-                       emit_imm32(disp);
-               }
+__PORTED__ s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
+{
+       codegendata  *cd;
+       s4            disp;
+       s4            reg;
 
-       } else if ((disp) == 0 && (basereg) != RBP && (basereg) != R13) {
-               emit_address_byte(0,(dreg),(basereg));
+       assert(src->type == TYPE_LNG);
 
-       } else if ((basereg) == RIP) {
-               emit_address_byte(0, dreg, RBP);
-               emit_imm32(disp);
+       /* get required compiler data */
 
-       } else {
-               if (IS_IMM8(disp)) {
-                       emit_address_byte(1, dreg, basereg);
-                       emit_imm8(disp);
+       cd = jd->cd;
 
-               } else {
-                       emit_address_byte(2, dreg, basereg);
-                       emit_imm32(disp);
-               }
-       }
-}
+       if (IS_INMEMORY(src->flags)) {
+               COUNT_SPILLS;
 
+               disp = src->vv.regoff * 4;
 
-static void emit_membase32(codegendata *cd, s4 basereg, s4 disp, s4 dreg)
-{
-       if ((basereg == REG_SP) || (basereg == R12)) {
-               emit_address_byte(2, dreg, REG_SP);
-               emit_address_byte(0, REG_SP, REG_SP);
-               emit_imm32(disp);
-       }
-       else {
-               emit_address_byte(2, dreg, basereg);
-               emit_imm32(disp);
+               M_ILD(tempreg, REG_SP, disp);
+
+               reg = tempreg;
        }
+       else
+               reg = GET_HIGH_REG(src->vv.regoff);
+
+       return reg;
 }
 
+/* emit_load_low ***************************************************************
 
-static void emit_memindex(codegendata *cd, s4 reg, s4 disp, s4 basereg, s4 indexreg, s4 scale)
-{
-       if (basereg == -1) {
-               emit_address_byte(0, reg, 4);
-               emit_address_byte(scale, indexreg, 5);
-               emit_imm32(disp);
-       }
-       else if ((disp == 0) && (basereg != RBP) && (basereg != R13)) {
-               emit_address_byte(0, reg, 4);
-               emit_address_byte(scale, indexreg, basereg);
-       }
-       else if (IS_IMM8(disp)) {
-               emit_address_byte(1, reg, 4);
-               emit_address_byte(scale, indexreg, basereg);
-               emit_imm8(disp);
-       }
-       else {
-               emit_address_byte(2, reg, 4);
-               emit_address_byte(scale, indexreg, basereg);
-               emit_imm32(disp);
-       }
-}
+   Emits a possible load of the low 32-bits of an operand.
 
+*******************************************************************************/
 
-void emit_ishift(jitdata *jd, s4 shift_op, instruction *iptr)
+__PORTED__ s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
 {
-       s4 s1, s2, d, d_old;
-       varinfo *v_s1,*v_s2,*v_dst;
-       codegendata *cd;
+       codegendata  *cd;
+       s4            disp;
+       s4            reg;
+
+       assert(src->type == TYPE_LNG);
 
        /* get required compiler data */
 
        cd = jd->cd;
 
-       v_s1  = VAROP(iptr->s1);
-       v_s2  = VAROP(iptr->sx.s23.s2);
-       v_dst = VAROP(iptr->dst);
-
-       s1 = v_s1->vv.regoff;
-       s2 = v_s2->vv.regoff;
-       d  = v_dst->vv.regoff;
+       if (IS_INMEMORY(src->flags)) {
+               COUNT_SPILLS;
 
-       M_INTMOVE(RCX, REG_ITMP1);                                    /* save RCX */
+               disp = src->vv.regoff * 4;
 
-       if (IS_INMEMORY(v_dst->flags)) {
-               if (IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       if (s1 == d) {
-                               M_ILD(RCX, REG_SP, s2 * 8);
-                               emit_shiftl_membase(cd, shift_op, REG_SP, d * 8);
+               M_ILD(tempreg, REG_SP, disp + 4);
 
-                       } else {
-                               M_ILD(RCX, REG_SP, s2 * 8);
-                               M_ILD(REG_ITMP2, REG_SP, s1 * 8);
-                               emit_shiftl_reg(cd, shift_op, REG_ITMP2);
-                               M_IST(REG_ITMP2, REG_SP, d * 8);
-                       }
+               reg = tempreg;
+       }
+       else
+               reg = GET_LOW_REG(src->vv.regoff);
 
-               } else if (IS_INMEMORY(v_s2->flags) && !IS_INMEMORY(v_s1->flags)) {
-                       /* s1 may be equal to RCX */
-                       if (s1 == RCX) {
-                               if (s2 == d) {
-                                       M_ILD(REG_ITMP1, REG_SP, s2 * 8);
-                                       M_IST(s1, REG_SP, d * 8);
-                                       M_INTMOVE(REG_ITMP1, RCX);
+       return reg;
+}
 
-                               } else {
-                                       M_IST(s1, REG_SP, d * 8);
-                                       M_ILD(RCX, REG_SP, s2 * 8);
-                               }
+s4 emit_load_s1_notzero(jitdata *jd, instruction *iptr, s4 tempreg) {
+       codegendata *cd = jd->cd;
+       s4 reg = emit_load_s1(jd, iptr, tempreg);
+       if (reg == 0) {
+               M_MOV(reg, tempreg);
+               return tempreg;
+       } else {
+               return reg;
+       }
+}
 
-                       } else {
-                               M_ILD(RCX, REG_SP, s2 * 8);
-                               M_IST(s1, REG_SP, d * 8);
-                       }
+s4 emit_load_s2_notzero(jitdata *jd, instruction *iptr, s4 tempreg) {
+       codegendata *cd = jd->cd;
+       s4 reg = emit_load_s2(jd, iptr, tempreg);
+       if (reg == 0) {
+               M_MOV(reg, tempreg);
+               return tempreg;
+       } else {
+               return reg;
+       }
+}
 
-                       emit_shiftl_membase(cd, shift_op, REG_SP, d * 8);
+s4 emit_load_s1_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg) {
+       codegendata *cd = jd->cd;
+       s4 reg = emit_load_s1(jd, iptr, tempreg);
+       if (reg == notreg) {
+               M_MOV(reg, tempreg);
+               return tempreg;
+       } else {
+               return reg;
+       }
+}
 
-               } else if (!IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       if (s1 == d) {
-                               M_INTMOVE(s2, RCX);
-                               emit_shiftl_membase(cd, shift_op, REG_SP, d * 8);
+s4 emit_load_s2_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg) {
+       codegendata *cd = jd->cd;
+       s4 reg = emit_load_s2(jd, iptr, tempreg);
+       if (reg == notreg) {
+               M_MOV(reg, tempreg);
+               return tempreg;
+       } else {
+               return reg;
+       }
+}
 
-                       } else {
-                               M_INTMOVE(s2, RCX);
-                               M_ILD(REG_ITMP2, REG_SP, s1 * 8);
-                               emit_shiftl_reg(cd, shift_op, REG_ITMP2);
-                               M_IST(REG_ITMP2, REG_SP, d * 8);
-                       }
+s4 emit_alloc_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg) {
+       codegendata *cd;
+       s4           hr, lr;
+       varinfo     *dst;
 
-               } else {
-                       /* s1 may be equal to RCX */
-                       M_IST(s1, REG_SP, d * 8);
-                       M_INTMOVE(s2, RCX);
-                       emit_shiftl_membase(cd, shift_op, REG_SP, d * 8);
-               }
+       /* (r0, r1)    
+        * (r2, r3)
+        * (r4, r5)
+        * (r6, r7)
+        * (r8, r9)
+        * (r10, r11)
+        * (r12, r13) Illegal, because r13 is PV
+        * (r14, r15) Illegal, because r15 is SP
+        */
 
-               M_INTMOVE(REG_ITMP1, RCX);                             /* restore RCX */
+       cd = jd->cd;
+       dst = VAROP(iptr->dst);
 
-       } else {
-               d_old = d;
-               if (d == RCX) {
-                       d = REG_ITMP3;
+       if (IS_INMEMORY(dst->flags)) {
+               if (! IS_REG_ITMP(ltmpreg)) {
+                       M_INTMOVE(ltmpreg, breg);
                }
-                                       
-               if (IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       M_ILD(RCX, REG_SP, s2 * 8);
-                       M_ILD(d, REG_SP, s1 * 8);
-                       emit_shiftl_reg(cd, shift_op, d);
-
-               } else if (IS_INMEMORY(v_s2->flags) && !IS_INMEMORY(v_s1->flags)) {
-                       /* s1 may be equal to RCX */
-                       M_INTMOVE(s1, d);
-                       M_ILD(RCX, REG_SP, s2 * 8);
-                       emit_shiftl_reg(cd, shift_op, d);
-
-               } else if (!IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       M_INTMOVE(s2, RCX);
-                       M_ILD(d, REG_SP, s1 * 8);
-                       emit_shiftl_reg(cd, shift_op, d);
-
+               if (! IS_REG_ITMP(htmpreg)) {
+                       M_INTMOVE(htmpreg, breg);
+               }
+               return PACK_REGS(ltmpreg, htmpreg);
+       } else {
+               hr = GET_HIGH_REG(dst->vv.regoff);
+               lr = GET_LOW_REG(dst->vv.regoff);
+               if (((hr % 2) == 0) && lr == (hr + 1)) {
+                       /* the result is already in a even-odd pair */
+                       return dst->vv.regoff;                  
+               } else if (((hr % 2) == 0) && (hr < R12)) {
+                       /* the high register is at a even position */
+                       M_INTMOVE(hr + 1, breg);
+                       return PACK_REGS(hr + 1, hr);
+               } else if (((lr % 2) == 1) && (lr < R12)) {
+                       /* the low register is at a odd position */
+                       M_INTMOVE(lr - 1, breg);
+                       return PACK_REGS(lr, lr - 1);
                } else {
-                       /* s1 may be equal to RCX */
-                       if (s1 == RCX) {
-                               if (s2 == d) {
-                                       /* d cannot be used to backup s1 since this would
-                                          overwrite s2. */
-                                       M_INTMOVE(s1, REG_ITMP3);
-                                       M_INTMOVE(s2, RCX);
-                                       M_INTMOVE(REG_ITMP3, d);
-
-                               } else {
-                                       M_INTMOVE(s1, d);
-                                       M_INTMOVE(s2, RCX);
-                               }
-
-                       } else {
-                               /* d may be equal to s2 */
-                               M_INTMOVE(s2, RCX);
-                               M_INTMOVE(s1, d);
+                       /* no way to create an even-odd pair by 1 copy operation,
+                        * Use the temporary register pair.
+                        */
+                       if (! IS_REG_ITMP(ltmpreg)) {
+                               M_INTMOVE(ltmpreg, breg);
                        }
-                       emit_shiftl_reg(cd, shift_op, d);
+                       if (! IS_REG_ITMP(htmpreg)) {
+                               M_INTMOVE(htmpreg, breg);
+                       }
+                       return PACK_REGS(ltmpreg, htmpreg);
                }
-
-               if (d_old == RCX)
-                       M_INTMOVE(REG_ITMP3, RCX);
-               else
-                       M_INTMOVE(REG_ITMP1, RCX);                         /* restore RCX */
        }
 }
 
-
-void emit_lshift(jitdata *jd, s4 shift_op, instruction *iptr)
-{
-       s4 s1, s2, d, d_old;
-       varinfo *v_s1,*v_s2,*v_dst;
+void emit_restore_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg) {
        codegendata *cd;
-
-       /* get required compiler data */
+       s4           hr, lr;
+       varinfo     *dst;
 
        cd = jd->cd;
+       dst = VAROP(iptr->dst);
 
-       v_s1  = VAROP(iptr->s1);
-       v_s2  = VAROP(iptr->sx.s23.s2);
-       v_dst = VAROP(iptr->dst);
-
-       s1 = v_s1->vv.regoff;
-       s2 = v_s2->vv.regoff;
-       d  = v_dst->vv.regoff;
-       
-       M_INTMOVE(RCX, REG_ITMP1);                                    /* save RCX */
-
-       if (IS_INMEMORY(v_dst->flags)) {
-               if (IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       if (s1 == d) {
-                               M_ILD(RCX, REG_SP, s2 * 8);
-                               emit_shift_membase(cd, shift_op, REG_SP, d * 8);
-
-                       } else {
-                               M_ILD(RCX, REG_SP, s2 * 8);
-                               M_LLD(REG_ITMP2, REG_SP, s1 * 8);
-                               emit_shift_reg(cd, shift_op, REG_ITMP2);
-                               M_LST(REG_ITMP2, REG_SP, d * 8);
-                       }
-
-               } else if (IS_INMEMORY(v_s2->flags) && !IS_INMEMORY(v_s1->flags)) {
-                       /* s1 may be equal to RCX */
-                       if (s1 == RCX) {
-                               if (s2 == d) {
-                                       M_ILD(REG_ITMP1, REG_SP, s2 * 8);
-                                       M_LST(s1, REG_SP, d * 8);
-                                       M_INTMOVE(REG_ITMP1, RCX);
-
-                               } else {
-                                       M_LST(s1, REG_SP, d * 8);
-                                       M_ILD(RCX, REG_SP, s2 * 8);
-                               }
-
-                       } else {
-                               M_ILD(RCX, REG_SP, s2 * 8);
-                               M_LST(s1, REG_SP, d * 8);
-                       }
-
-                       emit_shift_membase(cd, shift_op, REG_SP, d * 8);
-
-               } else if (!IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       if (s1 == d) {
-                               M_INTMOVE(s2, RCX);
-                               emit_shift_membase(cd, shift_op, REG_SP, d * 8);
-
-                       } else {
-                               M_INTMOVE(s2, RCX);
-                               M_LLD(REG_ITMP2, REG_SP, s1 * 8);
-                               emit_shift_reg(cd, shift_op, REG_ITMP2);
-                               M_LST(REG_ITMP2, REG_SP, d * 8);
-                       }
-
-               } else {
-                       /* s1 may be equal to RCX */
-                       M_LST(s1, REG_SP, d * 8);
-                       M_INTMOVE(s2, RCX);
-                       emit_shift_membase(cd, shift_op, REG_SP, d * 8);
-               }
-
-               M_INTMOVE(REG_ITMP1, RCX);                             /* restore RCX */
-
-       } else {
-               d_old = d;
-               if (d == RCX) {
-                       d = REG_ITMP3;
-               }
-
-               if (IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       M_ILD(RCX, REG_SP, s2 * 8);
-                       M_LLD(d, REG_SP, s1 * 8);
-                       emit_shift_reg(cd, shift_op, d);
-
-               } else if (IS_INMEMORY(v_s2->flags) && !IS_INMEMORY(v_s1->flags)) {
-                       /* s1 may be equal to RCX */
-                       M_INTMOVE(s1, d);
-                       M_ILD(RCX, REG_SP, s2 * 8);
-                       emit_shift_reg(cd, shift_op, d);
-
-               } else if (!IS_INMEMORY(v_s2->flags) && IS_INMEMORY(v_s1->flags)) {
-                       M_INTMOVE(s2, RCX);
-                       M_LLD(d, REG_SP, s1 * 8);
-                       emit_shift_reg(cd, shift_op, d);
-
-               } else {
-                       /* s1 may be equal to RCX */
-                       if (s1 == RCX) {
-                               if (s2 == d) {
-                                       /* d cannot be used to backup s1 since this would
-                                          overwrite s2. */
-                                       M_INTMOVE(s1, REG_ITMP3);
-                                       M_INTMOVE(s2, RCX);
-                                       M_INTMOVE(REG_ITMP3, d);
-
-                               } else {
-                                       M_INTMOVE(s1, d);
-                                       M_INTMOVE(s2, RCX);
-                               }
-
-                       } else {
-                               /* d may be equal to s2 */
-                               M_INTMOVE(s2, RCX);
-                               M_INTMOVE(s1, d);
-                       }
-                       emit_shift_reg(cd, shift_op, d);
-               }
-
-               if (d_old == RCX)
-                       M_INTMOVE(REG_ITMP3, RCX);
-               else
-                       M_INTMOVE(REG_ITMP1, RCX);                         /* restore RCX */
-       }
-}
-
-
-/* low-level code emitter functions *******************************************/
-
-void emit_mov_reg_reg(codegendata *cd, s8 reg, s8 dreg)
-{
-       emit_rex(1,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_mov_imm_reg(codegendata *cd, s8 imm, s8 reg)
-{
-       emit_rex(1,0,0,(reg));
-       *(cd->mcodeptr++) = 0xb8 + ((reg) & 0x07);
-       emit_imm64((imm));
-}
-
-
-void emit_movl_reg_reg(codegendata *cd, s8 reg, s8 dreg)
-{
-       emit_rex(0,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_movl_imm_reg(codegendata *cd, s8 imm, s8 reg) {
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0xb8 + ((reg) & 0x07);
-       emit_imm32((imm));
-}
-
-
-void emit_mov_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg) {
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x8b;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-/*
- * this one is for INVOKEVIRTUAL/INVOKEINTERFACE to have a
- * constant membase immediate length of 32bit
- */
-void emit_mov_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg) {
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x8b;
-       emit_membase32(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movl_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg)
-{
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x8b;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-/* ATTENTION: Always emit a REX byte, because the instruction size can
-   be smaller when all register indexes are smaller than 7. */
-void emit_movl_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg)
-{
-       emit_byte_rex((reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x8b;
-       emit_membase32(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_mov_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_mov_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_membase32(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movl_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-/* Always emit a REX byte, because the instruction size can be smaller when   */
-/* all register indexes are smaller than 7.                                   */
-void emit_movl_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       emit_byte_rex((reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_membase32(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_mov_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg) {
-       emit_rex(1,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x8b;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movl_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg) {
-       emit_rex(0,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x8b;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_mov_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       emit_rex(1,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movl_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       emit_rex(0,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movw_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x89;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movb_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       emit_byte_rex((reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x88;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_mov_imm_membase(codegendata *cd, s8 imm, s8 basereg, s8 disp) {
-       emit_rex(1,0,0,(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_membase(cd, (basereg),(disp),0);
-       emit_imm32((imm));
-}
-
-
-void emit_mov_imm_membase32(codegendata *cd, s8 imm, s8 basereg, s8 disp) {
-       emit_rex(1,0,0,(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_membase32(cd, (basereg),(disp),0);
-       emit_imm32((imm));
-}
-
-
-void emit_movl_imm_membase(codegendata *cd, s8 imm, s8 basereg, s8 disp) {
-       emit_rex(0,0,0,(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_membase(cd, (basereg),(disp),0);
-       emit_imm32((imm));
-}
-
-
-/* Always emit a REX byte, because the instruction size can be smaller when   */
-/* all register indexes are smaller than 7.                                   */
-void emit_movl_imm_membase32(codegendata *cd, s8 imm, s8 basereg, s8 disp) {
-       emit_byte_rex(0,0,(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_membase32(cd, (basereg),(disp),0);
-       emit_imm32((imm));
-}
-
-
-void emit_movsbq_reg_reg(codegendata *cd, s8 reg, s8 dreg)
-{
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xbe;
-       /* XXX: why do reg and dreg have to be exchanged */
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_movswq_reg_reg(codegendata *cd, s8 reg, s8 dreg)
-{
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xbf;
-       /* XXX: why do reg and dreg have to be exchanged */
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_movslq_reg_reg(codegendata *cd, s8 reg, s8 dreg)
-{
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x63;
-       /* XXX: why do reg and dreg have to be exchanged */
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_movzwq_reg_reg(codegendata *cd, s8 reg, s8 dreg)
-{
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xb7;
-       /* XXX: why do reg and dreg have to be exchanged */
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_movswq_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg) {
-       emit_rex(1,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xbf;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movsbq_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg) {
-       emit_rex(1,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xbe;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movzwq_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg) {
-       emit_rex(1,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xb7;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_mov_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
-{
-       emit_rex(1,0,(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
-       emit_imm32((imm));
-}
-
-
-void emit_movl_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
-{
-       emit_rex(0,0,(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
-       emit_imm32((imm));
-}
-
-
-void emit_movw_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
-{
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,0,(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0xc7;
-       emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
-       emit_imm16((imm));
-}
-
-
-void emit_movb_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale)
-{
-       emit_rex(0,0,(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0xc6;
-       emit_memindex(cd, 0,(disp),(basereg),(indexreg),(scale));
-       emit_imm8((imm));
-}
-
-
-/*
- * alu operations
- */
-void emit_alu_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg)
-{
-       emit_rex(1,(reg),0,(dreg));
-       *(cd->mcodeptr++) = (((opc)) << 3) + 1;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_alul_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg)
-{
-       emit_rex(0,(reg),0,(dreg));
-       *(cd->mcodeptr++) = (((opc)) << 3) + 1;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_alu_reg_membase(codegendata *cd, s8 opc, s8 reg, s8 basereg, s8 disp)
-{
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = (((opc)) << 3) + 1;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_alul_reg_membase(codegendata *cd, s8 opc, s8 reg, s8 basereg, s8 disp)
-{
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = (((opc)) << 3) + 1;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_alu_membase_reg(codegendata *cd, s8 opc, s8 basereg, s8 disp, s8 reg)
-{
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = (((opc)) << 3) + 3;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_alul_membase_reg(codegendata *cd, s8 opc, s8 basereg, s8 disp, s8 reg)
-{
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = (((opc)) << 3) + 3;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_alu_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg) {
-       if (IS_IMM8(imm)) {
-               emit_rex(1,0,0,(dreg));
-               *(cd->mcodeptr++) = 0x83;
-               emit_reg((opc),(dreg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(1,0,0,(dreg));
-               *(cd->mcodeptr++) = 0x81;
-               emit_reg((opc),(dreg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_alu_imm32_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg) {
-       emit_rex(1,0,0,(dreg));
-       *(cd->mcodeptr++) = 0x81;
-       emit_reg((opc),(dreg));
-       emit_imm32((imm));
-}
-
-
-void emit_alul_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg) {
-       if (IS_IMM8(imm)) {
-               emit_rex(0,0,0,(dreg));
-               *(cd->mcodeptr++) = 0x83;
-               emit_reg((opc),(dreg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(0,0,0,(dreg));
-               *(cd->mcodeptr++) = 0x81;
-               emit_reg((opc),(dreg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_alu_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp) {
-       if (IS_IMM8(imm)) {
-               emit_rex(1,(basereg),0,0);
-               *(cd->mcodeptr++) = 0x83;
-               emit_membase(cd, (basereg),(disp),(opc));
-               emit_imm8((imm));
-       } else {
-               emit_rex(1,(basereg),0,0);
-               *(cd->mcodeptr++) = 0x81;
-               emit_membase(cd, (basereg),(disp),(opc));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_alul_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp) {
-       if (IS_IMM8(imm)) {
-               emit_rex(0,(basereg),0,0);
-               *(cd->mcodeptr++) = 0x83;
-               emit_membase(cd, (basereg),(disp),(opc));
-               emit_imm8((imm));
-       } else {
-               emit_rex(0,(basereg),0,0);
-               *(cd->mcodeptr++) = 0x81;
-               emit_membase(cd, (basereg),(disp),(opc));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_test_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(1,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x85;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_testl_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(0,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x85;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_test_imm_reg(codegendata *cd, s8 imm, s8 reg) {
-       *(cd->mcodeptr++) = 0xf7;
-       emit_reg(0,(reg));
-       emit_imm32((imm));
-}
-
-
-void emit_testw_imm_reg(codegendata *cd, s8 imm, s8 reg) {
-       *(cd->mcodeptr++) = 0x66;
-       *(cd->mcodeptr++) = 0xf7;
-       emit_reg(0,(reg));
-       emit_imm16((imm));
-}
-
-
-void emit_testb_imm_reg(codegendata *cd, s8 imm, s8 reg) {
-       *(cd->mcodeptr++) = 0xf6;
-       emit_reg(0,(reg));
-       emit_imm8((imm));
-}
-
-
-void emit_lea_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg) {
-       emit_rex(1,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x8d;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_leal_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg) {
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x8d;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-
-void emit_incl_membase(codegendata *cd, s8 basereg, s8 disp)
-{
-       emit_rex(0,0,0,(basereg));
-       *(cd->mcodeptr++) = 0xff;
-       emit_membase(cd, (basereg),(disp),0);
-}
-
-
-
-void emit_cltd(codegendata *cd) {
-    *(cd->mcodeptr++) = 0x99;
-}
-
-
-void emit_cqto(codegendata *cd) {
-       emit_rex(1,0,0,0);
-       *(cd->mcodeptr++) = 0x99;
-}
-
-
-
-void emit_imul_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xaf;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_imull_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xaf;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_imul_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       emit_rex(1,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xaf;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_imull_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xaf;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_imul_imm_reg(codegendata *cd, s8 imm, s8 dreg) {
-       if (IS_IMM8((imm))) {
-               emit_rex(1,0,0,(dreg));
-               *(cd->mcodeptr++) = 0x6b;
-               emit_reg(0,(dreg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(1,0,0,(dreg));
-               *(cd->mcodeptr++) = 0x69;
-               emit_reg(0,(dreg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_imul_imm_reg_reg(codegendata *cd, s8 imm, s8 reg, s8 dreg) {
-       if (IS_IMM8((imm))) {
-               emit_rex(1,(dreg),0,(reg));
-               *(cd->mcodeptr++) = 0x6b;
-               emit_reg((dreg),(reg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(1,(dreg),0,(reg));
-               *(cd->mcodeptr++) = 0x69;
-               emit_reg((dreg),(reg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_imull_imm_reg_reg(codegendata *cd, s8 imm, s8 reg, s8 dreg) {
-       if (IS_IMM8((imm))) {
-               emit_rex(0,(dreg),0,(reg));
-               *(cd->mcodeptr++) = 0x6b;
-               emit_reg((dreg),(reg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(0,(dreg),0,(reg));
-               *(cd->mcodeptr++) = 0x69;
-               emit_reg((dreg),(reg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_imul_imm_membase_reg(codegendata *cd, s8 imm, s8 basereg, s8 disp, s8 dreg) {
-       if (IS_IMM8((imm))) {
-               emit_rex(1,(dreg),0,(basereg));
-               *(cd->mcodeptr++) = 0x6b;
-               emit_membase(cd, (basereg),(disp),(dreg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(1,(dreg),0,(basereg));
-               *(cd->mcodeptr++) = 0x69;
-               emit_membase(cd, (basereg),(disp),(dreg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_imull_imm_membase_reg(codegendata *cd, s8 imm, s8 basereg, s8 disp, s8 dreg) {
-       if (IS_IMM8((imm))) {
-               emit_rex(0,(dreg),0,(basereg));
-               *(cd->mcodeptr++) = 0x6b;
-               emit_membase(cd, (basereg),(disp),(dreg));
-               emit_imm8((imm));
-       } else {
-               emit_rex(0,(dreg),0,(basereg));
-               *(cd->mcodeptr++) = 0x69;
-               emit_membase(cd, (basereg),(disp),(dreg));
-               emit_imm32((imm));
-       }
-}
-
-
-void emit_idiv_reg(codegendata *cd, s8 reg) {
-       emit_rex(1,0,0,(reg));
-       *(cd->mcodeptr++) = 0xf7;
-       emit_reg(7,(reg));
-}
-
-
-void emit_idivl_reg(codegendata *cd, s8 reg) {
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0xf7;
-       emit_reg(7,(reg));
-}
-
-
-
-void emit_ret(codegendata *cd) {
-    *(cd->mcodeptr++) = 0xc3;
-}
-
-
-
-/*
- * shift ops
- */
-void emit_shift_reg(codegendata *cd, s8 opc, s8 reg) {
-       emit_rex(1,0,0,(reg));
-       *(cd->mcodeptr++) = 0xd3;
-       emit_reg((opc),(reg));
-}
-
-
-void emit_shiftl_reg(codegendata *cd, s8 opc, s8 reg) {
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0xd3;
-       emit_reg((opc),(reg));
-}
-
-
-void emit_shift_membase(codegendata *cd, s8 opc, s8 basereg, s8 disp) {
-       emit_rex(1,0,0,(basereg));
-       *(cd->mcodeptr++) = 0xd3;
-       emit_membase(cd, (basereg),(disp),(opc));
-}
-
-
-void emit_shiftl_membase(codegendata *cd, s8 opc, s8 basereg, s8 disp) {
-       emit_rex(0,0,0,(basereg));
-       *(cd->mcodeptr++) = 0xd3;
-       emit_membase(cd, (basereg),(disp),(opc));
-}
-
-
-void emit_shift_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg) {
-       if ((imm) == 1) {
-               emit_rex(1,0,0,(dreg));
-               *(cd->mcodeptr++) = 0xd1;
-               emit_reg((opc),(dreg));
-       } else {
-               emit_rex(1,0,0,(dreg));
-               *(cd->mcodeptr++) = 0xc1;
-               emit_reg((opc),(dreg));
-               emit_imm8((imm));
-       }
-}
-
-
-void emit_shiftl_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg) {
-       if ((imm) == 1) {
-               emit_rex(0,0,0,(dreg));
-               *(cd->mcodeptr++) = 0xd1;
-               emit_reg((opc),(dreg));
-       } else {
-               emit_rex(0,0,0,(dreg));
-               *(cd->mcodeptr++) = 0xc1;
-               emit_reg((opc),(dreg));
-               emit_imm8((imm));
-       }
-}
-
-
-void emit_shift_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp) {
-       if ((imm) == 1) {
-               emit_rex(1,0,0,(basereg));
-               *(cd->mcodeptr++) = 0xd1;
-               emit_membase(cd, (basereg),(disp),(opc));
-       } else {
-               emit_rex(1,0,0,(basereg));
-               *(cd->mcodeptr++) = 0xc1;
-               emit_membase(cd, (basereg),(disp),(opc));
-               emit_imm8((imm));
-       }
-}
-
-
-void emit_shiftl_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp) {
-       if ((imm) == 1) {
-               emit_rex(0,0,0,(basereg));
-               *(cd->mcodeptr++) = 0xd1;
-               emit_membase(cd, (basereg),(disp),(opc));
-       } else {
-               emit_rex(0,0,0,(basereg));
-               *(cd->mcodeptr++) = 0xc1;
-               emit_membase(cd, (basereg),(disp),(opc));
-               emit_imm8((imm));
-       }
-}
-
-
-
-/*
- * jump operations
- */
-void emit_jmp_imm(codegendata *cd, s8 imm) {
-       *(cd->mcodeptr++) = 0xe9;
-       emit_imm32((imm));
-}
-
-
-void emit_jmp_reg(codegendata *cd, s8 reg) {
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0xff;
-       emit_reg(4,(reg));
-}
-
-
-void emit_jcc(codegendata *cd, s8 opc, s8 imm) {
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = (0x80 + (opc));
-       emit_imm32((imm));
-}
-
-
-
-/*
- * conditional set and move operations
- */
-
-/* we need the rex byte to get all low bytes */
-void emit_setcc_reg(codegendata *cd, s8 opc, s8 reg) {
-       *(cd->mcodeptr++) = (0x40 | (((reg) >> 3) & 0x01));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = (0x90 + (opc));
-       emit_reg(0,(reg));
-}
-
-
-/* we need the rex byte to get all low bytes */
-void emit_setcc_membase(codegendata *cd, s8 opc, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = (0x40 | (((basereg) >> 3) & 0x01));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = (0x90 + (opc));
-       emit_membase(cd, (basereg),(disp),0);
-}
-
-
-void emit_cmovcc_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg)
-{
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = (0x40 + (opc));
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cmovccl_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg)
-{
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = (0x40 + (opc));
-       emit_reg((dreg),(reg));
-}
-
-
-
-void emit_neg_reg(codegendata *cd, s8 reg)
-{
-       emit_rex(1,0,0,(reg));
-       *(cd->mcodeptr++) = 0xf7;
-       emit_reg(3,(reg));
-}
-
-
-void emit_negl_reg(codegendata *cd, s8 reg)
-{
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0xf7;
-       emit_reg(3,(reg));
-}
-
-
-void emit_push_reg(codegendata *cd, s8 reg) {
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0x50 + (0x07 & (reg));
-}
-
-
-void emit_push_imm(codegendata *cd, s8 imm) {
-       *(cd->mcodeptr++) = 0x68;
-       emit_imm32((imm));
-}
-
-
-void emit_pop_reg(codegendata *cd, s8 reg) {
-       emit_rex(0,0,0,(reg));
-       *(cd->mcodeptr++) = 0x58 + (0x07 & (reg));
-}
-
-
-void emit_xchg_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(1,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x87;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_nop(codegendata *cd) {
-    *(cd->mcodeptr++) = 0x90;
-}
-
-
-
-/*
- * call instructions
- */
-void emit_call_reg(codegendata *cd, s8 reg) {
-       emit_rex(1,0,0,(reg));
-       *(cd->mcodeptr++) = 0xff;
-       emit_reg(2,(reg));
-}
-
-
-void emit_call_imm(codegendata *cd, s8 imm) {
-       *(cd->mcodeptr++) = 0xe8;
-       emit_imm32((imm));
-}
-
-
-void emit_call_mem(codegendata *cd, ptrint mem)
-{
-       *(cd->mcodeptr++) = 0xff;
-       emit_mem(2,(mem));
-}
-
-
-
-/*
- * floating point instructions (SSE2)
- */
-void emit_addsd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x58;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_addss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x58;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvtsi2ssq_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2a;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvtsi2ss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2a;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvtsi2sdq_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2a;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvtsi2sd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2a;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvtss2sd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x5a;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvtsd2ss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x5a;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvttss2siq_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2c;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvttss2si_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2c;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvttsd2siq_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(1,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2c;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_cvttsd2si_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2c;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_divss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x5e;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_divsd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x5e;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_movd_reg_freg(codegendata *cd, s8 reg, s8 freg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(1,(freg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x6e;
-       emit_reg((freg),(reg));
-}
-
-
-void emit_movd_freg_reg(codegendata *cd, s8 freg, s8 reg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(1,(freg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x7e;
-       emit_reg((freg),(reg));
-}
-
-
-void emit_movd_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x7e;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movd_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x7e;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(1,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x6e;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movdl_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x6e;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movd_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 dreg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(dreg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x6e;
-       emit_memindex(cd, (dreg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movq_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x7e;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_movq_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0xd6;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movq_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x7e;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_movsd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(reg),0,(dreg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_reg((reg),(dreg));
-}
-
-
-void emit_movss_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x11;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-/* Always emit a REX byte, because the instruction size can be smaller when   */
-/* all register indexes are smaller than 7.                                   */
-void emit_movss_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_byte_rex((reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x11;
-       emit_membase32(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movsd_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x11;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-/* Always emit a REX byte, because the instruction size can be smaller when   */
-/* all register indexes are smaller than 7.                                   */
-void emit_movsd_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_byte_rex((reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x11;
-       emit_membase32(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movss_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-/* Always emit a REX byte, because the instruction size can be smaller when   */
-/* all register indexes are smaller than 7.                                   */
-void emit_movss_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_byte_rex((dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_membase32(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movlps_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg)
-{
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x12;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movlps_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp)
-{
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x13;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movsd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-/* Always emit a REX byte, because the instruction size can be smaller when   */
-/* all register indexes are smaller than 7.                                   */
-void emit_movsd_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_byte_rex((dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_membase32(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movlpd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg)
-{
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x12;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_movlpd_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp)
-{
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(reg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x13;
-       emit_membase(cd, (basereg),(disp),(reg));
-}
-
-
-void emit_movss_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x11;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movsd_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(reg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x11;
-       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movss_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_memindex(cd, (dreg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_movsd_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),(indexreg),(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x10;
-       emit_memindex(cd, (dreg),(disp),(basereg),(indexreg),(scale));
-}
-
-
-void emit_mulss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x59;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_mulsd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x59;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_subss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf3;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x5c;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_subsd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0xf2;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x5c;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_ucomiss_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2e;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_ucomisd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x2e;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_xorps_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x57;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_xorps_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x57;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-void emit_xorpd_reg_reg(codegendata *cd, s8 reg, s8 dreg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(dreg),0,(reg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x57;
-       emit_reg((dreg),(reg));
-}
-
-
-void emit_xorpd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg) {
-       *(cd->mcodeptr++) = 0x66;
-       emit_rex(0,(dreg),0,(basereg));
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x57;
-       emit_membase(cd, (basereg),(disp),(dreg));
-}
-
-
-/* system instructions ********************************************************/
-
-void emit_rdtsc(codegendata *cd)
-{
-       *(cd->mcodeptr++) = 0x0f;
-       *(cd->mcodeptr++) = 0x31;
+       if (IS_INMEMORY(dst->flags)) {
+               if (! IS_REG_ITMP(ltmpreg)) {
+                       M_INTMOVE(breg, ltmpreg);
+               }
+               if (! IS_REG_ITMP(htmpreg)) {
+                       M_INTMOVE(breg, htmpreg);
+               }
+       } else {
+               hr = GET_HIGH_REG(dst->vv.regoff);
+               lr = GET_LOW_REG(dst->vv.regoff);
+               if (((hr % 2) == 0) && lr == (hr + 1)) {
+                       return;
+               } else if (((hr % 2) == 0) && (hr < R12)) {
+                       M_INTMOVE(breg, hr + 1);
+               } else if (((lr % 2) == 1) && (lr < R12)) {
+                       M_INTMOVE(breg, lr - 1);
+               } else {
+                       if (! IS_REG_ITMP(ltmpreg)) {
+                               M_INTMOVE(breg, ltmpreg);
+                       }
+                       if (! IS_REG_ITMP(htmpreg)) {
+                               M_INTMOVE(breg, htmpreg);
+                       }
+               }
+       }
 }
 
-/* emit_load_high **************************************************************
-
-   Emits a possible load of the high 32-bits of an operand.
-
-*******************************************************************************/
-
-__PORTED__ s4 emit_load_high(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
-{
-       codegendata  *cd;
-       s4            disp;
-       s4            reg;
-
-       assert(src->type == TYPE_LNG);
-
-       /* get required compiler data */
-
+void emit_copy_dst(jitdata *jd, instruction *iptr, s4 dtmpreg) {
+       codegendata *cd;
+       varinfo *dst;
        cd = jd->cd;
-
-       if (IS_INMEMORY(src->flags)) {
-               COUNT_SPILLS;
-
-               disp = src->vv.regoff * 4;
-
-               M_ILD(tempreg, REG_SP, disp);
-
-               reg = tempreg;
+       dst = VAROP(iptr->dst);
+       if (! IS_INMEMORY(dst->flags)) {
+               if (dst->vv.regoff != dtmpreg) {
+                       if (IS_FLT_DBL_TYPE(dst->type)) {
+                               M_FLTMOVE(dtmpreg, dst->vv.regoff);
+                       } else if (IS_2_WORD_TYPE(dst->type)) {
+                               M_LNGMOVE(dtmpreg, dst->vv.regoff);
+                       } else {
+                               M_INTMOVE(dtmpreg, dst->vv.regoff);
+                       }
+               }
        }
-       else
-               reg = GET_HIGH_REG(src->vv.regoff);
-
-       return reg;
 }
 
-/* emit_load_low ***************************************************************
-
-   Emits a possible load of the low 32-bits of an operand.
-
-*******************************************************************************/
-
-__PORTED__ s4 emit_load_low(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg)
-{
-       codegendata  *cd;
-       s4            disp;
-       s4            reg;
-
-       assert(src->type == TYPE_LNG);
-
-       /* get required compiler data */
-
-       cd = jd->cd;
-
-       if (IS_INMEMORY(src->flags)) {
-               COUNT_SPILLS;
+void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt) {
 
-               disp = src->vv.regoff * 4;
-
-               M_ILD(tempreg, REG_SP, disp + 4);
+       s4 branchdisp = disp;
 
-               reg = tempreg;
+       switch (condition) {
+               case BRANCH_EQ:
+                       M_BEQ(branchdisp);
+                       break;
+               case BRANCH_NE:
+                       M_BNE(branchdisp);
+                       break;
+               case BRANCH_LT:
+                       M_BLT(branchdisp);
+                       break;
+               case BRANCH_GE:
+                       M_BGE(branchdisp);
+                       break;
+               case BRANCH_GT:
+                       M_BGT(branchdisp);
+                       break;
+               case BRANCH_LE:
+                       M_BLE(branchdisp);
+                       break;
+               case BRANCH_UNCONDITIONAL:
+                       M_BR(branchdisp);
+                       break;
+               default:
+                       vm_abort("emit_branch: unknown condition %d", condition);
        }
-       else
-               reg = GET_LOW_REG(src->vv.regoff);
-
-       return reg;
 }
 
-/* emit_nullpointer_check ******************************************************
-
-   Emit a NullPointerException check.
-
-*******************************************************************************/
-
-__PORTED__ void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
-{
+void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg) {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TEST(reg);
-               M_BEQ(0);
-               codegen_add_nullpointerexception_ref(cd);
+               M_BNE(SZ_BRC + SZ_ILL);
+               M_ILL(EXCEPTION_HARDWARE_ARITHMETIC);
        }
 }
 
@@ -2448,167 +882,86 @@ __PORTED__ void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 re
 
 *******************************************************************************/
 
-__PORTED__ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
+void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1, s4 s2)
 {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                /* Size is s4, >= 0
                 * Do unsigned comparison to catch negative indexes.
                 */
                N_CL(s2, OFFSET(java_arrayheader, size), RN, s1);
-        M_BGE(0);
-        codegen_add_arrayindexoutofboundsexception_ref(cd, s2);
+        M_BLT(SZ_BRC + SZ_ILL);
+               M_ILL2(s2, EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
        }
 }
 
-s4 emit_load_s1_notzero(jitdata *jd, instruction *iptr, s4 tempreg) {
-       codegendata *cd = jd->cd;
-       s4 reg = emit_load_s1(jd, iptr, tempreg);
-       if (reg == 0) {
-               M_MOV(reg, tempreg);
-               return tempreg;
-       } else {
-               return reg;
+void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 reg, s4 s1) {
+       if (INSTRUCTION_MUST_CHECK(iptr)) {
+               if (reg != RN) {
+                       M_TEST(reg);
+               }
+               switch (condition) {
+                       case BRANCH_LE:
+                               M_BGT(SZ_BRC + SZ_ILL);
+                               break;
+                       case BRANCH_EQ:
+                               M_BNE(SZ_BRC + SZ_ILL);
+                               break;
+                       case BRANCH_GT:
+                               M_BLE(SZ_BRC + SZ_ILL);
+                               break;
+                       default:
+                               vm_abort("emit_classcast_check: unknown condition %d", condition);
+               }
+               M_ILL2(s1, EXCEPTION_HARDWARE_CLASSCAST);
        }
 }
 
-s4 emit_load_s2_notzero(jitdata *jd, instruction *iptr, s4 tempreg) {
-       codegendata *cd = jd->cd;
-       s4 reg = emit_load_s2(jd, iptr, tempreg);
-       if (reg == 0) {
-               M_MOV(reg, tempreg);
-               return tempreg;
-       } else {
-               return reg;
+void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg) {
+       if (INSTRUCTION_MUST_CHECK(iptr)) {
+               M_TEST(reg);
+               M_BNE(SZ_BRC + SZ_ILL);
+               M_ILL(EXCEPTION_HARDWARE_NULLPOINTER);
        }
 }
 
-s4 emit_load_s1_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg) {
-       codegendata *cd = jd->cd;
-       s4 reg = emit_load_s1(jd, iptr, tempreg);
-       if (reg == notreg) {
-               M_MOV(reg, tempreg);
-               return tempreg;
-       } else {
-               return reg;
+void emit_exception_check(codegendata *cd, instruction *iptr) {
+       if (INSTRUCTION_MUST_CHECK(iptr)) {
+               M_TEST(REG_RESULT);
+               M_BNE(SZ_BRC + SZ_ILL);
+               M_ILL(EXCEPTION_HARDWARE_EXCEPTION);
        }
 }
 
-s4 emit_load_s2_but(jitdata *jd, instruction *iptr, s4 tempreg, s4 notreg) {
-       codegendata *cd = jd->cd;
-       s4 reg = emit_load_s2(jd, iptr, tempreg);
-       if (reg == notreg) {
-               M_MOV(reg, tempreg);
-               return tempreg;
-       } else {
-               return reg;
-       }
-}
+void emit_restore_pv(codegendata *cd) {
+       s4 offset;
 
-s4 emit_alloc_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg) {
-       codegendata *cd;
-       s4           hr, lr;
-       varinfo     *dst;
+       /*
+       N_BASR(REG_PV, RN);
+       disp = (s4) (cd->mcodeptr - cd->mcodebase);
+       M_ASUB_IMM32(disp, REG_ITMP1, REG_PV);
+       */
 
-       /* (r0, r1)    
-        * (r2, r3)
-        * (r4, r5)
-        * (r6, r7)
-        * (r8, r9)
-        * (r10, r11)
-        * (r12, r13) Illegal, because r13 is PV
-        * (r14, r15) Illegal, because r15 is SP
+       /* If the offset from the method start does not fit into an immediate
+        * value, we can't put it into the data segment!
         */
 
-       cd = jd->cd;
-       dst = VAROP(iptr->dst);
-
-       if (IS_INMEMORY(dst->flags)) {
-               if (! IS_REG_ITMP(ltmpreg)) {
-                       M_INTMOVE(ltmpreg, breg);
-               }
-               if (! IS_REG_ITMP(htmpreg)) {
-                       M_INTMOVE(htmpreg, breg);
-               }
-               return PACK_REGS(ltmpreg, htmpreg);
-       } else {
-               hr = GET_HIGH_REG(dst->vv.regoff);
-               lr = GET_LOW_REG(dst->vv.regoff);
-               if (((hr % 2) == 0) && lr == (hr + 1)) {
-                       /* the result is already in a even-odd pair */
-                       return dst->vv.regoff;                  
-               } else if (((hr % 2) == 0) && (hr < R12)) {
-                       /* the high register is at a even position */
-                       M_INTMOVE(hr + 1, breg);
-                       return PACK_REGS(hr + 1, hr);
-               } else if (((lr % 2) == 1) && (lr < R12)) {
-                       /* the low register is at a odd position */
-                       M_INTMOVE(lr - 1, breg);
-                       return PACK_REGS(lr, lr - 1);
-               } else {
-                       /* no way to create an even-odd pair by 1 copy operation,
-                        * Use the temporary register pair.
-                        */
-                       if (! IS_REG_ITMP(ltmpreg)) {
-                               M_INTMOVE(ltmpreg, breg);
-                       }
-                       if (! IS_REG_ITMP(htmpreg)) {
-                               M_INTMOVE(htmpreg, breg);
-                       }
-                       return PACK_REGS(ltmpreg, htmpreg);
-               }
-       }
-}
-
-void emit_restore_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 ltmpreg, s4 breg) {
-       codegendata *cd;
-       s4           hr, lr;
-       varinfo     *dst;
+       /* Displacement from start of method to here */
 
-       cd = jd->cd;
-       dst = VAROP(iptr->dst);
+       offset = (s4) (cd->mcodeptr - cd->mcodebase);
 
-       if (IS_INMEMORY(dst->flags)) {
-               if (! IS_REG_ITMP(ltmpreg)) {
-                       M_INTMOVE(breg, ltmpreg);
-               }
-               if (! IS_REG_ITMP(htmpreg)) {
-                       M_INTMOVE(breg, htmpreg);
-               }
+       if (N_VALID_IMM(-(offset + SZ_BASR))) {
+               /* Get program counter */
+               N_BASR(REG_PV, RN);
+               /* Substract displacement */
+               M_ASUB_IMM(offset + SZ_BASR, REG_PV);
        } else {
-               hr = GET_HIGH_REG(dst->vv.regoff);
-               lr = GET_LOW_REG(dst->vv.regoff);
-               if (((hr % 2) == 0) && lr == (hr + 1)) {
-                       return;
-               } else if (((hr % 2) == 0) && (hr < R12)) {
-                       M_INTMOVE(breg, hr + 1);
-               } else if (((lr % 2) == 1) && (lr < R12)) {
-                       M_INTMOVE(breg, lr - 1);
-               } else {
-                       if (! IS_REG_ITMP(ltmpreg)) {
-                               M_INTMOVE(breg, ltmpreg);
-                       }
-                       if (! IS_REG_ITMP(htmpreg)) {
-                               M_INTMOVE(breg, htmpreg);
-                       }
-               }
-       }
-}
-
-void emit_copy_dst(jitdata *jd, instruction *iptr, s4 dtmpreg) {
-       codegendata *cd;
-       varinfo *dst;
-       cd = jd->cd;
-       dst = VAROP(iptr->dst);
-       if (! IS_INMEMORY(dst->flags)) {
-               if (dst->vv.regoff != dtmpreg) {
-                       if (IS_FLT_DBL_TYPE(dst->type)) {
-                               M_FLTMOVE(dtmpreg, dst->vv.regoff);
-                       } else if (IS_2_WORD_TYPE(dst->type)) {
-                               M_LNGMOVE(dtmpreg, dst->vv.regoff);
-                       } else {
-                               M_INTMOVE(dtmpreg, dst->vv.regoff);
-                       }
-               }
+               /* Save program counter and jump over displacement in instruction flow */
+               N_BRAS(REG_PV, SZ_BRAS + SZ_LONG);
+               /* Place displacement here */
+               /* REG_PV points now exactly to this position */
+               N_LONG(offset + SZ_BRAS);
+               /* Substract *(REG_PV) from REG_PV */
+               N_S(REG_PV, 0, RN, REG_PV);
        }
 }
 
index 2396195e226ccaf5596f7f78db8b1f08d739a5aa..a8d6654001deedd6ebc1c15708ac32b8e53b4a44 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: emit.h 7616 2007-03-29 23:21:50Z michi $
+   $Id: emit.h 7848 2007-05-01 21:40:26Z pm $
 
 */
 
 
 /* macros to create code ******************************************************/
 
-/* immediate data union */
-
-typedef union {
-    s4 i;
-    s8 l;
-    float f;
-    double d;
-    void *a;
-    u1 b[8];
-} imm_buf;
-
-
-/* opcodes for alu instructions */
-
-#define ALU_ADD      0
-#define ALU_OR       1
-#define ALU_ADC      2
-#define ALU_SBB      3
-#define ALU_AND      4
-#define ALU_SUB      5
-#define ALU_XOR      6
-#define ALU_CMP      7
-
-
-#define SHIFT_ROL    0
-#define SHIFT_ROR    1
-#define SHIFT_RCL    2
-#define SHIFT_RCR    3
-#define SHIFT_SHL    4
-#define SHIFT_SHR    5
-#define SHIFT_SAR    7
-
-#if 0
-#define CC_O         0
-#define CC_NO        1
-#define CC_B         2
-#define CC_C         2
-#define CC_NAE       2
-#define CC_AE        3
-#define CC_NB        3
-#define CC_NC        3
-#define CC_E         4
-#define CC_Z         4
-#define CC_NE        5
-#define CC_NZ        5
-#define CC_BE        6
-#define CC_NA        6
-#define CC_A         7
-#define CC_NBE       7
-#define CC_S         8
-#define CC_LZ        8
-#define CC_NS        9
-#define CC_GEZ       9
-#define CC_P         0x0a
-#define CC_PE        0x0a
-#define CC_NP        0x0b
-#define CC_PO        0x0b
-#define CC_L         0x0c
-#define CC_NGE       0x0c
-#define CC_GE        0x0d
-#define CC_NL        0x0d
-#define CC_LE        0x0e
-#define CC_NG        0x0e
-#define CC_G         0x0f
-#define CC_NLE       0x0f
-#endif
-
-
-/* modrm and stuff */
-
-#define emit_address_byte(mod,reg,rm) \
-    do { \
-        *(cd->mcodeptr++) = ((((mod) & 0x03) << 6) | (((reg) & 0x07) << 3) | ((rm) & 0x07)); \
-    } while (0);
-
-
-#define emit_rex(size,reg,index,rm) \
-    do { \
-        if (((size) == 1) || ((reg) > 7) || ((index) > 7) || ((rm) > 7)) \
-            *(cd->mcodeptr++) = (0x40 | (((size) & 0x01) << 3) | ((((reg) >> 3) & 0x01) << 2) | ((((index) >> 3) & 0x01) << 1) | (((rm) >> 3) & 0x01)); \
-    } while (0)
-
-
-#define emit_byte_rex(reg,index,rm) \
-    do { \
-        *(cd->mcodeptr++) = (0x40 | ((((reg) >> 3) & 0x01) << 2) | ((((index) >> 3) & 0x01) << 1) | (((rm) >> 3) & 0x01)); \
-    } while (0)
-
-
-#define emit_mem(r,disp) \
-    do { \
-        emit_address_byte(0,(r),5); \
-        emit_imm32((disp)); \
-    } while (0)
-
-
-#define emit_imm8(imm) \
-    do { \
-        *(cd->mcodeptr++) = (u1) ((imm) & 0xff); \
-    } while (0)
-
-
-#define emit_imm16(imm) \
-    do { \
-        imm_buf imb; \
-        imb.i = (s4) (imm); \
-        *(cd->mcodeptr++) = imb.b[0]; \
-        *(cd->mcodeptr++) = imb.b[1]; \
-    } while (0)
-
-
-#define emit_imm32(imm) \
-    do { \
-        imm_buf imb; \
-        imb.i = (s4) (imm); \
-        *(cd->mcodeptr++) = imb.b[0]; \
-        *(cd->mcodeptr++) = imb.b[1]; \
-        *(cd->mcodeptr++) = imb.b[2]; \
-        *(cd->mcodeptr++) = imb.b[3]; \
-    } while (0)
-
-
-#define emit_imm64(imm) \
-    do { \
-        imm_buf imb; \
-        imb.l = (s8) (imm); \
-        *(cd->mcodeptr++) = imb.b[0]; \
-        *(cd->mcodeptr++) = imb.b[1]; \
-        *(cd->mcodeptr++) = imb.b[2]; \
-        *(cd->mcodeptr++) = imb.b[3]; \
-        *(cd->mcodeptr++) = imb.b[4]; \
-        *(cd->mcodeptr++) = imb.b[5]; \
-        *(cd->mcodeptr++) = imb.b[6]; \
-        *(cd->mcodeptr++) = imb.b[7]; \
-    } while (0)
-
-
-/* convenience macros *********************************************************/
-
-#define emit_reg(reg,rm)                emit_address_byte(3,(reg),(rm))
-
-
-/* function prototypes ********************************************************/
-
-void emit_cmovxx(codegendata *cd, instruction *iptr, s4 s, s4 d);
-
-
-/* code generation prototypes */
-
-void emit_ishift(jitdata *jd, s4 shift_op, instruction *iptr);
-void emit_lshift(jitdata *jd, s4 shift_op, instruction *iptr);
-
-
-/* integer instructions */
-
-void emit_mov_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_mov_imm_reg(codegendata *cd, s8 imm, s8 reg);
-void emit_movl_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movl_imm_reg(codegendata *cd, s8 imm, s8 reg);
-void emit_mov_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg);
-void emit_mov_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg);
-void emit_movl_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg);
-void emit_movl_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg);
-void emit_mov_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_mov_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movl_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movl_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_mov_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg);
-void emit_movl_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg);
-void emit_mov_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_movl_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_movw_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_movb_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_mov_imm_membase(codegendata *cd, s8 imm, s8 basereg, s8 disp);
-void emit_mov_imm_membase32(codegendata *cd, s8 imm, s8 basereg, s8 disp);
-void emit_movl_imm_membase(codegendata *cd, s8 imm, s8 basereg, s8 disp);
-void emit_movl_imm_membase32(codegendata *cd, s8 imm, s8 basereg, s8 disp);
-void emit_movsbq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movsbq_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movswq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movswq_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movslq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movslq_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movzwq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movzwq_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movswq_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg);
-void emit_movsbq_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg);
-void emit_movzwq_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 reg);
-void emit_mov_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale);
-void emit_movl_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale);
-void emit_movw_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale);
-void emit_movb_imm_memindex(codegendata *cd, s4 imm, s4 disp, s4 basereg, s4 indexreg, s4 scale);
-void emit_alu_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg);
-void emit_alul_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg);
-void emit_alu_reg_membase(codegendata *cd, s8 opc, s8 reg, s8 basereg, s8 disp);
-void emit_alul_reg_membase(codegendata *cd, s8 opc, s8 reg, s8 basereg, s8 disp);
-void emit_alu_membase_reg(codegendata *cd, s8 opc, s8 basereg, s8 disp, s8 reg);
-void emit_alul_membase_reg(codegendata *cd, s8 opc, s8 basereg, s8 disp, s8 reg);
-void emit_alu_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg);
-void emit_alu_imm32_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg);
-void emit_alul_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg);
-void emit_alu_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp);
-void emit_alul_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp);
-void emit_test_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_testl_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_test_imm_reg(codegendata *cd, s8 imm, s8 reg);
-void emit_testw_imm_reg(codegendata *cd, s8 imm, s8 reg);
-void emit_testb_imm_reg(codegendata *cd, s8 imm, s8 reg);
-void emit_lea_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg);
-void emit_leal_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 reg);
-
-void emit_incl_membase(codegendata *cd, s8 basereg, s8 disp);
-
-void emit_cltd(codegendata *cd);
-void emit_cqto(codegendata *cd);
-void emit_imul_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_imull_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_imul_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_imull_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_imul_imm_reg(codegendata *cd, s8 imm, s8 dreg);
-void emit_imul_imm_reg_reg(codegendata *cd, s8 imm,s8 reg, s8 dreg);
-void emit_imull_imm_reg_reg(codegendata *cd, s8 imm, s8 reg, s8 dreg);
-void emit_imul_imm_membase_reg(codegendata *cd, s8 imm, s8 basereg, s8 disp, s8 dreg);
-void emit_imull_imm_membase_reg(codegendata *cd, s8 imm, s8 basereg, s8 disp, s8 dreg);
-void emit_idiv_reg(codegendata *cd, s8 reg);
-void emit_idivl_reg(codegendata *cd, s8 reg);
-void emit_ret(codegendata *cd);
-void emit_shift_reg(codegendata *cd, s8 opc, s8 reg);
-void emit_shiftl_reg(codegendata *cd, s8 opc, s8 reg);
-void emit_shift_membase(codegendata *cd, s8 opc, s8 basereg, s8 disp);
-void emit_shiftl_membase(codegendata *cd, s8 opc, s8 basereg, s8 disp);
-void emit_shift_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg);
-void emit_shiftl_imm_reg(codegendata *cd, s8 opc, s8 imm, s8 dreg);
-void emit_shift_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp);
-void emit_shiftl_imm_membase(codegendata *cd, s8 opc, s8 imm, s8 basereg, s8 disp);
-void emit_jmp_imm(codegendata *cd, s8 imm);
-void emit_jmp_reg(codegendata *cd, s8 reg);
-void emit_jcc(codegendata *cd, s8 opc, s8 imm);
-void emit_setcc_reg(codegendata *cd, s8 opc, s8 reg);
-void emit_setcc_membase(codegendata *cd, s8 opc, s8 basereg, s8 disp);
-void emit_cmovcc_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg);
-void emit_cmovccl_reg_reg(codegendata *cd, s8 opc, s8 reg, s8 dreg);
-void emit_neg_reg(codegendata *cd, s8 reg);
-void emit_negl_reg(codegendata *cd, s8 reg);
-void emit_neg_membase(codegendata *cd, s8 basereg, s8 disp);
-void emit_negl_membase(codegendata *cd, s8 basereg, s8 disp);
-void emit_push_reg(codegendata *cd, s8 reg);
-void emit_push_imm(codegendata *cd, s8 imm);
-void emit_pop_reg(codegendata *cd, s8 reg);
-void emit_xchg_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_nop(codegendata *cd);
-void emit_call_reg(codegendata *cd, s8 reg);
-void emit_call_imm(codegendata *cd, s8 imm);
-void emit_call_mem(codegendata *cd, ptrint mem);
-
-
-/* floating point instructions (SSE2) */
-
-void emit_addsd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_addss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvtsi2ssq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvtsi2ss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvtsi2sdq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvtsi2sd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvtss2sd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvtsd2ss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvttss2siq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvttss2si_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvttsd2siq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_cvttsd2si_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_divss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_divsd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movd_reg_freg(codegendata *cd, s8 reg, s8 freg);
-void emit_movd_freg_reg(codegendata *cd, s8 freg, s8 reg);
-void emit_movd_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movd_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_movd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movdl_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movd_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 dreg);
-void emit_movq_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movq_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movq_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movsd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_movss_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movss_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movsd_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movsd_reg_membase32(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movss_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movss_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movlps_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movlps_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movsd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movsd_membase32_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movlpd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_movlpd_reg_membase(codegendata *cd, s8 reg, s8 basereg, s8 disp);
-void emit_movss_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_movsd_reg_memindex(codegendata *cd, s8 reg, s8 disp, s8 basereg, s8 indexreg, s8 scale);
-void emit_movss_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 dreg);
-void emit_movsd_memindex_reg(codegendata *cd, s8 disp, s8 basereg, s8 indexreg, s8 scale, s8 dreg);
-void emit_mulss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_mulsd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_subss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_subsd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_ucomiss_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_ucomisd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_xorps_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_xorps_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-void emit_xorpd_reg_reg(codegendata *cd, s8 reg, s8 dreg);
-void emit_xorpd_membase_reg(codegendata *cd, s8 basereg, s8 disp, s8 dreg);
-
-
-/* system instructions ********************************************************/
-
-void emit_rdtsc(codegendata *cd);
-
 s4 emit_load_s1_notzero(jitdata *jd, instruction *iptr, s4 tempreg);
 s4 emit_load_s2_notzero(jitdata *jd, instruction *iptr, s4 tempreg);
 
@@ -376,6 +60,9 @@ void emit_restore_dst_even_odd(jitdata *jd, instruction *iptr, s4 htmpreg, s4 lt
  */
 void emit_copy_dst(jitdata *jd, instruction *iptr, s4 dtmpreg);
 
+/* Emits code to recalculate the PV (procedure vector) after a subroutine call. */
+void emit_restore_pv(codegendata *cd);
+
 #endif /* _MD_EMIT_H */
 
 
index a9164c7803a2fab7b99e45e0b4b585efa23a8798..2cbe506318be2eae6b05206391187b2e02df6099 100644 (file)
@@ -1,42 +1,79 @@
 #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
+ */
+
+#define __CS_LOOP(ptr, op_val, op_string) ({                           \
+       int old_val, new_val;                           \
+        __asm__ __volatile__("   l     %0,0(%3)\n"                     \
+                             "0: lr    %1,%0\n"                                \
+                             op_string "  %1,%4\n"                     \
+                             "   cs    %0,%1,0(%3)\n"                  \
+                             "   jl    0b"                             \
+                             : "=&d" (old_val), "=&d" (new_val),       \
+                              "=m" (*ptr)      \
+                            : "a" (ptr), "d" (op_val),                 \
+                              "m" (*ptr)       \
+                            : "cc", "memory" );                        \
+       new_val;                                                        \
+})
+
 static inline void
-__attribute__ ((unused))
 atomic_add (volatile int *mem, int val)
 {
-#if 0
-  __asm__ __volatile__ ("lock; addl %1,%0"
-                                               : "=m" (*mem) 
-                                               : "ir" (val), "m" (*mem));
-#endif
+       __CS_LOOP(mem, val, "ar");
 }
 
 static inline long
-__attribute__ ((unused))
 compare_and_swap (volatile long *p, long oldval, long newval)
 {
-#if 0
-  long ret;
-
-  __asm__ __volatile__ ("lock; cmpxchgq %2, %1"
-                        : "=a" (ret), "=m" (*p)
-                        : "r" (newval), "m" (*p), "0" (oldval));
-  return ret;
-#endif
+       __asm__ __volatile__("  cs   %0,%3,0(%2)\n"
+                            : "+d" (oldval), "=m" (*p)
+                            : "a" (p), "d" (newval), "m" (*p)
+                            : "cc", "memory" );
+       return oldval;
 }
 
-#if 0
-#define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_BEFORE_ATOMIC() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("" : : : "memory");
-#define MEMORY_BARRIER() __asm__ __volatile__ ( \
-               "mfence" : : : "memory" )
-#endif
+/*
+ *  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 STORE_ORDER_BARRIER()
-#define MEMORY_BARRIER_BEFORE_ATOMIC()
-#define MEMORY_BARRIER_AFTER_ATOMIC()
-#define MEMORY_BARRIER()
+#define MEMORY_BARRIER_BEFORE_ATOMIC() eieio()
+#define MEMORY_BARRIER_AFTER_ATOMIC() eieio()
 
 #endif
index 4cc4992c6fb6344395203d96ebc2fc8b17bc61ea..60bb4ce6dd8711a7d1f7b20ef7f0679e1e404be0 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md-abi.c 7581 2007-03-26 07:23:16Z pm $
+   $Id: md-abi.c 7839 2007-04-29 22:46:56Z pm $
 
 */
 
@@ -88,7 +88,7 @@ s4 nregdescfloat[] = {
 
 const s4 abi_registers_float_argument[] = {
        0, /* f0/fa0 */
-       1  /* f2/fa2 */
+       2  /* f2/fa2 */
 };
 
 const s4 abi_registers_float_saved[] = {
@@ -141,8 +141,7 @@ void md_param_alloc(methoddesc *md)
                case TYPE_ADR:
                        if (iarg < INT_ARG_CNT) {
                                pd->inmemory  = false;
-/*                             pd->regoff    = abi_registers_integer_argument[iarg]; */
-                               pd->regoff    = iarg;
+                               pd->regoff    = abi_registers_integer_argument[iarg]; 
                                iarg++;
                        }
                        else {
@@ -156,10 +155,9 @@ void md_param_alloc(methoddesc *md)
                        if (iarg < INT_ARG_CNT - 1) {
                                /* _ALIGN(iarg); */
                                pd->inmemory  = false;
-/*                             pd->regoff    = */
-/*                                     PACK_REGS(abi_registers_integer_argument[iarg + 1], */
-/*                                                       abi_registers_integer_argument[iarg]); */
-                               pd->regoff    = PACK_REGS(iarg + 1, iarg);
+                               pd->regoff    = 
+                                       PACK_REGS(abi_registers_integer_argument[iarg + 1], 
+                                                         abi_registers_integer_argument[iarg]); 
                                iarg += 2;
                        }
                        else {
@@ -174,8 +172,7 @@ void md_param_alloc(methoddesc *md)
                case TYPE_FLT:
                        if (farg < FLT_ARG_CNT) {
                                pd->inmemory  = false;
-/*                             pd->regoff    = abi_registers_float_argument[farg]; */
-                               pd->regoff    = farg;
+                               pd->regoff    = abi_registers_float_argument[farg]; 
                                farg++;
                        }
                        else {
@@ -188,8 +185,7 @@ void md_param_alloc(methoddesc *md)
                case TYPE_DBL:
                        if (farg < FLT_ARG_CNT) {
                                pd->inmemory  = false;
-/*                             pd->regoff    = abi_registers_integer_argument[farg]; */
-                               pd->regoff    = farg;
+                               pd->regoff    = abi_registers_float_argument[farg]; 
                                farg++;
                        }
                        else {
@@ -205,7 +201,7 @@ void md_param_alloc(methoddesc *md)
                }
        }
 
-       /* Since R3/R4, F1 (==A0/A1, A0) are used for passing return
+       /* Since A0+A1/FA0 are used for passing return
           values, this argument register usage has to be regarded,
           too. */
 
index 16dfc515d4e6f76fb47422e8331c561b060f582c..83db8ebed5151fd54ece1ca51663a807f864c31b 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md-abi.h 7680 2007-04-10 05:02:20Z pm $
+   $Id: md-abi.h 7839 2007-04-29 22:46:56Z pm $
 
 */
 
 #ifndef _MD_ABI_H
 #define _MD_ABI_H
 
-/* keep old code happy */
-
-#define RIP    -1
-#define RAX    0
-#define RCX    1
-#define RDX    2
-#define RBX    3
-#define RSP    4
-#define RBP    5
-#define RSI    6
-#define RDI    7
-#define R8     8
-#define R9     9
-#define R10    10
-#define R11    11
-#define R12    12
-#define R13    13
-#define R14    14
-#define R15    15
-
-
-#define XMM0   0
-#define XMM1   1
-#define XMM2   2
-#define XMM3   3
-#define XMM4   4
-#define XMM5   5
-#define XMM6   6
-#define XMM7   7
-#define XMM8   8
-#define XMM9   9
-#define XMM10  10
-#define XMM11  11
-#define XMM12  12
-#define XMM13  13
-#define XMM14  14
-#define XMM15  15
-
-
-
 /* define registers ***********************************************************/
 
 #define R0     0
 
 #define REG_FTMP1       F4       /* temporary floating point register         */
 #define REG_FTMP2       F6       /* temporary floating point register         */
-/* No ftmp3 */
-/* #define REG_FTMP3       F5 */       /* temporary floating point register         */
 
+/* No ftmp3 */
 
 #define INT_REG_CNT     16       /* number of integer registers               */
 #define INT_SAV_CNT     5        /* number of integer callee saved registers  */
 
 #define TRACE_ARGS_NUM  8
 
-
-
-
-
-
-
-
-
-
-
-
 #endif /* _MD_ABI_H */
 
 
index 271c0f7c316e3486f5428949841b0563733470c1..9cfd3ee5ee88001a6583f9c063b22038f0676eb7 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: md-asm.h 7486 2007-03-08 13:50:07Z twisti $
+   $Id: md-asm.h 7839 2007-04-29 22:46:56Z pm $
 
 */
 
 
 /* register defines ***********************************************************/
 
-#if 0
-
-#define v0       %rax
-#define v0l      %eax
-#define itmp1    v0
-
-#define a3       %rcx
-#define a2       %rdx
-
-#define t0       %rbx
-#define t0l      %ebx
-
-#define sp       %rsp
-#define s0       %rbp
-
-#define a1       %rsi
-#define a0       %rdi
-#define a0l      %edi
-
-#define a4       %r8
-#define a5       %r9
-
-#define itmp2    %r10
-#define itmp3    %r14
-
-#define s1       %r12
-#define s2       %r13
-#define s3       %r14
-#define s4       %r15
-
-
-#define bp       s0
-
-#define itmp1l   %eax
-#define itmp2l   %r10d
-#define itmp3l   %r11d
-
-#define xptr     itmp1
-#define xpc      itmp2
-#define mptr     itmp2
-
-
-#define fa0      %xmm0
-#define fa1      %xmm1
-#define fa2      %xmm2
-#define fa3      %xmm3
-#define fa4      %xmm4
-#define fa5      %xmm5
-#define fa6      %xmm6
-#define fa7      %xmm7
-
-#define ftmp1    %xmm8
-#define ftmp2    %xmm9
-#define ftmp3    %xmm10
-
-#define ft0      %xmm11
-#define ft1      %xmm12
-#define ft2      %xmm13
-#define ft3      %xmm14
-#define ft4      %xmm15
-
-#endif
-
 #define a0       %r2
 #define a1       %r3
 #define a2       %r4
 
 /* save and restore macros ****************************************************/
 
-#define SAVE_ARGUMENT_REGISTERS(off) \
-       mov     a0,(0+(off))*8(sp)   ; \
-       mov     a1,(1+(off))*8(sp)   ; \
-       mov     a2,(2+(off))*8(sp)   ; \
-       mov     a3,(3+(off))*8(sp)   ; \
-       mov     a4,(4+(off))*8(sp)   ; \
-       mov     a5,(5+(off))*8(sp)   ; \
-       \
-       movq    fa0,(6+(off))*8(sp)  ; \
-       movq    fa1,(7+(off))*8(sp)  ; \
-       movq    fa2,(8+(off))*8(sp)  ; \
-       movq    fa3,(9+(off))*8(sp)  ; \
-       movq    fa4,(10+(off))*8(sp) ; \
-       movq    fa5,(11+(off))*8(sp) ; \
-       movq    fa6,(12+(off))*8(sp) ; \
-       movq    fa7,(13+(off))*8(sp) ;
-
-
-#define RESTORE_ARGUMENT_REGISTERS(off) \
-       mov     (0+(off))*8(sp),a0   ; \
-       mov     (1+(off))*8(sp),a1   ; \
-       mov     (2+(off))*8(sp),a2   ; \
-       mov     (3+(off))*8(sp),a3   ; \
-       mov     (4+(off))*8(sp),a4   ; \
-       mov     (5+(off))*8(sp),a5   ; \
-       \
-       movq    (6+(off))*8(sp),fa0  ; \
-       movq    (7+(off))*8(sp),fa1  ; \
-       movq    (8+(off))*8(sp),fa2  ; \
-       movq    (9+(off))*8(sp),fa3  ; \
-       movq    (10+(off))*8(sp),fa4 ; \
-       movq    (11+(off))*8(sp),fa5 ; \
-       movq    (12+(off))*8(sp),fa6 ; \
-       movq    (13+(off))*8(sp),fa7 ;
-
-
-#define SAVE_TEMPORARY_REGISTERS(off) \
-       mov     t0,(0+(off))*8(sp)   ; \
-       movq    ft0,(1+(off))*8(sp)  ; \
-       movq    ft1,(2+(off))*8(sp)  ; \
-       movq    ft2,(3+(off))*8(sp)  ; \
-       movq    ft3,(4+(off))*8(sp)  ;
-
-
-#define RESTORE_TEMPORARY_REGISTERS(off) \
-       mov     (0+(off))*8(sp),t0   ; \
-       movq    (1+(off))*8(sp),ft0  ; \
-       movq    (2+(off))*8(sp),ft1  ; \
-       movq    (3+(off))*8(sp),ft2  ; \
-       movq    (4+(off))*8(sp),ft3  ;
-
 /* Volatile float registers (all volatile in terms of C abi) */
 
 #define LOAD_STORE_VOLATILE_FLOAT_REGISTERS(inst, off) \
index e3d250353b175726564b2aa8bd535bea699f3e68..6129ff20a1db309d808130c084cb6b6cd47a9d6b 100644 (file)
 
    Changes: Edwin Steiner
 
-   $Id: md.c 7581 2007-03-26 07:23:16Z pm $
+   $Id: md.c 7848 2007-05-01 21:40:26Z pm $
 
 */
 
-#define REG_RSP 0
-#define REG_RIP 0
-#define REG_RAX 0
-#define REG_R10 0
-#define REG_RIP 0
-#define REG_RSP 0
-#define REG_RIP 0
-#define REG_RAX 0
-#define REG_R10 0
-#define REG_RIP 0
-
-
 #define _GNU_SOURCE
 
 #include "config.h"
@@ -55,6 +43,7 @@
 #include "vm/jit/s390/md-abi.h"
 
 #if defined(ENABLE_THREADS)
+# include "threads/threads-common.h"
 # include "threads/native/threads.h"
 #endif
 
 #include <assert.h>
 #define OOPS() assert(0);
 
+/* prototypes *****************************************************************/
+
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p);
+
+void md_dump_context(u1 *pc, mcontext_t *mc);
+
 /* md_init *********************************************************************
 
    Do some machine dependent initialization.
 
 void md_init(void)
 {
-       /* nothing to do */
+       struct sigaction act;
+       
+       act.sa_sigaction = md_signal_handler_sigill;
+       act.sa_flags     = SA_NODEFER | SA_SIGINFO;
+
+       if (sigaction(SIGILL, &act, NULL) == -1)        {
+               vm_abort("%s: error registering SIGILL signal handler.", __FUNCTION__);
+       }
 }
 
+/* md_dump_context ************************************************************
+   Logs the machine context
+  
+*******************************************************************************/
+
+void md_dump_context(u1 *pc, mcontext_t *mc) {
+       int i;
+       
+       union {
+               u8 l;
+               fpreg_t fr;
+       } freg;
+
+       log_println("Dumping context.");
+
+       log_println("Program counter: 0x%08X", pc);
+
+#if defined(ENABLE_DISASSEMBLER)
+       log_println("Printing instruction at program counter:");
+       disassinstr(pc);
+#endif
+
+       log_println("General purpose registers:");
+
+       for (i = 0; i < 16; i++) {
+               log_println("\tr%d:\t0x%08X\t%d", i, mc->gregs[i], mc->gregs[i]);
+       }
+
+       log_println("Floating point registers:");
+
+       for (i = 0; i < 16; i++) {
+               freg.fr.d = mc->fpregs.fprs[i].d;
+               log_println("\tf%d\t0x%016llX\t(double)%e\t(float)%f", i, freg.l, freg.fr.d, freg.fr.f);
+       }
+
+#if defined(ENABLE_THREADS)
+       log_println("Dumping the current stacktrace:");
+       threads_print_stacktrace();
+#endif
+
+}
 
 /* md_signal_handler_sigsegv ***************************************************
 
@@ -95,35 +139,102 @@ void md_init(void)
 
 void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t *_uc;
-       mcontext_t *_mc;
-       u1         *sp;
-       u1         *ra;
-       u1         *xpc;
+       ucontext_t        *_uc;
+       mcontext_t        *_mc;
+       u1                *pv;
+       u1                *sp;
+       u1                *ra;
+       u1                *xpc;
+       s4                 type;
+       ptrint             val;
+       java_objectheader *e;
+       s4                 base;
+       s4                 is_null;
 
        _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 <ucontext.h>. */
-
-       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 */
+       xpc = (u1 *)_mc->psw.addr;
+
+       /* Check opcodes and verify it is a null pointer exception */
+
+       switch (xpc[0]) {
+               case 0x58: /* L */
+               case 0x50: /* ST */
+                       base = (xpc[2] >> 4) & 0xF;
+                       if (base == 0) {
+                               is_null = 1;
+                       } else if (_mc->gregs[base] == 0) {
+                               is_null = 1;
+                       } else {
+                               is_null = 0;
+                       }
+                       break;
+       }
 
-       threads_check_stackoverflow(sp);
+       if (! is_null) {
+#if !defined(NDEBUG)
+               md_dump_context(xpc, _mc);
 #endif
+               vm_abort("%s: segmentation fault at %p, aborting.", __FUNCTION__, xpc);
+       }
+
+       pv = (u1 *)_mc->gregs[REG_PV];
+       sp = (u1 *)_mc->gregs[REG_SP];
+       ra = xpc;
+       type = EXCEPTION_HARDWARE_NULLPOINTER;
+       val = 0;
 
-       _mc->gregs[REG_RAX] =
-               (ptrint) stacktrace_hardware_nullpointerexception(NULL, sp, ra, xpc);
+       e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
 
-       _mc->gregs[REG_R10] = (ptrint) xpc;                      /* REG_ITMP2_XPC */
-       _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
+       _mc->gregs[REG_ITMP2_XPC] = (ptrint) xpc;
+       _mc->gregs[REG_ITMP1_XPTR] = (ptrint) e;
+       _mc->psw.addr = (ptrint) asm_handle_exception;
 }
 
+void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p) {
+       ucontext_t        *_uc;
+       mcontext_t        *_mc;
+       u1                *xpc;
+       u1                *ra;
+       u1                *pv;
+       u1                *sp;
+       s4                 type;
+       ptrint             val;
+       java_objectheader *e;
+       s4                 reg;
+
+       _uc = (ucontext_t *) _p;
+       _mc = &_uc->uc_mcontext;
+       xpc = ra = siginfo->si_addr;
+
+       /* Our trap instruction has the format: { 0x02, one_byte_of_data }. */
+
+       if ((siginfo->si_code == ILL_ILLOPC) && (xpc[0] == 0x02)) {
+
+               /* bits 7-4 contain a register holding a value */
+               reg = (xpc[1] >> 4) & 0xF;
+
+               /* bits 3-0 designate the exception type */
+               type = xpc[1] & 0xF;  
+
+               pv = (u1 *)_mc->gregs[REG_PV];
+               sp = (u1 *)_mc->gregs[REG_SP];
+               val = (ptrint)_mc->gregs[reg];
+
+               e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
+
+               _mc->gregs[REG_ITMP1_XPTR] = (ptrint)e;
+               _mc->gregs[REG_ITMP2_XPC] = (ptrint)xpc;
+               _mc->psw.addr = (ptrint) asm_handle_exception;
+
+       } else {
+#if !defined(NDEBUG)
+               md_dump_context(xpc, _mc);
+#endif
+               vm_abort("%s: illegal instruction at %p, aborting.", __FUNCTION__, xpc);
+       }
+}
 
 /* md_signal_handler_sigfpe ****************************************************
 
@@ -134,27 +245,73 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
 void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
 {
-       ucontext_t  *_uc;
-       mcontext_t  *_mc;
-       u1          *sp;
-       u1          *ra;
-       u1          *xpc;
+       ucontext_t         *_uc;
+       mcontext_t         *_mc;
+       u1                 *pv;
+       u1                 *sp;
+       u1                 *ra;
+       u1                 *xpc;
+       u1                 *pc;
+       s4                  r1, r2;
+       s4                  type;
+       ptrint              val;
+       java_objectheader  *e;
 
        _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 <ucontext.h>. */
+       /* Instruction that raised signal */
+       xpc = siginfo->si_addr;
+
+       /* Check opcodes */
+
+       if (xpc[0] == 0x1D) { /* DR */
+
+               r1 = (xpc[1] >> 4) & 0xF;
+               r2 = xpc[1] & 0xF;
+
+               if (
+                       (_mc->gregs[r1] == 0xFFFFFFFF) &&
+                       (_mc->gregs[r1 + 1] == 0x80000000) && 
+                       (_mc->gregs[r2] == 0xFFFFFFFF)
+               ) {
+                       /* handle special case */
+                       /* next instruction */
+                       pc = (u1 *)_mc->psw.addr;
+                       /* reminder */
+                       _mc->gregs[r1] = 0;
+                       /* quotient */
+                       _mc->gregs[r1 + 1] = 0x80000000;
+                       /* continue at next instruction */
+                       _mc->psw.addr = (ptrint) pc;
 
-       sp  = (u1 *) _mc->gregs[REG_RSP];
-       xpc = (u1 *) _mc->gregs[REG_RIP];
-       ra  = xpc;                          /* return address is equal to xpc     */
+                       return;
+               } else if (_mc->gregs[r2] == 0) {
+                       /* division by 0 */
 
-       _mc->gregs[REG_RAX] =
-               (ptrint) stacktrace_hardware_arithmeticexception(NULL, sp, ra, xpc);
+                       pv = (u1 *)_mc->gregs[REG_PV];
+                       sp = (u1 *)_mc->gregs[REG_SP];
+                       ra = xpc;
 
-       _mc->gregs[REG_R10] = (ptrint) xpc;                      /* REG_ITMP2_XPC */
-       _mc->gregs[REG_RIP] = (ptrint) asm_handle_exception;
+                       type = EXCEPTION_HARDWARE_ARITHMETIC;
+                       val = 0;
+
+                       e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
+
+                       _mc->gregs[REG_ITMP1_XPTR] = (ptrint)e;
+                       _mc->gregs[REG_ITMP2_XPC] = (ptrint)xpc;
+                       _mc->psw.addr = (ptrint) asm_handle_exception;
+
+                       return;
+               }
+       }
+
+       /* Could not handle signal */
+
+#if !defined(NDEBUG)
+       md_dump_context(xpc, _mc);
+#endif
+       vm_abort("%s: floating point exception at %p, aborting.", __FUNCTION__, xpc);
 }
 
 
@@ -180,7 +337,7 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
        /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
           different to the ones in <ucontext.h>. */
 
-       pc = (u1 *) _mc->gregs[REG_RIP];
+       pc = (u1 *) _mc->psw.addr;
 
        t->pc = pc;
 }
@@ -195,10 +352,10 @@ void thread_restartcriticalsection(ucontext_t *_uc)
 
        _mc = &_uc->uc_mcontext;
 
-       pc = critical_find_restart_point((void *) _mc->gregs[REG_RIP]);
+       pc = critical_find_restart_point((void *) _mc->psw.addr);
 
        if (pc != NULL)
-               _mc->gregs[REG_RIP] = (ptrint) pc;
+               _mc->psw.addr = (ptrint) pc;
 }
 #endif
 
index 74a38211837300af907f4b979ab55ce1a45775c2..7b06b708e8a0cd3112b899402cf21adeed068fa6 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 7581 2007-03-26 07:23:16Z pm $
+   $Id: patcher.c 7839 2007-04-29 22:46:56Z pm $
 
 */
 
@@ -807,12 +807,20 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
                case REG_ITMP1: 
                        /* First M_ALD is into ITMP1 */
                        /* INSTANCEOF code */
+
+                       *(u4 *)(ra + SZ_L + SZ_L) |= (u2)(s2)(- c->index);
+                       *(u4 *)(ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC) |=
+                               (u2)(s2)(OFFSET(vftbl_t, interfacetable[0]) -
+                                       c->index * sizeof(methodptr*));
+
+                       break;
+
                case REG_ITMP2:
-                       /* First M_ALD is into ITMP1 */
+                       /* First M_ALD is into ITMP2 */
                        /* CHECKCAST code */
 
                        *(u4 *)(ra + SZ_L + SZ_L) |= (u2)(s2)(- c->index);
-                       *(u4 *)(ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC) |=
+                       *(u4 *)(ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC + SZ_ILL) |=
                                (u2)(s2)(OFFSET(vftbl_t, interfacetable[0]) -
                                        c->index * sizeof(methodptr*));
 
diff --git a/src/vm/jit/schedule/.cvsignore b/src/vm/jit/schedule/.cvsignore
deleted file mode 100644 (file)
index cfca562..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
index d577b2b38d6d1cce92f9eacca9de2896879a6ead..12f28753f328db6c1be1f0cfd0d7de24a7f08841 100644 (file)
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/global.h"
 #include "vm/builtin.h"
@@ -83,7 +79,7 @@ bool show_init(void)
 
        show_global_lock = NEW(java_objectheader);
 
-       lock_init_object_lock(show_global_lock);
+       LOCK_INIT_OBJECT_LOCK(show_global_lock);
 #endif
 
        /* everything's ok */
diff --git a/src/vm/jit/sparc64/.cvsignore b/src/vm/jit/sparc64/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index 3afa0d92dd72bee69c80824c63dd8a2895f86192..ce7a16fda60822ab24b3c126edff6710207803b3 100644 (file)
@@ -96,47 +96,82 @@ asm_vm_call_method_long:
 asm_vm_call_method_float: 
 asm_vm_call_method_double:
        
-       save %sp,-144,%sp                                /* 16 reg-save + 2 */
+       save %sp,-((JITSTACK_CNT+2)*8),%sp
+       add %sp,JITSTACK,%l1               /* right above window save area */
 
 
-       /* %i2 not needed after _nocopy -> calculate in branch delay */
+       /* %i1 not needed after _nocopy -> calculate in branch delay */
 
        brlez %i1, calljava_nocopy
        
        dec %i1   /* branch delay */
        ldx [%i2 + offvmargdata],%o0
+       ldx [%i2 + offvmargtype],%l2
+       cmp %l2,2
+       be,a %xcc,calljava_arg0isfloat
+       ld  [%i2 + offvmargdata],fa0f   /* delay: annulled if branch not taken */
        ldd [%i2 + offvmargdata],fa0
+calljava_arg0isfloat:
        brlez %i1,calljava_nocopy
 
        dec %i1   /* branch delay */
        ldx [%i2 + (offvmargdata+sizevmarg*1)],%o1
+       ldx [%i2 + (offvmargtype+sizevmarg*1)],%l2
+       cmp %l2,2
+       be,a %xcc,calljava_arg1isfloat
+       ld  [%i2 + (offvmargdata+sizevmarg*1)],fa1f
        ldd [%i2 + (offvmargdata+sizevmarg*1)],fa1
+calljava_arg1isfloat:
        brlez %i1,calljava_nocopy
 
        dec %i1
        ldx [%i2 + (offvmargdata+sizevmarg*2)],%o2
+       ldx [%i2 + (offvmargtype+sizevmarg*2)],%l2
+       cmp %l2,2
+       be,a %xcc,calljava_arg2isfloat
+       ld  [%i2 + (offvmargdata+sizevmarg*2)],fa2f
        ldd [%i2 + (offvmargdata+sizevmarg*2)],fa2
+calljava_arg2isfloat:
        brlez %i1,calljava_nocopy
 
        dec %i1
        ldx [%i2 + (offvmargdata+sizevmarg*3)],%o3
+       ldx [%i2 + (offvmargtype+sizevmarg*3)],%l2
+       cmp %l2,2
+       be,a %xcc,calljava_arg3isfloat
+       ld  [%i2 + (offvmargdata+sizevmarg*3)],fa3f
        ldd [%i2 + (offvmargdata+sizevmarg*3)],fa3
+calljava_arg3isfloat:
        brlez %i1,calljava_nocopy
 
        dec %i1
        ldx [%i2 + (offvmargdata+sizevmarg*4)],%o4
+       ldx [%i2 + (offvmargtype+sizevmarg*4)],%l2
+       cmp %l2,2
+       be,a %xcc,calljava_arg4isfloat
+       ld  [%i2 + (offvmargdata+sizevmarg*4)],fa4f
        ldd [%i2 + (offvmargdata+sizevmarg*4)],fa4
+calljava_arg4isfloat:
 
 calljava_argsloaded:   
        brlez %i1, calljava_nocopy
        nop
        sllx %i1,3,%l0                     /* remaining args * 8           */
-       add %sp,16*8+bias,%l1              /* right above window save area */
        sub %sp,%l0,%sp                    /* allocate more stack space    */
+       add %sp,JITSTACK,%l1               /* adjust stack begin pointer   */
        
 calljava_copyloop:
+       ldx [%i2 + (offvmargtype+sizevmarg*5)],%l2
+       cmp %l2,2
+       be  %xcc,calljava_copyloop_float
+       nop
        ldx [%i2 + (offvmargdata+sizevmarg*5)],%l0
        stx %l0,[%l1]
+       b   calljava_copy_done
+calljava_copyloop_float:
+       ld  [%i2 + (offvmargdata+sizevmarg*5)],%f1      
+       std %f0,[%l1]
+calljava_copy_done:
        inc sizevmarg,%i2                  /* src++                        */
        subcc %i1,1,%i1                    /* arg_count--                  */
        bnz %xcc, calljava_copyloop        /* use cc from previous instr   */
@@ -151,8 +186,8 @@ calljava_nocopy:
        mov   %i0,itmp1         /* pass method info pointer via itmp1 */
        
        setx  asm_call_jit_compiler,%l0,mptr_itmp2  /* fake virtual function call (2 instr) */
-       stx   mptr_itmp2,[%sp + 2047 + 17*8]        /* store function address               */
-       add   %sp,2047 + 16*8,mptr_itmp2            /* set method pointer                   */
+       stx   mptr_itmp2,[%l1 + 1*8]        /* store function address               */
+       mov   %l1,mptr_itmp2            /* set method pointer                   */
        
        ldx  [1*8 + mptr_itmp2], pv_caller          /* method call as in Java               */
        jmpl pv_caller,ra_caller                      /* call JIT compiler          */
@@ -205,7 +240,8 @@ asm_vm_call_method_end:
 asm_call_jit_compiler:
        
        /* stacksave for regsave(16) + argslots(6) + float args  */
-       save    %sp,-((16+6+FLT_ARG_CNT)*8),%sp
+       /* Note: +1 to keep stack 16-byte aligned                */
+       save    %sp,-((16+6+FLT_ARG_CNT+1)*8),%sp
 
        SAVE_FLOAT_ARGUMENT_REGISTERS(22)
 
@@ -419,31 +455,6 @@ L_asm_patcher_wrapper_exception:
        nop
 
 
-asm_getclassvalues_atomic:
-_crit_restart:
-_crit_begin:
-/* not doing a window save, using the global temporary registers */
-       ldsw    [offbaseval+%o0],itmp1
-       ldsw    [offdiffval+%o0],itmp2
-       ldsw    [offbaseval+%o1],itmp3
-_crit_end:
-       stw     itmp1,[offcast_super_baseval+%o2]
-       stw     itmp2,[offcast_super_diffval+%o2]
-       stw     itmp3,[offcast_sub_baseval+%o2]
-       jmpl    ra_caller+8,zero  /* caller's ra, b/c no window save */
-       nop
-
-
-    .data
-
-asm_criticalsections:
-#if defined(ENABLE_THREADS)
-    .xword   _crit_begin
-    .xword   _crit_end
-    .xword   _crit_restart
-#endif
-    .xword   0
-    
     
 /* asm_store_fp_state_reg **************************************************
  *                                                                         *
@@ -476,6 +487,34 @@ asm_load_fp_state_reg:
        nop
 
 
+
+
+asm_getclassvalues_atomic:
+_crit_restart:
+_crit_begin:
+/* not doing a window save, using the global temporary registers */
+       ldsw    [offbaseval+%o0],itmp1
+       ldsw    [offdiffval+%o0],itmp2
+       ldsw    [offbaseval+%o1],itmp3
+_crit_end:
+       stw     itmp1,[offcast_super_baseval+%o2]
+       stw     itmp2,[offcast_super_diffval+%o2]
+       stw     itmp3,[offcast_sub_baseval+%o2]
+       jmpl    ra_caller+8,zero  /* caller's ra, b/c no window save */
+       nop
+
+
+    .data
+
+asm_criticalsections:
+#if defined(ENABLE_THREADS)
+    .xword   _crit_begin
+    .xword   _crit_end
+    .xword   _crit_restart
+#endif
+    .xword   0
+    
+
 /* disable exec-stacks ********************************************************/
 
 #if defined(__linux__) && defined(__ELF__)
index 5504b550c0a6759d2586fc91bd041bdfe20f0995..df4212e37183a491ab8972c64d3ff9750880a551 100644 (file)
@@ -109,7 +109,7 @@ bool codegen_emit(jitdata *jd)
        codeinfo           *code;
        codegendata        *cd;
        registerdata       *rd;
-       s4                  len, s1, s2, s3, d, disp;
+       s4                  len, s1, s2, s3, d, disp, slots;
        varinfo            *var;
        basicblock         *bptr;
        instruction        *iptr;
@@ -219,7 +219,55 @@ bool codegen_emit(jitdata *jd)
 #endif
        
        
-       
+               /* call monitorenter function */
+#if defined(ENABLE_THREADS)
+       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+               /* stack offset for monitor argument */
+
+               s1 = rd->memuse;
+
+               /* save float argument registers */
+
+               /* XXX jit-c-call */
+               slots = FLT_ARG_CNT;
+               ALIGN_STACK_SLOTS(slots);
+
+               M_LDA(REG_SP, REG_SP, -(slots * 8));
+               for (i = 0; i < FLT_ARG_CNT; i++)
+                       M_DST(abi_registers_float_argument[i], REG_SP, CSTACK +  i * 8);
+
+               s1 += slots;
+
+               /* get correct lock object */
+
+               if (m->flags & ACC_STATIC) {
+                       disp = dseg_add_address(cd, &m->class->object.header);
+                       M_ALD(REG_OUT0, REG_PV, disp);
+                       disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
+                       M_ALD(REG_ITMP3, REG_PV, disp);
+               }
+               else {
+                       /* copy class pointer: $i0 -> $o0 */
+                       M_MOV(REG_RESULT_CALLEE, REG_OUT0);
+                       M_BNEZ(REG_OUT0, 3);
+                       disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
+                       M_ALD(REG_ITMP3, REG_PV, disp);                   /* branch delay */
+                       M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER);
+               }
+
+               M_JMP(REG_RA_CALLER, REG_ITMP3, REG_ZERO);
+               M_AST(REG_OUT0, REG_SP, CSTACK + s1 * 8);             /* branch delay */
+
+               /* restore float argument registers */
+
+               for (i = 0; i < FLT_ARG_CNT; i++)
+                       M_DLD(abi_registers_float_argument[i], REG_SP, CSTACK + i * 8);
+
+               M_LDA(REG_SP, REG_SP, slots * 8);
+       }
+#endif
+
+
        /* take arguments out of register or stack frame */
        
        md = m->parseddesc;
@@ -310,9 +358,6 @@ bool codegen_emit(jitdata *jd)
                /* release scratch space */
                M_ADD_IMM(REG_SP, INT_ARG_CNT * 8, REG_SP);
        }
-       
-       
-       /* XXX monitor enter */
 
 
 
@@ -2207,24 +2252,32 @@ nowperformreturn:
 
 #if defined(ENABLE_THREADS)
                        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
-/* XXX: REG_RESULT is save, but what about FRESULT? */
-                               M_ALD(rd->argintregs[0], REG_SP, rd->memuse * 8); /* XXX: what for ? */
+                               /* XXX jit-c-call */
+                               disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
+                               M_ALD(REG_ITMP3, REG_PV, disp);
+
+                               /* we need to save fp return value (int saved by window) */
 
                                switch (iptr->opc) {
                                case ICMD_FRETURN:
                                case ICMD_DRETURN:
-                                       M_DST(REG_FRESULT, REG_SP, rd->memuse * 8);
-                                       break;
-                               }
+                                       M_ALD(REG_OUT0, REG_SP, CSTACK + rd->memuse * 8);
+                                       M_JMP(REG_RA_CALLER, REG_ITMP3, REG_ZERO);
+                                       M_DST(REG_FRESULT, REG_SP, CSTACK + rd->memuse * 8); /* delay */
 
-                               disp = dseg_add_functionptr(cd, BUILTIN_monitorexit);
-                               M_ALD(REG_ITMP3, REG_PV, disp);
-                               M_JMP(REG_RA_CALLER, REG_ITMP3, REG_ZERO); /*REG_RA_CALLER */
+                                       /* restore the fp return value */
 
-                               switch (iptr->opc) {
-                               case ICMD_FRETURN:
-                               case ICMD_DRETURN:
-                                       M_DLD(REG_FRESULT, REG_SP, rd->memuse * 8);
+                                       M_DLD(REG_FRESULT, REG_SP, CSTACK + rd->memuse * 8);
+                                       break;
+                               case ICMD_IRETURN:
+                               case ICMD_LRETURN:
+                               case ICMD_ARETURN:
+                               case ICMD_RETURN:
+                                       M_JMP(REG_RA_CALLER, REG_ITMP3, REG_ZERO);
+                                       M_ALD(REG_OUT0, REG_SP, CSTACK + rd->memuse * 8); /* delay */
+                                       break;
+                               default:
+                                       assert(false);
                                        break;
                                }
                        }
@@ -2431,10 +2484,7 @@ gen_method:
                                        }
                                        else {
                                                s1 = emit_load(jd, iptr, var, REG_FTMP1);
-                                               if (IS_2_WORD_TYPE(var->type))
-                                                       M_DST(s1, REG_SP, JITSTACK + d * 8);
-                                               else
-                                                       M_FST(s1, REG_SP, JITSTACK + d * 8);
+                                               M_DST(s1, REG_SP, JITSTACK + d * 8);
                                        }
                                }
                        }
@@ -2593,9 +2643,8 @@ gen_method:
                                        superindex = super->index;
                                }
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
+                                       CODEGEN_CRITICAL_SECTION_NEW;
 
                                s1 = emit_load_s1(jd, iptr, REG_ITMP1);
 
@@ -2666,17 +2715,17 @@ gen_method:
 
                                        M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl));
                                        M_ALD(REG_ITMP3, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                                       
+                                       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));
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        /*                              } */
                                        M_CMP(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_ULT, REG_ITMP3, s1);
@@ -2759,9 +2808,9 @@ gen_method:
                                supervftbl = super->vftbl;
                        }
 
-#if defined(ENABLE_THREADS)
-                       codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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) {
@@ -2836,15 +2885,15 @@ gen_method:
 
                                M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl));
                                M_ALD(REG_ITMP2, REG_PV, disp);
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               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));
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                               CODEGEN_CRITICAL_SECTION_END;
+
                                M_SUB(REG_ITMP1, REG_ITMP3, REG_ITMP1);
                                M_CMP(REG_ITMP1, REG_ITMP2);
                                M_XCMOVULE_IMM(1, d);
@@ -2991,6 +3040,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        s4            t;
        s4            s1, s2, disp;
        s4            funcdisp;             /* displacement of the function       */
+       s4            fltregarg_offset[FLT_ARG_CNT];
 
        /* get required compiler data */
 
@@ -3012,6 +3062,12 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                nmd->memuse +  /* nmd knows about the native stackframe layout */
                WINSAVE_CNT;
 
+
+       /* keep stack 16-byte aligned (ABI requirement) */
+
+       if (cd->stackframesize & 1)
+               cd->stackframesize++;
+
        /* create method header */
 
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
@@ -3042,11 +3098,15 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        }
 #endif
 
-       /* save float argument registers */
+       /* save float argument registers (into abi parameter slots) */
+
+       assert(ABIPARAMS_CNT >= FLT_ARG_CNT);
 
        for (i = 0, j = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
                if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
-                       M_DST(abi_registers_float_argument[i], REG_SP, CSTACK + (j * 8));
+                       s1 = WINSAVE_CNT + (j * 8);
+                       M_DST(abi_registers_float_argument[i], REG_SP, BIAS + s1);
+                       fltregarg_offset[i] = s1; /* remember stack offset */
                        j++;
                }
        }
@@ -3062,22 +3122,25 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        M_JMP(REG_RA_CALLER, REG_ITMP3, REG_ZERO);
        M_NOP; /* XXX fill me! */
 
-       /* restore float argument registers */
-
+       /* keep float arguments on stack */
+#if 0
        for (i = 0, j = 0; i < md->paramcount && i < FLT_ARG_CNT; i++) {
                if (IS_FLT_DBL_TYPE(md->paramtypes[i].type)) {
                        M_DLD(abi_registers_float_argument[i], REG_SP, CSTACK + (j * 8));
                        j++;
                }
        }
+#endif
 
        /* copy or spill arguments to new locations */
-       int num_fltregargs = 0;
-       int fltregarg_inswap[16];
+
        for (i = md->paramcount - 1, j = i + nativeparams; i >= 0; i--, j--) {
                t = md->paramtypes[i].type;
 
                if (IS_INT_LNG_TYPE(t)) {
+
+                       /* integral types */
+
                        if (!md->params[i].inmemory) {
                                s1 = md->params[i].regoff;
                                /* s1 refers to the old window, transpose */
@@ -3092,7 +3155,15 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                                }
 
                        } else {
-                               /*assert(false);*/
+                               if (!nmd->params[j].inmemory) {
+                                       /* JIT stack arg -> NAT reg arg */
+
+                                       /* Due to the Env pointer that is always passed, the 6th JIT arg   */
+                                       /* is the 7th (or 8th w/ class ptr) NAT arg, and goes to the stack */
+
+                                       assert(false); /* path never taken */
+                               }
+
                                s1 = md->params[i].regoff + cd->stackframesize;
                                s2 = nmd->params[j].regoff - 6;
                                M_ALD(REG_ITMP1, REG_SP, CSTACK + s1 * 8);
@@ -3100,49 +3171,58 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
                        }
 
                } else {
+
+                       /* floating point types */
+
                        if (!md->params[i].inmemory) {
                                s1 = md->params[i].regoff;
 
                                if (!nmd->params[j].inmemory) {
+
                                        /* no mapping to regs needed, native flt args use regoff */
                                        s2 = nmd->params[j].regoff;
-                                       
-                                       /* we cannot move flt regs to their native arg locations directly */
-                                       M_DMOV(s1, s2 + 16);
-                                       fltregarg_inswap[num_fltregargs] = s2;
-                                       num_fltregargs++;
-                                       /*printf("flt arg swap to %d\n", s2 + 16);*/
 
-                               } else {
+                                       /* JIT float regs are still on the stack */
+                                       M_DLD(s2, REG_SP, BIAS + fltregarg_offset[i]);
+                               } 
+                               else {
+                                       /* not supposed to happen with 16 NAT flt args */
+                                       assert(false); 
+                                       /*
                                        s2 = nmd->params[j].regoff;
                                        if (IS_2_WORD_TYPE(t))
                                                M_DST(s1, REG_SP, CSTACK + (s2 * 8));
                                        else
                                                M_FST(s1, REG_SP, CSTACK + (s2 * 8));
+                                       */
                                }
 
-                       } else {
-                               /*assert(false);*/
+                       } 
+                       else {
                                s1 = md->params[i].regoff + cd->stackframesize;
-                               s2 = nmd->params[j].regoff - 6;
-                               if (IS_2_WORD_TYPE(t)) {
-                                       M_DLD(REG_FTMP1, REG_SP, CSTACK + s1 * 8);
-                                       M_DST(REG_FTMP1, REG_SP, CSTACK + s2 * 8);
-                               } else {
-                                       M_FLD(REG_FTMP1, REG_SP, CSTACK + s1 * 8);
-                                       M_FST(REG_FTMP1, REG_SP, CSTACK + s2 * 8);
+
+                               if (!nmd->params[j].inmemory) {
+
+                                       /* JIT stack -> NAT reg */
+
+                                       s2 = nmd->params[j].regoff; 
+                                       M_DLD(s2, REG_SP, CSTACK + s1 * 8);
+                               }
+                               else {
+
+                                       /* JIT stack -> NAT stack */
+
+                                       s2 = nmd->params[j].regoff - 6;
+
+                                       /* The FTMP register may already be loaded with args */
+                                       /* we know $f0 is unused because of the env pointer  */
+                                       M_DLD(REG_F0, REG_SP, CSTACK + s1 * 8);
+                                       M_DST(REG_F0, REG_SP, CSTACK + s2 * 8);
                                }
                        }
                }
        }
        
-       /* move swapped float args to target regs */
-       for (i = 0; i < num_fltregargs; i++) {
-               s1 = fltregarg_inswap[i];
-               M_DMOV(s1 + 16, s1);
-               /*printf("float arg to target reg: %d ==> %d\n", s1+16, s1);*/
-       }
-
 
        /* put class into second argument register */
 
index 9233b2f81418b0de7d10ef6e040a2b7bd8ff602d..2f4820066cf69684230cf830c9dbb7d428e91204 100644 (file)
@@ -88,6 +88,10 @@ s4 nat_argintregs[INT_NATARG_CNT];
         M_NOP; \
     }
 
+#define ALIGN_STACK_SLOTS(slots) \
+       if (slots & 1) \
+               slots++;
+
 
 /* M_INTMOVE:
      generates an integer-move from register rs to rd.
@@ -689,38 +693,6 @@ s4   get_lopart_disp(s4 disp);
 #define M_AADD_IMM(a,b,c)       M_ADD_IMM(a,b,c)
 #define M_ASUB_IMM(a,b,c)       M_SUB_IMM(a,b,c)
 #define M_ASLL_IMM(a,b,c)       M_SLLX_IMM(a,b,c)
-
-
-
-
-/* var_to_reg_xxx **************************************************************
-
-   This function generates code to fetch data from a pseudo-register
-   into a real register. If the pseudo-register has actually been
-   assigned to a real register, no code will be emitted, since
-   following operations can use this register directly.
-    
-   v: pseudoregister to be fetched from
-   tempregnum: temporary register to be used if v is actually spilled to ram
-
-   return: the register number, where the operand can be found after 
-           fetching (this wil be either tempregnum or the register
-           number allready given to v)
-
-*******************************************************************************/
-
-#define var_to_reg_int(regnr,v,tempnr) \
-    do { \
-        if ((v)->flags & INMEMORY) { \
-            COUNT_SPILLS; \
-            M_LDX(tempnr, REG_SP, (v)->regoff * 8); \
-            regnr = tempnr; \
-        } else { \
-            regnr = (v)->regoff; \
-        } \
-    } while (0)
-                                                                                                                                 
-
-                                                                                                                                 
        
+
 #endif /* _CODEGEN_H */
index 30f30c12aa15de91b6a62ea2c3bc22e567b674fe..03575db907e0781d85f53762d63603e106f3eabe 100644 (file)
@@ -707,6 +707,7 @@ void emit_verbosecall_enter(jitdata *jd)
        methoddesc   *md;
        s4            disp;
        s4            i, t;
+       s4            stackslots;
 
        /* get required compiler data */
 
@@ -721,7 +722,10 @@ void emit_verbosecall_enter(jitdata *jd)
        M_NOP;
 
        /* XXX jit-c-call */
-       M_LDA(REG_SP, REG_SP, -(1 + FLT_ARG_CNT) * 8);
+       stackslots = 1 + FLT_ARG_CNT;
+       ALIGN_STACK_SLOTS(stackslots);
+
+       M_LDA(REG_SP, REG_SP, -(stackslots * 8));
 
        /* save float argument registers */
 
@@ -809,7 +813,7 @@ void emit_verbosecall_enter(jitdata *jd)
                        M_DLD(rd->tmpfltregs[i], REG_SP, (2 + ARG_CNT + INT_TMP_CNT + i) * 8);
        }
 */
-       M_LDA(REG_SP, REG_SP, (1 + FLT_ARG_CNT) * 8);
+       M_LDA(REG_SP, REG_SP, stackslots * 8);
 
        /* mark trace code */
 
@@ -842,8 +846,8 @@ void emit_verbosecall_exit(jitdata *jd)
 
        M_NOP;
        
-       /* XXX jit-c-call */
-       M_LDA(REG_SP, REG_SP, -(1 * 8));
+       /* XXX jit-c-call (keep stack aligned)*/
+       M_LDA(REG_SP, REG_SP, -(2 * 8));
 
        M_DST(REG_FRESULT, REG_SP, JITSTACK);
 
@@ -861,7 +865,7 @@ void emit_verbosecall_exit(jitdata *jd)
 
        M_DLD(REG_FRESULT, REG_SP, JITSTACK);
 
-       M_LDA(REG_SP, REG_SP, 1 * 8);
+       M_LDA(REG_SP, REG_SP, 2 * 8);
 
        /* mark trace code */
 
diff --git a/src/vm/jit/sparc64/linux/.cvsignore b/src/vm/jit/sparc64/linux/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index 5f50a10b2df345512a31c81eea9d6732833ba824..2bae87b45bbdaf043dafa314f29fd9aea717a13d 100644 (file)
@@ -152,21 +152,6 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *info , 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 **************************************************************
 
@@ -193,9 +178,35 @@ 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;
+       u1         *pc;
+       u1         *npc;
+
+       _mc = &_uc->uc_mcontext;
+
+       pc = (u1 *) _mc->mc_gregs[MC_PC];
 
+       npc = critical_find_restart_point(pc);
+       assert(npc);
+
+       _mc->mc_gregs[MC_NPC] = (ptrint) npc;
+
+       assert(false); /* test this */
+}
+#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
index c989a2a5724768140c2cb74f5716f5587ae96f15..b69caa2cdf1e372beccef0803157f755c90ef3fc 100644 (file)
@@ -1,5 +1,8 @@
 #ifndef _MACHINE_INSTR_H
 #define _MACHINE_INSTR_H
+
+#include "toolbox/logging.h"
+
 /*
 static inline void
 __attribute__ ((unused))
@@ -23,6 +26,7 @@ __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"
@@ -30,6 +34,7 @@ compare_and_swap (volatile long *p, long oldval, long newval)
     : "=&r"(ret), "=m"(*p) 
     : "r"(oldval), "r"(newval), "m"(*p));
 
+  /*dolog("compare_and_swap() return=%d mem=%d", ret, *p);*/
   return ret;
 }
 
@@ -37,6 +42,6 @@ compare_and_swap (volatile long *p, long oldval, long newval)
 #define MEMORY_BARRIER_BEFORE_ATOMIC() __asm__ __volatile__ ("mb" : : : "memory");
 #define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("mb" : : : "memory");
 #define MEMORY_BARRIER() __asm__ __volatile__ ( \
-               "mb" : : : "memory" );
+               "membar 0x0F" : : : "memory" );
 
 #endif
index af256859df4577965488f5b3d788198bbc525691..faee75458c44fc0232d5e48dc518697f5043895e 100644 (file)
@@ -91,8 +91,6 @@ const s4 abi_registers_integer_saved[] = {
        28, /* i4  */
 };
 
-const s4 abi_registers_integer_temporary[] = {
-};
 
 
 s4 nregdescfloat[] = {
@@ -110,9 +108,6 @@ const s4 abi_registers_float_argument[] = {
        12, /* f24  */
 };
 
-const s4 abi_registers_float_saved[] = {
-};
-
 const s4 abi_registers_float_temporary[] = {
        4,  /* f8   */
        5,  /* f10  */
index 8f62e0432f27ab8072b7a9cdeaed34c5bba1b3e2..db7735914cb81e8a53496b75e90cbf398fd2c481 100644 (file)
@@ -83,6 +83,8 @@
 
 #define REG_IFTMP        1   /* temporary integer and floating point register */
 
+#define REG_F0           0
+
 
 #define INT_REG_CNT     32   /* number of integer registers                   */
 #define INT_SAV_CNT     12   /* number of int callee saved registers          */
index e1af0541c788546c8d196ec4c09001419c0fa7dd..d366051a963660397400c9b52ce33a09c41ca2bd 100644 (file)
 #define ft6     %f14
 
 #define fa0     %f16
+#define fa0f    %f17
 #define fa1     %f18
+#define fa1f    %f19
 #define fa2     %f20
+#define fa2f    %f21
 #define fa3     %f22
+#define fa3f    %f23
 #define fa4     %f24
+#define fa4f    %f25
 #define ft7     %f26
 #define ft8     %f28
 #define ft9     %f30
diff --git a/src/vm/jit/sparc64/solaris/.cvsignore b/src/vm/jit/sparc64/solaris/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index 5addbee442536233eca2141574f41226e4860fe8..546a850a584010ac7b4ad32cb9cb525a679f8712 100644 (file)
@@ -1,4 +1,4 @@
-/* src/vm/jit/alpha/linux/md.c - machine dependent Alpha Linux functions
+/* src/vm/jit/sparc64/solaris/md-os.c - machine dependent SPARC Solaris functions
 
    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
 #include <assert.h>
 #include <ucontext.h>
 
+/* work around name clash */
+#define REG_SP_OS REG_SP
 #undef REG_SP
 
 #include "vm/types.h"
 
+#include "vm/jit/sparc64/codegen.h"
 #include "vm/jit/sparc64/md-abi.h"
 
 #include "vm/exceptions.h"
 #include "vm/jit/stacktrace.h"
 
 
+ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex)
+{
+       ptrint val;     
+       s8     *window;
+       
+       
+       /* return 0 for REG_ZERO */
+       
+       if (rindex == 0)
+               return 0;
+               
+       
+       if (rindex <= 15) {
+               
+               /* register is in global or out range, available in context */
+               
+       }
+       else {
+               assert(rindex <= 31);
+               
+               /* register is local or in, need to fetch from regsave area on stack */
+       /*      
+               window = ctx->sigc_regs.u_regs[REG_SP] + BIAS;
+               val = window[rindex - 16];
+               */
+       }
+       
+       return val;
+}
+
 /* md_signal_handler_sigsegv ***************************************************
 
    NullPointerException signal handler for hardware null pointer
@@ -67,29 +100,72 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        u1          *sp;
        u1          *ra;
        u1          *xpc;
+       s4           d;
+       s4           s1;
+       s4           disp;
+       ptrint       val;
+       s4           type;
+       java_objectheader *e;
 
        _uc = (ucontext_t *) _p;
        _mc = &_uc->uc_mcontext;
 
-       instr = *((s4 *) (_mc->gregs[REG_PC]));
-       /*addr = _mc->sc_regs[(instr >> 16) & 0x1f];*/
-       addr = 0;
+       pv  = (u1 *) md_get_reg_from_context(_mc, REG_PV_CALLEE);
+#if 0
+       sp  = (u1 *) md_get_reg_from_context(ctx, REG_SP);
+       ra  = (u1 *) md_get_reg_from_context(ctx, REG_RA_CALLEE);  /* this is correct for leafs */
+       xpc = (u1 *) ctx->sigc_regs.tpc;
 
-       if (addr == 0) {
+       /* get exception-throwing instruction */        
+
+       mcode = *((u4 *) xpc);
+
+       d    = M_OP3_GET_RD(mcode);
+       s1   = M_OP3_GET_RS(mcode);
+       disp = M_OP3_GET_IMM(mcode);
+
+       /* flush register windows? */
+       
+       val   = md_get_reg_from_context(ctx, d);
+
+       /* check for special-load */
+
+       if (s1 == REG_ZERO) {
+               /* we use the exception type as load displacement */
+
+               type = disp;
+       }
+       else {
+               /* This is a normal NPE: addr must be NULL and the NPE-type
+                  define is 0. */
+
+               addr  = md_get_reg_from_context(ctx, s1);
+               type = (s4) addr;
+       }
 
+#endif
+       e = exceptions_new_hardware_exception(pv, sp, ra, xpc, type, val);
+
+       /* set registers */
+
+       _mc->gregs[REG_G2]  = (ptrint) e; /* REG_ITMP2_XPTR */
+       _mc->gregs[REG_G3]  = (ptrint) xpc; /* REG_ITMP3_XPC */
+       _mc->gregs[REG_PC]  = (ptrint) asm_handle_exception;
+       _mc->gregs[REG_nPC] = (ptrint) asm_handle_exception + 4;        
 #if 0
+       if (addr == 0) {
+
                pv  = (u1 *) _mc->gregs[REG_G3];
-               sp  = (u1 *) _mc->mc_fp;
-               ra  = (u1 *) _mc->mc_i7;       /* this is correct for leafs */
-               xpc = (u1 *) _mc->mc_gregs[MC_PC];
+               sp  = (u1 *) (_uc->uc_stack.ss_sp);
+               /*ra  = (u1 *) _mc->mc_i7;*/       /* this is correct for leafs */
+               ra  = 0;
+               xpc = (u1 *) _mc->gregs[REG_PC];
 
-               _mc->mc_gregs[MC_G4] =
+               _mc->gregs[REG_G4] =
                        (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
 
-               _mc->mc_gregs[MC_G5] = (ptrint) xpc;
-               _mc->mc_gregs[MC_PC] = (ptrint) asm_handle_exception;
-#endif
-               assert(0);
+               _mc->gregs[REG_G5] = (ptrint) xpc;
+               _mc->gregs[REG_PC] = (ptrint) asm_handle_exception;
 
        } else {
                addr += (long) ((instr << 16) >> 16);
@@ -101,6 +177,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                                                                   */
                assert(0);
        }
+#endif
 }
 
 
index 89ae9c0e9578cb81d8f3cbdd3e5ea4fb4418ef8e..b81dfd45e1a62f1a736c595dc7f225b9d6350908 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: stack.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: stack.c 7908 2007-05-15 09:55:17Z christian $
 
 */
 
 #include "vm/jit/jit.h"
 #include "vm/jit/stack.h"
 
+#if 0
 #if defined(ENABLE_SSA)
 # include "vm/jit/optimizing/lsra.h"
 # include "vm/jit/optimizing/ssa.h"
 #elif defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #endif
+#endif
 
 #include "vmcore/options.h"
 #include "vm/resolve.h"
@@ -2038,9 +2040,6 @@ bool stack_analyse(jitdata *jd)
        methodinfo   *m;              /* method being analyzed                    */
        registerdata *rd;
        stackdata_t   sd;
-#if defined(ENABLE_SSA)
-       lsradata     *ls;
-#endif
        int           stackdepth;
        stackptr      curstack;       /* current stack top                        */
        stackptr      copy;
@@ -2082,9 +2081,6 @@ bool stack_analyse(jitdata *jd)
 
        m    = jd->m;
        rd   = jd->rd;
-#if defined(ENABLE_SSA)
-       ls   = jd->ls;
-#endif
 
        /* initialize the stackdata_t struct */
 
@@ -2107,10 +2103,6 @@ bool stack_analyse(jitdata *jd)
        sd.exstack.varnum = sd.localcount;
        sd.var[sd.exstack.varnum].type = TYPE_ADR;
 
-#if defined(ENABLE_LSRA)
-       m->maxlifetimes = 0;
-#endif
-
 #if defined(ENABLE_STATISTICS)
        iteration_count = 0;
 #endif
@@ -3180,18 +3172,7 @@ normal_ACONST:
                                                        return false;
                                                }
 #endif
-               
-#if defined(ENABLE_SSA)
-                                               if (ls != NULL) {
-                                                       GET_NEW_VAR(sd, new_index, type);
-                                                       DST(type, new_index);
-                                                       stackdepth++;
-                                               }
-                                               else
-
-#else
                                                LOAD(type, varindex);
-#endif
                                                break;
 
                                                /* pop 2 push 1 */
@@ -3224,13 +3205,6 @@ normal_ACONST:
 
                                        case ICMD_IINC:
                                                STATISTICS_STACKDEPTH_DISTRIBUTION(count_store_depth);
-#if defined(ENABLE_SSA)
-                                               if (ls != NULL) {
-                                                       iptr->s1.varindex = 
-                                                               jd->local_map[iptr->s1.varindex * 5 +TYPE_INT];
-                                               }
-                                               else {
-#endif
                                                last_store_boundary[iptr->s1.varindex] = sd.new;
 
                                                iptr->s1.varindex = 
@@ -3248,9 +3222,6 @@ normal_ACONST:
                                                        i--;
                                                        copy = copy->prev;
                                                }
-#if defined(ENABLE_SSA)
-                                               }
-#endif
 
                                                iptr->dst.varindex = iptr->s1.varindex;
                                                break;
@@ -3314,9 +3285,6 @@ normal_ACONST:
                                                }
 #endif
 
-#if defined(ENABLE_SSA)
-                                               if (ls != NULL) {
-#endif
                                                /* check for conflicts as described in Figure 5.2 */
 
                                                copy = curstack->prev;
@@ -3387,9 +3355,6 @@ assume_conflict:
                                                /* remember the stack boundary at this store */
 store_tail:
                                                last_store_boundary[javaindex] = sd.new;
-#if defined(ENABLE_SSA)
-                                               } /* if (ls != NULL) */
-#endif
 
                                                if (opcode == ICMD_ASTORE && curstack->type == TYPE_RET)
                                                        STORE(TYPE_RET, varindex);
index 1d34fc3372292360dd88747518f28911f1006996..99f02e0c31f54972c763ede0ce8d5754f23f6b36 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: stacktrace.c 7792 2007-04-22 20:02:05Z tbfg $
+   $Id: stacktrace.c 7840 2007-04-30 10:53:13Z tbfg $
 
 */
 
@@ -155,7 +155,7 @@ void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
                                                                                         u1 *sp, u1 *ra, u1 *xpc)
 {
        stackframeinfo **psfi;
-#if !defined(__I386__) && !defined(__X86_64__) && !defined(__S390__)
+#if !defined(__I386__) && !defined(__X86_64__) && !defined(__S390__) && !defined(__M68K__)
        bool             isleafmethod;
 #endif
 #if defined(ENABLE_JIT)
@@ -195,6 +195,7 @@ void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
 # 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. */
 
diff --git a/src/vm/jit/tools/.cvsignore b/src/vm/jit/tools/.cvsignore
deleted file mode 100644 (file)
index 6e6bd7a..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-*.o
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-genoffsets
-genoffsets.exe
diff --git a/src/vm/jit/verify/.cvsignore b/src/vm/jit/verify/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/x86_64/.cvsignore b/src/vm/jit/x86_64/.cvsignore
deleted file mode 100644 (file)
index 1f83cf9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
-offsets.h
index 7a2b087add676f777cf6dc2e5485c8ccd3630be6..35d55a6bd24f0dabf5f70c24e47fe862c59eaaaa 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: codegen.c 7794 2007-04-23 19:57:45Z michi $
+   $Id: codegen.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #include "vm/jit/x86_64/emit.h"
 
 #include "mm/memory.h"
+
 #include "native/jni.h"
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -2549,9 +2548,9 @@ gen_method:
                                        supervftbl = super->vftbl;
                                }
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               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 */
@@ -2621,9 +2620,9 @@ gen_method:
                                        }
 
                                        M_MOV_IMM(supervftbl, REG_ITMP3);
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_START;
+
                                        M_ILD32(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
 
                                        /*                                      if (s1 != REG_ITMP1) { */
@@ -2645,9 +2644,9 @@ gen_method:
                                        M_MOV_IMM(supervftbl, REG_ITMP3);
                                        M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval));
                                        /*                                      } */
-#if defined(ENABLE_THREADS)
-                                       codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+
+                                       CODEGEN_CRITICAL_SECTION_END;
+
                                        M_ICMP(REG_ITMP3, REG_ITMP2);
                                        emit_classcast_check(cd, iptr, BRANCH_UGT, REG_ITMP3, s1);
 
@@ -2700,16 +2699,15 @@ gen_method:
                                super      = NULL;
                                superindex = 0;
                                supervftbl = NULL;
-
-                       else {
+                       }
+                       else {
                                super      = iptr->sx.s23.s3.c.cls;
                                superindex = super->index;
                                supervftbl = super->vftbl;
                        }
 
-#if defined(ENABLE_THREADS)
-            codegen_threadcritrestart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                       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);
@@ -2789,17 +2787,13 @@ gen_method:
 
                                M_MOV_IMM(supervftbl, REG_ITMP2);
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstart(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               CODEGEN_CRITICAL_SECTION_START;
 
                                M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, diffval));
                                M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval));
 
-#if defined(ENABLE_THREADS)
-                               codegen_threadcritstop(cd, cd->mcodeptr - cd->mcodebase);
-#endif
+                               CODEGEN_CRITICAL_SECTION_END;
 
                                M_ISUB(REG_ITMP2, REG_ITMP1);
                                M_CLR(d); /* may be REG_ITMP2 */
index a7d9f0017ebefa76fe7a1947b143d4e4657acb68..f7bfc5f9006f7b447884c5cb14c412f27d482a4a 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: emit.c 7766 2007-04-19 13:24:48Z michi $
+   $Id: emit.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
@@ -39,9 +39,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
diff --git a/src/vm/jit/x86_64/freebsd/.cvsignore b/src/vm/jit/x86_64/freebsd/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
diff --git a/src/vm/jit/x86_64/linux/.cvsignore b/src/vm/jit/x86_64/linux/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index 9a109c01ef3d224b3a52119707daeb80c49de49d..f675dab46b39ff824f1d858a73f7ff2b192a3d6b 100644 (file)
@@ -245,21 +245,33 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
+/* 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)
+void md_critical_section_restart(ucontext_t *_uc)
 {
        mcontext_t *_mc;
        u1         *pc;
-       void       *critical;
+       void       *npc;
 
        _mc = &_uc->uc_mcontext;
 
+       /* ATTENTION: Don't use CACAO's internal REG_* defines as they are
+          different to the ones in <ucontext.h>. */
+
        pc = (u1 *) _mc->gregs[REG_RIP];
 
-       critical = critical_find_restart_point(pc);
+       npc = critical_find_restart_point(pc);
 
-       if (critical != NULL)
-               _mc->gregs[REG_RIP] = (ptrint) critical;
+       if (npc != NULL) {
+               log_println("md_critical_section_restart: pc=%p, npc=%p", pc, npc);
+               _mc->gregs[REG_RIP] = (ptrint) npc;
+       }
 }
 #endif
 
index 7d5c99ad06a95e747747fdd1c9daafeead52b867..bf6f4a675aaf1edb90833754c7594eacd78371c7 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: signal.c 7797 2007-04-23 20:12:39Z michi $
+   $Id: signal.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 #endif
 
 
-/* global variables ***********************************************************/
-
-#if defined(ENABLE_THREADS)
-static threadobject *thread_signal;
-#endif
-
-
 /* function prototypes ********************************************************/
 
 void signal_handler_sighup(int sig, siginfo_t *siginfo, void *_p);
@@ -281,15 +274,9 @@ bool signal_start_thread(void)
 
        name = utf_new_char("Signal Handler");
 
-       thread_signal = threads_create_thread(name);
-
-       if (thread_signal == NULL)
+       if (!threads_thread_start_internal(name, signal_thread))
                return false;
 
-       /* actually start the signal handler thread */
-
-       threads_start_thread(thread_signal, signal_thread);
-
        /* everything's ok */
 
        return true;
index a9b1d1a334d08f90a7864eb2a02aacb565f594d3..1d127f76f57c0248bdaf7d18043a187bc915e6ac 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: string.c 7522 2007-03-14 21:54:49Z twisti $
+   $Id: string.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
 
 #include "native/include/java_lang_String.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
@@ -86,7 +82,7 @@ bool string_init(void)
 
        lock_hashtable_string = NEW(java_objectheader);
 
-       lock_init_object_lock(lock_hashtable_string);
+       LOCK_INIT_OBJECT_LOCK(lock_hashtable_string);
 #endif
 
        /* everything's ok */
index 1375634ef8e5227f0035e77bdc892d2485d44f23..00abe045ef45aa17a1d9dd828861d9a142739e28 100644 (file)
@@ -48,9 +48,7 @@
 #include "native/include/java_lang_String.h" /* required by java_lang_Class.h */
 #include "native/include/java_lang_Class.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
+#include "threads/threads-common.h"
 
 #include "toolbox/logging.h"
 
@@ -489,7 +487,7 @@ static void XXusage(void)
 {
        puts("    -v                       write state-information");
 #if !defined(NDEBUG)
-       puts("    -verbose[:call|exception|jit|memory]");
+       puts("    -verbose[:call|exception|jit|memory|threads]");
        puts("                             enable specific verbose output");
        puts("    -debug-color             colored output for ANSI terms");
 #endif
@@ -1122,12 +1120,16 @@ bool vm_create(JavaVMInitArgs *vm_args)
                                opt_stat = true;
 # endif
                        }
+                       else if (strcmp("threads", opt_arg) == 0) {
+                               opt_verbosethreads = true;
+                       }
+#endif
                        else {
                                printf("Unknown -verbose option: %s\n", opt_arg);
                                usage();
                        }
-#endif
                        break;
+
                case OPT_DEBUGCOLOR:
                        opt_debugcolor = true;
                        break;
diff --git a/src/vmcore/.cvsignore b/src/vmcore/.cvsignore
deleted file mode 100644 (file)
index 8f719f9..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-*.a
-*.o
-*.la
-*.lo
-.deps
-.libs
-Makefile
-Makefile.in
-TAGS
index b734ce17e812d5edd310b7fd039663061bae31ac..cbd0a509bde86878951367cb90ac28ed0d339244 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: class.c 7797 2007-04-23 20:12:39Z michi $
+   $Id: class.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
@@ -40,9 +40,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/logging.h"
 
@@ -243,9 +241,7 @@ classinfo *class_create_classinfo(utf *classname)
        if (classname != utf_not_named_yet)
                class_set_packagename(c);
 
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(&c->object.header);
-#endif
+       LOCK_INIT_OBJECT_LOCK(&c->object.header);
 
        return c;
 }
@@ -518,12 +514,16 @@ bool class_load_attributes(classbuffer *cb)
                        if (!loader_load_attribute_signature(cb, &(c->signature)))
                                return false;
                }
+#if 0
+               /* XXX We can't do a release with that enabled */
+
                else if (attribute_name == utf_RuntimeVisibleAnnotations) {
                        /* RuntimeVisibleAnnotations */
 
                        if (!annotation_load_attribute_runtimevisibleannotations(cb))
                                return false;
                }
+#endif
 #endif
                else {
                        /* unknown attribute */
index 0b26cc5c1e99b8b9cbdd133021c8267083c89087..93107b50b421b6b6519ee1d400da94c376426551 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: classcache.c 7560 2007-03-23 18:51:41Z twisti $
+   $Id: classcache.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
@@ -35,9 +35,7 @@
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/hashtable.h"
 #include "toolbox/logging.h"
@@ -266,7 +264,7 @@ bool classcache_init(void)
 
        lock_hashtable_classcache = NEW(java_objectheader);
 
-       lock_init_object_lock(lock_hashtable_classcache);
+       LOCK_INIT_OBJECT_LOCK(lock_hashtable_classcache);
 #endif
 
        /* everything's ok */
index ab287448ed55148340c6cf0f253fbdc7c1d852cf..a965b3679d163647ed5ad1860e11a9c211855e3f 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: linker.c 7691 2007-04-12 12:45:10Z twisti $
+   $Id: linker.c 7870 2007-05-05 13:46:11Z tbfg $
 
 */
 
 #include "vm/types.h"
 
 #include "mm/memory.h"
+
 #include "native/native.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/logging.h"
 
@@ -134,10 +131,14 @@ bool linker_init(void)
 
        interfaceindex = 0;
 
+#if defined(ENABLE_THREADS)
        /* create the global lock object */
 
        linker_classrenumber_lock = NEW(java_objectheader);
 
+       LOCK_INIT_OBJECT_LOCK(linker_classrenumber_lock);
+#endif
+
        /* 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 */
@@ -1211,8 +1212,9 @@ static arraydescriptor *link_array(classinfo *c)
 
 static void linker_compute_subclasses(classinfo *c)
 {
-       LOCK_MONITOR_ENTER(linker_classrenumber_lock);
-
+#if defined(ENABLE_THREADS) && !defined(DISABLE_GC)
+       threads_cast_stopworld();
+#endif
        if (!(c->flags & ACC_INTERFACE)) {
                c->nextsub = NULL;
                c->sub     = NULL;
@@ -1229,7 +1231,9 @@ static void linker_compute_subclasses(classinfo *c)
 
        linker_compute_class_values(class_java_lang_Object);
 
-       LOCK_MONITOR_EXIT(linker_classrenumber_lock);
+#if defined(ENABLE_THREADS) && !defined(DISABLE_GC)
+       threads_cast_startworld();
+#endif
 }
 
 
index 28c413a933c722a5483ed9eb8134e7e4ed5c1ac3..d3c05fa55b078face3aa8e2981657104485c4d20 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: loader.c 7693 2007-04-12 14:56:49Z michi $
+   $Id: loader.c 7918 2007-05-20 20:42:18Z michi $
 
 */
 
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/hashtable.h"
 #include "toolbox/logging.h"
@@ -102,7 +98,7 @@ bool loader_init(void)
        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((java_objectheader *) lce);
+                       LOCK_INIT_OBJECT_LOCK(lce);
 #endif
 
        /* initialize classloader hashtable, 10 entries should be enough */
index 13f56a7e71f94480b6a9d5e4c0e0e11a9bbf3ff8..4f31ef465bcf360293f20c1b99243b9bbe4dd920 100644 (file)
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: options.c 7596 2007-03-28 21:05:53Z twisti $
+   $Id: options.c 7894 2007-05-10 14:04:05Z twisti $
 
 */
 
 
 #include "config.h"
 
-#include <string.h>
+#if defined(HAVE_STRING_H)
+# include <string.h>
+#endif
+
 #include <limits.h>
 
 #include "vm/types.h"
@@ -76,6 +79,7 @@ bool opt_verbosejni       = false;
 bool opt_verbosecall      = false;      /* trace all method invocation        */
 bool opt_verboseexception = false;
 bool opt_verbosememory    = false;
+bool opt_verbosethreads   = false;
 
 bool showmethods = false;
 bool showconstantpool = false;
@@ -199,7 +203,13 @@ s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
                                opt_index++;
 
                                if (opt_index < vm_args->nOptions) {
+
+#if defined(HAVE_STRDUP)
                                        opt_arg = strdup(vm_args->options[opt_index].optionString);
+#else
+# error !HAVE_STRDUP
+#endif
+
                                        opt_index++;
                                        return opts[i].value;
                                }
@@ -218,7 +228,13 @@ s4 options_get(opt_struct *opts, JavaVMInitArgs *vm_args)
                                if (strlen(option + 1) > l) {
                                        if (memcmp(option + 1, opts[i].name, l) == 0) {
                                                opt_index++;
+
+#if defined(HAVE_STRDUP)
                                                opt_arg = strdup(option + 1 + l);
+#else
+# error !HAVE_STRDUP
+#endif
+
                                                return opts[i].value;
                                        }
                                }
index 2409cabc480bc93f0b0da373c9e0e884734b8042..92ecd07bb5f8fc6bd15710667cf565c8fb67d42c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: options.h 7596 2007-03-28 21:05:53Z twisti $
+   $Id: options.h 7894 2007-05-10 14:04:05Z twisti $
 
 */
 
@@ -88,6 +88,7 @@ extern bool opt_verbosejni;
 extern bool opt_verbosecall;
 extern bool opt_verboseexception;
 extern bool opt_verbosememory;
+extern bool opt_verbosethreads;
 
 extern bool showmethods;
 extern bool showconstantpool;
index 4cf87f3a2974f369f5e8f5f394e7f2d1603aeccd..ac68015cbcae4c18ee3803fbf338ddc215fe6340 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: statistics.c 7643 2007-04-03 11:35:40Z twisti $
+   $Id: statistics.c 7916 2007-05-18 14:24:21Z twisti $
 
 */
 
 #include "config.h"
 
 #include <string.h> 
-#include <sys/time.h>
-#include <sys/resource.h>
+
+#if defined(HAVE_TIME_H)
+# include <time.h>
+#endif
+
+#if defined(HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#endif
+
+#if defined(HAVE_SYS_RESOURCE_H)
+# include <sys/resource.h>
+#endif
 
 #include "vm/types.h"
 
@@ -82,12 +92,14 @@ 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;
 
-s4 size_lock_record_pool = 0;
+s4 size_lock_record      = 0;
 s4 size_lock_hashtable   = 0;
 s4 size_lock_waiter      = 0;
 
@@ -159,7 +171,6 @@ int count_tryblocks = 0;
 int count_code_len = 0;
 int count_data_len = 0;
 int count_cstub_len = 0;
-int count_nstub_len = 0;
 int count_max_new_stack = 0;
 int count_upper_bound_new_stack = 0;
 
@@ -265,14 +276,21 @@ void jniinvokation(void)
 
 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;
+
+       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
 }
 
 
@@ -588,6 +606,35 @@ void print_stats(void)
 }
 
 
+/* 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.
@@ -598,25 +645,24 @@ void statistics_print_memory_usage(void)
 {
        s4 sum;
 
-       printf("memory usage ----------------------\n\n");
-       printf("code:                   %10d\n", count_code_len);
-       printf("data:                   %10d\n", count_data_len);
-
-       printf("                         ----------\n");
+       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;
 
-       printf("                        %10d\n", sum);
-       printf("\n");
-
-       printf("classinfo  (%3d B):     %10d\n", (int) sizeof(classinfo), size_classinfo);
-       printf("fieldinfo  (%3d B):     %10d\n", (int) sizeof(fieldinfo), size_fieldinfo);
-       printf("methodinfo (%3d B):     %10d\n", (int) sizeof(methodinfo), size_methodinfo);
-       printf("lineinfo   (%3d B):     %10d\n", (int) sizeof(lineinfo), size_lineinfo);
-       printf("codeinfo   (%3d B):     %10d\n", (int) sizeof(codeinfo), size_codeinfo);
-       printf("                         ----------\n");
+       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 +
@@ -625,25 +671,24 @@ void statistics_print_memory_usage(void)
                size_lineinfo +
                size_codeinfo;
 
-       printf("                        %10d\n", sum);
-       printf("\n");
-
-       printf("constant pool:          %10d\n", count_const_pool_len);
-       printf("classref:               %10d\n", count_classref_len);
-       printf("parsed descriptors:     %10d\n", count_parsed_desc_len);
-       printf("vftbl:                  %10d\n", count_vftbl_len);
-       printf("compiler stubs:         %10d\n", count_cstub_len);
-       printf("native stubs:           %10d\n", count_nstub_len);
-       printf("utf:                    %10d\n", count_utf_len);
-       printf("vmcode:                 %10d\n", count_vmcode_len);
-       printf("exception tables:       %10d\n", count_extable_len);
-       printf("stack map:              %10d\n", size_stack_map);
-       printf("string:                 %10d\n", size_string);
-       printf("threadobject:           %10d\n", size_threadobject);
-       printf("lock record pool:       %10d\n", size_lock_record_pool);
-       printf("lock hashtable:         %10d\n", size_lock_hashtable);
-       printf("lock waiter:            %10d\n", size_lock_waiter);
-       printf("                         ----------\n");
+       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("exception tables:       %10d", count_extable_len);
+       log_println("stack map:              %10d", size_stack_map);
+       log_println("string:                 %10d", size_string);
+       log_println("threadobject:           %10d", size_threadobject);
+       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 +
@@ -651,28 +696,26 @@ void statistics_print_memory_usage(void)
                count_parsed_desc_len + 
                count_vftbl_len +
                count_cstub_len +
-               count_nstub_len +
+               size_stub_native +
                count_utf_len +
                count_vmcode_len +
                count_extable_len +
                size_stack_map +
                size_string +
                size_threadobject +
-               size_lock_record_pool +
+               size_lock_record +
                size_lock_hashtable +
                size_lock_waiter;
 
-       printf("                        %10d\n", sum);
-       printf("\n");
-
-       printf("max. memory usage:      %10d\n", maxcodememusage);
-       printf("max. heap memory usage: %10d\n", maxmemusage);
-       printf("max. dump memory usage: %10d\n", maxdumpsize);
-       printf("\n");
-                  
-       printf("heap memory not freed:  %10d\n", (s4) memoryusage);
-       printf("dump memory not freed:  %10d\n", (s4) globalallocateddumpsize);
-       printf("\n");
+       log_println("                        %10d", sum);
+       log_println("");
+       log_println("max. memory usage:      %10d", maxcodememusage);
+       log_println("max. heap memory usage: %10d", maxmemusage);
+       log_println("max. dump memory usage: %10d", maxdumpsize);
+       log_println("");
+       log_println("heap memory not freed:  %10d", (s4) memoryusage);
+       log_println("dump memory not freed:  %10d", (s4) globalallocateddumpsize);
+       log_println("");
 }
 
 
@@ -691,6 +734,7 @@ void statistics_print_gc_memory_usage(void)
        log_println("heap size:      %10lld", gc_get_heap_size());
        log_println("free:           %10lld", gc_get_free_bytes());
        log_println("used:           %10lld", gc_get_total_bytes());
+       log_println("");
 }
 
 
index f0254801000840e98b9624dd1419ea48deda84d4..e9ad8d4df98ffaf6fdf75fdce5899227033aded8 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: statistics.h 7551 2007-03-21 14:26:09Z twisti $
+   $Id: statistics.h 7916 2007-05-18 14:24:21Z twisti $
 
 */
 
@@ -95,12 +95,14 @@ 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 s4 size_lock_record_pool;
+extern s4 size_lock_record;
 extern s4 size_lock_hashtable;
 extern s4 size_lock_waiter;
 
@@ -171,7 +173,6 @@ extern int count_tryblocks;
 extern int count_code_len;
 extern int count_data_len;
 extern int count_cstub_len;
-extern int count_nstub_len;
 extern int count_max_new_stack;
 extern int count_upper_bound_new_stack;
 
@@ -219,6 +220,7 @@ 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);
 
index 2fb8fee625313e8ba96f456542ff52adbb789ed9..48613d720278afe1d2752e5dce8bba980e5f5570 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: suck.c 7783 2007-04-20 13:28:27Z twisti $
+   $Id: suck.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/list.h"
 #include "toolbox/logging.h"
index 3251e5924cf80de20bb7acf014205ec124f1b3e3..65a4126568349fa2784c11d278f46815c4aef54c 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: utf8.c 7716 2007-04-16 14:29:53Z twisti $
+   $Id: utf8.c 7813 2007-04-25 19:20:13Z twisti $
 
 */
 
 
 #include "mm/memory.h"
 
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
 
 #include "toolbox/hashtable.h"
 
diff --git a/tests/.cvsignore b/tests/.cvsignore
deleted file mode 100644 (file)
index 94cc1ce..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.class
-Makefile
-Makefile.in
index 40d5bb52fdf7ebacef5183ee9f1b4d9949907850..875c8ad228155971d7a03ee6ab3632d388cbbb6f 100644 (file)
@@ -28,7 +28,7 @@
 ##
 ## Changes:
 ##
-## $Id: Makefile.am 4357 2006-01-22 23:33:38Z twisti $
+## $Id: Makefile.am 7882 2007-05-07 14:23:32Z tbfg $
 
 ## Process this file with automake to produce Makefile.in
 
@@ -46,11 +46,12 @@ EXTRA_DIST = \
        BasicToStrings.output \
        GCBench.java \
        JavaPerformance.java \
-       param_test.java
+       param_test.java \
+       exception_restore_registers.java
 
 JAVA = $(top_builddir)/src/cacao/cacao
 
-checkall: x.tst TestArrayClasses.tst BasicToStrings.tst param_test.tst
+checkall: x.tst TestArrayClasses.tst BasicToStrings.tst param_test.tst exception_restore_registers.tst
 
 %.tst:
        $(JAVAC) $*.java
diff --git a/tests/regression/.cvsignore b/tests/regression/.cvsignore
deleted file mode 100644 (file)
index 94cc1ce..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.class
-Makefile
-Makefile.in
diff --git a/tests/regression/codepatching/.cvsignore b/tests/regression/codepatching/.cvsignore
deleted file mode 100644 (file)
index 94cc1ce..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.class
-Makefile
-Makefile.in
diff --git a/tests/regression/native/.cvsignore b/tests/regression/native/.cvsignore
deleted file mode 100644 (file)
index 9334082..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-*.class
-*.h
-*.so
-Makefile
-Makefile.in
diff --git a/tests/stack/.cvsignore b/tests/stack/.cvsignore
deleted file mode 100644 (file)
index 6b468b6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-*.class