[jdk18] RFR: 8278413: C2 crash when allocating array of size too large

Nils Eliasson neliasso at openjdk.java.net
Fri Dec 17 14:37:27 UTC 2021


On Thu, 16 Dec 2021 12:32:31 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> src/hotspot/share/opto/cfgnode.cpp line 2700:
>> 
>>> 2698:           Node* valid_length_test = call->in(AllocateNode::ValidLengthTest);
>>> 2699:           const Type* valid_length_test_t = phase->type(valid_length_test);
>>> 2700:           if (valid_length_test_t->isa_int() && valid_length_test_t->is_int()->is_con(0)) {
>> 
>> Here you do: 
>> 
>> Node* valid_length_test = call->in(AllocateNode::ValidLengthTest);
>> const Type* valid_length_test_t = phase->type(valid_length_test);
>> if (valid_length_test_t->isa_int() && valid_length_test_t->is_int()->is_con(0)) {
>> 
>> 
>> But in compile.cpp:3766 you do:
>> 
>> Node* valid_length_test = call->in(call->req());
>> call->rm_prec(call->req());
>> if (valid_length_test->find_int_con(1) == 0) {
>> 
>> 
>> Why "call->req()" and not "call->in(AllocateNode::ValidLengthTest)"?
>> 
>> And why not "if (valid_length_test->find_int_con(1) == 0) {" in both places?
>
>> Here you do:
>> 
>> ```
>> Node* valid_length_test = call->in(AllocateNode::ValidLengthTest);
>> const Type* valid_length_test_t = phase->type(valid_length_test);
>> if (valid_length_test_t->isa_int() && valid_length_test_t->is_int()->is_con(0)) {
>> ```
>> 
>> But in compile.cpp:3766 you do:
>> 
>> ```
>> Node* valid_length_test = call->in(call->req());
>> call->rm_prec(call->req());
>> if (valid_length_test->find_int_con(1) == 0) {
>> ```
>> 
>> Why "call->req()" and not "call->in(AllocateNode::ValidLengthTest)"?
> 
> call->in(AllocateNode::ValidLengthTest) only works for allocateArrayNode. The code I modified in compile.cpp runs after macro expansion so there's no AllocateArrayNode anymore. Instead there's a call to the runtime. When the AllocateArrayNode is macro expanded I move in(AllocateNode::ValidLengthTest) to the new runtime call as a precedence edge that is at req(). I tried adding it as an extra parameter that would be removed in compile.cpp but that messed up debug infos and I hit some asserts.
> 
>> > And why not "if (valid_length_test->find_int_con(1) == 0) {" in both places?
> 
> So`that the Value() call does the right thing during CCP where a node can be registered as a constant but not transformed yet to a ConNode.

That's make sense. Thanks for explaining!

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

PR: https://git.openjdk.java.net/jdk18/pull/30


More information about the hotspot-compiler-dev mailing list