@@ -47,7 +47,8 @@ void MMTkBarrierSetC2::expand_allocate(PhaseMacroExpand* x,
47
47
AllocateNode* alloc, // allocation node to be expanded
48
48
Node* length, // array length for an array allocation
49
49
const TypeFunc* slow_call_type, // Type of slow call
50
- address slow_call_address) { // Address of slow call
50
+ address slow_call_address,
51
+ Node* valid_length_test) { // Address of slow call
51
52
Node* ctrl = alloc->in (TypeFunc::Control);
52
53
Node* mem = alloc->in (TypeFunc::Memory);
53
54
Node* i_o = alloc->in (TypeFunc::I_O);
@@ -465,6 +466,12 @@ void MMTkBarrierSetC2::expand_allocate(PhaseMacroExpand* x,
465
466
// Copy debug information and adjust JVMState information, then replace
466
467
// allocate node with the call
467
468
call->copy_call_debug_info (&(x->_igvn ), (SafePointNode*) alloc);
469
+ // For array allocations, copy the valid length check to the call node so Compile::final_graph_reshaping() can verify
470
+ // that the call has the expected number of CatchProj nodes (in case the allocation always fails and the fallthrough
471
+ // path dies).
472
+ if (valid_length_test != NULL ) {
473
+ call->add_req (valid_length_test);
474
+ }
468
475
if (!always_slow) {
469
476
call->set_cnt (PROB_UNLIKELY_MAG (4 )); // Same effect as RC_UNCOMMON.
470
477
} else {
0 commit comments