mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8155046: Parse::Block construction using undefined behavior
Blocks should be created via constructor and placement new. Reviewed-by: kvn
This commit is contained in:
parent
bc9236dd30
commit
d1cfec7f7e
2 changed files with 13 additions and 12 deletions
|
@ -166,14 +166,11 @@ class Parse : public GraphKit {
|
||||||
int _all_successors; // Include exception paths also.
|
int _all_successors; // Include exception paths also.
|
||||||
Block** _successors;
|
Block** _successors;
|
||||||
|
|
||||||
// Use init_node/init_graph to initialize Blocks.
|
|
||||||
// Block() : _live_locals((uintptr_t*)NULL,0) { ShouldNotReachHere(); }
|
|
||||||
Block() : _live_locals() { ShouldNotReachHere(); }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Set up the block data structure itself.
|
// Set up the block data structure itself.
|
||||||
void init_node(Parse* outer, int po);
|
Block(Parse* outer, int rpo);
|
||||||
|
|
||||||
// Set up the block's relations to other blocks.
|
// Set up the block's relations to other blocks.
|
||||||
void init_graph(Parse* outer);
|
void init_graph(Parse* outer);
|
||||||
|
|
||||||
|
|
|
@ -1235,29 +1235,33 @@ void Parse::init_blocks() {
|
||||||
// Create the blocks.
|
// Create the blocks.
|
||||||
_block_count = flow()->block_count();
|
_block_count = flow()->block_count();
|
||||||
_blocks = NEW_RESOURCE_ARRAY(Block, _block_count);
|
_blocks = NEW_RESOURCE_ARRAY(Block, _block_count);
|
||||||
Copy::zero_to_bytes(_blocks, sizeof(Block)*_block_count);
|
|
||||||
|
|
||||||
int rpo;
|
|
||||||
|
|
||||||
// Initialize the structs.
|
// Initialize the structs.
|
||||||
for (rpo = 0; rpo < block_count(); rpo++) {
|
for (int rpo = 0; rpo < block_count(); rpo++) {
|
||||||
Block* block = rpo_at(rpo);
|
Block* block = rpo_at(rpo);
|
||||||
block->init_node(this, rpo);
|
new(block) Block(this, rpo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect predecessor and successor information.
|
// Collect predecessor and successor information.
|
||||||
for (rpo = 0; rpo < block_count(); rpo++) {
|
for (int rpo = 0; rpo < block_count(); rpo++) {
|
||||||
Block* block = rpo_at(rpo);
|
Block* block = rpo_at(rpo);
|
||||||
block->init_graph(this);
|
block->init_graph(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------init_node-------------------------------------
|
//-------------------------------init_node-------------------------------------
|
||||||
void Parse::Block::init_node(Parse* outer, int rpo) {
|
Parse::Block::Block(Parse* outer, int rpo) : _live_locals() {
|
||||||
_flow = outer->flow()->rpo_at(rpo);
|
_flow = outer->flow()->rpo_at(rpo);
|
||||||
_pred_count = 0;
|
_pred_count = 0;
|
||||||
_preds_parsed = 0;
|
_preds_parsed = 0;
|
||||||
_count = 0;
|
_count = 0;
|
||||||
|
_is_parsed = false;
|
||||||
|
_is_handler = false;
|
||||||
|
_has_merged_backedge = false;
|
||||||
|
_start_map = NULL;
|
||||||
|
_num_successors = 0;
|
||||||
|
_all_successors = 0;
|
||||||
|
_successors = NULL;
|
||||||
assert(pred_count() == 0 && preds_parsed() == 0, "sanity");
|
assert(pred_count() == 0 && preds_parsed() == 0, "sanity");
|
||||||
assert(!(is_merged() || is_parsed() || is_handler() || has_merged_backedge()), "sanity");
|
assert(!(is_merged() || is_parsed() || is_handler() || has_merged_backedge()), "sanity");
|
||||||
assert(_live_locals.size() == 0, "sanity");
|
assert(_live_locals.size() == 0, "sanity");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue