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

riscv: MacroAssembler::stop() should emit fixed-length instruction sequence

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 19
    • hotspot
    • b16
    • riscv
    • linux

      PhaseOutput::fill_buffer detects if the real size of a node matches (<=) the size of it in scratch_emit(). The call chain for MacroAssembler::stop() is:

      ```
      MachEpilogNode::emit
          -> reserved_stack_check()
               -> should_not_reach_here()
                    -> stop(const char *msg)
      ```

      li() on RISCV could generate 1~6 instructions, and the msg argument could be an on-stack buffer; it uses __ pc() that could also be different in scratch_emit() and emit(). They both have the potential issue here so the size generated in MacroAssembler::stop() needs to be a fixed value.

      Could be reproduced in fastdebug build:

      ```
      // Die now.
      instruct ShouldNotReachHere() %{
        match(Halt);
        ins_cost(BRANCH_COST);
        format %{ "#@ShouldNotReachHere" %}
        ins_encode %{
          Assembler::CompressibleRegion cr(&_masm);
          if (is_reachable()) {
            __ halt();
      + __ unimplemented("this is an on-stack char literal"); // assertion fail at 'assert(false, "wrong size of mach node");'
          }
        %}
        ins_pipe(pipe_class_default);
      %}
      ```

      Tests passed in hotspot tier1 & jdk tier1.

            xlinzheng Xiaolin Zheng
            xlinzheng Xiaolin Zheng
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: