Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jun 2011 07:10:23 GMT
From:      Oli Kron <kron24@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/158304: openjdk 1.6 does not build on a machine without CMOV
Message-ID:  <201106260710.p5Q7ANUG094858@red.freebsd.org>
Resent-Message-ID: <201106260720.p5Q7K36n082386@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         158304
>Category:       ports
>Synopsis:       openjdk 1.6 does not build on a machine without CMOV
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jun 26 07:20:03 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Oli Kron
>Release:        8.2-RELEASE-p2
>Organization:
>Environment:
FreeBSD ephraim.local 8.2-RELEASE-p2 FreeBSD 8.2-RELEASE-p2 #1: Mon May 30 09:29:24 CEST 2011     toor@ephraim.local:/usr/obj/usr/src/sys/LEXVIA  i386

>Description:
I have a machine with this CPU:

CPU: VIA Samuel 2 (532.64-MHz 686-class CPU)
  Origin = "CentaurHauls"  Id = 0x673  Family = 6  Model = 7  Stepping = 3
  Features=0x803035<FPU,DE,TSC,MSR,MTRR,PGE,MMX>

Although it is a 686-class CPU it doesn't have the CMOV instruction.

I could not build /usr/ports/java/openjdk6/ (openjdk6-b22_6):

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (assembler_x86.cpp:1042), pid=91688, tid=686821696
#  guarantee(VM_Version::supports_cmov()) failed: illegal instruction
#
# JRE version: 6.0-b20
# Java VM: OpenJDK Server VM (19.0-b09 mixed mode, sharing bsd-x86 )
# An error report file with more information is saved as:
# /usr/ports/java/openjdk6/work/build/bsd-i586/hotspot/outputdir/bsd_i486_compiler2/product/hs_err_pid91688.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Abort trap (core dumped)
gmake[4]: *** [product] Error 134
gmake[4]: Leaving directory `/usr/ports/java/openjdk6/work/build/bsd-i586/hotspot/outputdir'
gmake[3]: *** [generic_build2] Error 2
gmake[3]: Leaving directory `/usr/ports/java/openjdk6/work/hotspot/make'
gmake[2]: *** [product] Error 2
gmake[2]: Leaving directory `/usr/ports/java/openjdk6/work/hotspot/make'
gmake[1]: *** [hotspot-build] Error 2
gmake[1]: Leaving directory `/usr/ports/java/openjdk6/work'
gmake: *** [build_product_image] Error 2
*** Error code 1

Using hs_err_pid91688.log (I'm sorry I've deleted the file) I did some
googling and found the cause: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7032388

>How-To-Repeat:
Try build java/openjdk6 on a machine without CMOV (i586 or some i686
like VIA Samuel 2)
>Fix:
I've managed my problem using a bugfix from IcedTea:

cd
wget http://icedtea.classpath.org/download/source/icedtea6-1.10.2.tar.gz
tar xf icedtea6-1.10.2.tar.gz

cd /usr/ports/java/openjdk6
make patch
cd work
patch -p1 <~/icedtea6-1.10.2/patches/hotspot/original/7032388-work_without_cmov_instruction.patch
cd ..
make build install

I'm attaching thefix 7032388-work_without_cmov_instruction.patch


Patch attached with submission follows:

diff -Nru openjdk.orig/hotspot/src/cpu/x86/vm/assembler_x86.cpp openjdk/hotspot/src/cpu/x86/vm/assembler_x86.cpp
--- openjdk.orig/hotspot/src/cpu/x86/vm/assembler_x86.cpp	2011-02-28 16:03:14.000000000 +0000
+++ openjdk/hotspot/src/cpu/x86/vm/assembler_x86.cpp	2011-03-31 03:28:54.031901634 +0100
@@ -7643,6 +7643,28 @@
   }
 }
 
+void MacroAssembler::cmov32(Condition cc, Register dst, Address src) {
+  if (VM_Version::supports_cmov()) {
+    cmovl(cc, dst, src);
+  } else {
+    Label L;
+    jccb(negate_condition(cc), L);
+    movl(dst, src);
+    bind(L);
+  }
+}
+
+void MacroAssembler::cmov32(Condition cc, Register dst, Register src) {
+  if (VM_Version::supports_cmov()) {
+    cmovl(cc, dst, src);
+  } else {
+    Label L;
+    jccb(negate_condition(cc), L);
+    movl(dst, src);
+    bind(L);
+  }
+}
+
 void MacroAssembler::verify_oop(Register reg, const char* s) {
   if (!VerifyOops) return;
 
@@ -8559,14 +8581,7 @@
   movl(result, cnt1);
   subl(cnt1, cnt2);
   push(cnt1);
-  if (VM_Version::supports_cmov()) {
-    cmovl(Assembler::lessEqual, cnt2, result);
-  } else {
-    Label GT_LABEL;
-    jccb(Assembler::greater, GT_LABEL);
-    movl(cnt2, result);
-    bind(GT_LABEL);
-  }
+  cmov32(Assembler::lessEqual, cnt2, result);
 
   // Is the minimum length zero?
   testl(cnt2, cnt2);
diff -Nru openjdk.orig/hotspot/src/cpu/x86/vm/assembler_x86.hpp openjdk/hotspot/src/cpu/x86/vm/assembler_x86.hpp
--- openjdk.orig/hotspot/src/cpu/x86/vm/assembler_x86.hpp	2011-02-28 16:03:14.000000000 +0000
+++ openjdk/hotspot/src/cpu/x86/vm/assembler_x86.hpp	2011-03-31 03:28:54.031901634 +0100
@@ -2174,10 +2174,13 @@
 
   // Data
 
-  void cmov(Condition cc, Register dst, Register src) { LP64_ONLY(cmovq(cc, dst, src)) NOT_LP64(cmovl(cc, dst, src)); }
+  void cmov32( Condition cc, Register dst, Address  src);
+  void cmov32( Condition cc, Register dst, Register src);
 
-  void cmovptr(Condition cc, Register dst, Address src) { LP64_ONLY(cmovq(cc, dst, src)) NOT_LP64(cmovl(cc, dst, src)); }
-  void cmovptr(Condition cc, Register dst, Register src) { LP64_ONLY(cmovq(cc, dst, src)) NOT_LP64(cmovl(cc, dst, src)); }
+  void cmov(   Condition cc, Register dst, Register src) { cmovptr(cc, dst, src); }
+
+  void cmovptr(Condition cc, Register dst, Address  src) { LP64_ONLY(cmovq(cc, dst, src)) NOT_LP64(cmov32(cc, dst, src)); }
+  void cmovptr(Condition cc, Register dst, Register src) { LP64_ONLY(cmovq(cc, dst, src)) NOT_LP64(cmov32(cc, dst, src)); }
 
   void movoop(Register dst, jobject obj);
   void movoop(Address dst, jobject obj);
diff -Nru openjdk.orig/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp openjdk/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
--- openjdk.orig/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	2011-02-28 16:03:14.000000000 +0000
+++ openjdk/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	2011-03-31 03:28:54.035901697 +0100
@@ -559,24 +559,13 @@
   __ lea    (rdi, Address(rdi, rcx, Address::times_2, arrayOopDesc::base_offset_in_bytes(T_CHAR)));
 
   // compute minimum length (in rax) and difference of lengths (on top of stack)
-  if (VM_Version::supports_cmov()) {
-    __ movl     (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
-    __ movl     (rax, Address(rax, java_lang_String::count_offset_in_bytes()));
-    __ mov      (rcx, rbx);
-    __ subptr   (rbx, rax); // subtract lengths
-    __ push     (rbx);      // result
-    __ cmov     (Assembler::lessEqual, rax, rcx);
-  } else {
-    Label L;
-    __ movl     (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
-    __ movl     (rcx, Address(rax, java_lang_String::count_offset_in_bytes()));
-    __ mov      (rax, rbx);
-    __ subptr   (rbx, rcx);
-    __ push     (rbx);
-    __ jcc      (Assembler::lessEqual, L);
-    __ mov      (rax, rcx);
-    __ bind (L);
-  }
+  __ movl  (rbx, Address(rbx, java_lang_String::count_offset_in_bytes()));
+  __ movl  (rax, Address(rax, java_lang_String::count_offset_in_bytes()));
+  __ mov   (rcx, rbx);
+  __ subptr(rbx, rax); // subtract lengths
+  __ push  (rbx);      // result
+  __ cmov  (Assembler::lessEqual, rax, rcx);
+
   // is minimum length 0?
   Label noLoop, haveResult;
   __ testptr (rax, rax);
diff -Nru openjdk.orig/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp openjdk/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
--- openjdk.orig/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	2011-02-28 16:03:14.000000000 +0000
+++ openjdk/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	2011-03-31 03:28:54.035901697 +0100
@@ -1931,18 +1931,10 @@
     __ movl(temp, Address(array, h, Address::times_8, 0*wordSize));
     __ bswapl(temp);
     __ cmpl(key, temp);
-    if (VM_Version::supports_cmov()) {
-      __ cmovl(Assembler::less        , j, h);   // j = h if (key <  array[h].fast_match())
-      __ cmovl(Assembler::greaterEqual, i, h);   // i = h if (key >= array[h].fast_match())
-    } else {
-      Label set_i, end_of_if;
-      __ jccb(Assembler::greaterEqual, set_i);     // {
-      __ mov(j, h);                                //   j = h;
-      __ jmp(end_of_if);                           // }
-      __ bind(set_i);                              // else {
-      __ mov(i, h);                                //   i = h;
-      __ bind(end_of_if);                          // }
-    }
+    // j = h if (key <  array[h].fast_match())
+    __ cmov32(Assembler::less        , j, h);
+    // i = h if (key >= array[h].fast_match())
+    __ cmov32(Assembler::greaterEqual, i, h);
     // while (i+1 < j)
     __ bind(entry);
     __ leal(h, Address(i, 1));                   // i+1
@@ -3463,22 +3455,14 @@
 
   // find a free slot in the monitor block (result in rdx)
   { Label entry, loop, exit;
-    __ movptr(rcx, monitor_block_top);            // points to current entry, starting with top-most entry
-    __ lea(rbx, monitor_block_bot);               // points to word before bottom of monitor block
+    __ movptr(rcx, monitor_block_top);           // points to current entry, starting with top-most entry
+
+    __ lea(rbx, monitor_block_bot);              // points to word before bottom of monitor block
     __ jmpb(entry);
 
     __ bind(loop);
     __ cmpptr(Address(rcx, BasicObjectLock::obj_offset_in_bytes()), (int32_t)NULL_WORD);  // check if current entry is used
-
-// TODO - need new func here - kbt
-    if (VM_Version::supports_cmov()) {
-      __ cmov(Assembler::equal, rdx, rcx);       // if not used then remember entry in rdx
-    } else {
-      Label L;
-      __ jccb(Assembler::notEqual, L);
-      __ mov(rdx, rcx);                          // if not used then remember entry in rdx
-      __ bind(L);
-    }
+    __ cmovptr(Assembler::equal, rdx, rcx);      // if not used then remember entry in rdx
     __ cmpptr(rax, Address(rcx, BasicObjectLock::obj_offset_in_bytes()));   // check if current entry is for same object
     __ jccb(Assembler::equal, exit);             // if same object then stop searching
     __ addptr(rcx, entry_size);                  // otherwise advance to next entry


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106260710.p5Q7ANUG094858>