RFR: 8283737: riscv: MacroAssembler::stop() should emit fixed-length instruction sequence [v3]

Xiaolin Zheng xlinzheng at openjdk.java.net
Tue Mar 29 08:53:16 UTC 2022


> Hi team,
> 
> Could I have a review of this simple patch? -
> 
> `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; `stop()` also 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 the fastdebug build by adding one line:
> 
> 
> // 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);
> %}
> 
> 
> This patch also fixes a typo introduced in JDK-8278994: `c_bnez` is mistakenly written to `c_beqz`, though not used until now, needing a fix for future usage.
> 
> 
> Tests passed in hotspot tier1 & jdk tier1 without new errors found.
> 
> Thanks,
> Xiaolin

Xiaolin Zheng has updated the pull request incrementally with one additional commit since the last revision:

  Polish comments as the suggestion

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7982/files
  - new: https://git.openjdk.java.net/jdk/pull/7982/files/f3549b81..1106943d

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7982&range=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7982&range=01-02

  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7982.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7982/head:pull/7982

PR: https://git.openjdk.java.net/jdk/pull/7982


More information about the hotspot-compiler-dev mailing list