Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8241904

assert(VM_Version::supports_sse4_1()) failed in Assembler::ptest

    Details

      Description

      # Symptom

      ```
      # A fatal error has been detected by the Java Runtime Environment:
      #
      # Internal Error (/Users/fool/workspace/open/jdk11u/src/hotspot/cpu/x86/assembler_x86.cpp:4204), pid=64128, tid=22019
      # Error: assert(VM_Version::supports_sse4_1()) failed
      #
      # JRE version: OpenJDK Runtime Environment (11.0.7) (fastdebug build 11.0.7-internal+0-adhoc.fool.jdk11u)
      # Java VM: OpenJDK 64-Bit Server VM (fastdebug 11.0.7-internal+0-adhoc.fool.jdk11u, compiled mode, compressed oops, g1 gc, bsd-amd64)

      Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
      V [libjvm.dylib+0xc2bfc8] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x66e
      V [libjvm.dylib+0xc2c6c1] VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x3f
      V [libjvm.dylib+0x4324d1] report_vm_error(char const*, int, char const*, char const*, ...)+0xcc
      V [libjvm.dylib+0x1d5d59] Assembler::ptest(XMMRegisterImpl*, XMMRegisterImpl*)+0x5f
      V [libjvm.dylib+0x91f506] MacroAssembler::encode_iso_array(RegisterImpl*, RegisterImpl*, RegisterImpl*, XMMRegisterImpl*, XMMRegisterImpl*, XMMRegisterImpl*, XMMRegisterImpl*, RegisterImpl*, RegisterImpl*)+0x8fc
      V [libjvm.dylib+0x4f1ef] encode_iso_arrayNode::emit(CodeBuffer&, PhaseRegAlloc*) const+0x227
      V [libjvm.dylib+0x3a1112] Compile::scratch_emit_size(Node const*)+0x28c
      V [libjvm.dylib+0xa23ee5] Compile::shorten_branches(unsigned int*, int&, int&, int&)+0x421
      V [libjvm.dylib+0xa21f7c] Compile::init_buffer(unsigned int*)+0x1fc
      V [libjvm.dylib+0xa21b7a] Compile::Output()+0x56a
      V [libjvm.dylib+0x3a48ff] Compile::Code_Gen()+0x473
      V [libjvm.dylib+0x3a1f5c] Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool, bool, DirectiveSet*)+0xc84
      V [libjvm.dylib+0x2cb347] C2Compiler::compile_method(ciEnv*, ciMethod*, int, DirectiveSet*)+0xff
      V [libjvm.dylib+0x3b59bf] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x5cd
      V [libjvm.dylib+0x3b524c] CompileBroker::compiler_thread_loop()+0x1fa
      V [libjvm.dylib+0xb9efa4] JavaThread::thread_main_inner()+0x1f8
      V [libjvm.dylib+0xb9ea98] JavaThread::run()+0x2ac
      V [libjvm.dylib+0xb9b3fd] Thread::call_run()+0x83
      V [libjvm.dylib+0xa13aee] thread_native_entry(Thread*)+0x136
      C [libsystem_pthread.dylib+0x5d36] _pthread_start+0x7d
      C [libsystem_pthread.dylib+0x258f] thread_start+0xf
      ```

      # Reproduce

      - Program
      ```
      import java.nio.charset.Charset;

      public class Test {
          public static void main(String[] args) {
              byte[] Bytes = {1, 2, 3, 4, 5, 6, 7, 8};
              Charset UTF8Charset = Charset.forName("UTF-8");
              Charset ISO88591Charset = Charset.forName("ISO-8859-1");

              String string = new String(Bytes, UTF8Charset);

              Bytes = string.getBytes(ISO88591Charset);
              System.out.println(Bytes[0]);
          }
      }
      ```

      - Run with a debug VM
      ```
      java \
          -XX:CompileCommand=compileonly,java.lang.StringCoding::encode8859_1 \
          -Xcomp -XX:-TieredCompilation -XX:UseSSE=3 Test
      ```

      # Affected Versions

      jdk8 ~ jdk11

      - It might be fixed by
      ```
      diff -r 00f8f9fcdc3a src/hotspot/cpu/x86/assembler_x86.cpp
      --- a/src/hotspot/cpu/x86/assembler_x86.cpp Wed Mar 25 09:37:07 2020 +0100
      +++ b/src/hotspot/cpu/x86/assembler_x86.cpp Tue Mar 31 14:07:51 2020 +0800
      @@ -4201,7 +4201,7 @@
       }

       void Assembler::ptest(XMMRegister dst, XMMRegister src) {
      - assert(VM_Version::supports_sse4_1(), "");
      + assert(VM_Version::supports_sse4_1() || VM_Version::supports_avx(), "");
         InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false);
         int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes);
         emit_int8(0x17);
      ```

        Attachments

          Activity

            People

            • Assignee:
              jiefu Jie Fu
              Reporter:
              jiefu Jie Fu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: