RFR: 8261731: shallow copy the internal buffer of a scalar-replaced java.lang.String object

Tobias Hartmann thartmann at openjdk.java.net
Thu Mar 4 07:50:39 UTC 2021


On Wed, 3 Mar 2021 18:31:19 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> Hi Xin,
>> when building a fastdebug build of your latest changes I got a crash because of an assertion in your new code.
>> I've attached the hs_err and replay file. After restarting the build it succeeded so there must have been a special situation. Hopefully the replay file can help you to reproduce the error.
>> 
>> Best regards,
>> Volker
>> 
>> [hs_err_pid18140.log](https://github.com/openjdk/jdk/files/6075724/hs_err_pid18140.log)
>> [replay_pid18140.log](https://github.com/openjdk/jdk/files/6075725/replay_pid18140.log)
>
>> Hi Xin,
>> when building a fastdebug build of your latest changes I got a crash because of an assertion in your new code.
>> I've attached the hs_err and replay file. After restarting the build it succeeded so there must have been a special situation. Hopefully the replay file can help you to reproduce the error.
>> 
>> Best regards,
>> Volker
>> 
>> [hs_err_pid18140.log](https://github.com/openjdk/jdk/files/6075724/hs_err_pid18140.log)
>> [replay_pid18140.log](https://github.com/openjdk/jdk/files/6075725/replay_pid18140.log)
> 
> hi, Volker, 
> thank you for using this patch. 
> Yes, indeed, it's a bug. I introduced yesterday, I got a silly typo for the AddP nodes.  I need to use else if instead of else. 
> in your replay file, optimization met a special node StrEquals. I have handled it above. 
> diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp
> index 56dab5c6449..76e97087fd9 100644
> --- a/src/hotspot/share/opto/macro.cpp
> +++ b/src/hotspot/share/opto/macro.cpp
> @@ -1372,7 +1372,7 @@ void PhaseMacroExpand::process_users_of_string_allocation(AllocateArrayNode* all
>              if (n->in(3) == use) { // str2
>                _igvn.replace_input_of(n, 3, dst_adr);
>              }
> -          } if (n->is_AddP()) {
> +          } else if (n->is_AddP()) {
>              // Skip second AddP. This node must be handled by the upper level.
>            } else {
>              assert(n->Opcode() == Op_LoadUB || n->Opcode() == Op_LoadB, "unknow code shape");
> I will fix soon.

I didn't look at the code yet but run this through some quick testing. The following tests fail with `-ea -esa -XX:CompileThreshold=100:`
- compiler/codecache/stress/RandomAllocationTest.java
- compiler/codecache/stress/UnexpectedDeoptimizationTest.java
#  Internal Error (open/src/hotspot/share/opto/node.hpp:825), pid=27269, tid=27288
#  assert(is_AllocateArray()) failed: invalid node class: IfTrue

Current CompileTask:
C2:  12403 2987       4       java.lang.Class::descriptorString (160 bytes)

Stack: [0x00007fc080bfc000,0x00007fc080cfd000],  sp=0x00007fc080cf8340,  free space=1008k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x1302c8c]  PhaseMacroExpand::scalar_replacement(AllocateNode*, GrowableArray<SafePointNode*>&)+0x88c
V  [libjvm.so+0x1303e5e]  PhaseMacroExpand::eliminate_allocate_node(AllocateNode*) [clone .part.0]+0x50e
V  [libjvm.so+0x130447c]  PhaseMacroExpand::eliminate_macro_nodes()+0x57c
V  [libjvm.so+0xa0fbb5]  Compile::Optimize()+0x1235
V  [libjvm.so+0xa11c85]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, DirectiveSet*)+0x1905
V  [libjvm.so+0x83d69a]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1ea
V  [libjvm.so+0xa21aa1]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xf21
V  [libjvm.so+0xa22748]  CompileBroker::compiler_thread_loop()+0x5a8
V  [libjvm.so+0x18488e1]  JavaThread::thread_main_inner()+0x271
V  [libjvm.so+0x1850b30]  Thread::call_run()+0x100
V  [libjvm.so+0x153b086]  thread_native_entry(Thread*)+0x116

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

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


More information about the hotspot-compiler-dev mailing list