961 |
961 |
962 // Now that we have a bound on the depth of the monitor stack, we can |
962 // Now that we have a bound on the depth of the monitor stack, we can |
963 // initialize the CellTypeState-related information. |
963 // initialize the CellTypeState-related information. |
964 init_state(); |
964 init_state(); |
965 |
965 |
966 // We allocate space for all state-vectors for all basicblocks in one huge chuck. |
966 // We allocate space for all state-vectors for all basicblocks in one huge |
967 // Then in the next part of the code, we set a pointer in each _basic_block that |
967 // chunk. Then in the next part of the code, we set a pointer in each |
968 // points to each piece. |
968 // _basic_block that points to each piece. |
969 CellTypeState *basicBlockState = NEW_RESOURCE_ARRAY(CellTypeState, bbNo * _state_len); |
969 |
|
970 // The product of bbNo and _state_len can get large if there are lots of |
|
971 // basic blocks and stack/locals/monitors. Need to check to make sure |
|
972 // we don't overflow the capacity of a pointer. |
|
973 if ((unsigned)bbNo > UINTPTR_MAX / sizeof(CellTypeState) / _state_len) { |
|
974 report_error("The amount of memory required to analyze this method " |
|
975 "exceeds addressable range"); |
|
976 return; |
|
977 } |
|
978 |
|
979 CellTypeState *basicBlockState = |
|
980 NEW_RESOURCE_ARRAY(CellTypeState, bbNo * _state_len); |
970 memset(basicBlockState, 0, bbNo * _state_len * sizeof(CellTypeState)); |
981 memset(basicBlockState, 0, bbNo * _state_len * sizeof(CellTypeState)); |
971 |
982 |
972 // Make a pass over the basicblocks and assign their state vectors. |
983 // Make a pass over the basicblocks and assign their state vectors. |
973 for (int blockNum=0; blockNum < bbNo; blockNum++) { |
984 for (int blockNum=0; blockNum < bbNo; blockNum++) { |
974 BasicBlock *bb = _basic_blocks + blockNum; |
985 BasicBlock *bb = _basic_blocks + blockNum; |