/hg/release/icedtea6-1.11: 4 new changesets

aph at icedtea.classpath.org aph at icedtea.classpath.org
Mon Jan 23 08:58:01 PST 2012


changeset 17a45cdfc108 in /hg/release/icedtea6-1.11
details: http://icedtea.classpath.org/hg/release/icedtea6-1.11?cmd=changeset;node=17a45cdfc108
author: aph
date: Fri Jan 20 10:51:50 2012 -0500

	Rewrite disassembler to use the OpenJDK hsdis framework. 2012-01-20
	Andrew Haley <aph at redhat.com>

	 * openjdk/hotspot/src/cpu/zero/vm/thumb2.cpp (Whole
	file): use PrintAssembly rather than t2ee_print_disass.
	(t2ee_print_disass): Delete. (class Hsdis):Rename. (Was
	class Opcodes.) Rewrite to use the OpenJDK hsdis framework.
	(Thumb2_disass): move Hsdis here from global scope. Rewrite
	to use the OpenJDK hsdis framework.
		* patches/arm-hsdis.patch: New file.
		* Makefile.am (ICEDTEA_PATCHES): Add patches/arm-hsdis.patch.


changeset 68bfc595c849 in /hg/release/icedtea6-1.11
details: http://icedtea.classpath.org/hg/release/icedtea6-1.11?cmd=changeset;node=68bfc595c849
author: aph
date: Fri Jan 20 14:04:34 2012 -0500

	Return NULL to fix disassembler. 2012-01-20 Andrew Haley
	<aph at redhat.com>

	 * arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp
	(print_address): Return NULL;


changeset c13852361818 in /hg/release/icedtea6-1.11
details: http://icedtea.classpath.org/hg/release/icedtea6-1.11?cmd=changeset;node=c13852361818
author: aph
date: Mon Jan 23 09:49:12 2012 -0500

	Minor tweaks to ARM hsdis patch. 2012-01-23 Andrew Haley
	<aph at redhat.com>

	 * arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp
	(Thumb2_disass): Minor tidying.
		* patches/arm-hsdis.patch: Make test for ARM more generic.


changeset 6aa2b2fc20ba in /hg/release/icedtea6-1.11
details: http://icedtea.classpath.org/hg/release/icedtea6-1.11?cmd=changeset;node=6aa2b2fc20ba
author: aph
date: Mon Jan 23 16:43:01 2012 +0000

	Add cast to silence warning. 2012-01-23 Andrew Haley
	<aph at redhat.com>

	 * arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp
	(print_address): Add cast to silence warning.


diffstat:

 ChangeLog                                   |   28 +++++
 Makefile.am                                 |    1 +
 arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp |  154 ++++++++++++---------------
 patches/arm-hsdis.patch                     |   88 ++++++++++++++++
 4 files changed, 186 insertions(+), 85 deletions(-)

diffs (409 lines):

diff -r aa81d0648c82 -r 6aa2b2fc20ba ChangeLog
--- a/ChangeLog	Thu Jan 19 17:41:09 2012 +0100
+++ b/ChangeLog	Mon Jan 23 16:43:01 2012 +0000
@@ -1,9 +1,37 @@
+2012-01-23  Andrew Haley  <aph at redhat.com>
+
+	* arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp (print_address): Add
+	cast to silence warning.
+
 2012-01-19  Xerxes RÃ¥nby  <xerxes at zafena.se>
 	    Andrew Haley  <aph at redhat.com>
 
 	* openjdk/hotspot/src/cpu/zero/vm/thumb2.cpp
 	(Thumb2_Compile): Disable T2-JIT on unsupported targets like armv5.
 
+2012-01-23  Andrew Haley  <aph at redhat.com>
+
+	* arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp (Thumb2_disass):
+	Minor tidying.
+	* patches/arm-hsdis.patch: Make test for ARM more generic.
+
+2012-01-20  Andrew Haley  <aph at redhat.com>
+
+	* arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp (print_address):
+	Return NULL;
+
+2012-01-20  Andrew Haley  <aph at redhat.com>
+
+	* openjdk/hotspot/src/cpu/zero/vm/thumb2.cpp
+	(Whole file): use PrintAssembly rather than t2ee_print_disass.
+	(t2ee_print_disass): Delete.
+	(class Hsdis):Rename.  (Was class Opcodes.)
+	Rewrite to use the OpenJDK hsdis framework.
+	(Thumb2_disass): move Hsdis here from global scope.
+	Rewrite to use the OpenJDK hsdis framework.
+	* patches/arm-hsdis.patch: New file.
+	* Makefile.am (ICEDTEA_PATCHES): Add patches/arm-hsdis.patch.
+
 2012-01-19  Andrew Haley  <aph at redhat.com>
 
 	* openjdk-ecj/hotspot/src/cpu/zero/vm/thumb2.cpp
diff -r aa81d0648c82 -r 6aa2b2fc20ba Makefile.am
--- a/Makefile.am	Thu Jan 19 17:41:09 2012 +0100
+++ b/Makefile.am	Mon Jan 23 16:43:01 2012 +0000
@@ -399,6 +399,7 @@
 	patches/openjdk/6296893-BMP_Writer_handles_TopDown_prop_incorrectly.patch \
 	patches/openjdk/7103224-glibc_name_collision.patch \
 	patches/arm-debug.patch \
+	patches/arm-hsdis.patch	\
 	patches/openjdk/7103610-_NET_WM_PID_and_WM_CLIENT_MACHINE_are_not_set.patch \
 	patches/openjdk/7102369-7094468-rmiregistry.patch \
 	patches/openjdk/6851973-kerberos.patch \
diff -r aa81d0648c82 -r 6aa2b2fc20ba arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp
--- a/arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp	Thu Jan 19 17:41:09 2012 +0100
+++ b/arm_port/hotspot/src/cpu/zero/vm/thumb2.cpp	Mon Jan 23 16:43:01 2012 +0000
@@ -38,10 +38,6 @@
 static char *t2ee_print_statistics;
 #endif
 
-#ifdef T2EE_PRINT_DISASS
-static char *t2ee_print_disass;
-#endif
-
 #ifdef T2EE_PRINT_REGUSAGE
 static char *t2ee_print_regusage;
 #endif
@@ -56,11 +52,6 @@
 #include "precompiled.hpp"
 #include "interpreter/bytecodes.hpp"
 
-#ifdef T2EE_PRINT_DISASS
-#include "dis-asm.h"
-#include "bfd.h"
-#endif
-
 #define opc_nop			0x00
 #define opc_aconst_null		0x01
 #define opc_iconst_m1		0x02
@@ -725,41 +716,44 @@
 
 #ifdef T2EE_PRINT_DISASS
 
-class Opcodes {
+class Hsdis {
 public:
-  typeof (::print_insn_little_arm) *print_insn_little_arm;
-  typeof (::init_disassemble_info) *init_disassemble_info;
-  typeof (::disassemble_init_for_target) *disassemble_init_for_target;
-
-  // Load libopcodes.so lazily.
-  Opcodes()
+
+  typedef void* (*decode_instructions_event_callback_ftype)  (void*, const char*, void*);
+
+  typedef void* (*decode_instructions_ftype)
+    (void* start, void* end,
+     decode_instructions_event_callback_ftype event_callback,
+     void* event_stream,
+     void* printf_callback,
+     void* printf_stream,
+     const char* options);
+
+  decode_instructions_ftype decode_instructions;
+
+  void *lib;
+
+  // Load hsdis-arm.so lazily.
+  Hsdis()
   {
-    void *lib;
-    if (t2ee_print_disass) {
-      if (lib = dlopen("libopcodes.so", RTLD_NOW)) {
-	print_insn_little_arm
-	  = (typeof print_insn_little_arm)dlsym(lib, "print_insn_little_arm");
-	init_disassemble_info
-	  = (typeof init_disassemble_info)dlsym(lib, "init_disassemble_info");
-	disassemble_init_for_target
-	  = (typeof disassemble_init_for_target)dlsym(lib, "disassemble_init_for_target");
+    if (PrintAssembly) {
+      if (lib = dlopen("hsdis-arm.so", RTLD_NOW)) {
+	decode_instructions
+	  = (typeof decode_instructions)dlsym(lib, "decode_instructions");
       }
 
-      if (! (print_insn_little_arm
-	     && init_disassemble_info
-	     && disassemble_init_for_target))
-	{
-	  fprintf (stderr, "The environment variable T2EE_PRINT_DISASS is set, but\n"
-		   "libopcodes.so has not been found or is invalid.  If you want to\n"
-		   "see a disassembly, please ensure that a valid copy of\n"
-		   "libopcodes.so is present somewhere in your library load path.\n");
-	  abort();
-	}
+      if (! (decode_instructions)) {
+	fprintf (stderr, "PrintAssembly (or T2EE_PRINT_DISASS) is set, but\n"
+		 "hsdis-arm.so has not been found or is invalid.  If you want to\n"
+		 "see a disassembly, please ensure that a valid copy of\n"
+		 "hsdis-arm.so is present somewhere in your library load path.\n");
+	abort();
+      }
     }
   }
 };
 
-static Opcodes opcodes;
+static void *print_address(void *stream, const char *tag, void *data);
 
 void Thumb2_disass(Thumb2_Info *jinfo)
 {
@@ -773,10 +767,11 @@
   int start_b, end_b;
   unsigned nodisass;
 
-  struct disassemble_info info;
   unsigned short *codebuf = jinfo->codebuf->codebuf;
   unsigned idx, compiled_len;
 
+  static Hsdis hsdis;
+
 #if 0
   printf("Local Variable Usage\n");
   printf("====================\n");
@@ -794,16 +789,6 @@
   fflush(stdout);
   fflush(stderr);
 
-  opcodes.init_disassemble_info(&info, stdout, (fprintf_ftype)fprintf);
-  info.arch = bfd_arch_arm;
-  opcodes.disassemble_init_for_target(&info);
-  info.endian = BFD_ENDIAN_LITTLE;
-  info.endian_code = BFD_ENDIAN_LITTLE;
-  info.buffer = (bfd_byte *)codebuf;
-  info.buffer_vma = (bfd_vma)codebuf;
-  info.buffer_length = jinfo->codebuf->idx * sizeof(short);
-  info.disassembler_options = (char *)"force-thumb";
-
   compiled_len = jinfo->codebuf->idx * 2;
   for (idx = 0; idx < compiled_len; ) {
     nodisass = 0;
@@ -867,14 +852,17 @@
 	      low++;
 	    }
 	    bci += len;
-	    for (i = 0; i < 4; i++) {
+	    {
+	      // The insn sequence generated by tableswitch is 14
+	      // bytes long.
+	      const int tableswitch_code_len = 14;
 	      printf("0x%08x:\t", (int)codebuf+idx);
-	      {
-		int len = opcodes.print_insn_little_arm((bfd_vma)codebuf+idx, &info);
-		if (len == -1) len = 2;
-		idx += len;
-		putchar('\n');
-	      }
+		unsigned short *p = codebuf + idx/2;
+		hsdis.decode_instructions((char*)p,
+					  (char *)p + tableswitch_code_len,
+					  print_address, NULL, NULL, stdout,
+					  "force-thumb");
+		idx += tableswitch_code_len;
 	    }
 	    for (i = 0; i < n; i++) {
 	      printf("0x%08x:\t.short\t0x%04x\n", (int)codebuf+idx, *(short *)((int)codebuf + idx));
@@ -929,7 +917,6 @@
       }
     }
     if (!nodisass) {
-      printf("0x%08x:\t", (int)codebuf+idx);
       {
 	int len;
 	unsigned s1, s2;
@@ -945,16 +932,27 @@
 	    len = 4;
 	  }
 	} else {
-	  len = opcodes.print_insn_little_arm((bfd_vma)codebuf+idx, &info);
-	  if (len == -1) len = 2;
-	  idx += len;
+	  char *p = (char*)codebuf + idx;
+	  len = 2;
+	  while (len + idx < compiled_len
+		 && start_bci[(len + idx)/2] == -1)
+	    len += 2;
+	  hsdis.decode_instructions((char*)p, (char*)p + len,
+				      print_address, NULL, NULL, stdout,
+				      "force-thumb");
 	}
-	putchar('\n');
+	idx += len;
       }
     }
   }
   fflush(stdout);
 }
+// where
+static void *print_address(void *, const char *tag, void *data) {
+  if (strcmp(tag, "insn") == 0)
+    printf("0x%08x:\t", (unsigned int)data);
+  return NULL;
+}
 #endif
 
 #define BCI(len, pop, push, special, islocal, islocal_n, isstore, local_n, local_type) \
@@ -7131,7 +7129,7 @@
 #endif
 
 #ifdef T2EE_PRINT_COMPILATION
-  if (t2ee_print_compilation) {
+  if (t2ee_print_compilation || PrintAssembly) {
     fprintf(stderr, "Compiling %d %c%c %s\n",
 	compiled_methods,
 	method->is_synchronized() ? 'S' : ' ',
@@ -7208,7 +7206,7 @@
 
 #ifdef T2EE_PRINT_DISASS
   if (DISASS_AFTER == 0 || compiled_methods >= DISASS_AFTER)
-    if (t2ee_print_disass)
+    if (PrintAssembly)
 	Thumb2_disass(&jinfo_str);
 #endif
 
@@ -7383,7 +7381,7 @@
   t2ee_print_statistics = getenv("T2EE_PRINT_STATISTICS");
 #endif
 #ifdef T2EE_PRINT_DISASS
-  t2ee_print_disass = getenv("T2EE_PRINT_DISASS");
+  PrintAssembly |= getenv("T2EE_PRINT_DISASS") != NULL;
 #endif
 #ifdef T2EE_PRINT_REGUSAGE
   t2ee_print_regusage = getenv("T2EE_PRINT_REGUSAGE");
@@ -7775,33 +7773,19 @@
   mov_imm(&codebuf, ARM_R3, (u32)Thumb2_Handle_Exception_NoRegs);
   mov_reg(&codebuf, ARM_PC, ARM_R3);
 
+  // Disassemble the codebuf we just created.  For debugging
+  if (PrintAssembly) {
+    Hsdis hsdis;
+    hsdis.decode_instructions(cb->hp, cb->hp + codebuf.idx * 2,
+			      print_address, NULL, NULL, stdout,
+			      "force-thumb");
+    putchar('\n');
+  }
+
   Thumb2_Clear_Cache(cb->hp, cb->hp + codebuf.idx * 2);
   cb->hp += codebuf.idx * 2;
 
   thumb2_codebuf = cb;
-
-#if 0 // Disassemble the codebuf we just created.  For debugging
-  Opcodes opcodes;
-  if (t2ee_print_disass) {
-    struct disassemble_info info;
-    info.arch = bfd_arch_arm;
-    opcodes.disassemble_init_for_target(&info);
-    opcodes.init_disassemble_info(&info, stdout, (fprintf_ftype)fprintf);
-    info.endian = BFD_ENDIAN_LITTLE;
-    info.endian_code = BFD_ENDIAN_LITTLE;
-    info.buffer = (bfd_byte *)codebuf.codebuf;
-    info.buffer_vma = (bfd_vma)codebuf.codebuf;
-    info.buffer_length = codebuf.idx * sizeof(short);
-    info.disassembler_options = (char *)"force-thumb";
-    int len;
-    for (unsigned int i = 0; i < codebuf.idx * sizeof(short); i += len) {
-      printf("0x%08x:\t", ((int)codebuf.codebuf)+i);
-      len = opcodes.print_insn_little_arm(((bfd_vma)codebuf.codebuf)+i, &info);
-      if (len == -1) len = 2;
-      putchar('\n');
-    }
-  }
-#endif
 }
 
 #endif // THUMB2EE
diff -r aa81d0648c82 -r 6aa2b2fc20ba patches/arm-hsdis.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/arm-hsdis.patch	Mon Jan 23 16:43:01 2012 +0000
@@ -0,0 +1,90 @@
+2012-01-20  Andrew Haley  <aph at redhat.com>
+
+	* Makefile (ARCH): Add entry for armv7l.
+	(CFLAGS): Enable debugging.
+	($(LIBRARIES)): Pass CFLAGS to sub-make.
+	* hsdis.c: Include string.h.
+	(parse_caller_options): Fix strncmp bug.
+	(native_arch_name): Add entry for ARM.
+
+diff -u openjdk/hotspot/src/share/tools/hsdis/hsdis.c ../icedtea6/openjdk/hotspot/src/share/tools/hsdis/hsdis.c
+--- openjdk/hotspot/src/share/tools/hsdis/hsdis.c	2011-11-14 17:07:33.000000000 -0500
++++ openjdk/hotspot/src/share/tools/hsdis/hsdis.c	2012-01-20 10:21:28.000000000 -0500
+@@ -22,8 +22,6 @@
+  *
+  */
+ 
+-#include "precompiled.hpp"
+-
+ /* hsdis.c -- dump a range of addresses as native instructions
+    This implements the plugin protocol required by the
+    HotSpot PrintAssembly option.
+@@ -37,6 +35,8 @@
+ #include <dis-asm.h>
+ #include <inttypes.h>
+ 
++#include <string.h>
++
+ #ifndef bool
+ #define bool int
+ #define true 1
+@@ -358,7 +358,7 @@
+       if (plen > mach_size)  plen = mach_size;
+       strncpy(mach_option, p, plen);
+       mach_option[plen] = '\0';
+-    } else if (plen > 6 && strncmp(p, "hsdis-", 6)) {
++    } else if (plen > 6 && !strncmp(p, "hsdis-", 6)) {
+       // do not pass these to the next level
+     } else {
+       /* just copy it; {i386,sparc}-dis.c might like to see it  */
+@@ -420,6 +420,9 @@
+ #ifdef LIBARCH_sparcv9
+     res = "sparc:v9b";
+ #endif
++#ifdef LIBARCH_arm
++    res = "arm";
++#endif
+   if (res == NULL)
+     res = "architecture not set in Makefile!";
+   return res;
+diff -u openjdk/hotspot/src/share/tools/hsdis/Makefile openjdk/hotspot/src/share/tools/hsdis/Makefile
+--- openjdk/hotspot/src/share/tools/hsdis/Makefile	2011-11-14 17:07:33.000000000 -0500
++++ openjdk/hotspot/src/share/tools/hsdis/Makefile	2012-01-20 10:20:32.000000000 -0500
+@@ -68,14 +68,18 @@
+ CONFIGURE_ARGS= --host=$(MINGW) --target=$(MINGW)
+ else
+ CPU             = $(shell uname -m)
++ifneq		 ($(findstring arm,$(CPU)),)
++ARCH=arm
++else
+ ARCH1=$(CPU:x86_64=amd64)
+ ARCH=$(ARCH1:i686=i386)
+ CFLAGS/i386	+= -m32
+ CFLAGS/sparc	+= -m32
+ CFLAGS/sparcv9	+= -m64
+ CFLAGS/amd64	+= -m64
++endif
+ CFLAGS		+= $(CFLAGS/$(ARCH))
+-CFLAGS		+= -fPIC
++CFLAGS		+= -fPIC -g
+ OS		= linux
+ LIB_EXT		= .so
+ CC 		= gcc
+@@ -118,7 +122,7 @@
+ BINUTILSDIR	= $(shell cd $(BINUTILS);pwd)
+ endif
+ 
+-CPPFLAGS	+= -I$(BINUTILSDIR)/include -I$(BINUTILS)/bfd -I$(TARGET_DIR)/bfd
++CPPFLAGS	+= -I$(BINUTILSDIR)/include -I$(BINUTILSDIR)/bfd -I$(TARGET_DIR)/bfd
+ CPPFLAGS	+= -DLIBARCH_$(LIBARCH) -DLIBARCH=\"$(LIBARCH)\" -DLIB_EXT=\"$(LIB_EXT)\"
+ 
+ TARGET_DIR	= build/$(OS)-$(JDKARCH)
+@@ -145,7 +149,7 @@
+ demo: $(TARGET) $(DEMO_TARGET)
+ 
+ $(LIBRARIES): $(TARGET_DIR) $(TARGET_DIR)/Makefile
+-	if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes; fi
++	if [ ! -f $@ ]; then cd $(TARGET_DIR); make all-opcodes "CFLAGS=$(CFLAGS)"; fi
+ 
+ $(TARGET_DIR)/Makefile:
+ 	(cd $(TARGET_DIR); CC=$(CC) CFLAGS="$(CFLAGS)" $(BINUTILSDIR)/configure --disable-nls $(CONFIGURE_ARGS))



More information about the distro-pkg-dev mailing list