47 // Split the block spanning bci into two separate ranges. The former |
47 // Split the block spanning bci into two separate ranges. The former |
48 // block becomes the second half and a new range is created for the |
48 // block becomes the second half and a new range is created for the |
49 // first half. Returns the range beginning at bci. |
49 // first half. Returns the range beginning at bci. |
50 ciBlock *ciMethodBlocks::split_block_at(int bci) { |
50 ciBlock *ciMethodBlocks::split_block_at(int bci) { |
51 ciBlock *former_block = block_containing(bci); |
51 ciBlock *former_block = block_containing(bci); |
52 ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, this, former_block->start_bci()); |
52 ciBlock *new_block = new(_arena) ciBlock(_method, _num_blocks++, former_block->start_bci()); |
53 _blocks->append(new_block); |
53 _blocks->append(new_block); |
54 assert(former_block != NULL, "must not be NULL"); |
54 assert(former_block != NULL, "must not be NULL"); |
55 new_block->set_limit_bci(bci); |
55 new_block->set_limit_bci(bci); |
56 former_block->set_start_bci(bci); |
56 former_block->set_start_bci(bci); |
57 for (int pos=bci-1; pos >= 0; pos--) { |
57 for (int pos=bci-1; pos >= 0; pos--) { |
81 ciBlock *ciMethodBlocks::make_block_at(int bci) { |
81 ciBlock *ciMethodBlocks::make_block_at(int bci) { |
82 ciBlock *cb = block_containing(bci); |
82 ciBlock *cb = block_containing(bci); |
83 if (cb == NULL ) { |
83 if (cb == NULL ) { |
84 // This is our first time visiting this bytecode. Create |
84 // This is our first time visiting this bytecode. Create |
85 // a fresh block and assign it this starting point. |
85 // a fresh block and assign it this starting point. |
86 ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, this, bci); |
86 ciBlock *nb = new(_arena) ciBlock(_method, _num_blocks++, bci); |
87 _blocks->append(nb); |
87 _blocks->append(nb); |
88 _bci_to_block[bci] = nb; |
88 _bci_to_block[bci] = nb; |
89 return nb; |
89 return nb; |
90 } else if (cb->start_bci() == bci) { |
90 } else if (cb->start_bci() == bci) { |
91 // The block begins at bci. Simply return it. |
91 // The block begins at bci. Simply return it. |
94 // We have already created a block containing bci but |
94 // We have already created a block containing bci but |
95 // not starting at bci. This existing block needs to |
95 // not starting at bci. This existing block needs to |
96 // be split into two. |
96 // be split into two. |
97 return split_block_at(bci); |
97 return split_block_at(bci); |
98 } |
98 } |
|
99 } |
|
100 |
|
101 ciBlock *ciMethodBlocks::make_dummy_block() { |
|
102 ciBlock *dum = new(_arena) ciBlock(_method, -1, 0); |
|
103 return dum; |
99 } |
104 } |
100 |
105 |
101 void ciMethodBlocks::do_analysis() { |
106 void ciMethodBlocks::do_analysis() { |
102 ciBytecodeStream s(_method); |
107 ciBytecodeStream s(_method); |
103 ciBlock *cur_block = block_containing(0); |
108 ciBlock *cur_block = block_containing(0); |
251 int b2bsize = _code_size * sizeof(ciBlock **); |
256 int b2bsize = _code_size * sizeof(ciBlock **); |
252 _bci_to_block = (ciBlock **) arena->Amalloc(b2bsize); |
257 _bci_to_block = (ciBlock **) arena->Amalloc(b2bsize); |
253 Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord)); |
258 Copy::zero_to_words((HeapWord*) _bci_to_block, b2bsize / sizeof(HeapWord)); |
254 |
259 |
255 // create initial block covering the entire method |
260 // create initial block covering the entire method |
256 ciBlock *b = new(arena) ciBlock(_method, _num_blocks++, this, 0); |
261 ciBlock *b = new(arena) ciBlock(_method, _num_blocks++, 0); |
257 _blocks->append(b); |
262 _blocks->append(b); |
258 _bci_to_block[0] = b; |
263 _bci_to_block[0] = b; |
259 |
264 |
260 // create blocks for exception handlers |
265 // create blocks for exception handlers |
261 if (meth->has_exception_handlers()) { |
266 if (meth->has_exception_handlers()) { |
332 } |
337 } |
333 } |
338 } |
334 #endif |
339 #endif |
335 |
340 |
336 |
341 |
337 ciBlock::ciBlock(ciMethod *method, int index, ciMethodBlocks *mb, int start_bci) : |
342 ciBlock::ciBlock(ciMethod *method, int index, int start_bci) : |
338 #ifndef PRODUCT |
343 #ifndef PRODUCT |
339 _method(method), |
344 _method(method), |
340 #endif |
345 #endif |
341 _idx(index), _flags(0), _start_bci(start_bci), _limit_bci(-1), _control_bci(fall_through_bci), |
346 _idx(index), _flags(0), _start_bci(start_bci), _limit_bci(-1), _control_bci(fall_through_bci), |
342 _ex_start_bci(-1), _ex_limit_bci(-1) { |
347 _ex_start_bci(-1), _ex_limit_bci(-1) { |